Fix thermos getWorldName

This commit is contained in:
Jesse Boyd 2018-01-20 20:41:23 +11:00
parent 5125a18540
commit ca906cc8c3
No known key found for this signature in database
GPG Key ID: 59F1DE6293AF6E1F

View File

@ -17,6 +17,7 @@ import com.sk89q.worldedit.world.World;
import cpw.mods.fml.common.FMLCommonHandler; import cpw.mods.fml.common.FMLCommonHandler;
import cpw.mods.fml.common.ModMetadata; import cpw.mods.fml.common.ModMetadata;
import java.io.File; import java.io.File;
import java.lang.reflect.Method;
import java.nio.charset.StandardCharsets; import java.nio.charset.StandardCharsets;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collection; import java.util.Collection;
@ -132,6 +133,21 @@ public class FaweForge implements IFawe {
} }
else if (world instanceof EditSession) { else if (world instanceof EditSession) {
return getWorldName(((EditSession) world).getWorld()); 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<? extends Object> 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()); return getWorldName(((ForgeWorld) world).getWorld());
} }