mirror of
https://github.com/PaperMC/Paper.git
synced 2024-11-26 17:17:13 +01:00
Add BeaconEffectEvent
This commit is contained in:
parent
16ab69f11b
commit
7d9632e328
2 changed files with 139 additions and 0 deletions
73
Spigot-API-Patches/0013-Add-BeaconEffectEvent.patch
Normal file
73
Spigot-API-Patches/0013-Add-BeaconEffectEvent.patch
Normal file
|
@ -0,0 +1,73 @@
|
|||
From fb47713bc3aa1e7c44c50caacd86b3a29a275203 Mon Sep 17 00:00:00 2001
|
||||
From: Byteflux <byte@byteflux.net>
|
||||
Date: Thu, 23 Jul 2015 11:45:20 -0700
|
||||
Subject: [PATCH] Add BeaconEffectEvent
|
||||
|
||||
|
||||
diff --git a/src/main/java/org/github/paperspigot/event/block/BeaconEffectEvent.java b/src/main/java/org/github/paperspigot/event/block/BeaconEffectEvent.java
|
||||
new file mode 100644
|
||||
index 0000000..9bc14a2
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/org/github/paperspigot/event/block/BeaconEffectEvent.java
|
||||
@@ -0,0 +1,58 @@
|
||||
+package org.github.paperspigot.event.block;
|
||||
+
|
||||
+import org.bukkit.block.Block;
|
||||
+import org.bukkit.entity.Player;
|
||||
+import org.bukkit.event.Cancellable;
|
||||
+import org.bukkit.event.HandlerList;
|
||||
+import org.bukkit.event.block.BlockEvent;
|
||||
+import org.bukkit.potion.PotionEffect;
|
||||
+
|
||||
+public class BeaconEffectEvent extends BlockEvent implements Cancellable {
|
||||
+ private static final HandlerList handlers = new HandlerList();
|
||||
+ private boolean cancelled;
|
||||
+ private PotionEffect effect;
|
||||
+ private Player player;
|
||||
+ private boolean primary;
|
||||
+
|
||||
+ public BeaconEffectEvent(Block block, PotionEffect effect, Player player, boolean primary) {
|
||||
+ super(block);
|
||||
+ this.effect = effect;
|
||||
+ this.player = player;
|
||||
+ this.primary = primary;
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public boolean isCancelled() {
|
||||
+ return cancelled;
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public void setCancelled(boolean cancelled) {
|
||||
+ this.cancelled = cancelled;
|
||||
+ }
|
||||
+
|
||||
+ public PotionEffect getEffect() {
|
||||
+ return effect;
|
||||
+ }
|
||||
+
|
||||
+ public void setEffect(PotionEffect effect) {
|
||||
+ this.effect = effect;
|
||||
+ }
|
||||
+
|
||||
+ public Player getPlayer() {
|
||||
+ return player;
|
||||
+ }
|
||||
+
|
||||
+ public boolean isPrimary() {
|
||||
+ return primary;
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public HandlerList getHandlers() {
|
||||
+ return handlers;
|
||||
+ }
|
||||
+
|
||||
+ public static HandlerList getHandlerList() {
|
||||
+ return handlers;
|
||||
+ }
|
||||
+}
|
||||
--
|
||||
1.9.5.msysgit.1
|
||||
|
66
Spigot-Server-Patches/0069-Add-BeaconEffectEvent.patch
Normal file
66
Spigot-Server-Patches/0069-Add-BeaconEffectEvent.patch
Normal file
|
@ -0,0 +1,66 @@
|
|||
From 2d5e9cd7821456f0ca27163bbf734a6f18130fd6 Mon Sep 17 00:00:00 2001
|
||||
From: Byteflux <byte@byteflux.net>
|
||||
Date: Thu, 23 Jul 2015 12:44:06 -0700
|
||||
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 3ea1b62..a24dc68 100644
|
||||
--- a/src/main/java/net/minecraft/server/TileEntityBeacon.java
|
||||
+++ b/src/main/java/net/minecraft/server/TileEntityBeacon.java
|
||||
@@ -10,6 +10,14 @@ import org.bukkit.craftbukkit.entity.CraftHumanEntity;
|
||||
import org.bukkit.entity.HumanEntity;
|
||||
// CraftBukkit end
|
||||
|
||||
+// PaperSpigot start
|
||||
+import org.bukkit.craftbukkit.event.CraftEventFactory;
|
||||
+import org.bukkit.entity.Player;
|
||||
+import org.bukkit.potion.PotionEffect;
|
||||
+import org.bukkit.potion.PotionEffectType;
|
||||
+import org.github.paperspigot.event.block.BeaconEffectEvent;
|
||||
+// PaperSpigot end
|
||||
+
|
||||
public class TileEntityBeacon extends TileEntityContainer implements IUpdatePlayerListBox, IInventory {
|
||||
|
||||
public static final MobEffectList[][] a = new MobEffectList[][] { { MobEffectList.FASTER_MOVEMENT, MobEffectList.FASTER_DIG}, { MobEffectList.RESISTANCE, MobEffectList.JUMP}, { MobEffectList.INCREASE_DAMAGE}, { MobEffectList.REGENERATION}};
|
||||
@@ -76,18 +84,35 @@ public class TileEntityBeacon extends TileEntityContainer implements IUpdatePlay
|
||||
Iterator iterator = list.iterator();
|
||||
|
||||
EntityHuman entityhuman;
|
||||
+ // PaperSpigot start
|
||||
+ org.bukkit.block.Block block = world.getWorld().getBlockAt(position.getX(), position.getY(), position.getZ());
|
||||
+ PotionEffect primaryEffect = new PotionEffect(PotionEffectType.getById(this.k), 180, b0, true, true);
|
||||
+ // PaperSpigot end
|
||||
|
||||
while (iterator.hasNext()) {
|
||||
entityhuman = (EntityHuman) iterator.next();
|
||||
- entityhuman.addEffect(new MobEffect(this.k, 180, b0, true, true));
|
||||
+ // PaperSpigot 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(effect.getType().getId(), effect.getDuration(), effect.getAmplifier(), effect.isAmbient(), effect.hasParticles()));
|
||||
+ // PaperSpigot end
|
||||
}
|
||||
|
||||
if (this.j >= 4 && this.k != this.l && this.l > 0) {
|
||||
iterator = list.iterator();
|
||||
+ PotionEffect secondaryEffect = new PotionEffect(PotionEffectType.getById(this.l), 180, 0, true, true); // PaperSpigot
|
||||
|
||||
while (iterator.hasNext()) {
|
||||
entityhuman = (EntityHuman) iterator.next();
|
||||
- entityhuman.addEffect(new MobEffect(this.l, 180, 0, true, true));
|
||||
+ // PaperSpigot 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(effect.getType().getId(), effect.getDuration(), effect.getAmplifier(), effect.isAmbient(), effect.hasParticles()));
|
||||
+ // PaperSpigot end
|
||||
}
|
||||
}
|
||||
}
|
||||
--
|
||||
1.9.5.msysgit.1
|
||||
|
Loading…
Reference in a new issue