mirror of
https://github.com/PurpurMC/Purpur.git
synced 2026-02-17 16:37:43 +01:00
Upstream has released updates that appears to apply and compile correctly Paper Changes: b75eeca0 Boost light task priority to ensure it doesnt hold up chunk loads 3d2bc848 Ensure VillagerTrades doesn't load async - fixes #3495 e470f1ef Add more information to Timing Reports f4a47db6 Improve Thread Pool usage to allow single threads for single cpu servers a4fe910f Fix sounds when using worldedit regen command 70ad51a8 Updated Upstream (Bukkit/CraftBukkit) d7cfa4fa Improve legacy format serialization more
202 lines
5.4 KiB
Diff
202 lines
5.4 KiB
Diff
From 5dbf64e9ba5558297cbc7584e973926d6fbe073f Mon Sep 17 00:00:00 2001
|
|
From: William Blake Galbreath <blake.galbreath@gmail.com>
|
|
Date: Fri, 18 Oct 2019 22:50:05 -0500
|
|
Subject: [PATCH] Add more llama API
|
|
|
|
---
|
|
.../event/entity/LlamaJoinCaravanEvent.java | 61 ++++++++++++++++++
|
|
.../event/entity/LlamaLeaveCaravanEvent.java | 34 ++++++++++
|
|
src/main/java/org/bukkit/entity/Llama.java | 62 +++++++++++++++++++
|
|
3 files changed, 157 insertions(+)
|
|
create mode 100644 src/main/java/net/pl3x/purpur/event/entity/LlamaJoinCaravanEvent.java
|
|
create mode 100644 src/main/java/net/pl3x/purpur/event/entity/LlamaLeaveCaravanEvent.java
|
|
|
|
diff --git a/src/main/java/net/pl3x/purpur/event/entity/LlamaJoinCaravanEvent.java b/src/main/java/net/pl3x/purpur/event/entity/LlamaJoinCaravanEvent.java
|
|
new file mode 100644
|
|
index 000000000..6e68c1399
|
|
--- /dev/null
|
|
+++ b/src/main/java/net/pl3x/purpur/event/entity/LlamaJoinCaravanEvent.java
|
|
@@ -0,0 +1,61 @@
|
|
+package net.pl3x.purpur.event.entity;
|
|
+
|
|
+import org.bukkit.entity.Llama;
|
|
+import org.bukkit.event.Cancellable;
|
|
+import org.bukkit.event.HandlerList;
|
|
+import org.bukkit.event.entity.EntityEvent;
|
|
+import org.jetbrains.annotations.NotNull;
|
|
+
|
|
+/**
|
|
+ * Called when a Llama tries to join a caravan.
|
|
+ * <p>
|
|
+ * Cancelling the event will not let the Llama join. To prevent future attempts
|
|
+ * at joining a caravan use {@link Llama#setShouldJoinCaravan(boolean)}.
|
|
+ */
|
|
+public class LlamaJoinCaravanEvent extends EntityEvent implements Cancellable {
|
|
+ private static final HandlerList handlers = new HandlerList();
|
|
+ private boolean canceled;
|
|
+ private final Llama head;
|
|
+
|
|
+ public LlamaJoinCaravanEvent(@NotNull Llama llama, @NotNull Llama head) {
|
|
+ super(llama);
|
|
+ this.head = head;
|
|
+ }
|
|
+
|
|
+ @Override
|
|
+ @NotNull
|
|
+ public Llama getEntity() {
|
|
+ return (Llama) entity;
|
|
+ }
|
|
+
|
|
+ /**
|
|
+ * Get the Llama that this Llama is about to follow
|
|
+ *
|
|
+ * @return Llama about to be followed
|
|
+ */
|
|
+ @NotNull
|
|
+ public Llama getHead() {
|
|
+ return head;
|
|
+ }
|
|
+
|
|
+ @Override
|
|
+ public boolean isCancelled() {
|
|
+ return canceled;
|
|
+ }
|
|
+
|
|
+ @Override
|
|
+ public void setCancelled(boolean cancel) {
|
|
+ canceled = cancel;
|
|
+ }
|
|
+
|
|
+ @Override
|
|
+ @NotNull
|
|
+ public HandlerList getHandlers() {
|
|
+ return handlers;
|
|
+ }
|
|
+
|
|
+ @NotNull
|
|
+ public static HandlerList getHandlerList() {
|
|
+ return handlers;
|
|
+ }
|
|
+}
|
|
diff --git a/src/main/java/net/pl3x/purpur/event/entity/LlamaLeaveCaravanEvent.java b/src/main/java/net/pl3x/purpur/event/entity/LlamaLeaveCaravanEvent.java
|
|
new file mode 100644
|
|
index 000000000..ec8d978c2
|
|
--- /dev/null
|
|
+++ b/src/main/java/net/pl3x/purpur/event/entity/LlamaLeaveCaravanEvent.java
|
|
@@ -0,0 +1,34 @@
|
|
+package net.pl3x.purpur.event.entity;
|
|
+
|
|
+import org.bukkit.entity.Llama;
|
|
+import org.bukkit.event.HandlerList;
|
|
+import org.bukkit.event.entity.EntityEvent;
|
|
+import org.jetbrains.annotations.NotNull;
|
|
+
|
|
+/**
|
|
+ * Called when a Llama leaves a caravan
|
|
+ */
|
|
+public class LlamaLeaveCaravanEvent extends EntityEvent {
|
|
+ private static final HandlerList handlers = new HandlerList();
|
|
+
|
|
+ public LlamaLeaveCaravanEvent(@NotNull Llama llama) {
|
|
+ super(llama);
|
|
+ }
|
|
+
|
|
+ @Override
|
|
+ @NotNull
|
|
+ public Llama getEntity() {
|
|
+ return (Llama) entity;
|
|
+ }
|
|
+
|
|
+ @Override
|
|
+ @NotNull
|
|
+ public HandlerList getHandlers() {
|
|
+ return handlers;
|
|
+ }
|
|
+
|
|
+ @NotNull
|
|
+ public static HandlerList getHandlerList() {
|
|
+ return handlers;
|
|
+ }
|
|
+}
|
|
diff --git a/src/main/java/org/bukkit/entity/Llama.java b/src/main/java/org/bukkit/entity/Llama.java
|
|
index d23226ccb..1ef9479c9 100644
|
|
--- a/src/main/java/org/bukkit/entity/Llama.java
|
|
+++ b/src/main/java/org/bukkit/entity/Llama.java
|
|
@@ -3,6 +3,7 @@ package org.bukkit.entity;
|
|
import com.destroystokyo.paper.entity.RangedEntity;
|
|
import org.bukkit.inventory.LlamaInventory;
|
|
import org.jetbrains.annotations.NotNull;
|
|
+import org.jetbrains.annotations.Nullable; // Purpur
|
|
|
|
/**
|
|
* Represents a Llama.
|
|
@@ -67,4 +68,65 @@ public interface Llama extends ChestedHorse, RangedEntity { // Paper
|
|
@NotNull
|
|
@Override
|
|
LlamaInventory getInventory();
|
|
+
|
|
+ // Purpur start
|
|
+
|
|
+ /**
|
|
+ * Check if this Llama should attempt to join a caravan
|
|
+ *
|
|
+ * @return True if Llama is allowed to join a caravan
|
|
+ */
|
|
+ boolean shouldJoinCaravan();
|
|
+
|
|
+ /**
|
|
+ * Set if this Llama should attempt to join a caravan
|
|
+ *
|
|
+ * @param shouldJoinCaravan True to allow joining a caravan
|
|
+ */
|
|
+ void setShouldJoinCaravan(boolean shouldJoinCaravan);
|
|
+
|
|
+ /**
|
|
+ * Check if Llama is in a caravan
|
|
+ *
|
|
+ * @return True if in caravan
|
|
+ */
|
|
+ boolean inCaravan();
|
|
+
|
|
+ /**
|
|
+ * Join a caravan
|
|
+ *
|
|
+ * @param llama Head of caravan to join
|
|
+ */
|
|
+ void joinCaravan(@NotNull Llama llama);
|
|
+
|
|
+ /**
|
|
+ * Leave current caravan if in one
|
|
+ */
|
|
+ void leaveCaravan();
|
|
+
|
|
+ /**
|
|
+ * Check if another Llama is following this Llama
|
|
+ *
|
|
+ * @return True if being followed in the caravan
|
|
+ */
|
|
+ boolean hasCaravanTail();
|
|
+
|
|
+ /**
|
|
+ * Get the Llama that this Llama is following
|
|
+ * <p>
|
|
+ * Does not necessarily mean the leader of the entire caravan
|
|
+ *
|
|
+ * @return The Llama being followed
|
|
+ */
|
|
+ @Nullable
|
|
+ Llama getCaravanHead();
|
|
+
|
|
+ /**
|
|
+ * Get the Llama following this Llama, if any
|
|
+ *
|
|
+ * @return The Llama following this one
|
|
+ */
|
|
+ @Nullable
|
|
+ Llama getCaravanTail();
|
|
+ // Purpur end
|
|
}
|
|
--
|
|
2.24.0
|
|
|