Now with less use of Command.All.Find()

This commit is contained in:
UnknownShadow200 2016-06-20 10:49:52 +10:00
parent 1eee2dda2c
commit b098e32481
7 changed files with 16 additions and 23 deletions

View File

@ -73,7 +73,7 @@ namespace MCGalaxy.Commands
} else if (cmd == "SPAWN") { } else if (cmd == "SPAWN") {
Command.all.Find("setspawn").Use(p, ""); Command.all.Find("setspawn").Use(p, "");
} else if (cmd == "PRESET") { } 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") { } else if (cmd == "ENV") {
HandleEnvCommand(p, arg, arg2); HandleEnvCommand(p, arg, arg2);
} else if (cmd == "MAP") { } else if (cmd == "MAP") {

View File

@ -17,10 +17,8 @@
*/ */
using System; using System;
namespace MCGalaxy.Commands { namespace MCGalaxy.Commands {
public class CmdNotes : Command {
public class CmdNotes : Command {
public override string name { get { return "notes"; } } public override string name { get { return "notes"; } }
public override string shortcut { get { return ""; } } public override string shortcut { get { return ""; } }
public override string type { get { return CommandTypes.Moderation; } } 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 name { get { return "mynotes"; } }
public override string shortcut { get { return ""; } } public override string shortcut { get { return ""; } }
public override string type { get { return CommandTypes.Other; } } 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 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) { MessageInGameOnly(p); } if (Player.IsSuper(p)) { MessageInGameOnly(p); return; }
Command.all.Find("notes").Use(p, p.name); base.Use(p, p.name);
} }
public override void Help(Player p) { public override void Help(Player p) {

View File

@ -34,16 +34,15 @@ namespace MCGalaxy.Commands
Player.Message(p, "There is no block \"" + message + "\"."); return; Player.Message(p, "There is no block \"" + message + "\"."); return;
} }
int phys = p.level.physics; int phys = p.level.physics;
Command.all.Find("physics").Use(p, "0"); CmdPhysics.SetPhysics(p.level, 0);
Command cmd = Command.all.Find("replaceall"); Command cmd = Command.all.Find("replaceall");
string args = message.CaselessEq("all") ? string args = message.CaselessEq("all") ?
"lavafall waterfall lava_fast active_lava active_water " + "lavafall waterfall lava_fast active_lava active_water " +
"active_hot_lava active_cold_water fast_hot_lava magma geyser air" : "active_hot_lava active_cold_water fast_hot_lava magma geyser" : message;
message + " air"; cmd.Use(p, args + " air");
cmd.Use(p, args);
Command.all.Find("physics").Use(p, phys.ToString()); CmdPhysics.SetPhysics(p.level, phys);
Player.GlobalMessage("Unflooded!"); Player.GlobalMessage("Unflooded!");
} }

View File

@ -20,7 +20,7 @@ using MCGalaxy.Drawing.Brushes;
using MCGalaxy.Drawing.Ops; using MCGalaxy.Drawing.Ops;
namespace MCGalaxy.Commands.Building { namespace MCGalaxy.Commands.Building {
public sealed class CmdWriteText : Command { public class CmdWriteText : Command {
public override string name { get { return "writetext"; } } public override string name { get { return "writetext"; } }
public override string shortcut { get { return "wrt"; } } public override string shortcut { get { return "wrt"; } }
public override string type { get { return CommandTypes.Building; } } 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 name { get { return "write"; } }
public override string shortcut { get { return ""; } } 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) { 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) { public override void Help(Player p) {

View File

@ -888,7 +888,7 @@ namespace MCGalaxy.Gui
} }
else 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"); PlayersTextBox.AppendTextAndScroll("Sent Message '" + ImpersonateORSendCmdTxt.Text + "' as player");
} }
ImpersonateORSendCmdTxt.Text = ""; ImpersonateORSendCmdTxt.Text = "";

View File

@ -192,6 +192,7 @@
<Compile Include="Commands\CPE\CmdModel.cs" /> <Compile Include="Commands\CPE\CmdModel.cs" />
<Compile Include="Commands\CPE\CmdReachDistance.cs" /> <Compile Include="Commands\CPE\CmdReachDistance.cs" />
<Compile Include="Commands\CPE\CmdSkin.cs" /> <Compile Include="Commands\CPE\CmdSkin.cs" />
<Compile Include="Commands\CPE\CmdTexture.cs" />
<Compile Include="Commands\CPE\CustomBlockCommand.cs" /> <Compile Include="Commands\CPE\CustomBlockCommand.cs" />
<Compile Include="Commands\Economy\CmdAward.cs" /> <Compile Include="Commands\Economy\CmdAward.cs" />
<Compile Include="Commands\Economy\CmdAwardMod.cs" /> <Compile Include="Commands\Economy\CmdAwardMod.cs" />
@ -388,7 +389,6 @@
<Compile Include="Commands\World\CmdReveal.cs" /> <Compile Include="Commands\World\CmdReveal.cs" />
<Compile Include="Commands\World\CmdSave.cs" /> <Compile Include="Commands\World\CmdSave.cs" />
<Compile Include="Commands\World\CmdSetspawn.cs" /> <Compile Include="Commands\World\CmdSetspawn.cs" />
<Compile Include="Commands\World\CmdTexture.cs" />
<Compile Include="Commands\World\CmdUnflood.cs" /> <Compile Include="Commands\World\CmdUnflood.cs" />
<Compile Include="Commands\World\CmdUnload.cs" /> <Compile Include="Commands\World\CmdUnload.cs" />
<Compile Include="Commands\World\PermissionCmd.cs" /> <Compile Include="Commands\World\PermissionCmd.cs" />