mirror of
https://github.com/BentoBoxWorld/Limits.git
synced 2024-09-27 14:12:57 +02:00
parent
2b6377fee7
commit
8fa551ff7c
@ -107,7 +107,7 @@ public class LimitPanel {
|
|||||||
// Entity limits
|
// Entity limits
|
||||||
Map<EntityType, Integer> map = addon.getSettings().getLimits();
|
Map<EntityType, Integer> map = addon.getSettings().getLimits();
|
||||||
// Merge in any permission-based limits
|
// Merge in any permission-based limits
|
||||||
ibc.getEntityLimits().forEach(map::put);
|
if (ibc != null) ibc.getEntityLimits().forEach(map::put);
|
||||||
map.forEach((k,v) -> {
|
map.forEach((k,v) -> {
|
||||||
PanelItemBuilder pib = new PanelItemBuilder();
|
PanelItemBuilder pib = new PanelItemBuilder();
|
||||||
pib.name(Util.prettifyText(k.toString()));
|
pib.name(Util.prettifyText(k.toString()));
|
||||||
|
@ -36,6 +36,7 @@ import org.bukkit.event.block.LeavesDecayEvent;
|
|||||||
import org.bukkit.event.entity.EntityChangeBlockEvent;
|
import org.bukkit.event.entity.EntityChangeBlockEvent;
|
||||||
import org.bukkit.event.entity.EntityExplodeEvent;
|
import org.bukkit.event.entity.EntityExplodeEvent;
|
||||||
import org.bukkit.event.player.PlayerInteractEvent;
|
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.events.island.IslandEvent.IslandDeleteEvent;
|
||||||
import world.bentobox.bentobox.api.localization.TextVariables;
|
import world.bentobox.bentobox.api.localization.TextVariables;
|
||||||
@ -436,6 +437,7 @@ public class BlockLimitsListener implements Listener {
|
|||||||
* @param islandId - island unique id
|
* @param islandId - island unique id
|
||||||
* @return island block count or null if there is none yet
|
* @return island block count or null if there is none yet
|
||||||
*/
|
*/
|
||||||
|
@Nullable
|
||||||
public IslandBlockCount getIsland(String islandId) {
|
public IslandBlockCount getIsland(String islandId) {
|
||||||
return islandCountMap.get(islandId);
|
return islandCountMap.get(islandId);
|
||||||
}
|
}
|
||||||
|
@ -168,11 +168,15 @@ public class EntityLimitListener implements Listener {
|
|||||||
.filter(e -> e.getType().equals(ent.getType()))
|
.filter(e -> e.getType().equals(ent.getType()))
|
||||||
.filter(e -> island.inIslandSpace(e.getLocation())).count();
|
.filter(e -> island.inIslandSpace(e.getLocation())).count();
|
||||||
// Check island settings first
|
// 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 no island settings then try global settings
|
||||||
if (limitAmount < 0 && addon.getSettings().getLimits().containsKey(ent.getType())) {
|
if (limitAmount < 0 && addon.getSettings().getLimits().containsKey(ent.getType())) {
|
||||||
limitAmount = addon.getSettings().getLimits().get(ent.getType());
|
limitAmount = addon.getSettings().getLimits().get(ent.getType());
|
||||||
}
|
}
|
||||||
|
if (limitAmount == -1) return false;
|
||||||
return count >= limitAmount;
|
return count >= limitAmount;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user