mirror of
https://github.com/BentoBoxWorld/Limits.git
synced 2025-02-20 14:21:42 +01:00
Check for specific types and not classes
https://github.com/BentoBoxWorld/Limits/issues/105
This commit is contained in:
parent
d0e7ec0d68
commit
4f92611df0
@ -8,6 +8,7 @@ import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.Objects;
|
||||
import java.util.Optional;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.World;
|
||||
@ -15,7 +16,6 @@ import org.bukkit.entity.EntityType;
|
||||
import org.eclipse.jdt.annotation.Nullable;
|
||||
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import world.bentobox.bentobox.api.localization.TextVariables;
|
||||
import world.bentobox.bentobox.api.panels.PanelItem;
|
||||
@ -25,7 +25,6 @@ import world.bentobox.bentobox.api.user.User;
|
||||
import world.bentobox.bentobox.database.objects.Island;
|
||||
import world.bentobox.bentobox.util.Util;
|
||||
import world.bentobox.limits.Limits;
|
||||
import world.bentobox.limits.Settings;
|
||||
import world.bentobox.limits.Settings.EntityGroup;
|
||||
import world.bentobox.limits.objects.IslandBlockCount;
|
||||
|
||||
|
@ -435,7 +435,8 @@ public class EntityLimitListener implements Listener {
|
||||
// We have to count the entities
|
||||
if (limitAmount >= 0)
|
||||
{
|
||||
int count = (int) ent.getWorld().getEntitiesByClasses(ent.getClass()).stream()
|
||||
int count = (int) ent.getWorld().getEntities().stream()
|
||||
.filter(e -> e.getType().equals(ent.getType()))
|
||||
.filter(e -> island.inIslandSpace(e.getLocation()))
|
||||
.count();
|
||||
if (count >= limitAmount)
|
||||
|
@ -8,7 +8,7 @@ import static org.mockito.ArgumentMatchers.anyString;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
@ -48,7 +48,7 @@ public class EntityLimitListenerTest {
|
||||
private Settings settings;
|
||||
@Mock
|
||||
private World world;
|
||||
private Collection<Entity> collection;
|
||||
private List<Entity> collection;
|
||||
@Mock
|
||||
private Location location;
|
||||
private IslandBlockCount ibc;
|
||||
@ -81,7 +81,7 @@ public class EntityLimitListenerTest {
|
||||
collection.add(ent);
|
||||
collection.add(ent);
|
||||
collection.add(ent);
|
||||
when(world.getEntitiesByClasses(any())).thenReturn(collection);
|
||||
when(world.getEntities()).thenReturn(collection);
|
||||
|
||||
ell = new EntityLimitListener(addon);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user