From 80af1907188a0558241ad909c5a9d30f2dccec40 Mon Sep 17 00:00:00 2001 From: boy0001 Date: Fri, 20 Feb 2015 17:09:53 +1100 Subject: [PATCH] . --- .../plot/config/Permissions.java | 18 ++++ .../plot/object/Plot.java | 96 ++----------------- .../plot/util/PlotHelper.java | 9 +- .../plot/util/SendChunk.java | 1 - .../plot/util/bukkit/BukkitUtil.java | 3 +- 5 files changed, 30 insertions(+), 97 deletions(-) create mode 100644 PlotSquared/src/main/java/com/intellectualcrafters/plot/config/Permissions.java diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/config/Permissions.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/config/Permissions.java new file mode 100644 index 000000000..97a8c8593 --- /dev/null +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/config/Permissions.java @@ -0,0 +1,18 @@ +package com.intellectualcrafters.plot.config; + +public class Permissions { + // ADMIN + public static String ADMIN = "plots.admin"; + // BUILD + public static String BUILD_OTHER = "plots.admin.build.other"; + public static String BUILD_ROAD = "plots.admin.build.road"; + public static String BUILD_UNOWNED = "plots.admin.build.unowned"; + // INTERACT + public static String INTERACT_OTHER = "plots.admin.interact.other"; + public static String INTERACT_ROAD = "plots.admin.interact.road"; + public static String INTERACT_UNOWNED = "plots.admin.interact.unowned"; + // BREAK + public static String BREAK_OTHER = "plots.admin.break.other"; + public static String BREAK_ROAD = "plots.admin.break.road"; + public static String BREAK_UNOWNED = "plots.admin.break.unowned"; +} diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/Plot.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/Plot.java index 972ce83f5..43d566514 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/Plot.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/Plot.java @@ -26,11 +26,6 @@ import java.util.HashSet; import java.util.Set; import java.util.UUID; -import org.bukkit.Bukkit; -import org.bukkit.World; -import org.bukkit.block.Biome; -import org.bukkit.entity.Player; - import com.intellectualcrafters.plot.BukkitMain; import com.intellectualcrafters.plot.database.DBFunc; import com.intellectualcrafters.plot.flag.Flag; @@ -87,33 +82,6 @@ import com.intellectualcrafters.plot.util.UUIDHandler; public boolean hasChanged = false; public boolean countsTowardsMax = true; - /** - * Primary constructor - * - * @param id - * @param owner - * @param plotBiome - * @param helpers - * @param denied - * - * @deprecated - */ - @Deprecated - @SuppressWarnings("unused") - public Plot(final PlotId id, final UUID owner, final Biome plotBiome, final ArrayList helpers, final ArrayList denied, final String world) { - this.id = id; - this.settings = new PlotSettings(this); - this.owner = owner; - this.deny_entry = this.owner == null; - this.helpers = helpers; - this.denied = denied; - this.trusted = new ArrayList<>(); - this.settings.setAlias(""); - this.delete = false; - this.settings.flags = new HashSet(); - this.world = world; - } - /** * Primary constructor * @@ -136,40 +104,6 @@ import com.intellectualcrafters.plot.util.UUIDHandler; this.world = world; } - /** - * Constructor for saved plots - * - * @param id - * @param owner - * @param plotBiome - * @param helpers - * @param denied - * @param merged - * - * @deprecated - */ - @Deprecated - @SuppressWarnings("unused") - public Plot(final PlotId id, final UUID owner, final Biome plotBiome, final ArrayList helpers, final ArrayList trusted, final ArrayList denied, final String alias, final BlockLoc position, final Set flags, final String world, final boolean[] merged) { - this.id = id; - this.settings = new PlotSettings(this); - this.owner = owner; - this.deny_entry = this.owner != null; - this.trusted = trusted; - this.helpers = helpers; - this.denied = denied; - this.settings.setAlias(alias); - this.settings.setPosition(position); - this.settings.setMerged(merged); - this.delete = false; - if (flags != null) { - this.settings.flags = flags; - } else { - this.settings.flags = new HashSet(); - } - this.world = world; - } - /** * Constructor for saved plots * @@ -215,8 +149,8 @@ import com.intellectualcrafters.plot.util.UUIDHandler; * * @return true if the player is added as a helper or is the owner */ - public boolean hasRights(final Player player) { - return BukkitMain.hasPermission(player, "plots.admin.build.other") || ((this.helpers != null) && this.helpers.contains(DBFunc.everyone)) || ((this.helpers != null) && this.helpers.contains(UUIDHandler.getUUID(player))) || ((this.owner != null) && this.owner.equals(UUIDHandler.getUUID(player))) || ((this.owner != null) && (this.trusted != null) && (UUIDHandler.uuidWrapper.getPlayer(this.owner) != null) && (this.trusted.contains(UUIDHandler.getUUID(player)) || this.trusted.contains(DBFunc.everyone))); + public boolean isAdded(final UUID uuid) { + return ((this.helpers != null) && this.helpers.contains(DBFunc.everyone)) || ((this.helpers != null) && this.helpers.contains(uuid)) || ((this.owner != null) && this.owner.equals(uuid)) || ((this.owner != null) && (this.trusted != null) && (UUIDHandler.uuidWrapper.getPlayer(this.owner) != null) && (this.trusted.contains(uuid) || this.trusted.contains(DBFunc.everyone))); } /** @@ -226,8 +160,8 @@ import com.intellectualcrafters.plot.util.UUIDHandler; * * @return false if the player is allowed to enter */ - public boolean deny_entry(final Player player) { - return (this.denied != null) && ((this.denied.contains(DBFunc.everyone) && !this.hasRights(player)) || (!this.hasRights(player) && this.denied.contains(UUIDHandler.getUUID(player)))); + public boolean isDenied(final UUID uuid) { + return (this.denied != null) && ((this.denied.contains(DBFunc.everyone) && !this.isAdded(uuid)) || (!this.isAdded(uuid) && this.denied.contains(uuid))); } /** @@ -242,8 +176,8 @@ import com.intellectualcrafters.plot.util.UUIDHandler; * * @param player */ - public void setOwner(final Player player) { - this.owner = UUIDHandler.getUUID(player); + public void setOwner(final UUID uuid) { + this.owner = uuid; } /** @@ -253,13 +187,6 @@ import com.intellectualcrafters.plot.util.UUIDHandler; return this.id; } - /** - * Get the plot World - */ - public World getWorld() { - return Bukkit.getWorld(this.world); - } - /** * Get a clone of the plot * @@ -269,7 +196,7 @@ import com.intellectualcrafters.plot.util.UUIDHandler; public Object clone() throws CloneNotSupportedException { final Plot p = (Plot) super.clone(); if (!p.equals(this) || (p != this)) { - return new Plot(this.id, this.owner, this.helpers, this.trusted, this.denied, this.settings.getAlias(), this.settings.getPosition(), this.settings.flags, getWorld().getName(), this.settings.getMerged()); + return new Plot(this.id, this.owner, this.helpers, this.trusted, this.denied, this.settings.getAlias(), this.settings.getPosition(), this.settings.flags, this.world, this.settings.getMerged()); } return p; } @@ -340,15 +267,6 @@ import com.intellectualcrafters.plot.util.UUIDHandler; this.trusted.remove(uuid); } - /** - * Clear a plot - * - * @param plr initiator - */ - public void clear(final Player plr, final boolean isDelete) { - PlotHelper.clear(plr, this, isDelete); - } - @Override public boolean equals(final Object obj) { if (this == obj) { diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/PlotHelper.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/PlotHelper.java index bc358bd02..91f4a785f 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/PlotHelper.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/PlotHelper.java @@ -27,9 +27,6 @@ import java.util.HashMap; import java.util.List; import java.util.UUID; -import org.bukkit.Chunk; -import org.bukkit.block.Biome; - import net.milkbowl.vault.economy.Economy; import com.intellectualcrafters.plot.BukkitMain; @@ -466,7 +463,7 @@ import com.intellectualcrafters.plot.util.bukkit.BukkitUtil; Runnable run = new Runnable() { @Override public void run() { - PlotHelper.setBiome(world, plot, Biome.FOREST); + PlotHelper.setBiome(world, plot, "FOREST"); runners.remove(plot); TaskManager.runTask(whenDone); AChunkManager.manager.update(location); @@ -535,13 +532,13 @@ import com.intellectualcrafters.plot.util.bukkit.BukkitUtil; BlockManager.setBlocks(world, xl, yl, zl, ids, data); } - public static void setBiome(final String world, final Plot plot, final Biome b) { + public static void setBiome(final String world, final Plot plot, final String biome) { final int bottomX = getPlotBottomLoc(world, plot.id).getX() + 1; final int topX = getPlotTopLoc(world, plot.id).getX(); final int bottomZ = getPlotBottomLoc(world, plot.id).getZ() + 1; final int topZ = getPlotTopLoc(world, plot.id).getZ(); - BukkitUtil.setBiome(world, bottomX, bottomZ, topX, topZ, b); + BukkitUtil.setBiome(world, bottomX, bottomZ, topX, topZ, biome); } public static int getHeighestBlock(final String world, final int x, final int z) { diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/SendChunk.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/SendChunk.java index f4157d461..923bbc35f 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/SendChunk.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/SendChunk.java @@ -4,7 +4,6 @@ import static com.intellectualcrafters.plot.util.ReflectionUtils.getRefClass; import java.util.HashSet; import java.util.List; -import java.util.Set; import org.bukkit.Bukkit; import org.bukkit.Chunk; diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/BukkitUtil.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/BukkitUtil.java index 8da1bc20a..76fe85727 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/BukkitUtil.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/BukkitUtil.java @@ -91,7 +91,8 @@ public class BukkitUtil extends BlockManager { } } - public static void setBiome(String worldname, int pos1_x, int pos1_z, int pos2_x, int pos2_z, Biome b) { + public static void setBiome(String worldname, int pos1_x, int pos1_z, int pos2_x, int pos2_z, String biome) { + Biome b = Biome.valueOf(biome.toUpperCase()); World world = getWorld(worldname); for (int x = pos1_x; x<= pos2_x; x++) { for (int z = pos1_z; z<= pos2_z; z++) {