From ca906cc8c36dee405f2386995af7f459d979e6a9 Mon Sep 17 00:00:00 2001 From: Jesse Boyd Date: Sat, 20 Jan 2018 20:41:23 +1100 Subject: [PATCH] Fix thermos getWorldName --- .../java/com/boydti/fawe/forge/FaweForge.java | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/forge1710/src/main/java/com/boydti/fawe/forge/FaweForge.java b/forge1710/src/main/java/com/boydti/fawe/forge/FaweForge.java index 4d9d22f3..d4188cce 100644 --- a/forge1710/src/main/java/com/boydti/fawe/forge/FaweForge.java +++ b/forge1710/src/main/java/com/boydti/fawe/forge/FaweForge.java @@ -17,6 +17,7 @@ import com.sk89q.worldedit.world.World; import cpw.mods.fml.common.FMLCommonHandler; import cpw.mods.fml.common.ModMetadata; import java.io.File; +import java.lang.reflect.Method; import java.nio.charset.StandardCharsets; import java.util.ArrayList; import java.util.Collection; @@ -132,6 +133,21 @@ public class FaweForge implements IFawe { } else if (world instanceof EditSession) { return getWorldName(((EditSession) world).getWorld()); + } else if (world.getClass().getName().equals("com.sk89q.worldedit.bukkit.BukkitWorld")) { + try { + Class classBukkitWorld = world.getClass(); + Method methodGetWorld = classBukkitWorld.getDeclaredMethod("getWorld"); + methodGetWorld.setAccessible(true); + Object craftWorld = methodGetWorld.invoke(world); + Class classCraftWorld = craftWorld.getClass(); + Method methodGetHandle = classCraftWorld.getDeclaredMethod("getHandle"); + methodGetHandle.setAccessible(true); + Object nmsWorld = methodGetHandle.invoke(craftWorld); + return getWorldName((net.minecraft.world.World) nmsWorld); + } catch (Throwable e) { + e.printStackTrace(); + return world.getName(); + } } return getWorldName(((ForgeWorld) world).getWorld()); }