Make 'can only be used in game'/'cannot be used from console' messages consistent.

This commit is contained in:
UnknownShadow200 2016-01-23 10:24:48 +11:00
parent ceb6e5a1a5
commit 6b70fa09dc
30 changed files with 122 additions and 224 deletions

View File

@ -27,12 +27,8 @@ namespace MCGalaxy.Commands {
public override LevelPermission defaultRank { get { return LevelPermission.AdvBuilder; } } public override LevelPermission defaultRank { get { return LevelPermission.AdvBuilder; } }
public override void Use(Player p, string message) { public override void Use(Player p, string message) {
if (p == null) { if (p == null) { MessageInGameOnly(p); return; }
Player.SendMessage(p, "This command cannot be used from console."); return; if (message == "") { Help(p); return; }
}
if (message == "") {
Help(p); return;
}
float dist; float dist;
if( !float.TryParse(message, out dist)) { if( !float.TryParse(message, out dist)) {

View File

@ -27,10 +27,9 @@ namespace MCGalaxy.Commands {
public override LevelPermission defaultRank { get { return LevelPermission.Banned; } } public override LevelPermission defaultRank { get { return LevelPermission.Banned; } }
public override void Use(Player p, string message) { public override void Use(Player p, string message) {
if (p == null) { if (p == null) { MessageInGameOnly(p); return; }
Server.s.Log("This command can only be used in-game."); return;
}
string[] parts = message.ToLower().Split(' '); string[] parts = message.ToLower().Split(' ');
if (parts.Length == 0) { if (parts.Length == 0) {
if (Server.Chatrooms.Count == 0) { if (Server.Chatrooms.Count == 0) {
Player.SendMessage(p, "There are currently no rooms"); Player.SendMessage(p, "There are currently no rooms");

View File

@ -34,7 +34,7 @@ namespace MCGalaxy.Commands
public override void Use(Player p, string message) public override void Use(Player p, string message)
{ {
if (p == null) { Player.SendMessage(p, "This command can only be used in-game!"); return; } if (p == null) { MessageInGameOnly(p); return; }
if (message.Split(' ')[0] == "all") if (message.Split(' ')[0] == "all")
{ {
p.ignoreglobal = !p.ignoreglobal; p.ignoreglobal = !p.ignoreglobal;

View File

@ -29,7 +29,7 @@ namespace MCGalaxy.Commands
public override void Use(Player p, string message) public override void Use(Player p, string message)
{ {
if (message == "") { Player.SendMessage(p, "You"); return; } if (message == "") { Player.SendMessage(p, "You"); return; }
if (p == null) { Player.SendMessage(p, "This command can only be used in-game!"); return; } if (p == null) { MessageInGameOnly(p); return; }
if (p.muted) { Player.SendMessage(p, "You are currently muted and cannot use this command."); return; } if (p.muted) { Player.SendMessage(p, "You are currently muted and cannot use this command."); return; }
if (Server.chatmod && !p.voice) { Player.SendMessage(p, "Chat moderation is on, you cannot emote."); return; } if (Server.chatmod && !p.voice) { Player.SendMessage(p, "Chat moderation is on, you cannot emote."); return; }

View File

@ -37,19 +37,14 @@ namespace MCGalaxy
public static CommandList all = new CommandList(); public static CommandList all = new CommandList();
public static CommandList core = new CommandList(); public static CommandList core = new CommandList();
/// <summary>
/// Add a command to the server
/// </summary>
/// <param name="command">The command to add</param>
public void AddCommand(Command command)
{
all.Add(command);
}
protected static void RevertAndClearState(Player p, ushort x, ushort y, ushort z) { protected static void RevertAndClearState(Player p, ushort x, ushort y, ushort z) {
p.ClearBlockchange(); p.ClearBlockchange();
p.RevertBlock(x, y, z); p.RevertBlock(x, y, z);
} }
protected void MessageInGameOnly(Player p) {
Player.SendMessage(p, "/" + name + " can only be used in-game.");
}
} }
public sealed class CommandTypes { public sealed class CommandTypes {

View File

@ -33,15 +33,11 @@ namespace MCGalaxy.Commands
public override void Use(Player p, string message) public override void Use(Player p, string message)
{ {
if (p != null) if (p == null) { MessageInGameOnly(p); return; }
{
Player.SendMessage(p, "Break/build a block to display information."); Player.SendMessage(p, "Break/build a block to display information.");
p.ClearBlockchange(); p.ClearBlockchange();
p.Blockchange += new Player.BlockchangeEventHandler(AboutBlockchange); p.Blockchange += new Player.BlockchangeEventHandler(AboutBlockchange);
return;
}
Player.SendMessage(p, "This command can only be used in-game");
} }
public override void Help(Player p) public override void Help(Player p)
{ {

View File

@ -28,53 +28,36 @@ namespace MCGalaxy.Commands
public static string keywords { get { return ""; } } public static string keywords { get { return ""; } }
public CmdAfk() { } public CmdAfk() { }
public override void Use(Player p, string message) public override void Use(Player p, string message) {
{ if (p == null) { MessageInGameOnly(p); return; }
if (p != null) if (Server.chatmod) {
{ Player.SendMessage(p, "You cannot use /afk while chat moderation is enabled");
return;
if (Server.chatmod) { }
Player.SendMessage(p, "You cannot use /afk while chat moderation is enabled");
return; if (message != "list") {
} if (p.joker)
message = "";
if (message != "list") if (!Server.afkset.Contains(p.name)) {
{ Server.afkset.Add(p.name);
if (p.joker) if (p.muted)
{ message = "";
message = ""; Player.GlobalMessage("-" + p.color + p.DisplayName + Server.DefaultColor + "- is AFK " + message);
} //IRCBot.Say(p.name + " is AFK " + message);
if (!Server.afkset.Contains(p.name)) Server.IRC.Say(p.DisplayName + " is AFK " + message);
{ p.afkStart = DateTime.Now;
Server.afkset.Add(p.name); } else {
if (p.muted) Server.afkset.Remove(p.name);
{ Player.GlobalMessage("-" + p.color + p.DisplayName + Server.DefaultColor + "- is no longer AFK");
message = ""; //IRCBot.Say(p.name + " is no longer AFK");
} Server.IRC.Say(p.DisplayName + " is no longer AFK");
Player.GlobalMessage("-" + p.color + p.DisplayName + Server.DefaultColor + "- is AFK " + message); }
//IRCBot.Say(p.name + " is AFK " + message); } else {
Server.IRC.Say(p.DisplayName + " is AFK " + message); foreach (string s in Server.afkset)
p.afkStart = DateTime.Now; Player.SendMessage(p, s);
return;
}
else
{
Server.afkset.Remove(p.name);
Player.GlobalMessage("-" + p.color + p.DisplayName + Server.DefaultColor + "- is no longer AFK");
//IRCBot.Say(p.name + " is no longer AFK");
Server.IRC.Say(p.DisplayName + " is no longer AFK");
return;
}
}
else
{
foreach (string s in Server.afkset) Player.SendMessage(p, s);
return;
}
} }
Player.SendMessage(p, "This command can only be used in-game");
} }
public override void Help(Player p) public override void Help(Player p)
{ {
Player.SendMessage(p, "/afk <reason> - mark yourself as AFK. Use again to mark yourself as back"); Player.SendMessage(p, "/afk <reason> - mark yourself as AFK. Use again to mark yourself as back");

View File

@ -26,22 +26,16 @@ namespace MCGalaxy.Commands
public override LevelPermission defaultRank { get { return LevelPermission.Admin; } } public override LevelPermission defaultRank { get { return LevelPermission.Admin; } }
public CmdBotAdd() { } public CmdBotAdd() { }
public override void Use(Player p, string message) public override void Use(Player p, string message) {
{
if (message == "") { Help(p); return; } if (message == "") { Help(p); return; }
if (p != null) if (p == null) { MessageInGameOnly(p); return; }
{
if (!Player.ValidName(message)) { Player.SendMessage(p, "bot name " + message + " not valid!"); return; } if (!Player.ValidName(message)) { Player.SendMessage(p, "bot name " + message + " not valid!"); return; }
PlayerBot bot = new PlayerBot(message, p.level, p.pos[0], p.pos[1], p.pos[2], p.rot[0], 0); PlayerBot bot = new PlayerBot(message, p.level, p.pos[0], p.pos[1], p.pos[2], p.rot[0], 0);
PlayerBot.Add(bot); PlayerBot.Add(bot);
//who.SendMessage("You were summoned by " + p.color + p.name + "&e.");
return;
}
Player.SendMessage(p, "This command can only be used in-game");
} }
public override void Help(Player p) public override void Help(Player p) {
{
Player.SendMessage(p, "/botadd <name> - Add a new bot at your position."); Player.SendMessage(p, "/botadd <name> - Add a new bot at your position.");
} }
} }

View File

@ -31,26 +31,22 @@ namespace MCGalaxy.Commands
public override void Use(Player p, string message) public override void Use(Player p, string message)
{ {
if (message == "") { Help(p); return; } if (message == "") { Help(p); return; }
if (p == null) { if (p == null) { MessageInGameOnly(p); return; }
Player.SendMessage(p, "This command can only be used in-game!"); return;
} try
try {
{ if (message.ToLower() == "all") {
if (message.ToLower() == "all") PlayerBot.RemoveAllFromLevel(p.level);
{ } else {
PlayerBot.RemoveAllFromLevel(p.level); PlayerBot who = PlayerBot.Find(message);
} if (who == null) { Player.SendMessage(p, "There is no bot " + who + "!"); return; }
else if (p.level != who.level) { Player.SendMessage(p, who.name + " is in a different level."); return; }
{ PlayerBot.Remove(who);
PlayerBot who = PlayerBot.Find(message); Player.SendMessage(p, "Removed bot.");
if (who == null) { Player.SendMessage(p, "There is no bot " + who + "!"); return; }
if (p.level != who.level) { Player.SendMessage(p, who.name + " is in a different level."); return; }
PlayerBot.Remove(who);
Player.SendMessage(p, "Removed bot.");
}
} }
catch (Exception e) { Server.ErrorLog(e); Player.SendMessage(p, "Error caught"); }
} }
catch (Exception e) { Server.ErrorLog(e); Player.SendMessage(p, "Error caught"); }
}
public override void Help(Player p) public override void Help(Player p)
{ {

View File

@ -29,11 +29,8 @@ namespace MCGalaxy.Commands
public override void Use(Player p, string message) public override void Use(Player p, string message)
{ {
if (message == "") { Help(p); return; } if (message == "") { Help(p); return; }
if (p == null) if (p == null) { MessageInGameOnly(p); return; }
{
Player.SendMessage(p, "This command can only be used in-game");
return;
}
PlayerBot who = PlayerBot.Find(message); PlayerBot who = PlayerBot.Find(message);
if (who == null) { Player.SendMessage(p, "There is no bot " + message + "!"); return; } if (who == null) { Player.SendMessage(p, "There is no bot " + message + "!"); return; }
if (p.level != who.level) { Player.SendMessage(p, who.name + " is in a different level."); return; } if (p.level != who.level) { Player.SendMessage(p, who.name + " is in a different level."); return; }

View File

@ -29,11 +29,7 @@ namespace MCGalaxy.Commands
public override void Use(Player p, string message) public override void Use(Player p, string message)
{ {
if (p == null) if (p == null) { MessageInGameOnly(p); return; }
{
Player.SendMessage(p, "This command can only be used in-game");
return;
}
if (!p.canBuild) if (!p.canBuild)
{ {
Player.SendMessage(p, "You're currently being &4possessed" + Server.DefaultColor + "!"); Player.SendMessage(p, "You're currently being &4possessed" + Server.DefaultColor + "!");

View File

@ -29,7 +29,7 @@ namespace MCGalaxy.Commands
public override void Use(Player p, string message) public override void Use(Player p, string message)
{ {
if (p == null) { Player.SendMessage(p, "This command can only be used in-game!"); return; } if (p == null) { MessageInGameOnly(p); return; }
if (message == "check") if (message == "check")
{ {
if (p.hidden) if (p.hidden)

View File

@ -27,7 +27,7 @@ namespace MCGalaxy.Commands
public CmdReferee() { } public CmdReferee() { }
public override void Use(Player p, string message) public override void Use(Player p, string message)
{ {
if (p == null) { Player.SendMessage(p, "This command can only be used in-game!"); return; } if (p == null) { MessageInGameOnly(p); return; }
if (p.referee) if (p.referee)
{ {
p.referee = false; p.referee = false;

View File

@ -28,7 +28,7 @@ namespace MCGalaxy.Commands
public override void Use(Player p, string message) public override void Use(Player p, string message)
{ {
if (p == null) { Player.SendMessage(p, "This command can only be used in-game!"); return; } if (p == null) { MessageInGameOnly(p); return; }
if (message == "" || message.IndexOf(' ') != -1) { Help(p); return; } if (message == "" || message.IndexOf(' ') != -1) { Help(p); return; }
if (Server.voteKickInProgress) { p.SendMessage("Please wait for the current vote to finish!"); return; } if (Server.voteKickInProgress) { p.SendMessage("Please wait for the current vote to finish!"); return; }

View File

@ -28,7 +28,7 @@ namespace MCGalaxy.Commands
public override void Use(Player p, string message) public override void Use(Player p, string message)
{ {
if (p == null) { Player.SendMessage(p, "This command can only be used in-game!"); return; } if (p == null) { MessageInGameOnly(p); return; }
if (message != "") { Help(p); return; } if (message != "") { Help(p); return; }
if (p.possess != "") if (p.possess != "")
{ {

View File

@ -30,7 +30,7 @@ namespace MCGalaxy.Commands
public override void Use(Player p, string message) public override void Use(Player p, string message)
{ {
if (p == null) { Player.SendMessage(p, "This command can only be used in-game!"); return; } if (p == null) { MessageInGameOnly(p); return; }
if (message == "") { Help(p); return; } if (message == "") { Help(p); return; }
try try

View File

@ -27,12 +27,9 @@ namespace MCGalaxy.Commands
public override LevelPermission defaultRank { get { return LevelPermission.Operator; } } public override LevelPermission defaultRank { get { return LevelPermission.Operator; } }
public override void Use(Player p, string message) { public override void Use(Player p, string message) {
if (p == null) { if (p == null) { MessageInGameOnly(p); return; }
Player.SendMessage(p, "This command can only be used in-game."); return; if (message == "") { Help(p); return; }
}
if (message == "") {
Help(p); return;
}
if (message.ToLower() != "all" && Block.Byte(message) == Block.Zero) { if (message.ToLower() != "all" && Block.Byte(message) == Block.Zero) {
Player.SendMessage(p, "There is no block \"" + message + "\"."); return; Player.SendMessage(p, "There is no block \"" + message + "\"."); return;
} }

View File

@ -28,28 +28,24 @@ namespace MCGalaxy.Commands
public override void Use(Player p, string message) public override void Use(Player p, string message)
{ {
if (p != null) if (p == null) { MessageInGameOnly(p); return; }
p.ClearBlockchange();
p.painting = false;
p.BlockAction = 0;
p.cmdTimer = false;
p.staticCommands = false;
p.deleteMode = false;
p.ZoneCheck = false;
p.modeType = 0;
p.aiming = false;
p.onTrain = false;
p.isFlying = false;
try
{ {
p.ClearBlockchange(); p.level.blockqueue.RemoveAll(b => b.p == p);
p.painting = false;
p.BlockAction = 0;
p.cmdTimer = false;
p.staticCommands = false;
p.deleteMode = false;
p.ZoneCheck = false;
p.modeType = 0;
p.aiming = false;
p.onTrain = false;
p.isFlying = false;
try
{
p.level.blockqueue.RemoveAll(b => b.p == p);
}
finally { BlockQueue.resume(); }
Player.SendMessage(p, "Every toggle or action was aborted.");
return;
} }
Player.SendMessage(p, "This command can only be used in-game!"); finally { BlockQueue.resume(); }
Player.SendMessage(p, "Every toggle or action was aborted.");
} }
public override void Help(Player p) public override void Help(Player p)
{ {

View File

@ -29,11 +29,8 @@ namespace MCGalaxy.Commands
public override void Use(Player p, string message) public override void Use(Player p, string message)
{ {
if (message == "") { Help(p); return; } if (message == "") { Help(p); return; }
if (p == null) if (p == null) { MessageInGameOnly(p); return; }
{
Player.SendMessage(p, "This command can only be used in-game");
return;
}
if (message.Split(' ').Length > 2) { Help(p); return; } if (message.Split(' ').Length > 2) { Help(p); return; }
message = message.ToLower(); message = message.ToLower();
if (message == "clear") if (message == "clear")

View File

@ -28,11 +28,7 @@ namespace MCGalaxy.Commands
public override void Use(Player p, string message) public override void Use(Player p, string message)
{ {
if (p == null) if (p == null) { MessageInGameOnly(p); return; }
{
Player.SendMessage(p, "This command can only be used in-game");
return;
}
string[] parameters = message.Split(' '); string[] parameters = message.Split(' ');
ushort[] click = p.lastClick; ushort[] click = p.lastClick;

View File

@ -29,11 +29,7 @@ namespace MCGalaxy.Commands
public override void Use(Player p, string message) public override void Use(Player p, string message)
{ {
if (p == null) if (p == null) { MessageInGameOnly(p); return; }
{
Player.SendMessage(p, "This command can only be used in-game");
return;
}
string foundcmd, foundmessage = ""; int foundnum = 0; string foundcmd, foundmessage = ""; int foundnum = 0;
if (message.IndexOf(' ') == -1) if (message.IndexOf(' ') == -1)

View File

@ -28,9 +28,7 @@ namespace MCGalaxy.Commands
public CmdDraw() { } public CmdDraw() { }
public override void Use(Player p, string message) { public override void Use(Player p, string message) {
if (p == null) { if (p == null) { MessageInGameOnly(p); return; }
Player.SendMessage(p, "This command can only be used in-game!"); return;
}
if (p.level.permissionbuild > p.group.Permission) { if (p.level.permissionbuild > p.group.Permission) {
p.SendMessage("You can not edit this map."); return; p.SendMessage("You can not edit this map."); return;
} }

View File

@ -28,18 +28,12 @@ namespace MCGalaxy.Commands
public override void Use(Player p, string message) public override void Use(Player p, string message)
{ {
if (p == null) if (p == null) { MessageInGameOnly(p); return; }
{
Player.SendMessage(p, "This command can only be used in-game"); int x = (ushort)(p.pos[0] / 32);
return; int y = (ushort)((p.pos[1] / 32) - 1);
} int z = (ushort)(p.pos[2] / 32);
else Command.all.Find("click").Use(p, x + " " + y + " " + z);
{
int click1 = (ushort)(p.pos[0] / 32);
int click2 = (ushort)((p.pos[1] / 32) - 1);
int click3 = (ushort)(p.pos[2] / 32);
Command.all.Find("click").Use(p, click1 + " " + click2 + " " + click3);
}
} }
public override void Help(Player p) public override void Help(Player p)
{ {

View File

@ -32,16 +32,12 @@ namespace MCGalaxy.Commands
public override void Use(Player p, string message) public override void Use(Player p, string message)
{ {
if (p == null) { MessageInGameOnly(p); return; }
if (Server.agreetorulesonentry == false) if (Server.agreetorulesonentry == false)
{ {
Player.SendMessage(p, "This command can only be used if agree-to-rules-on-entry is enabled!"); Player.SendMessage(p, "This command can only be used if agree-to-rules-on-entry is enabled!");
return; return;
} }
if (p == null)
{
Player.SendMessage(p, "This command can only be used in-game");
return;
}
//If someone is ranked before agreeing to the rules they are locked and cannot use any commands unless demoted back to guest //If someone is ranked before agreeing to the rules they are locked and cannot use any commands unless demoted back to guest
/*if (p.group.Permission > LevelPermission.Guest) /*if (p.group.Permission > LevelPermission.Guest)
{ {

View File

@ -30,12 +30,8 @@ namespace MCGalaxy.Commands
public override void Use(Player p, string message) public override void Use(Player p, string message)
{ {
if (p == null) { MessageInGameOnly(p); return; }
if (message.Split(' ').Length < 2) { Help(p); return; } if (message.Split(' ').Length < 2) { Help(p); return; }
if (p == null)
{
Player.SendMessage(p, "This command can only be used in-game");
return;
}
string foundPath = message.Split(' ')[1].ToLower(); string foundPath = message.Split(' ')[1].ToLower();
if (!Player.ValidName(foundPath)) { Player.SendMessage(p, "Invalid AI name!"); return; } if (!Player.ValidName(foundPath)) { Player.SendMessage(p, "Invalid AI name!"); return; }

View File

@ -26,28 +26,19 @@ namespace MCGalaxy.Commands
public override LevelPermission defaultRank { get { return LevelPermission.AdvBuilder; } } public override LevelPermission defaultRank { get { return LevelPermission.AdvBuilder; } }
public CmdC4() { } public CmdC4() { }
public override void Use(Player p, string message) public override void Use(Player p, string message) {
{ if (p == null) { MessageInGameOnly(p); return; }
if (p != null)
{ if (p.level.physics >= 1 && p.level.physics < 5) {
if (p.level.physics >= 1 && p.level.physics < 5) sbyte numb = Level.C4.NextCircuit(p.level);
{ Level.C4.C4s c4 = new Level.C4.C4s(numb);
sbyte numb = Level.C4.NextCircuit(p.level); p.level.C4list.Add(c4);
Level.C4.C4s c4 = new Level.C4.C4s(numb); p.c4circuitNumber = numb;
p.level.C4list.Add(c4); Player.SendMessage(p, "Place any block for c4 and place a " + c.red + "red" + Server.DefaultColor + " block for the detonator!");
p.c4circuitNumber = numb; p.Blockchange += new Player.BlockchangeEventHandler(Blockchange1);
Player.SendMessage(p, "Place any block for c4 and place a " + c.red + "red" + Server.DefaultColor + " block for the detonator!"); } else {
p.Blockchange += new Player.BlockchangeEventHandler(Blockchange1); Player.SendMessage(p, "To use c4, the physics level must be 1, 2, 3 or 4");
return;
}
else
{
Player.SendMessage(p, "To use c4, the physics level must be 1, 2, 3 or 4");
return;
}
} }
Player.SendMessage(p, "This command can only be used in-game!");
return;
} }
public override void Help(Player p) public override void Help(Player p)
{ {

View File

@ -30,6 +30,7 @@ namespace MCGalaxy.Commands
public override void Use(Player p, string message) public override void Use(Player p, string message)
{ {
if (p == null) { MessageInGameOnly(p); return; }
if (!Server.agreetorulesonentry) if (!Server.agreetorulesonentry)
{ {
Player.SendMessage(p, "This command can only be used if agree-to-rules-on-entry is enabled in the console!"); Player.SendMessage(p, "This command can only be used if agree-to-rules-on-entry is enabled in the console!");
@ -40,11 +41,6 @@ namespace MCGalaxy.Commands
Player.SendMessage(p, "Your awesomeness prevents you from using this command"); Player.SendMessage(p, "Your awesomeness prevents you from using this command");
return; return;
} }
if (p == null)
{
Player.SendMessage(p, "This command can only be used in-game");
return;
}
p.Kick("If you don't agree with the rules, consider playing elsewhere."); p.Kick("If you don't agree with the rules, consider playing elsewhere.");
} }

View File

@ -32,16 +32,9 @@ namespace MCGalaxy.Commands
public override void Use(Player p, string message) public override void Use(Player p, string message)
{ {
if (p == null) if (p == null) { MessageInGameOnly(p); return; }
{ if (message == "") { Help(p); return; }
Player.SendMessage(p, "This command can not be used in console!");
return;
}
if (message == "")
{
Help(p);
return;
}
int length = message.Split(' ').Length; int length = message.Split(' ').Length;
try try
{ {

View File

@ -28,7 +28,7 @@ namespace MCGalaxy.Commands
public override LevelPermission defaultRank { get { return LevelPermission.Guest; } } public override LevelPermission defaultRank { get { return LevelPermission.Guest; } }
public override void Use(Player p, string message) public override void Use(Player p, string message)
{ {
if (p == null) { Player.SendMessage(p, "This command can only be used in-game"); return; } if (p == null) { MessageInGameOnly(p); return; }
string[] command = message.ToLower().Split(' '); string[] command = message.ToLower().Split(' ');
string par0 = String.Empty; string par0 = String.Empty;
string par1 = String.Empty; string par1 = String.Empty;

View File

@ -29,7 +29,7 @@ namespace MCGalaxy.Commands
public override void Use(Player p, string message) public override void Use(Player p, string message)
{ {
if (p == null) { Player.SendMessage(p, "This command can only be used in-game"); return; } if (p == null) { MessageInGameOnly(p); return; }
string[] command = message.ToLower().Split(' '); string[] command = message.ToLower().Split(' ');
string par0 = String.Empty; string par0 = String.Empty;
string par1 = String.Empty; string par1 = String.Empty;