Paper/Spigot-Server-Patches/0660-Added-firing-of-PlayerChangeBeaconEffectEvent.patch
Riley Park 4e958e229f
We're going on an Adventure! (#4842)
Co-authored-by: Jake Potrebic <jake.m.potrebic@gmail.com>
Co-authored-by: zml <zml@stellardrift.ca>
Co-authored-by: Mariell Hoversholm <proximyst@proximyst.com>
2021-02-21 20:45:33 +01:00

39 lines
1.8 KiB
Diff

From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Jake Potrebic <jake.m.potrebic@gmail.com>
Date: Wed, 24 Jun 2020 15:14:51 -0600
Subject: [PATCH] Added firing of PlayerChangeBeaconEffectEvent
diff --git a/src/main/java/net/minecraft/server/ContainerBeacon.java b/src/main/java/net/minecraft/server/ContainerBeacon.java
index 288390bf9210f0fcc7c85e3093a4924614dc1573..2b09368ad998aef7d1e76a45515c6ac7ebf5c6fb 100644
--- a/src/main/java/net/minecraft/server/ContainerBeacon.java
+++ b/src/main/java/net/minecraft/server/ContainerBeacon.java
@@ -1,6 +1,9 @@
package net.minecraft.server;
import org.bukkit.craftbukkit.inventory.CraftInventoryView; // CraftBukkit
+// Paper start
+import io.papermc.paper.event.player.PlayerChangeBeaconEffectEvent;
+// Paper end
public class ContainerBeacon extends Container {
@@ -128,9 +131,15 @@ public class ContainerBeacon extends Container {
public void c(int i, int j) {
if (this.d.hasItem()) {
- this.containerProperties.setProperty(1, i);
- this.containerProperties.setProperty(2, j);
+ // Paper start
+ PlayerChangeBeaconEffectEvent event = new PlayerChangeBeaconEffectEvent((org.bukkit.entity.Player) this.player.player.getBukkitEntity(), org.bukkit.potion.PotionEffectType.getById(i), org.bukkit.potion.PotionEffectType.getById(j), this.containerAccess.getLocation().getBlock());
+ if (event.callEvent()) {
+ this.containerProperties.setProperty(1, event.getPrimary() == null ? 0 : event.getPrimary().getId());
+ this.containerProperties.setProperty(2, event.getSecondary() == null ? 0 : event.getSecondary().getId());
+ if (!event.willConsumeItem()) return;
this.d.a(1);
+ }
+ // Paper end
}
}