Dependencies?

Discussion in 'Plugin Development' started by DarthAimbot, Aug 28, 2015.

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

    DarthAimbot

    I am trying to make a plugin.

    I want to put the user into a war game using the war plugin but also modify some stats of the game, does anyone know/care to share how I could access data from other plugins inside my own?
     
  2. Offline

    mrgreen33gamer

    So what you want to do is get variables and other data from a plugin you've already created/Extend off of another plugin?
     
  3. Offline

    au2001

    @DarthAimbot Check if the plugin you want to use has an API (he probably does), if so there will be a documentation that you can read to know how to use it.
     
  4. Offline

    mrgreen33gamer

    @au2001 If he's trying to use another plugin, for instance building off of essentials, Vault, etc, can't he just right click his project, goto properties, goto Java Build Path, and Add External JARs? Or am I reading the post wrong?
     
  5. Offline

    DarthAimbot

    @au2001 @mrgreen33gamer
    So, how do I implement that plugin, just so I can test if it works, say I make a plugin with a class "Turret" and inside that class it has like a enum or somthing that stores all the data, how would I implement that plugin in another and change the data?
     
  6. Offline

    au2001

    @DarthAimbot For the war plugin, look at their github since they don't have any API.
    You'll have to, as @mrgreen33gamer said, add external jars and add it as dependency in your plugin.yml.
     
  7. Offline

    DarthAimbot

    @au2001 I think this will work, I am just confused about the process as well as how the mechanical state works.

    Like if, I make my own Econ plugin, and make a function called Add money, and in another plugin wanted to make it so whenever you got a kill it ran add money function from the first plugin, how would I do that? without using hidden commands.
     
  8. Offline

    mrgreen33gamer

    @DarthAimbot

    Firstly, make sure you have imported your API you're using to your plugin, steps are below, then you make that method a Static for adding money, then you just add the class name then the method. Example:

    Code:java
    1. ImportedClass.addMoney();


    Then make sure the packages from the ImportClass are similar to the imported plugin.

    Steps to adding a external JAR:

    1. Right click your project.
    2. Click properties.
    3. Then to the left, click on the 'Java Build Path' tab.
    4. Now select the tab to the top named: Libraries.
    5. Now click the button to the right called: Add External Jars.
    6. Now find and select your .JAR file you wish to add.
    7. Now that you've selected you .JAR file, click open.
    8. After that, in the properties window, click OK.
    9. Now goto your plugin.yml file and add:
    Code:
    depend: [IMPORTEDFILENAME] 
    10. You're done! You can now grab methods from that JAR file and add them to yours!
     
  9. Offline

    au2001

    in eclipse*
    You could also use maven but that's a tutorial for another day.
     
  10. Offline

    DarthAimbot

    @mrgreen33gamer @au2001

    I went to project structure -> modules -> dependencies -> + -> Jars, But I still don't know how to access stuff from them, I tried something like,
    Code:
     import test.testMain; 
    testMain main = new testMain();
    main.addMoney(player, 5)
    
    but id does not notice any of the methods in my other plugin.
    :(
     
    Last edited: Aug 29, 2015
  11. Offline

    au2001

  12. Offline

    DarthAimbot

    @au2001
    The Package names are Different, the methods are Static, but nothing pops up. I have tried to find example code, but just can't. :(
     
  13. Offline

    timtower Administrator Administrator Moderator

    @au2001 Static isn't really a best practise.
    @DarthAimbot Added to your build path? Can you show the full code?
    And never make a new instance of a class extending JavaPlugin please.
     
  14. Offline

    au2001

    Especially if the methods you're trying to use are static ;)
     
  15. Offline

    DarthAimbot

    @timtower
    How do I access configs then?
     
  16. Offline

    timtower Administrator Administrator Moderator

    You pass the original instance around
     
  17. Offline

    DarthAimbot

    I think that is what I am doing, I am doing this.
    Code:
    private final main plugin; public Warps_Menu(JavaPlugin plug){
    plugin = (main) plug;}
    
    @timtower
     
    Last edited: Sep 2, 2015
Thread Status:
Not open for further replies.

Share This Page