Need help with hashmaps/economy plugin

Discussion in 'Plugin Development' started by superpigpork1, Feb 8, 2015.

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

    superpigpork1

    Hello, I need help creating a balance command for my plugin, so when a player does /dbal it shows them their donator coin balance. I have the player's name and balance in a hashmap.

    here's the class with the hashmap in:
    http://pastebin.com/dGN5e4qm
    And here's the class I'm trying to create the command in:
    http://pastebin.com/pdRQYbCW

    this is the tutorial I followed to get to this stage :)
    so my files (not including the DbalCommand class) are the same as on there but with different names.
     
  2. Offline

    ProMCKingz

    @superpigpork1
    You should really be using a UUID instead of a players name.
     
  3. @superpigpork1 *Sigh* Another reason why you should always learn Java first, because it really helps understand what exactly is going on when you make things like this.

    Anyway, to retrieve the balance (based on your code), you want to get the command sender (from the DbalCommand class), check if it's a player (if cs instanceof Player), check if they have an account in the hashmap (EconManager.hasAccount) then send the player the balance, by using your EconManager.

    As people may have said, store usernames in a UUID for nice storage and keep note that hashmaps will reset on reload/restart so it is advised to use a config or something to store them (either onDisable or replace the hashmap feature entirely with a config).
     
  4. Offline

    superpigpork1

    Ok thank you,
    they do save to a config onDisable and get loaded onEnable .
     
  5. Offline

    superpigpork1

    IMG]http://i61.tinypic.com/se3ypk.jpg[/IMG]
     

    Attached Files:

    DJSkepter likes this.
Thread Status:
Not open for further replies.

Share This Page