2019-03-20 00:28:15 +00:00
|
|
|
From 5b2eff30f6fc1cf8f9794b1599d1d92eb76928d6 Mon Sep 17 00:00:00 2001
|
2018-07-30 03:54:13 +00:00
|
|
|
From: Anthony MacAllister <anthonymmacallister@gmail.com>
|
|
|
|
Date: Thu, 26 Jul 2018 15:28:53 -0400
|
|
|
|
Subject: [PATCH] EntityTransformedEvent
|
|
|
|
|
|
|
|
|
|
|
|
diff --git a/src/main/java/com/destroystokyo/paper/event/entity/EntityTransformedEvent.java b/src/main/java/com/destroystokyo/paper/event/entity/EntityTransformedEvent.java
|
|
|
|
new file mode 100644
|
2019-03-20 00:28:15 +00:00
|
|
|
index 000000000..12194f1fc
|
2018-07-30 03:54:13 +00:00
|
|
|
--- /dev/null
|
|
|
|
+++ b/src/main/java/com/destroystokyo/paper/event/entity/EntityTransformedEvent.java
|
2018-11-14 04:21:32 +00:00
|
|
|
@@ -0,0 +1,92 @@
|
2018-07-30 03:54:13 +00:00
|
|
|
+package com.destroystokyo.paper.event.entity;
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+import org.bukkit.entity.Entity;
|
|
|
|
+import org.bukkit.event.Cancellable;
|
|
|
|
+import org.bukkit.event.HandlerList;
|
|
|
|
+import org.bukkit.event.entity.EntityEvent;
|
2018-11-14 04:21:32 +00:00
|
|
|
+import org.bukkit.event.entity.EntityTransformEvent;
|
2018-07-30 03:54:13 +00:00
|
|
|
+
|
|
|
|
+/**
|
|
|
|
+ * Fired when an entity transforms into another entity
|
|
|
|
+ * <p>
|
|
|
|
+ * If the event is cancelled, the entity will not transform
|
2018-11-14 04:21:32 +00:00
|
|
|
+ * @deprecated Bukkit has added {@link EntityTransformEvent}, you should start using that
|
2018-07-30 03:54:13 +00:00
|
|
|
+ */
|
2018-11-14 04:21:32 +00:00
|
|
|
+@Deprecated
|
2018-07-30 03:54:13 +00:00
|
|
|
+public class EntityTransformedEvent extends EntityEvent implements Cancellable {
|
|
|
|
+ private static final HandlerList handlers = new HandlerList();
|
|
|
|
+ private boolean cancelled;
|
|
|
|
+ private final Entity transformed;
|
|
|
|
+ private final TransformedReason reason;
|
|
|
|
+
|
|
|
|
+ public EntityTransformedEvent(Entity entity, Entity transformed, TransformedReason reason) {
|
|
|
|
+ super(entity);
|
|
|
|
+ this.transformed = transformed;
|
|
|
|
+ this.reason = reason;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * The entity after it has transformed
|
|
|
|
+ *
|
|
|
|
+ * @return Transformed entity
|
2018-11-14 04:21:32 +00:00
|
|
|
+ * @deprecated see {@link EntityTransformEvent#getTransformedEntity()}
|
2018-07-30 03:54:13 +00:00
|
|
|
+ */
|
2018-11-14 04:21:32 +00:00
|
|
|
+ @Deprecated
|
2018-07-30 03:54:13 +00:00
|
|
|
+ public Entity getTransformed() {
|
|
|
|
+ return transformed;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * @return The reason for the transformation
|
2018-11-14 04:21:32 +00:00
|
|
|
+ * @deprecated see {@link EntityTransformEvent#getTransformReason()}
|
2018-07-30 03:54:13 +00:00
|
|
|
+ */
|
2018-11-14 04:21:32 +00:00
|
|
|
+ @Deprecated
|
2018-07-30 03:54:13 +00:00
|
|
|
+ public TransformedReason getReason() {
|
|
|
|
+ return reason;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public HandlerList getHandlers(){
|
|
|
|
+ return handlers;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public static HandlerList getHandlerList(){
|
|
|
|
+ return handlers;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public boolean isCancelled(){
|
|
|
|
+ return cancelled;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public void setCancelled(boolean cancel){
|
|
|
|
+ cancelled = cancel;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public enum TransformedReason {
|
|
|
|
+ /**
|
|
|
|
+ * When a zombie drowns
|
|
|
|
+ */
|
|
|
|
+ DROWNED,
|
|
|
|
+ /**
|
|
|
|
+ * When a zombie villager is cured
|
|
|
|
+ */
|
|
|
|
+ CURED,
|
|
|
|
+ /**
|
|
|
|
+ * When a villager turns to a zombie villager
|
|
|
|
+ */
|
|
|
|
+ INFECTED,
|
|
|
|
+ /**
|
|
|
|
+ * When a mooshroom turns to a cow
|
|
|
|
+ */
|
|
|
|
+ SHEARED,
|
|
|
|
+ /**
|
|
|
|
+ * When a pig turns to a zombiepigman
|
|
|
|
+ */
|
|
|
|
+ LIGHTNING
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+}
|
|
|
|
--
|
2019-03-20 00:28:15 +00:00
|
|
|
2.21.0
|
2018-07-30 03:54:13 +00:00
|
|
|
|