From f0c4e16635d9e935ec1a5c4af47d8301e261bbf8 Mon Sep 17 00:00:00 2001 From: Auxilor Date: Fri, 6 Nov 2020 17:37:43 +0000 Subject: [PATCH] Fixed registering already-existing permission --- .../ecoenchants/enchantments/EcoEnchant.java | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/EcoEnchant.java b/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/EcoEnchant.java index b701d20c..95a31b6c 100644 --- a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/EcoEnchant.java +++ b/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/EcoEnchant.java @@ -74,13 +74,15 @@ public abstract class EcoEnchant extends Enchantment implements Listener, Regist if(!Prerequisite.areMet(prerequisites)) return; - Permission permission = new Permission( - "ecoenchants.fromtable." + permissionName, - "Allows getting " + permissionName + " from an Enchanting Table", - PermissionDefault.TRUE - ); - permission.addParent(Bukkit.getPluginManager().getPermission("ecoenchants.fromtable.*"), true); - Bukkit.getPluginManager().addPermission(permission); + if(Bukkit.getPluginManager().getPermission("ecoenchants.fromtable." + permissionName) == null) { + Permission permission = new Permission( + "ecoenchants.fromtable." + permissionName, + "Allows getting " + permissionName + " from an Enchanting Table", + PermissionDefault.TRUE + ); + permission.addParent(Bukkit.getPluginManager().getPermission("ecoenchants.fromtable.*"), true); + Bukkit.getPluginManager().addPermission(permission); + } this.update(); this.add();