diff --git a/Commands/Fun/ZombieSurvival/CmdAlive.cs b/Commands/Fun/ZombieSurvival/CmdAlive.cs index 2fa1bbb7c..5a73bc870 100644 --- a/Commands/Fun/ZombieSurvival/CmdAlive.cs +++ b/Commands/Fun/ZombieSurvival/CmdAlive.cs @@ -30,15 +30,10 @@ namespace MCGalaxy.Commands { public override void Use(Player p, string message) { Player[] alive = Server.zombie.Alive.Items; - if (alive.Length == 0) { - Player.Message(p, "No one is alive."); return; - } + if (alive.Length == 0) { Player.Message(p, "No one is alive."); return; } - Player.Message(p, "Players who are " + Colors.green + "alive %Sare:"); - string list = ""; - foreach (Player pl in alive) - list = list + pl.group.color + pl.DisplayName + "%S, "; - Player.Message(p, list); + Player.Message(p, "Players who are &2alive %Sare:"); + Player.Message(p, alive.Join(pl => pl.ColoredName + "%S")); } public override void Help(Player p) { diff --git a/Commands/Fun/ZombieSurvival/CmdInfected.cs b/Commands/Fun/ZombieSurvival/CmdInfected.cs index c445feab7..0ab876731 100644 --- a/Commands/Fun/ZombieSurvival/CmdInfected.cs +++ b/Commands/Fun/ZombieSurvival/CmdInfected.cs @@ -30,15 +30,10 @@ namespace MCGalaxy.Commands { public override void Use(Player p, string message) { Player[] infected = Server.zombie.Infected.Items; - if (infected.Length == 0) { - Player.Message(p, "No one is infected"); return; - } + if (infected.Length == 0) { Player.Message(p, "No one is infected"); return; } - Player.Message(p, "Players who are " + Colors.red + "infected %Sare:"); - string list = ""; - foreach (Player pl in infected) - list = list + Colors.red + pl.DisplayName + "%S, "; - Player.Message(p, list); + Player.Message(p, "Players who are &cinfected %Sare:"); + Player.Message(p, infected.Join(pl => "&c" + pl.DisplayName + "%S")); } public override void Help(Player p) { diff --git a/Commands/Moderation/CmdJoker.cs b/Commands/Moderation/CmdJoker.cs index 687047618..e618953f4 100644 --- a/Commands/Moderation/CmdJoker.cs +++ b/Commands/Moderation/CmdJoker.cs @@ -16,9 +16,7 @@ permissions and limitations under the Licenses. */ namespace MCGalaxy.Commands { - - public sealed class CmdJoker : Command { - + public sealed class CmdJoker : Command { public override string name { get { return "joker"; } } public override string shortcut { get { return ""; } } public override string type { get { return CommandTypes.Moderation; } } diff --git a/Commands/other/CmdAscend.cs b/Commands/other/CmdAscend.cs index 8b0d14ac1..9eff82326 100644 --- a/Commands/other/CmdAscend.cs +++ b/Commands/other/CmdAscend.cs @@ -27,6 +27,10 @@ namespace MCGalaxy.Commands { public CmdAscend() { } public override void Use(Player p, string message) { + if (Player.IsSuper(p)) { MessageInGameOnly(p); return; } + if (!p.level.CanUseHacks(p)) { + Player.Message(p, "You cannot use /ascend on this map."); return; + } ushort x = (ushort)(p.pos[0] / 32), y = (ushort)(p.pos[1] / 32), z = (ushort)(p.pos[2] / 32); while (y < p.level.Height) { @@ -52,8 +56,11 @@ namespace MCGalaxy.Commands { } public override void Help(Player p) { + string name = Group.findPerm(LevelPermission.Operator).ColoredName; Player.Message(p, "%T/ascend"); Player.Message(p, "%HTeleports you to the first free space above you."); + Player.Message(p, "%H Does not work on maps which have -hax in their motd. " + + "(unless you are {0}%H+ and the motd also has +ophax)", name); } } } diff --git a/Commands/other/CmdDescend.cs b/Commands/other/CmdDescend.cs index e3d5ca361..0ba64366f 100644 --- a/Commands/other/CmdDescend.cs +++ b/Commands/other/CmdDescend.cs @@ -25,6 +25,10 @@ namespace MCGalaxy.Commands { public CmdDescend() { } public override void Use(Player p, string message) { + if (Player.IsSuper(p)) { MessageInGameOnly(p); return; } + if (!p.level.CanUseHacks(p)) { + Player.Message(p, "You cannot use /descend on this map."); return; + } if (p.pos[1] < 51 + 4) { Player.Message(p, "No free spaces found below you."); return; } // Move starting position down half a block since players are a little bit above the ground. ushort x = (ushort)(p.pos[0] / 32), y = (ushort)((p.pos[1] - 51 - 4) / 32), z = (ushort)(p.pos[2] / 32); @@ -54,6 +58,8 @@ namespace MCGalaxy.Commands { public override void Help(Player p) { Player.Message(p, "%T/descend"); Player.Message(p, "%HTeleports you to the first free space below you."); + Player.Message(p, "%H Does not work on maps which have -hax in their motd. " + + "(unless you are {0}%H+ and the motd also has +ophax)", name); } } } diff --git a/Commands/other/CmdFly.cs b/Commands/other/CmdFly.cs index 0873c0589..f6498239a 100644 --- a/Commands/other/CmdFly.cs +++ b/Commands/other/CmdFly.cs @@ -28,13 +28,8 @@ namespace MCGalaxy.Commands { public CmdFly() { } public override void Use(Player p, string message) { - bool serverMotd = p.level == Server.mainLevel || p.level.motd == "ignore"; - string motd = serverMotd ? Server.motd : p.level.motd; - bool noFly = motd.Contains("-hax") || p.level.ctfmode || p.level.CurrentGame() != null; - if (noFly && p.Rank >= LevelPermission.Operator && motd.Contains("+ophax")) - noFly = false; - - if (noFly) { + if (Player.IsSuper(p)) { MessageInGameOnly(p); return; } + if (!p.level.CanUseHacks(p)) { Player.Message(p, "You cannot use /fly on this map."); p.isFlying = false; return; } diff --git a/Levels/Level.cs b/Levels/Level.cs index d8d47816d..a3cf99b5a 100644 --- a/Levels/Level.cs +++ b/Levels/Level.cs @@ -109,6 +109,15 @@ namespace MCGalaxy { CustomBlocks = null; } } + + public bool CanUseHacks(Player p) { + bool serverMotd = p.level == Server.mainLevel || motd == "ignore"; + string realMotd = serverMotd ? Server.motd : motd; + bool noHacks = realMotd.Contains("-hax") || ctfmode || CurrentGame() != null; + if (noHacks && p.Rank >= LevelPermission.Operator && realMotd.Contains("+ophax")) + return true; + return noHacks; + } /// Whether block changes made on this level should be /// saved to the BlockDB and .lvl files. diff --git a/Server/Server.cs b/Server/Server.cs index ac844dccc..ca07015f4 100644 --- a/Server/Server.cs +++ b/Server/Server.cs @@ -373,11 +373,8 @@ namespace MCGalaxy { if (OnSettingsUpdate != null) OnSettingsUpdate(); } - public static string FindColor(string Username) { - foreach (Group grp in Group.GroupList.Where(grp => grp.playerList.Contains(Username))) { - return grp.color; - } - return Group.standard.color; + public static string FindColor(string name) { + return Group.findPlayerGroup(name).color; } } } \ No newline at end of file