2019-06-14 10:27:40 +08:00
|
|
|
From f85769e8ba9c1aa2b67b14ed2c91ad26f639801f Mon Sep 17 00:00:00 2001
|
2016-10-17 14:27:02 +08:00
|
|
|
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
|
2019-06-06 23:36:57 +08:00
|
|
|
index 000000000..3b725a489
|
2016-10-17 14:27:02 +08:00
|
|
|
--- /dev/null
|
|
|
|
+++ b/src/main/java/com/destroystokyo/paper/event/entity/EntityZapEvent.java
|
2019-03-20 08:28:15 +08:00
|
|
|
@@ -0,0 +1,65 @@
|
2016-10-17 14:27:02 +08:00
|
|
|
+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;
|
2018-12-03 07:31:09 +08:00
|
|
|
+import org.bukkit.event.entity.EntityTransformEvent;
|
2016-10-17 14:27:02 +08:00
|
|
|
+
|
2018-12-08 18:09:55 +08:00
|
|
|
+import java.util.Collections;
|
2019-03-20 08:28:15 +08:00
|
|
|
+import org.jetbrains.annotations.NotNull;
|
2016-10-17 14:27:02 +08:00
|
|
|
+
|
|
|
|
+/**
|
|
|
|
+ * Fired when lightning strikes an entity
|
|
|
|
+ */
|
2018-12-03 07:31:09 +08:00
|
|
|
+public class EntityZapEvent extends EntityTransformEvent implements Cancellable {
|
2016-10-17 14:27:02 +08:00
|
|
|
+ private static final HandlerList handlers = new HandlerList();
|
|
|
|
+ private boolean cancelled;
|
2019-03-20 08:28:15 +08:00
|
|
|
+ @NotNull private final LightningStrike bolt;
|
2016-10-17 14:27:02 +08:00
|
|
|
+
|
2019-03-20 08:28:15 +08:00
|
|
|
+ public EntityZapEvent(@NotNull final Entity entity, @NotNull final LightningStrike bolt, @NotNull final Entity replacementEntity) {
|
2018-12-08 18:09:55 +08:00
|
|
|
+ super(entity, Collections.singletonList(replacementEntity), TransformReason.LIGHTNING);
|
2016-10-17 14:27:02 +08:00
|
|
|
+ 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
|
|
|
|
+ */
|
2019-03-20 08:28:15 +08:00
|
|
|
+ @NotNull
|
2016-10-17 14:27:02 +08:00
|
|
|
+ public LightningStrike getBolt() {
|
|
|
|
+ return bolt;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * Gets the entity that will replace the struck entity.
|
|
|
|
+ * @return The entity that will replace the struck entity
|
|
|
|
+ */
|
2019-03-20 08:28:15 +08:00
|
|
|
+ @NotNull
|
2016-10-17 14:27:02 +08:00
|
|
|
+ public Entity getReplacementEntity() {
|
2018-12-03 07:31:09 +08:00
|
|
|
+ return getTransformedEntity();
|
2016-10-17 14:27:02 +08:00
|
|
|
+ }
|
|
|
|
+
|
2019-03-20 08:28:15 +08:00
|
|
|
+ @NotNull
|
2016-10-17 14:27:02 +08:00
|
|
|
+ @Override
|
|
|
|
+ public HandlerList getHandlers() {
|
|
|
|
+ return handlers;
|
|
|
|
+ }
|
|
|
|
+
|
2019-03-20 08:28:15 +08:00
|
|
|
+ @NotNull
|
2016-10-17 14:27:02 +08:00
|
|
|
+ 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
|
2019-06-06 23:36:57 +08:00
|
|
|
index 0e0ed93b5..d3949edfc 100644
|
2016-10-17 14:27:02 +08:00
|
|
|
--- a/src/main/java/org/bukkit/event/entity/PigZapEvent.java
|
|
|
|
+++ b/src/main/java/org/bukkit/event/entity/PigZapEvent.java
|
2018-12-08 18:09:55 +08:00
|
|
|
@@ -2,6 +2,7 @@ package org.bukkit.event.entity;
|
2016-10-17 14:27:02 +08:00
|
|
|
|
2018-12-08 18:09:55 +08:00
|
|
|
import java.util.Collections;
|
|
|
|
import org.bukkit.entity.Entity;
|
2016-10-17 14:27:02 +08:00
|
|
|
+import com.destroystokyo.paper.event.entity.EntityZapEvent;
|
|
|
|
import org.bukkit.entity.LightningStrike;
|
|
|
|
import org.bukkit.entity.Pig;
|
|
|
|
import org.bukkit.entity.PigZombie;
|
2019-03-20 08:28:15 +08:00
|
|
|
@@ -12,14 +13,14 @@ import org.jetbrains.annotations.NotNull;
|
2016-10-17 14:27:02 +08:00
|
|
|
/**
|
|
|
|
* Stores data for pigs being zapped
|
|
|
|
*/
|
2018-12-03 07:31:09 +08:00
|
|
|
-public class PigZapEvent extends EntityTransformEvent implements Cancellable {
|
2016-10-31 10:42:38 +08:00
|
|
|
- private static final HandlerList handlers = new HandlerList();
|
2016-10-17 14:27:02 +08:00
|
|
|
+public class PigZapEvent extends EntityZapEvent implements Cancellable {
|
2016-10-31 10:42:38 +08:00
|
|
|
+ //private static final HandlerList handlers = new HandlerList();
|
2016-10-17 14:27:02 +08:00
|
|
|
private boolean canceled;
|
|
|
|
private final PigZombie pigzombie;
|
|
|
|
private final LightningStrike bolt;
|
|
|
|
|
2019-03-20 08:28:15 +08:00
|
|
|
public PigZapEvent(@NotNull final Pig pig, @NotNull final LightningStrike bolt, @NotNull final PigZombie pigzombie) {
|
2018-12-08 18:09:55 +08:00
|
|
|
- super(pig, Collections.singletonList((Entity) pigzombie), TransformReason.LIGHTNING);
|
2016-10-17 14:27:02 +08:00
|
|
|
+ super(pig, bolt, pigzombie);
|
|
|
|
this.bolt = bolt;
|
|
|
|
this.pigzombie = pigzombie;
|
|
|
|
}
|
2019-05-06 10:58:04 +08:00
|
|
|
@@ -63,6 +64,8 @@ public class PigZapEvent extends EntityTransformEvent implements Cancellable {
|
2016-10-31 10:42:38 +08:00
|
|
|
return pigzombie;
|
|
|
|
}
|
|
|
|
|
|
|
|
+ // Paper start
|
|
|
|
+ /*
|
2019-03-20 08:28:15 +08:00
|
|
|
@NotNull
|
2016-10-31 10:42:38 +08:00
|
|
|
@Override
|
|
|
|
public HandlerList getHandlers() {
|
2019-05-06 10:58:04 +08:00
|
|
|
@@ -73,4 +76,6 @@ public class PigZapEvent extends EntityTransformEvent implements Cancellable {
|
2016-10-31 10:42:38 +08:00
|
|
|
public static HandlerList getHandlerList() {
|
|
|
|
return handlers;
|
|
|
|
}
|
|
|
|
+ */
|
|
|
|
+ // Paper end
|
|
|
|
}
|
2016-10-17 14:27:02 +08:00
|
|
|
--
|
2019-03-20 08:28:15 +08:00
|
|
|
2.21.0
|
2016-10-17 14:27:02 +08:00
|
|
|
|