mirror of
https://github.com/IntellectualSites/PlotSquared.git
synced 2024-11-25 22:56:45 +01:00
This should hopefully fix that broken merge. Maybe. Possibly. Idk.
This commit is contained in:
parent
a882555d1b
commit
172bd6f0f2
@ -49,7 +49,6 @@ import com.plotsquared.core.uuid.UUIDMapping;
|
|||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Collection;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
import java.util.concurrent.ExecutionException;
|
import java.util.concurrent.ExecutionException;
|
||||||
@ -139,20 +138,19 @@ public class ListCmd extends SubCommand {
|
|||||||
String arg = args[0].toLowerCase();
|
String arg = args[0].toLowerCase();
|
||||||
final boolean[] sort = new boolean[] {true};
|
final boolean[] sort = new boolean[] {true};
|
||||||
|
|
||||||
final Consumer<PlotQuery> plotConsumer = plots -> {
|
final Consumer<PlotQuery> plotConsumer = query -> {
|
||||||
if (query == null) {
|
if (query == null) {
|
||||||
sendMessage(player, Captions.DID_YOU_MEAN,
|
sendMessage(player, Captions.DID_YOU_MEAN,
|
||||||
new StringComparison<>(args[0], new String[] {"mine", "shared", "world", "all"})
|
new StringComparison<>(args[0], new String[] {"mine", "shared", "world", "all"})
|
||||||
.getBestMatch());
|
.getBestMatch());
|
||||||
return false;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (area != null) {
|
if (area != null) {
|
||||||
query.relativeToArea(area);
|
query.relativeToArea(area);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (sort) {
|
if (sort[0]) {
|
||||||
query.withSortingStrategy(SortingStrategy.SORT_BY_CREATION);
|
query.withSortingStrategy(SortingStrategy.SORT_BY_CREATION);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -160,7 +158,7 @@ public class ListCmd extends SubCommand {
|
|||||||
|
|
||||||
if (plots.isEmpty()) {
|
if (plots.isEmpty()) {
|
||||||
MainUtil.sendMessage(player, Captions.FOUND_NO_PLOTS);
|
MainUtil.sendMessage(player, Captions.FOUND_NO_PLOTS);
|
||||||
return false;
|
return;
|
||||||
}
|
}
|
||||||
displayPlots(player, plots, 12, page, args);
|
displayPlots(player, plots, 12, page, args);
|
||||||
};
|
};
|
||||||
@ -198,7 +196,6 @@ public class ListCmd extends SubCommand {
|
|||||||
}
|
}
|
||||||
plotConsumer.accept(PlotQuery.newQuery().inWorld(world));
|
plotConsumer.accept(PlotQuery.newQuery().inWorld(world));
|
||||||
break;
|
break;
|
||||||
plotConsumer.accept(PlotSquared.get().getPlots(world));
|
|
||||||
case "expired":
|
case "expired":
|
||||||
if (!Permissions.hasPermission(player, Captions.PERMISSION_LIST_EXPIRED)) {
|
if (!Permissions.hasPermission(player, Captions.PERMISSION_LIST_EXPIRED)) {
|
||||||
MainUtil.sendMessage(player, Captions.NO_PERMISSION,
|
MainUtil.sendMessage(player, Captions.NO_PERMISSION,
|
||||||
@ -211,9 +208,6 @@ public class ListCmd extends SubCommand {
|
|||||||
plotConsumer.accept(PlotQuery.newQuery().expiredPlots());
|
plotConsumer.accept(PlotQuery.newQuery().expiredPlots());
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
plotConsumer.accept(ExpireManager.IMP == null ?
|
|
||||||
new ArrayList<>() :
|
|
||||||
new ArrayList<>(ExpireManager.IMP.getPendingExpired()));
|
|
||||||
case "area":
|
case "area":
|
||||||
if (!Permissions.hasPermission(player, Captions.PERMISSION_LIST_AREA)) {
|
if (!Permissions.hasPermission(player, Captions.PERMISSION_LIST_AREA)) {
|
||||||
MainUtil
|
MainUtil
|
||||||
@ -239,7 +233,7 @@ public class ListCmd extends SubCommand {
|
|||||||
.sendMessage(player, Captions.NO_PERMISSION, Captions.PERMISSION_LIST_ALL);
|
.sendMessage(player, Captions.NO_PERMISSION, Captions.PERMISSION_LIST_ALL);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
plotConsumer.accept(PlotQuery().newQuery().allPlots());
|
plotConsumer.accept(PlotQuery.newQuery().allPlots());
|
||||||
break;
|
break;
|
||||||
case "done":
|
case "done":
|
||||||
if (!Permissions.hasPermission(player, Captions.PERMISSION_LIST_DONE)) {
|
if (!Permissions.hasPermission(player, Captions.PERMISSION_LIST_DONE)) {
|
||||||
@ -248,7 +242,7 @@ public class ListCmd extends SubCommand {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
sort[0] = 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;
|
break;
|
||||||
case "top":
|
case "top":
|
||||||
if (!Permissions.hasPermission(player, Captions.PERMISSION_LIST_TOP)) {
|
if (!Permissions.hasPermission(player, Captions.PERMISSION_LIST_TOP)) {
|
||||||
@ -257,7 +251,7 @@ public class ListCmd extends SubCommand {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
sort[0] = 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;
|
break;
|
||||||
case "forsale":
|
case "forsale":
|
||||||
if (!Permissions.hasPermission(player, Captions.PERMISSION_LIST_FOR_SALE)) {
|
if (!Permissions.hasPermission(player, Captions.PERMISSION_LIST_FOR_SALE)) {
|
||||||
@ -337,36 +331,16 @@ public class ListCmd extends SubCommand {
|
|||||||
Captions.PERMISSION_LIST_PLAYER);
|
Captions.PERMISSION_LIST_PLAYER);
|
||||||
} else {
|
} else {
|
||||||
sort[0] = false;
|
sort[0] = false;
|
||||||
plotConsumer.accept(PlotSquared.get()
|
plotConsumer.accept(PlotQuery.newQuery().ownedBy(uuid).withSortingStrategy(SortingStrategy.SORT_BY_TEMP));
|
||||||
.sortPlotsByTemp(PlotSquared.get().getPlots(uuid)));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
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;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void displayPlots(final PlotPlayer player, List<Plot> plots, int pageSize, int page, String[] args {
|
public void displayPlots(final PlotPlayer player, List<Plot> plots, int pageSize, int page, String[] args) {
|
||||||
// Header
|
// Header
|
||||||
plots.removeIf(plot -> !plot.isBasePlot());
|
plots.removeIf(plot -> !plot.isBasePlot());
|
||||||
this.paginate(player, plots, pageSize, page,
|
this.paginate(player, plots, pageSize, page,
|
||||||
|
@ -41,10 +41,7 @@ import com.plotsquared.core.util.query.SortingStrategy;
|
|||||||
import com.plotsquared.core.util.task.RunnableVal2;
|
import com.plotsquared.core.util.task.RunnableVal2;
|
||||||
import com.plotsquared.core.util.task.RunnableVal3;
|
import com.plotsquared.core.util.task.RunnableVal3;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.HashSet;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
import java.util.concurrent.CompletableFuture;
|
import java.util.concurrent.CompletableFuture;
|
||||||
@ -79,7 +76,7 @@ public class Visit extends Command {
|
|||||||
|
|
||||||
final PlotQuery query = PlotQuery.newQuery();
|
final PlotQuery query = PlotQuery.newQuery();
|
||||||
final PlotArea[] sortByArea = new PlotArea[] {player.getApplicablePlotArea()};
|
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<Integer> pageConsumer = page -> {
|
final Consumer<Integer> pageConsumer = page -> {
|
||||||
// We get the query once,
|
// We get the query once,
|
||||||
@ -88,7 +85,7 @@ public class Visit extends Command {
|
|||||||
|
|
||||||
if (unsorted.isEmpty()) {
|
if (unsorted.isEmpty()) {
|
||||||
Captions.FOUND_NO_PLOTS.send(player);
|
Captions.FOUND_NO_PLOTS.send(player);
|
||||||
return CompletableFuture.completedFuture(false);
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (unsorted.size() > 1) {
|
if (unsorted.size() > 1) {
|
||||||
@ -97,11 +94,11 @@ public class Visit extends Command {
|
|||||||
|
|
||||||
if (page < 1 || page > unsorted.size()) {
|
if (page < 1 || page > unsorted.size()) {
|
||||||
Captions.NOT_VALID_NUMBER.send(player, "(1, " + unsorted.size() + ")");
|
Captions.NOT_VALID_NUMBER.send(player, "(1, " + unsorted.size() + ")");
|
||||||
return CompletableFuture.completedFuture(false);
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (shouldSortByArea.get()) {
|
if (shouldSortByArea.get()) {
|
||||||
query.relativeToArea(sortByArea).withSortingStrategy(SortingStrategy.SORT_BY_CREATION);
|
query.relativeToArea(sortByArea[0]).withSortingStrategy(SortingStrategy.SORT_BY_CREATION);
|
||||||
} else {
|
} else {
|
||||||
query.withSortingStrategy(SortingStrategy.SORT_BY_TEMP);
|
query.withSortingStrategy(SortingStrategy.SORT_BY_TEMP);
|
||||||
}
|
}
|
||||||
@ -171,7 +168,7 @@ public class Visit extends Command {
|
|||||||
} else if (throwable != null || uuids.size() != 1) {
|
} else if (throwable != null || uuids.size() != 1) {
|
||||||
Captions.COMMAND_SYNTAX.send(player, getUsage());
|
Captions.COMMAND_SYNTAX.send(player, getUsage());
|
||||||
} else {
|
} else {
|
||||||
query.ownedBy(user).whereBasePlot();
|
query.ownedBy(uuids.toArray(new UUID[0])[0]).whereBasePlot();
|
||||||
shouldSortByArea.set(true);
|
shouldSortByArea.set(true);
|
||||||
pageConsumer.accept(page[0]);
|
pageConsumer.accept(page[0]);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user