diff --git a/pom.xml b/pom.xml index a6ed8b8..16b2344 100644 --- a/pom.xml +++ b/pom.xml @@ -53,12 +53,12 @@ UTF-8 UTF-8 - 16 + 17 2.0.9 - 1.16.5-R0.1-SNAPSHOT - 1.18.0-SNAPSHOT + 1.19.4-R0.1-SNAPSHOT + 1.23.0 ${build.version}-SNAPSHOT @@ -206,7 +206,7 @@ maven-resources-plugin 3.1.0 - + org.apache.maven.plugins maven-surefire-plugin 3.0.0-M5 @@ -217,19 +217,29 @@ --add-opens java.base/java.math=ALL-UNNAMED --add-opens java.base/java.io=ALL-UNNAMED --add-opens java.base/java.util=ALL-UNNAMED - --add-opens java.base/java.util.stream=ALL-UNNAMED + --add-opens + java.base/java.util.stream=ALL-UNNAMED --add-opens java.base/java.text=ALL-UNNAMED - --add-opens java.base/java.util.regex=ALL-UNNAMED - --add-opens java.base/java.nio.channels.spi=ALL-UNNAMED + --add-opens + java.base/java.util.regex=ALL-UNNAMED + --add-opens + java.base/java.nio.channels.spi=ALL-UNNAMED --add-opens java.base/sun.nio.ch=ALL-UNNAMED --add-opens java.base/java.net=ALL-UNNAMED - --add-opens java.base/java.util.concurrent=ALL-UNNAMED + --add-opens + java.base/java.util.concurrent=ALL-UNNAMED --add-opens java.base/sun.nio.fs=ALL-UNNAMED --add-opens java.base/sun.nio.cs=ALL-UNNAMED --add-opens java.base/java.nio.file=ALL-UNNAMED - --add-opens java.base/java.nio.charset=ALL-UNNAMED - --add-opens java.base/java.lang.reflect=ALL-UNNAMED - --add-opens java.logging/java.util.logging=ALL-UNNAMED + --add-opens + java.base/java.nio.charset=ALL-UNNAMED + --add-opens + java.base/java.lang.reflect=ALL-UNNAMED + --add-opens + java.logging/java.util.logging=ALL-UNNAMED + --add-opens java.base/java.lang.ref=ALL-UNNAMED + --add-opens java.base/java.util.jar=ALL-UNNAMED + --add-opens java.base/java.util.zip=ALL-UNNAMED @@ -251,7 +261,7 @@ org.jacoco jacoco-maven-plugin - 0.8.3 + 0.8.7 true @@ -262,16 +272,21 @@ - pre-unit-test + prepare-agent prepare-agent - post-unit-test + report report + + + XML + + diff --git a/src/main/java/world/bentobox/limits/listeners/EntityLimitListener.java b/src/main/java/world/bentobox/limits/listeners/EntityLimitListener.java index 9bf49aa..3f3cf3e 100644 --- a/src/main/java/world/bentobox/limits/listeners/EntityLimitListener.java +++ b/src/main/java/world/bentobox/limits/listeners/EntityLimitListener.java @@ -403,10 +403,6 @@ public class EntityLimitListener implements Listener { // We have to count the entities if (limitAmount >= 0) { -// int count = (int) ent.getWorld().getEntities().stream() -// .filter(e -> e.getType().equals(ent.getType())) -// .filter(e -> island.inIslandSpace(e.getLocation())) -// .count(); int count = (int) ent.getWorld().getNearbyEntities(island.getBoundingBox()).stream() .filter(e -> e.getType().equals(ent.getType())) .count(); @@ -427,9 +423,9 @@ public class EntityLimitListener implements Listener { for (Map.Entry group : groupsLimits.entrySet()) { //do not use lambda if (group.getValue() < 0) continue; -// int count = (int) ent.getWorld().getEntities().stream() -// .filter(e -> group.getKey().contains(e.getType())) -// .filter(e -> island.inIslandSpace(e.getLocation())).count(); + // int count = (int) ent.getWorld().getEntities().stream() + // .filter(e -> group.getKey().contains(e.getType())) + // .filter(e -> island.inIslandSpace(e.getLocation())).count(); int count = (int) ent.getWorld().getNearbyEntities(island.getBoundingBox()).stream() .filter(e -> group.getKey().contains(e.getType())) .count(); diff --git a/src/main/java/world/bentobox/limits/listeners/JoinListener.java b/src/main/java/world/bentobox/limits/listeners/JoinListener.java index 1e0830e..388e52e 100644 --- a/src/main/java/world/bentobox/limits/listeners/JoinListener.java +++ b/src/main/java/world/bentobox/limits/listeners/JoinListener.java @@ -5,7 +5,6 @@ import java.util.Locale; import java.util.Objects; import java.util.UUID; -import org.apache.commons.lang.math.NumberUtils; import org.bukkit.Bukkit; import org.bukkit.Material; import org.bukkit.OfflinePlayer; @@ -118,11 +117,12 @@ public class JoinListener implements Listener { return true; } // Check value - if (!NumberUtils.isDigits(split[4])) { - logError(name, perms.getPermission(), "the last part MUST be a number!"); + try { + Integer.parseInt(split[4]); + } catch(Exception e) { + logError(name, perms.getPermission(), "the last part MUST be an integer!"); return true; } - return false; } diff --git a/src/test/java/bentobox/addon/limits/listeners/JoinListenerTest.java b/src/test/java/bentobox/addon/limits/listeners/JoinListenerTest.java index 109d1b1..a655d2f 100644 --- a/src/test/java/bentobox/addon/limits/listeners/JoinListenerTest.java +++ b/src/test/java/bentobox/addon/limits/listeners/JoinListenerTest.java @@ -298,7 +298,7 @@ public class JoinListenerTest { when(player.getEffectivePermissions()).thenReturn(perms); PlayerJoinEvent e = new PlayerJoinEvent(player, "welcome"); jl.onPlayerJoin(e); - verify(addon).logError("Player tastybento has permission: 'bskyblock.island.limit.STONE.abc' but the last part MUST be a number! Ignoring..."); + verify(addon).logError("Player tastybento has permission: 'bskyblock.island.limit.STONE.abc' but the last part MUST be an integer! Ignoring..."); } /** diff --git a/src/test/java/world/bentobox/limits/listeners/EntityLimitListenerTest.java b/src/test/java/world/bentobox/limits/listeners/EntityLimitListenerTest.java index a5e6da4..2e3c3c2 100644 --- a/src/test/java/world/bentobox/limits/listeners/EntityLimitListenerTest.java +++ b/src/test/java/world/bentobox/limits/listeners/EntityLimitListenerTest.java @@ -19,6 +19,7 @@ import org.bukkit.configuration.file.YamlConfiguration; import org.bukkit.entity.Entity; import org.bukkit.entity.EntityType; import org.bukkit.entity.LivingEntity; +import org.bukkit.util.BoundingBox; import org.junit.After; import org.junit.Before; import org.junit.Test; @@ -80,15 +81,11 @@ public class EntityLimitListenerTest { collection.add(ent); collection.add(ent); collection.add(ent); - when(world.getEntities()).thenReturn(collection); + when(world.getNearbyEntities(any())).thenReturn(collection); ell = new EntityLimitListener(addon); } - @After - public void tearDown() { - } - /** * Test for {@link EntityLimitListener#atLimit(Island, Entity)} */