Files
Purpur/patches/unapplied-api/0033-Grindstone-API.patch
2024-12-03 20:24:56 -08:00

85 lines
2.7 KiB
Diff

From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: BillyGalbreath <blake.galbreath@gmail.com>
Date: Mon, 27 Dec 2021 08:10:50 -0600
Subject: [PATCH] Grindstone API
diff --git a/src/main/java/org/purpurmc/purpur/event/inventory/GrindstoneTakeResultEvent.java b/src/main/java/org/purpurmc/purpur/event/inventory/GrindstoneTakeResultEvent.java
new file mode 100644
index 0000000000000000000000000000000000000000..d6db2d355553c9c54b83328d237b9c75e7a8e375
--- /dev/null
+++ b/src/main/java/org/purpurmc/purpur/event/inventory/GrindstoneTakeResultEvent.java
@@ -0,0 +1,72 @@
+package org.purpurmc.purpur.event.inventory;
+
+import org.bukkit.entity.HumanEntity;
+import org.bukkit.entity.Player;
+import org.bukkit.event.HandlerList;
+import org.bukkit.event.inventory.InventoryEvent;
+import org.bukkit.inventory.GrindstoneInventory;
+import org.bukkit.inventory.InventoryView;
+import org.bukkit.inventory.ItemStack;
+import org.jetbrains.annotations.ApiStatus;
+import org.jspecify.annotations.NullMarked;
+
+/**
+ * Called when a player takes the result item out of a Grindstone
+ */
+@NullMarked
+public class GrindstoneTakeResultEvent extends InventoryEvent {
+ private static final HandlerList handlers = new HandlerList();
+ private final Player player;
+ private final ItemStack result;
+ private int experienceAmount;
+
+ @ApiStatus.Internal
+ public GrindstoneTakeResultEvent(HumanEntity player, InventoryView view, ItemStack result, int experienceAmount) {
+ super(view);
+ this.player = (Player) player;
+ this.result = result;
+ this.experienceAmount = experienceAmount;
+ }
+
+ public Player getPlayer() {
+ return player;
+ }
+
+ public ItemStack getResult() {
+ return result;
+ }
+
+ @Override
+ public GrindstoneInventory getInventory() {
+ return (GrindstoneInventory) super.getInventory();
+ }
+
+ /**
+ * Get the amount of experience this transaction will give
+ * (takes priority over and uses result from {@link org.bukkit.event.block.BlockExpEvent})
+ *
+ * @return Amount of experience to give
+ */
+ public int getExperienceAmount() {
+ return this.experienceAmount;
+ }
+
+ /**
+ * Set the amount of experience this transaction will give
+ * (takes priority over {@link org.bukkit.event.block.BlockExpEvent})
+ *
+ * @param experienceAmount Amount of experience to give
+ */
+ public void setExperienceAmount(int experienceAmount) {
+ this.experienceAmount = experienceAmount;
+ }
+
+ @Override
+ public HandlerList getHandlers() {
+ return handlers;
+ }
+
+ public static HandlerList getHandlerList() {
+ return handlers;
+ }
+}