diff --git a/pom.xml b/pom.xml
index a4e976a..ebb3994 100644
--- a/pom.xml
+++ b/pom.xml
@@ -65,7 +65,7 @@
-LOCAL
- 2.3.0
+ 2.3.1
diff --git a/src/main/java/world/bentobox/level/LevelsManager.java b/src/main/java/world/bentobox/level/LevelsManager.java
index cac2994..a57a543 100644
--- a/src/main/java/world/bentobox/level/LevelsManager.java
+++ b/src/main/java/world/bentobox/level/LevelsManager.java
@@ -475,7 +475,6 @@ public class LevelsManager {
return ld.getLevel(world);
}
}
- addon.getPlugin().logDebug("Returning 0L");
return 0L;
}
diff --git a/src/main/java/world/bentobox/level/listeners/IslandActivitiesListeners.java b/src/main/java/world/bentobox/level/listeners/IslandActivitiesListeners.java
index f7a1c40..e68e91f 100644
--- a/src/main/java/world/bentobox/level/listeners/IslandActivitiesListeners.java
+++ b/src/main/java/world/bentobox/level/listeners/IslandActivitiesListeners.java
@@ -7,7 +7,6 @@ import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
-import world.bentobox.bentobox.BentoBox;
import world.bentobox.bentobox.api.events.island.IslandEvent.IslandCreatedEvent;
import world.bentobox.bentobox.api.events.island.IslandEvent.IslandPreclearEvent;
import world.bentobox.bentobox.api.events.island.IslandEvent.IslandRegisteredEvent;
@@ -39,20 +38,19 @@ public class IslandActivitiesListeners implements Listener {
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
public void onNewIsland(IslandCreatedEvent e) {
- BentoBox.getInstance().logDebug(e.getEventName());
+
zeroIsland(e.getIsland());
}
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
public void onNewIsland(IslandResettedEvent e) {
- BentoBox.getInstance().logDebug(e.getEventName());
+
zeroIsland(e.getIsland());
}
private void zeroIsland(final Island island) {
// Clear the island setting
if (island.getOwner() != null && island.getWorld() != null) {
- BentoBox.getInstance().logDebug("Zeroing island");
addon.getPipeliner().addIsland(island).thenAccept(results ->
addon.getManager().setInitialIslandLevel(island, results.getLevel()));
}
@@ -60,11 +58,10 @@ public class IslandActivitiesListeners implements Listener {
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onIslandDelete(IslandPreclearEvent e) {
- BentoBox.getInstance().logDebug(e.getEventName());
+
// Remove player from the top ten and level
UUID uuid = e.getIsland().getOwner();
World world = e.getIsland().getWorld();
- BentoBox.getInstance().logDebug(uuid + " " + world);
remove(world, uuid);
}
@@ -76,42 +73,42 @@ public class IslandActivitiesListeners implements Listener {
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
public void onNewIslandOwner(TeamSetownerEvent e) {
- BentoBox.getInstance().logDebug(e.getEventName());
+
// Remove player from the top ten and level
remove(e.getIsland().getWorld(), e.getIsland().getOwner());
}
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
public void onIsland(TeamJoinedEvent e) {
- BentoBox.getInstance().logDebug(e.getEventName());
+
// Remove player from the top ten and level
remove(e.getIsland().getWorld(), e.getPlayerUUID());
}
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
public void onIsland(IslandUnregisteredEvent e) {
- BentoBox.getInstance().logDebug(e.getEventName());
+
// Remove player from the top ten and level
remove(e.getIsland().getWorld(), e.getPlayerUUID());
}
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
public void onIsland(IslandRegisteredEvent e) {
- BentoBox.getInstance().logDebug(e.getEventName());
+
// Remove player from the top ten and level
remove(e.getIsland().getWorld(), e.getPlayerUUID());
}
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
public void onIsland(TeamLeaveEvent e) {
- BentoBox.getInstance().logDebug(e.getEventName());
+
// Remove player from the top ten and level
remove(e.getIsland().getWorld(), e.getPlayerUUID());
}
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
public void onIsland(TeamKickEvent e) {
- BentoBox.getInstance().logDebug(e.getEventName());
+
// Remove player from the top ten and level
remove(e.getIsland().getWorld(), e.getPlayerUUID());
}
diff --git a/src/main/java/world/bentobox/level/objects/LevelsData.java b/src/main/java/world/bentobox/level/objects/LevelsData.java
index dfdfe00..2c1f7e2 100644
--- a/src/main/java/world/bentobox/level/objects/LevelsData.java
+++ b/src/main/java/world/bentobox/level/objects/LevelsData.java
@@ -70,6 +70,14 @@ public class LevelsData implements DataObject {
mdCount = new HashMap<>();
}
+ private void initialize() {
+ if (levels == null) levels = new TreeMap<>(String.CASE_INSENSITIVE_ORDER);
+ if (initialLevel == null) initialLevel = new TreeMap<>(String.CASE_INSENSITIVE_ORDER);
+ if (pointsToNextLevel == null) pointsToNextLevel = new TreeMap<>(String.CASE_INSENSITIVE_ORDER);
+ if (uwCount == null) uwCount = new HashMap<>();
+ if (mdCount == null) mdCount = new HashMap<>();
+ }
+
/* (non-Javadoc)
* @see world.bentobox.bbox.database.objects.DataObject#getUniqueId()
*/
@@ -92,7 +100,7 @@ public class LevelsData implements DataObject {
* @return island level
*/
public Long getLevel(World world) {
- if (levels == null) levels = new TreeMap<>(String.CASE_INSENSITIVE_ORDER);
+ initialize();
return world == null ? 0L : levels.getOrDefault(world.getName(), 0L);
}
@@ -100,7 +108,7 @@ public class LevelsData implements DataObject {
* @return the levels
*/
public Map getLevels() {
- if (levels == null) levels = new TreeMap<>(String.CASE_INSENSITIVE_ORDER);
+ initialize();
return levels;
}
@@ -108,7 +116,7 @@ public class LevelsData implements DataObject {
* @param levels the levels to set
*/
public void setLevels(Map levels) {
- if (levels == null) levels = new TreeMap<>(String.CASE_INSENSITIVE_ORDER);
+ initialize();
this.levels = levels;
}
@@ -118,7 +126,7 @@ public class LevelsData implements DataObject {
* @param lv - level
*/
public void setLevel(World world, Long lv) {
- if (levels == null) levels = new TreeMap<>(String.CASE_INSENSITIVE_ORDER);
+ initialize();
String name = world.getName().toLowerCase(Locale.ENGLISH);
levels.put(name, lv - this.initialLevel.getOrDefault(name, 0L));
}
@@ -129,7 +137,7 @@ public class LevelsData implements DataObject {
* @param level - level
*/
public void setInitialLevel(World world, long level) {
- if (initialLevel == null) initialLevel = new TreeMap<>(String.CASE_INSENSITIVE_ORDER);
+ initialize();
this.initialLevel.put(world.getName().toLowerCase(Locale.ENGLISH), level);
}
@@ -137,7 +145,7 @@ public class LevelsData implements DataObject {
* @return the initialLevel
*/
public Map getInitialLevel() {
- if (initialLevel == null) initialLevel = new TreeMap<>(String.CASE_INSENSITIVE_ORDER);
+ initialize();
return initialLevel;
}
@@ -145,7 +153,7 @@ public class LevelsData implements DataObject {
* @param initialLevel the initialLevel to set
*/
public void setInitialLevel(Map initialLevel) {
- if (initialLevel == null) initialLevel = new TreeMap<>(String.CASE_INSENSITIVE_ORDER);
+ initialize();
this.initialLevel = initialLevel;
}
@@ -155,7 +163,7 @@ public class LevelsData implements DataObject {
* @return initial island level or 0 by default
*/
public long getInitialLevel(World world) {
- if (initialLevel == null) initialLevel = new TreeMap<>(String.CASE_INSENSITIVE_ORDER);
+ initialize();
return initialLevel.getOrDefault(world.getName().toLowerCase(Locale.ENGLISH), 0L);
}
@@ -164,6 +172,7 @@ public class LevelsData implements DataObject {
* @param world - world to remove
*/
public void remove(World world) {
+ initialize();
this.levels.remove(world.getName().toLowerCase(Locale.ENGLISH));
this.initialLevel.remove(world.getName().toLowerCase(Locale.ENGLISH));
this.pointsToNextLevel.remove(world.getName().toLowerCase(Locale.ENGLISH));
@@ -175,7 +184,7 @@ public class LevelsData implements DataObject {
* @return the pointsToNextLevel
*/
public Map getPointsToNextLevel() {
- if (pointsToNextLevel == null) pointsToNextLevel = new TreeMap<>(String.CASE_INSENSITIVE_ORDER);
+ initialize();
return pointsToNextLevel;
}
@@ -183,7 +192,7 @@ public class LevelsData implements DataObject {
* @param pointsToNextLevel the pointsToNextLevel to set
*/
public void setPointsToNextLevel(Map pointsToNextLevel) {
- if (pointsToNextLevel == null) pointsToNextLevel = new TreeMap<>(String.CASE_INSENSITIVE_ORDER);
+ initialize();
this.pointsToNextLevel = pointsToNextLevel;
}
@@ -194,7 +203,7 @@ public class LevelsData implements DataObject {
* @param points - points to next level
*/
public void setPointsToNextLevel(World world, Long points) {
- if (pointsToNextLevel == null) pointsToNextLevel = new TreeMap<>(String.CASE_INSENSITIVE_ORDER);
+ initialize();
pointsToNextLevel.put(world.getName().toLowerCase(Locale.ENGLISH), points);
}
@@ -205,7 +214,7 @@ public class LevelsData implements DataObject {
* @return points to next level or zero if unknown
*/
public long getPointsToNextLevel(World world) {
- if (pointsToNextLevel == null) pointsToNextLevel = new TreeMap<>(String.CASE_INSENSITIVE_ORDER);
+ initialize();
return pointsToNextLevel.getOrDefault(world.getName().toLowerCase(Locale.ENGLISH), 0L);
}
@@ -213,7 +222,7 @@ public class LevelsData implements DataObject {
* @param uwCount the uwCount to set
*/
public void setUwCount(World world, Multiset uwCount) {
- if (this.uwCount == null) this.uwCount = new HashMap<>();
+ initialize();
Map count = new EnumMap<>(Material.class);
uwCount.forEach(m -> count.put(m, uwCount.count(m)));
@@ -224,7 +233,7 @@ public class LevelsData implements DataObject {
* @param mdCount the mdCount to set
*/
public void setMdCount(World world, Multiset mdCount) {
- if (this.mdCount == null) this.mdCount = new HashMap<>();
+ initialize();
Map count = new EnumMap<>(Material.class);
mdCount.forEach(m -> count.put(m, mdCount.count(m)));
@@ -237,7 +246,7 @@ public class LevelsData implements DataObject {
* @return the uwCount
*/
public Map getUwCount(World world) {
- if (this.uwCount == null) this.uwCount = new HashMap<>();
+ initialize();
return uwCount.getOrDefault(world.getName(), Collections.emptyMap());
}
@@ -246,7 +255,7 @@ public class LevelsData implements DataObject {
* @return the mdCount
*/
public Map getMdCount(World world) {
- if (this.mdCount == null) this.mdCount = new HashMap<>();
+ initialize();
return mdCount.getOrDefault(world.getName(), Collections.emptyMap());
}