Skip to content

Instantly share code, notes, and snippets.

@0xilly
Created July 31, 2014 04:28
Show Gist options
  • Save 0xilly/6e0dd79d4672cbbef604 to your computer and use it in GitHub Desktop.
Save 0xilly/6e0dd79d4672cbbef604 to your computer and use it in GitHub Desktop.
String getJsonFilePath(World world) {
String levelName = world.getWorldInfo().getWorldName();
try {
String subDirectory = ( MinecraftServer.getServer() instanceof DedicatedServer )? "" : "saves/";
String directory = subDirectory + levelName + "/stored_runes/";
new File(directory).mkdirs();//ensure the folder exists
String fileName = directory + shortClassName() + ".json";
return fileName;
} catch (Exception e) {
LogHelper.info("Server not found");
String directory = "saves" + levelName + "/stored_runes/";
new File(directory).mkdirs();//ensure the folder exists
String fileName = directory + shortClassName() + ".json";
return fileName;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment