Simplify the checking for 'can use additional perm X' across all commands.

This commit is contained in:
UnknownShadow200 2016-04-03 18:32:20 +10:00
parent 25f6d38a6d
commit 2349a81f79
19 changed files with 111 additions and 162 deletions

View File

@ -105,10 +105,7 @@ namespace MCGalaxy.Commands {
} }
void HandleCreate(Player p, string[] parts) { void HandleCreate(Player p, string[] parts) {
if ((int)p.group.Permission < CommandOtherPerms.GetPerm(this, 1)) { if (!CheckAdditionalPerm(p, 1)) { MessageNeedPerms(p, "can create a chatroom.", 1); return; }
Player.SendMessage(p, "You aren't a high enough rank to create a chatroon.");
return;
}
if (parts.Length <= 1) { if (parts.Length <= 1) {
Player.SendMessage(p, "You need to provide a new chatroom name."); Player.SendMessage(p, "You need to provide a new chatroom name.");
return; return;
@ -129,8 +126,8 @@ namespace MCGalaxy.Commands {
return; return;
} }
string room = parts[1]; string room = parts[1];
bool canDeleteForce = (int)p.group.Permission >= CommandOtherPerms.GetPerm(this, 3); bool canDeleteForce = CheckAdditionalPerm(p, 3);
bool canDelete = (int)p.group.Permission >= CommandOtherPerms.GetPerm(this, 2); bool canDelete = CheckAdditionalPerm(p, 2);
if (!canDelete && !canDeleteForce) { if (!canDelete && !canDeleteForce) {
Player.SendMessage(p, "You aren't a high enough rank to delete a chatroon."); Player.SendMessage(p, "You aren't a high enough rank to delete a chatroon.");
return; return;
@ -173,11 +170,7 @@ namespace MCGalaxy.Commands {
} }
void HandleSpy(Player p, string[] parts) { void HandleSpy(Player p, string[] parts) {
if ((int)p.group.Permission < CommandOtherPerms.GetPerm(this, 4)) { if (!CheckAdditionalPerm(p, 4)) { MessageNeedPerms(p, "can spy on a chatroom.", 4); return; }
Player.SendMessage(p, "You aren't a high enough rank to spy " +
"on a chatroon.");
return;
}
if (parts.Length <= 1) { if (parts.Length <= 1) {
Player.SendMessage(p, "You need to provide a chatroom name to spy on."); Player.SendMessage(p, "You need to provide a chatroom name to spy on.");
return; return;
@ -201,11 +194,7 @@ namespace MCGalaxy.Commands {
} }
void HandleForceJoin(Player p, string[] parts) { void HandleForceJoin(Player p, string[] parts) {
if ((int)p.group.Permission < CommandOtherPerms.GetPerm(this, 5)) { if (!CheckAdditionalPerm(p, 5)) { MessageNeedPerms(p, "can force players to join a chatroom.", 5); return; }
Player.SendMessage(p, "You aren't a high enough rank to force " +
"players to join a chatroon.");
return;
}
if (parts.Length <= 2) { if (parts.Length <= 2) {
Player.SendMessage(p, "You need to provide a player name, then a chatroom name."); Player.SendMessage(p, "You need to provide a player name, then a chatroom name.");
return; return;
@ -235,10 +224,7 @@ namespace MCGalaxy.Commands {
} }
void HandleKick(Player p, string[] parts) { void HandleKick(Player p, string[] parts) {
if ((int)p.group.Permission < CommandOtherPerms.GetPerm(this, 6)) { if (!CheckAdditionalPerm(p, 6)) { MessageNeedPerms(p, "can kick players from a chatroom.", 6); return; }
Player.SendMessage(p, "You aren't a high enough rank to kick someone from a chatroon.");
return;
}
if (parts.Length <= 1) { if (parts.Length <= 1) {
Player.SendMessage(p, "You need to provide a player name."); Player.SendMessage(p, "You need to provide a player name.");
return; return;
@ -261,7 +247,7 @@ namespace MCGalaxy.Commands {
void HandleAll(Player p, string[] parts, string message) { void HandleAll(Player p, string[] parts, string message) {
int length = parts.Length > 1 ? parts[0].Length + 1 : parts[0].Length; int length = parts.Length > 1 ? parts[0].Length + 1 : parts[0].Length;
message = message.Substring( length ); message = message.Substring( length );
if ((int)p.group.Permission >= CommandOtherPerms.GetPerm(this, 7)) { if (CheckAdditionalPerm(p, 7)) {
Chat.GlobalChatRoom(p, message, true); Chat.GlobalChatRoom(p, message, true);
return; return;
} }
@ -296,21 +282,21 @@ namespace MCGalaxy.Commands {
Player.SendMessage(p, "/chatroom join [room] - joins a room"); Player.SendMessage(p, "/chatroom join [room] - joins a room");
Player.SendMessage(p, "/chatroom leave [room] - leaves a room"); Player.SendMessage(p, "/chatroom leave [room] - leaves a room");
if ((int)p.group.Permission >= CommandOtherPerms.GetPerm(this, 1)) if (CheckAdditionalPerm(p, 1))
Player.SendMessage(p, "/chatroom create [room] - creates a new room"); Player.SendMessage(p, "/chatroom create [room] - creates a new room");
if ((int)p.group.Permission >= CommandOtherPerms.GetPerm(this, 3)) if (CheckAdditionalPerm(p, 3))
Player.SendMessage(p, "/chatroom delete [room] - deletes a room"); Player.SendMessage(p, "/chatroom delete [room] - deletes a room");
else if ((int)p.group.Permission >= CommandOtherPerms.GetPerm(this, 2)) else if (CheckAdditionalPerm(p, 2))
Player.SendMessage(p, "/chatroom delete [room] - deletes a room if all people have left"); Player.SendMessage(p, "/chatroom delete [room] - deletes a room only if all people have left");
if ((int)p.group.Permission >= CommandOtherPerms.GetPerm(this, 4)) if (CheckAdditionalPerm(p, 4))
Player.SendMessage(p, "/chatroom spy [room] - spy on a chatroom"); Player.SendMessage(p, "/chatroom spy [room] - spy on a chatroom");
if ((int)p.group.Permission >= CommandOtherPerms.GetPerm(this, 5)) if (CheckAdditionalPerm(p, 5))
Player.SendMessage(p, "/chatroom forcejoin [player] [room] - forces a player to join a room"); Player.SendMessage(p, "/chatroom forcejoin [player] [room] - forces a player to join a room");
if ((int)p.group.Permission >= CommandOtherPerms.GetPerm(this, 6)) if (CheckAdditionalPerm(p, 6))
Player.SendMessage(p, "/chatroom kick [player] - kicks the player from their current room"); Player.SendMessage(p, "/chatroom kick [player] - kicks the player from their current room");
if ((int)p.group.Permission >= CommandOtherPerms.GetPerm(this, 7)) if (CheckAdditionalPerm(p, 7))
Player.SendMessage(p, "/chatroom all [message] - sends a global message to all rooms"); Player.SendMessage(p, "/chatroom all [message] - sends a global message to all rooms");
else else
Player.SendMessage(p, "/chatroom all [message] - sends a global message to all rooms " + Player.SendMessage(p, "/chatroom all [message] - sends a global message to all rooms " +

View File

@ -58,7 +58,12 @@ namespace MCGalaxy
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) { protected bool CheckAdditionalPerm(Player p, int num = 1) {
return p == null || (int)p.group.Permission >= CommandOtherPerms.GetPerm(this, num);
}
protected void MessageNeedPerms(Player p, string action, int num = 1) {
int perm = CommandOtherPerms.GetPerm(this, num)
Group grp = Group.findPermInt(perm); Group grp = Group.findPermInt(perm);
if (grp == null) if (grp == null)
Player.SendMessage(p, "Onlys rank with a permission level greater than &a" + perm + "%Scan " + action); Player.SendMessage(p, "Onlys rank with a permission level greater than &a" + perm + "%Scan " + action);

View File

@ -42,9 +42,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 (!CheckAdditionalPerm(p)) { MessageNeedPerms(p, "can setup the economy."); return; }
MessageNeedPerms(p, CommandOtherPerms.GetPerm(this), "setup the economy."); return;
}
switch (args[0].ToLower()) { switch (args[0].ToLower()) {
case "apply": case "apply":
@ -84,7 +82,7 @@ namespace MCGalaxy.Commands {
public override void Help(Player p) { public override void Help(Player p) {
Player.SendMessage(p, "%cMost commands have been removed from /economy, " + Player.SendMessage(p, "%cMost commands have been removed from /economy, " +
"use the appropriate command from %T/help economy %cinstead."); "use the appropriate command from %T/help economy %cinstead.");
if ((int)p.group.Permission >= CommandOtherPerms.GetPerm(this)) { if (CheckAdditionalPerm(p)) {
Player.SendMessage(p, "%f/eco <type> %e- to setup economy"); Player.SendMessage(p, "%f/eco <type> %e- to setup economy");
Player.SendMessage(p, "%f/eco help %e- get more specific help for setting up the economy"); Player.SendMessage(p, "%f/eco help %e- get more specific help for setting up the economy");
} }

View File

@ -65,7 +65,7 @@ namespace MCGalaxy.Commands {
break; break;
} }
if ((int)p.group.Permission >= CommandOtherPerms.GetPerm(this, 2)) { if (CheckAdditionalPerm(p, 2)) {
switch (cmd) { switch (cmd) {
case "download": case "download":
case "generate": case "generate":
@ -176,7 +176,7 @@ namespace MCGalaxy.Commands {
} }
void HandleRules(Player p, string target) { void HandleRules(Player p, string target) {
bool hasPerm = (int)p.group.Permission >= CommandOtherPerms.GetPerm(this, 1); bool hasPerm = CheckAdditionalPerm(p, 1);
if (target == "" || !hasPerm) { if (target == "" || !hasPerm) {
Player.SendMessage(p, "The aim of the game is to stay alive the longest."); Player.SendMessage(p, "The aim of the game is to stay alive the longest.");
Player.SendMessage(p, "Don't fall in the lava!!"); Player.SendMessage(p, "Don't fall in the lava!!");
@ -359,12 +359,12 @@ namespace MCGalaxy.Commands {
p.SendMessage("/cd goto - goto the countdown map"); p.SendMessage("/cd goto - goto the countdown map");
p.SendMessage("/cd players - view players currently playing"); p.SendMessage("/cd players - view players currently playing");
if ((int)p.group.Permission >= CommandOtherPerms.GetPerm(this, 1)) if (CheckAdditionalPerm(p, 1))
p.SendMessage("/cd rules <all/map/player> - the rules of countdown. with send: all to send to all, map to send to map and have a player's name to send to a player"); p.SendMessage("/cd rules <all/map/player> - the rules of countdown. with send: all to send to all, map to send to map and have a player's name to send to a player");
else else
p.SendMessage("/cd rules - view the rules of countdown"); p.SendMessage("/cd rules - view the rules of countdown");
if ((int)p.group.Permission >= CommandOtherPerms.GetPerm(this, 2)) { if (CheckAdditionalPerm(p, 2)) {
p.SendMessage("/cd generate [width] [height] [length] - generates the countdown map (default size is 32x32x32)"); p.SendMessage("/cd generate [width] [height] [length] - generates the countdown map (default size is 32x32x32)");
p.SendMessage("/cd enable - enable the game"); p.SendMessage("/cd enable - enable the game");
p.SendMessage("/cd disable - disable the game"); p.SendMessage("/cd disable - disable the game");

View File

@ -248,7 +248,7 @@ namespace MCGalaxy.Commands
case "all": case "all":
case "a": case "a":
case "everyone": case "everyone":
if ((int)p.group.Permission >= CommandOtherPerms.GetPerm(this, 1)) if (CheckAdditionalPerm(p))
{ {
Player[] players = PlayerInfo.Online.Items; Player[] players = PlayerInfo.Online.Items;
foreach (Player who in players) foreach (Player who in players)
@ -269,7 +269,7 @@ namespace MCGalaxy.Commands
case "lvl": case "lvl":
case "map": case "map":
case "m": case "m":
if ((int)p.group.Permission >= CommandOtherPerms.GetPerm(this, 1)) if ((CheckAdditionalPerm(p))
{ {
foreach (Player who in p.level.players) foreach (Player who in p.level.players)
{ {
@ -289,7 +289,7 @@ namespace MCGalaxy.Commands
case "pls": case "pls":
case "pl": case "pl":
case "p": case "p":
if ((int)p.group.Permission >= CommandOtherPerms.GetPerm(this, 1)) if CheckAdditionalPerm(p))
{ {
TntWarsGame gm = TntWarsGame.GetTntWarsGame(p); TntWarsGame gm = TntWarsGame.GetTntWarsGame(p);
if (gm == null) if (gm == null)
@ -315,7 +315,7 @@ namespace MCGalaxy.Commands
break; break;
default: default:
if (text[1] != null && (int)p.group.Permission >= CommandOtherPerms.GetPerm(this, 1)) if (text[1] != null && CheckAdditionalPerm(p))
{ {
Player who = PlayerInfo.FindOrShowMatches(p, text[1]); Player who = PlayerInfo.FindOrShowMatches(p, text[1]);
if (who != null) if (who != null)
@ -465,7 +465,7 @@ namespace MCGalaxy.Commands
case "setup": case "setup":
case "s": case "s":
if ((int)p.group.Permission >= CommandOtherPerms.GetPerm(this, 1)) if (CheckAdditionalPerm(p))
{ {
bool justcreated = false; bool justcreated = false;
TntWarsGame it = TntWarsGame.FindFromGameNumber(p.CurrentTntGameNumber); TntWarsGame it = TntWarsGame.FindFromGameNumber(p.CurrentTntGameNumber);
@ -1813,7 +1813,7 @@ namespace MCGalaxy.Commands
Player.SendMessage(p, "/tw scores <top/team/me> - view the top score/team scores/your scores"); Player.SendMessage(p, "/tw scores <top/team/me> - view the top score/team scores/your scores");
Player.SendMessage(p, "/tw players {p} - view the current players in your game"); Player.SendMessage(p, "/tw players {p} - view the current players in your game");
Player.SendMessage(p, "/tw health {hp} - view your currrent amount of health left"); Player.SendMessage(p, "/tw health {hp} - view your currrent amount of health left");
if ((int)p.group.Permission >= CommandOtherPerms.GetPerm(this, 1)) if (CheckAdditionalPerm(p))
{ {
Player.SendMessage(p, "/tw rules <all/level/players/<playername>> - send the rules to yourself, all, your map, all players in your game or to one person!"); Player.SendMessage(p, "/tw rules <all/level/players/<playername>> - send the rules to yourself, all, your map, all players in your game or to one person!");
Player.SendMessage(p, "/tw setup {s} - setup the game (do '/tntwars setup help' for more info!"); Player.SendMessage(p, "/tw setup {s} - setup the game (do '/tntwars setup help' for more info!");

View File

@ -38,8 +38,7 @@ namespace MCGalaxy.Commands {
Player who = p; Player who = p;
if (message != "") { if (message != "") {
if (p != null && (int)p.group.Permission < CommandOtherPerms.GetPerm(this)) { if (!CheckAdditionalPerm(p)) { MessageNeedPerms(p, "can send the FAQ to a player."); return; }
Player.SendMessage(p, "Your rank cannot send the FAQ to other players."); return; }
who = PlayerInfo.FindOrShowMatches(p, message); who = PlayerInfo.FindOrShowMatches(p, message);
if (who == null) return; if (who == null) return;
} }

View File

@ -46,9 +46,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 (!CheckAdditionalPerm(p)) { MessageNeedPerms(p, "can send the server news to all players."); return; }
MessageNeedPerms(p, CommandOtherPerms.GetPerm(this), "to send the server news to all players."); return;
}
foreach (string line in lines) foreach (string line in lines)
Player.GlobalMessage(line); Player.GlobalMessage(line);
return; return;

View File

@ -39,9 +39,7 @@ namespace MCGalaxy.Commands
Player who = p; Player who = p;
if (message != "") { if (message != "") {
if (p != null && (int)p.group.Permission < CommandOtherPerms.GetPerm(this)) { if (!CheckAdditionalPerm(p)) { MessageNeedPerms(p, "can send the rules to a player."); return; }
Player.SendMessage(p, "You can't send /rules to another player."); return;
}
who = PlayerInfo.FindOrShowMatches(p, message); who = PlayerInfo.FindOrShowMatches(p, message);
if (who == null) return; if (who == null) return;
} }
@ -62,7 +60,7 @@ namespace MCGalaxy.Commands
} }
public override void Help(Player p) { public override void Help(Player p) {
if ((int)p.group.Permission >= CommandOtherPerms.GetPerm(this)) { if (CheckAdditionalPerm(p)) {
Player.SendMessage(p, "/rules [player]- Displays server rules to a player."); Player.SendMessage(p, "/rules [player]- Displays server rules to a player.");
Player.SendMessage(p, "If no [player] is given, the rules will be sent to you."); Player.SendMessage(p, "If no [player] is given, the rules will be sent to you.");
} else { } else {

View File

@ -60,7 +60,7 @@ namespace MCGalaxy.Commands
if (who.isDev) Player.SendMessage(p, "> > Player is a &9Developer"); if (who.isDev) Player.SendMessage(p, "> > Player is a &9Developer");
else if (who.isMod) Player.SendMessage(p, "> > Player is a &9MCGalaxy Moderator"); else if (who.isMod) Player.SendMessage(p, "> > Player is a &9MCGalaxy Moderator");
if (p == null || (int)p.group.Permission >= CommandOtherPerms.GetPerm(this)) { if (!CheckAdditionalPerm(p)) return;
string givenIP; string givenIP;
if (Server.bannedIP.Contains(who.ip)) givenIP = "&8" + who.ip + ", which is banned"; if (Server.bannedIP.Contains(who.ip)) givenIP = "&8" + who.ip + ", which is banned";
else givenIP = who.ip; else givenIP = who.ip;
@ -68,7 +68,6 @@ namespace MCGalaxy.Commands
if (Server.useWhitelist&& Server.whiteList.Contains(who.name)) if (Server.useWhitelist&& Server.whiteList.Contains(who.name))
Player.SendMessage(p, "> > Player is &fWhitelisted"); Player.SendMessage(p, "> > Player is &fWhitelisted");
} }
}
public override void Help(Player p) { public override void Help(Player p) {
Player.SendMessage(p, "/whois [player] - Displays information about someone."); Player.SendMessage(p, "/whois [player] - Displays information about someone.");

View File

@ -14,7 +14,7 @@
BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
or implied. See the Licenses for the specific language governing or implied. See the Licenses for the specific language governing
permissions and limitations under the Licenses. permissions and limitations under the Licenses.
*/ */
using System; using System;
using System.Data; using System.Data;
using MCGalaxy.SQL; using MCGalaxy.SQL;
@ -69,14 +69,13 @@ namespace MCGalaxy.Commands
if (Server.Devs.ContainsInsensitive(message)) Player.SendMessage(p, "> > Player is a &9Developer"); if (Server.Devs.ContainsInsensitive(message)) Player.SendMessage(p, "> > Player is a &9Developer");
else if (Server.Mods.ContainsInsensitive(message)) Player.SendMessage(p, "> > Player is a &9MCGalaxy Moderator"); else if (Server.Mods.ContainsInsensitive(message)) Player.SendMessage(p, "> > Player is a &9MCGalaxy Moderator");
if (p == null || (int)p.group.Permission >= CommandOtherPerms.GetPerm(this)) { if (!CheckAdditionalPerm(p)) return;
if (Server.bannedIP.Contains(target.ip)) if (Server.bannedIP.Contains(target.ip))
target.ip = "&8" + target.ip + ", which is banned"; target.ip = "&8" + target.ip + ", which is banned";
Player.SendMessage(p, "> > the IP of " + target.ip); Player.SendMessage(p, "> > the IP of " + target.ip);
if (Server.useWhitelist&& Server.whiteList.Contains(message)) if (Server.useWhitelist&& Server.whiteList.Contains(message))
Player.SendMessage(p, "> > Player is &fWhitelisted"); Player.SendMessage(p, "> > Player is &fWhitelisted");
} }
}
string TotalTime(string time) { string TotalTime(string time) {
TimeSpan value = time.ParseDBTime(); TimeSpan value = time.ParseDBTime();

View File

@ -44,9 +44,7 @@ namespace MCGalaxy.Commands {
if (parts[0] == "all") { if (parts[0] == "all") {
if (lvl == null) { Player.SendMessage(p, "Level not found."); return; } if (lvl == null) { Player.SendMessage(p, "Level not found."); return; }
if (p != null && (int)p.group.Permission < CommandOtherPerms.GetPerm(this)) { if (!CheckAdditionalPerm(p)) { MessageNeedPerms(p, "can reload all players in a map."); return; }
MessageNeedPerms(p, CommandOtherPerms.GetPerm(this), "reload all players in a map."); return;
}
Player[] players = PlayerInfo.Online.Items; Player[] players = PlayerInfo.Online.Items;
foreach (Player who in players) { foreach (Player who in players) {

View File

@ -45,9 +45,9 @@ namespace MCGalaxy.Commands
Player.SendMessage(p, "Place a block where you would like to check for zones."); Player.SendMessage(p, "Place a block where you would like to check for zones.");
return; return;
} }
else if ((int)p.group.Permission < CommandOtherPerms.GetPerm(this, 1)) else if (!CheckAdditionalPerm(p, 1))
{ {
MessageNeedPerms(p, CommandOtherPerms.GetPerm(this, 1), "to delete zones."); return; MessageNeedPerms(p, "can delete zones.", 1); return;
} }
if (message.IndexOf(' ') == -1) if (message.IndexOf(' ') == -1)
@ -77,9 +77,9 @@ namespace MCGalaxy.Commands
if (message.ToLower() == "del all") if (message.ToLower() == "del all")
{ {
if ((int)p.group.Permission < CommandOtherPerms.GetPerm(this, 2)) if (!CheckAdditionalPerm(p, 2))
{ {
MessageNeedPerms(p, CommandOtherPerms.GetPerm(this, 2), "to delete all zones."); return; MessageNeedPerms(p, "can delete all zones.", 2); return;
} }
else else
{ {
@ -100,9 +100,9 @@ namespace MCGalaxy.Commands
} }
if ((int)p.group.Permission < CommandOtherPerms.GetPerm(this, 3)) if (!CheckAdditionalPerm(p, 3))
{ {
MessageNeedPerms(p, CommandOtherPerms.GetPerm(this, 3), "to create zones."); return; MessageNeedPerms(p, "can create zones.", 3); return;
} }
if (Group.Find(message.Split(' ')[1]) != null) if (Group.Find(message.Split(' ')[1]) != null)

View File

@ -72,10 +72,7 @@ namespace MCGalaxy.Commands
if (lvl == null || message.Split(' ')[0].ToLower() == "ps" || message.Split(' ')[0].ToLower() == "rp") lvl = p.level; if (lvl == null || message.Split(' ')[0].ToLower() == "ps" || message.Split(' ')[0].ToLower() == "rp") lvl = p.level;
else message = message.Substring(message.IndexOf(' ') + 1); else message = message.Substring(message.IndexOf(' ') + 1);
} }
if (!CheckAdditionalPerm(p)) { MessageNeedPerms(p, "can set map options."); return; }
if (p != null && (int)p.group.Permission < CommandOtherPerms.GetPerm(this)) {
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,9 +89,7 @@ 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)) { if (!CheckAdditionalPerm(p)) { MessageNeedPerms(p, "can undo other players."); return; }
MessageNeedPerms(p, CommandOtherPerms.GetPerm(this), "to undo other players."); return;
}
} }
UndoOnlineDrawOp op = new UndoOnlineDrawOp(); UndoOnlineDrawOp op = new UndoOnlineDrawOp();
@ -110,10 +108,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 (!CheckAdditionalPerm(p)) { MessageNeedPerms(p, "can undo other players."); return; }
MessageNeedPerms(p, CommandOtherPerms.GetPerm(this), "to undo other players."); return;
}
UndoOfflineDrawOp op = new UndoOfflineDrawOp(); UndoOfflineDrawOp op = new UndoOfflineDrawOp();
op.Start = DateTime.UtcNow.AddTicks(-seconds * TimeSpan.TicksPerSecond); op.Start = DateTime.UtcNow.AddTicks(-seconds * TimeSpan.TicksPerSecond);
op.whoName = whoName; op.whoName = whoName;
@ -129,9 +124,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 (!CheckAdditionalPerm(p, 2)) { MessageNeedPerms(p, "can undo physics.", 2); 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,9 +69,7 @@ namespace MCGalaxy.Commands
} }
else if (foundPath == "kill") else if (foundPath == "kill")
{ {
if ((int)p.group.Permission < CommandOtherPerms.GetPerm(this)) { if (CheckAdditionalPerm(p)) { MessageNeedPerms(p, "can toggle a bot's killer instinct."); return; }
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

@ -61,15 +61,11 @@ namespace MCGalaxy.Commands
if (split[0] == "all") if (split[0] == "all")
{ {
if ((int)p.group.Permission < CommandOtherPerms.GetPerm(this)) if (!CheckAdditionalPerm(p)) { MessageNeedPerms(p, "can 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++) for (int k = 0; k < strArray.Length; k++)
{ {
Player.GlobalMessage(strArray[k]); Player.GlobalMessage(strArray[k]);
} }
return; return;
} }
else else
@ -85,7 +81,6 @@ namespace MCGalaxy.Commands
} }
Player.SendMessage(p, "The Changelog was successfully sent to " + player.name + "."); Player.SendMessage(p, "The Changelog was successfully sent to " + player.name + ".");
return; return;
} }
} }

View File

@ -57,9 +57,7 @@ namespace MCGalaxy.Commands {
} }
void HandleList(Player p, string[] args) { void HandleList(Player p, string[] args) {
if ((int)p.group.Permission < CommandOtherPerms.GetPerm(this)) { if (!CheckAdditionalPerm(p)) { MessageNeedPerms(p, "can see the list of reports."); return; }
Player.SendMessage(p, "%cYour rank cannot see the list of reports."); return;
}
bool foundone = false; bool foundone = false;
FileInfo[] fi = new DirectoryInfo("extra/reported").GetFiles("*.txt"); FileInfo[] fi = new DirectoryInfo("extra/reported").GetFiles("*.txt");
@ -82,9 +80,7 @@ namespace MCGalaxy.Commands {
if (args.Length != 2) { if (args.Length != 2) {
Player.SendMessage(p, "You need to provide a player's name."); return; Player.SendMessage(p, "You need to provide a player's name."); return;
} }
if ((int)p.group.Permission < CommandOtherPerms.GetPerm(this)) { if (!CheckAdditionalPerm(p)) { MessageNeedPerms(p, "can view the details of a report."); return; }
Player.SendMessage(p, "%cYour rank cannot view the details of a report."); return;
}
if (!Player.ValidName(args[1])) { if (!Player.ValidName(args[1])) {
Player.SendMessage(p, "\"" + args[1] + "\" is not a valid player name."); return; Player.SendMessage(p, "\"" + args[1] + "\" is not a valid player name."); return;
} }
@ -100,9 +96,7 @@ namespace MCGalaxy.Commands {
if (args.Length != 2) { if (args.Length != 2) {
Player.SendMessage(p, "You need to provide a player's name."); return; Player.SendMessage(p, "You need to provide a player's name."); return;
} }
if ((int)p.group.Permission < CommandOtherPerms.GetPerm(this)) { if (!CheckAdditionalPerm(p)) { MessageNeedPerms(p, "can delete reports."); return; }
Player.SendMessage(p, "%cYour rank cannot delete a report."); return;
}
if (!Player.ValidName(args[1])) { if (!Player.ValidName(args[1])) {
Player.SendMessage(p, "\"" + args[1] + "\" is not a valid player name."); return; Player.SendMessage(p, "\"" + args[1] + "\" is not a valid player name."); return;
} }
@ -122,9 +116,7 @@ namespace MCGalaxy.Commands {
} }
void HandleClear(Player p, string[] args) { void HandleClear(Player p, string[] args) {
if ((int)p.group.Permission < CommandOtherPerms.GetPerm(this)) { if (!CheckAdditionalPerm(p)) { MessageNeedPerms(p, "can clear the list of reports."); return; }
Player.SendMessage(p, "%cYour rank cannot clear the reports list."); return;
}
FileInfo[] fi = new DirectoryInfo("extra/reported").GetFiles("*.txt"); FileInfo[] fi = new DirectoryInfo("extra/reported").GetFiles("*.txt");
foreach (FileInfo file in fi) { foreach (FileInfo file in fi) {
@ -160,7 +152,7 @@ namespace MCGalaxy.Commands {
public override void Help(Player p) { public override void Help(Player p) {
Player.SendMessage(p, "%T/report [Player] [Reason] %H- Reports that player for the given reason."); Player.SendMessage(p, "%T/report [Player] [Reason] %H- Reports that player for the given reason.");
if ((int)p.group.Permission < CommandOtherPerms.GetPerm(this)) return; if (!CheckAdditionalPerm(p)) return;
Player.SendMessage(p, "%T/report list %H- Outputs the list of reported players."); Player.SendMessage(p, "%T/report list %H- Outputs the list of reported players.");
Player.SendMessage(p, "%T/report check [Player] %H- View the report for the given player."); Player.SendMessage(p, "%T/report check [Player] %H- View the report for the given player.");
Player.SendMessage(p, "%T/report delete [Player] %H- Deletes the report for the given player."); Player.SendMessage(p, "%T/report delete [Player] %H- Deletes the report for the given player.");

View File

@ -52,35 +52,35 @@ namespace MCGalaxy.Commands
Player.SendMessage(p, "Tnt usage is not allowed at the moment!"); return; Player.SendMessage(p, "Tnt usage is not allowed at the moment!"); return;
} }
if ((int)p.group.Permission >= CommandOtherPerms.GetPerm(this, 1)) { if (CheckAdditionalPerm(p, 1)) {
p.modeType = Block.bigtnt; p.modeType = Block.bigtnt;
Player.SendMessage(p, "TNT (Big) mode is now &aON%S."); Player.SendMessage(p, "TNT (Big) mode is now &aON%S.");
} else { } else {
MessageNeedPerms(p, CommandOtherPerms.GetPerm(this, 1), "to use big TNT mode."); return; MessageNeedPerms(p, "can use big TNT mode.", 1); return;
} }
} else if (message.ToLower() == "nuke") { } else if (message.ToLower() == "nuke") {
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;
} }
if ((int)p.group.Permission >= CommandOtherPerms.GetPerm(this, 3)) { if (CheckAdditionalPerm(p, 3)) {
p.modeType = Block.nuketnt; p.modeType = Block.nuketnt;
Player.SendMessage(p, "TNT (Nuke) mode is now &aON%S."); Player.SendMessage(p, "TNT (Nuke) mode is now &aON%S.");
} else { } else {
MessageNeedPerms(p, CommandOtherPerms.GetPerm(this, 3), "to use nuke TNT mode."); return; MessageNeedPerms(p, "can use nuke TNT mode.", 3); return;
} }
} else if (message.ToLower() == "allow") { } else if (message.ToLower() == "allow") {
if ((int)p.group.Permission >= CommandOtherPerms.GetPerm(this, 2)) { if (CheckAdditionalPerm(p, 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 {
MessageNeedPerms(p, CommandOtherPerms.GetPerm(this, 2), "to allow TNT usage."); return; MessageNeedPerms(p, "can allow TNT usage.", 2); return;
} }
return; return;
} else if (message.ToLower() == "disallow") { } else if (message.ToLower() == "disallow") {
if ((int)p.group.Permission >= CommandOtherPerms.GetPerm(this, 2)) { if (CheckAdditionalPerm(p, 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 {
MessageNeedPerms(p, CommandOtherPerms.GetPerm(this, 2), "to disallow TNT usage."); return; MessageNeedPerms(p, "can disallow TNT usage.", 2); return;
} }
return; return;
} else { } else {
@ -92,7 +92,7 @@ namespace MCGalaxy.Commands
public override void Help(Player p) { public override void Help(Player p) {
Player.SendMessage(p, "/tnt [small/big/nuke] - Creates exploding TNT (with Physics 3)."); Player.SendMessage(p, "/tnt [small/big/nuke] - Creates exploding TNT (with Physics 3).");
Player.SendMessage(p, "Big and Nuke TNT is reserved for " + Group.findPermInt(CommandOtherPerms.GetPerm(this, 3)).name + "+"); Player.SendMessage(p, "Big and Nuke TNT is reserved for " + Group.findPermInt(CommandOtherPerms.GetPerm(this, 3)).name + "+");
if ((int)p.group.Permission >= CommandOtherPerms.GetPerm(this, 2)) { if (CheckAdditionalPerm(p, 2)) {
Player.SendMessage(p, "/tnt allow - Allows the use of tnt server-wide."); Player.SendMessage(p, "/tnt allow - Allows the use of tnt server-wide.");
Player.SendMessage(p, "/tnt disallow - Disallows the use of tnt server-wide."); Player.SendMessage(p, "/tnt disallow - Disallows the use of tnt server-wide.");
} }

View File

@ -64,7 +64,7 @@ namespace MCGalaxy.Commands
if (par0 == "create" || par0 == "add" || par0 == "c" || par0 == "a") if (par0 == "create" || par0 == "add" || par0 == "c" || par0 == "a")
{ {
if ((int)p.group.Permission >= CommandOtherPerms.GetPerm(this, 1)) if (CheckAdditionalPerm(p, 1))
{ {
if (par1 == null) { Player.SendMessage(p, "You didn't specify a name for the warp!"); return; } if (par1 == null) { Player.SendMessage(p, "You didn't specify a name for the warp!"); return; }
if (Warp.WarpExists(par1)) { Player.SendMessage(p, "Warp has already been created!!"); return; } if (Warp.WarpExists(par1)) { Player.SendMessage(p, "Warp has already been created!!"); return; }
@ -85,12 +85,12 @@ namespace MCGalaxy.Commands
} }
} }
} }
else { MessageNeedPerms(p, CommandOtherPerms.GetPerm(this, 1), "to create warps."); return; } else { MessageNeedPerms(p, "can create warps.", 1); return; }
} }
if (par0 == "delete" || par0 == "remove" || par0 == "d" || par0 == "r") if (par0 == "delete" || par0 == "remove" || par0 == "d" || par0 == "r")
{ {
if ((int)p.group.Permission >= CommandOtherPerms.GetPerm(this, 2)) if (CheckAdditionalPerm(p, 2))
{ {
if (par1 == null) { Player.SendMessage(p, "You didn't specify a warp to delete!"); return; } if (par1 == null) { Player.SendMessage(p, "You didn't specify a warp to delete!"); return; }
if (!Warp.WarpExists(par1)) { Player.SendMessage(p, "Warp doesn't exist!!"); return; } if (!Warp.WarpExists(par1)) { Player.SendMessage(p, "Warp doesn't exist!!"); return; }
@ -110,12 +110,12 @@ namespace MCGalaxy.Commands
} }
} }
} }
else { MessageNeedPerms(p, CommandOtherPerms.GetPerm(this, 2), "to delete warps"); return; } else { MessageNeedPerms(p, "can delete warps.", 2); return; }
} }
if (par0 == "move" || par0 == "change" || par0 == "edit" || par0 == "m" || par0 == "e") if (par0 == "move" || par0 == "change" || par0 == "edit" || par0 == "m" || par0 == "e")
{ {
if ((int)p.group.Permission >= CommandOtherPerms.GetPerm(this, 3)) if (CheckAdditionalPerm(p, 3))
{ {
if (par1 == null) { Player.SendMessage(p, "You didn't specify a warp to be moved!"); return; } if (par1 == null) { Player.SendMessage(p, "You didn't specify a warp to be moved!"); return; }
if (!Warp.WarpExists(par1)) { Player.SendMessage(p, "Warp doesn't exist!!"); return; } if (!Warp.WarpExists(par1)) { Player.SendMessage(p, "Warp doesn't exist!!"); return; }
@ -136,7 +136,7 @@ namespace MCGalaxy.Commands
} }
} }
} }
else { MessageNeedPerms(p, CommandOtherPerms.GetPerm(this, 3), "to move warps."); return; } else { MessageNeedPerms(p, "can move warps.", 3); return; }
} }
else else
@ -173,18 +173,12 @@ namespace MCGalaxy.Commands
{ {
Player.SendMessage(p, "/warp [name] - warp to that warp"); Player.SendMessage(p, "/warp [name] - warp to that warp");
Player.SendMessage(p, "/warp list - list all the warps"); Player.SendMessage(p, "/warp list - list all the warps");
if ((int)p.group.Permission >= CommandOtherPerms.GetPerm(this, 1)) if (CheckAdditionalPerm(p, 1))
{
Player.SendMessage(p, "/warp create [name] <player> - create a warp, if a <player> is given, it will be created where they are"); Player.SendMessage(p, "/warp create [name] <player> - create a warp, if a <player> is given, it will be created where they are");
} if (CheckAdditionalPerm(p, 2))
if ((int)p.group.Permission >= CommandOtherPerms.GetPerm(this, 2))
{
Player.SendMessage(p, "/warp delete [name] - delete a warp"); Player.SendMessage(p, "/warp delete [name] - delete a warp");
} if (CheckAdditionalPerm(p, 3))
if ((int)p.group.Permission >= CommandOtherPerms.GetPerm(this, 3))
{
Player.SendMessage(p, "/warp move [name] <player> - move a warp, if a <player> is given, it will be created where they are"); Player.SendMessage(p, "/warp move [name] <player> - move a warp, if a <player> is given, it will be created where they are");
} }
} }
}
} }