Skip to content

Commit

Permalink
Bug fixes
Browse files Browse the repository at this point in the history
Fixes #62
  • Loading branch information
tastybento committed Jan 11, 2020
1 parent 2b6377f commit 8fa551f
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ public void showLimits(World world, User user, UUID target) {
// Entity limits
Map<EntityType, Integer> map = addon.getSettings().getLimits();
// Merge in any permission-based limits
ibc.getEntityLimits().forEach(map::put);
if (ibc != null) ibc.getEntityLimits().forEach(map::put);
map.forEach((k,v) -> {
PanelItemBuilder pib = new PanelItemBuilder();
pib.name(Util.prettifyText(k.toString()));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
import org.bukkit.event.entity.EntityChangeBlockEvent;
import org.bukkit.event.entity.EntityExplodeEvent;
import org.bukkit.event.player.PlayerInteractEvent;
import org.eclipse.jdt.annotation.Nullable;

import world.bentobox.bentobox.api.events.island.IslandEvent.IslandDeleteEvent;
import world.bentobox.bentobox.api.localization.TextVariables;
Expand Down Expand Up @@ -436,6 +437,7 @@ public void setIsland(String islandId, IslandBlockCount ibc) {
* @param islandId - island unique id
* @return island block count or null if there is none yet
*/
@Nullable
public IslandBlockCount getIsland(String islandId) {
return islandCountMap.get(islandId);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -168,11 +168,15 @@ private boolean atLimit(Island island, Entity ent) {
.filter(e -> e.getType().equals(ent.getType()))
.filter(e -> island.inIslandSpace(e.getLocation())).count();
// Check island settings first
int limitAmount = addon.getBlockLimitListener().getIsland(island.getUniqueId()).getEntityLimit(ent.getType());
int limitAmount = -1;
if (addon.getBlockLimitListener().getIsland(island.getUniqueId()) != null) {
limitAmount = addon.getBlockLimitListener().getIsland(island.getUniqueId()).getEntityLimit(ent.getType());
}
// If no island settings then try global settings
if (limitAmount < 0 && addon.getSettings().getLimits().containsKey(ent.getType())) {
limitAmount = addon.getSettings().getLimits().get(ent.getType());
}
if (limitAmount == -1) return false;
return count >= limitAmount;
}
}
Expand Down

0 comments on commit 8fa551f

Please sign in to comment.