diff --git a/Commands/Command.cs b/Commands/Command.cs index fa973559d..87c0f6a2f 100644 --- a/Commands/Command.cs +++ b/Commands/Command.cs @@ -57,6 +57,14 @@ namespace MCGalaxy protected void MessageInGameOnly(Player p) { Player.SendMessage(p, "/" + name + " can only be used in-game."); } + + protected void MessageNeedPerms(Player p, int perm, string action) { + Group grp = Group.findPermInt(perm); + if (grp == null) + Player.SendMessage(p, "Onlys rank with a permission level greater than &a" + perm + "%Scan " + action); + else + Player.SendMessage(p, "Only " + grp.color + grp.name + "%s+ can " + action); + } } public struct CommandPerm { diff --git a/Commands/Economy/CmdEconomy.cs b/Commands/Economy/CmdEconomy.cs index cc92ac80a..92c276def 100644 --- a/Commands/Economy/CmdEconomy.cs +++ b/Commands/Economy/CmdEconomy.cs @@ -43,7 +43,7 @@ namespace MCGalaxy.Commands { void HandleSetup(Player p, string message, string[] args) { if (p != null && (int)p.group.Permission < CommandOtherPerms.GetPerm(this)) { - Player.SendMessage(p, "%cYou are not allowed to use %f/eco setup"); return; + MessageNeedPerms(p, CommandOtherPerms.GetPerm(this), "setup the economy."); return; } switch (args[0].ToLower()) { diff --git a/Commands/Information/CmdNews.cs b/Commands/Information/CmdNews.cs index 1ef663978..6a3904d32 100644 --- a/Commands/Information/CmdNews.cs +++ b/Commands/Information/CmdNews.cs @@ -47,8 +47,7 @@ namespace MCGalaxy.Commands string[] args = message.Split(' '); if (args[0] == "all") { if (p != null && (int)p.group.Permission < CommandOtherPerms.GetPerm(this)) { - Player.SendMessage(p, "You must be at least " + Group.findPermInt(CommandOtherPerms.GetPerm(this)).name + " to send this to all players."); - return; + MessageNeedPerms(p, CommandOtherPerms.GetPerm(this), "to send the server news to all players."); return; } foreach (string line in lines) Player.GlobalMessage(line); diff --git a/Commands/Moderation/CmdReveal.cs b/Commands/Moderation/CmdReveal.cs index 7a953037f..3325c9e32 100644 --- a/Commands/Moderation/CmdReveal.cs +++ b/Commands/Moderation/CmdReveal.cs @@ -43,11 +43,9 @@ namespace MCGalaxy.Commands { } if (parts[0] == "all") { - if (lvl == null) { - Player.SendMessage(p, "Level not found."); return; - } - if (p != null && (int)p.group.Permission < CommandOtherPerms.GetPerm(this)) { - Player.SendMessage(p, "Reserved for " + Group.findPermInt(CommandOtherPerms.GetPerm(this)).name + "+"); return; + if (lvl == null) { Player.SendMessage(p, "Level not found."); return; } + if (p != null && (int)p.group.Permission < CommandOtherPerms.GetPerm(this)) { + MessageNeedPerms(p, CommandOtherPerms.GetPerm(this), "reload all players in a map."); return; } Player[] players = PlayerInfo.Online.Items; diff --git a/Commands/Moderation/CmdZone.cs b/Commands/Moderation/CmdZone.cs index fc9d320c6..af4876d06 100644 --- a/Commands/Moderation/CmdZone.cs +++ b/Commands/Moderation/CmdZone.cs @@ -47,8 +47,7 @@ namespace MCGalaxy.Commands } else if ((int)p.group.Permission < CommandOtherPerms.GetPerm(this, 1)) { - Player.SendMessage(p, "Reserved for " + Group.findPermInt(CommandOtherPerms.GetPerm(this, 1)).name + "+"); - return; + MessageNeedPerms(p, CommandOtherPerms.GetPerm(this, 1), "to delete zones."); return; } if (message.IndexOf(' ') == -1) @@ -80,8 +79,7 @@ namespace MCGalaxy.Commands { if ((int)p.group.Permission < CommandOtherPerms.GetPerm(this, 2)) { - Player.SendMessage(p, "Only a " + Group.findPermInt(CommandOtherPerms.GetPerm(this, 2)).name + "+ may delete all zones at once"); - return; + MessageNeedPerms(p, CommandOtherPerms.GetPerm(this, 2), "to delete all zones."); return; } else { @@ -104,7 +102,7 @@ namespace MCGalaxy.Commands if ((int)p.group.Permission < CommandOtherPerms.GetPerm(this, 3)) { - Player.SendMessage(p, "Setting zones is reserved for " + Group.findPermInt(CommandOtherPerms.GetPerm(this, 3)).name); return; + MessageNeedPerms(p, CommandOtherPerms.GetPerm(this, 3), "to create zones."); return; } if (Group.Find(message.Split(' ')[1]) != null) diff --git a/Commands/World/CmdMap.cs b/Commands/World/CmdMap.cs index e68906c66..37a87e8b4 100644 --- a/Commands/World/CmdMap.cs +++ b/Commands/World/CmdMap.cs @@ -73,8 +73,9 @@ namespace MCGalaxy.Commands else message = message.Substring(message.IndexOf(' ') + 1); } - if (p != null) - if ((int)p.group.Permission < CommandOtherPerms.GetPerm(this)) { Player.SendMessage(p, "Setting map options is reserved to " + Group.findPermInt(CommandOtherPerms.GetPerm(this)).name + "+"); return; } + if (p != null && (int)p.group.Permission < CommandOtherPerms.GetPerm(this)) { + MessageNeedPerms(p, CommandOtherPerms.GetPerm(this, 1), "to set map options."); return; + } string foundStart; if (message.IndexOf(' ') == -1) foundStart = message.ToLower(); diff --git a/Commands/building/CmdUndo.cs b/Commands/building/CmdUndo.cs index 4691f3e18..dac1580fe 100644 --- a/Commands/building/CmdUndo.cs +++ b/Commands/building/CmdUndo.cs @@ -89,8 +89,8 @@ namespace MCGalaxy.Commands if (who.group.Permission > p.group.Permission) { Player.SendMessage(p, "Cannot undo a user of higher or equal rank"); return; } - if ((int)p.group.Permission < CommandOtherPerms.GetPerm(this, 1)) { - Player.SendMessage(p, "Only an " + Group.findPermInt(CommandOtherPerms.GetPerm(this, 1)).name + "+ may undo other people's actions"); return; + if ((int)p.group.Permission < CommandOtherPerms.GetPerm(this)) { + MessageNeedPerms(p, CommandOtherPerms.GetPerm(this), "to undo other players."); return; } } @@ -111,7 +111,7 @@ namespace MCGalaxy.Commands void UndoOfflinePlayer(Player p, long seconds, string whoName) { if (p != null && (int)p.group.Permission < CommandOtherPerms.GetPerm(this)) { - Player.SendMessage(p, "Reserved for " + Group.findPermInt(CommandOtherPerms.GetPerm(this)).name + "+"); return; + MessageNeedPerms(p, CommandOtherPerms.GetPerm(this), "to undo other players."); return; } UndoOfflineDrawOp op = new UndoOfflineDrawOp(); @@ -130,7 +130,7 @@ namespace MCGalaxy.Commands void UndoLevelPhysics(Player p, long seconds) { if (p != null && (int)p.group.Permission < CommandOtherPerms.GetPerm(this, 2)) { - Player.SendMessage(p, "Reserved for " + Group.findPermInt(CommandOtherPerms.GetPerm(this, 2)).name + "+"); return; + MessageNeedPerms(p, CommandOtherPerms.GetPerm(this, 2), "to undo physics."); return; } if (p != null && !p.group.CanExecute("physics")) { Player.SendMessage(p, "You can only undo physics if you can use /physics."); return; diff --git a/Commands/other/CmdBotSet.cs b/Commands/other/CmdBotSet.cs index b2806fd26..23b84d9d1 100644 --- a/Commands/other/CmdBotSet.cs +++ b/Commands/other/CmdBotSet.cs @@ -69,7 +69,9 @@ namespace MCGalaxy.Commands } else if (foundPath == "kill") { - if ((int)p.group.Permission < CommandOtherPerms.GetPerm(this)) { Player.SendMessage(p, "Only a " + Group.findPermInt(CommandOtherPerms.GetPerm(this)).name + "+ may toggle killer instinct."); return; } + if ((int)p.group.Permission < CommandOtherPerms.GetPerm(this)) { + MessageNeedPerms(p, CommandOtherPerms.GetPerm(this), "to toggle bot killer instinct."); return; + } Pb.kill = !Pb.kill; if (p != null) Chat.GlobalChatLevel(p, Pb.color + Pb.name + Server.DefaultColor + "'s kill instinct: " + Pb.kill, false); Server.s.Log(Pb.name + "'s kill instinct: " + Pb.kill); diff --git a/Commands/other/CmdChangeLog.cs b/Commands/other/CmdChangeLog.cs index 9b9d605e2..c18220f17 100644 --- a/Commands/other/CmdChangeLog.cs +++ b/Commands/other/CmdChangeLog.cs @@ -63,8 +63,7 @@ namespace MCGalaxy.Commands { if ((int)p.group.Permission < CommandOtherPerms.GetPerm(this)) { - Player.SendMessage(p, "You must be at least " + Group.findPermInt(CommandOtherPerms.GetPerm(this)).name + " to send the changelog to all players."); - return; + MessageNeedPerms(p, CommandOtherPerms.GetPerm(this), "to send the changelog to all players."); return; } for (int k = 0; k < strArray.Length; k++) { diff --git a/Commands/other/CmdTnt.cs b/Commands/other/CmdTnt.cs index 3efe980c4..31fb3c846 100644 --- a/Commands/other/CmdTnt.cs +++ b/Commands/other/CmdTnt.cs @@ -39,14 +39,14 @@ namespace MCGalaxy.Commands if (!p.allowTnt) { Player.SendMessage(p, "Tnt usage is not allowed at the moment!"); return; } - p.modeType = 0; Player.SendMessage(p, "TNT mode is now &cOFF" + Server.DefaultColor + "."); + p.modeType = 0; Player.SendMessage(p, "TNT mode is now &cOFF%S."); } else if (message.ToLower() == "small" || message == "") { if (!p.allowTnt) { Player.SendMessage(p, "Tnt usage is not allowed at the moment!"); return; } p.modeType = Block.smalltnt; - Player.SendMessage(p, "TNT mode is now &aON" + Server.DefaultColor + "."); + Player.SendMessage(p, "TNT mode is now &aON%S."); } else if (message.ToLower() == "big") { if (!p.allowTnt) { Player.SendMessage(p, "Tnt usage is not allowed at the moment!"); return; @@ -54,9 +54,9 @@ namespace MCGalaxy.Commands if ((int)p.group.Permission >= CommandOtherPerms.GetPerm(this, 1)) { p.modeType = Block.bigtnt; - Player.SendMessage(p, "TNT (Big) mode is now &aON" + Server.DefaultColor + "."); + Player.SendMessage(p, "TNT (Big) mode is now &aON%S."); } else { - Player.SendMessage(p, "This mode is reserved for " + Group.findPermInt(CommandOtherPerms.GetPerm(this, 1)).name + "+"); + MessageNeedPerms(p, CommandOtherPerms.GetPerm(this, 1), "to use big TNT mode."); return; } } else if (message.ToLower() == "nuke") { if (!p.allowTnt) { @@ -65,22 +65,22 @@ namespace MCGalaxy.Commands if ((int)p.group.Permission >= CommandOtherPerms.GetPerm(this, 3)) { p.modeType = Block.nuketnt; - Player.SendMessage(p, "TNT (Nuke) mode is now &aON" + Server.DefaultColor + "."); + Player.SendMessage(p, "TNT (Nuke) mode is now &aON%S."); } else { - Player.SendMessage(p, "This mode is reserved for " + Group.findPermInt(CommandOtherPerms.GetPerm(this, 3)).name + "+"); + MessageNeedPerms(p, CommandOtherPerms.GetPerm(this, 3), "to use nuke TNT mode."); return; } } else if (message.ToLower() == "allow") { if ((int)p.group.Permission >= CommandOtherPerms.GetPerm(this, 2)) { p.allowTnt = true; Player.SendMessage(p, "&cTnt usage has now been enabled!"); } else { - Player.SendMessage(p, "You must be " + Group.findPermInt(CommandOtherPerms.GetPerm(this, 2)).name + "+ to use this command."); + MessageNeedPerms(p, CommandOtherPerms.GetPerm(this, 2), "to allow TNT usage."); return; } return; } else if (message.ToLower() == "disallow") { if ((int)p.group.Permission >= CommandOtherPerms.GetPerm(this, 2)) { p.allowTnt = false; Player.SendMessage(p, "&cTnt usage has now been disabled!"); } else { - Player.SendMessage(p, "You must be " + Group.findPermInt(CommandOtherPerms.GetPerm(this, 2)).name + "+ to use this command."); + MessageNeedPerms(p, CommandOtherPerms.GetPerm(this, 2), "to disallow TNT usage."); return; } return; } else { diff --git a/Commands/other/CmdWarp.cs b/Commands/other/CmdWarp.cs index 86e8f7849..dee1d36e9 100644 --- a/Commands/other/CmdWarp.cs +++ b/Commands/other/CmdWarp.cs @@ -85,7 +85,7 @@ namespace MCGalaxy.Commands } } } - else { Player.SendMessage(p, "You can't use that because you aren't a" + Group.findPermInt(CommandOtherPerms.GetPerm(this, 1)).name + "+"); return; } + else { MessageNeedPerms(p, CommandOtherPerms.GetPerm(this, 1), "to create warps."); return; } } if (par0 == "delete" || par0 == "remove" || par0 == "d" || par0 == "r") @@ -110,7 +110,7 @@ namespace MCGalaxy.Commands } } } - else { Player.SendMessage(p, "You can't use that because you aren't a" + Group.findPermInt(CommandOtherPerms.GetPerm(this, 2)).name + "+"); return; } + else { MessageNeedPerms(p, CommandOtherPerms.GetPerm(this, 2), "to delete warps"); return; } } if (par0 == "move" || par0 == "change" || par0 == "edit" || par0 == "m" || par0 == "e") @@ -136,7 +136,7 @@ namespace MCGalaxy.Commands } } } - else { Player.SendMessage(p, "You can't use that because you aren't a " + Group.findPermInt(CommandOtherPerms.GetPerm(this, 3)).name + "+"); return; } + else { MessageNeedPerms(p, CommandOtherPerms.GetPerm(this, 3), "to move warps."); return; } } else diff --git a/Commands/other/CmdXundo.cs b/Commands/other/CmdXundo.cs index ec0d3e705..a0b80b2dd 100644 --- a/Commands/other/CmdXundo.cs +++ b/Commands/other/CmdXundo.cs @@ -34,9 +34,6 @@ namespace MCGalaxy.Commands if (number != 1) { Help(p); return; } Player who = PlayerInfo.Find(message); - - string error = "You are not allowed to undo this player"; - if (who == null || p == null || !(who.group.Permission >= LevelPermission.Operator && p.group.Permission < LevelPermission.Operator)) { //This executes if who doesn't exist, if who is lower than Operator, or if the user is an op+. @@ -44,7 +41,7 @@ namespace MCGalaxy.Commands Command.all.Find("undo").Use(p, ((who == null) ? message : who.name) + " all"); //Who null check return; } - Player.SendMessage(p, error); + Player.SendMessage(p, "You are not allowed to undo this player"); }