mirror of
https://github.com/IntellectualSites/PlotSquared.git
synced 2024-11-26 07:06:44 +01:00
Fixes #1366
This commit is contained in:
parent
04c011164a
commit
3b4490c1c6
@ -15,7 +15,6 @@ import com.intellectualcrafters.plot.util.MainUtil;
|
|||||||
import com.intellectualcrafters.plot.util.Permissions;
|
import com.intellectualcrafters.plot.util.Permissions;
|
||||||
import com.intellectualcrafters.plot.util.UUIDHandler;
|
import com.intellectualcrafters.plot.util.UUIDHandler;
|
||||||
import com.plotsquared.general.commands.CommandDeclaration;
|
import com.plotsquared.general.commands.CommandDeclaration;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
@ -87,6 +86,10 @@ public class Cluster extends SubCommand {
|
|||||||
MainUtil.sendMessage(player, C.COMMAND_SYNTAX, "/plot cluster create <name> <id-bot> <id-top>");
|
MainUtil.sendMessage(player, C.COMMAND_SYNTAX, "/plot cluster create <name> <id-bot> <id-top>");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
int currentClusters = Settings.Limit.GLOBAL ? player.getClusterCount() : player.getPlotCount(player.getLocation().getWorld());
|
||||||
|
if (currentClusters >= player.getAllowedPlots()) {
|
||||||
|
return sendMessage(player, C.CANT_CLAIM_MORE_CLUSTERS);
|
||||||
|
}
|
||||||
// check pos1 / pos2
|
// check pos1 / pos2
|
||||||
PlotId pos1 = PlotId.fromString(args[2]);
|
PlotId pos1 = PlotId.fromString(args[2]);
|
||||||
PlotId pos2 = PlotId.fromString(args[3]);
|
PlotId pos2 = PlotId.fromString(args[3]);
|
||||||
@ -132,9 +135,9 @@ public class Cluster extends SubCommand {
|
|||||||
} else {
|
} else {
|
||||||
current = player.getPlayerClusterCount(player.getLocation().getWorld());
|
current = player.getPlayerClusterCount(player.getLocation().getWorld());
|
||||||
}
|
}
|
||||||
int allowed = Permissions.hasPermissionRange(player, "plots.cluster", Settings.Limit.MAX_PLOTS);
|
int allowed = Permissions.hasPermissionRange(player, "plots.cluster.size", Settings.Limit.MAX_PLOTS);
|
||||||
if (current + cluster.getArea() > allowed) {
|
if (current + cluster.getArea() > allowed) {
|
||||||
MainUtil.sendMessage(player, C.NO_PERMISSION, "plots.cluster." + (current + cluster.getArea()));
|
MainUtil.sendMessage(player, C.NO_PERMISSION, "plots.cluster.size." + (current + cluster.getArea()));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
// create cluster
|
// create cluster
|
||||||
|
@ -332,6 +332,7 @@ public enum C {
|
|||||||
NO_PERMISSION_EVENT("$2You are lacking the permission node: $1%s", "Permission"),
|
NO_PERMISSION_EVENT("$2You are lacking the permission node: $1%s", "Permission"),
|
||||||
NO_PLOT_PERMS("$2You must be the plot owner to perform this action", "Permission"),
|
NO_PLOT_PERMS("$2You must be the plot owner to perform this action", "Permission"),
|
||||||
CANT_CLAIM_MORE_PLOTS("$2You can't claim more plots.", "Permission"),
|
CANT_CLAIM_MORE_PLOTS("$2You can't claim more plots.", "Permission"),
|
||||||
|
CANT_CLAIM_MORE_CLUSTERS("$2You can't claim more clusters.", "Permission"),
|
||||||
CANT_TRANSFER_MORE_PLOTS("$2You can't send more plots to that user", "Permission"),
|
CANT_TRANSFER_MORE_PLOTS("$2You can't send more plots to that user", "Permission"),
|
||||||
CANT_CLAIM_MORE_PLOTS_NUM("$2You can't claim more than $1%s $2plots at once", "Permission"),
|
CANT_CLAIM_MORE_PLOTS_NUM("$2You can't claim more than $1%s $2plots at once", "Permission"),
|
||||||
YOU_BE_DENIED("$2You are not allowed to enter this plot", "Permission"),
|
YOU_BE_DENIED("$2You are not allowed to enter this plot", "Permission"),
|
||||||
|
@ -63,6 +63,10 @@ public class PlotCluster {
|
|||||||
return this.region;
|
return this.region;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean isOwner(UUID uuid) {
|
||||||
|
return uuid.equals(owner);
|
||||||
|
}
|
||||||
|
|
||||||
public boolean isAdded(UUID uuid) {
|
public boolean isAdded(UUID uuid) {
|
||||||
return this.owner.equals(uuid) || this.invited.contains(uuid) || this.invited.contains(DBFunc.everyone) || this.helpers.contains(uuid)
|
return this.owner.equals(uuid) || this.invited.contains(uuid) || this.invited.contains(DBFunc.everyone) || this.helpers.contains(uuid)
|
||||||
|| this.helpers
|
|| this.helpers
|
||||||
|
@ -132,6 +132,14 @@ public abstract class PlotPlayer implements CommandCaller, OfflinePlotPlayer {
|
|||||||
return Permissions.hasPermissionRange(this, "plots.plot", Settings.Limit.MAX_PLOTS);
|
return Permissions.hasPermissionRange(this, "plots.plot", Settings.Limit.MAX_PLOTS);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the total number of allowed clusters
|
||||||
|
* @return number of allowed clusters within the scope (globally, or in the player's current world as defined in the settings.yml)
|
||||||
|
*/
|
||||||
|
public int getAllowedClusters() {
|
||||||
|
return Permissions.hasPermissionRange(this, "plots.cluster", Settings.Limit.MAX_PLOTS);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the number of plots this player owns.
|
* Get the number of plots this player owns.
|
||||||
*
|
*
|
||||||
@ -163,6 +171,25 @@ public abstract class PlotPlayer implements CommandCaller, OfflinePlotPlayer {
|
|||||||
return count.get();
|
return count.get();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public int getClusterCount() {
|
||||||
|
if (!Settings.Limit.GLOBAL) {
|
||||||
|
return getClusterCount(getLocation().getWorld());
|
||||||
|
}
|
||||||
|
final AtomicInteger count = new AtomicInteger(0);
|
||||||
|
final UUID uuid = getUUID();
|
||||||
|
PS.get().foreachPlotArea(new RunnableVal<PlotArea>() {
|
||||||
|
@Override
|
||||||
|
public void run(PlotArea value) {
|
||||||
|
for (PlotCluster cluster : value.getClusters()) {
|
||||||
|
if (cluster.isOwner(getUUID())) {
|
||||||
|
count.incrementAndGet();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
return count.get();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the number of plots this player owns in the world.
|
* Get the number of plots this player owns in the world.
|
||||||
* @param world the name of the plotworld to check.
|
* @param world the name of the plotworld to check.
|
||||||
@ -185,6 +212,19 @@ public abstract class PlotPlayer implements CommandCaller, OfflinePlotPlayer {
|
|||||||
return count;
|
return count;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public int getClusterCount(String world) {
|
||||||
|
UUID uuid = getUUID();
|
||||||
|
int count = 0;
|
||||||
|
for (PlotArea area : PS.get().getPlotAreas(world)) {
|
||||||
|
for (PlotCluster cluster : area.getClusters()) {
|
||||||
|
if (cluster.isOwner(getUUID())) {
|
||||||
|
count++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return count;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get a {@code Set} of plots owned by this player.
|
* Get a {@code Set} of plots owned by this player.
|
||||||
* @see PS for more searching functions
|
* @see PS for more searching functions
|
||||||
|
Loading…
Reference in New Issue
Block a user