From b459f8bdb5a8a15e3571a4dd59267f604bc1bed3 Mon Sep 17 00:00:00 2001 From: BONNe Date: Sun, 27 Mar 2022 14:43:31 +0300 Subject: [PATCH 1/2] Fixes wrong placeholder value #159 Placeholder value did not check default and world limits. It used just island limits that are assigned via permissions. This commit should fix it. --- src/main/java/world/bentobox/limits/Limits.java | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/main/java/world/bentobox/limits/Limits.java b/src/main/java/world/bentobox/limits/Limits.java index 18c9798..c54a306 100644 --- a/src/main/java/world/bentobox/limits/Limits.java +++ b/src/main/java/world/bentobox/limits/Limits.java @@ -191,11 +191,11 @@ public class Limits extends Addon { if (is == null) { return LIMIT_NOT_SET; } - @Nullable IslandBlockCount ibc = getBlockLimitListener().getIsland(is.getUniqueId()); - if (ibc == null) { - return LIMIT_NOT_SET; - } - int limit = ibc.getBlockLimit(m); + + int limit = this.getBlockLimitListener(). + getMaterialLimits(is.getWorld(), is.getUniqueId()). + getOrDefault(m, -1); + return limit == -1 ? LIMIT_NOT_SET : String.valueOf(limit); } From 5fd461ddea1f103bc3217d16e826efbd39ac23b1 Mon Sep 17 00:00:00 2001 From: BONNe Date: Sun, 27 Mar 2022 14:45:43 +0300 Subject: [PATCH 2/2] Add limits offsets to the GUI and Placeholder Offsets were not added to the GUI and Placeholder value. Part of #159 --- .../bentobox/limits/listeners/BlockLimitsListener.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/main/java/world/bentobox/limits/listeners/BlockLimitsListener.java b/src/main/java/world/bentobox/limits/listeners/BlockLimitsListener.java index 0fa02b9..1f5742b 100644 --- a/src/main/java/world/bentobox/limits/listeners/BlockLimitsListener.java +++ b/src/main/java/world/bentobox/limits/listeners/BlockLimitsListener.java @@ -431,7 +431,12 @@ public class BlockLimitsListener implements Listener { } // Island if (islandCountMap.containsKey(id)) { - result.putAll(islandCountMap.get(id).getBlockLimits()); + IslandBlockCount islandBlockCount = islandCountMap.get(id); + result.putAll(islandBlockCount.getBlockLimits()); + + // Add offsets to the every limit. + islandBlockCount.getBlockLimitsOffset().forEach((material, offset) -> + result.put(material, result.getOrDefault(material, 0) + offset)); } return result; }