SPIGOT-4889: Add PlayerTakeLecternBookEvent

This commit is contained in:
Brokkonaut 2019-05-07 17:15:32 +02:00 committed by md_5
parent 7d29eb5e5a
commit 5c0d3b25e8

View file

@ -1,12 +1,14 @@
--- a/net/minecraft/server/ContainerLectern.java --- a/net/minecraft/server/ContainerLectern.java
+++ b/net/minecraft/server/ContainerLectern.java +++ b/net/minecraft/server/ContainerLectern.java
@@ -1,15 +1,38 @@ @@ -1,15 +1,40 @@
package net.minecraft.server; package net.minecraft.server;
+// CraftBukkit start +// CraftBukkit start
+import org.bukkit.Bukkit;
+import org.bukkit.craftbukkit.inventory.CraftInventoryLectern; +import org.bukkit.craftbukkit.inventory.CraftInventoryLectern;
+import org.bukkit.craftbukkit.inventory.CraftInventoryView; +import org.bukkit.craftbukkit.inventory.CraftInventoryView;
+import org.bukkit.entity.Player; +import org.bukkit.entity.Player;
+import org.bukkit.event.player.PlayerTakeLecternBookEvent;
+// CraftBukkit end +// CraftBukkit end
+ +
public class ContainerLectern extends Container { public class ContainerLectern extends Container {
@ -42,7 +44,7 @@
super(Containers.LECTERN, i); super(Containers.LECTERN, i);
a(iinventory, 1); a(iinventory, 1);
a(icontainerproperties, 1); a(icontainerproperties, 1);
@@ -23,6 +46,7 @@ @@ -23,6 +48,7 @@
} }
}); });
this.a(icontainerproperties); this.a(icontainerproperties);
@ -50,7 +52,21 @@
} }
@Override @Override
@@ -70,6 +94,7 @@ @@ -48,6 +74,13 @@
return false;
}
+ // CraftBukkit start - Event for taking the book
+ PlayerTakeLecternBookEvent event = new PlayerTakeLecternBookEvent(player, ((CraftInventoryLectern) getBukkitView().getTopInventory()).getHolder());
+ Bukkit.getServer().getPluginManager().callEvent(event);
+ if (event.isCancelled()) {
+ return false;
+ }
+ // CraftBukkit end
ItemStack itemstack = this.inventory.splitWithoutUpdate(0);
this.inventory.update();
@@ -70,6 +103,7 @@
@Override @Override
public boolean canUse(EntityHuman entityhuman) { public boolean canUse(EntityHuman entityhuman) {