From 547577ccb6f565fefdbef7151265ef651e542b37 Mon Sep 17 00:00:00 2001 From: Jake Potrebic Date: Wed, 2 Dec 2020 18:25:31 -0800 Subject: [PATCH] Add cause to Weather/ThunderChangeEvents --- .../event/weather/ThunderChangeEvent.java | 29 +++++++++++++++++++ .../event/weather/WeatherChangeEvent.java | 29 +++++++++++++++++++ 2 files changed, 58 insertions(+) diff --git a/paper-api/src/main/java/org/bukkit/event/weather/ThunderChangeEvent.java b/paper-api/src/main/java/org/bukkit/event/weather/ThunderChangeEvent.java index 6cdf83476b..032395c711 100644 --- a/paper-api/src/main/java/org/bukkit/event/weather/ThunderChangeEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/weather/ThunderChangeEvent.java @@ -12,10 +12,20 @@ public class ThunderChangeEvent extends WeatherEvent implements Cancellable { private static final HandlerList handlers = new HandlerList(); private boolean canceled; private final boolean to; + // Paper start + private final Cause cause; + public ThunderChangeEvent(@NotNull final World world, final boolean to, @NotNull final Cause cause) { + super(world); + this.to = to; + this.cause = cause; + } + + @Deprecated // Paper end public ThunderChangeEvent(@NotNull final World world, final boolean to) { super(world); this.to = to; + this.cause = Cause.UNKNOWN; // Paper } @Override @@ -47,4 +57,23 @@ public class ThunderChangeEvent extends WeatherEvent implements Cancellable { public static HandlerList getHandlerList() { return handlers; } + // Paper start + /** + * Gets the cause of the weather change. + * + * @return the weather change cause + */ + @NotNull + public Cause getCause() { + return this.cause; + } + + public enum Cause { + COMMAND, + NATURAL, + SLEEP, + PLUGIN, + UNKNOWN + } + // Paper end } diff --git a/paper-api/src/main/java/org/bukkit/event/weather/WeatherChangeEvent.java b/paper-api/src/main/java/org/bukkit/event/weather/WeatherChangeEvent.java index d562d87e74..dabd390b84 100644 --- a/paper-api/src/main/java/org/bukkit/event/weather/WeatherChangeEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/weather/WeatherChangeEvent.java @@ -12,10 +12,20 @@ public class WeatherChangeEvent extends WeatherEvent implements Cancellable { private static final HandlerList handlers = new HandlerList(); private boolean canceled; private final boolean to; + // Paper start + private final Cause cause; + public WeatherChangeEvent(@NotNull final World world, final boolean to, @NotNull Cause cause) { + super(world); + this.to = to; + this.cause = cause; + } + + @Deprecated // Paper end public WeatherChangeEvent(@NotNull final World world, final boolean to) { super(world); this.to = to; + this.cause = Cause.UNKNOWN; // Paper } @Override @@ -47,4 +57,23 @@ public class WeatherChangeEvent extends WeatherEvent implements Cancellable { public static HandlerList getHandlerList() { return handlers; } + // Paper start + /** + * Gets the cause of the weather change. + * + * @return the weather change cause + */ + @NotNull + public Cause getCause() { + return cause; + } + + public enum Cause { + COMMAND, + NATURAL, + SLEEP, + PLUGIN, + UNKNOWN + } + // Paper end }