Mirror von
https://github.com/PaperMC/Paper.git
synchronisiert 2024-11-14 20:10:05 +01:00
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.
Dieser Commit ist enthalten in:
Ursprung
030de0f42a
Commit
22b248d631
92
Spigot-API-Patches/0029-Entity-AddTo-RemoveFrom-World-Events.patch
Normale Datei
92
Spigot-API-Patches/0029-Entity-AddTo-RemoveFrom-World-Events.patch
Normale Datei
@ -0,0 +1,92 @@
|
||||
From 6fbe0184aa41dd325adc6415b01dda65b1b97c35 Mon Sep 17 00:00:00 2001
|
||||
From: Aikar <aikar@aikar.co>
|
||||
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 0000000..cc44c1d
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/com/destroystokyo/paper/event/entity/EntityAddToWorldEvent.java
|
||||
@@ -0,0 +1,37 @@
|
||||
+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 0000000..9b522ce
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/com/destroystokyo/paper/event/entity/EntityRemoveFromWorldEvent.java
|
||||
@@ -0,0 +1,34 @@
|
||||
+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;
|
||||
+ }
|
||||
+}
|
||||
--
|
||||
2.7.4
|
||||
|
@ -0,0 +1,29 @@
|
||||
From ba08cdb1b65264542221e56bf8178ec42ca2aeae Mon Sep 17 00:00:00 2001
|
||||
From: Aikar <aikar@aikar.co>
|
||||
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 fcd7cd6..b1c78b5 100644
|
||||
--- a/src/main/java/net/minecraft/server/World.java
|
||||
+++ b/src/main/java/net/minecraft/server/World.java
|
||||
@@ -1119,6 +1119,7 @@ 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) {
|
||||
@@ -1126,6 +1127,7 @@ 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
|
||||
}
|
||||
|
||||
--
|
||||
2.7.4
|
||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren