From b098e32481399fb2ace3cd911986b9f72dafd896 Mon Sep 17 00:00:00 2001 From: UnknownShadow200 Date: Mon, 20 Jun 2016 10:49:52 +1000 Subject: [PATCH] Now with less use of Command.All.Find() --- Commands/{World => CPE}/CmdTexture.cs | 0 Commands/CmdOverseer.cs | 2 +- Commands/Moderation/CmdNotes.cs | 13 +++++-------- Commands/World/CmdUnflood.cs | 9 ++++----- Commands/building/CmdWrite.cs | 11 ++++------- GUI/Window.cs | 2 +- MCGalaxy_.csproj | 2 +- 7 files changed, 16 insertions(+), 23 deletions(-) rename Commands/{World => CPE}/CmdTexture.cs (100%) diff --git a/Commands/World/CmdTexture.cs b/Commands/CPE/CmdTexture.cs similarity index 100% rename from Commands/World/CmdTexture.cs rename to Commands/CPE/CmdTexture.cs diff --git a/Commands/CmdOverseer.cs b/Commands/CmdOverseer.cs index 301b5448d..617624d48 100644 --- a/Commands/CmdOverseer.cs +++ b/Commands/CmdOverseer.cs @@ -73,7 +73,7 @@ namespace MCGalaxy.Commands } else if (cmd == "SPAWN") { Command.all.Find("setspawn").Use(p, ""); } else if (cmd == "PRESET") { - Command.all.Find("env").Use(p, "l preset " + arg); + Command.all.Find("env").Use(p, "preset " + arg); } else if (cmd == "ENV") { HandleEnvCommand(p, arg, arg2); } else if (cmd == "MAP") { diff --git a/Commands/Moderation/CmdNotes.cs b/Commands/Moderation/CmdNotes.cs index 40ed57e88..4f9a3b9dd 100644 --- a/Commands/Moderation/CmdNotes.cs +++ b/Commands/Moderation/CmdNotes.cs @@ -17,10 +17,8 @@ */ using System; -namespace MCGalaxy.Commands { - - public class CmdNotes : Command { - +namespace MCGalaxy.Commands { + public class CmdNotes : Command { public override string name { get { return "notes"; } } public override string shortcut { get { return ""; } } public override string type { get { return CommandTypes.Moderation; } } @@ -74,8 +72,7 @@ namespace MCGalaxy.Commands { } } - public class CmdMyNotes : Command { - + public sealed class CmdMyNotes : CmdNotes { public override string name { get { return "mynotes"; } } public override string shortcut { get { return ""; } } public override string type { get { return CommandTypes.Other; } } @@ -83,8 +80,8 @@ namespace MCGalaxy.Commands { public override LevelPermission defaultRank { get { return LevelPermission.Guest; } } public override void Use(Player p, string message) { - if (p == null) { MessageInGameOnly(p); } - Command.all.Find("notes").Use(p, p.name); + if (Player.IsSuper(p)) { MessageInGameOnly(p); return; } + base.Use(p, p.name); } public override void Help(Player p) { diff --git a/Commands/World/CmdUnflood.cs b/Commands/World/CmdUnflood.cs index 74eb75157..2eafe1612 100644 --- a/Commands/World/CmdUnflood.cs +++ b/Commands/World/CmdUnflood.cs @@ -34,16 +34,15 @@ namespace MCGalaxy.Commands Player.Message(p, "There is no block \"" + message + "\"."); return; } int phys = p.level.physics; - Command.all.Find("physics").Use(p, "0"); + CmdPhysics.SetPhysics(p.level, 0); Command cmd = Command.all.Find("replaceall"); string args = message.CaselessEq("all") ? "lavafall waterfall lava_fast active_lava active_water " + - "active_hot_lava active_cold_water fast_hot_lava magma geyser air" : - message + " air"; - cmd.Use(p, args); + "active_hot_lava active_cold_water fast_hot_lava magma geyser" : message; + cmd.Use(p, args + " air"); - Command.all.Find("physics").Use(p, phys.ToString()); + CmdPhysics.SetPhysics(p.level, phys); Player.GlobalMessage("Unflooded!"); } diff --git a/Commands/building/CmdWrite.cs b/Commands/building/CmdWrite.cs index 583b668da..16f874d67 100644 --- a/Commands/building/CmdWrite.cs +++ b/Commands/building/CmdWrite.cs @@ -20,7 +20,7 @@ using MCGalaxy.Drawing.Brushes; using MCGalaxy.Drawing.Ops; namespace MCGalaxy.Commands.Building { - public sealed class CmdWriteText : Command { + public class CmdWriteText : Command { public override string name { get { return "writetext"; } } public override string shortcut { get { return "wrt"; } } public override string type { get { return CommandTypes.Building; } } @@ -86,16 +86,13 @@ namespace MCGalaxy.Commands.Building { } } - public sealed class CmdWrite : Command { - + public sealed class CmdWrite : CmdWriteText { public override string name { get { return "write"; } } public override string shortcut { get { return ""; } } - public override string type { get { return CommandTypes.Building; } } - public override bool museumUsable { get { return false; } } - public override LevelPermission defaultRank { get { return LevelPermission.AdvBuilder; } } public override void Use(Player p, string message) { - Command.all.Find("writetext").Use(p, "1 1 " + message); + if (message == "") { Help(p); return; } + base.Use(p, "1 1 " + message); } public override void Help(Player p) { diff --git a/GUI/Window.cs b/GUI/Window.cs index fb9e22c33..385e742f4 100644 --- a/GUI/Window.cs +++ b/GUI/Window.cs @@ -888,7 +888,7 @@ namespace MCGalaxy.Gui } else { - Command.all.Find("Impersonate").Use(null, prpertiesofplyer.name + " " + ImpersonateORSendCmdTxt.Text); + Command.all.Find("impersonate").Use(null, prpertiesofplyer.name + " " + ImpersonateORSendCmdTxt.Text); PlayersTextBox.AppendTextAndScroll("Sent Message '" + ImpersonateORSendCmdTxt.Text + "' as player"); } ImpersonateORSendCmdTxt.Text = ""; diff --git a/MCGalaxy_.csproj b/MCGalaxy_.csproj index 91853855b..a3ae453eb 100644 --- a/MCGalaxy_.csproj +++ b/MCGalaxy_.csproj @@ -192,6 +192,7 @@ + @@ -388,7 +389,6 @@ -