From d212fcee9953b99147026e7082011a189f0c625e Mon Sep 17 00:00:00 2001 From: tastybento Date: Fri, 1 Oct 2021 17:40:07 -0700 Subject: [PATCH] Update to BentoBox API 1.18 --- pom.xml | 2 +- .../level/calculators/IslandLevelCalculator.java | 2 +- .../level/events/IslandLevelCalculatedEvent.java | 14 ++++++++++++++ .../bentobox/level/events/IslandPreLevelEvent.java | 13 +++++++++++++ src/main/resources/addon.yml | 2 +- 5 files changed, 30 insertions(+), 3 deletions(-) diff --git a/pom.xml b/pom.xml index 6e2936c..1a1d333 100644 --- a/pom.xml +++ b/pom.xml @@ -59,7 +59,7 @@ 2.0.9 1.17-R0.1-SNAPSHOT - 1.17.0 + 1.18.0-SNAPSHOT ${build.version}-SNAPSHOT diff --git a/src/main/java/world/bentobox/level/calculators/IslandLevelCalculator.java b/src/main/java/world/bentobox/level/calculators/IslandLevelCalculator.java index 5dd2523..7052077 100644 --- a/src/main/java/world/bentobox/level/calculators/IslandLevelCalculator.java +++ b/src/main/java/world/bentobox/level/calculators/IslandLevelCalculator.java @@ -203,7 +203,7 @@ public class IslandLevelCalculator { private long calculateLevel(long blockAndDeathPoints) { String calcString = addon.getSettings().getLevelCalc(); String withValues = calcString.replace("blocks", String.valueOf(blockAndDeathPoints)).replace("level_cost", String.valueOf(this.addon.getSettings().getLevelCost())); - return (long)eval(withValues) - this.island.getLevelHandicap() - (addon.getSettings().isZeroNewIslandLevels() ? results.initialLevel.get() : 0); + return (long)eval(withValues) - (addon.getSettings().isZeroNewIslandLevels() ? results.initialLevel.get() : 0); } /** diff --git a/src/main/java/world/bentobox/level/events/IslandLevelCalculatedEvent.java b/src/main/java/world/bentobox/level/events/IslandLevelCalculatedEvent.java index 8db2679..b59c6c5 100644 --- a/src/main/java/world/bentobox/level/events/IslandLevelCalculatedEvent.java +++ b/src/main/java/world/bentobox/level/events/IslandLevelCalculatedEvent.java @@ -3,6 +3,9 @@ package world.bentobox.level.events; import java.util.List; import java.util.UUID; +import org.bukkit.event.HandlerList; +import org.eclipse.jdt.annotation.NonNull; + import world.bentobox.bentobox.api.events.IslandBaseEvent; import world.bentobox.bentobox.database.objects.Island; import world.bentobox.level.calculators.Results; @@ -18,6 +21,17 @@ public class IslandLevelCalculatedEvent extends IslandBaseEvent { private UUID targetPlayer; + private static final HandlerList handlers = new HandlerList(); + + @Override + public @NonNull HandlerList getHandlers() { + return getHandlerList(); + } + + public static HandlerList getHandlerList() { + return handlers; + } + /** * @param targetPlayer - target player * @param island - island diff --git a/src/main/java/world/bentobox/level/events/IslandPreLevelEvent.java b/src/main/java/world/bentobox/level/events/IslandPreLevelEvent.java index 453ab58..0845233 100644 --- a/src/main/java/world/bentobox/level/events/IslandPreLevelEvent.java +++ b/src/main/java/world/bentobox/level/events/IslandPreLevelEvent.java @@ -2,6 +2,9 @@ package world.bentobox.level.events; import java.util.UUID; +import org.bukkit.event.HandlerList; +import org.eclipse.jdt.annotation.NonNull; + import world.bentobox.bentobox.api.events.IslandBaseEvent; import world.bentobox.bentobox.database.objects.Island; @@ -13,6 +16,16 @@ import world.bentobox.bentobox.database.objects.Island; public class IslandPreLevelEvent extends IslandBaseEvent { private final UUID targetPlayer; + private static final HandlerList handlers = new HandlerList(); + + @Override + public @NonNull HandlerList getHandlers() { + return getHandlerList(); + } + + public static HandlerList getHandlerList() { + return handlers; + } /** diff --git a/src/main/resources/addon.yml b/src/main/resources/addon.yml index 181fe2c..f669a12 100755 --- a/src/main/resources/addon.yml +++ b/src/main/resources/addon.yml @@ -2,7 +2,7 @@ name: Level main: world.bentobox.level.Level version: ${version}${build.number} icon: DIAMOND -api-version: 1.17 +api-version: 1.18 authors: tastybento