2021-06-11 14:02:28 +02:00
|
|
|
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
|
|
From: LordKorea <lk97798@posteo.net>
|
|
|
|
Date: Mon, 11 May 2020 22:38:10 -0400
|
|
|
|
Subject: [PATCH] Add and implement PlayerRecipeBookClickEvent
|
|
|
|
|
|
|
|
|
|
|
|
diff --git a/src/main/java/com/destroystokyo/paper/event/player/PlayerRecipeBookClickEvent.java b/src/main/java/com/destroystokyo/paper/event/player/PlayerRecipeBookClickEvent.java
|
|
|
|
new file mode 100644
|
|
|
|
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000
|
|
|
|
--- /dev/null
|
|
|
|
+++ b/src/main/java/com/destroystokyo/paper/event/player/PlayerRecipeBookClickEvent.java
|
|
|
|
@@ -0,0 +0,0 @@
|
|
|
|
+package com.destroystokyo.paper.event.player;
|
|
|
|
+
|
|
|
|
+import org.bukkit.NamespacedKey;
|
|
|
|
+import org.bukkit.entity.Player;
|
|
|
|
+import org.bukkit.event.Cancellable;
|
|
|
|
+import org.bukkit.event.HandlerList;
|
|
|
|
+import org.bukkit.event.player.PlayerEvent;
|
2024-02-01 10:15:57 +01:00
|
|
|
+import org.jetbrains.annotations.ApiStatus;
|
2024-09-30 01:48:34 +02:00
|
|
|
+import org.jspecify.annotations.NullMarked;
|
2021-06-11 14:02:28 +02:00
|
|
|
+
|
|
|
|
+/**
|
|
|
|
+ * Called when a player clicks a recipe in the recipe book
|
|
|
|
+ */
|
2024-09-30 01:48:34 +02:00
|
|
|
+@NullMarked
|
2021-06-11 14:02:28 +02:00
|
|
|
+public class PlayerRecipeBookClickEvent extends PlayerEvent implements Cancellable {
|
2024-02-01 10:15:57 +01:00
|
|
|
+
|
|
|
|
+ private static final HandlerList HANDLER_LIST = new HandlerList();
|
|
|
|
+
|
2024-09-30 01:48:34 +02:00
|
|
|
+ private NamespacedKey recipe;
|
2021-06-11 14:02:28 +02:00
|
|
|
+ private boolean makeAll;
|
|
|
|
+
|
2024-02-01 10:15:57 +01:00
|
|
|
+ private boolean cancelled;
|
|
|
|
+
|
|
|
|
+ @ApiStatus.Internal
|
2024-09-30 01:48:34 +02:00
|
|
|
+ public PlayerRecipeBookClickEvent(final Player player, final NamespacedKey recipe, final boolean makeAll) {
|
2021-06-11 14:02:28 +02:00
|
|
|
+ super(player);
|
|
|
|
+ this.recipe = recipe;
|
|
|
|
+ this.makeAll = makeAll;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * Gets the namespaced key of the recipe that was clicked by the player
|
|
|
|
+ *
|
|
|
|
+ * @return The namespaced key of the recipe
|
|
|
|
+ */
|
|
|
|
+ public NamespacedKey getRecipe() {
|
2024-02-01 10:15:57 +01:00
|
|
|
+ return this.recipe;
|
2021-06-11 14:02:28 +02:00
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * Changes what recipe is requested. This sets the requested recipe to the recipe with the given key
|
|
|
|
+ *
|
|
|
|
+ * @param recipe The key of the recipe that should be requested
|
|
|
|
+ */
|
2024-09-30 01:48:34 +02:00
|
|
|
+ public void setRecipe(final NamespacedKey recipe) {
|
2021-06-11 14:02:28 +02:00
|
|
|
+ this.recipe = recipe;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
2024-02-01 10:15:57 +01:00
|
|
|
+ * Gets a boolean which indicates whether the player requested to make the maximum amount of results. This is
|
|
|
|
+ * {@code true} if shift is pressed while the recipe is clicked in the recipe book
|
2021-06-11 14:02:28 +02:00
|
|
|
+ *
|
|
|
|
+ * @return {@code true} if shift is pressed while the recipe is clicked
|
|
|
|
+ */
|
|
|
|
+ public boolean isMakeAll() {
|
2024-02-01 10:15:57 +01:00
|
|
|
+ return this.makeAll;
|
2021-06-11 14:02:28 +02:00
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
2024-02-01 10:15:57 +01:00
|
|
|
+ * Sets whether the maximum amount of results should be made. If this is {@code true}, the request is handled as if
|
2021-06-11 14:02:28 +02:00
|
|
|
+ * the player had pressed shift while clicking on the recipe
|
|
|
|
+ *
|
|
|
|
+ * @param makeAll {@code true} if the request should attempt to make the maximum amount of results
|
|
|
|
+ */
|
2024-09-30 01:48:34 +02:00
|
|
|
+ public void setMakeAll(final boolean makeAll) {
|
2021-06-11 14:02:28 +02:00
|
|
|
+ this.makeAll = makeAll;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public boolean isCancelled() {
|
2024-02-01 10:15:57 +01:00
|
|
|
+ return this.cancelled;
|
2021-06-11 14:02:28 +02:00
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Override
|
2024-09-30 01:48:34 +02:00
|
|
|
+ public void setCancelled(final boolean cancel) {
|
2024-02-01 10:15:57 +01:00
|
|
|
+ this.cancelled = cancel;
|
2021-06-11 14:02:28 +02:00
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public HandlerList getHandlers() {
|
2024-02-01 10:15:57 +01:00
|
|
|
+ return HANDLER_LIST;
|
2021-06-11 14:02:28 +02:00
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public static HandlerList getHandlerList() {
|
2024-02-01 10:15:57 +01:00
|
|
|
+ return HANDLER_LIST;
|
2021-06-11 14:02:28 +02:00
|
|
|
+ }
|
|
|
|
+}
|
2023-08-06 02:21:59 +02:00
|
|
|
diff --git a/src/main/java/org/bukkit/event/player/PlayerRecipeBookClickEvent.java b/src/main/java/org/bukkit/event/player/PlayerRecipeBookClickEvent.java
|
|
|
|
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
|
|
|
--- a/src/main/java/org/bukkit/event/player/PlayerRecipeBookClickEvent.java
|
|
|
|
+++ b/src/main/java/org/bukkit/event/player/PlayerRecipeBookClickEvent.java
|
|
|
|
@@ -0,0 +0,0 @@ import org.jetbrains.annotations.NotNull;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Called when a player clicks a recipe in the recipe book.
|
|
|
|
+ * @deprecated use {@link com.destroystokyo.paper.event.player.PlayerRecipeBookClickEvent}
|
|
|
|
*/
|
|
|
|
+@Deprecated(forRemoval = true) // Paper
|
|
|
|
+@org.bukkit.Warning(false) // Paper
|
|
|
|
public class PlayerRecipeBookClickEvent extends PlayerEvent {
|
|
|
|
|
|
|
|
private static final HandlerList handlers = new HandlerList();
|