Package dev.polv.taleapi.event.player
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.
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 Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptiononPlayerMove(TalePlayer player, Location from, Location to) Called when a player moves from one location to another.
-
Field Details
-
EVENT
The event instance. Use this to register listeners and fire the event.
-
-
Method Details
-
onPlayerMove
Called when a player moves from one location to another.- Parameters:
player- the player who is movingfrom- the location the player is moving fromto- the location the player is moving to- Returns:
- the event result -
EventResult.CANCELto prevent the movement
-