Make all 'you need additional perm X' messages consistent.

This commit is contained in:
UnknownShadow200 2016-04-03 18:03:25 +10:00
parent bfba394433
commit 25f6d38a6d
12 changed files with 39 additions and 37 deletions

View File

@ -57,6 +57,14 @@ namespace MCGalaxy
protected void MessageInGameOnly(Player p) { protected void MessageInGameOnly(Player p) {
Player.SendMessage(p, "/" + name + " can only be used in-game."); 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 { public struct CommandPerm {

View File

@ -43,7 +43,7 @@ namespace MCGalaxy.Commands {
void HandleSetup(Player p, string message, string[] args) { void HandleSetup(Player p, string message, string[] args) {
if (p != null && (int)p.group.Permission < CommandOtherPerms.GetPerm(this)) { 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()) { switch (args[0].ToLower()) {

View File

@ -47,8 +47,7 @@ namespace MCGalaxy.Commands
string[] args = message.Split(' '); string[] args = message.Split(' ');
if (args[0] == "all") { if (args[0] == "all") {
if (p != null && (int)p.group.Permission < CommandOtherPerms.GetPerm(this)) { 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."); MessageNeedPerms(p, CommandOtherPerms.GetPerm(this), "to send the server news to all players."); return;
return;
} }
foreach (string line in lines) foreach (string line in lines)
Player.GlobalMessage(line); Player.GlobalMessage(line);

View File

@ -43,11 +43,9 @@ namespace MCGalaxy.Commands {
} }
if (parts[0] == "all") { if (parts[0] == "all") {
if (lvl == null) { if (lvl == null) { Player.SendMessage(p, "Level not found."); return; }
Player.SendMessage(p, "Level not found."); return;
}
if (p != null && (int)p.group.Permission < CommandOtherPerms.GetPerm(this)) { 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), "reload all players in a map."); return;
} }
Player[] players = PlayerInfo.Online.Items; Player[] players = PlayerInfo.Online.Items;

View File

@ -47,8 +47,7 @@ namespace MCGalaxy.Commands
} }
else if ((int)p.group.Permission < CommandOtherPerms.GetPerm(this, 1)) else if ((int)p.group.Permission < CommandOtherPerms.GetPerm(this, 1))
{ {
Player.SendMessage(p, "Reserved for " + Group.findPermInt(CommandOtherPerms.GetPerm(this, 1)).name + "+"); MessageNeedPerms(p, CommandOtherPerms.GetPerm(this, 1), "to delete zones."); return;
return;
} }
if (message.IndexOf(' ') == -1) if (message.IndexOf(' ') == -1)
@ -80,8 +79,7 @@ namespace MCGalaxy.Commands
{ {
if ((int)p.group.Permission < CommandOtherPerms.GetPerm(this, 2)) 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"); MessageNeedPerms(p, CommandOtherPerms.GetPerm(this, 2), "to delete all zones."); return;
return;
} }
else else
{ {
@ -104,7 +102,7 @@ namespace MCGalaxy.Commands
if ((int)p.group.Permission < CommandOtherPerms.GetPerm(this, 3)) 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) if (Group.Find(message.Split(' ')[1]) != null)

View File

@ -73,8 +73,9 @@ namespace MCGalaxy.Commands
else message = message.Substring(message.IndexOf(' ') + 1); else message = message.Substring(message.IndexOf(' ') + 1);
} }
if (p != null) if (p != null && (int)p.group.Permission < CommandOtherPerms.GetPerm(this)) {
if ((int)p.group.Permission < CommandOtherPerms.GetPerm(this)) { Player.SendMessage(p, "Setting map options is reserved to " + Group.findPermInt(CommandOtherPerms.GetPerm(this)).name + "+"); return; } MessageNeedPerms(p, CommandOtherPerms.GetPerm(this, 1), "to set map options."); return;
}
string foundStart; string foundStart;
if (message.IndexOf(' ') == -1) foundStart = message.ToLower(); if (message.IndexOf(' ') == -1) foundStart = message.ToLower();

View File

@ -89,8 +89,8 @@ namespace MCGalaxy.Commands
if (who.group.Permission > p.group.Permission) { if (who.group.Permission > p.group.Permission) {
Player.SendMessage(p, "Cannot undo a user of higher or equal rank"); return; Player.SendMessage(p, "Cannot undo a user of higher or equal rank"); return;
} }
if ((int)p.group.Permission < CommandOtherPerms.GetPerm(this, 1)) { if ((int)p.group.Permission < CommandOtherPerms.GetPerm(this)) {
Player.SendMessage(p, "Only an " + Group.findPermInt(CommandOtherPerms.GetPerm(this, 1)).name + "+ may undo other people's actions"); return; 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) { void UndoOfflinePlayer(Player p, long seconds, string whoName) {
if (p != null && (int)p.group.Permission < CommandOtherPerms.GetPerm(this)) { 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(); UndoOfflineDrawOp op = new UndoOfflineDrawOp();
@ -130,7 +130,7 @@ namespace MCGalaxy.Commands
void UndoLevelPhysics(Player p, long seconds) { void UndoLevelPhysics(Player p, long seconds) {
if (p != null && (int)p.group.Permission < CommandOtherPerms.GetPerm(this, 2)) { 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")) { if (p != null && !p.group.CanExecute("physics")) {
Player.SendMessage(p, "You can only undo physics if you can use /physics."); return; Player.SendMessage(p, "You can only undo physics if you can use /physics."); return;

View File

@ -69,7 +69,9 @@ namespace MCGalaxy.Commands
} }
else if (foundPath == "kill") 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; Pb.kill = !Pb.kill;
if (p != null) Chat.GlobalChatLevel(p, Pb.color + Pb.name + Server.DefaultColor + "'s kill instinct: " + Pb.kill, false); 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); Server.s.Log(Pb.name + "'s kill instinct: " + Pb.kill);

View File

@ -63,8 +63,7 @@ namespace MCGalaxy.Commands
{ {
if ((int)p.group.Permission < CommandOtherPerms.GetPerm(this)) 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."); MessageNeedPerms(p, CommandOtherPerms.GetPerm(this), "to send the changelog to all players."); return;
return;
} }
for (int k = 0; k < strArray.Length; k++) for (int k = 0; k < strArray.Length; k++)
{ {

View File

@ -39,14 +39,14 @@ namespace MCGalaxy.Commands
if (!p.allowTnt) { if (!p.allowTnt) {
Player.SendMessage(p, "Tnt usage is not allowed at the moment!"); return; 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 == "") { } else if (message.ToLower() == "small" || message == "") {
if (!p.allowTnt) { if (!p.allowTnt) {
Player.SendMessage(p, "Tnt usage is not allowed at the moment!"); return; Player.SendMessage(p, "Tnt usage is not allowed at the moment!"); return;
} }
p.modeType = Block.smalltnt; 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") { } else if (message.ToLower() == "big") {
if (!p.allowTnt) { if (!p.allowTnt) {
Player.SendMessage(p, "Tnt usage is not allowed at the moment!"); return; 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)) { if ((int)p.group.Permission >= CommandOtherPerms.GetPerm(this, 1)) {
p.modeType = Block.bigtnt; 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 { } 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") { } else if (message.ToLower() == "nuke") {
if (!p.allowTnt) { if (!p.allowTnt) {
@ -65,22 +65,22 @@ namespace MCGalaxy.Commands
if ((int)p.group.Permission >= CommandOtherPerms.GetPerm(this, 3)) { if ((int)p.group.Permission >= CommandOtherPerms.GetPerm(this, 3)) {
p.modeType = Block.nuketnt; 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 { } 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") { } else if (message.ToLower() == "allow") {
if ((int)p.group.Permission >= CommandOtherPerms.GetPerm(this, 2)) { if ((int)p.group.Permission >= CommandOtherPerms.GetPerm(this, 2)) {
p.allowTnt = true; Player.SendMessage(p, "&cTnt usage has now been enabled!"); p.allowTnt = true; Player.SendMessage(p, "&cTnt usage has now been enabled!");
} else { } 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; return;
} else if (message.ToLower() == "disallow") { } else if (message.ToLower() == "disallow") {
if ((int)p.group.Permission >= CommandOtherPerms.GetPerm(this, 2)) { if ((int)p.group.Permission >= CommandOtherPerms.GetPerm(this, 2)) {
p.allowTnt = false; Player.SendMessage(p, "&cTnt usage has now been disabled!"); p.allowTnt = false; Player.SendMessage(p, "&cTnt usage has now been disabled!");
} else { } 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; return;
} else { } else {

View File

@ -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") 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") 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 else

View File

@ -34,9 +34,6 @@ namespace MCGalaxy.Commands
if (number != 1) { Help(p); return; } if (number != 1) { Help(p); return; }
Player who = PlayerInfo.Find(message); 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)) 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+. //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 Command.all.Find("undo").Use(p, ((who == null) ? message : who.name) + " all"); //Who null check
return; return;
} }
Player.SendMessage(p, error); Player.SendMessage(p, "You are not allowed to undo this player");
} }