From a661a1737fc253d3cb6cb6b3a59a67b62c60569a Mon Sep 17 00:00:00 2001 From: Aikar Date: Mon, 28 Mar 2016 20:33:10 -0400 Subject: [PATCH] Entity AddTo/RemoveFrom World Events These events will give plugins a reliable way to track every entity that is added or removed from a world, so that one may always ensure they are in a desired state. --- ...Entity-AddTo-RemoveFrom-World-Events.patch | 90 +++++++++++++++++++ ...Entity-AddTo-RemoveFrom-World-Events.patch | 27 ++++++ 2 files changed, 117 insertions(+) create mode 100644 Spigot-API-Patches/Entity-AddTo-RemoveFrom-World-Events.patch create mode 100644 Spigot-Server-Patches/Entity-AddTo-RemoveFrom-World-Events.patch diff --git a/Spigot-API-Patches/Entity-AddTo-RemoveFrom-World-Events.patch b/Spigot-API-Patches/Entity-AddTo-RemoveFrom-World-Events.patch new file mode 100644 index 0000000000..13449e66a6 --- /dev/null +++ b/Spigot-API-Patches/Entity-AddTo-RemoveFrom-World-Events.patch @@ -0,0 +1,90 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Aikar +Date: Mon, 28 Mar 2016 20:26:34 -0400 +Subject: [PATCH] Entity AddTo/RemoveFrom World Events + + +diff --git a/src/main/java/com/destroystokyo/paper/event/entity/EntityAddToWorldEvent.java b/src/main/java/com/destroystokyo/paper/event/entity/EntityAddToWorldEvent.java +new file mode 100644 +index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 +--- /dev/null ++++ b/src/main/java/com/destroystokyo/paper/event/entity/EntityAddToWorldEvent.java +@@ -0,0 +0,0 @@ ++package com.destroystokyo.paper.event.entity; ++ ++import org.bukkit.entity.Entity; ++import org.bukkit.event.Event; ++import org.bukkit.event.HandlerList; ++ ++/** ++ * Fired any time an entity is being added to the world for any reason. ++ * ++ * Not to be confused with {@link org.bukkit.event.entity.CreatureSpawnEvent} ++ * This will fire anytime a chunk is reloaded too. ++ */ ++public class EntityAddToWorldEvent extends Event { ++ ++ private final Entity entity; ++ public EntityAddToWorldEvent(Entity entity) { ++ this.entity = entity; ++ } ++ ++ /** ++ * Gets the entity being added to the world ++ * @return ++ */ ++ public Entity getEntity() { ++ return entity; ++ } ++ ++ private static final HandlerList handlers = new HandlerList(); ++ ++ public HandlerList getHandlers() { ++ return handlers; ++ } ++ ++ public static HandlerList getHandlerList() { ++ return handlers; ++ } ++} +diff --git a/src/main/java/com/destroystokyo/paper/event/entity/EntityRemoveFromWorldEvent.java b/src/main/java/com/destroystokyo/paper/event/entity/EntityRemoveFromWorldEvent.java +new file mode 100644 +index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 +--- /dev/null ++++ b/src/main/java/com/destroystokyo/paper/event/entity/EntityRemoveFromWorldEvent.java +@@ -0,0 +0,0 @@ ++package com.destroystokyo.paper.event.entity; ++ ++import org.bukkit.entity.Entity; ++import org.bukkit.event.Event; ++import org.bukkit.event.HandlerList; ++ ++/** ++ * Fired any time an entity is being removed from a world for any reason ++ */ ++public class EntityRemoveFromWorldEvent extends Event { ++ private final Entity entity; ++ ++ public EntityRemoveFromWorldEvent(Entity entity) { ++ this.entity = entity; ++ } ++ ++ /** ++ * Gets the entity being removed from the world ++ * @return ++ */ ++ public Entity getEntity() { ++ return entity; ++ } ++ ++ private static final HandlerList handlers = new HandlerList(); ++ ++ public HandlerList getHandlers() { ++ return handlers; ++ } ++ ++ public static HandlerList getHandlerList() { ++ return handlers; ++ } ++} +-- \ No newline at end of file diff --git a/Spigot-Server-Patches/Entity-AddTo-RemoveFrom-World-Events.patch b/Spigot-Server-Patches/Entity-AddTo-RemoveFrom-World-Events.patch new file mode 100644 index 0000000000..acb01a12f0 --- /dev/null +++ b/Spigot-Server-Patches/Entity-AddTo-RemoveFrom-World-Events.patch @@ -0,0 +1,27 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Aikar +Date: Mon, 28 Mar 2016 20:32:58 -0400 +Subject: [PATCH] Entity AddTo/RemoveFrom World Events + + +diff --git a/src/main/java/net/minecraft/server/World.java b/src/main/java/net/minecraft/server/World.java +index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 +--- a/src/main/java/net/minecraft/server/World.java ++++ b/src/main/java/net/minecraft/server/World.java +@@ -0,0 +0,0 @@ public abstract class World implements IBlockAccess { + } + + entity.valid = true; // CraftBukkit ++ new com.destroystokyo.paper.event.entity.EntityRemoveFromWorldEvent(entity.getBukkitEntity()); // Paper - fire while valid + } + + protected void c(Entity entity) { +@@ -0,0 +0,0 @@ public abstract class World implements IBlockAccess { + ((IWorldAccess) this.u.get(i)).b(entity); + } + ++ new com.destroystokyo.paper.event.entity.EntityRemoveFromWorldEvent(entity.getBukkitEntity()); // Paper - fire while valid + entity.valid = false; // CraftBukkit + } + +-- \ No newline at end of file