|
| 1 | +package io.papermc.paper.event.entity; |
| 2 | + |
| 3 | +import io.papermc.paper.world.WeatheringCopperState; |
| 4 | +import org.bukkit.entity.CopperGolem; |
| 5 | +import org.bukkit.event.Cancellable; |
| 6 | +import org.bukkit.event.HandlerList; |
| 7 | +import org.bukkit.event.entity.EntityEvent; |
| 8 | +import org.jetbrains.annotations.ApiStatus; |
| 9 | +import org.jspecify.annotations.NullMarked; |
| 10 | + |
| 11 | +/** |
| 12 | + * Called when a {@link CopperGolem} transitions from one {@link WeatheringCopperState} to another. |
| 13 | + */ |
| 14 | +@NullMarked |
| 15 | +public class CopperGolemWeatheringEvent extends EntityEvent implements Cancellable { |
| 16 | + |
| 17 | + private static final HandlerList HANDLER_LIST = new HandlerList(); |
| 18 | + |
| 19 | + private final WeatheringCopperState weatherState; |
| 20 | + private final WeatheringCopperState nextWeatherState; |
| 21 | + |
| 22 | + private boolean cancelled; |
| 23 | + |
| 24 | + @ApiStatus.Internal |
| 25 | + public CopperGolemWeatheringEvent(final CopperGolem golem, final WeatheringCopperState weatherState, final WeatheringCopperState nextWeatherState) { |
| 26 | + super(golem); |
| 27 | + this.weatherState = weatherState; |
| 28 | + this.nextWeatherState = nextWeatherState; |
| 29 | + } |
| 30 | + |
| 31 | + /** |
| 32 | + * Gets the copper golem entity that is about to weather. |
| 33 | + * |
| 34 | + * @return The copper golem entity about to weather. |
| 35 | + */ |
| 36 | + @Override |
| 37 | + public CopperGolem getEntity() { |
| 38 | + return (CopperGolem) super.getEntity(); |
| 39 | + } |
| 40 | + |
| 41 | + /** |
| 42 | + * Gets the current weathering state of the copper golem. |
| 43 | + * |
| 44 | + * @return The current weathering state. |
| 45 | + */ |
| 46 | + public WeatheringCopperState getWeatheringState() { |
| 47 | + return weatherState; |
| 48 | + } |
| 49 | + |
| 50 | + /** |
| 51 | + * Gets the next weathering state the copper golem will transition to. |
| 52 | + * |
| 53 | + * @return The next weathering state. |
| 54 | + */ |
| 55 | + public WeatheringCopperState getNextWeatheringState() { |
| 56 | + return nextWeatherState; |
| 57 | + } |
| 58 | + |
| 59 | + @Override |
| 60 | + public boolean isCancelled() { |
| 61 | + return cancelled; |
| 62 | + } |
| 63 | + |
| 64 | + @Override |
| 65 | + public void setCancelled(final boolean cancel) { |
| 66 | + this.cancelled = cancel; |
| 67 | + } |
| 68 | + |
| 69 | + @Override |
| 70 | + public HandlerList getHandlers() { |
| 71 | + return HANDLER_LIST; |
| 72 | + } |
| 73 | + |
| 74 | + public static HandlerList getHandlerList() { |
| 75 | + return HANDLER_LIST; |
| 76 | + } |
| 77 | +} |
0 commit comments