and you shouldn't use == but .equals, better. example: private String test = "blabla"; if(test.equals("blabla"){ System.out.println("this is the case"); } else if(test.equals("lolilol"){ System.out.println("this isn't the case");
root would be items and null is the default value and of course the list doesn't have a value by itself so it gives it a default value of null . Understand?
It's still unfinished but this is what I've done so far http://forums.bukkit.org/threads/plugin-development-a-huge-tutorial-status-under-development.15167/
I got the file in sync with the plugin. Now as I said, the only thing to do is check every array... There's no function for that then? The splitString worked, but I have to point out a single array every time. Is there no way to check every array at once? Something such as "<variable>[ANY]"?
You could use a for loop. int i; for(i=0; i <= yourarray.length();i++){ } This checks if i is smaller than or equal to your arrays length(number of items/index's) then check whatever. I will be making a tutorial on this, it's a simple concept but difficult to understand unless tought
Thanks alot everyone for all the help here . When I added some more stuff to allow easier editing, I will publish the plugin and put you all in the credits. You're the best :3 Again, if I need help, I'll just come back again
Right, now there's another thing I don't know how to do. Putting stuff in the yaml file. I made it so the plugin creates the yml file, but then I want it to add the structure as well. It's really easy: Items: - tnt - bedrock Something like this, for instance. Anyone knows how to do this?
I do it like this: Code: public Configuration load() { try { Configuration PluginPropConfig = new Configuration(Ranksfile); PluginPropConfig.load(); return PluginPropConfig; } catch (Exception e) { } return null; } public void saveRaffleMaker(String maker) { Configuration config = load(); config.setProperty("RaffleMaker", maker); config.save(); } public void saveTickets(ArrayList<String> Tick) { Configuration config = load(); config.setProperty("UnSoldTickets", Tick); config.save(); } If you want minecraft item you need to store the info, like Material ID or Type and ItemStack amount
I'm trying to figure out what everything means... Having some trouble with it though. For instance: Code: Configuration PluginPropConfig = new Configuration(Ranksfile); What's Ranksfile supposed to be? I tried inserting my config.yml file there, but that didn't work. And well... I don't really understand anything of this code :/ Could you maybe annotate it for me? What every line does?
I'll be adding this to my tutorial so I'll explain it in depth there but it's similar to how the properties files works. Ranksfile would be the location of the file, I think Sammy forgot to include it in his code, but it would probably look like this. Code: static File Ranksfile = new File("plugins/" + "Ranks" + File.separator + "Ranks.config"); Configuration PluginPropConfig = new Configuration(Ranksfile);
Mmm yes.... Now the part where you actually add stuff to the file, that's what I really don't understand.
I'll explain, it's really simple once you get it. Did you understand my tutorial on Filehanding though?
That's a whole different kind of file, right? YML files uses a certain format for it to work (ie: you can't use tabs, it has to be 4 spaces"). So I suppose there is a special way of putting stuff in a certain branch.
Alright, I got one part figured out now. I know how to make the plugin write in a file, now I want it to list a few items. This is what my config file looks like after creation: Code: items: ' - lava_bucket' And this is the code: Code: config.setProperty("items", "\n- lava_bucket"); When I removed the \n, it didnt give the ', but it put lava_bucket right next to it. Like so: Code: items: - lava_bucket What I want it to become is: Code: items: - lava_bucket The syntax for "setProperty" is: Code: String arg0, Obj arg0 Anyone has an idea here?
to list multiple items in the yml file, you must send an array in the second argument: config.setProperty("items", SEND ARRAY HERE); its easy dw
Code: List<String> itemList = new ArrayList<String>(); itemList.add("lava_bucket"); config.setProperty("items", itemList); Not an array, but close.
To keep the whole idea concise you can simultaneously declare and initialize the variable within the for loop info: for(int i = 0 ; i <= yourarray.length() ; i++){}
Hey guys, I've already figured this out (see my plugin) There's one other thing I don't know though, I don't know how to reload a config file... I've made a different thread about it, but didn't get a reaction on it.