Let players teleport to their merged plots

This commit is contained in:
Hannes Greule 2020-07-08 19:33:58 +02:00
parent 2936b806f3
commit d652225f36

View File

@ -84,7 +84,7 @@ public class HomeCommand extends Command {
@NotNull private PlotQuery query(@NotNull final PlotPlayer<?> player) { @NotNull private PlotQuery query(@NotNull final PlotPlayer<?> player) {
// everything plots need to have in common here // everything plots need to have in common here
return PlotQuery.newQuery().ownedBy(player).whereBasePlot(); return PlotQuery.newQuery().ownedBy(player);
} }
@Override public CompletableFuture<Boolean> execute(PlotPlayer<?> player, String[] args, @Override public CompletableFuture<Boolean> execute(PlotPlayer<?> player, String[] args,
@ -107,6 +107,7 @@ public class HomeCommand extends Command {
PlotQuery query = query(player); PlotQuery query = query(player);
int page = 1; // page = index + 1 int page = 1; // page = index + 1
String identifier; String identifier;
boolean basePlotOnly = true;
switch (args.length) { switch (args.length) {
case 1: case 1:
identifier = args[0]; identifier = args[0];
@ -124,6 +125,7 @@ public class HomeCommand extends Command {
Plot fromId = MainUtil.getPlotFromString(player, identifier, false); Plot fromId = MainUtil.getPlotFromString(player, identifier, false);
if (fromId != null && fromId.isOwner(player.getUUID())) { if (fromId != null && fromId.isOwner(player.getUUID())) {
// it was a valid plot id // it was a valid plot id
basePlotOnly = false;
query.withPlot(fromId); query.withPlot(fromId);
break; break;
} }
@ -165,12 +167,16 @@ public class HomeCommand extends Command {
break; break;
} }
// as the query already filters by owner, this is fine // as the query already filters by owner, this is fine
basePlotOnly = false;
query.withPlot(plot); query.withPlot(plot);
break; break;
case 0: case 0:
query.withSortingStrategy(SortingStrategy.SORT_BY_CREATION); query.withSortingStrategy(SortingStrategy.SORT_BY_CREATION);
break; break;
} }
if (basePlotOnly) {
query.whereBasePlot();
}
home(player, query, page, confirm, whenDone); home(player, query, page, confirm, whenDone);
return CompletableFuture.completedFuture(true); return CompletableFuture.completedFuture(true);
} }