summaryrefslogtreecommitdiff
path: root/src/main/java/com/keuin/kbackupfabric/util/WorldUtil.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/com/keuin/kbackupfabric/util/WorldUtil.java')
-rw-r--r--src/main/java/com/keuin/kbackupfabric/util/WorldUtil.java15
1 files changed, 15 insertions, 0 deletions
diff --git a/src/main/java/com/keuin/kbackupfabric/util/WorldUtil.java b/src/main/java/com/keuin/kbackupfabric/util/WorldUtil.java
new file mode 100644
index 0000000..badc068
--- /dev/null
+++ b/src/main/java/com/keuin/kbackupfabric/util/WorldUtil.java
@@ -0,0 +1,15 @@
+package com.keuin.kbackupfabric.util;
+
+import net.minecraft.server.world.ThreadedAnvilChunkStorage;
+import net.minecraft.world.World;
+
+import java.io.File;
+
+public class WorldUtil {
+ public static String getWorldDirectoryName(World world) throws NoSuchFieldException, IllegalAccessException {
+ File saveDir;
+ ThreadedAnvilChunkStorage threadedAnvilChunkStorage = (ThreadedAnvilChunkStorage) ReflectionUtils.getPrivateField(world.getChunkManager(), "threadedAnvilChunkStorage");
+ saveDir = (File) ReflectionUtils.getPrivateField(threadedAnvilChunkStorage, "saveDir");
+ return saveDir.getName();
+ }
+}