I'm not sure if this is the right section to put this question, but here goes. I need help coding a custom plugin (Spigot 1.8). I've got the basic framework down for a few simple commands and a config file. However, I am creating a custom mini game plugin for a game I am going to put on my server. The plugin will let me create multiple arenas for this game. I would like the plugin to create a new config file for every arena that is created? How can I do this? I looked up creating multiple config files, and I found something that let me create multiple config files, but I had to create them in the plugin itself. The plugin couldn't keep creating more and more files based on commands.
This is the code I used to create a custom config file
What you need to do is white up a custom file handler that will make new files in your plugin's folder on demand. Look into JSON and how to create,edit,and read files. With tis you can create a method that will create a new file with whatever name you want and even put hem in a separate folder inside your plugin's folder to make everything nice and neat.
What you need to do is white up a custom file handler that will make new files in your plugin's folder on demand. Look into JSON and how to create,edit,and read files. With tis you can create a method that will create a new file with whatever name you want and even put hem in a separate folder inside your plugin's folder to make everything nice and neat.
I'm not sure if this is the right section to put this question, but here goes. I need help coding a custom plugin (Spigot 1.8). I've got the basic framework down for a few simple commands and a config file. However, I am creating a custom mini game plugin for a game I am going to put on my server. The plugin will let me create multiple arenas for this game. I would like the plugin to create a new config file for every arena that is created? How can I do this? I looked up creating multiple config files, and I found something that let me create multiple config files, but I had to create them in the plugin itself. The plugin couldn't keep creating more and more files based on commands.
This is the code I used to create a custom config file
private File arenaFile = null;
private FileConfiguration arenaConfig = null;
publicvoid reloadArenaConfig() throws UnsupportedEncodingException
{
if(arenaFile == null)
{
arenaFile = new File(getDataFolder(), "arena.yml");
}
arenaConfig = YamlConfiguration.loadConfiguration(arenaFile);
Reader arenaConfigStream = new InputStreamReader(this.getResource("arena.yml"), "UTF8");
if(arenaConfigStream != null)
{
YamlConfiguration defConfigA = YamlConfiguration.loadConfiguration(arenaConfigStream);
arenaConfig.setDefaults(defConfigA);
}
}
public FileConfiguration getArenaConfig()
{
if(arenaConfig == null)
{
try {
reloadArenaConfig();
} catch (UnsupportedEncodingException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
returnarenaConfig;
}
publicvoid saveArenaConfig()
{
if(arenaConfig == null || arenaFile == null)
{
return;
}
try {
getArenaConfig().save(arenaFile);
} catch (IOException ex) {
// TODO Auto-generated catch block
getLogger().log(Level.SEVERE, "Could not save arena config to " + arenaFile, ex);
}
}
publicvoid saveDefaultArenaConfig()
{
if(arenaFile == null)
{
arenaFile = new File(getDataFolder(), "arena.yml");
}
if(!arenaFile.exists())
{
plugin.saveResource("arenaConfig.yml", false);
}
}
public FileConfiguration getArenaConfig;
(This is not the full code for my entire plugin, just the part relevant to creating the custom config)
So does anyone have any ideas?
Anyone out there know the answer?
Please?
What you need to do is white up a custom file handler that will make new files in your plugin's folder on demand. Look into JSON and how to create,edit,and read files. With tis you can create a method that will create a new file with whatever name you want and even put hem in a separate folder inside your plugin's folder to make everything nice and neat.
For plugin support jump over to the Bukkit forums http://bukkit.org/forums/plugin-development.5/
The developers are still very much active on the forums there.
Ok, thank you. i will post my question there as well, and in the meantime, Iw ill look into JSON.