mirror of
https://github.com/IntellectualSites/PlotSquared.git
synced 2024-11-22 21:26:45 +01:00
Permissions overhaul
This commit is contained in:
parent
f119f6996d
commit
f2b5f1d224
@ -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)) {
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
@ -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;
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -54,7 +54,7 @@ public class Setup extends SubCommand implements Listener {
|
||||
public final static Map<String, SetupObject> 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
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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;
|
||||
|
@ -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))) {
|
||||
|
@ -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,40 +382,33 @@ 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 (PlotMain.hasPermission(player, "plots.admin.interact.road")) {
|
||||
return;
|
||||
}
|
||||
if (PlayerFunctions.getPlot(event.getClickedBlock().getLocation()) == null) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
||||
public static void MobSpawn(final CreatureSpawnEvent event) {
|
||||
@ -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,26 +511,33 @@ 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())) {
|
||||
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) {
|
||||
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 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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGHEST)
|
||||
public static void onInventoryClick(final InventoryClickEvent event) {
|
||||
@ -568,25 +567,32 @@ 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())) {
|
||||
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) {
|
||||
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 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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
|
||||
public static void onHangingPlace(final HangingPlaceEvent e) {
|
||||
@ -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);
|
||||
}
|
||||
}
|
||||
|
@ -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)));
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
Reference in New Issue
Block a user