Fixed entities targetting other entities outside the border

This commit is contained in:
BuildTools 2019-09-22 00:18:19 -06:00
parent 1e1da915fe
commit 989778d114

View File

@ -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 @EventHandler
public void onStackableInteract(PlayerArmorStandManipulateEvent event) { public void onStackableInteract(PlayerArmorStandManipulateEvent event) {
Player player = event.getPlayer(); Player player = event.getPlayer();