Interface PlayerMoveCallback

Functional Interface:
This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.

@FunctionalInterface public interface PlayerMoveCallback
Called when a player moves from one location to another.

This event fires specifically for player movement. For general entity movement (including players), see EntityMoveCallback.

This event is cancellable. If cancelled, the player's movement will be reverted to the original location.

Example Usage


 // Log player movements
 PlayerMoveCallback.EVENT.register((player, from, to) -> {
   System.out.println(player.getDisplayName() + " moved from " + from + " to " + to);
   return EventResult.PASS;
 });

 // Prevent players from entering a restricted area
 PlayerMoveCallback.EVENT.register(EventPriority.HIGH, (player, from, to) -> {
   if (isRestrictedArea(to) && !hasPermission(player)) {
     player.sendMessage("You cannot enter this area!");
     return EventResult.CANCEL;
   }
   return EventResult.PASS;
 });
 
  • Field Details

    • EVENT

      static final Event<PlayerMoveCallback> EVENT
      The event instance. Use this to register listeners and fire the event.
  • Method Details

    • onPlayerMove

      EventResult onPlayerMove(TalePlayer player, Location from, Location to)
      Called when a player moves from one location to another.
      Parameters:
      player - the player who is moving
      from - the location the player is moving from
      to - the location the player is moving to
      Returns:
      the event result - EventResult.CANCEL to prevent the movement