Fix for level setting with different sized islands.

https://github.com/BentoBoxWorld/BentoBox/issues/709
This commit is contained in:
tastybento 2019-05-29 00:12:33 -07:00
parent 2ea430554f
commit 671e17398e

View File

@ -39,6 +39,8 @@ public class IslandTeamListeners implements Listener {
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
public void onNewIsland(IslandCreatedEvent e) {
// Clear the island setting
addon.setInitialIslandLevel(e.getIsland(), 0L);
if (e.getIsland().getOwner() != null && e.getIsland().getWorld() != null) {
cil.putIfAbsent(e.getIsland(), new CalcIslandLevel(addon, e.getIsland(), () -> zeroLevel(e.getIsland())));
}
@ -46,6 +48,8 @@ public class IslandTeamListeners implements Listener {
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
public void onNewIsland(IslandResettedEvent e) {
// Clear the island setting
addon.setInitialIslandLevel(e.getIsland(), 0L);
if (e.getIsland().getOwner() != null && e.getIsland().getWorld() != null) {
cil.putIfAbsent(e.getIsland(), new CalcIslandLevel(addon, e.getIsland(), () -> zeroLevel(e.getIsland())));
}
@ -95,7 +99,8 @@ public class IslandTeamListeners implements Listener {
private void zeroLevel(Island island) {
if (cil.containsKey(island)) {
addon.setInitialIslandLevel(island, cil.get(island).getResult().getLevel());
long level = cil.get(island).getResult().getLevel();
addon.setInitialIslandLevel(island, level);
cil.remove(island);
}
}