Search in sources :

Example 1 with FolderName

use of net.minecraft.world.storage.FolderName in project Fragile-Glass by fredtargaryen.

the class DataManager method setupDirsAndFiles.

public void setupDirsAndFiles(MinecraftServer ms) {
    // Get path to serverconfigs folder of world as File object
    // ms.getActiveAnvilConverter().getFile(ms.getFolderName(), "serverconfig");
    this.configDir = ms.func_240776_a_(new FolderName("serverconfig")).toFile();
    this.configFile = new File(this.configDir, DataReference.MODID + "_" + this.typeString + ".cfg");
    if (!this.configFile.exists()) {
        try {
            // Config file is not in config folder! Write from defaultFileData (see bottom of file)
            FragileGlassBase.warn("[FRAGILE GLASS CONFIG] " + DataReference.MODID + "_" + this.typeString + ".cfg not found! Writing a new one.");
            FileWriter fw = new FileWriter(this.configFile);
            for (String s : this.getDefaultConfigFileText()) {
                fw.write(s);
            }
            fw.close();
        } catch (IOException ioe) {
            this.handleConfigFileException(ioe);
        }
    }
}
Also used : FolderName(net.minecraft.world.storage.FolderName)

Example 2 with FolderName

use of net.minecraft.world.storage.FolderName in project mxTune by AeronicaMC.

the class FileHelper method initialize.

/**
 * Stores the path of the server side 'world' folder. This changes based on the chosen save folder for SP/LAN
 * integrated server or the 'level-name' property in the server.properties for dedicated servers.
 * <p></p>
 * This needs to be called from the {@link FMLServerStartingEvent}
 */
public static void initialize(MinecraftServer server) {
    // The top level "world" save folder a.k.a. the "Over World"
    // .getActiveAnvilConverter().getFile(server.getFolderName(), "serverconfig").toPath();
    // File chunkDir = server.getActiveAnvilConverter().getFile(server.getFolderName(), "");
    File chunkDir = server.getWorldPath(new FolderName("")).toFile();
    serverWorldFolder = Paths.get(chunkDir.getPath());
    LOGGER.debug("FileHelper: serverWorldFolder {}", serverWorldFolder.toString());
}
Also used : File(java.io.File) FolderName(net.minecraft.world.storage.FolderName)

Example 3 with FolderName

use of net.minecraft.world.storage.FolderName in project AstralSorcery by HellFirePvP.

the class CommonProxy method getASServerDataDirectory.

public File getASServerDataDirectory() {
    MinecraftServer server = LogicalSidedProvider.INSTANCE.get(LogicalSide.SERVER);
    if (server == null) {
        return null;
    }
    File asDataDir = server.func_240776_a_(new FolderName(AstralSorcery.MODID)).toFile();
    if (!asDataDir.exists()) {
        asDataDir.mkdirs();
    }
    return asDataDir;
}
Also used : File(java.io.File) FolderName(net.minecraft.world.storage.FolderName) MinecraftServer(net.minecraft.server.MinecraftServer)

Aggregations

FolderName (net.minecraft.world.storage.FolderName)3 File (java.io.File)2 MinecraftServer (net.minecraft.server.MinecraftServer)1