Add getEntity by UUID API
This commit is contained in:
parent
31a482e9f0
commit
4bf9c3c177
2 changed files with 105 additions and 0 deletions
47
Spigot-API-Patches/0034-Add-getEntity-by-UUID-API.patch
Normal file
47
Spigot-API-Patches/0034-Add-getEntity-by-UUID-API.patch
Normal file
|
@ -0,0 +1,47 @@
|
||||||
|
From 5c9d87a6c795f9028600143e51fa59286c8a8192 Mon Sep 17 00:00:00 2001
|
||||||
|
From: DemonWav <demonwav@gmail.com>
|
||||||
|
Date: Wed, 30 Mar 2016 01:19:51 -0500
|
||||||
|
Subject: [PATCH] Add getEntity by UUID API
|
||||||
|
|
||||||
|
|
||||||
|
diff --git a/src/main/java/org/bukkit/Bukkit.java b/src/main/java/org/bukkit/Bukkit.java
|
||||||
|
index 5e31665..9d61cc5 100644
|
||||||
|
--- a/src/main/java/org/bukkit/Bukkit.java
|
||||||
|
+++ b/src/main/java/org/bukkit/Bukkit.java
|
||||||
|
@@ -1189,6 +1189,16 @@ public final class Bukkit {
|
||||||
|
public static void reloadPermissions() {
|
||||||
|
server.reloadPermissions();
|
||||||
|
}
|
||||||
|
+
|
||||||
|
+ /**
|
||||||
|
+ * Find an entity on the server by its UUID
|
||||||
|
+ *
|
||||||
|
+ * @param uuid The UUID of the entity
|
||||||
|
+ * @return The entity that is identified by the given UUID, or null if one isn't found
|
||||||
|
+ */
|
||||||
|
+ public static Entity getEntity(UUID uuid) {
|
||||||
|
+ return server.getEntity(uuid);
|
||||||
|
+ }
|
||||||
|
// Paper end
|
||||||
|
|
||||||
|
public static Server.Spigot spigot()
|
||||||
|
diff --git a/src/main/java/org/bukkit/Server.java b/src/main/java/org/bukkit/Server.java
|
||||||
|
index 6b1f2a4..1c8140f 100644
|
||||||
|
--- a/src/main/java/org/bukkit/Server.java
|
||||||
|
+++ b/src/main/java/org/bukkit/Server.java
|
||||||
|
@@ -1020,4 +1020,12 @@ public interface Server extends PluginMessageRecipient {
|
||||||
|
Spigot spigot();
|
||||||
|
|
||||||
|
void reloadPermissions(); // Paper
|
||||||
|
+
|
||||||
|
+ /**
|
||||||
|
+ * Find an entity on the server by its UUID
|
||||||
|
+ *
|
||||||
|
+ * @param uuid The UUID of the entity
|
||||||
|
+ * @return The entity that is identified by the given UUID, or null if one isn't found
|
||||||
|
+ */
|
||||||
|
+ Entity getEntity(UUID uuid); // Paper
|
||||||
|
}
|
||||||
|
--
|
||||||
|
2.7.4
|
||||||
|
|
58
Spigot-Server-Patches/0123-Add-getEntity-by-UUID-API.patch
Normal file
58
Spigot-Server-Patches/0123-Add-getEntity-by-UUID-API.patch
Normal file
|
@ -0,0 +1,58 @@
|
||||||
|
From eab823e7ef24a1d4a79f9cdc6efd9f7e169f7b2c Mon Sep 17 00:00:00 2001
|
||||||
|
From: DemonWav <demonwav@gmail.com>
|
||||||
|
Date: Wed, 30 Mar 2016 01:20:11 -0500
|
||||||
|
Subject: [PATCH] Add getEntity by UUID API
|
||||||
|
|
||||||
|
|
||||||
|
diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java
|
||||||
|
index d628a32..d7ca53b 100644
|
||||||
|
--- a/src/main/java/net/minecraft/server/MinecraftServer.java
|
||||||
|
+++ b/src/main/java/net/minecraft/server/MinecraftServer.java
|
||||||
|
@@ -1622,4 +1622,17 @@ public abstract class MinecraftServer implements Runnable, ICommandListener, IAs
|
||||||
|
return (Bukkit.getServer() instanceof CraftServer) ? ((CraftServer) Bukkit.getServer()).getServer() : null;
|
||||||
|
}
|
||||||
|
// CraftBukkit end
|
||||||
|
+
|
||||||
|
+ // Paper start
|
||||||
|
+ public Entity getEntity(UUID uuid) {
|
||||||
|
+ Entity entity;
|
||||||
|
+ for (WorldServer world : worldServer) {
|
||||||
|
+ entity = world.getEntity(uuid);
|
||||||
|
+ if (entity != null) {
|
||||||
|
+ return entity;
|
||||||
|
+ }
|
||||||
|
+ }
|
||||||
|
+ return null;
|
||||||
|
+ }
|
||||||
|
+ // Paper end
|
||||||
|
}
|
||||||
|
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
|
||||||
|
index 9ed9fbb..5b70d7a 100644
|
||||||
|
--- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java
|
||||||
|
+++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
|
||||||
|
@@ -46,6 +46,7 @@ import org.bukkit.configuration.serialization.ConfigurationSerialization;
|
||||||
|
import org.bukkit.conversations.Conversable;
|
||||||
|
import org.bukkit.craftbukkit.boss.CraftBossBar;
|
||||||
|
import org.bukkit.craftbukkit.command.VanillaCommandWrapper;
|
||||||
|
+import org.bukkit.craftbukkit.entity.CraftEntity;
|
||||||
|
import org.bukkit.craftbukkit.entity.CraftPlayer;
|
||||||
|
import org.bukkit.craftbukkit.generator.CraftChunkData;
|
||||||
|
import org.bukkit.craftbukkit.help.SimpleHelpMap;
|
||||||
|
@@ -1853,5 +1854,14 @@ public final class CraftServer implements Server {
|
||||||
|
((SimplePluginManager) pluginManager).clearPermissions();
|
||||||
|
loadCustomPermissions();
|
||||||
|
}
|
||||||
|
+
|
||||||
|
+ @Override
|
||||||
|
+ public CraftEntity getEntity(UUID uuid) {
|
||||||
|
+ Entity entity = getHandle().getServer().getEntity(uuid);
|
||||||
|
+ if (entity == null) {
|
||||||
|
+ return null;
|
||||||
|
+ }
|
||||||
|
+ return entity.getBukkitEntity();
|
||||||
|
+ }
|
||||||
|
// Paper end
|
||||||
|
}
|
||||||
|
--
|
||||||
|
2.7.4
|
||||||
|
|
Loading…
Reference in a new issue