Deprecate TeleportCause CHORUS_FRUIT for CONSUMABLE_EFFECT (#12546)

This commit is contained in:
Pedro 2025-05-18 10:33:21 -04:00 committed by GitHub
parent f1dbed072c
commit cc38032bee
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 13 additions and 5 deletions

View File

@ -1,5 +1,6 @@
package org.bukkit.event.player; package org.bukkit.event.player;
import io.papermc.paper.datacomponent.item.consumable.ConsumeEffect;
import io.papermc.paper.entity.TeleportFlag; import io.papermc.paper.entity.TeleportFlag;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
@ -121,10 +122,9 @@ public class PlayerTeleportEvent extends PlayerMoveEvent {
*/ */
END_GATEWAY, END_GATEWAY,
/** /**
* Indicates the teleportation was caused by a player consuming chorus * Indicates the teleportation was caused by a player consuming an item with a {@link ConsumeEffect.TeleportRandomly} effect
* fruit
*/ */
CHORUS_FRUIT, CONSUMABLE_EFFECT,
/** /**
* Indicates the teleportation was caused by a player exiting a vehicle * Indicates the teleportation was caused by a player exiting a vehicle
*/ */
@ -137,6 +137,14 @@ public class PlayerTeleportEvent extends PlayerMoveEvent {
* Indicates the teleportation was caused by an event not covered by * Indicates the teleportation was caused by an event not covered by
* this enum * this enum
*/ */
UNKNOWN UNKNOWN;
/**
* Indicates the teleportation was caused by a player consuming chorus
* fruit
* @deprecated in favor of {@link #CONSUMABLE_EFFECT}
*/
@Deprecated(since = "1.21.5", forRemoval = true)
public static final TeleportCause CHORUS_FRUIT = CONSUMABLE_EFFECT;
} }
} }

View File

@ -6,7 +6,7 @@
Vec3 vec3 = entity.position(); Vec3 vec3 = entity.position();
- if (entity.randomTeleport(d, d1, d2, true)) { - if (entity.randomTeleport(d, d1, d2, true)) {
+ // CraftBukkit start - handle canceled status of teleport event + // CraftBukkit start - handle canceled status of teleport event
+ java.util.Optional<Boolean> status = entity.randomTeleport(d, d1, d2, true, org.bukkit.event.player.PlayerTeleportEvent.TeleportCause.CHORUS_FRUIT); + java.util.Optional<Boolean> status = entity.randomTeleport(d, d1, d2, true, org.bukkit.event.player.PlayerTeleportEvent.TeleportCause.CONSUMABLE_EFFECT);
+ +
+ // teleport event was canceled, no more tries + // teleport event was canceled, no more tries
+ if (status.isEmpty()) break; + if (status.isEmpty()) break;