2019-06-14 02:27:40 +00:00
|
|
|
From f2d75b2305da564f7bf67db3354fbc8d06601225 Mon Sep 17 00:00:00 2001
|
2016-03-19 16:57:19 +00: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
|
2019-06-06 15:36:57 +00:00
|
|
|
index c2793f3ef..373f4b5b5 100644
|
2016-03-19 16:57:19 +00:00
|
|
|
--- a/src/main/java/org/bukkit/event/player/PlayerItemConsumeEvent.java
|
|
|
|
+++ b/src/main/java/org/bukkit/event/player/PlayerItemConsumeEvent.java
|
2019-03-20 00:28:15 +00:00
|
|
|
@@ -22,6 +22,7 @@ public class PlayerItemConsumeEvent extends PlayerEvent implements Cancellable {
|
2016-03-19 16:57:19 +00:00
|
|
|
private static final HandlerList handlers = new HandlerList();
|
|
|
|
private boolean isCancelled = false;
|
|
|
|
private ItemStack item;
|
2017-06-10 22:11:10 +00:00
|
|
|
+ @Nullable private ItemStack replacement; // Paper
|
2016-03-19 16:57:19 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @param player the player consuming
|
2019-03-20 00:28:15 +00:00
|
|
|
@@ -58,6 +59,29 @@ public class PlayerItemConsumeEvent extends PlayerEvent implements Cancellable {
|
2016-03-19 16:57:19 +00: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-10 22:11:10 +00:00
|
|
|
+ *
|
|
|
|
+ * @return The custom item stack that will replace the consumed item or null
|
2016-03-19 16:57:19 +00:00
|
|
|
+ */
|
2017-06-10 22:11:10 +00:00
|
|
|
+ @Nullable
|
2016-03-19 16:57:19 +00: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-10 22:11:10 +00:00
|
|
|
+ *
|
|
|
|
+ * @param replacement Replacement item to set, null to clear any custom stack and use default
|
2016-03-19 16:57:19 +00:00
|
|
|
+ */
|
2017-06-10 22:11:10 +00:00
|
|
|
+ public void setReplacement(@Nullable ItemStack replacement) {
|
2016-03-19 16:57:19 +00:00
|
|
|
+ this.replacement = replacement;
|
|
|
|
+ }
|
|
|
|
+ // Paper end
|
|
|
|
+
|
2019-05-06 02:58:04 +00:00
|
|
|
@Override
|
2016-03-19 16:57:19 +00:00
|
|
|
public boolean isCancelled() {
|
|
|
|
return this.isCancelled;
|
|
|
|
--
|
2019-03-20 00:28:15 +00:00
|
|
|
2.21.0
|
2016-03-19 16:57:19 +00:00
|
|
|
|