Paper/Spigot-API-Patches/0037-Add-EntityZapEvent.patch
Aikar e4d10a6d67
Updated Upstream (Bukkit/CraftBukkit)
Upstream has released updates that appears to apply and compile correctly.
This update has not been tested by PaperMC and as with ANY update, please do your own testing

Bukkit Changes:
122289ff Add FaceAttachable interface to handle Grindstone facing in common with Switches
a6db750e SPIGOT-5647: ZombieVillager entity should have getVillagerType()

CraftBukkit Changes:
bbe3d58e SPIGOT-5650: Lectern.setPage(int) causes a NullPointerException
3075579f Add FaceAttachable interface to handle Grindstone facing in common with Switches
95bd4238 SPIGOT-5647: ZombieVillager entity should have getVillagerType()
4d975ac3 SPIGOT-5617: setBlockData does not work when NotPlayEvent is called by redstone current
2020-04-02 17:09:17 -04:00

127 Zeilen
4.2 KiB
Diff

From 3e509ef8019f3efe28e265dbbbdae31c3f23d235 Mon Sep 17 00:00:00 2001
From: AlphaBlend <whizkid3000@hotmail.com>
Date: Sun, 16 Oct 2016 23:19:34 -0700
Subject: [PATCH] Add EntityZapEvent
diff --git a/src/main/java/com/destroystokyo/paper/event/entity/EntityZapEvent.java b/src/main/java/com/destroystokyo/paper/event/entity/EntityZapEvent.java
new file mode 100644
index 000000000..3b725a489
--- /dev/null
+++ b/src/main/java/com/destroystokyo/paper/event/entity/EntityZapEvent.java
@@ -0,0 +1,65 @@
+package com.destroystokyo.paper.event.entity;
+
+import org.apache.commons.lang.Validate;
+import org.bukkit.entity.Entity;
+import org.bukkit.entity.LightningStrike;
+import org.bukkit.event.Cancellable;
+import org.bukkit.event.HandlerList;
+import org.bukkit.event.entity.EntityEvent;
+import org.bukkit.event.entity.EntityTransformEvent;
+
+import java.util.Collections;
+import org.jetbrains.annotations.NotNull;
+
+/**
+ * Fired when lightning strikes an entity
+ */
+public class EntityZapEvent extends EntityTransformEvent implements Cancellable {
+ private static final HandlerList handlers = new HandlerList();
+ private boolean cancelled;
+ @NotNull private final LightningStrike bolt;
+
+ public EntityZapEvent(@NotNull final Entity entity, @NotNull final LightningStrike bolt, @NotNull final Entity replacementEntity) {
+ super(entity, Collections.singletonList(replacementEntity), TransformReason.LIGHTNING);
+ Validate.notNull(bolt);
+ Validate.notNull(replacementEntity);
+ this.bolt = bolt;
+ }
+
+ public boolean isCancelled() {
+ return cancelled;
+ }
+
+ public void setCancelled(boolean cancel) {
+ this.cancelled = cancel;
+ }
+
+ /**
+ * Gets the lightning bolt that is striking the entity.
+ * @return The lightning bolt responsible for this event
+ */
+ @NotNull
+ public LightningStrike getBolt() {
+ return bolt;
+ }
+
+ /**
+ * Gets the entity that will replace the struck entity.
+ * @return The entity that will replace the struck entity
+ */
+ @NotNull
+ public Entity getReplacementEntity() {
+ return getTransformedEntity();
+ }
+
+ @NotNull
+ @Override
+ public HandlerList getHandlers() {
+ return handlers;
+ }
+
+ @NotNull
+ public static HandlerList getHandlerList() {
+ return handlers;
+ }
+}
diff --git a/src/main/java/org/bukkit/event/entity/PigZapEvent.java b/src/main/java/org/bukkit/event/entity/PigZapEvent.java
index 0e0ed93b5..d3949edfc 100644
--- a/src/main/java/org/bukkit/event/entity/PigZapEvent.java
+++ b/src/main/java/org/bukkit/event/entity/PigZapEvent.java
@@ -2,6 +2,7 @@ package org.bukkit.event.entity;
import java.util.Collections;
import org.bukkit.entity.Entity;
+import com.destroystokyo.paper.event.entity.EntityZapEvent;
import org.bukkit.entity.LightningStrike;
import org.bukkit.entity.Pig;
import org.bukkit.entity.PigZombie;
@@ -12,14 +13,14 @@ import org.jetbrains.annotations.NotNull;
/**
* Stores data for pigs being zapped
*/
-public class PigZapEvent extends EntityTransformEvent implements Cancellable {
- private static final HandlerList handlers = new HandlerList();
+public class PigZapEvent extends EntityZapEvent implements Cancellable {
+ //private static final HandlerList handlers = new HandlerList();
private boolean canceled;
private final PigZombie pigzombie;
private final LightningStrike bolt;
public PigZapEvent(@NotNull final Pig pig, @NotNull final LightningStrike bolt, @NotNull final PigZombie pigzombie) {
- super(pig, Collections.singletonList((Entity) pigzombie), TransformReason.LIGHTNING);
+ super(pig, bolt, pigzombie);
this.bolt = bolt;
this.pigzombie = pigzombie;
}
@@ -63,6 +64,8 @@ public class PigZapEvent extends EntityTransformEvent implements Cancellable {
return pigzombie;
}
+ // Paper start
+ /*
@NotNull
@Override
public HandlerList getHandlers() {
@@ -73,4 +76,6 @@ public class PigZapEvent extends EntityTransformEvent implements Cancellable {
public static HandlerList getHandlerList() {
return handlers;
}
+ */
+ // Paper end
}
--
2.25.1