From 41e707069d2bf9c8cd7ad75f55305dad864d4f61 Mon Sep 17 00:00:00 2001 From: Brianna Date: Thu, 25 Feb 2021 14:19:28 -0600 Subject: [PATCH] Fixed an issue where decimal block points were not counted correctly. --- .../songoda/skyblock/api/island/IslandLevel.java | 4 ++-- .../com/songoda/skyblock/island/IslandLevel.java | 16 ++++++++-------- .../levelling/calculator/CalculatorRegistry.java | 2 +- .../placeholder/PlaceholderProcessor.java | 2 +- 4 files changed, 12 insertions(+), 12 deletions(-) diff --git a/src/main/java/com/songoda/skyblock/api/island/IslandLevel.java b/src/main/java/com/songoda/skyblock/api/island/IslandLevel.java index b2ac2c1e..7b156013 100644 --- a/src/main/java/com/songoda/skyblock/api/island/IslandLevel.java +++ b/src/main/java/com/songoda/skyblock/api/island/IslandLevel.java @@ -17,7 +17,7 @@ public class IslandLevel { /** * @return Points of the Island from gathered materials */ - public long getPoints() { + public double getPoints() { return this.handle.getIsland().getLevel().getPoints(); } @@ -31,7 +31,7 @@ public class IslandLevel { /** * @return Last calculated points of the Island */ - public long getLastCalculatedPoints() { + public double getLastCalculatedPoints() { return this.handle.getIsland().getLevel().getLastCalculatedPoints(); } diff --git a/src/main/java/com/songoda/skyblock/island/IslandLevel.java b/src/main/java/com/songoda/skyblock/island/IslandLevel.java index 16885cd8..8f174d9a 100644 --- a/src/main/java/com/songoda/skyblock/island/IslandLevel.java +++ b/src/main/java/com/songoda/skyblock/island/IslandLevel.java @@ -24,7 +24,7 @@ public class IslandLevel { private UUID ownerUUID; private long lastCalculatedLevel = 0; - private long lastCalculatedPoints = 0; + private double lastCalculatedPoints = 0; private Map materials; @@ -64,21 +64,21 @@ public class IslandLevel { this.ownerUUID = ownerUUID; } - public long getPoints() { + public double getPoints() { FileConfiguration configLoad = this.plugin.getLevelling(); ConfigurationSection materialSection = configLoad.getConfigurationSection("Materials"); if (materialSection == null) return 0; - long pointsEarned = 0; + double pointsEarned = 0; for (Entry entry : this.materials.entrySet()) { ConfigurationSection current = materialSection.getConfigurationSection(entry.getKey()); if (current == null) continue; - long pointsRequired = current.getLong("Points", 0); + double pointsRequired = current.getDouble("Points", 0); long blockAmount = entry.getValue(); long materialLimit = current.getLong("Limit", -1); @@ -135,7 +135,7 @@ public class IslandLevel { division = 1; } - long points = getPoints(); + double points = getPoints(); long subtract = this.plugin.getConfiguration().getLong("Island.Levelling.Subtract"); if(points >= subtract){ points -= subtract; @@ -143,7 +143,7 @@ public class IslandLevel { points = 0; } - return points / division; + return Math.round(points) / division; } public void checkLevelUp() { @@ -267,11 +267,11 @@ public class IslandLevel { this.materials = materials; } - public long getLastCalculatedPoints() { + public double getLastCalculatedPoints() { return this.lastCalculatedPoints; } - public void setLastCalculatedPoints(long lastCalculatedPoints) { + public void setLastCalculatedPoints(double lastCalculatedPoints) { this.lastCalculatedPoints = lastCalculatedPoints; } diff --git a/src/main/java/com/songoda/skyblock/levelling/calculator/CalculatorRegistry.java b/src/main/java/com/songoda/skyblock/levelling/calculator/CalculatorRegistry.java index dcc1ec47..154cb3d0 100644 --- a/src/main/java/com/songoda/skyblock/levelling/calculator/CalculatorRegistry.java +++ b/src/main/java/com/songoda/skyblock/levelling/calculator/CalculatorRegistry.java @@ -8,7 +8,7 @@ import java.util.List; import java.util.Map; public final class CalculatorRegistry { - + private static final Map> calculators = new HashMap<>(); public static void registerCalculator(Calculator calculator, CompatibleMaterial to) { diff --git a/src/main/java/com/songoda/skyblock/placeholder/PlaceholderProcessor.java b/src/main/java/com/songoda/skyblock/placeholder/PlaceholderProcessor.java index b2e6ad50..a7c45176 100644 --- a/src/main/java/com/songoda/skyblock/placeholder/PlaceholderProcessor.java +++ b/src/main/java/com/songoda/skyblock/placeholder/PlaceholderProcessor.java @@ -127,7 +127,7 @@ public class PlaceholderProcessor { } break; case "fabledskyblock_island_points": - returnValue = island == null ? "0" : Long.toString(island.getLevel().getPoints()); + returnValue = island == null ? "0" : Double.toString(island.getLevel().getPoints()); break; case "fabledskyblock_island_votes": if (island == null) {