Paper/Spigot-Server-Patches/0045-Add-BeaconEffectEvent.patch
Zach Brown c02c01b2c5
Add rate limiting to PacketPlayInUseItem as well
Also removes our toggle for Spigot's option, I doubt anyone uses it.
2016-09-10 21:44:06 -05:00

74 lines
3.1 KiB
Diff

From 22b4e5883590e2eaf7bc9b74535c121415f700e2 Mon Sep 17 00:00:00 2001
From: Byteflux <byte@byteflux.net>
Date: Wed, 2 Mar 2016 23:30:53 -0600
Subject: [PATCH] Add BeaconEffectEvent
diff --git a/src/main/java/net/minecraft/server/TileEntityBeacon.java b/src/main/java/net/minecraft/server/TileEntityBeacon.java
index 48f8793..9b0a1c4 100644
--- a/src/main/java/net/minecraft/server/TileEntityBeacon.java
+++ b/src/main/java/net/minecraft/server/TileEntityBeacon.java
@@ -16,6 +16,14 @@ import org.bukkit.entity.HumanEntity;
import org.bukkit.potion.PotionEffect;
// CraftBukkit end
+// Paper start
+import org.bukkit.craftbukkit.event.CraftEventFactory;
+import org.bukkit.entity.Player;
+import org.bukkit.potion.PotionData;
+import org.bukkit.potion.PotionEffect;
+import com.destroystokyo.paper.event.block.BeaconEffectEvent;
+// Paper end
+
public class TileEntityBeacon extends TileEntityContainer implements ITickable, IWorldInventory {
public static final MobEffectList[][] a = new MobEffectList[][] { { MobEffects.FASTER_MOVEMENT, MobEffects.FASTER_DIG}, { MobEffects.RESISTANCE, MobEffects.JUMP}, { MobEffects.INCREASE_DAMAGE}, { MobEffects.REGENERATION}};
@@ -114,14 +122,30 @@ public class TileEntityBeacon extends TileEntityContainer implements ITickable,
}
private void applyEffect(List list, MobEffectList effects, int i, int b0) {
+ // Paper - BeaconEffectEvent
+ applyEffect(list, effects, i, b0, true);
+ }
+
+ private void applyEffect(List list, MobEffectList effects, int i, int b0, boolean isPrimary) {
+ // Paper - BeaconEffectEvent
{
Iterator iterator = list.iterator();
EntityHuman entityhuman;
+ // Paper start - BeaconEffectEvent
+ org.bukkit.block.Block block = world.getWorld().getBlockAt(position.getX(), position.getY(), position.getZ());
+ PotionEffect effect = CraftPotionUtil.toBukkit(new MobEffect(effects, i, b0, true, true));
+ // Paper end
+
while (iterator.hasNext()) {
entityhuman = (EntityHuman) iterator.next();
- entityhuman.addEffect(new MobEffect(effects, i, b0, true, true));
+ // Paper start - BeaconEffectEvent
+ BeaconEffectEvent event = new BeaconEffectEvent(block, effect, (Player) entityhuman.getBukkitEntity(), isPrimary);
+ if (CraftEventFactory.callEvent(event).isCancelled()) continue;
+ PotionEffect eventEffect = event.getEffect();
+ entityhuman.getBukkitEntity().addPotionEffect(eventEffect, true);
+ // Paper end
}
}
}
@@ -143,10 +167,10 @@ public class TileEntityBeacon extends TileEntityContainer implements ITickable,
int i = getLevel();
List list = getHumansInRange();
- applyEffect(list, this.l, i, b0);
+ applyEffect(list, this.l, i, b0, true); // Paper - BeaconEffectEvent
if (hasSecondaryEffect()) {
- applyEffect(list, this.m, i, 0);
+ applyEffect(list, this.m, i, 0, false); // Paper - BeaconEffectEvent
}
}
--
2.10.0.windows.1