Paper/Spigot-Server-Patches/0046-Add-BeaconEffectEvent.patch

78 Zeilen
4.0 KiB
Diff

2016-03-01 00:09:49 +01:00
From dc65a8bcffb8c2767d4907e60d516b57f401730e 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/MobEffectList.java b/src/main/java/net/minecraft/server/MobEffectList.java
index 24ae8e2..a5cbda5 100644
--- a/src/main/java/net/minecraft/server/MobEffectList.java
+++ b/src/main/java/net/minecraft/server/MobEffectList.java
@@ -17,7 +17,7 @@ public class MobEffectList {
private final Map<IAttribute, AttributeModifier> a = Maps.newHashMap();
private final boolean c;
private final int d;
- private String e = "";
+ public String e = ""; // Paper - private -> public
private int f = -1;
public double durationModifier;
private boolean h;
diff --git a/src/main/java/net/minecraft/server/TileEntityBeacon.java b/src/main/java/net/minecraft/server/TileEntityBeacon.java
index ed5b374..6615890 100644
--- a/src/main/java/net/minecraft/server/TileEntityBeacon.java
+++ b/src/main/java/net/minecraft/server/TileEntityBeacon.java
@@ -13,6 +13,14 @@ import org.bukkit.craftbukkit.entity.CraftHumanEntity;
import org.bukkit.entity.HumanEntity;
// CraftBukkit end
+// Paper start
+import org.bukkit.craftbukkit.event.CraftEventFactory;
+import org.bukkit.entity.Player;
+import org.bukkit.potion.PotionEffect;
+import org.bukkit.potion.PotionEffectType;
+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}};
@@ -85,17 +93,33 @@ public class TileEntityBeacon extends TileEntityContainer implements ITickable,
EntityHuman entityhuman;
+ // Paper start
+ org.bukkit.block.Block block = world.getWorld().getBlockAt(position.getX(), position.getY(), position.getZ());
+ PotionEffect primaryEffect = new PotionEffect(PotionEffectType.getByName(this.l.e), 180, b0, true, true);
+ // 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();
+ entityhuman.addEffect(new MobEffect(MobEffectList.fromId(effect.getType().getId()), effect.getDuration(), effect.getAmplifier(), effect.isAmbient(), effect.hasParticles()));
+ // Paper end
}
if (this.k >= 4 && this.l != this.m && this.m != null) {
iterator = list.iterator();
+ PotionEffect secondaryEffect = new PotionEffect(PotionEffectType.getByName(this.m.e), 180, 0, true, true); // Paper
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();
+ entityhuman.addEffect(new MobEffect(MobEffectList.fromId(effect.getType().getId()), effect.getDuration(), effect.getAmplifier(), effect.isAmbient(), effect.hasParticles()));
+ // Paper end
}
}
}
--
2.7.2