use of org.bukkit.event.entity.EntityPortalEvent in project Glowstone by GlowstoneMC.
the class GlowEntity method teleportToSpawn.
/**
* Teleport this entity to the spawn point of the main world.
* This is used to teleport out of the End.
*
* @return {@code true} if the teleport was successful.
*/
protected boolean teleportToSpawn() {
Location target = server.getWorlds().get(0).getSpawnLocation();
EntityPortalEvent event = EventFactory.callEvent(new EntityPortalEvent(this, location.clone(), target, null));
if (event.isCancelled()) {
return false;
}
target = event.getTo();
teleport(target);
return true;
}
use of org.bukkit.event.entity.EntityPortalEvent in project Glowstone by GlowstoneMC.
the class GlowEntity method teleportToEnd.
/**
* Teleport this entity to the End.
* If no End world is loaded this does nothing.
*
* @return {@code true} if the teleport was successful.
*/
protected boolean teleportToEnd() {
if (!server.getAllowEnd()) {
return false;
}
Location target = null;
for (World world : server.getWorlds()) {
if (world.getEnvironment() == Environment.THE_END) {
target = world.getSpawnLocation();
break;
}
}
if (target == null) {
return false;
}
EntityPortalEvent event = EventFactory.callEvent(new EntityPortalEvent(this, location.clone(), target, null));
if (event.isCancelled()) {
return false;
}
target = event.getTo();
teleport(target);
return true;
}
Aggregations