Skip to content

Instantly share code, notes, and snippets.

@0xilly
Last active August 29, 2015 14:04
Show Gist options
  • Save 0xilly/bceff9ec71c05ea7a410 to your computer and use it in GitHub Desktop.
Save 0xilly/bceff9ec71c05ea7a410 to your computer and use it in GitHub Desktop.
String getJsonFilePath(World world) {
String levelName = world.getWorldInfo().getWorldName();
String directory = "";
try {
String subDirectory = ( MinecraftServer.getServer() instanceof DedicatedServer )? "" : "saves/";
directory = subDirectory + levelName + "/stored_runes/";
} catch (Exception e) {
LogHelper.info("Server not found");
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