mirror of
https://github.com/BentoBoxWorld/Limits.git
synced 2025-02-16 20:31:22 +01:00
huge performance boost for entity limit
This commit is contained in:
parent
f726492eae
commit
97006d28c1
@ -403,9 +403,12 @@ public class EntityLimitListener implements Listener {
|
||||
// We have to count the entities
|
||||
if (limitAmount >= 0)
|
||||
{
|
||||
int count = (int) ent.getWorld().getEntities().stream()
|
||||
// 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()))
|
||||
.filter(e -> island.inIslandSpace(e.getLocation()))
|
||||
.count();
|
||||
int max = limitAmount + (ibc == null ? 0 : ibc.getEntityLimitOffset(ent.getType()));
|
||||
if (count >= max) {
|
||||
@ -424,9 +427,12 @@ 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()
|
||||
// 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()))
|
||||
.filter(e -> island.inIslandSpace(e.getLocation())).count();
|
||||
.count();
|
||||
int max = group.getValue() + + (ibc == null ? 0 : ibc.getEntityGroupLimitOffset(group.getKey().getName()));
|
||||
if (count >= max) {
|
||||
return new AtLimitResult(group.getKey(), max);
|
||||
|
Loading…
Reference in New Issue
Block a user