mirror of
https://github.com/songoda/FabledSkyBlock.git
synced 2025-01-10 09:47:42 +01:00
Fixed entities targetting other entities outside the border
This commit is contained in:
parent
1e1da915fe
commit
989778d114
@ -248,6 +248,37 @@ public class Entity implements Listener {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks that an entity is not targeting another entity on different islands.
|
||||
* @author LimeGlass
|
||||
*/
|
||||
@EventHandler
|
||||
public void onEntityTarget(EntityTargetEvent event) {
|
||||
org.bukkit.entity.Entity entity = event.getEntity();
|
||||
WorldManager worldManager = skyblock.getWorldManager();
|
||||
if (!worldManager.isIslandWorld(entity.getWorld()))
|
||||
return;
|
||||
|
||||
org.bukkit.entity.Entity target = event.getTarget();
|
||||
|
||||
IslandManager islandManager = skyblock.getIslandManager();
|
||||
Island entityIsland = islandManager.getIslandAtLocation(entity.getLocation());
|
||||
Island targetIsland = islandManager.getIslandAtLocation(target.getLocation());
|
||||
// Event not related to Skyblock islands.
|
||||
if (entityIsland == null && targetIsland == null)
|
||||
return;
|
||||
// One entity is on an island, and the other isn't.
|
||||
if (entityIsland == null || targetIsland == null) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
// Both entities are on different islands.
|
||||
if (!entityIsland.getIslandUUID().equals(targetIsland.getIslandUUID())) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onStackableInteract(PlayerArmorStandManipulateEvent event) {
|
||||
Player player = event.getPlayer();
|
||||
|
Loading…
Reference in New Issue
Block a user