mirror of
https://github.com/IntellectualSites/PlotSquared.git
synced 2024-11-22 11:55:38 +01:00
Fix: use ownersInclude instead of ownedBy where required (#3419)
* Fix: use ownersInclude instead of ownedBy where required - Also account for multiple plot owners in Cluster player removal - Add whereBasePlot to avoid merged plots listing multiple times if required - Only use ownersInclude in visit if enabled in config - Fixes #3143 * Remove static import
This commit is contained in:
parent
0c76d08b10
commit
7cc38b5fa8
@ -559,13 +559,7 @@ public class Cluster extends SubCommand {
|
|||||||
Template.of("cluster", cluster.getName())
|
Template.of("cluster", cluster.getName())
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
for (final Plot plot : PlotQuery.newQuery().inWorld(player2.getLocation()
|
removePlayerPlots(cluster, uuid, player2.getLocation().getWorldName());
|
||||||
.getWorldName()).ownedBy(uuid)) {
|
|
||||||
PlotCluster current = plot.getCluster();
|
|
||||||
if (current != null && current.equals(cluster)) {
|
|
||||||
plot.unclaim();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
player.sendMessage(TranslatableCaption.of("cluster.cluster_kicked_user"));
|
player.sendMessage(TranslatableCaption.of("cluster.cluster_kicked_user"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -628,13 +622,7 @@ public class Cluster extends SubCommand {
|
|||||||
TranslatableCaption.of("cluster.cluster_removed"),
|
TranslatableCaption.of("cluster.cluster_removed"),
|
||||||
Template.of("cluster", cluster.getName())
|
Template.of("cluster", cluster.getName())
|
||||||
);
|
);
|
||||||
for (final Plot plot : PlotQuery.newQuery().inWorld(player.getLocation().getWorldName())
|
removePlayerPlots(cluster, uuid, player.getLocation().getWorldName());
|
||||||
.ownedBy(uuid)) {
|
|
||||||
PlotCluster current = plot.getCluster();
|
|
||||||
if (current != null && current.equals(cluster)) {
|
|
||||||
plot.unclaim();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
case "members": {
|
case "members": {
|
||||||
@ -866,6 +854,24 @@ public class Cluster extends SubCommand {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void removePlayerPlots(final PlotCluster cluster, final UUID uuid, final String world) {
|
||||||
|
for (final Plot plot : PlotQuery.newQuery().inWorld(world).ownedBy(uuid)) {
|
||||||
|
PlotCluster current = plot.getCluster();
|
||||||
|
if (current != null && current.equals(cluster)) {
|
||||||
|
if (plot.getOwners().size() == 1) {
|
||||||
|
plot.unclaim();
|
||||||
|
} else {
|
||||||
|
for (UUID newOwner : plot.getOwners()) {
|
||||||
|
if (!newOwner.equals(uuid)) {
|
||||||
|
plot.setOwner(newOwner);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Collection<Command> tab(final PlotPlayer<?> player, final String[] args, final boolean space) {
|
public Collection<Command> tab(final PlotPlayer<?> player, final String[] args, final boolean space) {
|
||||||
if (args.length == 1) {
|
if (args.length == 1) {
|
||||||
|
@ -203,7 +203,7 @@ public class ListCmd extends SubCommand {
|
|||||||
sort[0] = false;
|
sort[0] = false;
|
||||||
plotConsumer.accept(PlotQuery
|
plotConsumer.accept(PlotQuery
|
||||||
.newQuery()
|
.newQuery()
|
||||||
.ownedBy(player)
|
.ownersInclude(player)
|
||||||
.whereBasePlot()
|
.whereBasePlot()
|
||||||
.withSortingStrategy(SortingStrategy.SORT_BY_TEMP));
|
.withSortingStrategy(SortingStrategy.SORT_BY_TEMP));
|
||||||
}
|
}
|
||||||
@ -397,7 +397,8 @@ public class ListCmd extends SubCommand {
|
|||||||
sort[0] = false;
|
sort[0] = false;
|
||||||
plotConsumer.accept(PlotQuery
|
plotConsumer.accept(PlotQuery
|
||||||
.newQuery()
|
.newQuery()
|
||||||
.ownedBy(uuid)
|
.ownersInclude(uuid)
|
||||||
|
.whereBasePlot()
|
||||||
.withSortingStrategy(SortingStrategy.SORT_BY_TEMP));
|
.withSortingStrategy(SortingStrategy.SORT_BY_TEMP));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -236,7 +236,7 @@ public class Visit extends Command {
|
|||||||
final UUID uuid = uuids.toArray(new UUID[0])[0];
|
final UUID uuid = uuids.toArray(new UUID[0])[0];
|
||||||
PlotQuery query = PlotQuery.newQuery();
|
PlotQuery query = PlotQuery.newQuery();
|
||||||
if (Settings.Teleport.VISIT_MERGED_OWNERS) {
|
if (Settings.Teleport.VISIT_MERGED_OWNERS) {
|
||||||
query.ownersInclude(uuid);
|
query.whereBasePlot().ownersInclude(uuid);
|
||||||
} else {
|
} else {
|
||||||
query.whereBasePlot().ownedBy(uuid);
|
query.whereBasePlot().ownedBy(uuid);
|
||||||
}
|
}
|
||||||
@ -273,7 +273,9 @@ public class Visit extends Command {
|
|||||||
if (throwable instanceof TimeoutException) {
|
if (throwable instanceof TimeoutException) {
|
||||||
// The request timed out
|
// The request timed out
|
||||||
player.sendMessage(TranslatableCaption.of("players.fetching_players_timeout"));
|
player.sendMessage(TranslatableCaption.of("players.fetching_players_timeout"));
|
||||||
} else if (uuid != null && !PlotQuery.newQuery().ownedBy(uuid).anyMatch()) {
|
} else if (uuid != null && (Settings.Teleport.VISIT_MERGED_OWNERS
|
||||||
|
? !PlotQuery.newQuery().ownersInclude(uuid).anyMatch()
|
||||||
|
: !PlotQuery.newQuery().ownedBy(uuid).anyMatch())) {
|
||||||
// It was a valid UUID but the player has no plots
|
// It was a valid UUID but the player has no plots
|
||||||
player.sendMessage(TranslatableCaption.of("errors.player_no_plots"));
|
player.sendMessage(TranslatableCaption.of("errors.player_no_plots"));
|
||||||
} else if (uuid == null) {
|
} else if (uuid == null) {
|
||||||
@ -296,7 +298,9 @@ public class Visit extends Command {
|
|||||||
} else {
|
} else {
|
||||||
this.visit(
|
this.visit(
|
||||||
player,
|
player,
|
||||||
PlotQuery.newQuery().ownedBy(uuid).whereBasePlot(),
|
Settings.Teleport.VISIT_MERGED_OWNERS
|
||||||
|
? PlotQuery.newQuery().ownersInclude(uuid).whereBasePlot()
|
||||||
|
: PlotQuery.newQuery().ownedBy(uuid).whereBasePlot(),
|
||||||
null,
|
null,
|
||||||
confirm,
|
confirm,
|
||||||
whenDone,
|
whenDone,
|
||||||
|
Loading…
Reference in New Issue
Block a user