Skip to content

Commit

Permalink
Fixes issue with entities not in config being limited.
Browse files Browse the repository at this point in the history
  • Loading branch information
tastybento committed Jun 27, 2019
1 parent 56f9a0e commit 789df98
Showing 1 changed file with 3 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ public void onBlock(HangingPlaceEvent e) {
e.setCancelled(true);
User.getInstance(player).sendMessage("limits.hit-limit", "[material]",
Util.prettifyText(e.getEntity().getType().toString()),
"[number]", String.valueOf(addon.getSettings().getLimits().get(e.getEntity().getType())));
"[number]", String.valueOf(addon.getSettings().getLimits().getOrDefault(e.getEntity().getType(), -1)));

}
});
Expand All @@ -141,7 +141,7 @@ private void checkLimit(CreatureSpawnEvent e, boolean bypass) {
// Not allowed
e.setCancelled(true);
// If the reason is anything but because of a spawner then tell players within range
if (!e.getSpawnReason().equals(SpawnReason.SPAWNER) && !e.getSpawnReason().equals(SpawnReason.NATURAL) && !e.getSpawnReason().equals(SpawnReason.INFECTION) && !e.getSpawnReason().equals(SpawnReason.NETHER_PORTAL) && !e.getSpawnReason().equals(SpawnReason.REINFORCEMENTS) && !e.getSpawnReason().equals(SpawnReason.SLIME_SPLIT)) {
if (!e.getSpawnReason().equals(SpawnReason.SPAWNER) && !e.getSpawnReason().equals(SpawnReason.NATURAL) && !e.getSpawnReason().equals(SpawnReason.INFECTION) && !e.getSpawnReason().equals(SpawnReason.NETHER_PORTAL) && !e.getSpawnReason().equals(SpawnReason.REINFORCEMENTS) && !e.getSpawnReason().equals(SpawnReason.SLIME_SPLIT)) {
for (Entity ent : e.getLocation().getWorld().getNearbyEntities(e.getLocation(), 5, 5, 5)) {
if (ent instanceof Player) {
User.getInstance(ent).sendMessage("entity-limits.hit-limit", "[entity]",
Expand All @@ -167,7 +167,7 @@ private boolean atLimit(Island island, boolean bypass, Entity ent) {
long count = ent.getWorld().getEntities().stream()
.filter(e -> e.getType().equals(ent.getType()))
.filter(e -> island.inIslandSpace(e.getLocation())).count();
return addon.getSettings().getLimits().getOrDefault(ent.getType(), -1) <= count;
return addon.getSettings().getLimits().containsKey(ent.getType()) && count >= addon.getSettings().getLimits().get(ent.getType());
}
}

Expand Down

0 comments on commit 789df98

Please sign in to comment.