Pull config dir from FMLPaths

This commit is contained in:
Kenzie Togami 2019-02-21 00:40:00 -08:00
parent aa295d91e8
commit a0f127813d
No known key found for this signature in database
GPG Key ID: 5D200B325E157A81

View File

@ -55,11 +55,16 @@ import net.minecraftforge.fml.event.server.FMLServerAboutToStartEvent;
import net.minecraftforge.fml.event.server.FMLServerStartedEvent; import net.minecraftforge.fml.event.server.FMLServerStartedEvent;
import net.minecraftforge.fml.event.server.FMLServerStoppingEvent; import net.minecraftforge.fml.event.server.FMLServerStoppingEvent;
import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext; import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext;
import net.minecraftforge.fml.loading.FMLPaths;
import net.minecraftforge.registries.ForgeRegistries; import net.minecraftforge.registries.ForgeRegistries;
import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger; import org.apache.logging.log4j.Logger;
import java.io.File; import java.io.File;
import java.io.IOException;
import java.io.UncheckedIOException;
import java.nio.file.Files;
import java.nio.file.Path;
/** /**
* The Forge implementation of WorldEdit. * The Forge implementation of WorldEdit.
@ -79,7 +84,7 @@ public class ForgeWorldEdit {
private ForgePlatform platform; private ForgePlatform platform;
private ForgeConfiguration config; private ForgeConfiguration config;
private File workingDir; private Path workingDir;
private ModContainer container; private ModContainer container;
@ -99,8 +104,14 @@ public class ForgeWorldEdit {
this.container = ModLoadingContext.get().getActiveContainer(); this.container = ModLoadingContext.get().getActiveContainer();
// Setup working directory // Setup working directory
workingDir = new File(event.getModConfigurationDirectory() + File.separator + "worldedit"); workingDir = FMLPaths.CONFIGDIR.get().resolve("worldedit");
workingDir.mkdir(); if (!Files.exists(workingDir)) {
try {
Files.createDirectory(workingDir);
} catch (IOException e) {
throw new UncheckedIOException(e);
}
}
config = new ForgeConfiguration(this); config = new ForgeConfiguration(this);
config.load(); config.load();
@ -296,7 +307,7 @@ public class ForgeWorldEdit {
* @return the working directory * @return the working directory
*/ */
public File getWorkingDir() { public File getWorkingDir() {
return this.workingDir; return this.workingDir.toFile();
} }
/** /**