aboutsummaryrefslogtreecommitdiffhomepage
path: root/patches/api/0289-Add-cause-to-Weather-ThunderChangeEvents.patch
blob: 8e5d45d87b96c9fc2b1fbf63645cf70f4c489c80 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Jake Potrebic <jake.m.potrebic@gmail.com>
Date: Wed, 2 Dec 2020 18:25:31 -0800
Subject: [PATCH] Add cause to Weather/ThunderChangeEvents


diff --git a/src/main/java/org/bukkit/event/weather/ThunderChangeEvent.java b/src/main/java/org/bukkit/event/weather/ThunderChangeEvent.java
index 6cdf83476b4e366bed79960e3706bea5ebe56788..032395c7114b6d757acf1918ce2b014870e85fcd 100644
--- a/src/main/java/org/bukkit/event/weather/ThunderChangeEvent.java
+++ b/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/src/main/java/org/bukkit/event/weather/WeatherChangeEvent.java b/src/main/java/org/bukkit/event/weather/WeatherChangeEvent.java
index d562d87e7418641e52f4dae44f573eaa31add44a..dabd390b84354c14c269c03cbed2006014d004b2 100644
--- a/src/main/java/org/bukkit/event/weather/WeatherChangeEvent.java
+++ b/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
 }