From 9fd53af483b79905b6b0d7e3c38ecb71af8f7914 Mon Sep 17 00:00:00 2001 From: Jesse Boyd Date: Wed, 23 Nov 2016 15:47:18 +1100 Subject: [PATCH] Add world argument --- .../plot/commands/Visit.java | 29 ++++++++++++++++--- 1 file changed, 25 insertions(+), 4 deletions(-) diff --git a/Core/src/main/java/com/intellectualcrafters/plot/commands/Visit.java b/Core/src/main/java/com/intellectualcrafters/plot/commands/Visit.java index d7132df25..49bbd944e 100644 --- a/Core/src/main/java/com/intellectualcrafters/plot/commands/Visit.java +++ b/Core/src/main/java/com/intellectualcrafters/plot/commands/Visit.java @@ -4,6 +4,7 @@ import com.intellectualcrafters.plot.PS; import com.intellectualcrafters.plot.config.C; import com.intellectualcrafters.plot.config.Settings; import com.intellectualcrafters.plot.object.Plot; +import com.intellectualcrafters.plot.object.PlotArea; import com.intellectualcrafters.plot.object.PlotPlayer; import com.intellectualcrafters.plot.object.RunnableVal2; import com.intellectualcrafters.plot.object.RunnableVal3; @@ -46,16 +47,36 @@ public class Visit extends Command { } int page = Integer.MIN_VALUE; Collection unsorted = null; + PlotArea sortByArea = player.getApplicablePlotArea(); + boolean shouldSortByArea = Settings.Teleport.PER_WORLD_VISIT; switch (args.length) { - case 2: + case 3: if (!MathMan.isInteger(args[1])) { C.NOT_VALID_NUMBER.send(player, "(1, ∞)"); C.COMMAND_SYNTAX.send(player, getUsage()); return; } + page = Integer.parseInt(args[2]); + case 2: + if (!MathMan.isInteger(args[1])) { + sortByArea = PS.get().getPlotAreaByString(args[1]); + if (sortByArea == null) { + C.NOT_VALID_NUMBER.send(player, "(1, ∞)"); + C.COMMAND_SYNTAX.send(player, getUsage()); + return; + } + UUID user = UUIDHandler.getUUIDFromString(args[0]); + if (user == null) { + C.COMMAND_SYNTAX.send(player, getUsage()); + return; + } + unsorted = PS.get().getBasePlots(user); + shouldSortByArea = true; + break; + } page = Integer.parseInt(args[1]); case 1: - UUID user = (args.length == 2 || !MathMan.isInteger(args[0])) ? UUIDHandler.getCachedUUID(args[0], null) : null; + UUID user = (args.length == 2 || !MathMan.isInteger(args[0])) ? UUIDHandler.getUUIDFromString(args[0]) : null; if (page == Integer.MIN_VALUE && user == null && MathMan.isInteger(args[0])) { page = Integer.parseInt(args[0]); unsorted = PS.get().getBasePlots(player); @@ -95,8 +116,8 @@ public class Visit extends Command { return; } List plots; - if (Settings.Teleport.PER_WORLD_VISIT) { - plots = PS.get().sortPlots(unsorted, PS.SortType.CREATION_DATE, player.getApplicablePlotArea()); + if (shouldSortByArea) { + plots = PS.get().sortPlots(unsorted, PS.SortType.CREATION_DATE, sortByArea); } else { plots = PS.get().sortPlotsByTemp(unsorted); }