Hooking into iConomy API

Discussion in 'Plugin Development' started by Tehmaker, Sep 28, 2013.

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

    Tehmaker

    Hey guys, I have never hooked into another plugin's api,.... I am working on an RP server, and I need to be able to charge players for buying permits... I would just send a console command to remove money from the players account, but I am not sure how I would check to make sure that they have enough money for it...

    I looked for the hooked.java class that the iConomy creators made, but it is 2 years outdated. I would appreciate any help.
     
  2. Offline

    Jogy34

    I'd recommend using Vault. It had support for multiple economy systems and it has a really easy to use API. All you have to do is add the .jar to your build path like you did with the Bukkit.jar and then you just add in the setupEconomy() method to your main class along with an Economy variable and call the method in your on enable. You can then use this to get players' in game money and add to it and take away from it easily. This will also make your plugin easier to use for other server (if you plan on releasing it) because Vault supports a large number of different economy plugins.
     
  3. Offline

    Tehmaker

    Thanks, I will screw with vault :D

    Code:
    economy.depositPlayer(p.getName(), -10000);
    
    is this correct?

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 4, 2016
  4. Offline

    KoolSource

    -Snip- Not needed.

    Also, you don't use negative numbers with Vault. There are two methods:
    depositPlayer and withdrawPlayer. In your example above you would want to use withdrawPlayer(p.getName(),10000).

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 4, 2016
  5. Offline

    Jogy34


    There is no need for the permission (at all) or chat from vault since he only is looking for economy and, as I said, the setup economy method is found at the bottom of the Vault page
     
  6. Offline

    Tehmaker

    alrighty! Thanks for the help. I followed the github instructions, and set everything up, and it should be working right... Only issue is when I import economy, it doesn't do anything...

    I have vault in my referenced libraries, but it seems to just becomea an unresolved import when I type it myself, and when I use Eclipse to import it, it is just an error....
     
Thread Status:
Not open for further replies.

Share This Page