From e7077a0bdd6204b0a2038a9d2915b5941471ad01 Mon Sep 17 00:00:00 2001 From: UnknownShadow200 Date: Fri, 11 Aug 2017 12:41:54 +1000 Subject: [PATCH] Warps/Waypoints don't have to be lowercase anymore. --- MCGalaxy/Commands/World/CmdMap.cs | 4 +-- MCGalaxy/Commands/{other => World}/CmdWarp.cs | 26 +++++++++---------- .../Commands/{other => World}/CmdWaypoint.cs | 8 ++---- MCGalaxy/MCGalaxy_.csproj | 4 +-- 4 files changed, 18 insertions(+), 24 deletions(-) rename MCGalaxy/Commands/{other => World}/CmdWarp.cs (83%) rename MCGalaxy/Commands/{other => World}/CmdWaypoint.cs (78%) diff --git a/MCGalaxy/Commands/World/CmdMap.cs b/MCGalaxy/Commands/World/CmdMap.cs index 96f93b21a..ecdbf81c6 100644 --- a/MCGalaxy/Commands/World/CmdMap.cs +++ b/MCGalaxy/Commands/World/CmdMap.cs @@ -140,9 +140,7 @@ namespace MCGalaxy.Commands.World { GetBool(cfg.Buildable), GetBool(cfg.Deletable)); } - static string GetBool(bool value, bool console = false) { - return console ? (value ? "ON" : "OFF") : (value ? "&aON" : "&cOFF"); - } + static string GetBool(bool value) { return value ? "&aON" : "&cOFF"; } public override void Help(Player p) { Player.Message(p, "%T/Map [level] [option] %H- Sets [option] on [level]"); diff --git a/MCGalaxy/Commands/other/CmdWarp.cs b/MCGalaxy/Commands/World/CmdWarp.cs similarity index 83% rename from MCGalaxy/Commands/other/CmdWarp.cs rename to MCGalaxy/Commands/World/CmdWarp.cs index e311022ed..b68c85e16 100644 --- a/MCGalaxy/Commands/other/CmdWarp.cs +++ b/MCGalaxy/Commands/World/CmdWarp.cs @@ -21,7 +21,7 @@ using System.Threading; namespace MCGalaxy.Commands.Misc { public class CmdWarp : Command { public override string name { get { return "Warp"; } } - public override string type { get { return CommandTypes.Other; } } + public override string type { get { return CommandTypes.World; } } public override bool museumUsable { get { return false; } } public override LevelPermission defaultRank { get { return LevelPermission.Guest; } } public override bool SuperUseable { get { return false; } } @@ -32,18 +32,18 @@ namespace MCGalaxy.Commands.Misc { new CommandPerm(LevelPermission.Operator, "+ can move/edit warps"), }; } } - protected virtual bool CheckExtraPerms { get { return true; } } public override void Use(Player p, string message) { - UseCore(p, message, WarpList.Global, "Warp"); + UseCore(p, message, WarpList.Global, "Warp", true); } - protected void UseCore(Player p, string message, WarpList warps, string group) { - string[] args = message.ToLower().SplitSpaces(); + protected void UseCore(Player p, string message, WarpList warps, + string group, bool checkExtraPerms) { + string[] args = message.SplitSpaces(); string cmd = args[0]; if (cmd.Length == 0) { Help(p); return; } - if (args.Length == 1 && (cmd == "list" || cmd == "view")) { + if (args.Length == 1 && cmd.CaselessEq("list")) { Player.Message(p, "{0}s:", group); foreach (Warp wr in warps.Items) { if (LevelInfo.FindExact(wr.Level) != null) @@ -57,8 +57,8 @@ namespace MCGalaxy.Commands.Misc { } string name = args[1]; - if (cmd == "create" || cmd == "add") { - if (CheckExtraPerms && !CheckExtraPerm(p, 1)) return; + if (cmd.CaselessEq("create") || cmd.CaselessEq("add")) { + if (checkExtraPerms && !CheckExtraPerm(p, 1)) return; if (warps.Exists(name)) { Player.Message(p, "{0} already exists", group); return; } Player who = args.Length == 2 ? p : PlayerInfo.FindMatches(p, args[2]); @@ -66,15 +66,15 @@ namespace MCGalaxy.Commands.Misc { warps.Create(name, who); Player.Message(p, "{0} {1} created.", group, name); - } else if (cmd == "delete" || cmd == "remove") { - if (CheckExtraPerms && !CheckExtraPerm(p, 2)) return; + } else if (cmd.CaselessEq("delete") || cmd.CaselessEq("remove")) { + if (checkExtraPerms && !CheckExtraPerm(p, 2)) return; Warp warp = Matcher.FindWarps(p, warps, name); if (warp == null) return; warps.Remove(warp, p); Player.Message(p, "{0} {1} deleted.", group, warp.Name); - } else if (cmd == "move" || cmd == "update") { - if (CheckExtraPerms && !CheckExtraPerm(p, 3)) return; + } else if (cmd.CaselessEq("move") || cmd.CaselessEq("update")) { + if (checkExtraPerms && !CheckExtraPerm(p, 3)) return; Warp warp = Matcher.FindWarps(p, warps, name); if (warp == null) return; @@ -83,7 +83,7 @@ namespace MCGalaxy.Commands.Misc { warps.Update(warp, who); Player.Message(p, "{0} {1} moved.", group, warp.Name); - } else if (cmd == "goto") { + } else if (cmd.CaselessEq("goto")) { Warp warp = Matcher.FindWarps(p, warps, name); if (warp != null) warps.Goto(warp, p); } else { diff --git a/MCGalaxy/Commands/other/CmdWaypoint.cs b/MCGalaxy/Commands/World/CmdWaypoint.cs similarity index 78% rename from MCGalaxy/Commands/other/CmdWaypoint.cs rename to MCGalaxy/Commands/World/CmdWaypoint.cs index bb9087ab6..9a25d28d8 100644 --- a/MCGalaxy/Commands/other/CmdWaypoint.cs +++ b/MCGalaxy/Commands/World/CmdWaypoint.cs @@ -21,23 +21,19 @@ namespace MCGalaxy.Commands.Misc { public sealed class CmdWaypoint : CmdWarp { public override string name { get { return "Waypoint"; } } public override string shortcut { get { return "wp"; } } - public override string type { get { return CommandTypes.Other; } } - public override bool museumUsable { get { return true; } } public override LevelPermission defaultRank { get { return LevelPermission.Builder; } } - public override bool SuperUseable { get { return false; } } public override CommandPerm[] ExtraPerms { get { return null; } } - protected override bool CheckExtraPerms { get { return false; } } public override void Use(Player p, string message) { - UseCore(p, message, p.Waypoints, "Waypoint"); + UseCore(p, message, p.Waypoints, "Waypoint", false); } public override void Help(Player p) { + Player.Message(p, "%HWaypoints are warps only usable by you."); Player.Message(p, "%T/Waypoint create [name] %H- Create a new waypoint"); Player.Message(p, "%T/Waypoint update [name] %H- Update a waypoint"); Player.Message(p, "%T/Waypoint remove [name] %H- Remove a waypoint"); Player.Message(p, "%T/Waypoint list %H- Shows a list of waypoints"); - Player.Message(p, "%T/Waypoint goto [name] %H- Goto a waypoint"); Player.Message(p, "%T/Waypoint [name] %H- Goto a waypoint"); } } diff --git a/MCGalaxy/MCGalaxy_.csproj b/MCGalaxy/MCGalaxy_.csproj index 5a179917b..08e224bb3 100644 --- a/MCGalaxy/MCGalaxy_.csproj +++ b/MCGalaxy/MCGalaxy_.csproj @@ -349,8 +349,6 @@ - - @@ -373,6 +371,8 @@ + +