mirror of
https://github.com/PaperMC/Paper.git
synced 2024-11-30 06:24:06 +01:00
69a4a30e47
A recent commit has been made that caused patches to be out of order, rebuilding
270 lines
6.6 KiB
Diff
270 lines
6.6 KiB
Diff
From 2b4c99b420dceb1f6c57d19416ba20d1eee8005b 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 000000000..11248ee93
|
|
--- /dev/null
|
|
+++ b/src/main/java/com/destroystokyo/paper/event/entity/TurtleGoHomeEvent.java
|
|
@@ -0,0 +1,45 @@
|
|
+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;
|
|
+
|
|
+/**
|
|
+ * Fired when a Turtle decides to go home
|
|
+ */
|
|
+public class TurtleGoHomeEvent extends EntityEvent implements Cancellable {
|
|
+ private static final HandlerList handlers = new HandlerList();
|
|
+ private boolean cancelled = false;
|
|
+
|
|
+ public TurtleGoHomeEvent(Turtle turtle) {
|
|
+ super(turtle);
|
|
+ }
|
|
+
|
|
+ /**
|
|
+ * The turtle going home
|
|
+ *
|
|
+ * @return The turtle
|
|
+ */
|
|
+ public Turtle getEntity() {
|
|
+ return (Turtle) entity;
|
|
+ }
|
|
+
|
|
+ @Override
|
|
+ public boolean isCancelled() {
|
|
+ return cancelled;
|
|
+ }
|
|
+
|
|
+ @Override
|
|
+ public void setCancelled(boolean cancel) {
|
|
+ cancelled = cancel;
|
|
+ }
|
|
+
|
|
+ public HandlerList getHandlers() {
|
|
+ return handlers;
|
|
+ }
|
|
+
|
|
+ public static HandlerList getHandlerList() {
|
|
+ return handlers;
|
|
+ }
|
|
+}
|
|
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 000000000..7cb00f78d
|
|
--- /dev/null
|
|
+++ b/src/main/java/com/destroystokyo/paper/event/entity/TurtleLayEggEvent.java
|
|
@@ -0,0 +1,81 @@
|
|
+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;
|
|
+
|
|
+/**
|
|
+ * Fired when a Turtle lays eggs
|
|
+ */
|
|
+public class TurtleLayEggEvent extends EntityEvent implements Cancellable {
|
|
+ private static final HandlerList handlers = new HandlerList();
|
|
+ private boolean cancelled = false;
|
|
+ private final Location location;
|
|
+ private int eggCount;
|
|
+
|
|
+ public TurtleLayEggEvent(Turtle turtle, Location location, int eggCount) {
|
|
+ super(turtle);
|
|
+ this.location = location;
|
|
+ this.eggCount = eggCount;
|
|
+ }
|
|
+
|
|
+ /**
|
|
+ * The turtle laying the eggs
|
|
+ *
|
|
+ * @return The turtle
|
|
+ */
|
|
+ public Turtle getEntity() {
|
|
+ return (Turtle) entity;
|
|
+ }
|
|
+
|
|
+ /**
|
|
+ * Get the location where the eggs are being laid
|
|
+ *
|
|
+ * @return Location of eggs
|
|
+ */
|
|
+ public Location getLocation() {
|
|
+ return location;
|
|
+ }
|
|
+
|
|
+ /**
|
|
+ * Get the number of eggs being laid
|
|
+ *
|
|
+ * @return Number of eggs
|
|
+ */
|
|
+ public int getEggCount() {
|
|
+ return eggCount;
|
|
+ }
|
|
+
|
|
+ /**
|
|
+ * Set the number of eggs being laid
|
|
+ *
|
|
+ * @param eggCount Number of eggs
|
|
+ */
|
|
+ public void setEggCount(int eggCount) {
|
|
+ if (eggCount < 1) {
|
|
+ cancelled = true;
|
|
+ return;
|
|
+ }
|
|
+ eggCount = Math.min(eggCount, 4);
|
|
+ }
|
|
+
|
|
+ @Override
|
|
+ public boolean isCancelled() {
|
|
+ return cancelled;
|
|
+ }
|
|
+
|
|
+ @Override
|
|
+ public void setCancelled(boolean cancel) {
|
|
+ cancelled = cancel;
|
|
+ }
|
|
+
|
|
+ public HandlerList getHandlers() {
|
|
+ return handlers;
|
|
+ }
|
|
+
|
|
+ public static HandlerList getHandlerList() {
|
|
+ return handlers;
|
|
+ }
|
|
+}
|
|
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 000000000..5d53ee08b
|
|
--- /dev/null
|
|
+++ b/src/main/java/com/destroystokyo/paper/event/entity/TurtleStartDiggingEvent.java
|
|
@@ -0,0 +1,57 @@
|
|
+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;
|
|
+
|
|
+/**
|
|
+ * Fired when a Turtle starts digging to lay eggs
|
|
+ */
|
|
+public class TurtleStartDiggingEvent extends EntityEvent implements Cancellable {
|
|
+ private static final HandlerList handlers = new HandlerList();
|
|
+ private boolean cancelled = false;
|
|
+ private final Location location;
|
|
+
|
|
+ public TurtleStartDiggingEvent(Turtle turtle, Location location) {
|
|
+ super(turtle);
|
|
+ this.location = location;
|
|
+ }
|
|
+
|
|
+ /**
|
|
+ * The turtle digging
|
|
+ *
|
|
+ * @return The turtle
|
|
+ */
|
|
+ public Turtle getEntity() {
|
|
+ return (Turtle) entity;
|
|
+ }
|
|
+
|
|
+ /**
|
|
+ * Get the location where the turtle is digging
|
|
+ *
|
|
+ * @return Location where digging
|
|
+ */
|
|
+ public Location getLocation() {
|
|
+ return location;
|
|
+ }
|
|
+
|
|
+ @Override
|
|
+ public boolean isCancelled() {
|
|
+ return cancelled;
|
|
+ }
|
|
+
|
|
+ @Override
|
|
+ public void setCancelled(boolean cancel) {
|
|
+ cancelled = cancel;
|
|
+ }
|
|
+
|
|
+ public HandlerList getHandlers() {
|
|
+ return handlers;
|
|
+ }
|
|
+
|
|
+ public static HandlerList getHandlerList() {
|
|
+ return handlers;
|
|
+ }
|
|
+}
|
|
diff --git a/src/main/java/org/bukkit/entity/Turtle.java b/src/main/java/org/bukkit/entity/Turtle.java
|
|
index 0a4cd2993..e547eead4 100644
|
|
--- a/src/main/java/org/bukkit/entity/Turtle.java
|
|
+++ b/src/main/java/org/bukkit/entity/Turtle.java
|
|
@@ -1,6 +1,53 @@
|
|
package org.bukkit.entity;
|
|
|
|
+import org.bukkit.Location;
|
|
+
|
|
/**
|
|
* Represents a turtle.
|
|
*/
|
|
-public interface Turtle extends Animals { }
|
|
+public interface Turtle extends Animals {
|
|
+ // Paper start
|
|
+
|
|
+ /**
|
|
+ * Get the turtle's home location
|
|
+ *
|
|
+ * @return Home location
|
|
+ */
|
|
+ Location getHome();
|
|
+
|
|
+ /**
|
|
+ * Set the turtle's home location
|
|
+ *
|
|
+ * @param location Home location
|
|
+ */
|
|
+ void setHome(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();
|
|
+
|
|
+ /**
|
|
+ * Get if turtle is carrying egg
|
|
+ *
|
|
+ * @return True if carrying egg
|
|
+ */
|
|
+ boolean hasEgg();
|
|
+
|
|
+ /**
|
|
+ * Set if turtle is carrying egg
|
|
+ *
|
|
+ * @param hasEgg True if carrying egg
|
|
+ */
|
|
+ void setHasEgg(boolean hasEgg);
|
|
+ // Paper end
|
|
+}
|
|
--
|
|
2.19.1
|
|
|