diff --git a/bukkit/src/main/java/dev/aurelium/auraskills/bukkit/hooks/BukkitLuckPermsHook.java b/bukkit/src/main/java/dev/aurelium/auraskills/bukkit/hooks/BukkitLuckPermsHook.java index 875930128..37d01e7fa 100644 --- a/bukkit/src/main/java/dev/aurelium/auraskills/bukkit/hooks/BukkitLuckPermsHook.java +++ b/bukkit/src/main/java/dev/aurelium/auraskills/bukkit/hooks/BukkitLuckPermsHook.java @@ -32,10 +32,15 @@ public class BukkitLuckPermsHook extends LuckPermsHook implements Listener { private final String prefix = "auraskills.multiplier."; private final Map> permissionCache = new ConcurrentHashMap<>(); + private final boolean usePermissionCache; public BukkitLuckPermsHook(AuraSkillsPlugin plugin, ConfigurationNode config) { super(plugin, config); + this.usePermissionCache = config.node("use_permission_cache").getBoolean(true); + + if (!this.usePermissionCache) return; + luckPerms.getEventBus().subscribe(NodeAddEvent.class, event -> handleEvent(event.getNode(), event.getTarget())); @@ -43,6 +48,10 @@ public BukkitLuckPermsHook(AuraSkillsPlugin plugin, ConfigurationNode config) { event -> handleEvent(event.getNode(), event.getTarget())); } + public boolean usePermissionCache() { + return usePermissionCache; + } + private void handleEvent(Node node, PermissionHolder target) { if (!(node instanceof PermissionNode) && !(node instanceof InheritanceNode)) return; @@ -56,7 +65,7 @@ private void handleEvent(Node node, PermissionHolder target) { () -> { Player player = Bukkit.getPlayer(user.getUniqueId()); // In case if someone logs out in that 500 ms timeframe - if(player == null || !player.isOnline()) return; + if (player == null || !player.isOnline()) return; permissionCache.put(user.getUniqueId(), getMultiplierPermissions(user.getUniqueId())); }, 500, diff --git a/bukkit/src/main/java/dev/aurelium/auraskills/bukkit/user/BukkitUser.java b/bukkit/src/main/java/dev/aurelium/auraskills/bukkit/user/BukkitUser.java index 85ee0c272..a1c2dd5b7 100644 --- a/bukkit/src/main/java/dev/aurelium/auraskills/bukkit/user/BukkitUser.java +++ b/bukkit/src/main/java/dev/aurelium/auraskills/bukkit/user/BukkitUser.java @@ -65,7 +65,8 @@ public double getPermissionMultiplier(@Nullable Skill skill) { } double multiplier = 0.0; - if (plugin.getHookManager().isRegistered(BukkitLuckPermsHook.class)) { + if (plugin.getHookManager().isRegistered(BukkitLuckPermsHook.class) + && plugin.getHookManager().getHook(BukkitLuckPermsHook.class).usePermissionCache()) { Set permissions = plugin.getHookManager().getHook(BukkitLuckPermsHook.class).getMultiplierPermissions(player); for (String permission : permissions) { multiplier += getMultiplierFromPermission(permission, skill); @@ -169,7 +170,8 @@ public int getPermissionJobLimit() { if (value > highestLimit) { highestLimit = value; } - } catch (NumberFormatException ignored) {} + } catch (NumberFormatException ignored) { + } } } return highestLimit; diff --git a/common/src/main/resources/config.yml b/common/src/main/resources/config.yml index 7f5b192fe..9e4c81454 100644 --- a/common/src/main/resources/config.yml +++ b/common/src/main/resources/config.yml @@ -25,7 +25,7 @@ sql: max_lifetime: 1800000 keepalive_time: 0 default_language: en -languages: [en, es, fr, de, zh-CN, zh-TW, pt-BR, it, cs, pl, uk, ko, nl, ja, ru, id, vi, tr, fi, th] +languages: [ en, es, fr, de, zh-CN, zh-TW, pt-BR, it, cs, pl, uk, ko, nl, ja, ru, id, vi, tr, fi, th ] try_detect_client_language: false hooks: HolographicDisplays: @@ -34,6 +34,7 @@ hooks: enabled: true LuckPerms: enabled: true + use_permission_cache: true Oraxen: enabled: true PlaceholderAPI: @@ -168,7 +169,7 @@ damage_holograms: colors: default: gray critical: - digits: [white, yellow, gold, red, dark_red, dark_purple, light_purple, blue, dark_blue] + digits: [ white, yellow, gold, red, dark_red, dark_purple, light_purple, blue, dark_blue ] leaderboards: update_period: 6000 update_delay: 6000 @@ -228,10 +229,10 @@ requirement: prevent_weapon_use: true prevent_block_place: true prevent_interact: true - global: [] + global: [ ] armor: prevent_armor_equip: true - global: [] + global: [ ] critical: enabled: sword: true