From 395d6364be702558c3c30cbe0273d7e466a41507 Mon Sep 17 00:00:00 2001 From: Jesse Boyd Date: Sun, 7 Aug 2016 04:43:41 +1000 Subject: [PATCH] Cache on fail as well --- .../bukkit/listeners/PlayerEvents.java | 31 +++++++++++++++++-- 1 file changed, 29 insertions(+), 2 deletions(-) diff --git a/Bukkit/src/main/java/com/plotsquared/bukkit/listeners/PlayerEvents.java b/Bukkit/src/main/java/com/plotsquared/bukkit/listeners/PlayerEvents.java index bd81c5b01..99eb2cf84 100644 --- a/Bukkit/src/main/java/com/plotsquared/bukkit/listeners/PlayerEvents.java +++ b/Bukkit/src/main/java/com/plotsquared/bukkit/listeners/PlayerEvents.java @@ -1414,15 +1414,42 @@ public class PlayerEvents extends PlotListener implements Listener { if (mobs == null) { mobs = plot.countEntities(); } - if (mobs[i]++ >= cap) { + if (mobs[i] >= cap) { + plot.setMeta("EntityCount", mobs); + plot.setMeta("EntityCountTime", System.currentTimeMillis()); return true; } } + 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]++; + } if (mobs != null) { plot.setMeta("EntityCount", mobs); plot.setMeta("EntityCountTime", System.currentTimeMillis()); } - return false; }