An economy plugin that uses items as currency.
11

Pieconomy

Pieconomy is an economy plugin which allows you to use items as currency and inventories as accounts. With the default configuration, if I had three gold ingots and one gold nugget, and ran /bal, it would tell me I had 28 G. If I dropped an ingot, I would have 19 G. If I ran /pay turtledude01 5, he would get 5 gold nuggets, and I would lose an ingot and gain 4 nuggets (as change). And any other plugin using the economy will work properly (provided it’s written properly and follows the Economy Best Practices).

This plugin is for people who want a new style of economy, one where there isn’t some magic number in memory that increments when you get paid. The economy becomes real, and part of the game instead of part of a plugin. Great for RPG-style servers, or ones focused on survival.

Features

  • The obvious one. Your players’ accounts are their inventories; their money is their items. You say what items are what currencies - for instance, you could make an economy based around a mod which adds coins.
  • Multiple currencies - you could have gold AND dollars AND vote tokens AND cosmetic credits, all at the same time, all using items. No upper limit.
    • Any plugin can add new currencies to the registry if they want to. It’s still up to you to say what items back it, though.
  • Server accounts - you can create virtual accounts backed by the server, which players can pay to, and people with appropriate permissions can manipulate.
    • You can configure which (if any) currencies can be given to an account, and which (if any) currencies the account can have a negative amount for.
  • Total admin control - Staff can add and remove money from anyone, set anyone’s balance, and transfer money between accounts.

Things to keep in mind

Admins:

  • Change can be made whenever money is paid. Don’t assign monetary values to items you don’t want people to be able to convert between (hence why the default config uses gold ingots, nuggets, and blocks).
  • Whatever the smallest valued item a currency has is, that’s the smallest value that is used by the plugin. If you run off of USD, but don’t implement pennies, for instance, values (in any transaction) smaller than 5ยข will be simply ignored.

Players:

  • If you expect to receive money, make sure to have space in your inventory. It’s up to whatever plugin does the economy request how to handle a lack of space for money. Pieconomy also cannot combine items for you if space is low.
  • Be careful not to pay players with the same name as server accounts, or vice versa. If there is a name conflict, you can write player:<playername> or server:<accountname> wherever accounts are used in this plugin’s commands, and tab-complete is your friend. This will NOT work for commands not from this plugin.
  • Also keep in mind item 2 of the Admins section.

Developers:

This plugin runs a few edge cases you don’t expect to see in economy plugins. Player accounts can and will return ResultType.ACCOUNT_NO_SPACE. They can even return that when withdrawing, due to the making of change. They can even return that, but be successful on a larger amount, due to a full inventory but non-full stacks. Server accounts can report a balance, and successfully withdraw a balance, but return ACCOUNT_NO_SPACE if you try to put it back again due to the currency not being allowed on that account. They can also have negative values on any given currency.
However, I still have no idea how Contexts work, or what they even mean, so I ignore them completely.

All three:

Offline players cannot be interacted with, because Sponge doesn’t allow you to get their inventories.

Important!

THIS PLUGIN IS IN BETA! There may be bugs, and I haven’t been able to test it any further than myself on my own test server. In a real environment it could possibly behave unexpectedly. Report any and all bugs you find to the issue tracker, along with as precise a description of the circumstances as you possibly can. I am especially looking for any errors saying Unknown error regarding account balance subtraction calculations., or /withdraw making incorrect change. Thank you in advance for your help and support.

Commands

Player commands

/pay <to> <amount> [<currency>]
Pays someone else some money. Easy enough.

/bal [<who>] [<currency>]
Retrieve your balance, or someone else’s. If you’re the console, who isn’t optional.

/exchange <item>
Convert items of lesser value (which you must be holding) into items of greater value. They must evenly divide.

Admin commands

/deposit <to> <amount> [<currency>]
Add money to an account. Requires pieconomy.admin.deposit.server.<server account name> or pieconomy.admin.deposit.player, depending on the account used.

