From 81c72ee5d99cd7144298ba5cd9aab1cd6024a0a7 Mon Sep 17 00:00:00 2001 From: N0tMyFaultOG Date: Mon, 2 Nov 2020 21:03:46 +0100 Subject: [PATCH] Finish up permissions --- .../bukkit/util/BukkitEntityUtil.java | 32 +++++++++---------- .../com/plotsquared/core/command/Cluster.java | 4 +-- .../com/plotsquared/core/command/Merge.java | 2 +- .../core/permissions/Permission.java | 4 +++ 4 files changed, 23 insertions(+), 19 deletions(-) diff --git a/Bukkit/src/main/java/com/plotsquared/bukkit/util/BukkitEntityUtil.java b/Bukkit/src/main/java/com/plotsquared/bukkit/util/BukkitEntityUtil.java index b87f3bdcc..ad345dcbe 100644 --- a/Bukkit/src/main/java/com/plotsquared/bukkit/util/BukkitEntityUtil.java +++ b/Bukkit/src/main/java/com/plotsquared/bukkit/util/BukkitEntityUtil.java @@ -187,10 +187,10 @@ public class BukkitEntityUtil { } return true; } - if (!Permissions.hasPermission(plotPlayer, "plots.admin.destroy." + stub)) { + if (!Permissions.hasPermission(plotPlayer, Permission.PERMISSION_ADMIN_DESTROY + "." + stub)) { plotPlayer.sendMessage( TranslatableCaption.of("permission.no_permission_event"), - Template.of("node", "plots.admin.destroy." + stub) + Template.of("node", Permission.PERMISSION_ADMIN_DESTROY + "." + stub) ); return false; } @@ -199,10 +199,10 @@ public class BukkitEntityUtil { .isAdded(plotPlayer.getUUID()))) { return true; } - if (!Permissions.hasPermission(plotPlayer, "plots.admin.destroy." + stub)) { + if (!Permissions.hasPermission(plotPlayer, Permission.PERMISSION_ADMIN_DESTROY + "." + stub)) { plotPlayer.sendMessage( TranslatableCaption.of("permission.no_permission_event"), - Template.of("node", "plots.admin.destroy." + stub) + Template.of("node", Permission.PERMISSION_ADMIN_DESTROY + "." + stub) ); if (plot != null) { plot.debug(player.getName() @@ -220,10 +220,10 @@ public class BukkitEntityUtil { .getFlag(PveFlag.class))) { return true; } - if (!Permissions.hasPermission(plotPlayer, "plots.admin.pve." + stub)) { + if (!Permissions.hasPermission(plotPlayer, Permission.PERMISSION_ADMIN_PVE + "." + stub)) { plotPlayer.sendMessage( TranslatableCaption.of("permission.no_permission_event"), - Template.of("node", "plots.admin.pve." + stub) + Template.of("node", Permission.PERMISSION_ADMIN_PVE + "." + stub) ); if (plot != null) { plot.debug(player.getName() + " could not attack " + entityType @@ -241,10 +241,10 @@ public class BukkitEntityUtil { .getFlag(PveFlag.class))) { return true; } - if (!Permissions.hasPermission(plotPlayer, "plots.admin.pve." + stub)) { + if (!Permissions.hasPermission(plotPlayer, Permission.PERMISSION_ADMIN_PVE + "." + stub)) { plotPlayer.sendMessage( TranslatableCaption.of("permission.no_permission_event"), - Template.of("node", "plots.admin.pve." + stub) + Template.of("node", Permission.PERMISSION_ADMIN_PVE + "." + stub) ); if (plot != null) { plot.debug(player.getName() + " could not attack " + entityType @@ -255,10 +255,10 @@ public class BukkitEntityUtil { } else if (EntityCategories.PLAYER.contains(entityType)) { if (isPlot) { if (!plot.getFlag(PvpFlag.class) && !Permissions - .hasPermission(plotPlayer, "plots.admin.pvp." + stub)) { + .hasPermission(plotPlayer, Permission.PERMISSION_ADMIN_PVP + "." + stub)) { plotPlayer.sendMessage( TranslatableCaption.of("permission.no_permission_event"), - Template.of("node", "plots.admin.pvp." + stub) + Template.of("node", Permission.PERMISSION_ADMIN_PVP + "." + stub) ); plot.debug(player.getName() + " could not attack " + entityType + " because pve = false"); @@ -269,10 +269,10 @@ public class BukkitEntityUtil { } else if (roadFlags && area.getRoadFlag(PvpFlag.class)) { return true; } - if (!Permissions.hasPermission(plotPlayer, "plots.admin.pvp." + stub)) { + if (!Permissions.hasPermission(plotPlayer, Permission.PERMISSION_ADMIN_PVP + "." + stub)) { plotPlayer.sendMessage( TranslatableCaption.of("permission.no_permission_event"), - Template.of("node", "plots.admin.pvp." + stub) + Template.of("node", Permission.PERMISSION_ADMIN_PVP + "." + stub) ); return false; } @@ -286,10 +286,10 @@ public class BukkitEntityUtil { } } else if (roadFlags && (area.getRoadFlag(AnimalAttackFlag.class) || area .getFlag(PveFlag.class))) { - if (!Permissions.hasPermission(plotPlayer, "plots.admin.pve." + stub)) { + if (!Permissions.hasPermission(plotPlayer, Permission.PERMISSION_ADMIN_PVE + "." + stub)) { plotPlayer.sendMessage( TranslatableCaption.of("permission.no_permission_event"), - Template.of("node", "plots.admin.pve." + stub) + Template.of("node", Permission.PERMISSION_ADMIN_PVE + "." + stub) ); return false; } @@ -305,10 +305,10 @@ public class BukkitEntityUtil { } else if (roadFlags && area.getRoadFlag(PveFlag.class)) { return true; } - if (!Permissions.hasPermission(plotPlayer, "plots.admin.pve." + stub)) { + if (!Permissions.hasPermission(plotPlayer, Permission.PERMISSION_ADMIN_PVE + "." + stub)) { plotPlayer.sendMessage( TranslatableCaption.of("permission.no_permission_event"), - Template.of("node", "plots.admin.pve." + stub) + Template.of("node", Permission.PERMISSION_ADMIN_PVE + "." + stub) ); if (plot != null) { plot.debug(player.getName() + " could not attack " + entityType diff --git a/Core/src/main/java/com/plotsquared/core/command/Cluster.java b/Core/src/main/java/com/plotsquared/core/command/Cluster.java index de73b13d3..83105d935 100644 --- a/Core/src/main/java/com/plotsquared/core/command/Cluster.java +++ b/Core/src/main/java/com/plotsquared/core/command/Cluster.java @@ -214,7 +214,7 @@ public class Cluster extends SubCommand { if (current + cluster.getArea() > allowed) { player.sendMessage( TranslatableCaption.of("permission.no_permission"), - Template.of("node", "plots.cluster.size" + "." + (current + cluster.getArea())) + Template.of("node", Permission.PERMISSION_CLUSTER_SIZE + "." + (current + cluster.getArea())) ); return false; } @@ -385,7 +385,7 @@ public class Cluster extends SubCommand { if (current + cluster.getArea() > allowed) { player.sendMessage( TranslatableCaption.of("permission.no_permission"), - Template.of("node", "plots.cluster" + "." + (current + cluster.getArea())) + Template.of("node", Permission.PERMISSION_CLUSTER + "." + (current + cluster.getArea())) ); return false; } diff --git a/Core/src/main/java/com/plotsquared/core/command/Merge.java b/Core/src/main/java/com/plotsquared/core/command/Merge.java index d9e3e5657..8de599b7a 100644 --- a/Core/src/main/java/com/plotsquared/core/command/Merge.java +++ b/Core/src/main/java/com/plotsquared/core/command/Merge.java @@ -158,7 +158,7 @@ public class Merge extends SubCommand { if (!force && size - 1 > maxSize) { player.sendMessage( TranslatableCaption.of("permission.no_permission"), - Template.of("node", "plots.merge." + (size + 1)) + Template.of("node", Permission.PERMISSION_MERGE + "." + (size + 1)) ); return false; } diff --git a/Core/src/main/java/com/plotsquared/core/permissions/Permission.java b/Core/src/main/java/com/plotsquared/core/permissions/Permission.java index f9c3ca54a..9d5883891 100644 --- a/Core/src/main/java/com/plotsquared/core/permissions/Permission.java +++ b/Core/src/main/java/com/plotsquared/core/permissions/Permission.java @@ -50,10 +50,12 @@ public enum Permission { PERMISSION_ADMIN_VISIT_UNTRUSTED("plots.admin.visit.untrusted"), PERMISSION_ADMIN_ENTRY_FORCEFIELD("plots.admin.entry.forcefield"), PERMISSION_ADMIN_COMMANDS_CHATSPY("plots.admin.command.chatspy"), + PERMISSION_MERGE("plots.merge"), PERMISSION_MERGE_OTHER("plots.merge.other"), PERMISSION_MERGE_KEEP_ROAD("plots.merge.keeproad"), PERMISSION_ADMIN_CAPS_OTHER("plots.admin.caps.other"), PERMISSION_ADMIN_MUSIC_OTHER("plots.admin.music.other"), + PERMISSION_ADMIN_DESTROY("plots.admin.destroy"), PERMISSION_ADMIN_DESTROY_UNOWNED("plots.admin.destroy.unowned"), PERMISSION_ADMIN_DESTROY_GROUNDLEVEL("plots.admin.destroy.groundlevel"), PERMISSION_ADMIN_DESTROY_OTHER("plots.admin.destroy.other"), @@ -61,6 +63,8 @@ public enum Permission { PERMISSION_ADMIN_DESTROY_VEHICLE_ROAD("plots.admin.vehicle.break.road"), PERMISSION_ADMIN_DESTROY_VEHICLE_UNOWNED("plots.admin.vehicle.break.unowned"), PERMISSION_ADMIN_DESTROY_VEHICLE_OTHER("plots.admin.vehicle.break.other"), + PERMISSION_ADMIN_PVE("plots.admin.pve"), + PERMISSION_ADMIN_PVP("plots.admin.pvp"), PERMISSION_ADMIN_BUILD_ROAD("plots.admin.build.road"), PERMISSION_ADMIN_PROJECTILE_ROAD("plots.admin.projectile.road"), PERMISSION_ADMIN_PROJECTILE_UNOWNED("plots.admin.projectile.unowned"),