aboutsummaryrefslogtreecommitdiffhomepage
path: root/patches/api/0158-Turtle-API.patch
blob: 4d3712fd8c5631354cd382da8bdbd2a29bbe6b09 (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
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: BillyGalbreath <Blake.Galbreath@GMail.com>
Date: Fri, 28 Sep 2018 17:08:09 -0500
Subject: [PATCH] Turtle API


diff --git a/src/main/java/com/destroystokyo/paper/event/entity/TurtleGoHomeEvent.java b/src/main/java/com/destroystokyo/paper/event/entity/TurtleGoHomeEvent.java
new file mode 100644
index 0000000000000000000000000000000000000000..cfbc8aaf862ac90e794ee38bf8a6cb9ea414b13e
--- /dev/null
+++ b/src/main/java/com/destroystokyo/paper/event/entity/TurtleGoHomeEvent.java
@@ -0,0 +1,53 @@
+package com.destroystokyo.paper.event.entity;
+
+import org.bukkit.entity.Turtle;
+import org.bukkit.event.Cancellable;
+import org.bukkit.event.HandlerList;
+import org.bukkit.event.entity.EntityEvent;
+import org.jetbrains.annotations.ApiStatus;
+import org.jetbrains.annotations.NotNull;
+
+/**
+ * Fired when a Turtle decides to go home
+ */
+public class TurtleGoHomeEvent extends EntityEvent implements Cancellable {
+
+    private static final HandlerList HANDLER_LIST = new HandlerList();
+
+    private boolean cancelled;
+
+    @ApiStatus.Internal
+    public TurtleGoHomeEvent(@NotNull Turtle turtle) {
+        super(turtle);
+    }
+
+    /**
+     * The turtle going home
+     *
+     * @return The turtle
+     */
+    @NotNull
+    public Turtle getEntity() {
+        return (Turtle) super.getEntity();
+    }
+
+    @Override
+    public boolean isCancelled() {
+        return this.cancelled;
+    }
+
+    @Override
+    public void setCancelled(boolean cancel) {
+        this.cancelled = cancel;
+    }
+
+    @NotNull
+    public HandlerList getHandlers() {
+        return HANDLER_LIST;
+    }
+
+    @NotNull
+    public static HandlerList getHandlerList() {
+        return HANDLER_LIST;
+    }
+}
diff --git a/src/main/java/com/destroystokyo/paper/event/entity/TurtleLayEggEvent.java b/src/main/java/com/destroystokyo/paper/event/entity/TurtleLayEggEvent.java
new file mode 100644
index 0000000000000000000000000000000000000000..e917e64e8ea266a3fc7387c42aad95927f0f0501
--- /dev/null
+++ b/src/main/java/com/destroystokyo/paper/event/entity/TurtleLayEggEvent.java
@@ -0,0 +1,92 @@
+package com.destroystokyo.paper.event.entity;
+
+import org.bukkit.Location;
+import org.bukkit.entity.Turtle;
+import org.bukkit.event.Cancellable;
+import org.bukkit.event.HandlerList;
+import org.bukkit.event.entity.EntityEvent;
+import org.jetbrains.annotations.ApiStatus;
+import org.jetbrains.annotations.NotNull;
+
+/**
+ * Fired when a Turtle lays eggs
+ */
+public class TurtleLayEggEvent extends EntityEvent implements Cancellable {
+
+    private static final HandlerList HANDLER_LIST = new HandlerList();
+
+    @NotNull
+    private final Location location;
+    private int eggCount;
+
+    private boolean cancelled;
+
+    @ApiStatus.Internal
+    public TurtleLayEggEvent(@NotNull Turtle turtle, @NotNull Location location, int eggCount) {
+        super(turtle);
+        this.location = location;
+        this.eggCount = eggCount;
+    }
+
+    /**
+     * The turtle laying the eggs
+     *
+     * @return The turtle
+     */
+    @NotNull
+    public Turtle getEntity() {
+        return (Turtle) super.getEntity();
+    }
+
+    /**
+     * Get the location where the eggs are being laid
+     *
+     * @return Location of eggs
+     */
+    @NotNull
+    public Location getLocation() {
+        return this.location;
+    }
+
+    /**
+     * Get the number of eggs being laid
+     *
+     * @return Number of eggs
+     */
+    public int getEggCount() {
+        return this.eggCount;
+    }
+
+    /**
+     * Set the number of eggs being laid
+     *
+     * @param eggCount Number of eggs
+     */
+    public void setEggCount(int eggCount) {
+        if (eggCount < 1) {
+            this.cancelled = true;
+            return;
+        }
+        this.eggCount = Math.min(eggCount, 4);
+    }
+
+    @Override
+    public boolean isCancelled() {
+        return this.cancelled;
+    }
+
+    @Override
+    public void setCancelled(boolean cancel) {
+        this.cancelled = cancel;
+    }
+
+    @NotNull
+    public HandlerList getHandlers() {
+        return HANDLER_LIST;
+    }
+
+    @NotNull
+    public static HandlerList getHandlerList() {
+        return HANDLER_LIST;
+    }
+}
diff --git a/src/main/java/com/destroystokyo/paper/event/entity/TurtleStartDiggingEvent.java b/src/main/java/com/destroystokyo/paper/event/entity/TurtleStartDiggingEvent.java
new file mode 100644
index 0000000000000000000000000000000000000000..5cdc6b0c3db43279e2bb8043922b31f750ddb3f5
--- /dev/null
+++ b/src/main/java/com/destroystokyo/paper/event/entity/TurtleStartDiggingEvent.java
@@ -0,0 +1,66 @@
+package com.destroystokyo.paper.event.entity;
+
+import org.bukkit.Location;
+import org.bukkit.entity.Turtle;
+import org.bukkit.event.Cancellable;
+import org.bukkit.event.HandlerList;
+import org.bukkit.event.entity.EntityEvent;
+import org.jetbrains.annotations.ApiStatus;
+import org.jetbrains.annotations.NotNull;
+
+/**
+ * Fired when a Turtle starts digging to lay eggs
+ */
+public class TurtleStartDiggingEvent extends EntityEvent implements Cancellable {
+
+    private static final HandlerList HANDLER_LIST = new HandlerList();
+
+    @NotNull private final Location location;
+    private boolean cancelled;
+
+    @ApiStatus.Internal
+    public TurtleStartDiggingEvent(@NotNull Turtle turtle, @NotNull Location location) {
+        super(turtle);
+        this.location = location;
+    }
+
+    /**
+     * The turtle digging
+     *
+     * @return The turtle
+     */
+    @NotNull
+    public Turtle getEntity() {
+        return (Turtle) super.getEntity();
+    }
+
+    /**
+     * Get the location where the turtle is digging
+     *
+     * @return Location where digging
+     */
+    @NotNull
+    public Location getLocation() {
+        return this.location;
+    }
+
+    @Override
+    public boolean isCancelled() {
+        return this.cancelled;
+    }
+
+    @Override
+    public void setCancelled(boolean cancel) {
+        this.cancelled = cancel;
+    }
+
+    @NotNull
+    public HandlerList getHandlers() {
+        return HANDLER_LIST;
+    }
+
+    @NotNull
+    public static HandlerList getHandlerList() {
+        return HANDLER_LIST;
+    }
+}
diff --git a/src/main/java/org/bukkit/entity/Turtle.java b/src/main/java/org/bukkit/entity/Turtle.java
index 5584936158e3762d348cb2eaee2082da24ede367..aa83615a0c6565c9874c906a83cfe20c2a964b22 100644
--- a/src/main/java/org/bukkit/entity/Turtle.java
+++ b/src/main/java/org/bukkit/entity/Turtle.java
@@ -1,5 +1,8 @@
 package org.bukkit.entity;
 
+import org.bukkit.Location;
+import org.jetbrains.annotations.NotNull;
+
 /**
  * Represents a turtle.
  */
@@ -18,4 +21,42 @@ public interface Turtle extends Animals {
      * @return Whether the turtle is laying an egg
      */
     boolean isLayingEgg();
+
+    // Paper start
+    /**
+     * Get the turtle's home location
+     *
+     * @return Home location
+     */
+    @NotNull
+    Location getHome();
+
+    /**
+     * Set the turtle's home location
+     *
+     * @param location Home location
+     */
+    void setHome(@NotNull Location location);
+
+    /**
+     * Check if turtle is currently pathfinding to it's home
+     *
+     * @return True if going home
+     */
+    boolean isGoingHome();
+
+    /**
+     * Get if turtle is digging to lay eggs
+     *
+     * @return True if digging
+     */
+    boolean isDigging();
+
+    /**
+     * Set if turtle is carrying egg
+     *
+     * @param hasEgg True if carrying egg
+     */
+    void setHasEgg(boolean hasEgg);
+    // Paper end
 }