Register - Now accepting all Payment Methods (Economy API) [Stable]

Discussion in 'Resources' started by Nijikokun, May 10, 2011.

  1. Offline

    Nijikokun

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
  2. Offline

    Nijikokun

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    About Register
    Register was made due to a plugin that I was creating for iConomy and going to release to the public; This plugin was going to support 4 & 5 but instead I decided why limit the amount of choices and force users to use a economy plugin because they want x plugin.

    So I made Register, the API for ALL Major Economy Plugins for plugin authors.

    Frequently Asked Questions

    iConomy 4, 5, & 6+, BOSEconomy 6 & 7, Essentials Economy 2.2.17+, MultiCurrency
    It will save you time and automagically has support for hooking into the economy plugins, and has a GLOBAL API for you to use for all economy plugins, no matter what it supports or has, the api will stay the same for each one.
    Watch the project on github, it will tell you when I update it or push new features / fixes !
    Plugins that have Register will support all major economies, not the other way around. Register is an api that lets plugin authors use a single method to interact with multiple economic possibilities so that way they don't have to code tons and tons of classes to support them all.

    If someone else can make a better explanation; Please be my guest.
    Please just request the plugin, and it will be added if it can be.
    The advantages of using Register vs custom coding is; Register can be extended as the source is available, as well as you don't have to spend time making tons of classes to support something that's already been made; Register has a well thought out api as well as the ability to grab the plugin object if needed.
    Fork and send a pull request, I'll pull it if it cleanly can be done.
    Just replace the old source with the new one. Drag and drop style works best
    The licensing is AOL license <http://aol.nexua.org>

    This post has been edited 2 times. It was last edited by Nijikokun Jul 29, 2011.
    andrewkm likes this.
  3. Offline

    Nijikokun

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    API
    The code is actually Java, PHP just highlights with this code block, so don't think this is PHP.

    Methods - How we get the method that we can accept.
    PHP:
    Methods.setMethod(Plugin plugin); // Check to see if this is a economy plugin, utilize if we can.
    Methods.checkDisabled(Plugin plugin); // Checks to see if the method we have equals the plugin, and sets the method to null returning a boolean if it has; If not, returns false.
    Methods.hasMethod(); // Check to see if we already have a payment method
    Methods.getMethod(); // Return the payment method so we can start doing stuff.
    Method - This is our payment method object, it controls money / bank API
    PHP:
    public Object getPlugin(); // Get the Plugin, returns ACTUAL Plugin entity ie: Essentials plugin = Method.getPlugin();
    public String getName(); // Returns the Payment method name; ie: iConomy
    public String getVersion(); // Returns the version of the method ie: 5 (for iCo5) 4 (for iCo4)
    public String format(double amount); // Formats an amount via plugin or custom method if plugin doesn't have one
    public boolean hasBanks(); // Does this method support banks? Returns true/false; if False, no bank methods will work.
    public boolean hasBank(String bank); // Check for bank existance
    public boolean hasAccount(String name); // Check for account existance
    public boolean hasBankAccount(String bankString name); // Check to see if player has an account with bank
    public MethodAccount getAccount(String name); // Get the MethodAccount, explained later.
    public MethodBankAccount getBankAccount(String bankString name); // Get the MethodBankAccount, explained later.
    MethodAccount Allows us to modify / grab the balance of an account / player.
    PHP:
    public double balance(); // Grab the balance.
    public boolean set(double amount); // Set the balance to the amount given.
    public boolean add(double amount); // Add the amount given to the balance
    public boolean subtract(double amount); // Subtract the amount given from the balance.
    public boolean multiply(double amount); // Multiply the balance by the amount given.
    public boolean divide(double amount); // Divide the balance by the amount given.
    public boolean hasEnough(double amount); // Check to see if the balance is higher or equal to the amount given
    public boolean hasOver(double amount); // Check to see if the balance is higher than the amount given.
    public boolean hasUnder(double amount); // Check to see if the balance is lower than the amount given.
    public boolean isNegative(); // Check to see if the balance is negative.
    public boolean remove(); // Remove account from economy, delete, etc.
    MethodBankAccount Allows us to modify / grab the balance of a bank account.
    PHP:
    public int getBankId(); // Get the bank id if we can, -1 if plugin doesn't support bank id's
    public String getBankName(); // Get the name of the bank we are editing the account on
    public double balance(); // Grab the balance.
    public boolean set(double amount); // Set the balance to the amount given.
    public boolean add(double amount); // Add the amount given to the balance
    public boolean subtract(double amount); // Subtract the amount given from the balance.
    public boolean multiply(double amount); // Multiply the balance by the amount given.
    public boolean divide(double amount); // Divide the balance by the amount given.
    public boolean hasEnough(double amount); // Check to see if the balance is higher or equal to the amount given
    public boolean hasOver(double amount); // Check to see if the balance is higher than the amount given.
    public boolean hasUnder(double amount); // Check to see if the balance is lower than the amount given.
    public boolean isNegative(); // Check to see if the balance is negative.
    public boolean remove(); // Remove account from economy, delete, etc.
    andrewkm likes this.
  4. Offline

    Nijikokun

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    Examples / Usage

    Setting Register up with a Server Listener (View)

    Using Register in your plugin:
    To use register, you need to include the source code or use the code as a dependency library. The first is the easiest way and also, the source-code has a small footprint making it great to just drag and drop into your plugins source without worrying about any issues of dependencies.

    If you don't know where the source folder is located or how to do this, use google!
    Also, the drag and drop method can be seen here.

    Just a note, make sure you rename the packaging somehow:
    http://forums.bukkit.org/threads/re...s-economy-api-stable.16849/page-4#post-383074

    Using Banks?
    Before you run off gleefully into the night saying "YES BANKS YES OH GOOOOODDD"; There are some things you should know. Some plugins don't support banks (iCo4 & EEco) so what you need to do is check to see if the method that the server has supports them before diving in:
    PHP:
    if(Method.hasBanks()) {
        
    // The economy payment method supports banks
        // We now know this so we can do things with banks, you should make this check everytime you 
        //   wish to interact with banks or alternatively give a message saying that they don't support it.
    } else {
        
    // The economy payment method doesn't support banks :(
    }
    andrewkm likes this.
  5. Offline

    Nijikokun

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    Chronological Log of Updates / Additions

    0.3 - May 13th, 2011
    * Repackaged Register Methods, Removed prefix "Method" from method classes.
    * Updated Essentials support to 2.2.17 as preferred by essentials team.

    0.4, 0.5, 0.6 - May 13th, 2011
    * Updating methodizing with factory (Thanks @snowleo)
    * Added set() function to accounts / banks.
    * Minimized & Fixed checkDisabled()
    * Cleanup / Formatting

    0.7, 0.8, 0.9, 1.0 - May 13th, 2011 (9:34 AM)
    * Fix issue with plugin not loading dependencies if ran before.
    * Updated examples to reflect the fix, as well as curing some bugs.
    ** Make sure you look at the new example files.

    1.1, 1.2, 1.3 - May 15th, 2011 (11:12 PM)
    * Fixed iConomy 5 being confused as iCo4.
    * Fixed static initialization not working on specific java versions.
    ** Moved them to Methods (For Essentials referenced by package)
    * Added Javadoc to the class head
    * Merged MethodFactory into Methods
    * Fixed issue with plugins that load before.

    1.4, 1.5 - Stable - May 16th, 2011 (11:23 PM)
    * Fix the way that Register grabs plugin instances.
    * Prevent the usage of PluginManager if we can.
    * Prevent grabbing essentials if it doesn't have the API.

    1.6, 1.7, 1.8 - Stable - May 22nd, 2011 (7:00 PM)
    * Fix missing !
    * Fixed invalid variable
    * Added preference & a more stable attachment system.

    1.9, 2.0, 2.1 - Stable - July 28th, 2011 (9:21 PM)
    * Added iConomy 6, MultiCurrency, BOSE7 support.
    * Fixed some issues with iConomy4
    * Added commenting to help developers

    This post has been edited 2 times. It was last edited by Nijikokun Jul 29, 2011.
    andrewkm likes this.
  6. Offline

    Bonkerz

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    i like the logo
  7. Offline

    OrtwinS

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    Finally a plugin that unifies things in stead of more competing plugins for the same functionality.
    I always thought of iConomy as the defacto standard... just money, no extra's, and still other money plugins came about...

    Any plans of integrating Register with iConomy? so iConomy users dont need to install register as well?

    @Nijikokun you are a saint for this community :p

    PS, new avatar? nice, does it bare any resemblance with you?
  8. Offline

    Nijikokun

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    Users don't install Register, it's for plugin authors :p
    mbsuperstar1 likes this.
  9. Offline

    OrtwinS

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    Even better, java.knowledge.ortwins==false. I'm just happy stuff is integrating and unifying more, making things easier and better for everyone.
  10. Offline

    Acrobot

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    Thanks @Nijikokun :)
    Now I am able to support all economy plugins!

    BTW, will this be updated as plugins change?

    Also, I thought about making something like this, but you're first! :)
  11. Offline

    Nijikokun

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    yes
  12. Offline

    fullwall

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    @Nijikokun - experiencing some issues with Essentials Eco support (I think the classpaths got moved around). When I get around to it, I'll download the essentials JAR myself and see what's changed.
  13. Offline

    Nijikokun

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
  14. Offline

    $p!k3

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    where do i put this?
  15. Offline

    Nijikokun

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    Are you a plugin developer? If so, you add it to your source code, as if it were a part of your plugin, to the ROOT source directory (advanced java developers may do as they see fit) and then you hook into it as shown in the examples.
  16. Offline

    $p!k3

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    ohh i see.
  17. Offline

    Nijikokun

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    Updated Register to 0.3;

    Updates include:
    Moved methods into sub-package in payment, removed "Method" prefix for readability.
    Added Essentials 2.2.17 support overriding 16 support. I may add 16 back if I find a way to do so, until then.


    Notifying: @fullwall @Acrobot @cereal @essentialsteam

    Want to be on the Notifying list? Pm me with the title "Add to notifying list" or watch the thread or github page

    Enjoy the ride~
  18. Offline

    Nijikokun

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    Updated Register to 0.6

    Updates include:
    - Updating methodizing with factory (thanks @snowleo)
    - Added set() function to accounts / banks.
    - Minimized & Fixed checkDisabled()
    - Cleanup

    Notifying: @fullwall @Acrobot @cereal @essentialsteam
  19. Offline

    Nijikokun

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    Updated Register to 1.0

    Updates include:
    - Fix issue with plugin not loading dependencies if ran before.
    - Updated examples to reflect the fix, as well as curing some bugs.
    -- Make sure you look at the new example files.


    Notifying: @aPunch @fullwall @Acrobot @cereal @essentialsteam
  20. Offline

    fregaPT I steal plugins as my own

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    I will try this out later with a new plugin I'm developing,
    thank you !
  21. Offline

    Acrobot

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    Thanks Niji.
  22. Offline

    halvors

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    Do i need to include each economy plugin as dependcy?
  23. Offline

    fullwall

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    @halvors - no, you just need to add them to the build path. You don't actually need to bundle them.
  24. Offline

    halvors

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    Where get them?
  25. Offline

    fullwall

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    They're in the download under libs.
  26. Offline

    halvors

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
  27. Offline

    Nijikokun

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    Updated Register to 1.1

    Updates include:
    - Fixed iConomy 5 being confused as iCo4.
    - Fixed static initialization not working on specific java versions.
    -- Moved them to Methods (For Essentials referenced by package), If you change the paths it should automatically refactor if you drag / drop.

    Notifying: @aPunch @fullwall @Acrobot @cereal @essentialsteam @halvors @fregaPT @Reil
  28. Offline

    Nijikokun

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
  29. Offline

    furekusu

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    Thank you, I'm going to use this.

    But I have an issue with this. My plugin loads after iConomy, so it doesn't set it as the payment method. I wrote a workaround where all loaded plugins are checked when enabling. Is there a better solution?

    Also, there are warnings in the Method classes (not used variables etc).
  30. Offline

    halvors

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    Thanks Niji. Excellent work :D

Share This Page