Warps/Waypoints don't have to be lowercase anymore.

This commit is contained in:
UnknownShadow200 2017-08-11 12:41:54 +10:00
parent 96185e14ac
commit e7077a0bdd
4 changed files with 18 additions and 24 deletions

View File

@ -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] <value> %H- Sets [option] on [level]");

View File

@ -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 {

View File

@ -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");
}
}

View File

@ -349,8 +349,6 @@
<Compile Include="Commands\other\CmdTimer.cs" />
<Compile Include="Commands\other\CmdTp.cs" />
<Compile Include="Commands\other\CmdTpA.cs" />
<Compile Include="Commands\other\CmdWarp.cs" />
<Compile Include="Commands\other\CmdWaypoint.cs" />
<Compile Include="Commands\other\QuitCmds.cs" />
<Compile Include="Commands\Scripting\CmdCmdCreate.cs" />
<Compile Include="Commands\Scripting\CmdCmdLoad.cs" />
@ -373,6 +371,8 @@
<Compile Include="Commands\World\CmdOverseer.cs" />
<Compile Include="Commands\World\CmdOverseer.SubCommands.cs" />
<Compile Include="Commands\World\CmdPause.cs" />
<Compile Include="Commands\World\CmdWarp.cs" />
<Compile Include="Commands\World\CmdWaypoint.cs" />
<Compile Include="Commands\World\PermissionCmds.cs" />
<Compile Include="Commands\World\CmdPhysics.cs" />
<Compile Include="Commands\World\CmdRenameLvl.cs" />