mirror of
https://github.com/BentoBoxWorld/Limits.git
synced 2024-11-22 02:25:43 +01:00
Fix tests. Use world#nearbyEntities method.
This commit is contained in:
parent
eeafa239c4
commit
6b770d083e
41
pom.xml
41
pom.xml
@ -53,12 +53,12 @@
|
||||
<properties>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
|
||||
<java.version>16</java.version>
|
||||
<java.version>17</java.version>
|
||||
<!-- Non-minecraft related dependencies -->
|
||||
<powermock.version>2.0.9</powermock.version>
|
||||
<!-- More visible way how to change dependency versions -->
|
||||
<spigot.version>1.19.4-R0.1-SNAPSHOT</spigot.version>
|
||||
<bentobox.version>1.23.0-SNAPSHOT</bentobox.version>
|
||||
<bentobox.version>1.23.0</bentobox.version>
|
||||
<!-- Revision variable removes warning about dynamic version -->
|
||||
<revision>${build.version}-SNAPSHOT</revision>
|
||||
<!-- Do not change unless you want different name for local builds. -->
|
||||
@ -196,7 +196,7 @@
|
||||
<artifactId>maven-resources-plugin</artifactId>
|
||||
<version>3.1.0</version>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-surefire-plugin</artifactId>
|
||||
<version>3.0.0-M5</version>
|
||||
@ -207,19 +207,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
|
||||
</argLine>
|
||||
</configuration>
|
||||
</plugin>
|
||||
@ -241,7 +251,7 @@
|
||||
<plugin>
|
||||
<groupId>org.jacoco</groupId>
|
||||
<artifactId>jacoco-maven-plugin</artifactId>
|
||||
<version>0.8.3</version>
|
||||
<version>0.8.7</version>
|
||||
<configuration>
|
||||
<append>true</append>
|
||||
<excludes>
|
||||
@ -252,16 +262,21 @@
|
||||
</configuration>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>pre-unit-test</id>
|
||||
<id>prepare-agent</id>
|
||||
<goals>
|
||||
<goal>prepare-agent</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
<execution>
|
||||
<id>post-unit-test</id>
|
||||
<id>report</id>
|
||||
<goals>
|
||||
<goal>report</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<formats>
|
||||
<format>XML</format>
|
||||
</formats>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
|
@ -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<Settings.EntityGroup, Integer> 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();
|
||||
|
@ -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...");
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -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)}
|
||||
*/
|
||||
|
Loading…
Reference in New Issue
Block a user