summaryrefslogtreecommitdiff
path: root/src/main/java/com/keuin/kbackupfabric/util/WorldUtil.java
blob: badc0687ebdb0a4b50136d9ac4f0eb490dcdea11 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
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();
    }
}