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

74 Zeilen
3.1 KiB
Diff

2016-07-27 02:30:03 +02:00
From a73b6bfd3a69352a8bf17b618de3549a8a32dbc4 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-07-27 02:30:03 +02:00
index 48f8793..9b0a1c4 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-07-27 02:30:03 +02:00
@@ -16,6 +16,14 @@ import org.bukkit.entity.HumanEntity;
import org.bukkit.potion.PotionEffect;
2016-03-01 00:09:49 +01:00
// CraftBukkit end
+// Paper start
+import org.bukkit.craftbukkit.event.CraftEventFactory;
+import org.bukkit.entity.Player;
+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-07-27 02:30:03 +02:00
@@ -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();
2016-03-01 00:09:49 +01:00
EntityHuman entityhuman;
2016-07-27 02:30:03 +02:00
+ // Paper start - BeaconEffectEvent
2016-03-01 00:09:49 +01:00
+ org.bukkit.block.Block block = world.getWorld().getBlockAt(position.getX(), position.getY(), position.getZ());
2016-07-27 02:30:03 +02:00
+ PotionEffect effect = CraftPotionUtil.toBukkit(new MobEffect(effects, i, b0, true, true));
2016-03-01 00:09:49 +01:00
+ // Paper end
+
while (iterator.hasNext()) {
entityhuman = (EntityHuman) iterator.next();
2016-07-27 02:30:03 +02:00
- entityhuman.addEffect(new MobEffect(effects, i, b0, true, true));
2016-03-01 00:09:49 +01:00
+ // Paper start - BeaconEffectEvent
2016-07-27 02:30:03 +02:00
+ BeaconEffectEvent event = new BeaconEffectEvent(block, effect, (Player) entityhuman.getBukkitEntity(), isPrimary);
2016-03-01 00:09:49 +01:00
+ if (CraftEventFactory.callEvent(event).isCancelled()) continue;
2016-07-27 02:30:03 +02:00
+ PotionEffect eventEffect = event.getEffect();
+ entityhuman.getBukkitEntity().addPotionEffect(eventEffect, true);
2016-03-01 00:09:49 +01:00
+ // Paper end
}
2016-07-27 02:30:03 +02:00
}
}
@@ -143,10 +167,10 @@ public class TileEntityBeacon extends TileEntityContainer implements ITickable,
int i = getLevel();
List list = getHumansInRange();
2016-03-01 00:09:49 +01:00
2016-07-27 02:30:03 +02:00
- applyEffect(list, this.l, i, b0);
+ applyEffect(list, this.l, i, b0, true); // Paper - BeaconEffectEvent
2016-03-01 00:09:49 +01:00
2016-07-27 02:30:03 +02:00
if (hasSecondaryEffect()) {
- applyEffect(list, this.m, i, 0);
+ applyEffect(list, this.m, i, 0, false); // Paper - BeaconEffectEvent
2016-03-01 00:09:49 +01:00
}
}
2016-07-27 02:30:03 +02:00
2016-03-01 00:09:49 +01:00
--
2016-07-27 02:30:03 +02:00
2.9.0
2016-03-01 00:09:49 +01:00