[ECO/FIX]FayConomy v1.4 - iConomy to Essentials Eco Bridge [740]

Discussion in 'Inactive/Unsupported Plugins' started by xeology, Apr 28, 2011.

  1. Offline

    xeology

    FayConomy - iConomy to Essentials Eco Bridge:
    - Doubles as Essentials Eco API - EcoAPI
    Version: v1.4

    THIS IS INCLUDED IN ESSENTIALS!

    Use these if you are using the new version! ONLY USE 1 BY THE VERSION YOU NEED!

    http://dl.dropbox.com/u/18601879/EssentialsiConomyBridges.rar


    Ever want all those awesome iConomy plugins for Essentials Eco? Are you a developer and wanted an easy API for Essentials Eco? Well guess what! I got your solution!

    FayConomy (Fake - iConomy) is a mock API of iConomy's API while pretending to be iConomy. It will take iConomy API calls and reformat and redirect them directly into Essentials Eco!

    FayConomy also supports non-player accounts separate from Essentials but following their standards! Now you can have plugins that work with such features in iConomy such as iCoLand.

    If you are curious on how it is done the source is in the JAR and FULLY annotated. To develop using the API just develop as if it were iConomy using the iConomy JAR.

    WARNING: Do NOT attempt to run this with iConomy or without Essentials Eco! Do NOT delete the config.yml in the iConomy folder, this belongs to FayConomy. If you have a file with that name PRIOR to installing FayConomy then back it up and remove it!


    Features:
    • Bridges iConomy API over to Essentials Eco!
    • Custom API for Essentials Eco that is simple, easy and intuitive!
    • Bridges Deprecated API Functions for reverse compatibility
    • Fixes improper use of the API and makes it work regardless of the improper usage
    • Makes iConomy plugins work with Essentials Eco!
    • Adds NPC account support to Essentials Eco!
    • Change the name of the Currency!
    • Basic Persistance with configurable save times (in minutes!)
    Download The Plugin

    Source Code is in the JAR

    Install:
    • Just install the JAR
    • Run once, then open the iConomy\config.yml and change SaveRate: 10 to any amount in minutes that you may want!
    • Open the iConomy\config.yml and change CurrencyName and MultipleCurrencyName to whatever you like!
    Tested Plugins:

    • CookieMonster
    • iCoLand
    • MultiVerse
    • Towny
    ToDo:

    • Create a method for storing non-player money in Essentials
    • Bug fixes? +4
    • Optimization As optimized as it will get, no loops, no constants, no arrays, NOTHING
    • Get rid of my hacky Essentials iConomy Check bypass (ALMOST!)
    Changelog:

    Show Spoiler

    Version 1.4
    • Added Essentials Eco API, EcoAPI. Easier, less confusing and more intuitive. ONLY SUPPORTS ESSENTIALS!
    Version 1.3
    • Now allow improper iConomy API usage and fixes the negative results of such usage!
    • Added Currencyname and MultipleCurrencyName.
    Version 1.2
    • Added left out iConomy API, even the Deprecated ones!
    • Added NPC support!
    • Added basic lightweight persistance Minor fixes
    Version 1.1
    • Removed ALL loops
    • Removed ALL arrays
    • Removed ALL methods for storing
    • NEW, LIGHTER and IMPROVED!
    • Fixed decimals messing up essentials, essentials just doesn't handle them well so I truncate!
    • Direct player access opposed to storing player references on login
    Version 1.0b
    • Fixed the pesky ArrayIndexOutofBounds error, sorry guys, should have tested better!
    Version 1.0
    • Released


    Essentials Eco API - For Devs!
    Show Spoiler
    First off you will want to make sure you are checking for FayConomy so your not hooking into iConomy. Here is what you put in your main somewhere,

    Show Spoiler

    Code:
        private void detectFay() throws NoSuchMethodException{
            try{
            if (com.nijiko.coelho.iConomy.iConomy.isFay()){
                System.out.println("FayExtended - Linked with FayConomy!");
                return;
            }
            }
            catch(Throwable ex){
                System.out.println("FayExtended - YOU NEED FAYCONOMY!");
                throw new NoSuchMethodException();
            }
            System.out.println("FayExtended - YOU NEED FAYCONOMY!");
            return;
        }
    


    Put this in your onEnable()

    Code:
    detectFay();
    

    Put this in the import area of whatever class is going to use FayConomy hooks,

    Code:
    import com.nijiko.coelho.iConomy.EcoAPI;
    
    OR
    
    if you will be using the Essentials Version of this it will be
    
    import com.earth2me.essentials.EcoAPI;
    
    Here are a few rules, follow them well!

    Show Spoiler

    Accounts for npc's must be made first.

    Do not bother will decimals right now they will be truncated until Essentials Eco supports them.

    You will have to have your methods using the following hooks throw NoSuchMethodException, this is because that is the only way I can stop Essentials Eco calling to FayConomy thinking it is iConomy.

    The API will NEVER have anything removed or reformatted. I will ONLY change their internals in a way that does not break plugins unless some act of GOD stops me from keeping this promise.

    I may add new things, I may not. Doubles will be supported eventually!


    These are the player account checks

    Show Spoiler

    EcoAPI.getMoney(String player);

    - This gets the player's balance
    !Returns double


    EcoAPI.isNegative(String player);

    -This will see if it the player's balance is negative or not
    !Returns boolean


    EcoAPI.hasEnough(String player, double amount) ;

    - Will see if the player can afford amount
    !Returns boolean


    EcoAPI.hasMore(String player, amount);

    - Will see if the player has more than the amount
    !Returns boolean


    EcoAPI.hasLess(String player, amount);

    -Will see if the player has less than the amount
    !Returns boolean


    EcoAPI.getCurrency() ;

    - This will return the currency set by the admin
    !Returns String


    EcoAPI.getCurrencyPlural();

    - This will return the currency set by the admin in plural
    !Returns String


    These are the player account modifiers

    Show Spoiler

    EcoAPI.setMoney(String player, double amount);

    -This will set the player's balance


    EcoAPI.add(String player, amount);

    - This will add the amount to the player's balance


    EcoAPI.subtract(String player, amount);

    - This will subtact from the player's balance


    EcoAPI.multiply(String player, double multiplier);

    -This will multiply the player's balance by the multiplier.


    EcoAPI.multiply(String player, double dividend);

    -This will divide the player's balance by the dividend.


    EcoAPI.resetBalance(String player);

    - This will reset the player's balance to 0!


    Here are the NPC functions, YOU MUST USE newAccount() BEFORE PROCCESSING AN NPC'S ACCOUNT AS A PLAYER!

    Show Spoiler

    EcoAPI.newAccount(String npc);

    - This will generate a new npc account, it will not recreate existing accounts!
    !Returns boolean, true for success and false for already exists!


    EcoAPI.accountExist(String Name);

    -This will return if the npc's account exists
    !Returns boolean


    EcoAPI.removeAccount(String name);

    - This will remove an EXISTING npc account!


    Credits:
    • Makers of Essentials
    • Makers of iConomy
    • Guys on IRC for aid with my iConomy Check Bypass (one was scared of what I was doing lol)
    • Me for the time and code, Xeology
     
    Xordaii and KidCanada like this.
  2. Offline

    lamnea

    respect to this plugin!
     
  3. Offline

    andrewkm

    GREAT!
    i have a massive server running off essentials economy, will test out soon once the plugin gets more feedback.
     
  4. Offline

    ementalo

    We approve :)
     
  5. Offline

    xeology

    Very nice :D Now lets blow iConomy away!
     
  6. Offline

    TACTICALboom

    1 thing. Sweeeeeeeeet.
     
  7. Offline

    quickclay

    I continuously get "Whatever plugin is calling for users that are not players may be incompatible right now"
    Also, players balance has an infinite number of decimal places.. switched to whole numbers now, but can't reset players balances due to above error.
    Hmm and when I buy something from an essentialseco sign, the balance isn't reduced when I type /balance.
    CB733 Essentials 2.2.6
     
  8. Offline

    xeology

    What plugin? If the plugin still functions then it is not an issue however it may be down the road. I have not yet created a way to hook into Essentials database.

    Working on infinite decimals now . . .

    That is going to be resolved as well.

    1. Not an issue if the plugin doesnt actually NEED its own account (icolands)
    2. Resolved, truncates the decimals, essentials doesnt like them
    3. Tested this and it is resolved now.
    Thank you for the bug reports, 1 internetz to you!

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

    quickclay

    Great work, thanks! :)
     
  10. Offline

    MeinerHosen

    This is amazing.

    Just. Amazing.
     
  11. Offline

    Godofallcows

    So you don't need iConomy at all for this?
     
  12. Offline

    xeology

    Nope. Infact you cannot use economy with this. Sorry.
     
  13. Offline

    Rufus

    Does this work with towny? it'd be really cool if it did. o.o
     
  14. Offline

    xeology

    It does. Towny runs on my server.
     
  15. Offline

    Rufus

    Sweet, totaly will have to give this a go then, I like Essentials over Iconemy because its simple and has sign shops and now I get towny as well! Thank you! :)

    Eh what version are you using? Because I get this error when I try to start a town, it takes my money but towny doesn't set up the town.

    Code:
    13:30:35 [INFO] Account: com.nijiko.coelho.iConomy.system.Account@16369fdc
    13:30:35 [SEVERE] Could not pass event PLAYER_COMMAND_PREPROCESS to Towny
    java.lang.NoSuchMethodError: com.nijiko.coelho.iConomy.system.Account.save()V
            at ca.xshade.bukkit.towny.object.TownyIConomyObject.pay(TownyIConomyObje
    ct.java:32)
            at ca.xshade.bukkit.towny.event.TownyPlayerListener.newTown(TownyPlayerL
    istener.java:1133)
            at ca.xshade.bukkit.towny.event.TownyPlayerListener.parseTownCommand(Tow
    nyPlayerListener.java:926)
            at ca.xshade.bukkit.towny.event.TownyPlayerListener.onPlayerCommandPrepr
    ocess(TownyPlayerListener.java:412)
            at org.bukkit.plugin.java.JavaPluginLoader$5.execute(JavaPluginLoader.ja
    va:230)
            at org.bukkit.plugin.RegisteredListener.callEvent(RegisteredListener.jav
    a:59)
            at org.bukkit.plugin.SimplePluginManager.callEvent(SimplePluginManager.j
    ava:257)
            at net.minecraft.server.NetServerHandler.handleCommand(NetServerHandler.
    java:669)
            at net.minecraft.server.NetServerHandler.chat(NetServerHandler.java:640)
    
            at net.minecraft.server.NetServerHandler.a(NetServerHandler.java:634)
            at net.minecraft.server.Packet3Chat.a(Packet3Chat.java:32)
            at net.minecraft.server.NetworkManager.a(NetworkManager.java:195)
            at net.minecraft.server.NetServerHandler.a(NetServerHandler.java:74)
            at net.minecraft.server.NetworkListenThread.a(SourceFile:100)
            at net.minecraft.server.MinecraftServer.h(MinecraftServer.java:370)
            at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:285)
            at net.minecraft.server.ThreadServerApplication.run(SourceFile:394)
    13:30:35 [INFO] Rufus_Shinra tried command: town new new
    CB:740 With lastest version of Essentials and Fuzze's 740 version of towny. What are you using to make it work because I'd love towny to work on my server with Essentials. :)
     
  16. Offline

    Tottely

    :) Perfect guess it work with essentials buy and sell signs?
     
  17. Offline

    xeology

    Ill fix this. Didnt include that part in the API bridge, best wait for 1.2 anyways as this version doesnt support npc accounts but my next one will (almost done).
     
  18. Offline

    Rufus

    Wow, thank you that will be totaly wickid if you manage to pull it off. I'll be keeping an eye on this thread then, ygmd. :D
     
  19. Offline

    eJohn

    Awesome! I posted a request for a plugin exactly like this on the essentials wiki a lil' while back! Thanks! :D
     
  20. Offline

    Godofallcows

    Sorry for what! That is awesome! I was making sure I didn't have to install two plugins to run it. I am installing this now, thank you!
     
  21. Offline

    Parflagush

    Discovering this plugin just made my day! Thank you! I'm excited to try it out! :D
     
  22. Offline

    Xordaii

    Happy birthday, and thank you for the plugin!!! Hope you have fun today

    Saw your site, and very impressed. I am just learning to set up a server at home. This will help tons, as I did NOT want to mess with iConomy, but I like some of the plugins for it. Thank you again!
     
  23. Offline

    bradgillap

    This is awesome! Thank you!
     
  24. Offline

    xeology

    This is now fixed, Towny is using deprecated methods (iConomy) so might want to go bitch at him for having useless code. But it is fixed, you won't get that error.

    NPC SUPPORT IS HERE!
     
  25. Offline

    Rufus

    I dont seem to get any errors now but I still don't think this is working with towny very well. When I deposit money into the bank I get the "Name deposited $$$ into the town bank" message but when I check the bank nothing is in there, but it does get taken from Essentials.

    Because of this you cant claim land and such. Just letting you know in hopes it can be fixed somehow.

    Thanks for your efforts so far and keep up the good work,

    Rufus.
     
  26. Offline

    denieru7

    Awesome work, xeology! It's working great.

    Can I make a request to be able to edit the currency name for iConomy? It used to be in iConomy.yml, but with this plugin all other plugins use the default currency "Coins".

    Thank you!
     
  27. Offline

    xeology

    Does this work right with iconomy? I will be testing this today then. There will be a fix.

    Yes, I'll release it today with that in the config.

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

    denieru7

    Cool, thank you!
     
  29. Offline

    quickclay

    Doesn't seem to work with Lottery, fyi. Causes (Lottery) errors every time someone tries to buy a ticket.
    Thanks!
     
  30. Offline

    xeology

    Well I do not see this Error on 1.3 but if it persists please give me the EXACT error.

    This turns out to be caused by Towny's blatant disregard for the syntax of iconomy's API. Use hasAccount before getAccount to make sure it exists or it will be created. They just use getAccount and dont give 2 shits if it exists or not.

    BUT I fixed it. No point in not fixing it I suppose. I made sure it is hasAccounting prior to returning a account to the requesting plugin. So it works now, tested myself!

    Done.

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

Share This Page