Paper/Spigot-API-Patches/0211-Add-and-implement-PlayerRecipeBookClickEvent.patch
Daniel Ennis c97ce029e9
1.16.2 Release (#4123)
PaperMC believes that 1.16.2 is now ready for general release as we fixed the main issue plagueing the 1.16.x release, the MapLike data conversion issues.

Until now, it was not safe for a server to convert a world to 1.16.2 without data conversion issues around villages and potentially other things. If you did, those MapLike errors meant something went wrong.

This is now resolved.

Big thanks to all those that helped, notably @BillyGalbreath and @Proximyst who did large parts of the update process with me.

Please as always, backup your worlds and test before updating to 1.16.2!

If you update to 1.16.2, there is no going back to an older build than this.

---------------------------------

Co-authored-by: William Blake Galbreath <Blake.Galbreath@GMail.com>
Co-authored-by: Mariell Hoversholm <proximyst@proximyst.com>
Co-authored-by: krolik-exe <69214078+krolik-exe@users.noreply.github.com>
Co-authored-by: BillyGalbreath <BillyGalbreath@users.noreply.github.com>
Co-authored-by: stonar96 <minecraft.stonar96@gmail.com>
Co-authored-by: Shane Freeder <theboyetronic@gmail.com>
Co-authored-by: Jason <jasonpenilla2@me.com>
Co-authored-by: kashike <kashike@vq.lc>
Co-authored-by: Aurora <21148213+aurorasmiles@users.noreply.github.com>
Co-authored-by: KennyTV <kennytv@t-online.de>
Co-authored-by: commandblockguy <commandblockguy1@gmail.com>
Co-authored-by: DigitalRegent <misterwener@gmail.com>
Co-authored-by: ishland <ishlandmc@yeah.net>
2020-08-24 22:40:19 -04:00

97 Zeilen
3.1 KiB
Diff

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..7fa937d339ee98ad308deebb523fead6522eb262
--- /dev/null
+++ b/src/main/java/com/destroystokyo/paper/event/player/PlayerRecipeBookClickEvent.java
@@ -0,0 +1,84 @@
+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;
+import org.jetbrains.annotations.NotNull;
+
+/**
+ * Called when a player clicks a recipe in the recipe book
+ */
+public class PlayerRecipeBookClickEvent extends PlayerEvent implements Cancellable {
+ private static final HandlerList handlers = new HandlerList();
+ private boolean cancel = false;
+ @NotNull private NamespacedKey recipe;
+ private boolean makeAll;
+
+ public PlayerRecipeBookClickEvent(@NotNull Player player, @NotNull NamespacedKey recipe, boolean makeAll) {
+ 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
+ */
+ @NotNull
+ public NamespacedKey getRecipe() {
+ return recipe;
+ }
+
+ /**
+ * 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
+ */
+ public void setRecipe(@NotNull NamespacedKey recipe) {
+ this.recipe = recipe;
+ }
+
+ /**
+ * Gets a boolean which indicates whether or not the player requested to make the maximum amount of results. This is
+ * true if shift is pressed while the recipe is clicked in the recipe book
+ *
+ * @return {@code true} if shift is pressed while the recipe is clicked
+ */
+ public boolean isMakeAll() {
+ return makeAll;
+ }
+
+ /**
+ * Sets whether or not the maximum amount of results should be made. If this is true, the request is handled as if
+ * 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
+ */
+ public void setMakeAll(boolean makeAll) {
+ this.makeAll = makeAll;
+ }
+
+ @Override
+ public boolean isCancelled() {
+ return cancel;
+ }
+
+ @Override
+ public void setCancelled(boolean cancel) {
+ this.cancel = cancel;
+ }
+
+ @NotNull
+ @Override
+ public HandlerList getHandlers() {
+ return handlers;
+ }
+
+ @NotNull
+ public static HandlerList getHandlerList() {
+ return handlers;
+ }
+}