PaperMC/Spigot-Server-Patches/0038-Add-BeaconEffectEvent.patch
Zach Brown 70ce6ce831
Move version command update checking to the implementation
This makes it easier for downstream projects (forks) to replace the
version fetching system with their own. It is as simple as implementing
an interface and overriding the default implementation of
org.bukkit.UnsafeValues#getVersionFetcher()

It also makes it easier for us to organize things like the version
history feature.

Lastly I have updated the paper implementation to check against the site
API rather than against jenkins.
2019-05-27 04:13:41 -05:00

71 lines
3.1 KiB
Diff

From 41c3aa292936f2d523dfbd56f40d3a82262cde95 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 8fd4f4bf7..0612a446a 100644
--- a/src/main/java/net/minecraft/server/TileEntityBeacon.java
+++ b/src/main/java/net/minecraft/server/TileEntityBeacon.java
@@ -14,6 +14,11 @@ import org.bukkit.craftbukkit.potion.CraftPotionUtil;
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 com.destroystokyo.paper.event.block.BeaconEffectEvent;
+// Paper end
public class TileEntityBeacon extends TileEntity implements ITileInventory, ITickable {
@@ -235,14 +240,31 @@ public class TileEntityBeacon extends TileEntity implements ITileInventory, ITic
}
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), org.bukkit.event.entity.EntityPotionEffectEvent.Cause.BEACON);
+
+ // Paper start - BeaconEffectEvent
+ BeaconEffectEvent event = new BeaconEffectEvent(block, effect, (Player) entityhuman.getBukkitEntity(), isPrimary);
+ if (CraftEventFactory.callEvent(event).isCancelled()) continue;
+ PotionEffect eventEffect = event.getEffect();
+ entityhuman.addEffect(new MobEffect(MobEffectList.fromId(eventEffect.getType().getId()), eventEffect.getDuration(), eventEffect.getAmplifier(), true, true), org.bukkit.event.entity.EntityPotionEffectEvent.Cause.BEACON);
+ // Paper end
}
}
}
@@ -265,10 +287,10 @@ public class TileEntityBeacon extends TileEntity implements ITileInventory, ITic
int i = getLevel();
List list = getHumansInRange();
- applyEffect(list, this.primaryEffect, i, b0);
+ applyEffect(list, this.primaryEffect, i, b0, true); // Paper - BeaconEffectEvent
if (hasSecondaryEffect()) {
- applyEffect(list, this.secondaryEffect, i, 0);
+ applyEffect(list, this.secondaryEffect, i, 0, false); // Paper - BeaconEffectEvent
}
}
--
2.21.0