mirror of
https://github.com/PaperMC/Paper.git
synced 2024-12-23 15:00:30 +01:00
119 lines
4.1 KiB
Diff
119 lines
4.1 KiB
Diff
From 0000000000000000000000000000000000000000 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 0000000000000000000000000000000000000000..dc6d15975a47e68c5bd939e68ddd2773028a6ac8
|
|
--- /dev/null
|
|
+++ b/src/main/java/com/destroystokyo/paper/event/entity/EntityZapEvent.java
|
|
@@ -0,0 +1,69 @@
|
|
+package com.destroystokyo.paper.event.entity;
|
|
+
|
|
+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.EntityTransformEvent;
|
|
+
|
|
+import java.util.Collections;
|
|
+import org.jetbrains.annotations.ApiStatus;
|
|
+import org.jetbrains.annotations.NotNull;
|
|
+
|
|
+/**
|
|
+ * Fired when lightning strikes an entity
|
|
+ */
|
|
+public class EntityZapEvent extends EntityTransformEvent implements Cancellable {
|
|
+
|
|
+ private static final HandlerList HANDLER_LIST = new HandlerList();
|
|
+
|
|
+ @NotNull private final LightningStrike bolt;
|
|
+ private boolean cancelled;
|
|
+
|
|
+ @ApiStatus.Internal
|
|
+ public EntityZapEvent(@NotNull final Entity entity, @NotNull final LightningStrike bolt, @NotNull final Entity replacementEntity) {
|
|
+ super(entity, Collections.singletonList(replacementEntity), TransformReason.LIGHTNING);
|
|
+ this.bolt = bolt;
|
|
+ }
|
|
+
|
|
+ /**
|
|
+ * Gets the lightning bolt that is striking the entity.
|
|
+ *
|
|
+ * @return The lightning bolt responsible for this event
|
|
+ */
|
|
+ @NotNull
|
|
+ public LightningStrike getBolt() {
|
|
+ return this.bolt;
|
|
+ }
|
|
+
|
|
+ /**
|
|
+ * Gets the entity that will replace the struck entity.
|
|
+ *
|
|
+ * @return The entity that will replace the struck entity
|
|
+ */
|
|
+ @NotNull
|
|
+ public Entity getReplacementEntity() {
|
|
+ return super.getTransformedEntity();
|
|
+ }
|
|
+
|
|
+ @Override
|
|
+ public boolean isCancelled() {
|
|
+ return this.cancelled;
|
|
+ }
|
|
+
|
|
+ @Override
|
|
+ public void setCancelled(boolean cancel) {
|
|
+ this.cancelled = cancel;
|
|
+ }
|
|
+
|
|
+ @NotNull
|
|
+ @Override
|
|
+ public HandlerList getHandlers() {
|
|
+ return HANDLER_LIST;
|
|
+ }
|
|
+
|
|
+ @NotNull
|
|
+ public static HandlerList getHandlerList() {
|
|
+ return HANDLER_LIST;
|
|
+ }
|
|
+}
|
|
diff --git a/src/main/java/org/bukkit/event/entity/PigZapEvent.java b/src/main/java/org/bukkit/event/entity/PigZapEvent.java
|
|
index 0e0ed93b568fd2c0d8f6e359c31dc29cb0fa71c2..085337f3d3d6adef5fd4ecda133c607e4b77bd93 100644
|
|
--- a/src/main/java/org/bukkit/event/entity/PigZapEvent.java
|
|
+++ b/src/main/java/org/bukkit/event/entity/PigZapEvent.java
|
|
@@ -12,14 +12,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 com.destroystokyo.paper.event.entity.EntityZapEvent implements Cancellable { // Paper
|
|
+ // private static final HandlerList handlers = new HandlerList(); // Paper - moved in the super class
|
|
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); // Paper
|
|
this.bolt = bolt;
|
|
this.pigzombie = pigzombie;
|
|
}
|
|
@@ -63,6 +63,8 @@ public class PigZapEvent extends EntityTransformEvent implements Cancellable {
|
|
return pigzombie;
|
|
}
|
|
|
|
+ // Paper start
|
|
+ /*
|
|
@NotNull
|
|
@Override
|
|
public HandlerList getHandlers() {
|
|
@@ -73,4 +75,6 @@ public class PigZapEvent extends EntityTransformEvent implements Cancellable {
|
|
public static HandlerList getHandlerList() {
|
|
return handlers;
|
|
}
|
|
+ */
|
|
+ // Paper end
|
|
}
|