mirror of
https://github.com/BentoBoxWorld/Limits.git
synced 2024-09-27 06:02:44 +02: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
|
// We have to count the entities
|
||||||
if (limitAmount >= 0)
|
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 -> e.getType().equals(ent.getType()))
|
||||||
.filter(e -> island.inIslandSpace(e.getLocation()))
|
|
||||||
.count();
|
.count();
|
||||||
int max = limitAmount + (ibc == null ? 0 : ibc.getEntityLimitOffset(ent.getType()));
|
int max = limitAmount + (ibc == null ? 0 : ibc.getEntityLimitOffset(ent.getType()));
|
||||||
if (count >= max) {
|
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
|
for (Map.Entry<Settings.EntityGroup, Integer> group : groupsLimits.entrySet()) { //do not use lambda
|
||||||
if (group.getValue() < 0)
|
if (group.getValue() < 0)
|
||||||
continue;
|
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 -> 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()));
|
int max = group.getValue() + + (ibc == null ? 0 : ibc.getEntityGroupLimitOffset(group.getKey().getName()));
|
||||||
if (count >= max) {
|
if (count >= max) {
|
||||||
return new AtLimitResult(group.getKey(), max);
|
return new AtLimitResult(group.getKey(), max);
|
||||||
|
Loading…
Reference in New Issue
Block a user