From 172bd6f0f2be60c9abb4a5e3e69aa9fc41a3381a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexander=20S=C3=B6derberg?= Date: Sun, 24 May 2020 19:05:09 +0200 Subject: [PATCH] This should hopefully fix that broken merge. Maybe. Possibly. Idk. --- .../com/plotsquared/core/command/ListCmd.java | 44 ++++--------------- .../com/plotsquared/core/command/Visit.java | 13 +++--- 2 files changed, 14 insertions(+), 43 deletions(-) diff --git a/Core/src/main/java/com/plotsquared/core/command/ListCmd.java b/Core/src/main/java/com/plotsquared/core/command/ListCmd.java index dfd582f0f..489208adf 100644 --- a/Core/src/main/java/com/plotsquared/core/command/ListCmd.java +++ b/Core/src/main/java/com/plotsquared/core/command/ListCmd.java @@ -49,7 +49,6 @@ import com.plotsquared.core.uuid.UUIDMapping; import java.util.ArrayList; import java.util.Arrays; -import java.util.Collection; import java.util.List; import java.util.UUID; import java.util.concurrent.ExecutionException; @@ -139,20 +138,19 @@ public class ListCmd extends SubCommand { String arg = args[0].toLowerCase(); final boolean[] sort = new boolean[] {true}; - final Consumer plotConsumer = plots -> { + final Consumer plotConsumer = query -> { if (query == null) { sendMessage(player, Captions.DID_YOU_MEAN, new StringComparison<>(args[0], new String[] {"mine", "shared", "world", "all"}) .getBestMatch()); - return false; + return; } - if (area != null) { query.relativeToArea(area); } - if (sort) { + if (sort[0]) { query.withSortingStrategy(SortingStrategy.SORT_BY_CREATION); } @@ -160,7 +158,7 @@ public class ListCmd extends SubCommand { if (plots.isEmpty()) { MainUtil.sendMessage(player, Captions.FOUND_NO_PLOTS); - return false; + return; } displayPlots(player, plots, 12, page, args); }; @@ -198,7 +196,6 @@ public class ListCmd extends SubCommand { } plotConsumer.accept(PlotQuery.newQuery().inWorld(world)); break; - plotConsumer.accept(PlotSquared.get().getPlots(world)); case "expired": if (!Permissions.hasPermission(player, Captions.PERMISSION_LIST_EXPIRED)) { MainUtil.sendMessage(player, Captions.NO_PERMISSION, @@ -211,9 +208,6 @@ public class ListCmd extends SubCommand { plotConsumer.accept(PlotQuery.newQuery().expiredPlots()); } break; - plotConsumer.accept(ExpireManager.IMP == null ? - new ArrayList<>() : - new ArrayList<>(ExpireManager.IMP.getPendingExpired())); case "area": if (!Permissions.hasPermission(player, Captions.PERMISSION_LIST_AREA)) { MainUtil @@ -239,7 +233,7 @@ public class ListCmd extends SubCommand { .sendMessage(player, Captions.NO_PERMISSION, Captions.PERMISSION_LIST_ALL); return false; } - plotConsumer.accept(PlotQuery().newQuery().allPlots()); + plotConsumer.accept(PlotQuery.newQuery().allPlots()); break; case "done": if (!Permissions.hasPermission(player, Captions.PERMISSION_LIST_DONE)) { @@ -248,7 +242,7 @@ public class ListCmd extends SubCommand { return false; } sort[0] = false; - plotConsumer.accept(PlotQuery.newQuery().allPlots().thatPasses(DoneFlag::isDone).withSortingStrategy(SortingStrategy.SORT_BY_DONE)) + plotConsumer.accept(PlotQuery.newQuery().allPlots().thatPasses(DoneFlag::isDone).withSortingStrategy(SortingStrategy.SORT_BY_DONE)); break; case "top": if (!Permissions.hasPermission(player, Captions.PERMISSION_LIST_TOP)) { @@ -257,7 +251,7 @@ public class ListCmd extends SubCommand { return false; } sort[0] = false; - plotConsumer.accept(PlotQuery.newQuery().allPlots().withSortingStrategy(SortingStrategy.SORT_BY_RATING)) + plotConsumer.accept(PlotQuery.newQuery().allPlots().withSortingStrategy(SortingStrategy.SORT_BY_RATING)); break; case "forsale": if (!Permissions.hasPermission(player, Captions.PERMISSION_LIST_FOR_SALE)) { @@ -337,36 +331,16 @@ public class ListCmd extends SubCommand { Captions.PERMISSION_LIST_PLAYER); } else { sort[0] = false; - plotConsumer.accept(PlotSquared.get() - .sortPlotsByTemp(PlotSquared.get().getPlots(uuid))); + plotConsumer.accept(PlotQuery.newQuery().ownedBy(uuid).withSortingStrategy(SortingStrategy.SORT_BY_TEMP)); } } }); - - - UUID uuid = UUIDHandler.getUUID(args[0], null); - if (uuid == null) { - try { - uuid = UUID.fromString(args[0]); - } catch (Exception ignored) { - } - } - if (uuid != null) { - if (!Permissions.hasPermission(player, Captions.PERMISSION_LIST_PLAYER)) { - MainUtil.sendMessage(player, Captions.NO_PERMISSION, - Captions.PERMISSION_LIST_PLAYER); - return false; - } - sort[0] = false; - plotConsumer.accept(PlotQuery.newQuery().ownedBy(uuid).withSortingStrategy(SortingStrategy.SORT_BY_TEMP)); - break; - } } return true; } - public void displayPlots(final PlotPlayer player, List plots, int pageSize, int page, String[] args { + public void displayPlots(final PlotPlayer player, List plots, int pageSize, int page, String[] args) { // Header plots.removeIf(plot -> !plot.isBasePlot()); this.paginate(player, plots, pageSize, page, diff --git a/Core/src/main/java/com/plotsquared/core/command/Visit.java b/Core/src/main/java/com/plotsquared/core/command/Visit.java index cd541c33e..3a18fc7d9 100644 --- a/Core/src/main/java/com/plotsquared/core/command/Visit.java +++ b/Core/src/main/java/com/plotsquared/core/command/Visit.java @@ -41,10 +41,7 @@ import com.plotsquared.core.util.query.SortingStrategy; import com.plotsquared.core.util.task.RunnableVal2; import com.plotsquared.core.util.task.RunnableVal3; -import java.util.ArrayList; import java.util.Collection; -import java.util.Collections; -import java.util.HashSet; import java.util.List; import java.util.UUID; import java.util.concurrent.CompletableFuture; @@ -79,7 +76,7 @@ public class Visit extends Command { final PlotQuery query = PlotQuery.newQuery(); final PlotArea[] sortByArea = new PlotArea[] {player.getApplicablePlotArea()}; - final Atomicboolean shouldSortByArea = new AtomicBoolean(Settings.Teleport.PER_WORLD_VISIT); + final AtomicBoolean shouldSortByArea = new AtomicBoolean(Settings.Teleport.PER_WORLD_VISIT); final Consumer pageConsumer = page -> { // We get the query once, @@ -88,7 +85,7 @@ public class Visit extends Command { if (unsorted.isEmpty()) { Captions.FOUND_NO_PLOTS.send(player); - return CompletableFuture.completedFuture(false); + return; } if (unsorted.size() > 1) { @@ -97,11 +94,11 @@ public class Visit extends Command { if (page < 1 || page > unsorted.size()) { Captions.NOT_VALID_NUMBER.send(player, "(1, " + unsorted.size() + ")"); - return CompletableFuture.completedFuture(false); + return; } if (shouldSortByArea.get()) { - query.relativeToArea(sortByArea).withSortingStrategy(SortingStrategy.SORT_BY_CREATION); + query.relativeToArea(sortByArea[0]).withSortingStrategy(SortingStrategy.SORT_BY_CREATION); } else { query.withSortingStrategy(SortingStrategy.SORT_BY_TEMP); } @@ -171,7 +168,7 @@ public class Visit extends Command { } else if (throwable != null || uuids.size() != 1) { Captions.COMMAND_SYNTAX.send(player, getUsage()); } else { - query.ownedBy(user).whereBasePlot(); + query.ownedBy(uuids.toArray(new UUID[0])[0]).whereBasePlot(); shouldSortByArea.set(true); pageConsumer.accept(page[0]); }