diff --git a/Core/src/main/java/com/plotsquared/core/command/HomeCommand.java b/Core/src/main/java/com/plotsquared/core/command/HomeCommand.java index 2e99f0f09..59e2944d5 100644 --- a/Core/src/main/java/com/plotsquared/core/command/HomeCommand.java +++ b/Core/src/main/java/com/plotsquared/core/command/HomeCommand.java @@ -27,6 +27,7 @@ package com.plotsquared.core.command; import com.plotsquared.core.PlotSquared; import com.plotsquared.core.configuration.Captions; +import com.plotsquared.core.configuration.Settings; import com.plotsquared.core.events.TeleportCause; import com.plotsquared.core.player.PlotPlayer; import com.plotsquared.core.plot.Plot; @@ -119,7 +120,7 @@ public class HomeCommand extends Command { Captions.NOT_A_NUMBER.send(player, identifier); return CompletableFuture.completedFuture(false); } - query.withSortingStrategy(SortingStrategy.SORT_BY_TEMP); + sortBySettings(query, player); break; } // either plot id or alias @@ -178,7 +179,7 @@ public class HomeCommand extends Command { query.withPlot(plot); break; case 0: - query.withSortingStrategy(SortingStrategy.SORT_BY_TEMP); + sortBySettings(query, player); break; } if (basePlotOnly) { @@ -188,6 +189,15 @@ public class HomeCommand extends Command { return CompletableFuture.completedFuture(true); } + private void sortBySettings(PlotQuery plotQuery, PlotPlayer player) { + if (Settings.Teleport.PER_WORLD_VISIT) { + plotQuery.relativeToArea(player.getApplicablePlotArea()) + .withSortingStrategy(SortingStrategy.SORT_BY_CREATION); + } else { + plotQuery.withSortingStrategy(SortingStrategy.SORT_BY_TEMP); + } + } + @Override public Collection tab(PlotPlayer player, String[] args, boolean space) { final List completions = new ArrayList<>(); 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 b96cb9b5a..f5c4f1392 100644 --- a/Core/src/main/java/com/plotsquared/core/command/Visit.java +++ b/Core/src/main/java/com/plotsquared/core/command/Visit.java @@ -27,6 +27,7 @@ package com.plotsquared.core.command; import com.plotsquared.core.PlotSquared; import com.plotsquared.core.configuration.Captions; +import com.plotsquared.core.configuration.Settings; import com.plotsquared.core.events.TeleportCause; import com.plotsquared.core.player.PlotPlayer; import com.plotsquared.core.plot.Plot; @@ -93,8 +94,13 @@ public class Visit extends Command { return; } - if (sortByArea != null) { - query.relativeToArea(sortByArea).withSortingStrategy(SortingStrategy.SORT_BY_CREATION); + PlotArea relativeArea = sortByArea; + if (Settings.Teleport.PER_WORLD_VISIT && sortByArea == null) { + relativeArea = player.getApplicablePlotArea(); + } + + if (relativeArea != null) { + query.relativeToArea(relativeArea).withSortingStrategy(SortingStrategy.SORT_BY_CREATION); } else { query.withSortingStrategy(SortingStrategy.SORT_BY_TEMP); }