mirror of
https://github.com/BentoBoxWorld/Limits.git
synced 2024-09-27 14:12:57 +02:00
Avoids counting entities if the type spawned is not limited.
https://github.com/BentoBoxWorld/Limits/issues/74
This commit is contained in:
parent
55bb288dad
commit
4cb061d594
2
pom.xml
2
pom.xml
@ -64,7 +64,7 @@
|
||||
<!-- Do not change unless you want different name for local builds. -->
|
||||
<build.number>-LOCAL</build.number>
|
||||
<!-- This allows to change between versions. -->
|
||||
<build.version>1.9.2</build.version>
|
||||
<build.version>1.9.3</build.version>
|
||||
</properties>
|
||||
|
||||
<!-- Profiles will allow to automatically change build version. -->
|
||||
|
@ -164,9 +164,6 @@ public class EntityLimitListener implements Listener {
|
||||
* @return true if at the limit, false if not
|
||||
*/
|
||||
private boolean atLimit(Island island, Entity ent) {
|
||||
long count = ent.getWorld().getEntities().stream()
|
||||
.filter(e -> e.getType().equals(ent.getType()))
|
||||
.filter(e -> island.inIslandSpace(e.getLocation())).count();
|
||||
// Check island settings first
|
||||
int limitAmount = -1;
|
||||
if (addon.getBlockLimitListener().getIsland(island.getUniqueId()) != null) {
|
||||
@ -176,8 +173,11 @@ public class EntityLimitListener implements Listener {
|
||||
if (limitAmount < 0 && addon.getSettings().getLimits().containsKey(ent.getType())) {
|
||||
limitAmount = addon.getSettings().getLimits().get(ent.getType());
|
||||
}
|
||||
if (limitAmount == -1) return false;
|
||||
return count >= limitAmount;
|
||||
if (limitAmount < 0) return false;
|
||||
// We have to count the entities
|
||||
return ent.getWorld().getEntities().stream()
|
||||
.filter(e -> e.getType().equals(ent.getType()))
|
||||
.filter(e -> island.inIslandSpace(e.getLocation())).count() >= limitAmount;
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user