aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorJan Tuck <[email protected]>2020-06-22 01:16:21 +0200
committerAikar <[email protected]>2020-06-23 05:06:48 -0400
commit70df8f27161f86ffeedb5924b66a82f4499f201d (patch)
tree5c2125567bed8657e52257d71c2104586fa43894
parent24b2f54b7b7a690492b28b714075f0d3363b636e (diff)
downloadPaper-70df8f27161f86ffeedb5924b66a82f4499f201d.tar.gz
Paper-70df8f27161f86ffeedb5924b66a82f4499f201d.zip
Add PrepareGrindstoneEvent
-rw-r--r--Spigot-API-Patches/0213-Add-PrepareGrindstoneEvent.patch66
-rw-r--r--Spigot-Server-Patches/0548-Add-PrepareGrindstoneEvent.patch33
2 files changed, 99 insertions, 0 deletions
diff --git a/Spigot-API-Patches/0213-Add-PrepareGrindstoneEvent.patch b/Spigot-API-Patches/0213-Add-PrepareGrindstoneEvent.patch
new file mode 100644
index 0000000000..fa5a9fb527
--- /dev/null
+++ b/Spigot-API-Patches/0213-Add-PrepareGrindstoneEvent.patch
@@ -0,0 +1,66 @@
+From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
+From: Jan Tuck <[email protected]>
+Date: Sat, 20 Jun 2020 22:34:21 +0200
+Subject: [PATCH] Add PrepareGrindstoneEvent
+
+
+diff --git a/src/main/java/com/destroystokyo/paper/event/inventory/PrepareGrindstoneEvent.java b/src/main/java/com/destroystokyo/paper/event/inventory/PrepareGrindstoneEvent.java
+new file mode 100644
+index 0000000000000000000000000000000000000000..889185bf73ef2d834e5d416d1cf13c2363453c42
+--- /dev/null
++++ b/src/main/java/com/destroystokyo/paper/event/inventory/PrepareGrindstoneEvent.java
+@@ -0,0 +1,54 @@
++package com.destroystokyo.paper.event.inventory;
++
++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.NotNull;
++import org.jetbrains.annotations.Nullable;
++
++/**
++ * Called when an item is put in a slot for grinding in a Grindstone
++ */
++public class PrepareGrindstoneEvent extends InventoryEvent {
++
++ private static final HandlerList handlers = new HandlerList();
++ private ItemStack result;
++
++ public PrepareGrindstoneEvent(@NotNull InventoryView inventory, @Nullable ItemStack result) {
++ super(inventory);
++ this.result = result;
++ }
++
++ @NotNull
++ @Override
++ public GrindstoneInventory getInventory() {
++ return (GrindstoneInventory) super.getInventory();
++ }
++
++ /**
++ * Get result item, may be null.
++ *
++ * @return result item
++ */
++ @Nullable
++ public ItemStack getResult() {
++ return result;
++ }
++
++ public void setResult(@Nullable ItemStack result) {
++ this.result = result;
++ }
++
++ @NotNull
++ @Override
++ public HandlerList getHandlers() {
++ return handlers;
++ }
++
++ @NotNull
++ public static HandlerList getHandlerList() {
++ return handlers;
++ }
++}
diff --git a/Spigot-Server-Patches/0548-Add-PrepareGrindstoneEvent.patch b/Spigot-Server-Patches/0548-Add-PrepareGrindstoneEvent.patch
new file mode 100644
index 0000000000..f0a00ab8ed
--- /dev/null
+++ b/Spigot-Server-Patches/0548-Add-PrepareGrindstoneEvent.patch
@@ -0,0 +1,33 @@
+From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
+From: Jan Tuck <[email protected]>
+Date: Sat, 20 Jun 2020 22:34:20 +0200
+Subject: [PATCH] Add PrepareGrindstoneEvent
+
+
+diff --git a/src/main/java/net/minecraft/server/ContainerGrindstone.java b/src/main/java/net/minecraft/server/ContainerGrindstone.java
+index ed88e208d00f3b19b5c5916cf87513ab511a5fb1..83cb0cd64c81eb35fa49eecff93b40f08e0a5606 100644
+--- a/src/main/java/net/minecraft/server/ContainerGrindstone.java
++++ b/src/main/java/net/minecraft/server/ContainerGrindstone.java
+@@ -10,6 +10,10 @@ import org.bukkit.craftbukkit.inventory.CraftInventoryGrindstone;
+ import org.bukkit.craftbukkit.inventory.CraftInventoryView;
+ import org.bukkit.entity.Player;
+ // CraftBukkit end
++// Paper start
++import org.bukkit.craftbukkit.inventory.CraftItemStack;
++import com.destroystokyo.paper.event.inventory.PrepareGrindstoneEvent;
++// Paper end
+
+ public class ContainerGrindstone extends Container {
+
+@@ -144,6 +148,11 @@ public class ContainerGrindstone extends Container {
+ super.a(iinventory);
+ if (iinventory == this.craftInventory) {
+ this.e();
++ // Paper start
++ PrepareGrindstoneEvent event = new PrepareGrindstoneEvent(this.getBukkitView(), CraftItemStack.asBukkitCopy(this.resultInventory.getItem(0)));
++ event.callEvent();
++ this.resultInventory.setItem(0, CraftItemStack.asNMSCopy(event.getResult()));
++ // Paper end
+ }
+
+ }