Squashed commit of the following:

commit 91c78407cd
Author: Jesse Boyd <jessepaleg@gmail.com>
Date:   Sun Aug 7 11:29:59 2016 +1000

    Use a queue for expiry

commit 395d6364be
Author: Jesse Boyd <jessepaleg@gmail.com>
Date:   Sun Aug 7 04:43:41 2016 +1000

    Cache on fail as well

commit facd43700d
Author: Jesse Boyd <jessepaleg@gmail.com>
Date:   Sun Aug 7 04:00:50 2016 +1000

    Cache entity count every second

commit 1ae694ff5b
Author: Jesse Boyd <jessepaleg@gmail.com>
Date:   Sun Aug 7 03:52:37 2016 +1000

    Tweak entity counting

commit c99dd1e74a
Author: Jesse Boyd <jessepaleg@gmail.com>
Date:   Sat Aug 6 00:10:11 2016 +1000

    Needs sponge builds

commit f408ac82be
Author: Alexander Söderberg <Sauilitired@users.noreply.github.com>
Date:   Fri Aug 5 12:13:39 2016 +0200

    Update README.md

commit 9b95990ba6
Author: Alexander Söderberg <Sauilitired@users.noreply.github.com>
Date:   Thu Aug 4 16:50:37 2016 +0200

    Update this here as well
This commit is contained in:
MattBDev
2016-08-08 14:02:25 -04:00
parent 77fb329c9e
commit 112da17614
7 changed files with 66 additions and 19 deletions

View File

@ -22,6 +22,9 @@ public class EntitySpawnListener implements Listener {
return;
}
Plot plot = area.getOwnedPlotAbs(location);
if (Settings.Done.RESTRICT_BUILDING && plot.hasFlag(Flags.DONE)) {
event.setCancelled(true);
}
switch (entity.getType()) {
case ENDER_CRYSTAL:
if (plot == null) {
@ -34,8 +37,5 @@ public class EntitySpawnListener implements Listener {
event.setCancelled(true);
}
}
if (Settings.Done.RESTRICT_BUILDING && plot.hasFlag(Flags.DONE)) {
event.setCancelled(true);
}
}
}

View File

@ -1408,13 +1408,48 @@ public class PlayerEvents extends PlotListener implements Listener {
if (cap == Integer.MAX_VALUE) {
continue;
}
if (cap == 0) {
return true;
}
if (mobs == null) {
mobs = plot.countEntities();
}
if (mobs[i] >= cap) {
plot.setMeta("EntityCount", mobs);
plot.setMeta("EntityCountTime", System.currentTimeMillis());
return true;
}
}
if (mobs != null) {
for (IntegerFlag flag : flags) {
int i;
switch (flag.getName()) {
case "entity-cap":
i = 0;
break;
case "mob-cap":
i = 3;
break;
case "hostile-cap":
i = 2;
break;
case "animal-cap":
i = 1;
break;
case "vehicle-cap":
i = 4;
break;
case "misc-cap":
i = 5;
break;
default:
i = 0;
}
mobs[i]++;
}
plot.setMeta("EntityCount", mobs);
plot.setMeta("EntityCountTime", System.currentTimeMillis());
}
return false;
}

View File

@ -425,6 +425,10 @@ public class BukkitChunkManager extends ChunkManager {
@Override
public int[] countEntities(Plot plot) {
int[] existing = (int[]) plot.getMeta("EntityCount");
if (existing != null && (System.currentTimeMillis() - (long) plot.getMeta("EntityCountTime") < 1000)) {
return existing;
}
PlotArea area = plot.getArea();
World world = BukkitUtil.getWorld(area.worldname);
@ -449,9 +453,9 @@ public class BukkitChunkManager extends ChunkManager {
boolean doWhole = false;
List<Entity> entities = null;
if (size > 200) {
if (size > 200 && chunks.size() > 200) {
entities = world.getEntities();
if (entities.size() < 16 + size * size / 64) {
if (entities.size() < 16 + size / 8) {
doWhole = true;
}
}