Reimplement per-world-visit

This commit is contained in:
Hannes Greule 2021-04-03 21:48:21 +02:00
parent 932873ba02
commit 74a9c2f6b4
2 changed files with 20 additions and 4 deletions

View File

@ -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<Command> tab(PlotPlayer player, String[] args, boolean space) {
final List<Command> completions = new ArrayList<>();

View File

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