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

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

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

    Nijikokun


    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

    What plugins does Register Support? (open)
    iConomy 4, 5, & 6+, BOSEconomy 6 & 7, Essentials Economy 2.2.17+, MultiCurrency
    Why should I use Register? (open)
    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.
    How do I know if you update? (open)
    Watch the project on github, it will tell you when I update it or push new features / fixes !
    Does this mean that all plugins will work with all economies? (open)
    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.
    I want you to support x Plugin. (open)
    Please just request the plugin, and it will be added if it can be.
    What advantages do I get? (open)
    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.
    I updated Register. What do I do? (open)
    Fork and send a pull request, I'll pull it if it cleanly can be done.
    How do I upgrade? (open)
    Just replace the old source with the new one. Drag and drop style works best
    What is Register licensed under? (open)
    The licensing is AOL license <http://aol.nexua.org>


    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.
    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 :(
    }
    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

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

    Bonkerz

    i like the logo
     
  3. Offline

    OrtwinS

    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?
     
  4. Offline

    Nijikokun

    Users don't install Register, it's for plugin authors :p
     
    mbsuperstar1 likes this.
  5. Offline

    OrtwinS

    Even better, java.knowledge.ortwins==false. I'm just happy stuff is integrating and unifying more, making things easier and better for everyone.
     
  6. 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! :)
     
  7. Offline

    Nijikokun

    yes
     
  8. @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.
     
  9. Offline

    Nijikokun

  10. Offline

    $p!k3

    where do i put this?
     
  11. Offline

    Nijikokun

    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.
     
  12. Offline

    $p!k3

    ohh i see.
     
  13. Offline

    Nijikokun

    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~

    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

    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

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

    fregaPT I steal plugins as my own

    I will try this out later with a new plugin I'm developing,
    thank you !
     
  15. Thanks Niji.
     
  16. Offline

    halvors

    Do i need to include each economy plugin as dependcy?
     
  17. @halvors - no, you just need to add them to the build path. You don't actually need to bundle them.
     
  18. Offline

    halvors

    Where get them?
     
  19. They're in the download under libs.
     
  20. Offline

    halvors

  21. Offline

    Nijikokun

    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

    Updated Register to 1.2

    Updates include:
    - Merged MethodFactory into Methods
    - Added Javadoc head comment block to Methods.java and Method.java for licensing / details.

    Notifying: @aPunch @fullwall @Acrobot @cereal @essentialsteam @halvors @fregaPT @Reil

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

    furekusu

    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).
     
  23. Offline

    halvors

    Thanks Niji. Excellent work :D
     
  24. @furekusu - try setting iConomy as a soft dependency.
     
  25. Offline

    Nijikokun

    Loading after isn't a problem, it's already taken care of, look at the examples under the examples folder for more details.
    The warnings are fine, I personally don't have any.
     
  26. Offline

    furekusu

    Ok it works fine with softdepend.

    This is where i got the warning (BOSE.java): screenshot. The other ones are static methods called in a non-static way.
     
  27. Offline

    MiHo

    Code:
    18:40:24 [WARNING] Task of 'EasyTravel' generated an exception
    java.lang.NoClassDefFoundError: com/earth2me/essentials/api/Economy
    	at com.nijikokun.register.payment.methods.EE17.format(EE17.java:28)
    	at at.co.hohl.easytravel.ports.implementation.AbstractTravelPort.onPlayerEntered(AbstractTravelPort.java:138)
    	at at.co.hohl.easytravel.listener.TravelPlayerListener.onPlayerLocationUpdate(TravelPlayerListener.java:62)
    	at at.co.hohl.easytravel.TravelPlugin$1.run(TravelPlugin.java:219)
    	at org.bukkit.craftbukkit.scheduler.CraftScheduler.mainThreadHeartbeat(CraftScheduler.java:128)
    	at net.minecraft.server.MinecraftServer.h(MinecraftServer.java:358)
    	at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:285)
    	at net.minecraft.server.ThreadServerApplication.run(SourceFile:394)
    Caused by: java.lang.ClassNotFoundException: com.earth2me.essentials.api.Economy
    	at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
    	at java.security.AccessController.doPrivileged(Native Method)
    	at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
    	at org.bukkit.plugin.java.PluginClassLoader.findClass(PluginClassLoader.java:36)
    	at org.bukkit.plugin.java.PluginClassLoader.findClass(PluginClassLoader.java:24)
    	at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
    	at java.lang.ClassLoader.loadClass(ClassLoader.java:248)
    	... 8 more
    
    Any idea? (EasyTravel + Register tested on iConomy 4 & 5 Systems)

    EDIT: Ah... didn't recognized that also Essentials was installed on my localhost, when removing it, it works. But shouldn't it work with Essentials Economy too?
     
  28. Offline

    Nijikokun

    You have the wrong version, I need to find a way to check and see if it's the /right/ one.

    Updated Register to 1.3

    Updates include:
    - Fixed issue with plugins loaded before... again!

    Notifying: @aPunch @fullwall @Acrobot @cereal @essentialsteam @halvors @fregaPT @Reil @MiHo @furekusu

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

    MiHo

    Wrong version of Essentials or Register?!?
     
  30. Offline

    Nijikokun

    Updated Register to 1.5

    Updates include:
    * Fix the way that Register grabs plugin instances. (Prevents messages appearing twice)
    * Prevent the usage of PluginManager if we can.
    * Added fix to prevent the usage / error output of essentials without the API class.
    ** Meaning, no more essential errors if it doesn't have the class we need! YAY :D

    Thank you to @Acrobot for letting me use TeamViewer to solve the issue.

    Notifying: @aPunch @fullwall @Acrobot @cereal @essentialsteam @halvors @fregaPT @Reil @MiHo @furekusu
     
    MiHo likes this.
Thread Status:
Not open for further replies.

Share This Page