Hey guys, I got a big problem. I've been searching on the internet and find nothing about it. I need a function that will return me the permission of a plugins. The things is, that I don't wanna use bukkit libs for that, I would like to make it independent. How could I return an ArrayList of all the permission of a certain plugins, located in a directory. For exemple " C:\User\Desktop\Minecraft\Plugins" Thanks ! - Nic,.
Nic2555 You want to get the file as in the file PermissionsEX as an example stores permissions in? You should probably look into BufferedReaders if you don't know them already.
What I want it everythings under Permission: pushed into an arraylist. here an exemple : Code: permissions: lottery.*: description: Full access to Lottery plugin. children: lottery.buy: true lottery.admin.draw: true lottery.admin.addtopot: true lottery.admin.editconfig: true lottery.buy: description: Basic lottery rights. Can buy, check lottery info and claim winnings. default: true lottery.admin.draw: description: Access to /lottery draw command. default: op lottery.admin.addtopot: description: Access to /lottery addtopot command. default: op lottery.admin.editconfig: description: Access to ingame config editing and reloading. default: op I just need the name of the permission and another arrayList for the description, that would be awesome <Edit by mrCookieSlime: Merged posts. Please dont double post. There is an Edit-Button right next to the Date.>
Bad idea, use HashMaps if your storing 2 values that are closely related such as a permission(Key) and a description (Value) Code:java //Example:HashMap<Key,Value> example = new HashMap<>(); //Application:HashMap<String,String> perms = new HashMap<>();perms.put("lotto.create", "creates a lottery");// Puts Key(lotto.create) and Value (creates a lottery) in to the hashmap, "creates a lottery" is now the value for key "lotto.create" public String getDesc(String perm) {if(perms.contains(perm)) //Checks if perms contains the key perm{return perms.get(perm);//returns the value of perm}} That could may or may not work, I wrote it in browser
Could I sort the HashMap in a two colum list after that ? Like : [] (checkbox) {Permission} {Description}
Nic2555 You could iterate through every line using a BufferedReader and then parsing the String. EDIT: So you want to be able to get values from your "plugin.yml" file or the "permissions.yml" file in PermissionsEX?
As far as I know you could but I'm not super experienced with HashMaps, loop through all the entries and print them out into each column maybe? Edit: Aw man, Ninja'd
Nic2555 A few quick googles found me this: Code: File file = new File(this.getClass().getResource("path/to/file.txt").getFile()); Then you could try something like Code: FileConfiguration theFile = YamlConfiguration.loadConfiguration(file); No idea if this will work but it is worth a shot
Nic2555 Provide a valid reason why you shouldn't use YAML in a plugin. Also, it isn't "based on Bukkit," it's a separate library called "SnakeYAML." What's your issue with it? You also haven't even told us what your problem is, as you can't use anything other than YAML to create the plugin file.
Nic2555 Then your going to have to go pretty deep. Here is how to read a file line by line. You will have to parse each line yourself. Code: BufferedReader reader = new BufferedReader(new FileReader("stuff.txt"); for(String line; (line = br.readLine()) != null;) { String key = line.substring(0, line.indexOf(":")); } reader.close(); if the file has one line and looks like Code: thisKey: 'value' key will equal "thisKey"
mythbusterma The yaml are allready created, i just need to use them. they are in the plugin.jar, I need to use them. this is the issue. But i'll try the YAMLconfiguration things.