Parsing config.yml

Discussion in 'Plugin Development' started by Nic2555, Apr 13, 2015.

Thread Status:
Not open for further replies.
  1. Offline

    Nic2555

    Hey could anyone teach me how could i parse the plugin.yml file and extract it to a .txt file or whatever that i could use to get an inputstream. Or any other way i could get a list of permissions
    Thanks !
     
    Last edited: Apr 13, 2015
  2. Offline

    teej107

    @Nic2555 You want to get the permissions defined in the plugin.yml?
     
  3. Offline

    Nic2555

    Yea, I need a list or an array list of every permission define in the plugin.yml
    but i'm not creating a plugin, so i can't access the craftbukkit.jar location directly, i need to set my own path to the .jar file of the plugins, and get the permissions out of them.
     
  4. Offline

    teej107

    So you need to get every permission defined in each plugin then, right?
     
  5. Offline

    Nic2555

    Yea exactly
     
  6. Offline

    teej107

    @Nic2555 But this is not through a plugin, so you can't use the Bukkit API right?
     
  7. Offline

    nverdier

    @Nic2555
    1. Iterate through the plugins that are enabled
    2. Get the plugin of the current iteration's description, and get the permissions from that. (plugin.getDescription().getPermissions()), which returns a List<Permission>.
    3. You can then iterate through that and get the name, children, etc.
    Of course, the plugin has to have to permissions registered in the plugin.yml for this to work.
     
  8. Offline

    teej107

    @nverdier
    Just be make sure I understand.
     
  9. Offline

    nverdier

    Ok now I'm very confused.
     
  10. Offline

    Nic2555

    I still can use the tools bukkit API is providing. I just need to understand how they works so i can use them correctly.

    Thanks for your reply. How could i iterate through enabled plugins if i'm not starting a server in anyways ?
    Can i , like, create a new plugin from the .jar and then use it to access the permission like the craftbukkit.jar would do ?
     
    Last edited by a moderator: Apr 17, 2015
  11. Offline

    nverdier

    @Nic2555 What do you mean by 'if i'm not starting a server in anyways'?
     
  12. Offline

    Konato_K

    @Nic2555 The real question here is what are you trying to do?
     
    nverdier likes this.
  13. Offline

    teej107

    I'll post how to do it with or without CB since I'm still confused whether this is an actual plugin like they usually are or not.
    Without CB:
    1. Loop through the jar file contents. Treat it like a zip file. http://stackoverflow.com/questions/1429172/how-do-i-list-the-files-inside-a-jar-file
    2. Use a library from here: http://yaml.org/ for easy read from YAML files. I think Bukkit uses Snake YAML.
    With CB:
    1. http://infernaldevelopers.com/docs/Bukkit/1.7/org/bukkit/plugin/PluginManager.html#getPlugins()
    2. http://infernaldevelopers.com/docs/Bukkit/1.7/org/bukkit/plugin/Plugin.html#getDescription()
    3. http://infernaldevelopers.com/docs/Bukkit/1.7/org/bukkit/plugin/PluginDescriptionFile.html
    This applies to both options: Permissions don't have to be registered in the plugin.yml so if their not, you're kind of SOL.
     
  14. Offline

    Nic2555

    Thanks, i'll work with that. I've allready got access to the plugin.yml using snakeyaml. But since there's plugin.yml file without permissions, I tought there could be a better way to access them.
    Anyways thanks for all the help. Hope it will work. If you are still interress in my project, i'm trying to make an automatic permission maker. Just to simplified the hard task of making permissions.
    Wish you a pretty good day !

    - Nic

    I'm not using craftbukkit jar. It's an external application. it's not a plugin so i can't use the craftbukkit.jar sources like this.getClass.getPlugin.~
     
    Last edited by a moderator: Apr 16, 2015
  15. Offline

    Konato_K

    @Nic2555 Can't you communicate with the server?
     
  16. Offline

    Nic2555

    it's not a server. it's an application, a java application. i'm not starting any kind of minecraft server, i just need to import each permission from the plugin.jar files.
     
  17. Offline

    nverdier

    @Nic2555 What exactly are you trying to accomplish?
     
  18. Offline

    teej107

    nverdier likes this.
  19. Offline

    Nic2555

    i need to show a list of every permission of a selected plugins.

    yea i allready got all this. but since there's plugin.yml whitout permissions, like Essentials, they got to be stored somewhere so i need to access these. And bukkit is allready doing it, i just wanted to know if there's way i could access them whitout running a server.

    EDIT by Timtower: merged posts
     
    Last edited by a moderator: Apr 17, 2015
  20. Offline

    nverdier

    @Nic2555 They are stored in the actual code. It is extremely difficult to get them from that.
     
  21. Offline

    Konato_K

    @Nic2555 No, plugins don't need to register permissions to use them, therefore there is no real way to accomplish this.
     
  22. Offline

    Nic2555

    I'm sure there is. It's just complicated, and that's what make it fun to accomplish ;)
     
  23. Offline

    teej107

    @Nic2555 Would be annoying and too much in my opinion. But you would have to read the class file and look for hasPermission keyword.
     
  24. Offline

    timtower Administrator Administrator Moderator

    Have fun with that. Let us know when you have the solution.
     
  25. Offline

    mythbusterma

    @Nic2555

    Decompile all of the code of the plugin, then look for string literals that look like permissions.
     
  26. Offline

    Nic2555

    actually did. Not a complete solution, but i was able to get the permissions, and manage to put the children under the parents. Lots of weird looking code, pretty ugly but working. Thanks for all of you guys, hope I can release that soon !
    Have a good day !

    -Nic
     
Thread Status:
Not open for further replies.

Share This Page