From 24d11b7189e6a1cbdeda3518098ee4ad09459140 Mon Sep 17 00:00:00 2001 From: UnknownShadow200 Date: Sat, 20 May 2017 23:51:55 +1000 Subject: [PATCH] Remove /repeat as a separate command, just keep /. --- MCGalaxy/Commands/other/CmdRepeat.cs | 44 ---------------------------- MCGalaxy/MCGalaxy_.csproj | 1 - MCGalaxy/Player/Player.Handlers.cs | 41 +++++++++++++++----------- 3 files changed, 24 insertions(+), 62 deletions(-) delete mode 100644 MCGalaxy/Commands/other/CmdRepeat.cs diff --git a/MCGalaxy/Commands/other/CmdRepeat.cs b/MCGalaxy/Commands/other/CmdRepeat.cs deleted file mode 100644 index 1b79e4d91..000000000 --- a/MCGalaxy/Commands/other/CmdRepeat.cs +++ /dev/null @@ -1,44 +0,0 @@ -/* - Copyright 2011 MCForge - - Dual-licensed under the Educational Community License, Version 2.0 and - the GNU General Public License, Version 3 (the "Licenses"); you may - not use this file except in compliance with the Licenses. You may - obtain a copy of the Licenses at - - http://www.opensource.org/licenses/ecl2.php - http://www.gnu.org/licenses/gpl-3.0.html - - Unless required by applicable law or agreed to in writing, - software distributed under the Licenses are distributed on an "AS IS" - BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express - or implied. See the Licenses for the specific language governing - permissions and limitations under the Licenses. - */ -namespace MCGalaxy.Commands.Misc { - public sealed class CmdRepeat : Command { - public override string name { get { return "repeat"; } } - public override string type { get { return CommandTypes.Other; } } - public override bool museumUsable { get { return false; } } - public override LevelPermission defaultRank { get { return LevelPermission.Guest; } } - - public override void Use(Player p, string message) { - if (p.lastCMD == "") { Player.Message(p, "No commands used yet."); return; } - - Player.Message(p, "Repeating &b/" + p.lastCMD); - int argsIndex = p.lastCMD.IndexOf(' '); - string cmdName = argsIndex == -1 ? p.lastCMD : p.lastCMD.Substring(0, argsIndex); - string cmdMsg = argsIndex == -1 ? "" : p.lastCMD.Substring(argsIndex + 1); - - Command cmd = Command.all.Find(cmdName); - if (cmd == null) { Player.Message(p, "Unknown command \"" + cmdName + "\"."); } - if (p != null && !p.group.CanExecute(cmd)) { cmd.MessageCannotUse(p); return; } - cmd.Use(p, cmdMsg); - } - - public override void Help(Player p) { - Player.Message(p, "%T/repeat"); - Player.Message(p, "%HRepeats the last used command"); - } - } -} diff --git a/MCGalaxy/MCGalaxy_.csproj b/MCGalaxy/MCGalaxy_.csproj index f5d535315..eee9b5435 100644 --- a/MCGalaxy/MCGalaxy_.csproj +++ b/MCGalaxy/MCGalaxy_.csproj @@ -340,7 +340,6 @@ - diff --git a/MCGalaxy/Player/Player.Handlers.cs b/MCGalaxy/Player/Player.Handlers.cs index 08aefbb15..bf3d1fe84 100644 --- a/MCGalaxy/Player/Player.Handlers.cs +++ b/MCGalaxy/Player/Player.Handlers.cs @@ -165,14 +165,14 @@ namespace MCGalaxy { /// Adds to the BlockDB. Also turns block below to grass/dirt depending on light. /// Return code from DoBlockchange public int ChangeBlock(ushort x, ushort y, ushort z, ExtBlock block) { - ExtBlock old = level.GetExtBlock(x, y, z); + ExtBlock old = level.GetExtBlock(x, y, z); int type = level.DoBlockchange(this, x, y, z, block); if (type == 0) return type; // no change performed if (type == 2) Player.GlobalBlockchange(level, x, y, z, block); // different visually ushort flags = BlockDBFlags.ManualPlace; if (painting && Replacable(old.BlockID)) flags = BlockDBFlags.Painted; - level.BlockDB.Cache.Add(this, x, y, z, flags, old, block); + level.BlockDB.Cache.Add(this, x, y, z, flags, old, block); bool autoGrass = level.GrassGrow && (level.physics == 0 || level.physics == 5); if (!autoGrass) return type; @@ -214,8 +214,8 @@ namespace MCGalaxy { int PacketSize(byte[] buffer) { switch (buffer[0]) { - case (byte)'G': return -2; //For wom - case Opcode.Handshake: return 131; + case (byte)'G': return -2; //For wom + case Opcode.Handshake: return 131; case Opcode.SetBlockClient: if (!loggedIn) goto default; return 9; @@ -242,7 +242,7 @@ namespace MCGalaxy { void HandlePacket(byte[] buffer) { switch (buffer[0]) { - case Opcode.Ping: break; + case Opcode.Ping: break; case Opcode.Handshake: HandleLogin(buffer); break; case Opcode.SetBlockClient: @@ -626,22 +626,29 @@ namespace MCGalaxy { } bool DoCommand(string text) { - // Typing / will act as /repeat + // Typing / repeats last command executed if (text == "/") { - HandleCommand("repeat", ""); return true; + if (lastCMD == "") { + Player.Message(this, "Cannot repeat command: You haven't used any commands yet."); + return true; + } + text = lastCMD; + Player.Message(this, "Repeating %T/" + lastCMD); } else if (text[0] == '/' || text[0] == '!') { text = text.Remove(0, 1); - int sep = text.IndexOf(' '); - if (sep == -1) { - HandleCommand(text.ToLower(), ""); - } else { - string cmd = text.Substring(0, sep).ToLower(); - string msg = text.Substring(sep + 1); - HandleCommand(cmd, msg); - } - return true; + } else { + return false; } - return false; + + int sep = text.IndexOf(' '); + if (sep == -1) { + HandleCommand(text.ToLower(), ""); + } else { + string cmd = text.Substring(0, sep).ToLower(); + string msg = text.Substring(sep + 1); + HandleCommand(cmd, msg); + } + return true; } string HandleJoker(string text) {