From 4bac2282c81f58e230ba423fa4b7dcd1c9edcf47 Mon Sep 17 00:00:00 2001 From: WolfDW Date: Thu, 25 Jun 2020 02:44:08 +0000 Subject: [PATCH] Added island score block limits. --- .../songoda/skyblock/island/IslandLevel.java | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/songoda/skyblock/island/IslandLevel.java b/src/main/java/com/songoda/skyblock/island/IslandLevel.java index be1825f3..9d3d9784 100644 --- a/src/main/java/com/songoda/skyblock/island/IslandLevel.java +++ b/src/main/java/com/songoda/skyblock/island/IslandLevel.java @@ -78,8 +78,15 @@ public class IslandLevel { if (current == null) continue; long pointsRequired = current.getLong("Points", 0); + long blockAmount = entry.getValue(); - if (pointsRequired != 0) pointsEarned = pointsEarned + (entry.getValue() * pointsRequired); + long materialLimit = current.getLong("Limit", -1); + long materialAmountCounted = Math.min(materialLimit, blockAmount); + + if (materialLimit == -1) + materialAmountCounted = blockAmount; + + if (pointsRequired != 0) pointsEarned = pointsEarned + (materialAmountCounted * pointsRequired); } @@ -99,12 +106,17 @@ public class IslandLevel { if (current == null) return 0; Long boxedAmount = this.materials.get(material); - if (boxedAmount == null) return 0; + long materialLimit = current.getLong("Limit", -1); + long materialAmountCounted = Math.min(materialLimit, boxedAmount); + + if (materialLimit == -1) + materialAmountCounted = boxedAmount; + long pointsRequired = current.getLong("Points"); - return pointsRequired == 0 ? 0 : boxedAmount * pointsRequired; + return pointsRequired == 0 ? 0 : materialAmountCounted * pointsRequired; } public long getLevel() {