Package org.bukkit.event.entity

Examples of org.bukkit.event.entity.EntityPortalEvent


     * @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;
    }
View Full Code Here


        }
        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;
    }
View Full Code Here

    }
  }

  public void handlePortalEnterNextTick(Player player, Location from) {
    // Handle teleportation the next tick
    final EntityPortalEvent portalEvent = new EntityPortalEvent(player, from, null, null);
    CommonUtil.nextTick(new Runnable() {
      public void run() {
        handlePortalEnter(portalEvent, false);
        if (portalEvent.getTo() != null && !portalEvent.isCancelled()) {
          // Use a travel agent if needed
          Location to = portalEvent.getTo();
          if (portalEvent.useTravelAgent()) {
            to = WorldUtil.findSpawnLocation(to);
          }
          // This tends to happen with Bukkit logic...haha
          if (to == null) {
            return;
          }

          // Note: We could use EntityUtil.teleport here...
          // But why even bother, we would only add strange differences between teleports
          portalEvent.getEntity().teleport(to);
        }
      }
    });
  }
View Full Code Here

  public void onPlayerPortal(PlayerPortalEvent event) {
    if (!MyWorlds.enablePortals) {
      return;
    }
    // Wrap inside an Entity portal event
    EntityPortalEvent entityEvent = new EntityPortalEvent(event.getPlayer(), event.getFrom(), event.getTo(), event.getPortalTravelAgent());
    entityEvent.useTravelAgent(event.useTravelAgent());
    handlePortalEnter(entityEvent, true);
    // Now, apply them again
    event.setTo(entityEvent.getTo());
    event.useTravelAgent(entityEvent.useTravelAgent());
    event.setCancelled(entityEvent.isCancelled());

    // For ender portals we NEED to teleport away from the end world
    // Not doing so results in the player getting glitched
    // Yes, this is another thing Bukkit needs to fix...
    World fromWorld = event.getFrom().getWorld();
View Full Code Here

TOP

Related Classes of org.bukkit.event.entity.EntityPortalEvent

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.