2016-05-12 04:07:46 +02:00
From 44536adaf25c092b8223739374361ebc14b260bf Mon Sep 17 00:00:00 2001
2016-03-01 00:09:49 +01:00
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
2016-05-12 04:07:46 +02:00
index bb771c1..77170aa 100644
2016-03-01 00:09:49 +01:00
--- a/src/main/java/net/minecraft/server/TileEntityBeacon.java
+++ b/src/main/java/net/minecraft/server/TileEntityBeacon.java
2016-05-12 04:07:46 +02:00
@@ -14,6 +14,15 @@ import org.bukkit.craftbukkit.entity.CraftHumanEntity;
2016-03-01 00:09:49 +01:00
import org.bukkit.entity.HumanEntity;
// CraftBukkit end
+// Paper start
+import org.bukkit.craftbukkit.event.CraftEventFactory;
2016-03-12 03:36:47 +01:00
+import org.bukkit.craftbukkit.potion.CraftPotionUtil;
2016-03-01 00:09:49 +01:00
+import org.bukkit.entity.Player;
2016-03-12 03:36:47 +01:00
+import org.bukkit.potion.PotionData;
2016-03-01 00:09:49 +01:00
+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}};
2016-05-12 04:07:46 +02:00
@@ -88,17 +97,33 @@ public class TileEntityBeacon extends TileEntityContainer implements ITickable,
2016-03-01 00:09:49 +01:00
EntityHuman entityhuman;
+ // Paper start
+ org.bukkit.block.Block block = world.getWorld().getBlockAt(position.getX(), position.getY(), position.getZ());
2016-03-12 03:36:47 +01:00
+ PotionEffect primaryEffect = CraftPotionUtil.toBukkit(new MobEffect(this.l, i, b0, true, true));
2016-03-01 00:09:49 +01:00
+ // Paper end
+
while (iterator.hasNext()) {
entityhuman = (EntityHuman) iterator.next();
- entityhuman.addEffect(new MobEffect(this.l, i, b0, true, true));
+ // Paper start - BeaconEffectEvent
+ BeaconEffectEvent event = new BeaconEffectEvent(block, primaryEffect, (Player) entityhuman.getBukkitEntity(), true);
+ if (CraftEventFactory.callEvent(event).isCancelled()) continue;
+ PotionEffect effect = event.getEffect();
2016-03-19 02:45:22 +01:00
+ entityhuman.getBukkitEntity().addPotionEffect(effect, true);
2016-03-01 00:09:49 +01:00
+ // Paper end
}
if (this.k >= 4 && this.l != this.m && this.m != null) {
iterator = list.iterator();
2016-03-12 03:36:47 +01:00
+ PotionEffect secondaryEffect = org.bukkit.craftbukkit.potion.CraftPotionUtil.toBukkit(new MobEffect(this.m, i, 0, true, true)); // Paper
2016-03-01 00:09:49 +01:00
while (iterator.hasNext()) {
entityhuman = (EntityHuman) iterator.next();
- entityhuman.addEffect(new MobEffect(this.m, i, 0, true, true));
+ // Paper start - BeaconEffectEvent
+ BeaconEffectEvent event = new BeaconEffectEvent(block, secondaryEffect, (Player) entityhuman.getBukkitEntity(), false);
+ if (CraftEventFactory.callEvent(event).isCancelled()) continue;
+ PotionEffect effect = event.getEffect();
2016-05-08 22:33:53 +02:00
+ entityhuman.getBukkitEntity().addPotionEffect(effect, true);
2016-03-01 00:09:49 +01:00
+ // Paper end
}
}
}
--
2016-05-08 22:33:53 +02:00
2.8.2
2016-03-01 00:09:49 +01:00