pie-flavor / Pieconomy

An economy plugin for Sponge utilizing items as currency.
https://ore.spongepowered.org/pie_flavor/pieconomy
MIT License
3 stars 1 forks source link

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

Things to keep in mind

Admins:

Players:

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.

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
      }
    }
  ]
}

# 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.

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.