From e50605d69a733fd40b6c3fda5d721398dfd9b941 Mon Sep 17 00:00:00 2001 From: boy0001 Date: Tue, 28 Jul 2015 03:47:27 +1000 Subject: [PATCH] Minor stuff --- .../plot/commands/MainCommand.java | 34 +++++++++++++++++-- .../plot/object/ConsolePlayer.java | 1 + 2 files changed, 33 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/intellectualcrafters/plot/commands/MainCommand.java b/src/main/java/com/intellectualcrafters/plot/commands/MainCommand.java index aface6672..3ab325f56 100644 --- a/src/main/java/com/intellectualcrafters/plot/commands/MainCommand.java +++ b/src/main/java/com/intellectualcrafters/plot/commands/MainCommand.java @@ -29,6 +29,8 @@ import com.intellectualcrafters.plot.PS; import com.intellectualcrafters.plot.config.C; import com.intellectualcrafters.plot.config.Settings; import com.intellectualcrafters.plot.object.ConsolePlayer; +import com.intellectualcrafters.plot.object.Plot; +import com.intellectualcrafters.plot.object.PlotId; import com.intellectualcrafters.plot.object.PlotPlayer; import com.intellectualcrafters.plot.util.MainUtil; import com.intellectualcrafters.plot.util.MathMan; @@ -192,7 +194,7 @@ public class MainCommand extends CommandManager { .render(); } - public static boolean onCommand(final PlotPlayer player, final String cmd, final String... args) { + public static boolean onCommand(final PlotPlayer player, final String cmd, String... args) { int help_index = -1; String category = null; if (args.length == 0) { @@ -232,6 +234,34 @@ public class MainCommand extends CommandManager { } catch (NumberFormatException e) {} } + else if (ConsolePlayer.isConsole(player) && args.length >= 2) { + System.out.print(1); + String[] split = args[0].split(";"); + String world; + PlotId id; + if (split.length == 2) { + world = player.getLocation().getWorld(); + id = PlotId.fromString(split[0] + ";" + split[1]); + } + else if (split.length == 3) { + world = split[0]; + id = PlotId.fromString(split[1] + ";" + split[2]); + } + else { + id = null; + world = null; + } + if (id != null && PS.get().isPlotWorld(world)) { + System.out.print(2 + " | " + id + " | " + world); + Plot plot = MainUtil.getPlot(world, id); + if (plot != null) { + System.out.print(3 + " | " + plot); + player.teleport(MainUtil.getPlotCenter(plot)); + args = Arrays.copyOfRange(args, 1, args.length); + } + } + + } if (help_index != -1) { displayHelp(player, category, help_index, cmd); return true; @@ -268,7 +298,7 @@ public class MainCommand extends CommandManager { { ArrayList> cmds = getCommands(); cmd = new StringComparison>(label, cmds).getMatchObject(); - MainUtil.sendMessage(plr, C.DID_YOU_MEAN, cmd.getUsage()); + MainUtil.sendMessage(plr, C.DID_YOU_MEAN, cmd.getUsage().replaceAll("{label}", label)); } return CommandHandlingOutput.NOT_FOUND; } diff --git a/src/main/java/com/intellectualcrafters/plot/object/ConsolePlayer.java b/src/main/java/com/intellectualcrafters/plot/object/ConsolePlayer.java index a24702846..2407dea3d 100644 --- a/src/main/java/com/intellectualcrafters/plot/object/ConsolePlayer.java +++ b/src/main/java/com/intellectualcrafters/plot/object/ConsolePlayer.java @@ -48,6 +48,7 @@ public class ConsolePlayer implements PlotPlayer { @Override public Location getLocation() { + System.out.print(loc); return loc; }