Ejemplo n.º 1
0
  /**
   * Call this when a player got successfully teleported with the corresponding event to adjust
   * stored data to the new situation
   *
   * @param event
   */
  public void teleported(PlayerTeleportEvent event) {

    MovingData data = MovingData.get(event.getPlayer());

    // We can enforce a teleport, if that flag is explicitly set (but I'd rather have other plugins
    // not arbitrarily cancel teleport events in the first place...
    if (data.teleportInitializedByMe != null
        && event.isCancelled()
        && enforceTeleport
        && event.getTo().equals(data.teleportInitializedByMe)) {
      event.setCancelled(false);
      data.teleportInitializedByMe = null;
    }

    if (!event.isCancelled()) {
      data.wasTeleported = true;
      data.setBackPoint = event.getTo().clone();
      // data.lastLocation = event.getTo().clone();
    }

    // reset anyway - if another plugin cancelled our teleport it's no use to try and be precise
    data.jumpPhase = 0;
  }