/withdraw <from> <amount> [<currency>]
Remove money from an account. Requires pieconomy.admin.withdraw.server.<server account name> or pieconomy.admin.withdraw.player, depending on the account used.

/transfer <from> <to> <amount> [<currency>]
Transfer money from one account to another. Requires pieconomy.admin.transfer.from.server.<server account name> or pieconomy.admin.transfer.from.player and pieconomy.admin.transfer.to.server.<server account name> or pieconomy.admin.transfer.to.player, depending on the accounts used.

/setbal <who> <amount> [<currency>]
Set the balance of an account directly. Requires pieconomy.admin.setbal.server.<server account name> or pieconomy.admin.setbal.player, depending on the account used.

Configuration

What follows is most of the default configuration, plus explanatory comments.

# All the items that back the economy.
items {
  # The name of each entry is the ID of the item. Since Sponge rocks, modded items work just fine.
  # To add a data value to this, add '@<data>'. For instance, minecraft:wool@3.
  "minecraft:gold_nugget" {
    # This currency will be defined later on.
    currency = gold
    # And a gold nugget is worth 1 gold.
    amount = 1
  }
  # elided default settings for gold_ingot and gold_block
}

# All the currencies that make up the economy.
currencies {
  # The name of the currency.
  gold {
    # I have 22 G. You might change this to 2 for USD, so I would have $22.00.
    decimal-places = 0
    # May show up in other plugins. The display name of the currency. Component format.
    name = {text = Gold}
    # May show up in other plugins. The plural display name of the currency. Component format.
    plural = {text = Gold}
    # The symbol. All formatted monetary amounts should show it, for instance G or $. Component format.
    symbol = {text = G, color = gold}
    # The format that monetary amounts should show up in. Component format.
    # Use the variables %{amount}% and %{symbol}%.
    format = { text = "%{amount}% %{symbol}%" }
  }
}

# What currency should be used by default?
default-currency = gold

# Management of server accounts.
server-accounts {
  # Should they even be used?
  enable = true
  # How often, in minutes, should they be saved to disk?
  autosave-interval = 20
  # What accounts should exist?
  accounts = [
    # An account entry.
    {
      # The ID of the account. This is used internally, and should not ever be changed.
      # This allows you to change the name while keeping the associated data.
      id = "bank"
      # The name of the account. Players use this in commands and it appears in messages.
      name = "Bank"
      # What currencies can it accept?
      currencies {
        # This account does not specify any currencies.
        values = []
        # This is a blacklist, meaning any currency can be used.
        type = blacklist
      }
      # What currencies can have negative values?
      negative-values {
        # This account doesn't specify any currencies.
        values = []
        # This is a whitelist, meaning no currencies can have negative values.
        type = whitelist
      }
    }
  ]
  # Settings for dynamically-generated server accounts (e.g. if you were going to use this with Nations)
  dynamic-accounts {
    # This comes disabled by default.
    enabled = false
    # These two represent the same thing as in an account block, and are used for all unnamed accounts.
    currencies {
      values = []
      type = blacklist
    }
    negative-values {
      values = []
      type = whitelist
    } 
}

# Please don't touch.
version = 1

Metrics

This plugin uses bStats, which can collect data about your server. This data is in no way intrusive, is completely anonymized, and has a negligible impact on server performance, so there is no reason whatsoever not to enable it. Knowing my plugins are actively used is what keeps me developing. Please consider enabling metrics globally or for this plugin specifically in the metrics section in global.conf. A list of collected data can be found here.

Changelog

0.1.0: Initial release.
0.2.0: Allowed using data values, and fixed a rounding bug.
0.3.0: Improved format{} and added per-server-account permissions.
0.4.0: Added the /exchange command.
0.5.0: Updated to API 7.
0.6.0: Added dynamic server accounts.

Support

Appreciate tools like this? Wish there were more? Consider donating!

Category: Economy

Published on Jun 18, 2017

views

stars

watchers

total downloads

Licensed under MIT

Promoted Versions

Pages

Members