-
-
Notifications
You must be signed in to change notification settings - Fork 347
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
5a007dd
commit 2cc2261
Showing
2 changed files
with
124 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
From 8c54e3cab6c7f7af57ecc3074ec8f69a570702ae Mon Sep 17 00:00:00 2001 | ||
From: Eearslya Sleiarion <eearslya@gmail.com> | ||
Date: Mon, 24 Jun 2019 21:27:39 -0700 | ||
Subject: [PATCH] Add BellRingEvent | ||
|
||
Add a new event, BellRingEvent, to trigger whenever a player rings a | ||
village bell. Passes along the bell block and the player who rang it. | ||
--- | ||
.../paper/event/block/BellRingEvent.java | 54 +++++++++++++++++++ | ||
1 file changed, 54 insertions(+) | ||
create mode 100644 src/main/java/com/destroystokyo/paper/event/block/BellRingEvent.java | ||
|
||
diff --git a/src/main/java/com/destroystokyo/paper/event/block/BellRingEvent.java b/src/main/java/com/destroystokyo/paper/event/block/BellRingEvent.java | ||
new file mode 100644 | ||
index 000000000..7b4de3f0a | ||
--- /dev/null | ||
+++ b/src/main/java/com/destroystokyo/paper/event/block/BellRingEvent.java | ||
@@ -0,0 +1,54 @@ | ||
+package com.destroystokyo.paper.event.block; | ||
+ | ||
+import org.bukkit.block.Block; | ||
+import org.bukkit.entity.Entity; | ||
+import org.bukkit.event.Cancellable; | ||
+import org.bukkit.event.HandlerList; | ||
+import org.bukkit.event.block.BlockEvent; | ||
+import org.bukkit.potion.PotionEffect; | ||
+import org.jetbrains.annotations.NotNull; | ||
+ | ||
+/** | ||
+ * Called when a bell is rung by an entity. | ||
+ */ | ||
+public class BellRingEvent extends BlockEvent implements Cancellable { | ||
+ private static final HandlerList handlers = new HandlerList(); | ||
+ private boolean cancelled; | ||
+ private Entity entity; | ||
+ | ||
+ public BellRingEvent(@NotNull Block block, @NotNull Entity entity) { | ||
+ super(block); | ||
+ this.entity = entity; | ||
+ } | ||
+ | ||
+ @Override | ||
+ public boolean isCancelled() { | ||
+ return cancelled; | ||
+ } | ||
+ | ||
+ @Override | ||
+ public void setCancelled(boolean cancelled) { | ||
+ this.cancelled = cancelled; | ||
+ } | ||
+ | ||
+ /** | ||
+ * Gets the entity that rang the bell. | ||
+ * | ||
+ * @return Entity | ||
+ */ | ||
+ @NotNull | ||
+ public Entity getEntity() { | ||
+ return entity; | ||
+ } | ||
+ | ||
+ @NotNull | ||
+ @Override | ||
+ public HandlerList getHandlers() { | ||
+ return handlers; | ||
+ } | ||
+ | ||
+ @NotNull | ||
+ public static HandlerList getHandlerList() { | ||
+ return handlers; | ||
+ } | ||
+} | ||
-- | ||
2.24.0 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
From 48c7256ee3cf1a21d8a830f12d7d5a37d859c741 Mon Sep 17 00:00:00 2001 | ||
From: Eearslya Sleiarion <eearslya@gmail.com> | ||
Date: Mon, 24 Jun 2019 21:27:32 -0700 | ||
Subject: [PATCH] Add BellRingEvent | ||
|
||
--- | ||
src/main/java/net/minecraft/server/BlockBell.java | 14 +++++++++++++- | ||
1 file changed, 13 insertions(+), 1 deletion(-) | ||
|
||
diff --git a/src/main/java/net/minecraft/server/BlockBell.java b/src/main/java/net/minecraft/server/BlockBell.java | ||
index dbdbfb8ad9..0bbd1e1594 100644 | ||
--- a/src/main/java/net/minecraft/server/BlockBell.java | ||
+++ b/src/main/java/net/minecraft/server/BlockBell.java | ||
@@ -45,7 +45,7 @@ public class BlockBell extends BlockTileEntity { | ||
Entity entity1 = ((EntityArrow) entity).getShooter(); | ||
EntityHuman entityhuman = entity1 instanceof EntityHuman ? (EntityHuman) entity1 : null; | ||
|
||
- this.a(world, iblockdata, movingobjectpositionblock, entityhuman, true); | ||
+ this.handleBellRing(world, iblockdata, movingobjectpositionblock, entityhuman, true, entity); // Purpur | ||
} | ||
|
||
} | ||
@@ -56,11 +56,23 @@ public class BlockBell extends BlockTileEntity { | ||
} | ||
|
||
public boolean a(World world, IBlockData iblockdata, MovingObjectPositionBlock movingobjectpositionblock, @Nullable EntityHuman entityhuman, boolean flag) { | ||
+ // Purpur start - BellRingEvent | ||
+ return this.handleBellRing(world, iblockdata, movingobjectpositionblock, entityhuman, true, entityhuman); | ||
+ } | ||
+ | ||
+ public boolean handleBellRing(World world, IBlockData iblockdata, MovingObjectPositionBlock movingobjectpositionblock, @Nullable EntityHuman entityhuman, boolean flag, @Nullable Entity entity) { | ||
+ // Purpur end | ||
EnumDirection enumdirection = movingobjectpositionblock.getDirection(); | ||
BlockPosition blockposition = movingobjectpositionblock.getBlockPosition(); | ||
boolean flag1 = !flag || this.a(iblockdata, enumdirection, movingobjectpositionblock.getPos().y - (double) blockposition.getY()); | ||
|
||
if (flag1) { | ||
+ // Purpur start - BellRingEvent | ||
+ org.bukkit.block.Block block = world.getWorld().getBlockAt(blockposition.getX(), blockposition.getY(), blockposition.getZ()); | ||
+ if (!new com.destroystokyo.paper.event.block.BellRingEvent(block, (org.bukkit.entity.Entity) entity.getBukkitEntity()).callEvent()) { | ||
+ return true; | ||
+ } | ||
+ // Purpur end | ||
boolean flag2 = this.a(world, blockposition, enumdirection); | ||
|
||
if (flag2 && entityhuman != null) { | ||
-- | ||
2.24.0 | ||
|