mirror of
https://github.com/PaperMC/Paper.git
synced 2024-11-13 22:25:31 +01:00
40 lines
2.0 KiB
Diff
40 lines
2.0 KiB
Diff
|
@@ -1,5 +1,11 @@
|
||
|
package net.minecraft.server;
|
||
|
|
||
|
+// CraftBukkit start
|
||
|
+import org.bukkit.entity.Player;
|
||
|
+import org.bukkit.event.hanging.HangingPlaceEvent;
|
||
|
+import org.bukkit.event.painting.PaintingPlaceEvent;
|
||
|
+// CraftBukkit end
|
||
|
+
|
||
|
public class ItemHanging extends Item {
|
||
|
|
||
|
private final Class a;
|
||
|
@@ -24,6 +30,26 @@
|
||
|
|
||
|
if (entityhanging != null && entityhanging.survives()) {
|
||
|
if (!world.isStatic) {
|
||
|
+ // CraftBukkit start - fire HangingPlaceEvent
|
||
|
+ Player who = (entityhuman == null) ? null : (Player) entityhuman.getBukkitEntity();
|
||
|
+ org.bukkit.block.Block blockClicked = world.getWorld().getBlockAt(blockposition.getX(), blockposition.getY(), blockposition.getZ());
|
||
|
+ org.bukkit.block.BlockFace blockFace = org.bukkit.craftbukkit.block.CraftBlock.notchToBlockFace(enumdirection);
|
||
|
+
|
||
|
+ HangingPlaceEvent event = new HangingPlaceEvent((org.bukkit.entity.Hanging) entityhanging.getBukkitEntity(), who, blockClicked, blockFace);
|
||
|
+ world.getServer().getPluginManager().callEvent(event);
|
||
|
+
|
||
|
+ PaintingPlaceEvent paintingEvent = null;
|
||
|
+ if (entityhanging instanceof EntityPainting) {
|
||
|
+ // Fire old painting event until it can be removed
|
||
|
+ paintingEvent = new PaintingPlaceEvent((org.bukkit.entity.Painting) entityhanging.getBukkitEntity(), who, blockClicked, blockFace);
|
||
|
+ paintingEvent.setCancelled(event.isCancelled());
|
||
|
+ world.getServer().getPluginManager().callEvent(paintingEvent);
|
||
|
+ }
|
||
|
+
|
||
|
+ if (event.isCancelled() || (paintingEvent != null && paintingEvent.isCancelled())) {
|
||
|
+ return false;
|
||
|
+ }
|
||
|
+ // CraftBukkit end
|
||
|
world.addEntity(entityhanging);
|
||
|
}
|
||
|
|