Paper/Spigot-Server-Patches/0114-Add-getEntity-by-UUID-API.patch

62 lines
2.2 KiB
Diff
Raw Normal View History

2016-05-12 04:07:46 +02:00
From b50ffe187045367a4cadb8abf7d4990bccc58038 Mon Sep 17 00:00:00 2001
2016-03-30 08:20:36 +02:00
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
2016-05-12 04:07:46 +02:00
index f5e26df..8d8e415 100644
2016-03-30 08:20:36 +02:00
--- a/src/main/java/net/minecraft/server/MinecraftServer.java
+++ b/src/main/java/net/minecraft/server/MinecraftServer.java
2016-05-12 04:07:46 +02:00
@@ -1626,4 +1626,20 @@ public abstract class MinecraftServer implements Runnable, ICommandListener, IAs
2016-03-30 08:20:36 +02:00
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) {
2016-03-31 03:56:07 +02:00
+ if (world == null) {
+ continue;
+ }
2016-03-30 08:20:36 +02:00
+ entity = world.getEntity(uuid);
+ if (entity != null && !entity.dead) {
2016-03-30 08:20:36 +02:00
+ 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 e957ed0..0a5301f 100644
2016-03-30 08:20:36 +02:00
--- 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;
@@ -1858,5 +1859,14 @@ public final class CraftServer implements Server {
});
}
2016-03-30 08:20:36 +02:00
}
+
+ @Override
+ public CraftEntity getEntity(UUID uuid) {
+ Entity entity = getHandle().getServer().getEntity(uuid);
+ if (entity == null) {
+ return null;
+ }
+ return entity.getBukkitEntity();
+ }
// Paper end
}
--
2016-05-12 04:07:46 +02:00
2.8.2
2016-03-30 08:20:36 +02:00