mirror of
https://github.com/IntellectualSites/PlotSquared.git
synced 2024-11-22 21:26:45 +01:00
Added claim restrictions for clusters
This commit is contained in:
parent
0c3919b365
commit
214cd1dbf8
@ -179,7 +179,7 @@ public class Auto extends SubCommand {
|
||||
for (int i = 0; i <= max; i++) {
|
||||
final PlotId currentId = new PlotId(origin.x + id.x, origin.y + id.y);
|
||||
final Plot current = MainUtil.getPlot(worldname, currentId);
|
||||
if ((current != null) && (current.hasOwner() == false) && (current.settings.isMerged() == false) && cluster.equals(ClusterManager.getCluster(current))) {
|
||||
if (MainUtil.canClaim(plr, current) && (current.settings.isMerged() == false) && cluster.equals(ClusterManager.getCluster(current))) {
|
||||
Claim.claimPlot(plr, current, true, true);
|
||||
return true;
|
||||
}
|
||||
@ -193,7 +193,7 @@ public class Auto extends SubCommand {
|
||||
if ((size_x == 1) && (size_z == 1)) {
|
||||
while (!br) {
|
||||
final Plot plot = MainUtil.getPlot(worldname, getLastPlot(worldname));
|
||||
if ((plot.owner == null)) {
|
||||
if (MainUtil.canClaim(plr, plot)) {
|
||||
Claim.claimPlot(plr, plot, true, true);
|
||||
br = true;
|
||||
}
|
||||
@ -213,7 +213,7 @@ public class Auto extends SubCommand {
|
||||
lastPlot = false;
|
||||
}
|
||||
final PlotId end = new PlotId((start.x + size_x) - 1, (start.y + size_z) - 1);
|
||||
if (MainUtil.isUnowned(worldname, start, end)) {
|
||||
if (MainUtil.canClaim(plr, worldname, start, end)) {
|
||||
for (int i = start.x; i <= end.x; i++) {
|
||||
for (int j = start.y; j <= end.y; j++) {
|
||||
final Plot plot = MainUtil.getPlot(worldname, new PlotId(i, j));
|
||||
|
@ -93,7 +93,7 @@ public class Claim extends SubCommand {
|
||||
if (currentPlots >= MainUtil.getAllowedPlots(plr)) {
|
||||
return sendMessage(plr, C.CANT_CLAIM_MORE_PLOTS);
|
||||
}
|
||||
if (plot.hasOwner()) {
|
||||
if (!MainUtil.canClaim(plr, plot)) {
|
||||
return sendMessage(plr, C.PLOT_IS_CLAIMED);
|
||||
}
|
||||
final PlotWorld world = PlotSquared.getPlotWorld(plot.world);
|
||||
|
@ -129,7 +129,7 @@ public class Cluster extends SubCommand {
|
||||
// Add any existing plots to the current cluster
|
||||
for (final Plot plot : PlotSquared.getPlots(plr.getLocation().getWorld()).values()) {
|
||||
final PlotCluster current = ClusterManager.getCluster(plot);
|
||||
if (cluster.equals(current) && !cluster.hasRights(plot.owner)) {
|
||||
if (cluster.equals(current) && !cluster.isAdded(plot.owner)) {
|
||||
cluster.invited.add(plot.owner);
|
||||
DBFunc.setInvited(world, cluster, plot.owner);
|
||||
}
|
||||
@ -302,7 +302,7 @@ public class Cluster extends SubCommand {
|
||||
MainUtil.sendMessage(plr, C.INVALID_PLAYER, args[1]);
|
||||
return false;
|
||||
}
|
||||
if (!cluster.hasRights(uuid)) {
|
||||
if (!cluster.isAdded(uuid)) {
|
||||
// add the user if not added
|
||||
cluster.invited.add(uuid);
|
||||
final String world = plr.getLocation().getWorld();
|
||||
@ -344,7 +344,7 @@ public class Cluster extends SubCommand {
|
||||
return false;
|
||||
}
|
||||
// Can't kick if the player is yourself, the owner, or not added to the cluster
|
||||
if (uuid.equals(UUIDHandler.getUUID(plr)) || uuid.equals(cluster.owner) || !cluster.hasRights(uuid)) {
|
||||
if (uuid.equals(UUIDHandler.getUUID(plr)) || uuid.equals(cluster.owner) || !cluster.isAdded(uuid)) {
|
||||
MainUtil.sendMessage(plr, C.CANNOT_KICK_PLAYER, cluster.getName());
|
||||
return false;
|
||||
}
|
||||
@ -393,7 +393,7 @@ public class Cluster extends SubCommand {
|
||||
}
|
||||
}
|
||||
final UUID uuid = UUIDHandler.getUUID(plr);
|
||||
if (!cluster.hasRights(uuid)) {
|
||||
if (!cluster.isAdded(uuid)) {
|
||||
MainUtil.sendMessage(plr, C.CLUSTER_NOT_ADDED);
|
||||
return false;
|
||||
}
|
||||
@ -466,7 +466,7 @@ public class Cluster extends SubCommand {
|
||||
return false;
|
||||
}
|
||||
final UUID uuid = UUIDHandler.getUUID(plr);
|
||||
if (!cluster.hasRights(uuid)) {
|
||||
if (!cluster.isAdded(uuid)) {
|
||||
if (!Permissions.hasPermission(plr, "plots.cluster.tp.other")) {
|
||||
MainUtil.sendMessage(plr, C.NO_PERMISSION, "plots.cluster.tp.other");
|
||||
return false;
|
||||
@ -508,7 +508,7 @@ public class Cluster extends SubCommand {
|
||||
}
|
||||
final String name = cluster.getName();
|
||||
final String size = ((cluster.getP2().x - cluster.getP1().x) + 1) + "x" + ((cluster.getP2().y - cluster.getP1().y) + 1);
|
||||
final String rights = cluster.hasRights(UUIDHandler.getUUID(plr)) + "";
|
||||
final String rights = cluster.isAdded(UUIDHandler.getUUID(plr)) + "";
|
||||
String message = C.CLUSTER_INFO.s();
|
||||
message = message.replaceAll("%id%", id);
|
||||
message = message.replaceAll("%owner%", owner);
|
||||
|
@ -38,7 +38,7 @@ public class PlotCluster {
|
||||
this.settings = new PlotSettings(null);
|
||||
}
|
||||
|
||||
public boolean hasRights(final UUID uuid) {
|
||||
public boolean isAdded(final UUID uuid) {
|
||||
return (this.owner.equals(uuid) || this.invited.contains(uuid) || this.invited.contains(DBFunc.everyone) || this.helpers.contains(uuid) || this.helpers.contains(DBFunc.everyone));
|
||||
}
|
||||
|
||||
|
@ -1,49 +0,0 @@
|
||||
//package com.intellectualcrafters.plot.object;
|
||||
//
|
||||
//import java.util.Collection;
|
||||
//
|
||||
//import org.bukkit.Bukkit;
|
||||
//import org.bukkit.plugin.java.JavaPlugin;
|
||||
//
|
||||
//import com.gmail.filoghost.holographicdisplays.api.Hologram;
|
||||
//import com.gmail.filoghost.holographicdisplays.api.HologramsAPI;
|
||||
//import com.intellectualcrafters.plot.PlotSquared;
|
||||
//import com.intellectualcrafters.plot.util.PlotHelper;
|
||||
//
|
||||
///**
|
||||
// * Created 2015-02-14 for PlotSquared
|
||||
// *
|
||||
// * @author Citymonstret
|
||||
// */
|
||||
//public class PlotHologram {
|
||||
//
|
||||
// private static JavaPlugin plugin;
|
||||
// private final PlotId id;
|
||||
// private final String world;
|
||||
// private Hologram hologram;
|
||||
//
|
||||
// public PlotHologram(final String world, final PlotId id) {
|
||||
// this.id = id;
|
||||
// this.world = world;
|
||||
// this.hologram = createHologram(PlotSquared.getPlotManager(world).getSignLoc(Bukkit.getWorld(world), PlotSquared.getPlotWorld(world), PlotHelper.getPlot(Bukkit.getWorld(world), id)));
|
||||
// }
|
||||
//
|
||||
// public static Hologram createHologram(final org.bukkit.Location location) {
|
||||
// return HologramsAPI.createHologram(getPlugin(), location);
|
||||
// }
|
||||
//
|
||||
// public static JavaPlugin getPlugin() {
|
||||
// if (plugin == null) {
|
||||
// plugin = JavaPlugin.getPlugin(PlotSquared.class);
|
||||
// }
|
||||
// return plugin;
|
||||
// }
|
||||
//
|
||||
// public static void removeAll() {
|
||||
// final Collection<Hologram> holograms = HologramsAPI.getHolograms(getPlugin());
|
||||
// for (final Hologram h : holograms) {
|
||||
// h.delete();
|
||||
// }
|
||||
// }
|
||||
//
|
||||
//}
|
@ -34,6 +34,7 @@ import com.intellectualcrafters.plot.object.ChunkLoc;
|
||||
import com.intellectualcrafters.plot.object.Location;
|
||||
import com.intellectualcrafters.plot.object.Plot;
|
||||
import com.intellectualcrafters.plot.object.PlotBlock;
|
||||
import com.intellectualcrafters.plot.object.PlotCluster;
|
||||
import com.intellectualcrafters.plot.object.PlotId;
|
||||
import com.intellectualcrafters.plot.object.PlotManager;
|
||||
import com.intellectualcrafters.plot.object.PlotPlayer;
|
||||
@ -753,6 +754,37 @@ public class MainUtil {
|
||||
return manager.getPlotBottomLocAbs(plotworld, id);
|
||||
}
|
||||
|
||||
public static boolean canClaim(PlotPlayer player, String world, final PlotId pos1, final PlotId pos2) {
|
||||
for (int x = pos1.x; x <= pos2.x; x++) {
|
||||
for (int y = pos1.y; y <= pos2.y; y++) {
|
||||
final PlotId id = new PlotId(x, y);
|
||||
Plot plot = getPlot(world, id);
|
||||
if (!canClaim(player, plot)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public static boolean canClaim(PlotPlayer player, Plot plot) {
|
||||
if (plot == null) {
|
||||
return false;
|
||||
}
|
||||
if (Settings.ENABLE_CLUSTERS) {
|
||||
PlotCluster cluster = ClusterManager.getCluster(plot);
|
||||
if (cluster != null) {
|
||||
if (!cluster.isAdded(player.getUUID()) && !Permissions.hasPermission(player, "plots.admin.command.claim")) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (plot.owner != null) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public static boolean isUnowned(final String world, final PlotId pos1, final PlotId pos2) {
|
||||
for (int x = pos1.x; x <= pos2.x; x++) {
|
||||
for (int y = pos1.y; y <= pos2.y; y++) {
|
||||
|
Loading…
Reference in New Issue
Block a user