diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/PlotMain.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/PlotMain.java index 671a29d23..3ea860a4d 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/PlotMain.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/PlotMain.java @@ -284,7 +284,7 @@ import com.sk89q.worldguard.bukkit.WorldGuardPlugin; * @return true if player has the permission */ public static boolean hasPermission(final Player player, final String perm) { - if ((player == null) || player.isOp()) { + if ((player == null) || player.isOp() || player.hasPermission(ADMIN_PERMISSION)) { return true; } if (player.hasPermission(perm)) { diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Auto.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Auto.java index b3a0ad98b..a7d17fc7d 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Auto.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Auto.java @@ -153,7 +153,7 @@ import org.bukkit.entity.Player; sendMessage(plr, C.SCHEMATIC_INVALID, "non-existent: " + schematic); return true; } - if (!PlotMain.hasPermission(plr, "plots.claim." + schematic) && !plr.hasPermission("plots.admin")) { + if (!PlotMain.hasPermission(plr, "plots.claim." + schematic) && !plr.hasPermission("plots.admin.command.schematic")) { PlayerFunctions.sendMessage(plr, C.NO_SCHEMATIC_PERMISSION, schematic); return true; } diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Claim.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Claim.java index a2ea2987f..470353ca4 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Claim.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Claim.java @@ -125,7 +125,7 @@ public class Claim extends SubCommand { if (!world.SCHEMATICS.contains(schematic.toLowerCase())) { return sendMessage(plr, C.SCHEMATIC_INVALID, "non-existent: " + schematic); } - if (!PlotMain.hasPermission(plr, "plots.claim." + schematic) && !plr.hasPermission("plots.admin")) { + if (!PlotMain.hasPermission(plr, "plots.claim." + schematic) && !plr.hasPermission("plots.admin.command.schematic")) { return sendMessage(plr, C.NO_SCHEMATIC_PERMISSION, schematic); } } diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Clear.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Clear.java index 061bb9fbf..dfa5ebf69 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Clear.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Clear.java @@ -72,7 +72,7 @@ public class Clear extends SubCommand { if (!PlayerFunctions.getTopPlot(plr.getWorld(), plot).equals(PlayerFunctions.getBottomPlot(plr.getWorld(), plot))) { return sendMessage(plr, C.UNLINK_REQUIRED); } - if (((plot == null) || !plot.hasOwner() || !plot.getOwner().equals(UUIDHandler.getUUID(plr))) && !PlotMain.hasPermission(plr, "plots.admin")) { + if (((plot == null) || !plot.hasOwner() || !plot.getOwner().equals(UUIDHandler.getUUID(plr))) && !PlotMain.hasPermission(plr, "plots.admin.command.clear")) { return sendMessage(plr, C.NO_PLOT_PERMS); } assert plot != null; diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/CommandPermission.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/CommandPermission.java index 919d5b4ea..e1790b321 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/CommandPermission.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/CommandPermission.java @@ -49,6 +49,6 @@ public class CommandPermission { * @return true of player has the required permission node */ public boolean hasPermission(final Player player) { - return PlotMain.hasPermission(player, this.permission) || PlotMain.hasPermission(player, "plots.admin"); + return PlotMain.hasPermission(player, this.permission); } } diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Copy.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Copy.java index 52ed3fb56..7c1731d88 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Copy.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Copy.java @@ -44,7 +44,7 @@ public class Copy extends SubCommand { return false; } final Plot plot = PlayerFunctions.getCurrentPlot(plr); - if (((plot == null) || !plot.hasOwner() || !plot.getOwner().equals(UUIDHandler.getUUID(plr))) && !PlotMain.hasPermission(plr, "plots.admin")) { + if (((plot == null) || !plot.hasOwner() || !plot.getOwner().equals(UUIDHandler.getUUID(plr))) && !PlotMain.hasPermission(plr, "plots.admin.command.copy")) { PlayerFunctions.sendMessage(plr, C.NO_PLOT_PERMS); return false; } diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/DebugClear.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/DebugClear.java index 132e03f77..d786c0735 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/DebugClear.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/DebugClear.java @@ -78,7 +78,7 @@ public class DebugClear extends SubCommand { if (!PlayerFunctions.getTopPlot(plr.getWorld(), plot).equals(PlayerFunctions.getBottomPlot(plr.getWorld(), plot))) { return sendMessage(plr, C.UNLINK_REQUIRED); } - if (((plot == null) || !plot.hasOwner() || !plot.getOwner().equals(UUIDHandler.getUUID(plr))) && !PlotMain.hasPermission(plr, "plots.admin")) { + if (((plot == null) || !plot.hasOwner() || !plot.getOwner().equals(UUIDHandler.getUUID(plr))) && !PlotMain.hasPermission(plr, "plots.admin.command.debugclear")) { return sendMessage(plr, C.NO_PLOT_PERMS); } assert plot != null; diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Delete.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Delete.java index 1fd440f77..a187fd1ec 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Delete.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Delete.java @@ -46,7 +46,7 @@ public class Delete extends SubCommand { if (!PlayerFunctions.getTopPlot(plr.getWorld(), plot).equals(PlayerFunctions.getBottomPlot(plr.getWorld(), plot))) { return !sendMessage(plr, C.UNLINK_REQUIRED); } - if ((((plot == null) || !plot.hasOwner() || !plot.getOwner().equals(UUIDHandler.uuidWrapper.getUUID(plr)))) && !PlotMain.hasPermission(plr, "plots.admin")) { + if ((((plot == null) || !plot.hasOwner() || !plot.getOwner().equals(UUIDHandler.uuidWrapper.getUUID(plr)))) && !PlotMain.hasPermission(plr, "plots.admin.command.delete")) { return !sendMessage(plr, C.NO_PLOT_PERMS); } assert plot != null; diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Denied.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Denied.java index bfc4ae702..d352672ad 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Denied.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Denied.java @@ -55,7 +55,7 @@ import java.util.UUID; PlayerFunctions.sendMessage(plr, C.PLOT_UNOWNED); return false; } - if (!plot.getOwner().equals(UUIDHandler.getUUID(plr)) && !PlotMain.hasPermission(plr, "plots.admin")) { + if (!plot.getOwner().equals(UUIDHandler.getUUID(plr)) && !PlotMain.hasPermission(plr, "plots.admin.command.denied")) { PlayerFunctions.sendMessage(plr, C.NO_PLOT_PERMS); return true; } diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Helpers.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Helpers.java index 607c7c79d..6e96ac107 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Helpers.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Helpers.java @@ -55,7 +55,7 @@ import java.util.UUID; PlayerFunctions.sendMessage(plr, C.PLOT_UNOWNED); return false; } - if (!plot.getOwner().equals(UUIDHandler.getUUID(plr)) && !PlotMain.hasPermission(plr, "plots.admin")) { + if (!plot.getOwner().equals(UUIDHandler.getUUID(plr)) && !PlotMain.hasPermission(plr, "plots.admin.command.helpers")) { PlayerFunctions.sendMessage(plr, C.NO_PLOT_PERMS); return true; } diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Inbox.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Inbox.java index 7a9901e1d..6feb74467 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Inbox.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Inbox.java @@ -57,7 +57,7 @@ public class Inbox extends SubCommand { Integer tier; final UUID uuid = UUIDHandler.getUUID(plr); - if (PlotMain.hasPermission(plr, "plots.admin")) { + if (PlotMain.hasPermission(plr, "plots.comment.admin")) { tier = 0; } else if (plot.owner == uuid) { tier = 1; diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Kick.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Kick.java index d09b8307c..fcf20886e 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Kick.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Kick.java @@ -43,7 +43,7 @@ import org.bukkit.entity.Player; return false; } final Plot plot = PlayerFunctions.getCurrentPlot(plr); - if (((plot == null) || !plot.hasOwner() || !plot.getOwner().equals(UUIDHandler.getUUID(plr))) && !PlotMain.hasPermission(plr, "plots.admin")) { + if (((plot == null) || !plot.hasOwner() || !plot.getOwner().equals(UUIDHandler.getUUID(plr))) && !PlotMain.hasPermission(plr, "plots.admin.command.kick")) { PlayerFunctions.sendMessage(plr, C.NO_PLOT_PERMS); return false; } diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Merge.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Merge.java index c065c3adf..844ef7249 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Merge.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Merge.java @@ -86,7 +86,7 @@ public class Merge extends SubCommand { PlayerFunctions.sendMessage(plr, C.PLOT_UNOWNED); return false; } - boolean admin = PlotMain.hasPermission(plr, "plots.admin"); + boolean admin = PlotMain.hasPermission(plr, "plots.admin.command.merge"); if (!plot.getOwner().equals(UUIDHandler.getUUID(plr)) && !admin) { PlayerFunctions.sendMessage(plr, C.NO_PLOT_PERMS); return false; diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Paste.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Paste.java index 86a47cca9..4a8121be7 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Paste.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Paste.java @@ -44,7 +44,7 @@ public class Paste extends SubCommand { return false; } final Plot plot = PlayerFunctions.getCurrentPlot(plr); - if (((plot == null) || !plot.hasOwner() || !plot.getOwner().equals(UUIDHandler.getUUID(plr))) && !PlotMain.hasPermission(plr, "plots.admin")) { + if (((plot == null) || !plot.hasOwner() || !plot.getOwner().equals(UUIDHandler.getUUID(plr))) && !PlotMain.hasPermission(plr, "plots.admin.command.paste")) { PlayerFunctions.sendMessage(plr, C.NO_PLOT_PERMS); return false; } diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Reload.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Reload.java index e5a43f8d8..d0cda4684 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Reload.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Reload.java @@ -30,7 +30,7 @@ import org.bukkit.entity.Player; public class Reload extends SubCommand { public Reload() { - super("reload", "plots.admin", "Reload configurations", "", "reload", CommandCategory.INFO, false); + super("reload", "plots.admin.command.reload", "Reload configurations", "", "reload", CommandCategory.INFO, false); } @Override diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Set.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Set.java index 72fc9333e..694a3dc4e 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Set.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Set.java @@ -75,7 +75,7 @@ public class Set extends SubCommand { sendMessage(plr, C.PLOT_NOT_CLAIMED); return false; } - if (!plot.hasRights(plr) && !PlotMain.hasPermission(plr, "plots.admin")) { + if (!plot.hasRights(plr) && !PlotMain.hasPermission(plr, "plots.admin.command.set")) { PlayerFunctions.sendMessage(plr, C.NO_PLOT_PERMS); return false; } diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/SetOwner.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/SetOwner.java index 16ef018d4..07f92267a 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/SetOwner.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/SetOwner.java @@ -38,7 +38,7 @@ import java.util.UUID; @SuppressWarnings("deprecation") public class SetOwner extends SubCommand { public SetOwner() { - super("setowner", "plots.admin", "Set the plot owner", "setowner {player}", "so", CommandCategory.ACTIONS, true); + super("setowner", "plots.admin.command.setowner", "Set the plot owner", "setowner {player}", "so", CommandCategory.ACTIONS, true); } /* diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Setup.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Setup.java index 3225c26ab..f73a9d221 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Setup.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Setup.java @@ -54,7 +54,7 @@ public class Setup extends SubCommand implements Listener { public final static Map setupMap = new HashMap<>(); public Setup() { - super("setup", "plots.admin", "Setup a PlotWorld", "setup {world} {generator}", "setup", CommandCategory.ACTIONS, false); + super("setup", "plots.admin.command.setup", "Setup a PlotWorld", "setup {world} {generator}", "setup", CommandCategory.ACTIONS, false); } @Override diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Swap.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Swap.java index 4b645cb7f..8ba07ff4b 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Swap.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Swap.java @@ -57,7 +57,7 @@ public class Swap extends SubCommand { return false; } final Plot plot = PlayerFunctions.getCurrentPlot(plr); - if (((plot == null) || !plot.hasOwner() || !plot.getOwner().equals(UUIDHandler.getUUID(plr))) && !PlotMain.hasPermission(plr, "plots.admin")) { + if (((plot == null) || !plot.hasOwner() || !plot.getOwner().equals(UUIDHandler.getUUID(plr))) && !PlotMain.hasPermission(plr, "plots.admin.command.swap")) { PlayerFunctions.sendMessage(plr, C.NO_PLOT_PERMS); return false; } @@ -71,7 +71,7 @@ public class Swap extends SubCommand { try { plotid = new PlotId(Integer.parseInt(id.split(";")[0]), Integer.parseInt(id.split(";")[1])); final Plot plot2 = PlotMain.getPlots(world).get(plotid); - if (((plot2 == null) || !plot2.hasOwner() || (plot2.owner != UUIDHandler.getUUID(plr))) && !PlotMain.hasPermission(plr, "plots.admin")) { + if (((plot2 == null) || !plot2.hasOwner() || (plot2.owner != UUIDHandler.getUUID(plr))) && !PlotMain.hasPermission(plr, "plots.admin.command.swap")) { PlayerFunctions.sendMessage(plr, C.NO_PERM_MERGE, plotid.toString()); return false; } diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Trusted.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Trusted.java index 2f312aebe..c119ce819 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Trusted.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Trusted.java @@ -55,7 +55,7 @@ import java.util.UUID; PlayerFunctions.sendMessage(plr, C.PLOT_UNOWNED); return false; } - if (!plot.getOwner().equals(UUIDHandler.getUUID(plr)) && !PlotMain.hasPermission(plr, "plots.admin")) { + if (!plot.getOwner().equals(UUIDHandler.getUUID(plr)) && !PlotMain.hasPermission(plr, "plots.admin.command.trusted")) { PlayerFunctions.sendMessage(plr, C.NO_PLOT_PERMS); return true; } diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Unclaim.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Unclaim.java index e434c0189..134c2db65 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Unclaim.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Unclaim.java @@ -48,7 +48,7 @@ public class Unclaim extends SubCommand { if (!PlayerFunctions.getTopPlot(plr.getWorld(), plot).equals(PlayerFunctions.getBottomPlot(plr.getWorld(), plot))) { return !sendMessage(plr, C.UNLINK_REQUIRED); } - if ((((plot == null) || !plot.hasOwner() || !plot.getOwner().equals(UUIDHandler.getUUID(plr)))) && !PlotMain.hasPermission(plr, "plots.admin")) { + if ((((plot == null) || !plot.hasOwner() || !plot.getOwner().equals(UUIDHandler.getUUID(plr)))) && !PlotMain.hasPermission(plr, "plots.admin.command.unclaim")) { return !sendMessage(plr, C.NO_PLOT_PERMS); } assert plot != null; diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Unlink.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Unlink.java index f36c1bef6..6cc2f4d18 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Unlink.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Unlink.java @@ -56,7 +56,7 @@ public class Unlink extends SubCommand { return sendMessage(plr, C.NOT_IN_PLOT); } final Plot plot = PlayerFunctions.getCurrentPlot(plr); - if (((plot == null) || !plot.hasOwner() || !plot.getOwner().equals(UUIDHandler.getUUID(plr))) && !PlotMain.hasPermission(plr, "plots.admin")) { + if (((plot == null) || !plot.hasOwner() || !plot.getOwner().equals(UUIDHandler.getUUID(plr))) && !PlotMain.hasPermission(plr, "plots.admin.command.unlink")) { return sendMessage(plr, C.NO_PLOT_PERMS); } if (PlayerFunctions.getTopPlot(plr.getWorld(), plot).equals(PlayerFunctions.getBottomPlot(plr.getWorld(), plot))) { diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/PlayerEvents.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/PlayerEvents.java index 7778735d9..547d3f5c4 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/PlayerEvents.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/PlayerEvents.java @@ -109,7 +109,7 @@ import java.util.UUID; } if (enteredPlot(f, q)) { final Plot plot = getCurrentPlot(q); - final boolean admin = PlotMain.hasPermission(player, "plots.admin"); + final boolean admin = PlotMain.hasPermission(player, "plots.admin.entry.denied"); if (plot.deny_entry(player) && !admin) { event.setCancelled(true); return; @@ -161,7 +161,7 @@ import java.util.UUID; if (!isPlotWorld(world)) { return; } - if (PlotMain.hasPermission(event.getPlayer(), "plots.admin")) { + if (PlotMain.hasPermission(event.getPlayer(), "plots.admin.destroy.other")) { return; } if (isInPlot(event.getBlock().getLocation())) { @@ -189,8 +189,7 @@ import java.util.UUID; } @EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true) - public static void onPeskyMobsChangeTheWorldLikeWTFEvent( // LOL! - final EntityChangeBlockEvent event) { + public static void onPeskyMobsChangeTheWorldLikeWTFEvent(final EntityChangeBlockEvent event) { final World world = event.getBlock().getWorld(); if (!isPlotWorld(world)) { return; @@ -204,17 +203,17 @@ import java.util.UUID; final Block b = event.getBlock(); final Player p = (Player) e; if (!isInPlot(b.getLocation())) { - if (!PlotMain.hasPermission(p, "plots.admin")) { + if (!PlotMain.hasPermission(p, "plots.admin.build.road")) { event.setCancelled(true); } } else { final Plot plot = getCurrentPlot(b.getLocation()); - if (plot == null) { - if (!PlotMain.hasPermission(p, "plots.admin")) { + if (plot == null || !plot.hasOwner()) { + if (!PlotMain.hasPermission(p, "plots.admin.build.unowned")) { event.setCancelled(true); } } else if (!plot.hasRights(p)) { - if (!PlotMain.hasPermission(p, "plots.admin")) { + if (!PlotMain.hasPermission(p, "plots.admin.build.other")) { event.setCancelled(true); } } @@ -383,39 +382,32 @@ import java.util.UUID; if (!isPlotWorld(world)) { return; } - if (PlotMain.hasPermission(event.getPlayer(), "plots.admin")) { - return; - } + Player player = event.getPlayer(); if (isInPlot(event.getClickedBlock().getLocation())) { final Plot plot = getCurrentPlot(event.getClickedBlock().getLocation()); - - // They shouldn't be allowed to access other people's chests - - // if (new ArrayList<>(Arrays.asList(new Material[] { - // Material.STONE_BUTTON, Material.WOOD_BUTTON, - // Material.LEVER, Material.STONE_PLATE, Material.WOOD_PLATE, - // Material.CHEST, Material.TRAPPED_CHEST, Material.TRAP_DOOR, - // Material.WOOD_DOOR, Material.WOODEN_DOOR, - // Material.DISPENSER, Material.DROPPER - // - // })).contains(event.getClickedBlock().getType())) { - // return; - // } - + if (!plot.hasOwner()) { + if (PlotMain.hasPermission(player, "plots.admin.interact.unowned")) { + return; + } + } if (PlotMain.booleanFlags.containsKey(event.getClickedBlock().getType())) { final String flag = PlotMain.booleanFlags.get(event.getClickedBlock().getType()); if ((FlagManager.getPlotFlag(plot, flag) != null) && getFlagValue(FlagManager.getPlotFlag(plot, flag).getValue())) { return; } } - if (!plot.hasRights(event.getPlayer())) { + if (PlotMain.hasPermission(player, "plots.admin.interact.other")) { + return; + } event.setCancelled(true); } + return; } - if (PlayerFunctions.getPlot(event.getClickedBlock().getLocation()) == null) { - event.setCancelled(true); + if (PlotMain.hasPermission(player, "plots.admin.interact.road")) { + return; } + event.setCancelled(true); } @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) @@ -467,17 +459,17 @@ import java.util.UUID; if (e.getPlayer() != null) { final Player p = e.getPlayer(); if (!isInPlot(b.getLocation())) { - if (!PlotMain.hasPermission(p, "plots.admin")) { + if (!PlotMain.hasPermission(p, "plots.admin.build.road")) { e.setCancelled(true); } } else { final Plot plot = getCurrentPlot(b.getLocation()); - if (plot == null) { - if (!PlotMain.hasPermission(p, "plots.admin")) { + if (plot == null || !plot.hasOwner()) { + if (!PlotMain.hasPermission(p, "plots.admin.build.unowned")) { e.setCancelled(true); } } else if (!plot.hasRights(p)) { - if (!PlotMain.hasPermission(p, "plots.admin")) { + if (!PlotMain.hasPermission(p, "plots.admin.build.other")) { e.setCancelled(true); } } @@ -519,22 +511,29 @@ import java.util.UUID; @EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true) public static void onBucketEmpty(final PlayerBucketEmptyEvent e) { - if (!PlotMain.hasPermission(e.getPlayer(), "plots.admin")) { - final BlockFace bf = e.getBlockFace(); - final Block b = e.getBlockClicked().getLocation().add(bf.getModX(), bf.getModY(), bf.getModZ()).getBlock(); - if (isPlotWorld(b.getLocation())) { - if (!isInPlot(b.getLocation())) { + final BlockFace bf = e.getBlockFace(); + final Block b = e.getBlockClicked().getLocation().add(bf.getModX(), bf.getModY(), bf.getModZ()).getBlock(); + if (isPlotWorld(b.getLocation())) { + if (!isInPlot(b.getLocation())) { + if (PlotMain.hasPermission(e.getPlayer(), "plots.admin.build.road")) { + return; + } + PlayerFunctions.sendMessage(e.getPlayer(), C.NO_PLOT_PERMS); + e.setCancelled(true); + } else { + final Plot plot = getCurrentPlot(b.getLocation()); + if (plot == null || !plot.hasOwner()) { + if (PlotMain.hasPermission(e.getPlayer(), "plots.admin.build.unowned")) { + return; + } PlayerFunctions.sendMessage(e.getPlayer(), C.NO_PLOT_PERMS); e.setCancelled(true); - } else { - final Plot plot = getCurrentPlot(b.getLocation()); - if (plot == null) { - PlayerFunctions.sendMessage(e.getPlayer(), C.NO_PLOT_PERMS); - e.setCancelled(true); - } else if (!plot.hasRights(e.getPlayer())) { - PlayerFunctions.sendMessage(e.getPlayer(), C.NO_PLOT_PERMS); - e.setCancelled(true); + } else if (!plot.hasRights(e.getPlayer())) { + if (PlotMain.hasPermission(e.getPlayer(), "plots.admin.build.other")) { + return; } + PlayerFunctions.sendMessage(e.getPlayer(), C.NO_PLOT_PERMS); + e.setCancelled(true); } } } @@ -568,21 +567,28 @@ import java.util.UUID; @EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true) public static void onBucketFill(final PlayerBucketFillEvent e) { - if (!PlotMain.hasPermission(e.getPlayer(), "plots.admin")) { - final Block b = e.getBlockClicked(); - if (isPlotWorld(b.getLocation())) { - if (!isInPlot(b.getLocation())) { + final Block b = e.getBlockClicked(); + if (isPlotWorld(b.getLocation())) { + if (!isInPlot(b.getLocation())) { + if (PlotMain.hasPermission(e.getPlayer(), "plots.admin.build.road")) { + return; + } + PlayerFunctions.sendMessage(e.getPlayer(), C.NO_PLOT_PERMS); + e.setCancelled(true); + } else { + final Plot plot = getCurrentPlot(b.getLocation()); + if (plot == null || !plot.hasOwner()) { + if (PlotMain.hasPermission(e.getPlayer(), "plots.admin.build.unowned")) { + return; + } PlayerFunctions.sendMessage(e.getPlayer(), C.NO_PLOT_PERMS); e.setCancelled(true); - } else { - final Plot plot = getCurrentPlot(b.getLocation()); - if (plot == null) { - PlayerFunctions.sendMessage(e.getPlayer(), C.NO_PLOT_PERMS); - e.setCancelled(true); - } else if (!plot.hasRights(e.getPlayer())) { - PlayerFunctions.sendMessage(e.getPlayer(), C.NO_PLOT_PERMS); - e.setCancelled(true); + } else if (!plot.hasRights(e.getPlayer())) { + if (PlotMain.hasPermission(e.getPlayer(), "plots.admin.build.other")) { + return; } + PlayerFunctions.sendMessage(e.getPlayer(), C.NO_PLOT_PERMS); + e.setCancelled(true); } } } @@ -594,19 +600,19 @@ import java.util.UUID; if (isPlotWorld(b.getLocation())) { final Player p = e.getPlayer(); if (!isInPlot(b.getLocation())) { - if (!PlotMain.hasPermission(p, "plots.admin")) { + if (!PlotMain.hasPermission(p, "plots.admin.build.road")) { PlayerFunctions.sendMessage(p, C.NO_PLOT_PERMS); e.setCancelled(true); } } else { final Plot plot = getCurrentPlot(b.getLocation()); - if (plot == null) { - if (!PlotMain.hasPermission(p, "plots.admin")) { + if (plot == null || !plot.hasOwner()) { + if (!PlotMain.hasPermission(p, "plots.admin.build.unowned")) { PlayerFunctions.sendMessage(p, C.NO_PLOT_PERMS); e.setCancelled(true); } } else if (!plot.hasRights(p)) { - if (!PlotMain.hasPermission(p, "plots.admin")) { + if (!PlotMain.hasPermission(p, "plots.admin.build.other")) { PlayerFunctions.sendMessage(p, C.NO_PLOT_PERMS); e.setCancelled(true); } @@ -623,19 +629,19 @@ import java.util.UUID; final Location l = e.getEntity().getLocation(); if (isPlotWorld(l)) { if (!isInPlot(l)) { - if (!PlotMain.hasPermission(p, "plots.admin")) { + if (!PlotMain.hasPermission(p, "plots.admin.destroy.road")) { PlayerFunctions.sendMessage(p, C.NO_PLOT_PERMS); e.setCancelled(true); } } else { final Plot plot = getCurrentPlot(l); - if (plot == null) { - if (!PlotMain.hasPermission(p, "plots.admin")) { + if (plot == null || !plot.hasOwner()) { + if (!PlotMain.hasPermission(p, "plots.admin.destroy.unowned")) { PlayerFunctions.sendMessage(p, C.NO_PLOT_PERMS); e.setCancelled(true); } } else if (!plot.hasRights(p)) { - if (!PlotMain.hasPermission(p, "plots.admin")) { + if (!PlotMain.hasPermission(p, "plots.admin.destroy.other")) { PlayerFunctions.sendMessage(p, C.NO_PLOT_PERMS); e.setCancelled(true); } @@ -651,19 +657,19 @@ import java.util.UUID; if (isPlotWorld(l)) { final Player p = e.getPlayer(); if (!isInPlot(l)) { - if (!PlotMain.hasPermission(p, "plots.admin")) { + if (!PlotMain.hasPermission(p, "plots.admin.interact.road")) { PlayerFunctions.sendMessage(p, C.NO_PLOT_PERMS); e.setCancelled(true); } } else { final Plot plot = getCurrentPlot(l); - if (plot == null) { - if (!PlotMain.hasPermission(p, "plots.admin")) { + if (plot == null || !plot.hasOwner()) { + if (!PlotMain.hasPermission(p, "plots.admin.interact.unowned")) { PlayerFunctions.sendMessage(p, C.NO_PLOT_PERMS); e.setCancelled(true); } } else if (!plot.hasRights(p)) { - if (!PlotMain.hasPermission(p, "plots.admin")) { + if (!PlotMain.hasPermission(p, "plots.admin.interact.other")) { PlayerFunctions.sendMessage(p, C.NO_PLOT_PERMS); e.setCancelled(true); } @@ -688,14 +694,14 @@ import java.util.UUID; return; } if (!isInPlot(l)) { - if (!PlotMain.hasPermission(p, "plots.admin")) { + if (!PlotMain.hasPermission(p, "plots.admin.pve.road")) { PlayerFunctions.sendMessage(p, C.NO_PLOT_PERMS); e.setCancelled(true); } } else { final Plot plot = getCurrentPlot(l); - if (plot == null) { - if (!PlotMain.hasPermission(p, "plots.admin")) { + if (plot == null || !plot.hasOwner()) { + if (!PlotMain.hasPermission(p, "plots.admin.pve.unowned")) { PlayerFunctions.sendMessage(p, C.NO_PLOT_PERMS); e.setCancelled(true); return; @@ -708,7 +714,7 @@ import java.util.UUID; } assert plot != null; if (!plot.hasRights(p)) { - if (!PlotMain.hasPermission(p, "plots.admin")) { + if (!PlotMain.hasPermission(p, "plots.admin.pve.other")) { PlayerFunctions.sendMessage(p, C.NO_PLOT_PERMS); e.setCancelled(true); } @@ -724,19 +730,19 @@ import java.util.UUID; if (isPlotWorld(l)) { final Player p = e.getPlayer(); if (!isInPlot(l)) { - if (!PlotMain.hasPermission(p, "plots.admin")) { + if (!PlotMain.hasPermission(p, "plots.admin.projectile.road")) { PlayerFunctions.sendMessage(p, C.NO_PLOT_PERMS); e.setHatching(false); } } else { final Plot plot = getCurrentPlot(l); - if (plot == null) { - if (!PlotMain.hasPermission(p, "plots.admin")) { + if (plot == null || !plot.hasOwner()) { + if (!PlotMain.hasPermission(p, "plots.admin.projectile.unowned")) { PlayerFunctions.sendMessage(p, C.NO_PLOT_PERMS); e.setHatching(false); } } else if (!plot.hasRights(p)) { - if (!PlotMain.hasPermission(p, "plots.admin")) { + if (!PlotMain.hasPermission(p, "plots.admin.projectile.other")) { PlayerFunctions.sendMessage(p, C.NO_PLOT_PERMS); e.setHatching(false); } @@ -754,13 +760,18 @@ import java.util.UUID; if (PlotMain.hasPermission(event.getPlayer(), "plots.admin")) { return; } + Player player = event.getPlayer(); if (isInPlot(event.getBlock().getLocation())) { final Plot plot = getCurrentPlot(event.getBlockPlaced().getLocation()); - if (!plot.hasRights(event.getPlayer())) { + if (!plot.hasOwner() && PlotMain.hasPermission(player, "plots.admin.build.unowned")) { + return; + } + if (!plot.hasRights(player) && !PlotMain.hasPermission(player, "plots.admin.build.other")) { event.setCancelled(true); } + return; } - if (PlayerFunctions.getPlot(event.getBlockPlaced().getLocation()) == null) { + if (!PlotMain.hasPermission(player, "plots.admin.build.road")) { event.setCancelled(true); } } 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 37012667d..49648a96d 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/Plot.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/Plot.java @@ -216,7 +216,7 @@ import java.util.UUID; * @return true if the player is added as a helper or is the owner */ public boolean hasRights(final Player player) { - return PlotMain.hasPermission(player, "plots.admin") || ((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))); + return PlotMain.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))); } /**