From 48d3c2105d71219948b55d2fe9f7d227e2b15049 Mon Sep 17 00:00:00 2001 From: MeFisto94 Date: Thu, 6 Aug 2020 13:56:58 +0200 Subject: [PATCH] Fixes an OfflinePlayerUtil breakage caused by NMS Changes --- .../bukkit/util/OfflinePlayerUtil.java | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/Bukkit/src/main/java/com/plotsquared/bukkit/util/OfflinePlayerUtil.java b/Bukkit/src/main/java/com/plotsquared/bukkit/util/OfflinePlayerUtil.java index 41ae4dedd..197b05cd6 100644 --- a/Bukkit/src/main/java/com/plotsquared/bukkit/util/OfflinePlayerUtil.java +++ b/Bukkit/src/main/java/com/plotsquared/bukkit/util/OfflinePlayerUtil.java @@ -97,6 +97,17 @@ public class OfflinePlayerUtil { return callConstructor(c, worldServer); } + public static Object getWorldServer116() { + Object server = getMinecraftServer(); + Class minecraftServerClass = getNmsClass("MinecraftServer"); + Class dimensionManager = getNmsClass("DimensionManager"); + Class genericResourceKey = getNmsClass("ResourceKey"); + Object overworld = getField(makeField(dimensionManager, "OVERWORLD"), null); + Method getWorldServer = + makeMethod(minecraftServerClass, "getWorldServer", genericResourceKey); + return callMethod(getWorldServer, server, overworld); + } + public static Object getWorldServerNew() { Object server = getMinecraftServer(); Class minecraftServerClass = getNmsClass("MinecraftServer"); @@ -115,7 +126,11 @@ public class OfflinePlayerUtil { try { o = callMethod(getWorldServer, server, 0); } catch (final RuntimeException e) { - o = getWorldServerNew(); + try { + o = getWorldServerNew(); + } catch (final RuntimeException f) { + o = getWorldServer116(); + } } return o; }