From a6594687754ee156c4aef51e5c156463276dbc60 Mon Sep 17 00:00:00 2001 From: Indyuce Date: Sun, 24 Jul 2022 21:25:26 +0200 Subject: [PATCH] Fixed period of 0 for exp items --- .../experience/droptable/ExperienceItem.java | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/main/java/net/Indyuce/mmocore/experience/droptable/ExperienceItem.java b/src/main/java/net/Indyuce/mmocore/experience/droptable/ExperienceItem.java index e9a6035a..27045351 100644 --- a/src/main/java/net/Indyuce/mmocore/experience/droptable/ExperienceItem.java +++ b/src/main/java/net/Indyuce/mmocore/experience/droptable/ExperienceItem.java @@ -55,9 +55,7 @@ public class ExperienceItem { Validate.isTrue(config.contains("triggers")); id = config.getName(); - final int periodOption = config.getInt("period", 1); - // A period of 0 means the item will only trigger once - period = periodOption == 0 ? Integer.MAX_VALUE : periodOption; + period = config.getInt("period", 1); firstTrigger = config.getInt("first-trigger", period); lastTrigger = config.getInt("last-trigger", Integer.MAX_VALUE); claimChance = config.getDouble("chance", 100) / 100; @@ -79,10 +77,17 @@ public class ExperienceItem { * account the randomness factor from the 'chance' parameter */ public boolean roll(int professionLevel, int timesCollected) { + + // Check for the last triggering level if (professionLevel > lastTrigger) return false; - int claimsRequired = (professionLevel + 1 - (firstTrigger + timesCollected * period)); + // A period of 0 means the item only triggers once + if (period == 0 && timesCollected > 0) + return false; + + // Basic formula + final int claimsRequired = (professionLevel + 1 - (firstTrigger + timesCollected * period)); if (claimsRequired < 1) return false;