PaperMC/Spigot-Server-Patches/Add-BeaconEffectEvent.patch

63 lines
3.3 KiB
Diff
Raw Normal View History

2015-07-23 21:57:12 +02:00
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Byteflux <byte@byteflux.net>
2016-03-01 00:09:49 +01:00
Date: Wed, 2 Mar 2016 23:30:53 -0600
2015-07-23 21:57:12 +02:00
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 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
--- a/src/main/java/net/minecraft/server/TileEntityBeacon.java
+++ b/src/main/java/net/minecraft/server/TileEntityBeacon.java
@@ -0,0 +0,0 @@ import org.bukkit.craftbukkit.entity.CraftHumanEntity;
import org.bukkit.entity.HumanEntity;
// CraftBukkit end
2016-03-01 00:09:49 +01:00
+// Paper start
2015-07-23 21:57:12 +02:00
+import org.bukkit.craftbukkit.event.CraftEventFactory;
+import org.bukkit.craftbukkit.potion.CraftPotionUtil;
2015-07-23 21:57:12 +02:00
+import org.bukkit.entity.Player;
+import org.bukkit.potion.PotionData;
2015-07-23 21:57:12 +02:00
+import org.bukkit.potion.PotionEffect;
2016-03-01 00:09:49 +01:00
+import com.destroystokyo.paper.event.block.BeaconEffectEvent;
+// Paper end
2015-07-23 21:57:12 +02:00
+
2016-03-01 00:09:49 +01:00
public class TileEntityBeacon extends TileEntityContainer implements ITickable, IWorldInventory {
2015-07-23 21:57:12 +02:00
2016-03-01 00:09:49 +01:00
public static final MobEffectList[][] a = new MobEffectList[][] { { MobEffects.FASTER_MOVEMENT, MobEffects.FASTER_DIG}, { MobEffects.RESISTANCE, MobEffects.JUMP}, { MobEffects.INCREASE_DAMAGE}, { MobEffects.REGENERATION}};
@@ -0,0 +0,0 @@ public class TileEntityBeacon extends TileEntityContainer implements ITickable,
2015-07-23 21:57:12 +02:00
EntityHuman entityhuman;
2016-03-01 00:09:49 +01:00
+ // Paper start
+ org.bukkit.block.Block block = world.getWorld().getBlockAt(position.getX(), position.getY(), position.getZ());
+ PotionEffect primaryEffect = CraftPotionUtil.toBukkit(new MobEffect(this.l, i, b0, true, true));
2016-03-01 00:09:49 +01:00
+ // Paper end
+
2015-07-23 21:57:12 +02:00
while (iterator.hasNext()) {
entityhuman = (EntityHuman) iterator.next();
2016-03-01 00:09:49 +01:00
- entityhuman.addEffect(new MobEffect(this.l, i, b0, true, true));
+ // Paper start - BeaconEffectEvent
2015-07-23 21:57:12 +02:00
+ BeaconEffectEvent event = new BeaconEffectEvent(block, primaryEffect, (Player) entityhuman.getBukkitEntity(), true);
+ if (CraftEventFactory.callEvent(event).isCancelled()) continue;
+ PotionEffect effect = event.getEffect();
+ entityhuman.getBukkitEntity().addPotionEffect(effect, true);
2016-03-01 00:09:49 +01:00
+ // Paper end
2015-07-23 21:57:12 +02:00
}
2016-03-01 00:09:49 +01:00
if (this.k >= 4 && this.l != this.m && this.m != null) {
2015-07-23 21:57:12 +02:00
iterator = list.iterator();
+ PotionEffect secondaryEffect = org.bukkit.craftbukkit.potion.CraftPotionUtil.toBukkit(new MobEffect(this.m, i, 0, true, true)); // Paper
2015-07-23 21:57:12 +02:00
while (iterator.hasNext()) {
entityhuman = (EntityHuman) iterator.next();
2016-03-01 00:09:49 +01:00
- entityhuman.addEffect(new MobEffect(this.m, i, 0, true, true));
+ // Paper start - BeaconEffectEvent
2015-07-23 21:57:12 +02:00
+ BeaconEffectEvent event = new BeaconEffectEvent(block, secondaryEffect, (Player) entityhuman.getBukkitEntity(), false);
+ if (CraftEventFactory.callEvent(event).isCancelled()) continue;
+ PotionEffect effect = event.getEffect();
+ entityhuman.getBukkitEntity().addPotionEffect(effect);
2016-03-01 00:09:49 +01:00
+ // Paper end
2015-07-23 21:57:12 +02:00
}
}
}
--