2019-02-23 18:17:41 +01:00
|
|
|
From ecd8d3e4642c78e5943717aed64df470aa7f83c9 Mon Sep 17 00:00:00 2001
|
2016-03-19 17:57:19 +01:00
|
|
|
From: Jedediah Smith <jedediah@silencegreys.com>
|
|
|
|
Date: Sun, 21 Jun 2015 15:05:21 -0400
|
|
|
|
Subject: [PATCH] Custom replacement for eaten items
|
|
|
|
|
|
|
|
|
|
|
|
diff --git a/src/main/java/org/bukkit/event/player/PlayerItemConsumeEvent.java b/src/main/java/org/bukkit/event/player/PlayerItemConsumeEvent.java
|
2017-06-11 00:11:10 +02:00
|
|
|
index 8ab76b1d..7d28155b 100644
|
2016-03-19 17:57:19 +01:00
|
|
|
--- a/src/main/java/org/bukkit/event/player/PlayerItemConsumeEvent.java
|
|
|
|
+++ b/src/main/java/org/bukkit/event/player/PlayerItemConsumeEvent.java
|
2017-06-11 00:11:10 +02:00
|
|
|
@@ -6,6 +6,8 @@ import org.bukkit.event.Cancellable;
|
|
|
|
import org.bukkit.event.HandlerList;
|
|
|
|
import org.bukkit.inventory.ItemStack;
|
|
|
|
|
|
|
|
+import javax.annotation.Nullable;
|
|
|
|
+
|
|
|
|
/**
|
|
|
|
* This event will fire when a player is finishing consuming an item (food,
|
|
|
|
* potion, milk bucket).
|
|
|
|
@@ -20,6 +22,7 @@ public class PlayerItemConsumeEvent extends PlayerEvent implements Cancellable {
|
2016-03-19 17:57:19 +01:00
|
|
|
private static final HandlerList handlers = new HandlerList();
|
|
|
|
private boolean isCancelled = false;
|
|
|
|
private ItemStack item;
|
2017-06-11 00:11:10 +02:00
|
|
|
+ @Nullable private ItemStack replacement; // Paper
|
2016-03-19 17:57:19 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @param player the player consuming
|
2017-06-11 00:11:10 +02:00
|
|
|
@@ -55,6 +58,29 @@ public class PlayerItemConsumeEvent extends PlayerEvent implements Cancellable {
|
2016-03-19 17:57:19 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
+ // Paper start
|
|
|
|
+ /**
|
|
|
|
+ * Return the custom item stack that will replace the consumed item, or null if no
|
|
|
|
+ * custom replacement has been set (which means the default replacement will be used).
|
2017-06-11 00:11:10 +02:00
|
|
|
+ *
|
|
|
|
+ * @return The custom item stack that will replace the consumed item or null
|
2016-03-19 17:57:19 +01:00
|
|
|
+ */
|
2017-06-11 00:11:10 +02:00
|
|
|
+ @Nullable
|
2016-03-19 17:57:19 +01:00
|
|
|
+ public ItemStack getReplacement() {
|
|
|
|
+ return this.replacement;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * Set a custom item stack to replace the consumed item. Pass null to clear any custom
|
|
|
|
+ * stack that has been set and use the default replacement.
|
2017-06-11 00:11:10 +02:00
|
|
|
+ *
|
|
|
|
+ * @param replacement Replacement item to set, null to clear any custom stack and use default
|
2016-03-19 17:57:19 +01:00
|
|
|
+ */
|
2017-06-11 00:11:10 +02:00
|
|
|
+ public void setReplacement(@Nullable ItemStack replacement) {
|
2016-03-19 17:57:19 +01:00
|
|
|
+ this.replacement = replacement;
|
|
|
|
+ }
|
|
|
|
+ // Paper end
|
|
|
|
+
|
|
|
|
public boolean isCancelled() {
|
|
|
|
return this.isCancelled;
|
|
|
|
}
|
|
|
|
--
|
2019-02-23 18:17:41 +01:00
|
|
|
2.20.1
|
2016-03-19 17:57:19 +01:00
|
|
|
|