|
| 1 | +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 |
| 2 | +From: Jake Potrebic <jake.m.potrebic@gmail.com> |
| 3 | +Date: Wed, 12 May 2021 04:30:53 -0700 |
| 4 | +Subject: [PATCH] Add EntityPortalReadyEvent |
| 5 | + |
| 6 | + |
| 7 | +diff --git a/src/main/java/io/papermc/paper/event/entity/EntityPortalReadyEvent.java b/src/main/java/io/papermc/paper/event/entity/EntityPortalReadyEvent.java |
| 8 | +new file mode 100644 |
| 9 | +index 0000000000000000000000000000000000000000..3c6c1d7e97a0c9813bbc585fd209cc63f498e0d4 |
| 10 | +--- /dev/null |
| 11 | ++++ b/src/main/java/io/papermc/paper/event/entity/EntityPortalReadyEvent.java |
| 12 | +@@ -0,0 +1,89 @@ |
| 13 | ++package io.papermc.paper.event.entity; |
| 14 | ++ |
| 15 | ++import org.bukkit.PortalType; |
| 16 | ++import org.bukkit.World; |
| 17 | ++import org.bukkit.entity.Entity; |
| 18 | ++import org.bukkit.event.Cancellable; |
| 19 | ++import org.bukkit.event.HandlerList; |
| 20 | ++import org.bukkit.event.entity.EntityEvent; |
| 21 | ++import org.jetbrains.annotations.NotNull; |
| 22 | ++import org.jetbrains.annotations.Nullable; |
| 23 | ++ |
| 24 | ++/** |
| 25 | ++ * Called when an entity is ready to be teleported by a plugin. |
| 26 | ++ * Currently this is only called after the required |
| 27 | ++ * ticks have passed for a Nether Portal. |
| 28 | ++ * <p> |
| 29 | ++ * Cancelling this event resets the entity's readiness |
| 30 | ++ * regarding the current portal. |
| 31 | ++ */ |
| 32 | ++public class EntityPortalReadyEvent extends EntityEvent implements Cancellable { |
| 33 | ++ |
| 34 | ++ private static final HandlerList HANDLER_LIST = new HandlerList(); |
| 35 | ++ |
| 36 | ++ private World targetWorld; |
| 37 | ++ private final PortalType portalType; |
| 38 | ++ private boolean cancelled; |
| 39 | ++ |
| 40 | ++ public EntityPortalReadyEvent(final @NotNull Entity entity, final @Nullable World targetWorld, final @NotNull PortalType portalType) { |
| 41 | ++ super(entity); |
| 42 | ++ this.targetWorld = targetWorld; |
| 43 | ++ this.portalType = portalType; |
| 44 | ++ } |
| 45 | ++ |
| 46 | ++ /** |
| 47 | ++ * Gets the world this portal will teleport to. |
| 48 | ++ * Can be null if "allow-nether" is false in server.properties |
| 49 | ++ * or if there is another situation where there is no world to teleport to. |
| 50 | ++ * <p> |
| 51 | ++ * This world may be modified by later events such as {@link org.bukkit.event.player.PlayerPortalEvent} |
| 52 | ++ * or {@link org.bukkit.event.entity.EntityPortalEvent}. |
| 53 | ++ * |
| 54 | ++ * @return the world the portal will teleport the entity to. |
| 55 | ++ */ |
| 56 | ++ public @Nullable World getTargetWorld() { |
| 57 | ++ return targetWorld; |
| 58 | ++ } |
| 59 | ++ |
| 60 | ++ /** |
| 61 | ++ * Sets the world this portal will teleport to. A null value |
| 62 | ++ * will essentially cancel the teleport and prevent further events |
| 63 | ++ * such as {@link org.bukkit.event.player.PlayerPortalEvent} from firing. |
| 64 | ++ * <p> |
| 65 | ++ * This world may be modified by later events such as {@link org.bukkit.event.player.PlayerPortalEvent} |
| 66 | ++ * or {@link org.bukkit.event.entity.EntityPortalEvent}. |
| 67 | ++ * |
| 68 | ++ * @param targetWorld the world |
| 69 | ++ */ |
| 70 | ++ public void setTargetWorld(final @Nullable World targetWorld) { |
| 71 | ++ this.targetWorld = targetWorld; |
| 72 | ++ } |
| 73 | ++ |
| 74 | ++ /** |
| 75 | ++ * Gets the portal type for this event. |
| 76 | ++ * |
| 77 | ++ * @return the portal type |
| 78 | ++ */ |
| 79 | ++ public @NotNull PortalType getPortalType() { |
| 80 | ++ return portalType; |
| 81 | ++ } |
| 82 | ++ |
| 83 | ++ @Override |
| 84 | ++ public boolean isCancelled() { |
| 85 | ++ return cancelled; |
| 86 | ++ } |
| 87 | ++ |
| 88 | ++ @Override |
| 89 | ++ public void setCancelled(final boolean cancel) { |
| 90 | ++ this.cancelled = cancel; |
| 91 | ++ } |
| 92 | ++ |
| 93 | ++ @Override |
| 94 | ++ public @NotNull HandlerList getHandlers() { |
| 95 | ++ return HANDLER_LIST; |
| 96 | ++ } |
| 97 | ++ |
| 98 | ++ public static @NotNull HandlerList getHandlerList() { |
| 99 | ++ return HANDLER_LIST; |
| 100 | ++ } |
| 101 | ++} |
0 commit comments