hello, I need a guide to creating YML file. I want insert data and find data in this file. I want make war plugin and i need save player group, amount of Kills and amount of death. To this i need YML file. tnx!
I think you should take a look at this: http://forums.bukkit.org/threads/tu...ration-api-create-a-yaml-configuration.42775/ greetz blackwolf12333
nir Use a filewriter/bufferedwriter to write stuff into the file. Code: File yml = new File("stuff.yml"); if (!yml.exists()) { yml.createNewFile(); }
It's not work: (not create yml) Code: package me.berkonir.main; import java.io.File; import java.io.IOException; import java.util.logging.Logger; import org.bukkit.plugin.PluginDescriptionFile; import org.bukkit.plugin.PluginManager; import org.bukkit.plugin.java.JavaPlugin; public class NiWar extends JavaPlugin { public static NiWar plugin; public final Logger logger = Logger.getLogger("Minecraft"); public final PlayerListener pl = new PlayerListener(); @Override public void onEnable() { PluginDescriptionFile pdffile = this.getDescription(); logger.info(pdffile.getName() + " is enabled"); PluginManager pm = getServer().getPluginManager(); pm.registerEvents(pl, this); PluginFile(); } @Override public void onDisable() { PluginDescriptionFile pdffile = this.getDescription(); logger.info(pdffile.getName() + " is disabled"); } private void PluginFile() { File pluginfile = new File("plugin.yml"); if (!pluginfile.exists()){ try { pluginfile.createNewFile(); } catch (IOException e) { e.printStackTrace(); } } } }
nir That path I gave you generated the file directly in the server's folder, not your plugins folder. To define the path inside the plugins folder and automatically create a new folder for your plugin, define the path in the name of the File. Code: File pluginfile = new File("plugins/NiWar/plugin.yml");
How i make default file to this? And i need a guide to the options for this function (File), you know guide? I intend to (Eg): pluginfile.getName() and all the option after the Pluginfile.
nir What do you mean by default file? You can call it on the onEnable() so that the plugin automatically creates the file. Also, here's the JavaDoc for File: http://docs.oracle.com/javase/1.4.2/docs/api/java/io/File.html
Ok, tnx! I have a question. How i add pach? YML file would look like this: Code: players: kills: nirbe: 5 I know how add something (pluginefile.set(player.getName(), "bla")). EDIT by Moderator: merged posts, please use the edit button instead of double posting.
I'd suggest you take a look at http://forums.bukkit.org/threads/42775/ and http://forums.bukkit.org/threads/52476/ and maybe http://forums.bukkit.org/threads/42770/ too