Pieconomy - An economy plugin that uses items as currency

This is a discussion topic for the Ore project, Pieconomy. View the full project on Ore for downloads and more information.


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

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.

Note

This plugin uses bStats, which collects 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 to disable it. However, if you wish to anyway, simply set enabled to false in config/bStats/config.conf.

6 Likes

Super excited to see this!

I’ll be adjusting our current money making methods and switch over to this shortly.

Any issues with the Good Ole Currency mod that you might want me to look out for?


Also, do you have a discord for your plugins or is the best form of communication concerning the config going to be these forums? Either is good. Of course, discord is better if it’s avalible.

I don’t have a Discord server, no. And as long as the items have different item IDs for each item, it should work fine.

You did it :grinning:

Storing money in an account requires a Gringotts vault. A vault consists of a container, which can be either chest, dispenser or furnace, and a sign above declaring it as a vault. A player or faction may claim any number of vaults. Vaults are not protected from access through other players. If you would like them to be, you may use additional plugins such as LWC or WorldGuard.

Player vaults
Place a sign above a container block, with [vault] written on the first line. If it was created correctly, the sign will display your name on the third line and you will receive a message that the vault has been created.

https://dev.bukkit.org/projects/gringotts

Is it possible to add this feature in your plugin like Gringotts?

I suppose it’s possible, but I simply don’t see the point. Forcing you to keep everything in your inventory makes it much more fun, and if it were in an arbitrary box somewhere, it wouldn’t be reinforcing the idea that the currency is not some arbitrary number in memory somewhere quite as much.

I think if there is an option like how many containers that a player can have to store money, it will make the plugin more flexible. For some servers, they might set 0. For some server, they might set the value as 1 or 2 depending on their own requirement.

I’ll think about it. Perhaps I’d add other settings that can require you to be near the container, or to subtract a percentage when you use it (like an ATM).
The goal here is to require the player to manage their money, and for it to be treated like a core part of gameplay instead of a plugin feature. Can you place blocks from a chest holding them?

A new version has been released for Pieconomy, it is available for download here.


  • Added the ability to require specific data values
  • Fixed a rounding bug with depositing

A warning - item data values are now checked, and if you leave one off, it’s the same as if you set it to 0.

Could you add a message file for this plugin?

Hello ! When i try to load the plugin i have this error :
https://pastebin.com/1PAu8mU4
thanks :confused:

You’re trying to use 2 economy plugins, that’s not going to work out. You need to choose either EconomyLite or Pieconomy, you can’t have both.

1 Like

Now i have this

I put for item :
items {
“customnpcs:npcMoney” {
currency = gold
amount = 1
}
}
Thanks ^^’

And is that the correct item ID for the CustomNPCs mod? Verified using F3+H?

Its the same ^^

What version of SpongeForge and Forge are you using? Also, I’m not familiar with CustomNPCs, but I tried installing it and there wasn’t any such item. What mod is it from, if not CustomNPCs?

Hey its customnpc ^^’
Sponge : spongeforge-1.10.2-2281-5.2.0-BETA-2424.jar
Forge : forge-1.10.2-12.18.3.2281-universal.jar

So what’s up with that? I have a feeling your issue has something to do with this.

Mhm sorry but i dont understand what you mean by “Also, I’m not familiar with CustomNPCs, but I tried installing it and there wasn’t any such item.” >w< cause the item exist :c