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) {
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 {

View File

@ -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()) {

View File

@ -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);

View File

@ -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;

View File

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

View File

@ -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();

View File

@ -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;

View File

@ -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);

View File

@ -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++)
{

View File

@ -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 {

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

View File

@ -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");
}