Fix /levels and /unloaded from console.

This commit is contained in:
UnknownShadow200 2016-01-23 22:00:49 +11:00
parent 270e62ac05
commit 8cad8ad507
3 changed files with 42 additions and 69 deletions

View File

@ -1,25 +1,25 @@
/*
Copyright 2012 MCGalaxy
Dual-licensed under the Educational Community License, Version 2.0 and
the GNU General Public License, Version 3 (the "Licenses"); you may
not use this file except in compliance with the Licenses. You may
obtain a copy of the Licenses at
http://www.opensource.org/licenses/ecl2.php
http://www.gnu.org/licenses/gpl-3.0.html
Unless required by applicable law or agreed to in writing,
software distributed under the Licenses are distributed on an "AS IS"
BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
or implied. See the Licenses for the specific language governing
permissions and limitations under the Licenses.
Copyright 2012 MCGalaxy
Dual-licensed under the Educational Community License, Version 2.0 and
the GNU General Public License, Version 3 (the "Licenses"); you may
not use this file except in compliance with the Licenses. You may
obtain a copy of the Licenses at
http://www.opensource.org/licenses/ecl2.php
http://www.gnu.org/licenses/gpl-3.0.html
Unless required by applicable law or agreed to in writing,
software distributed under the Licenses are distributed on an "AS IS"
BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
or implied. See the Licenses for the specific language governing
permissions and limitations under the Licenses.
*/
using System;
namespace MCGalaxy.Commands
{
public sealed class CmdLevels : Command
{
namespace MCGalaxy.Commands {
public sealed class CmdLevels : Command {
public override string name { get { return "levels"; } }
public override string shortcut { get { return "maps"; } }
public override string type { get { return CommandTypes.Information; } }
@ -27,62 +27,35 @@ namespace MCGalaxy.Commands
public override LevelPermission defaultRank { get { return LevelPermission.Guest; } }
public CmdLevels() { }
public override void Use(Player p, string message)
{
try
{
public override void Use(Player p, string message) {
if (message != "") { Help(p); return; }
if (!String.IsNullOrEmpty(message.Trim()))
string canVisit = "", canBuild = "";
Server.levels.ForEach(
(level) =>
{
Help(p);
return;
}
message = "";
string message2 = "";
bool Once = false;
Server.levels.ForEach((level) =>
{
if (p != null && level.permissionvisit <= p.group.Permission)
{
if (p == null || level.permissionvisit <= p.group.Permission) {
if (Group.findPerm(level.permissionbuild) != null)
message += ", " + Group.findPerm(level.permissionbuild).color + level.name + " &b[&f" + level.physics + "&b]";
canVisit += ", " + Group.findPerm(level.permissionbuild).color + level.name + " &b[&f" + level.physics + "&b]";
else
message += ", " + level.name + " &b[" + level.physics + "]";
}
else
{
if (!Once)
{
Once = true;
if (Group.findPerm(level.permissionvisit) != null)
message2 += Group.findPerm(level.permissionvisit).color + level.name + " &b[&f" + level.physics + "&b]";
else
message2 += level.name + " &b[" + level.physics + "]";
}
canVisit += ", " + level.name + " &b[" + level.physics + "]";
} else {
if (Group.findPerm(level.permissionvisit) != null)
canBuild += ", " + Group.findPerm(level.permissionvisit).color + level.name + " &b[&f" + level.physics + "&b]";
else
{
if (Group.findPerm(level.permissionvisit) != null)
message2 += ", " + Group.findPerm(level.permissionvisit).color + level.name + " &b[&f" + level.physics + "&b]";
else
message2 += ", " + level.name + " &b[&f" + level.physics + "&b]";
}
canBuild += ", " + level.name + " &b[&f" + level.physics + "&b]";
}
});
Player.SendMessage(p, "Loaded levels [physics_level]: " + message.Remove(0, 2));
if (message2 != "")
Player.SendMessage(p, "Can't Goto: " + message2);
Player.SendMessage(p, "Use &f/unloaded" + Server.DefaultColor + " for unloaded levels.");
}
catch (Exception e)
{
Server.ErrorLog(e);
}
if (canVisit != "")
canVisit = canVisit.Remove(0, 2);
Player.SendMessage(p, "Loaded levels [physics_level]: " + canVisit);
if (canBuild != "")
Player.SendMessage(p, "Loaded levsl you cannot visit: " + canBuild.Remove(0, 2));
Player.SendMessage(p, "Use &f/unloaded" + Server.DefaultColor + " for unloaded levels.");
}
public override void Help(Player p)
{
public override void Help(Player p) {
Player.SendMessage(p, "%f/levels " + Server.DefaultColor + "- Lists all loaded levels and their physics levels.");
}
}

View File

@ -34,7 +34,6 @@ namespace MCGalaxy.Commands
try
{
List<string> levels = new List<string>(Server.levels.Count);
string unloadedLevels = ""; int currentNum = 0; int maxMaps = 0;
if (message != "")
@ -58,7 +57,7 @@ namespace MCGalaxy.Commands
if (!levels.Contains(file.Name.Replace(".lvl", "").ToLower()))
{
string level = file.Name.Replace(".lvl", "");
string visit = GetLoadOnGoto(level) && p.group.Permission >= GetPerVisitPermission(level) ? "%aYes" : "%cNo";
string visit = GetLoadOnGoto(level) && (p == null || p.group.Permission >= GetPerVisitPermission(level)) ? "%aYes" : "%cNo";
unloadedLevels += ", " + Group.findPerm(GetPerBuildPermission(level)).color + level + " &b[" + visit + "&b]";
}
}
@ -81,7 +80,7 @@ namespace MCGalaxy.Commands
if (!levels.Contains(fi[i].Name.Replace(".lvl", "").ToLower()))
{
string level = fi[i].Name.Replace(".lvl", "");
string visit = GetLoadOnGoto(level) && p.group.Permission >= GetPerVisitPermission(level) ? "%aYes" : "%cNo";
string visit = GetLoadOnGoto(level) && (p == null || p.group.Permission >= GetPerVisitPermission(level)) ? "%aYes" : "%cNo";
unloadedLevels += ", " + Group.findPerm(GetPerBuildPermission(level)).color + level + " &b[" + visit + "&b]";
}
}

View File

@ -21,5 +21,6 @@ namespace MCGalaxy.Games {
public abstract class IGame {
}
}