mirror of
https://github.com/BentoBoxWorld/Limits.git
synced 2024-09-26 13:42:54 +02:00
Fixed bugs with adding entity perm limits.
https://github.com/BentoBoxWorld/Limits/issues/47
This commit is contained in:
parent
fb6f6757d5
commit
789b73d3b3
@ -105,7 +105,10 @@ public class LimitPanel {
|
|||||||
pb.item(pib.build());
|
pb.item(pib.build());
|
||||||
}
|
}
|
||||||
// Entity limits
|
// Entity limits
|
||||||
addon.getSettings().getLimits().forEach((k,v) -> {
|
Map<EntityType, Integer> map = addon.getSettings().getLimits();
|
||||||
|
// Merge in any permission-based limits
|
||||||
|
ibc.getEntityLimits().forEach(map::put);
|
||||||
|
map.forEach((k,v) -> {
|
||||||
PanelItemBuilder pib = new PanelItemBuilder();
|
PanelItemBuilder pib = new PanelItemBuilder();
|
||||||
pib.name(Util.prettifyText(k.toString()));
|
pib.name(Util.prettifyText(k.toString()));
|
||||||
Material m;
|
Material m;
|
||||||
|
@ -42,32 +42,30 @@ public class EntityLimitListener implements Listener {
|
|||||||
if (!addon.getPlugin().getIWM().inWorld(e.getVehicle().getWorld())) {
|
if (!addon.getPlugin().getIWM().inWorld(e.getVehicle().getWorld())) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (addon.getSettings().getLimits().containsKey(e.getVehicle().getType())) {
|
// If someone in that area has the bypass permission, allow the spawning
|
||||||
// If someone in that area has the bypass permission, allow the spawning
|
for (Entity entity : Objects.requireNonNull(e.getVehicle().getLocation().getWorld()).getNearbyEntities(e.getVehicle().getLocation(), 5, 5, 5)) {
|
||||||
for (Entity entity : Objects.requireNonNull(e.getVehicle().getLocation().getWorld()).getNearbyEntities(e.getVehicle().getLocation(), 5, 5, 5)) {
|
if (entity instanceof Player) {
|
||||||
if (entity instanceof Player) {
|
Player player = (Player)entity;
|
||||||
Player player = (Player)entity;
|
boolean bypass = (player.isOp() || player.hasPermission(addon.getPlugin().getIWM().getPermissionPrefix(e.getVehicle().getWorld()) + MOD_BYPASS));
|
||||||
boolean bypass = (player.isOp() || player.hasPermission(addon.getPlugin().getIWM().getPermissionPrefix(e.getVehicle().getWorld()) + MOD_BYPASS));
|
// Check island
|
||||||
// Check island
|
addon.getIslands().getProtectedIslandAt(e.getVehicle().getLocation()).ifPresent(island -> {
|
||||||
addon.getIslands().getProtectedIslandAt(e.getVehicle().getLocation()).ifPresent(island -> {
|
// Ignore spawn
|
||||||
// Ignore spawn
|
if (island.isSpawn()) {
|
||||||
if (island.isSpawn()) {
|
return;
|
||||||
return;
|
}
|
||||||
}
|
// Check if the player is at the limit
|
||||||
// Check if the player is at the limit
|
if (!bypass && atLimit(island, e.getVehicle())) {
|
||||||
if (!bypass && atLimit(island, e.getVehicle())) {
|
e.setCancelled(true);
|
||||||
e.setCancelled(true);
|
for (Entity ent : e.getVehicle().getLocation().getWorld().getNearbyEntities(e.getVehicle().getLocation(), 5, 5, 5)) {
|
||||||
for (Entity ent : e.getVehicle().getLocation().getWorld().getNearbyEntities(e.getVehicle().getLocation(), 5, 5, 5)) {
|
if (ent instanceof Player) {
|
||||||
if (ent instanceof Player) {
|
((Player) ent).updateInventory();
|
||||||
((Player) ent).updateInventory();
|
User.getInstance(ent).sendMessage("entity-limits.hit-limit", "[entity]",
|
||||||
User.getInstance(ent).sendMessage("entity-limits.hit-limit", "[entity]",
|
Util.prettifyText(e.getVehicle().getType().toString())
|
||||||
Util.prettifyText(e.getVehicle().getType().toString())
|
, TextVariables.NUMBER, String.valueOf(addon.getSettings().getLimits().get(e.getVehicle().getType())));
|
||||||
, TextVariables.NUMBER, String.valueOf(addon.getSettings().getLimits().get(e.getVehicle().getType())));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
}
|
||||||
}
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -78,10 +76,6 @@ public class EntityLimitListener implements Listener {
|
|||||||
if (!addon.getPlugin().getIWM().inWorld(e.getLocation())) {
|
if (!addon.getPlugin().getIWM().inWorld(e.getLocation())) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!addon.getSettings().getLimits().containsKey(e.getEntityType())) {
|
|
||||||
// Unknown entity limit or unlimited
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
boolean bypass = false;
|
boolean bypass = false;
|
||||||
// Check why it was spawned
|
// Check why it was spawned
|
||||||
switch (e.getSpawnReason()) {
|
switch (e.getSpawnReason()) {
|
||||||
|
Loading…
Reference in New Issue
Block a user