From 15c40893ac535bfdb6769af4a1066b6685842531 Mon Sep 17 00:00:00 2001 From: UnknownShadow200 Date: Thu, 9 Jun 2016 12:30:20 +1000 Subject: [PATCH] Remove /killphysics and just make it /physics kill. --- Commands/Moderation/CmdKillPhysics.cs | 54 ---------------------- Commands/World/CmdPhysics.cs | 65 ++++++++++++++++----------- MCGalaxy_.csproj | 1 - 3 files changed, 40 insertions(+), 80 deletions(-) delete mode 100644 Commands/Moderation/CmdKillPhysics.cs diff --git a/Commands/Moderation/CmdKillPhysics.cs b/Commands/Moderation/CmdKillPhysics.cs deleted file mode 100644 index 1cf10e609..000000000 --- a/Commands/Moderation/CmdKillPhysics.cs +++ /dev/null @@ -1,54 +0,0 @@ -/* - ______________________________________________________ -Can be included and resold as part of a larger work (sublicensable) -Commercial use allowed under the following conditions : -Command May only be used by MCGalaxy users.This only gives permission to MCGalaxy and users, This may not be posted on any other site and or forums without the permission of the maker [xTYx728] -Can modify source-code but cannot distribute modifications (derivative works) -Support provided as follows : -For this command any, issues you may contact the maker for help. -Attribution to software creator must be made as specified: -Any edits MUST be reported back to the MCGalaxy forums and credit MUST be given to the respected maker -Software trademarks are included in the license -Software patents are included in the license -Additional terms: -This command is not to be posted on ANY other site and (or) forums. Any edits credit MUST be given to the respected owner. -_______________________________________________________________________________________________________ - -for full licences please go to http://www.binpress.com/license/view/l/2043171cc2d4e3237680e59d87e4dae6 -_______________________________________________________________________________________________________ - Idea by tommyz_. made by xTYx728 -*/ -using System.Threading; -namespace MCGalaxy.Commands -{ - public sealed class CmdKillPhysics : Command - { - public override string name { get { return "killphysics"; } } - public override string shortcut { get { return "kp"; } } - 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 void Use(Player p, string message) - { - if (message == "") - { - Level[] loaded = LevelInfo.Loaded.Items; - foreach (Level l in loaded) - { - if (l.physics > 0) - { - Command.all.Find("physics").Use(null, l.name + " 0"); - Thread.Sleep(500); - } - } - Player.Message(p, "All physics killed"); - } - } - - public override void Help(Player p) - { - Player.Message(p, "/killphysics - kills all physics on every level."); - - } - } -} diff --git a/Commands/World/CmdPhysics.cs b/Commands/World/CmdPhysics.cs index ce52393c4..88233e512 100644 --- a/Commands/World/CmdPhysics.cs +++ b/Commands/World/CmdPhysics.cs @@ -15,27 +15,20 @@ or implied. See the Licenses for the specific language governing permissions and limitations under the Licenses. */ -namespace MCGalaxy.Commands -{ - public sealed class CmdPhysics : Command - { +namespace MCGalaxy.Commands { + public sealed class CmdPhysics : Command { public override string name { get { return "physics"; } } public override string shortcut { get { return ""; } } public override string type { get { return CommandTypes.World; } } public override bool museumUsable { get { return false; } } public override LevelPermission defaultRank { get { return LevelPermission.Operator; } } - public CmdPhysics() { } + public override CommandAlias[] Aliases { + get { return new[] { new CommandAlias("killphysics", "kill") }; } + } public override void Use(Player p, string message) { - if (message == "") { - Level[] loaded = LevelInfo.Loaded.Items; - foreach (Level l in loaded) { - if (l.physics > 0) - Player.Message(p, "&5" + l.name + " %Shas physics at &b" + l.physics + - "%S. &cChecks: " + l.lastCheck + "; Updates: " + l.lastUpdate); - } - return; - } + if (message == "") { ShowPhysics(p); return; } + if (message.CaselessEq("kill")) { KillPhysics(p); return; } string[] args = message.Split(' '); Level level = p != null ? p.level : Server.mainLevel; @@ -51,25 +44,47 @@ namespace MCGalaxy.Commands level = LevelInfo.FindOrShowMatches(p, args[0]); if (level == null) return; } - - level.setPhysics(state); - if (state == 0) level.ClearPhysics(); - string stateDesc = states[state]; - level.ChatLevel("Physics are now " + stateDesc + "%S on &b" + level.name + "%S."); - - stateDesc = stateDesc.Substring( 2 ); - string logInfo = "Physics are now " + stateDesc + " on " + level.name + "."; - Server.s.Log(logInfo); - level.changed = true; + SetPhysics(level, state); } internal static string[] states = { "&cOFF", "&aNormal", "&aAdvanced", "&aHardcore", "&aInstant", "&4Doors-only" }; + + void ShowPhysics(Player p) { + Level[] loaded = LevelInfo.Loaded.Items; + foreach (Level lvl in loaded) { + if (lvl.physics == 0) continue; + Player.Message(p, "&5" + lvl.name + " %Shas physics at &b" + lvl.physics + + "%S. &cChecks: " + lvl.lastCheck + "; Updates: " + lvl.lastUpdate); + } + } + + void KillPhysics(Player p) { + Level[] levels = LevelInfo.Loaded.Items; + foreach (Level lvl in levels) { + if (lvl.physics == 0) continue; + SetPhysics(lvl, 0); + } + Player.Message(p, "Physics killed on all levels."); + } + + static void SetPhysics(Level lvl, int state) { + lvl.setPhysics(state); + if (state == 0) lvl.ClearPhysics(); + string stateDesc = states[state]; + lvl.ChatLevel("Physics are now " + stateDesc + "%S on &b" + lvl.name + "%S."); + + stateDesc = stateDesc.Substring( 2 ); + string logInfo = "Physics are now " + stateDesc + " on " + lvl.name + "."; + Server.s.Log(logInfo); + lvl.changed = true; + } public override void Help(Player p) { Player.Message(p, "%T/physics [map] [0/1/2/3/4/5]"); Player.Message(p, "%HSets the physics state for the given map."); Player.Message(p, "%H If no map name is given, uses the current map."); - Player.Message(p, "%H 0 = off, 1 = on, 2 = advanced, 3 = hardcore, 4 = instant, 5 = doors only"); + Player.Message(p, "%H 0 = off, 1 = on, 2 = advanced, 3 = hardcore, 4 = instant, 5 = doors only"); + Player.Message(p, "%T/physics kill %H- Sets physics to 0 on all loaded levels."); } } } diff --git a/MCGalaxy_.csproj b/MCGalaxy_.csproj index dbbbed54c..1a8ecece0 100644 --- a/MCGalaxy_.csproj +++ b/MCGalaxy_.csproj @@ -283,7 +283,6 @@ -