3
0
Mirror von https://github.com/PaperMC/Paper.git synchronisiert 2024-11-15 12:30:06 +01:00
Paper/Spigot-API-Patches/0036-Add-EntityZapEvent.patch
Zach Brown a2ad49b22f
Update upstream BD/B/CB/S
Note to other developers: This commit may require you to wipe your
workspace as a result of the changes to BD.

--- work/BuildData
Submodule work/BuildData f527a8ff..d56672db:
  > Mappings Update

--- work/Bukkit
Submodule work/Bukkit 0c1d258bb..db06c80d7:
  > Add list of entities to EntityTransformEvent
  > SPIGOT-4347: Add API to allow storing arbitrary values on ItemStacks

---work/CraftBukkit
Submodule work/CraftBukkit 6a398ac44..068dab5be:
  > Enable optional source JAR shading via profile shadeSourcesJar
  > Use ImmutableList rather than AbstractList for CraftMetaBook
  > Fix setRecipes(List) not setting Knowledge Book recipes.
  > Mappings Update
  > Add list of entities to EntityTransformEvent & move die calls
  > SPIGOT-4347: Add API to allow storing arbitrary values on ItemStacks
  > Add Vanilla help to default permissions

--- work/Spigot
Submodule work/Spigot a1f2566f6..e769fe4d9:
  > Mappings Update
  > Rebuild patches
2018-12-08 05:09:55 -05:00

125 Zeilen
4.1 KiB
Diff

From 2527eb4a36c059f3c42f5fc5dbac73c6021c6d10 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 00000000..c8f0bb05
--- /dev/null
+++ b/src/main/java/com/destroystokyo/paper/event/entity/EntityZapEvent.java
@@ -0,0 +1,63 @@
+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 javax.annotation.Nonnull;
+import java.util.Collections;
+
+/**
+ * Fired when lightning strikes an entity
+ */
+public class EntityZapEvent extends EntityTransformEvent implements Cancellable {
+ private static final HandlerList handlers = new HandlerList();
+ private boolean cancelled;
+ private final LightningStrike bolt;
+
+ public EntityZapEvent(final Entity entity, @Nonnull final LightningStrike bolt, @Nonnull 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
+ */
+ @Nonnull
+ public LightningStrike getBolt() {
+ return bolt;
+ }
+
+ /**
+ * Gets the entity that will replace the struck entity.
+ * @return The entity that will replace the struck entity
+ */
+ @Nonnull
+ public Entity getReplacementEntity() {
+ return getTransformedEntity();
+ }
+
+ @Override
+ public HandlerList getHandlers() {
+ return handlers;
+ }
+
+ 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 c1d4b30a..de8cad81 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;
@@ -11,14 +12,14 @@ import org.bukkit.event.HandlerList;
/**
* 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(final Pig pig, final LightningStrike bolt, final PigZombie pigzombie) {
- super(pig, Collections.singletonList((Entity) pigzombie), TransformReason.LIGHTNING);
+ super(pig, bolt, pigzombie);
this.bolt = bolt;
this.pigzombie = pigzombie;
}
@@ -57,6 +58,8 @@ public class PigZapEvent extends EntityTransformEvent implements Cancellable {
return pigzombie;
}
+ // Paper start
+ /*
@Override
public HandlerList getHandlers() {
return handlers;
@@ -65,4 +68,6 @@ public class PigZapEvent extends EntityTransformEvent implements Cancellable {
public static HandlerList getHandlerList() {
return handlers;
}
+ */
+ // Paper end
}
--
2.19.2