aboutsummaryrefslogtreecommitdiffhomepage
path: root/Spigot-Server-Patches/0114-Add-getEntity-by-UUID-API.patch
blob: 2867e29f1cd281abe2ffe3810628a679d2fb99e2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
From 85092d7597bb75335744094cdc93a0fd367e4a4c 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 3d2e0b6..842e364 100644
--- a/src/main/java/net/minecraft/server/MinecraftServer.java
+++ b/src/main/java/net/minecraft/server/MinecraftServer.java
@@ -1593,4 +1593,20 @@ 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) {
+            if (world == null) {
+                continue;
+            }
+            entity = world.getEntity(uuid);
+            if (entity != null && !entity.dead) {
+                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 e6cce51..a0478f2 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;
@@ -1865,5 +1866,14 @@ public final class CraftServer implements Server {
             });
         }
     }
+
+    @Override
+    public CraftEntity getEntity(UUID uuid) {
+        Entity entity = getHandle().getServer().getEntity(uuid);
+        if (entity == null) {
+            return null;
+        }
+        return entity.getBukkitEntity();
+    }
     // Paper end
 }
-- 
2.8.2