diff --git a/Commands/Command.cs b/Commands/Command.cs
index 19bf37b3e..dc8b0a15b 100644
--- a/Commands/Command.cs
+++ b/Commands/Command.cs
@@ -32,7 +32,7 @@ namespace MCGalaxy
public abstract void Use(Player p, string message);
public abstract void Help(Player p);
public virtual CommandPerm[] AdditionalPerms { get { return null; } }
- public virtual bool Enabled { get { return true; } }
+ public virtual CommandEnable Enabled { get { return CommandEnable.Always; } }
public static CommandList all = new CommandList();
public static CommandList core = new CommandList();
@@ -49,6 +49,23 @@ namespace MCGalaxy
Scripting.Autoload();
}
+ #region Helpers
+
+ const CommandEnable bothFlags = CommandEnable.Lava | CommandEnable.Zombie;
+ public static string GetDisabledReason(CommandEnable enable) {
+ if (enable == CommandEnable.Always) return null;
+ if (enable == CommandEnable.Economy && !Economy.Enabled)
+ return "economy is disabled.";
+
+ if (enable == bothFlags && !(Server.zombie.Running || Server.lava.active))
+ return "neither zombie nor lava survival is running.";
+ if (enable == CommandEnable.Zombie && !Server.zombie.Running)
+ return "zombie survival is not running.";
+ if (enable == CommandEnable.Lava)
+ return "lava survival is not running.";
+ return null;
+ }
+
protected static void RevertAndClearState(Player p, ushort x, ushort y, ushort z) {
p.ClearBlockchange();
p.RevertBlock(x, y, z);
@@ -72,15 +89,16 @@ namespace MCGalaxy
}
protected void MessageTooHighRank(Player p, string action, bool canAffectOwnRank) {
- MessageTooHighRank(p, action, p.group, canAffectOwnRank);
+ MessageTooHighRank(p, action, p.group, canAffectOwnRank);
}
protected void MessageTooHighRank(Player p, string action, Group grp, bool canAffectGroup) {
if (canAffectGroup)
- Player.SendMessage(p, "Can only " + action + " players ranked " + grp.color + grp.name + " %Sor below");
+ Player.SendMessage(p, "Can only " + action + " players ranked " + grp.color + grp.name + " %Sor below");
else
- Player.SendMessage(p, "Can only " + action + " players ranked below " + grp.color + grp.name);
+ Player.SendMessage(p, "Can only " + action + " players ranked below " + grp.color + grp.name);
}
+ #endregion
}
public struct CommandPerm {
@@ -97,6 +115,11 @@ namespace MCGalaxy
}
}
+ [Flags]
+ public enum CommandEnable {
+ Always = 0, Economy = 1, Zombie = 2, Lava = 4,
+ }
+
public sealed class CommandTypes {
public const string Building = "build";
public const string Chat = "chat";
diff --git a/Commands/Economy/CmdBuy.cs b/Commands/Economy/CmdBuy.cs
index b34b1ccbf..22e82a89c 100644
--- a/Commands/Economy/CmdBuy.cs
+++ b/Commands/Economy/CmdBuy.cs
@@ -27,7 +27,7 @@ namespace MCGalaxy.Commands {
public override string type { get { return CommandTypes.Economy; } }
public override bool museumUsable { get { return true; } }
public override LevelPermission defaultRank { get { return LevelPermission.Guest; } }
- public override bool Enabled { get { return Economy.Enabled; } }
+ public override CommandEnable Enabled { get { return CommandEnable.Economy; } }
public override void Use(Player p, string message) {
if (p == null) { MessageInGameOnly(p); return; }
diff --git a/Commands/Economy/CmdStore.cs b/Commands/Economy/CmdStore.cs
index dfc4c9962..ac9ef579d 100644
--- a/Commands/Economy/CmdStore.cs
+++ b/Commands/Economy/CmdStore.cs
@@ -25,11 +25,11 @@ namespace MCGalaxy.Commands {
/// Economy Beta v1.0 QuantumHive
public sealed class CmdStore : Command {
public override string name { get { return "store"; } }
- public override string shortcut { get { return ""; } }
+ public override string shortcut { get { return "shop"; } }
public override string type { get { return CommandTypes.Economy; } }
public override bool museumUsable { get { return true; } }
public override LevelPermission defaultRank { get { return LevelPermission.Guest; } }
- public override bool Enabled { get { return Economy.Enabled; } }
+ public override CommandEnable Enabled { get { return CommandEnable.Economy; } }
public override void Use(Player p, string message) {
if (message == "") {
diff --git a/Commands/Fun/CmdMapSet.cs b/Commands/Fun/CmdMapSet.cs
index 53d5ac5f4..5efb90948 100644
--- a/Commands/Fun/CmdMapSet.cs
+++ b/Commands/Fun/CmdMapSet.cs
@@ -27,7 +27,7 @@ namespace MCGalaxy.Commands {
public override string type { get { return CommandTypes.Games; } }
public override bool museumUsable { get { return true; } }
public override LevelPermission defaultRank { get { return LevelPermission.Operator; } }
- public override bool Enabled { get { return Server.zombie.Running || Server.lava.active; } }
+ public override CommandEnable Enabled { get { return CommandEnable.Zombie | CommandEnable.Lava; } }
static char[] trimChars = {' '};
public override void Use(Player p, string message) {
diff --git a/Commands/Fun/RateMapCmds.cs b/Commands/Fun/RateMapCmds.cs
index 7bb011664..fc1fa590d 100644
--- a/Commands/Fun/RateMapCmds.cs
+++ b/Commands/Fun/RateMapCmds.cs
@@ -27,7 +27,7 @@ namespace MCGalaxy.Commands {
public override string type { get { return CommandTypes.Games; } }
public override bool museumUsable { get { return true; } }
public override LevelPermission defaultRank { get { return LevelPermission.Banned; } }
- public override bool Enabled { get { return Server.zombie.Running || Server.lava.active; } }
+ public override CommandEnable Enabled { get { return CommandEnable.Zombie | CommandEnable.Lava; } }
public override void Use(Player p, string message) {
if (p == null) { MessageInGameOnly(p); return; }
@@ -49,7 +49,7 @@ namespace MCGalaxy.Commands {
public override string type { get { return CommandTypes.Games; } }
public override bool museumUsable { get { return true; } }
public override LevelPermission defaultRank { get { return LevelPermission.Banned; } }
- public override bool Enabled { get { return Server.zombie.Running || Server.lava.active; } }
+ public override CommandEnable Enabled { get { return CommandEnable.Zombie | CommandEnable.Lava; } }
public override void Use(Player p, string message) {
if (p == null) { MessageInGameOnly(p); return; }
diff --git a/Commands/Fun/ZombieSurvival/CmdAlive.cs b/Commands/Fun/ZombieSurvival/CmdAlive.cs
index f98b00e31..82905b322 100644
--- a/Commands/Fun/ZombieSurvival/CmdAlive.cs
+++ b/Commands/Fun/ZombieSurvival/CmdAlive.cs
@@ -25,7 +25,7 @@ namespace MCGalaxy.Commands {
public override string type { get { return CommandTypes.Games; } }
public override bool museumUsable { get { return true; } }
public override LevelPermission defaultRank { get { return LevelPermission.Banned; } }
- public override bool Enabled { get { return Server.zombie.Running; } }
+ public override CommandEnable Enabled { get { return CommandEnable.Zombie; } }
public CmdAlive() { }
public override void Use(Player p, string message) {
diff --git a/Commands/Fun/ZombieSurvival/CmdBounties.cs b/Commands/Fun/ZombieSurvival/CmdBounties.cs
index c04db12ad..d96cd6ade 100644
--- a/Commands/Fun/ZombieSurvival/CmdBounties.cs
+++ b/Commands/Fun/ZombieSurvival/CmdBounties.cs
@@ -27,7 +27,7 @@ namespace MCGalaxy.Commands {
public override string type { get { return CommandTypes.Games; } }
public override bool museumUsable { get { return true; } }
public override LevelPermission defaultRank { get { return LevelPermission.Banned; } }
- public override bool Enabled { get { return Server.zombie.Running; } }
+ public override CommandEnable Enabled { get { return CommandEnable.Zombie; } }
public CmdBounties() { }
public override void Use(Player p, string message) {
diff --git a/Commands/Fun/ZombieSurvival/CmdBounty.cs b/Commands/Fun/ZombieSurvival/CmdBounty.cs
index 697dd9caf..78caf5bbf 100644
--- a/Commands/Fun/ZombieSurvival/CmdBounty.cs
+++ b/Commands/Fun/ZombieSurvival/CmdBounty.cs
@@ -26,7 +26,7 @@ namespace MCGalaxy.Commands {
public override string type { get { return CommandTypes.Games; } }
public override bool museumUsable { get { return true; } }
public override LevelPermission defaultRank { get { return LevelPermission.Banned; } }
- public override bool Enabled { get { return Server.zombie.Running; } }
+ public override CommandEnable Enabled { get { return CommandEnable.Zombie; } }
public override void Use(Player p, string message) {
string[] args = message.Split(' ');
diff --git a/Commands/Fun/ZombieSurvival/CmdDisinfect.cs b/Commands/Fun/ZombieSurvival/CmdDisinfect.cs
index 7c1b68bae..74c65ed59 100644
--- a/Commands/Fun/ZombieSurvival/CmdDisinfect.cs
+++ b/Commands/Fun/ZombieSurvival/CmdDisinfect.cs
@@ -24,7 +24,7 @@ namespace MCGalaxy.Commands {
public override string type { get { return CommandTypes.Games; } }
public override bool museumUsable { get { return true; } }
public override LevelPermission defaultRank { get { return LevelPermission.Operator; } }
- public override bool Enabled { get { return Server.zombie.Running; } }
+ public override CommandEnable Enabled { get { return CommandEnable.Zombie; } }
public CmdDisInfect() { }
public override void Use(Player p, string message) {
diff --git a/Commands/Fun/ZombieSurvival/CmdEndRound.cs b/Commands/Fun/ZombieSurvival/CmdEndRound.cs
index 56c591a79..4640975d4 100644
--- a/Commands/Fun/ZombieSurvival/CmdEndRound.cs
+++ b/Commands/Fun/ZombieSurvival/CmdEndRound.cs
@@ -24,7 +24,7 @@ namespace MCGalaxy.Commands
public override string type { get { return CommandTypes.Moderation; } }
public override bool museumUsable { get { return true; } }
public override LevelPermission defaultRank { get { return LevelPermission.Banned; } }
- public override bool Enabled { get { return Server.zombie.Running; } }
+ public override CommandEnable Enabled { get { return CommandEnable.Zombie; } }
public CmdEndRound() { }
public override void Use(Player p, string message) {
diff --git a/Commands/Fun/ZombieSurvival/CmdFliphead.cs b/Commands/Fun/ZombieSurvival/CmdFliphead.cs
index 092f6a0ba..514d030af 100644
--- a/Commands/Fun/ZombieSurvival/CmdFliphead.cs
+++ b/Commands/Fun/ZombieSurvival/CmdFliphead.cs
@@ -24,7 +24,7 @@ namespace MCGalaxy.Commands {
public override string type { get { return CommandTypes.Other; } }
public override bool museumUsable { get { return true; } }
public override LevelPermission defaultRank { get { return LevelPermission.Banned; } }
- public override bool Enabled { get { return Server.zombie.Running; } }
+ public override CommandEnable Enabled { get { return CommandEnable.Zombie; } }
public CmdFlipHead() { }
public override void Use(Player p, string message) {
diff --git a/Commands/Fun/ZombieSurvival/CmdHuman.cs b/Commands/Fun/ZombieSurvival/CmdHuman.cs
index 41a7d3e57..40356bd82 100644
--- a/Commands/Fun/ZombieSurvival/CmdHuman.cs
+++ b/Commands/Fun/ZombieSurvival/CmdHuman.cs
@@ -25,7 +25,7 @@ namespace MCGalaxy.Commands {
public override string type { get { return CommandTypes.Moderation; } }
public override bool museumUsable { get { return true; } }
public override LevelPermission defaultRank { get { return LevelPermission.Banned; } }
- public override bool Enabled { get { return Server.zombie.Running; } }
+ public override CommandEnable Enabled { get { return CommandEnable.Zombie; } }
public CmdHuman() { }
public override void Use(Player p, string message) {
diff --git a/Commands/Fun/ZombieSurvival/CmdInfect.cs b/Commands/Fun/ZombieSurvival/CmdInfect.cs
index ee0ee8f07..8016694ca 100644
--- a/Commands/Fun/ZombieSurvival/CmdInfect.cs
+++ b/Commands/Fun/ZombieSurvival/CmdInfect.cs
@@ -24,7 +24,7 @@ namespace MCGalaxy.Commands {
public override string type { get { return CommandTypes.Games; } }
public override bool museumUsable { get { return true; } }
public override LevelPermission defaultRank { get { return LevelPermission.Operator; } }
- public override bool Enabled { get { return Server.zombie.Running; } }
+ public override CommandEnable Enabled { get { return CommandEnable.Zombie; } }
public CmdInfect() { }
public override void Use(Player p, string message) {
diff --git a/Commands/Fun/ZombieSurvival/CmdInfected.cs b/Commands/Fun/ZombieSurvival/CmdInfected.cs
index 4cd087b45..a654296b1 100644
--- a/Commands/Fun/ZombieSurvival/CmdInfected.cs
+++ b/Commands/Fun/ZombieSurvival/CmdInfected.cs
@@ -25,7 +25,7 @@ namespace MCGalaxy.Commands {
public override string type { get { return CommandTypes.Games; } }
public override bool museumUsable { get { return true; } }
public override LevelPermission defaultRank { get { return LevelPermission.Banned; } }
- public override bool Enabled { get { return Server.zombie.Running; } }
+ public override CommandEnable Enabled { get { return CommandEnable.Zombie; } }
public CmdInfected() { }
public override void Use(Player p, string message) {
diff --git a/Commands/Fun/ZombieSurvival/CmdQueue.cs b/Commands/Fun/ZombieSurvival/CmdQueue.cs
index b6f963883..78c3a6133 100644
--- a/Commands/Fun/ZombieSurvival/CmdQueue.cs
+++ b/Commands/Fun/ZombieSurvival/CmdQueue.cs
@@ -25,7 +25,7 @@ namespace MCGalaxy.Commands
public override string type { get { return CommandTypes.Games; } }
public override bool museumUsable { get { return true; } }
public override LevelPermission defaultRank { get { return LevelPermission.Operator; } }
- public override bool Enabled { get { return Server.zombie.Running; } }
+ public override CommandEnable Enabled { get { return CommandEnable.Zombie; } }
public CmdQueue() { }
public override void Use(Player p, string message) {
diff --git a/Commands/Fun/ZombieSurvival/CmdReferee.cs b/Commands/Fun/ZombieSurvival/CmdReferee.cs
index ca2cb0dcf..8333347df 100644
--- a/Commands/Fun/ZombieSurvival/CmdReferee.cs
+++ b/Commands/Fun/ZombieSurvival/CmdReferee.cs
@@ -25,7 +25,7 @@ namespace MCGalaxy.Commands {
public override string type { get { return CommandTypes.Moderation; } }
public override bool museumUsable { get { return true; } }
public override LevelPermission defaultRank { get { return LevelPermission.Operator; } }
- public override bool Enabled { get { return Server.zombie.Running; } }
+ public override CommandEnable Enabled { get { return CommandEnable.Zombie; } }
public CmdReferee() { }
public override void Use(Player p, string message) {
diff --git a/Commands/Information/CmdHelp.cs b/Commands/Information/CmdHelp.cs
index e0d857717..9b7c439c2 100644
--- a/Commands/Information/CmdHelp.cs
+++ b/Commands/Information/CmdHelp.cs
@@ -116,9 +116,11 @@ namespace MCGalaxy.Commands
case "commands":
case "command":
string commandsFound = "";
- foreach (Command comm in Command.all.commands)
- if (p == null || p.group.CanExecute(comm) && comm.Enabled)
+ foreach (Command comm in Command.all.commands) {
+ string disabled = Command.GetDisabledReason(comm.Enabled);
+ if (p == null || p.group.CanExecute(comm) && disabled == null)
try { commandsFound += ", " + comm.name; } catch { }
+ }
Player.SendMessage(p, "Available commands:");
Player.SendMessage(p, commandsFound.Remove(0, 2));
Player.SendMessage(p, "Type \"/help \" for more help.");
@@ -176,7 +178,8 @@ namespace MCGalaxy.Commands
static void PrintHelpForGroup(Player p, string typeName, string typeTitle) {
string message = "";
foreach (Command c in Command.all.commands) {
- if (p == null || p.group.CanExecute(c) && c.Enabled) {
+ string disabled = Command.GetDisabledReason(c.Enabled);
+ if (p == null || p.group.CanExecute(c) && disabled == null) {
if (c.type.Contains(typeName))
message += ", " + getColor(c.name) + c.name;
}
diff --git a/Player/Player.Handlers.cs b/Player/Player.Handlers.cs
index 78a33b834..a3a1243b3 100644
--- a/Player/Player.Handlers.cs
+++ b/Player/Player.Handlers.cs
@@ -1289,9 +1289,9 @@ return;
if (!group.CanExecute(command)) {
SendMessage("You are not allowed to use \"" + cmd + "\"."); return;
}
- if (!command.Enabled) {
- SendMessage("The game or economy associated with this command is not running, " +
- "so this command is disabled."); return;
+ string reason = Command.GetDisabledReason(command.Enabled);
+ if (reason != null) {
+ SendMessage("Command is disabled as " + reason); return;
}
if (!(cmd == "repeat" || cmd == "pass" || cmd == "setpass")) {
lastCMD = cmd + " " + message;