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 void Use(Player p, string message) {
if (p == null) {
Player.SendMessage(p, "This command cannot be used from console."); return;
}
if (message == "") {
Help(p); return;
}
if (p == null) { MessageInGameOnly(p); return; }
if (message == "") { Help(p); return; }
float 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 void Use(Player p, string message) {
if (p == null) {
Server.s.Log("This command can only be used in-game."); return;
}
if (p == null) { MessageInGameOnly(p); return; }
string[] parts = message.ToLower().Split(' ');
if (parts.Length == 0) {
if (Server.Chatrooms.Count == 0) {
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)
{
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")
{
p.ignoreglobal = !p.ignoreglobal;

View File

@ -29,7 +29,7 @@ namespace MCGalaxy.Commands
public override void Use(Player p, string message)
{
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 (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 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) {
p.ClearBlockchange();
p.RevertBlock(x, y, z);
}
protected void MessageInGameOnly(Player p) {
Player.SendMessage(p, "/" + name + " can only be used in-game.");
}
}
public sealed class CommandTypes {

View File

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

View File

@ -28,53 +28,36 @@ namespace MCGalaxy.Commands
public static string keywords { get { return ""; } }
public CmdAfk() { }
public override void Use(Player p, string message)
{
if (p != null)
{
if (Server.chatmod) {
Player.SendMessage(p, "You cannot use /afk while chat moderation is enabled");
return;
}
if (message != "list")
{
if (p.joker)
{
message = "";
}
if (!Server.afkset.Contains(p.name))
{
Server.afkset.Add(p.name);
if (p.muted)
{
message = "";
}
Player.GlobalMessage("-" + p.color + p.DisplayName + Server.DefaultColor + "- is AFK " + message);
//IRCBot.Say(p.name + " is AFK " + message);
Server.IRC.Say(p.DisplayName + " is AFK " + message);
p.afkStart = DateTime.Now;
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;
}
public override void Use(Player p, string message) {
if (p == null) { MessageInGameOnly(p); 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 (!Server.afkset.Contains(p.name)) {
Server.afkset.Add(p.name);
if (p.muted)
message = "";
Player.GlobalMessage("-" + p.color + p.DisplayName + Server.DefaultColor + "- is AFK " + message);
//IRCBot.Say(p.name + " is AFK " + message);
Server.IRC.Say(p.DisplayName + " is AFK " + message);
p.afkStart = DateTime.Now;
} 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");
}
} else {
foreach (string s in Server.afkset)
Player.SendMessage(p, s);
}
Player.SendMessage(p, "This command can only be used in-game");
}
public override void Help(Player p)
{
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 CmdBotAdd() { }
public override void Use(Player p, string message)
{
public override void Use(Player p, string message) {
if (message == "") { Help(p); return; }
if (p != null)
{
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.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");
if (p == null) { MessageInGameOnly(p); 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.Add(bot);
}
public override void Help(Player p)
{
public override void Help(Player p) {
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)
{
if (message == "") { Help(p); return; }
if (p == null) {
Player.SendMessage(p, "This command can only be used in-game!"); return;
}
try
{
if (message.ToLower() == "all")
{
PlayerBot.RemoveAllFromLevel(p.level);
}
else
{
PlayerBot who = PlayerBot.Find(message);
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.");
}
if (p == null) { MessageInGameOnly(p); return; }
try
{
if (message.ToLower() == "all") {
PlayerBot.RemoveAllFromLevel(p.level);
} else {
PlayerBot who = PlayerBot.Find(message);
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)
{

View File

@ -29,11 +29,8 @@ namespace MCGalaxy.Commands
public override void Use(Player p, string message)
{
if (message == "") { Help(p); return; }
if (p == null)
{
Player.SendMessage(p, "This command can only be used in-game");
return;
}
if (p == null) { MessageInGameOnly(p); return; }
PlayerBot who = PlayerBot.Find(message);
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; }

View File

@ -29,11 +29,7 @@ namespace MCGalaxy.Commands
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.canBuild)
{
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)
{
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 (p.hidden)

View File

@ -27,7 +27,7 @@ namespace MCGalaxy.Commands
public CmdReferee() { }
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)
{
p.referee = false;

View File

@ -28,7 +28,7 @@ namespace MCGalaxy.Commands
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 (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)
{
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 (p.possess != "")
{

View File

@ -30,7 +30,7 @@ namespace MCGalaxy.Commands
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; }
try

View File

@ -27,12 +27,9 @@ namespace MCGalaxy.Commands
public override LevelPermission defaultRank { get { return LevelPermission.Operator; } }
public override void Use(Player p, string message) {
if (p == null) {
Player.SendMessage(p, "This command can only be used in-game."); return;
}
if (message == "") {
Help(p); return;
}
if (p == null) { MessageInGameOnly(p); return; }
if (message == "") { Help(p); return; }
if (message.ToLower() != "all" && Block.Byte(message) == Block.Zero) {
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)
{
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.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;
p.level.blockqueue.RemoveAll(b => b.p == p);
}
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)
{

View File

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

View File

@ -28,11 +28,7 @@ namespace MCGalaxy.Commands
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[] parameters = message.Split(' ');
ushort[] click = p.lastClick;

View File

@ -29,11 +29,7 @@ namespace MCGalaxy.Commands
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 foundcmd, foundmessage = ""; int foundnum = 0;
if (message.IndexOf(' ') == -1)

View File

@ -28,9 +28,7 @@ namespace MCGalaxy.Commands
public CmdDraw() { }
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.level.permissionbuild > p.group.Permission) {
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)
{
if (p == null)
{
Player.SendMessage(p, "This command can only be used in-game");
return;
}
else
{
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);
}
if (p == null) { MessageInGameOnly(p); return; }
int x = (ushort)(p.pos[0] / 32);
int y = (ushort)((p.pos[1] / 32) - 1);
int z = (ushort)(p.pos[2] / 32);
Command.all.Find("click").Use(p, x + " " + y + " " + z);
}
public override void Help(Player p)
{

View File

@ -32,16 +32,12 @@ namespace MCGalaxy.Commands
public override void Use(Player p, string message)
{
if (p == null) { MessageInGameOnly(p); return; }
if (Server.agreetorulesonentry == false)
{
Player.SendMessage(p, "This command can only be used if agree-to-rules-on-entry is enabled!");
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 (p.group.Permission > LevelPermission.Guest)
{

View File

@ -30,12 +30,8 @@ namespace MCGalaxy.Commands
public override void Use(Player p, string message)
{
if (p == null) { MessageInGameOnly(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();
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 CmdC4() { }
public override void Use(Player p, string message)
{
if (p != null)
{
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);
p.level.C4list.Add(c4);
p.c4circuitNumber = numb;
Player.SendMessage(p, "Place any block for c4 and place a " + c.red + "red" + Server.DefaultColor + " block for the detonator!");
p.Blockchange += new Player.BlockchangeEventHandler(Blockchange1);
return;
}
else
{
Player.SendMessage(p, "To use c4, the physics level must be 1, 2, 3 or 4");
return;
}
public override void Use(Player p, string message) {
if (p == null) { MessageInGameOnly(p); return; }
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);
p.level.C4list.Add(c4);
p.c4circuitNumber = numb;
Player.SendMessage(p, "Place any block for c4 and place a " + c.red + "red" + Server.DefaultColor + " block for the detonator!");
p.Blockchange += new Player.BlockchangeEventHandler(Blockchange1);
} else {
Player.SendMessage(p, "To use c4, the physics level must be 1, 2, 3 or 4");
}
Player.SendMessage(p, "This command can only be used in-game!");
return;
}
public override void Help(Player p)
{

View File

@ -30,6 +30,7 @@ namespace MCGalaxy.Commands
public override void Use(Player p, string message)
{
if (p == null) { MessageInGameOnly(p); return; }
if (!Server.agreetorulesonentry)
{
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");
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.");
}

View File

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

View File

@ -28,7 +28,7 @@ namespace MCGalaxy.Commands
public override LevelPermission defaultRank { get { return LevelPermission.Guest; } }
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 par0 = String.Empty;
string par1 = String.Empty;

View File

@ -29,7 +29,7 @@ namespace MCGalaxy.Commands
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 par0 = String.Empty;
string par1 = String.Empty;