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) {
if ((int)p.group.Permission < CommandOtherPerms.GetPerm(this, 1)) {
Player.SendMessage(p, "You aren't a high enough rank to create a chatroon.");
return;
}
if (!CheckAdditionalPerm(p, 1)) { MessageNeedPerms(p, "can create a chatroom.", 1); return; }
if (parts.Length <= 1) {
Player.SendMessage(p, "You need to provide a new chatroom name.");
return;
@ -129,8 +126,8 @@ namespace MCGalaxy.Commands {
return;
}
string room = parts[1];
bool canDeleteForce = (int)p.group.Permission >= CommandOtherPerms.GetPerm(this, 3);
bool canDelete = (int)p.group.Permission >= CommandOtherPerms.GetPerm(this, 2);
bool canDeleteForce = CheckAdditionalPerm(p, 3);
bool canDelete = CheckAdditionalPerm(p, 2);
if (!canDelete && !canDeleteForce) {
Player.SendMessage(p, "You aren't a high enough rank to delete a chatroon.");
return;
@ -173,11 +170,7 @@ namespace MCGalaxy.Commands {
}
void HandleSpy(Player p, string[] parts) {
if ((int)p.group.Permission < CommandOtherPerms.GetPerm(this, 4)) {
Player.SendMessage(p, "You aren't a high enough rank to spy " +
"on a chatroon.");
return;
}
if (!CheckAdditionalPerm(p, 4)) { MessageNeedPerms(p, "can spy on a chatroom.", 4); return; }
if (parts.Length <= 1) {
Player.SendMessage(p, "You need to provide a chatroom name to spy on.");
return;
@ -201,11 +194,7 @@ namespace MCGalaxy.Commands {
}
void HandleForceJoin(Player p, string[] parts) {
if ((int)p.group.Permission < CommandOtherPerms.GetPerm(this, 5)) {
Player.SendMessage(p, "You aren't a high enough rank to force " +
"players to join a chatroon.");
return;
}
if (!CheckAdditionalPerm(p, 5)) { MessageNeedPerms(p, "can force players to join a chatroom.", 5); return; }
if (parts.Length <= 2) {
Player.SendMessage(p, "You need to provide a player name, then a chatroom name.");
return;
@ -235,10 +224,7 @@ namespace MCGalaxy.Commands {
}
void HandleKick(Player p, string[] parts) {
if ((int)p.group.Permission < CommandOtherPerms.GetPerm(this, 6)) {
Player.SendMessage(p, "You aren't a high enough rank to kick someone from a chatroon.");
return;
}
if (!CheckAdditionalPerm(p, 6)) { MessageNeedPerms(p, "can kick players from a chatroom.", 6); return; }
if (parts.Length <= 1) {
Player.SendMessage(p, "You need to provide a player name.");
return;
@ -261,7 +247,7 @@ namespace MCGalaxy.Commands {
void HandleAll(Player p, string[] parts, string message) {
int length = parts.Length > 1 ? parts[0].Length + 1 : parts[0].Length;
message = message.Substring( length );
if ((int)p.group.Permission >= CommandOtherPerms.GetPerm(this, 7)) {
if (CheckAdditionalPerm(p, 7)) {
Chat.GlobalChatRoom(p, message, true);
return;
}
@ -296,21 +282,21 @@ namespace MCGalaxy.Commands {
Player.SendMessage(p, "/chatroom join [room] - joins 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");
if ((int)p.group.Permission >= CommandOtherPerms.GetPerm(this, 3))
if (CheckAdditionalPerm(p, 3))
Player.SendMessage(p, "/chatroom delete [room] - deletes a room");
else if ((int)p.group.Permission >= CommandOtherPerms.GetPerm(this, 2))
Player.SendMessage(p, "/chatroom delete [room] - deletes a room if all people have left");
else if (CheckAdditionalPerm(p, 2))
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");
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");
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");
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");
else
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.");
}
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);
if (grp == null)
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) {
if (p != null && (int)p.group.Permission < CommandOtherPerms.GetPerm(this)) {
MessageNeedPerms(p, CommandOtherPerms.GetPerm(this), "setup the economy."); return;
}
if (!CheckAdditionalPerm(p)) { MessageNeedPerms(p, "can setup the economy."); return; }
switch (args[0].ToLower()) {
case "apply":
@ -84,7 +82,7 @@ namespace MCGalaxy.Commands {
public override void Help(Player p) {
Player.SendMessage(p, "%cMost commands have been removed from /economy, " +
"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 help %e- get more specific help for setting up the economy");
}

View File

@ -65,7 +65,7 @@ namespace MCGalaxy.Commands {
break;
}
if ((int)p.group.Permission >= CommandOtherPerms.GetPerm(this, 2)) {
if (CheckAdditionalPerm(p, 2)) {
switch (cmd) {
case "download":
case "generate":
@ -176,7 +176,7 @@ namespace MCGalaxy.Commands {
}
void HandleRules(Player p, string target) {
bool hasPerm = (int)p.group.Permission >= CommandOtherPerms.GetPerm(this, 1);
bool hasPerm = CheckAdditionalPerm(p, 1);
if (target == "" || !hasPerm) {
Player.SendMessage(p, "The aim of the game is to stay alive the longest.");
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 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");
else
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 enable - enable the game");
p.SendMessage("/cd disable - disable the game");

View File

@ -248,7 +248,7 @@ namespace MCGalaxy.Commands
case "all":
case "a":
case "everyone":
if ((int)p.group.Permission >= CommandOtherPerms.GetPerm(this, 1))
if (CheckAdditionalPerm(p))
{
Player[] players = PlayerInfo.Online.Items;
foreach (Player who in players)
@ -269,7 +269,7 @@ namespace MCGalaxy.Commands
case "lvl":
case "map":
case "m":
if ((int)p.group.Permission >= CommandOtherPerms.GetPerm(this, 1))
if ((CheckAdditionalPerm(p))
{
foreach (Player who in p.level.players)
{
@ -289,7 +289,7 @@ namespace MCGalaxy.Commands
case "pls":
case "pl":
case "p":
if ((int)p.group.Permission >= CommandOtherPerms.GetPerm(this, 1))
if CheckAdditionalPerm(p))
{
TntWarsGame gm = TntWarsGame.GetTntWarsGame(p);
if (gm == null)
@ -315,7 +315,7 @@ namespace MCGalaxy.Commands
break;
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]);
if (who != null)
@ -465,7 +465,7 @@ namespace MCGalaxy.Commands
case "setup":
case "s":
if ((int)p.group.Permission >= CommandOtherPerms.GetPerm(this, 1))
if (CheckAdditionalPerm(p))
{
bool justcreated = false;
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 players {p} - view the current players in your game");
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 setup {s} - setup the game (do '/tntwars setup help' for more info!");

View File

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

View File

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

View File

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

View File

@ -26,7 +26,7 @@ namespace MCGalaxy.Commands
public override bool museumUsable { get { return true; } }
public override LevelPermission defaultRank { get { return LevelPermission.Banned; } }
public override CommandPerm[] AdditionalPerms {
get { return new[] { new CommandPerm(LevelPermission.AdvBuilder, "The lowest rank which can see the target player's ip and if they are whitelisted") }; }
get { return new[] { new CommandPerm(LevelPermission.AdvBuilder, "The lowest rank which can see the target player's ip and if they are whitelisted") }; }
}
public override void Use(Player p, string message) {
@ -60,14 +60,13 @@ namespace MCGalaxy.Commands
if (who.isDev) Player.SendMessage(p, "> > Player is a &9Developer");
else if (who.isMod) Player.SendMessage(p, "> > Player is a &9MCGalaxy Moderator");
if (p == null || (int)p.group.Permission >= CommandOtherPerms.GetPerm(this)) {
string givenIP;
if (Server.bannedIP.Contains(who.ip)) givenIP = "&8" + who.ip + ", which is banned";
else givenIP = who.ip;
Player.SendMessage(p, "> > the IP of " + givenIP);
if (Server.useWhitelist&& Server.whiteList.Contains(who.name))
Player.SendMessage(p, "> > Player is &fWhitelisted");
}
if (!CheckAdditionalPerm(p)) return;
string givenIP;
if (Server.bannedIP.Contains(who.ip)) givenIP = "&8" + who.ip + ", which is banned";
else givenIP = who.ip;
Player.SendMessage(p, "> > the IP of " + givenIP);
if (Server.useWhitelist&& Server.whiteList.Contains(who.name))
Player.SendMessage(p, "> > Player is &fWhitelisted");
}
public override void Help(Player p) {

View File

@ -1,20 +1,20 @@
/*
Copyright 2010 MCSharp team (Modified for use with MCZall/MCLawl/MCGalaxy)
Dual-licensed under the Educational Community License, Version 2.0 and
the GNU General Public License, Version 3 (the "Licenses"); you may
not use this file except in compliance with the Licenses. You may
obtain a copy of the Licenses at
http://www.opensource.org/licenses/ecl2.php
http://www.gnu.org/licenses/gpl-3.0.html
Unless required by applicable law or agreed to in writing,
software distributed under the Licenses are distributed on an "AS IS"
BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
or implied. See the Licenses for the specific language governing
permissions and limitations under the Licenses.
*/
Copyright 2010 MCSharp team (Modified for use with MCZall/MCLawl/MCGalaxy)
Dual-licensed under the Educational Community License, Version 2.0 and
the GNU General Public License, Version 3 (the "Licenses"); you may
not use this file except in compliance with the Licenses. You may
obtain a copy of the Licenses at
http://www.opensource.org/licenses/ecl2.php
http://www.gnu.org/licenses/gpl-3.0.html
Unless required by applicable law or agreed to in writing,
software distributed under the Licenses are distributed on an "AS IS"
BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
or implied. See the Licenses for the specific language governing
permissions and limitations under the Licenses.
*/
using System;
using System.Data;
using MCGalaxy.SQL;
@ -28,8 +28,8 @@ namespace MCGalaxy.Commands
public override bool museumUsable { get { return true; } }
public override LevelPermission defaultRank { get { return LevelPermission.Banned; } }
public override CommandPerm[] AdditionalPerms {
get { return new[] { new CommandPerm(LevelPermission.AdvBuilder, "The lowest rank which can see the target player's ip and if they are whitelisted") }; }
}
get { return new[] { new CommandPerm(LevelPermission.AdvBuilder, "The lowest rank which can see the target player's ip and if they are whitelisted") }; }
}
public override void Use(Player p, string message) {
if (message == "") { Help(p); return; }
@ -50,10 +50,10 @@ namespace MCGalaxy.Commands
string color = target.color == "" ? group.color : target.color;
string prefix = target.title == "" ? "" : "[" + target.titleColor + target.title + color + "] ";
Player.SendMessage(p, color + prefix + target.name + " %Shas :");
Player.SendMessage(p, "> > the rank of " + group.color + plGroup);
Player.SendMessage(p, "> > the rank of " + group.color + plGroup);
if (Economy.Enabled)
Player.SendMessage(p, "> > &a" + target.money + " %S" + Server.moneys);
Player.SendMessage(p, "> > &cdied &a" + target.deaths + " %Stimes");
Player.SendMessage(p, "> > &bmodified &a" + target.blocks + " &eblocks.");
Player.SendMessage(p, "> > was last seen on &a" + target.lastLogin);
@ -69,22 +69,21 @@ namespace MCGalaxy.Commands
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");
if (p == null || (int)p.group.Permission >= CommandOtherPerms.GetPerm(this)) {
if (Server.bannedIP.Contains(target.ip))
target.ip = "&8" + target.ip + ", which is banned";
Player.SendMessage(p, "> > the IP of " + target.ip);
if (Server.useWhitelist&& Server.whiteList.Contains(message))
Player.SendMessage(p, "> > Player is &fWhitelisted");
}
if (!CheckAdditionalPerm(p)) return;
if (Server.bannedIP.Contains(target.ip))
target.ip = "&8" + target.ip + ", which is banned";
Player.SendMessage(p, "> > the IP of " + target.ip);
if (Server.useWhitelist&& Server.whiteList.Contains(message))
Player.SendMessage(p, "> > Player is &fWhitelisted");
}
string TotalTime(string time) {
TimeSpan value = time.ParseDBTime();
TimeSpan value = time.ParseDBTime();
return "time spent on server: " + value.Days + " Days, " + value.Hours + " Hours, " + value.Minutes + " Minutes, " + value.Seconds + " Seconds.";
}
public override void Help(Player p) {
Player.SendMessage(p, "/whowas <name> - Displays information about someone who left.");
}
}
}
}

View File

@ -44,9 +44,7 @@ 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)) {
MessageNeedPerms(p, CommandOtherPerms.GetPerm(this), "reload all players in a map."); return;
}
if (!CheckAdditionalPerm(p)) { MessageNeedPerms(p, "can reload all players in a map."); return; }
Player[] players = PlayerInfo.Online.Items;
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.");
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)
@ -77,9 +77,9 @@ namespace MCGalaxy.Commands
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
{
@ -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)

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;
else message = message.Substring(message.IndexOf(' ') + 1);
}
if (p != null && (int)p.group.Permission < CommandOtherPerms.GetPerm(this)) {
MessageNeedPerms(p, CommandOtherPerms.GetPerm(this, 1), "to set map options."); return;
}
if (!CheckAdditionalPerm(p)) { MessageNeedPerms(p, "can set map options."); return; }
string foundStart;
if (message.IndexOf(' ') == -1) foundStart = message.ToLower();

View File

@ -89,9 +89,7 @@ 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)) {
MessageNeedPerms(p, CommandOtherPerms.GetPerm(this), "to undo other players."); return;
}
if (!CheckAdditionalPerm(p)) { MessageNeedPerms(p, "can undo other players."); return; }
}
UndoOnlineDrawOp op = new UndoOnlineDrawOp();
@ -110,10 +108,7 @@ namespace MCGalaxy.Commands
}
void UndoOfflinePlayer(Player p, long seconds, string whoName) {
if (p != null && (int)p.group.Permission < CommandOtherPerms.GetPerm(this)) {
MessageNeedPerms(p, CommandOtherPerms.GetPerm(this), "to undo other players."); return;
}
if (!CheckAdditionalPerm(p)) { MessageNeedPerms(p, "can undo other players."); return; }
UndoOfflineDrawOp op = new UndoOfflineDrawOp();
op.Start = DateTime.UtcNow.AddTicks(-seconds * TimeSpan.TicksPerSecond);
op.whoName = whoName;
@ -129,9 +124,7 @@ namespace MCGalaxy.Commands
}
void UndoLevelPhysics(Player p, long seconds) {
if (p != null && (int)p.group.Permission < CommandOtherPerms.GetPerm(this, 2)) {
MessageNeedPerms(p, CommandOtherPerms.GetPerm(this, 2), "to undo physics."); return;
}
if (!CheckAdditionalPerm(p, 2)) { MessageNeedPerms(p, "can undo physics.", 2); 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,9 +69,7 @@ namespace MCGalaxy.Commands
}
else if (foundPath == "kill")
{
if ((int)p.group.Permission < CommandOtherPerms.GetPerm(this)) {
MessageNeedPerms(p, CommandOtherPerms.GetPerm(this), "to toggle bot killer instinct."); return;
}
if (CheckAdditionalPerm(p)) { MessageNeedPerms(p, "can toggle a bot's 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

@ -61,15 +61,11 @@ namespace MCGalaxy.Commands
if (split[0] == "all")
{
if ((int)p.group.Permission < CommandOtherPerms.GetPerm(this))
{
MessageNeedPerms(p, CommandOtherPerms.GetPerm(this), "to send the changelog to all players."); return;
}
if (!CheckAdditionalPerm(p)) { MessageNeedPerms(p, "can send the changelog to all players."); return; }
for (int k = 0; k < strArray.Length; k++)
{
Player.GlobalMessage(strArray[k]);
}
}
return;
}
else
@ -84,8 +80,7 @@ namespace MCGalaxy.Commands
Player.SendMessage(player, strArray[l]);
}
Player.SendMessage(p, "The Changelog was successfully sent to " + player.name + ".");
Player.SendMessage(p, "The Changelog was successfully sent to " + player.name + ".");
return;
}
}

View File

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

View File

@ -52,35 +52,35 @@ namespace MCGalaxy.Commands
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;
Player.SendMessage(p, "TNT (Big) mode is now &aON%S.");
} 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") {
if (!p.allowTnt) {
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;
Player.SendMessage(p, "TNT (Nuke) mode is now &aON%S.");
} 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") {
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!");
} else {
MessageNeedPerms(p, CommandOtherPerms.GetPerm(this, 2), "to allow TNT usage."); return;
MessageNeedPerms(p, "can allow TNT usage.", 2); return;
}
return;
} 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!");
} else {
MessageNeedPerms(p, CommandOtherPerms.GetPerm(this, 2), "to disallow TNT usage."); return;
MessageNeedPerms(p, "can disallow TNT usage.", 2); return;
}
return;
} else {
@ -92,7 +92,7 @@ namespace MCGalaxy.Commands
public override void Help(Player p) {
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 + "+");
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 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 ((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 (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 ((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 (!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 ((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 (!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
@ -173,18 +173,12 @@ namespace MCGalaxy.Commands
{
Player.SendMessage(p, "/warp [name] - warp to that warp");
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");
}
if ((int)p.group.Permission >= CommandOtherPerms.GetPerm(this, 2))
{
if (CheckAdditionalPerm(p, 2))
Player.SendMessage(p, "/warp delete [name] - delete a warp");
}
if ((int)p.group.Permission >= CommandOtherPerms.GetPerm(this, 3))
{
if (CheckAdditionalPerm(p, 3))
Player.SendMessage(p, "/warp move [name] <player> - move a warp, if a <player> is given, it will be created where they are");
}
}
}
}