Getting another plugin's config file

Discussion in 'Plugin Development' started by thechrisanator, Apr 18, 2017.

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

    thechrisanator

    How would I access another plugin's config file? Well... it can't be the config file. It has to be a specific file. Named say.. 'types'
    How would I save that onEnable() as a variable?
     
  2. Offline

    timtower Moderator Moderator

  3. Offline

    thechrisanator

    My goal is to be able to use the inputs of that file from another plugin to use in mine. I want to import items from another plugin, that I have created in that file.
     
  4. Offline

    timtower Moderator Moderator

  5. Offline

    thechrisanator

    The plugin im trying to get data from is not my own. I just want the balues I put into the file
     
  6. Offline

    timtower Moderator Moderator

    @thechrisanator Which plugin is it?
    Digging through the file is generally not the best method of doing things.
    And if you do then you should do it through the plugin itself.
     
  7. Offline

    thechrisanator

    Alright. New way of doing things: hpw can I access the plugin itself? I realize ill need to use some of its features too. How do I access another plugin?
    The plugin is mythic mobs
     
  8. Offline

    timtower Moderator Moderator

    @thechrisanator Add it to your build path.
    Make it a dependency in the plugin.yml
    Get the Plugin, cast to the main class of the plugin.
    Use as any API
     
  9. Offline

    thechrisanator

    New stuff idk how to do... *sigh* how do people learn this stuff...
     
  10. Offline

    FabeGabeMC

    I thought of possibly looking for your plugin with the PluginManager#getPlugin(String name) method, then calling Plugin#getConfig() ?
    Example:
    Code:java
    1. Plugin myPlugin = getServer().getPluginManager().getPlugin("MyPlugin");
    2. FileConfiguration pluginConfig = myPlugin.getConfig();
     
  11. Offline

    timtower Moderator Moderator

    Trial and error, a lot of it.
    API might be a better way to go though.
     
  12. Offline

    thechrisanator

    Let me explain more specifically of what I plan on doing.
    If a player has a lore on their armour, my plugin will be like: oh, you have that lore! Now ill give you an ability from mythic mobs! (It might be particles, or attributes, etc)
    The mythic mobs plugin also has custom items that can be created in a YAML file. How can I access those?
     
  13. Offline

    timtower Moderator Moderator

  14. Offline

    thechrisanator

    How do I access another plugin though?..
     
  15. Offline

    timtower Moderator Moderator

    @thechrisanator
    PluginManager#getPlugin(String name)
     
  16. Offline

    thechrisanator

    So String Name would be... Mythic Mobs? Or do I need a specific part of it?
    And what does the # mean?
     
  17. Offline

    timtower Moderator Moderator

    @thechrisanator The # means that it is a method for PluginManager, which you need an instance of.
    And the name that /plugins spits out.
     
  18. Offline

    thechrisanator

    Ohh ok. So its basically the plugin name?
     
  19. Offline

    timtower Moderator Moderator

  20. Offline

    thechrisanator

    Ok. I have the plugin accessible. Im assuming that I should only get it onEnable, so that it only does it once. What would I do next?
     
  21. Offline

    timtower Moderator Moderator

  22. Offline

    thechrisanator

    Which ones I CAN use? Or which ones I WANT to use?
     
  23. Offline

    timtower Moderator Moderator

    @thechrisanator Well, you can use them all, but maybe you want to use 1 or 2.
     
  24. Offline

    thechrisanator

  25. Offline

    timtower Moderator Moderator

  26. Offline

    thechrisanator

    So what would I need to import, then?
     
  27. Offline

    timtower Moderator Moderator

    @thechrisanator Get the Plugin. Cast it to the MythicMobs class.
    Go from there.
    Your IDE should be able to handle the imports on its own.
     
  28. Offline

    thechrisanator

    So I have this:
    Plugin MythicMobs = getServer().getPluginManager().getPlugin("MythicMobs");
    but then I want to get the "item" YAML. How would I do that?
     
  29. Offline

    timtower Moderator Moderator

    @thechrisanator Cast it to MythicMobs, told you that before.
    And don't start parsing those yml files yourself.
    MythicMobs already did that for you, just you need to find the items.
     
  30. Offline

    thechrisanator

    I feel so... dumb. Is there a file that explains "casting" and stuff like this?
     
Thread Status:
Not open for further replies.

Share This Page