mirror of
https://github.com/BentoBoxWorld/Limits.git
synced 2024-09-27 14:12:57 +02:00
Removed code smells.
This commit is contained in:
parent
088f853f0a
commit
989143d218
@ -113,7 +113,6 @@ public class EntityLimitListener implements Listener {
|
|||||||
// Other natural reasons
|
// Other natural reasons
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
// BentoBox.getInstance().logDebug("Bypass check took " + getTime(timer));
|
|
||||||
// Tag the entity with the island spawn location
|
// Tag the entity with the island spawn location
|
||||||
checkLimit(e, bypass);
|
checkLimit(e, bypass);
|
||||||
}
|
}
|
||||||
@ -160,25 +159,22 @@ public class EntityLimitListener implements Listener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void checkLimit(CreatureSpawnEvent e, boolean bypass) {
|
private void checkLimit(CreatureSpawnEvent e, boolean bypass) {
|
||||||
Bukkit.getScheduler().runTaskAsynchronously(BentoBox.getInstance(), () -> {
|
Bukkit.getScheduler().runTaskAsynchronously(BentoBox.getInstance(), () ->
|
||||||
addon.getIslands().getIslandAt(e.getLocation()).ifPresent(island -> {
|
addon.getIslands().getIslandAt(e.getLocation()).ifPresent(island -> {
|
||||||
// Check if creature is allowed to spawn or not
|
// Check if creature is allowed to spawn or not
|
||||||
AtLimitResult res;
|
AtLimitResult res;
|
||||||
if (!bypass && !island.isSpawn() && (res = atLimit(island, e.getEntity())).hit()) {
|
if (!bypass && !island.isSpawn() && (res = atLimit(island, e.getEntity())).hit()) {
|
||||||
//// BentoBox.getInstance().logDebug("Entity limit hit");
|
// Not allowed
|
||||||
// Not allowed
|
Bukkit.getScheduler().runTask(BentoBox.getInstance(), () -> {
|
||||||
Bukkit.getScheduler().runTask(BentoBox.getInstance(), () -> {
|
e.getEntity().remove();
|
||||||
e.getEntity().remove();
|
// If the entity was build, drop the building materials
|
||||||
// If the entity was build, drop the building materials
|
Bukkit.getScheduler().runTask(addon.getPlugin(), () -> replaceEntity(e));
|
||||||
Bukkit.getScheduler().runTask(addon.getPlugin(), () -> replaceEntity(e));
|
// If the reason is anything but because of a spawner then tell players within range
|
||||||
// If the reason is anything but because of a spawner then tell players within range
|
tellPlayers(e, res);
|
||||||
tellPlayers(e, res);
|
});
|
||||||
});
|
}
|
||||||
}
|
|
||||||
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
private void replaceEntity(CreatureSpawnEvent e) {
|
private void replaceEntity(CreatureSpawnEvent e) {
|
||||||
|
Loading…
Reference in New Issue
Block a user