Mirror von
https://github.com/PaperMC/Paper.git
synchronisiert 2024-12-15 11:00:06 +01:00
fe4678c414
Fixes our own, and upstream's, issues with the stricter Java 8 JavaDoc linter. Also removes the destroystokyo-release maven repository. I'm not sure why I added it originally, but it's unnecessary now.
61 Zeilen
2.2 KiB
Diff
61 Zeilen
2.2 KiB
Diff
From be5afd90beb1063d903d94f39ad8ce38c8545536 Mon Sep 17 00:00:00 2001
|
|
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
|
|
index 8ab76b1d..7d28155b 100644
|
|
--- a/src/main/java/org/bukkit/event/player/PlayerItemConsumeEvent.java
|
|
+++ b/src/main/java/org/bukkit/event/player/PlayerItemConsumeEvent.java
|
|
@@ -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 {
|
|
private static final HandlerList handlers = new HandlerList();
|
|
private boolean isCancelled = false;
|
|
private ItemStack item;
|
|
+ @Nullable private ItemStack replacement; // Paper
|
|
|
|
/**
|
|
* @param player the player consuming
|
|
@@ -55,6 +58,29 @@ public class PlayerItemConsumeEvent extends PlayerEvent implements Cancellable {
|
|
}
|
|
}
|
|
|
|
+ // 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).
|
|
+ *
|
|
+ * @return The custom item stack that will replace the consumed item or null
|
|
+ */
|
|
+ @Nullable
|
|
+ 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.
|
|
+ *
|
|
+ * @param replacement Replacement item to set, null to clear any custom stack and use default
|
|
+ */
|
|
+ public void setReplacement(@Nullable ItemStack replacement) {
|
|
+ this.replacement = replacement;
|
|
+ }
|
|
+ // Paper end
|
|
+
|
|
public boolean isCancelled() {
|
|
return this.isCancelled;
|
|
}
|
|
--
|
|
2.13.0.windows.1
|
|
|