[ECON] GoldStandard v1.0.1 - Item based dynamic currency system for iConomy [953]

Discussion in 'Inactive/Unsupported Plugins' started by Ballistic Buddha, Apr 26, 2011.

  1. GoldStandard: A Driving force for free market economies
    Version: v1.0.1

    Note: A third party library "GNU Trove" is required in order for the plugin to run, it is included in the .zip version and can be downloaded independently here.

    A Note to those upgrading to v1.0. You will have to either update or drop your SQL tables:
    1. MySQL users, use this script.
      1. Edit the file with your favorite text editor and replace both instances of <schema> with your schema's name.
      2. If you are running your mysql server on linux execute the following command from a terminal as root: "mysql -h [hostname-or-IP-address] -u [username] -p [database-name] < update.sql" and replace everything within the [] to the variables relavant to your instance, it will then ask you for your password from the tty and you would be done.
      3. If you are not running linux or are unfamiliar with the shell, just copy everything in the update.sql file after replacing the <schema> variable then just run those 2 commands any way you choose. I would also like to recommend the MySQL Workbench, which is a pretty solid GUI utility to administrate your database, which also includes some utilities from running SQL scripts or if you prefer you may just run commands directly from the GUI to update your database.
    2. H2SQL users, hang tight as I brew up a solution for those of you who don't want to reset your price values, if you are okay with resetting your prices, just delete the .db files in your plugins/GoldStandard/ folder
    In brief, this is a dynamic currency system for iConomy that lets you set parameters that will let the value of currency fluctuate (if specified). As of Version 1.0 it can now be used as a full-fledged dynamic economy, complete with any mixture of relative and independent price scaling! There are also options to use static pricing mixed in with dynamic pricing.​

    More About GoldStandard (open)

    So, I mainly started making this plugin a little while ago to get my feet wet with the bukkit API. It started out as just a way to sell a single item only, but I have since updated it to be more modular. The primary purpose of this plugin is to accompany an economic system similar to iConomyChestShop that is more trade and barter based, rather than based on selling and buying items directly to and from the server. However I noticed that the problem I had once I first set up iCS was that although people could buy items sold by other players, people had no means of actually generating money, as I didn’t quite fancy the idea of letting everyone sell items to chests. Hence, GoldStandard was born!

    GoldStandard is a selling system based on the idea of scaling prices based on supply and demand. Currently, the plugin only allows you to sell one specific type of item such as Gold Ingots, useful due to their rarity and lack of practical use, thus basing the driving force of the entire server’s economy on who has the most gold, and indirectly relating the value of all items in-game to the price of gold (or similar item).

    When used in conjunction with an adequate trading and buying system to act as a type of auction house, admins may indirectly control the price of all items on the server by directly adjusting the price of one item. There will be no longer be a need for admins to set specific values for any items or minerals except for the chosen item; rendering the need for setting prices for new items redundant. The prices of all items will eventually reach equilibrium as they adjust based upon how the players decide to buy and sell items to other players. With this plugin running alongside a “finite” buying system, admins might find it easier to stabilize an economy by adjusting the price of gold to the right range that suits their needs.

    Features
    Price Scaling
    Note: I'm currently working on getting better examples and explanations of how this works, but for now you can download the .zip version and examine the sample config included within it.
    The price of items works by either using static or dynamic pricing, using the following formulas:
    Code:
    For Dynamic Pricing (never goes outside the bounds specified):
    <current price> = <base price> - (<ratio>*<# of transactions>)
    For Static Pricing:
    <current price> = <base price>
    The number of transactions is found by querying the database for the number of items sold in the past X days (where X is a number specified in the config file)
    Relative items scale in relation to the base item. Making them effectively a sub or super unit of the base item. Transactions of relative items are effectively weighted based on their "relation" variable. Meaning that selling one relative item with a relation of .1 is effectively one 10th of a sale of the base item. Alternatively, if the ratio is 10, it will effectively count as a sale of 10 base items.

    Selling In-game
    Selling and Buying with GoldStandard can either be done commandless or via commands. For the non-command option, you must first create a "sell list", which is a list of all items that you want to sell. To modify this list use the commands /gsadd and /gsremove, you can add and remove multiple items with one command by comma separating their names/ids. After you have created your sell list, put a stack of all of the items you wish to sell into a furnace, chest, or dispenser in any slot, then left-click the container with the sell tool (Gold Sword by default), and viola! Minecash! Any items not in your sell list will remain untouched. If you’re really impatient you can just keep hitting the furnace while you are smelting gold ore, given that your action cooldowns aren't too long. You can also use commands in addition if specified in the config.
    Buyback
    You may also buyback items if allowed, to buy w/o commands you must first specify a buy item and quantity with /gsset. For instance, if I wanted to buy redstone in stacks of 8 the command would be /gsset redstone 1. After you specify a buy item, simply hit an empty valid container with the sell tool to buy the item stack. Alternatively, if the command option is enabled, you may use /gsbuy to buy multiple items at once. Buying an item will increase the value of the item relative to the ratio.
    Commands (open)

    Note: ItemIDs are synonymous with their nickname
    • /gsworth || /gsprice <itemIDs>- displays the current sale price for the selected items, comma seperate item names for multiple checks
    • /gssell || /gsell <items> <quantities>[Block Option] - sell x of item taken directly from your inventory
      • Comma sperate items and quantities, qtys match items in their respective order
      • The block options are ~ and *
      • Append the special character to the end of the amount like so:
      • /gssell 20~ - this sells 20 of the item in your inventory and counts blocks as 9x where applicable
      • /gssell 20* - same as ~ but will return your "change" in blocks if applicable
      • These characters do nothing if not applicable or not allowed
    • /gsbuy || /gbuy <items> <quantities> - buy items and insert them directly into your inventory
      • Comma sperate items and quantities, qtys match items in their respective order
    • /gsreset || /gsclear - Admin command that resets all prices back to their initial prices.
    • /gsadd || /gsa <items>[Block Option]
    • Comma separate items to be added
      • Append ~ to the end of the name/id to include blocks
    • /gsremove || /gsr <items> - remove items from your sell list
    • /gsset || /gss <item> <quantity> - set your item and stack size to buy
    • /gslist || gsl <but|sell> - display the items you are currently buying or selling
    • /gshistory || /ghistory <ItemID|Nickname|*> [sales(+)|purchases(-)|net(blank)]- Command that queries the database for the number of transactions
      • * is a wildcard that gets the history of all items
      • the type argument is optional, if blank it will get the net transactions
      • + and - are shorthand for sales and purchases respectively


    Requirements
    • GNU Trove (Packaged with the .zip file)
    • iConomy (iC Version 5.0+ as of GS version 0.7)
    • Permissions (If enabled)
    • MySQL (optional, requires mysql-connector-java-bin.jar in lib folder)
      • if you have already setup iConomy, you should already have this
    • H2SQL libraries (optional, requires h2.jar in lib folder)
      • if you have already setup iConomy, you should already have this
    • LWC (If using container protection)
    Configuration

    There are now 2 .yml config files. config.yml is for general plugin settings such as the duration, reload interval, and data source. items.yml is where all item-related configurations are set; INCLUDING price scaling options such as base, min, max, and ratio. Some settings are in both such as Buyback. In this case the setting in config.yml is the default and can be overridden for a specific item in items.yml.
    Example using Dynamic Pricing

    config.yml
    Code:
    #ItemID of the selling tool for commandless selling
    SellTool: 283
    #how long to keep records (in days)
    Duration: 7
    #How often (in minutes) to clean the database of old records (if needed)
    Reload Interval: 60
    #This option applies only to Gold Ingot, Iron Ingot, Diamond Gem, or Lapis Lazuli Dye
    #it enables selling one block of the equivilent material as 9x of the item
    #if an item cannot be represented as a block, this is ignored
    #this can be overridden for a specific item in items.yml
    Allow Block: true
    #enable buying (enforces the ratio in an inverse fashion)
    #this can also be overridden for a specific item in items.yml
    Buyback: false
    #Options: Chest, Furnace, Dispenser, Command
    SellMethods:
        - Furnace
        - Chest
        - Command
    #Protection system to use (LWC or none)
    Protection: LWC
    #MySQL, H2SQL or none
    Data: MySQL
    MySQL:
        database: minecraft
        hostname: localhost
        port: 3306
        username: mc
        password: pass
    
    items.yml
    Code:
    #Items are listed on level 1 by a specified nickname
    #the nickname can be anything as long as they are unique, but be aware that it will be shown in game
    #Currently, only one item is allowed and it must be a "base" item
    Items:
        Gold:
            #Decimal itemID of this item
            Id: 266
            #This is an optional override of the setting in config.yml for only this particular item
            #To use the default, delete this line
            Allow Block: true
            #This is an optional override of the setting in config.yml for only this particular item
            #To use the default, delete this line
            Buyback: true
            #There can only be one base item, it is a special item that is considered the basic unit of a multi-tiered economy
            #The price of the base item is always calculated from the base price
            #can only be base in version 0.8
            Type: base
            #base sale price of the base item
            Price: 100
            #minimum sale price of the base item
            Minimum: 50
            #maximum sale price of the base item
            Maximum: 200
            #decrease in price per item sold, increase per item bought
            #Sorry, but this must be in decimal format now :(
            Ratio: .1
    
    In this example, the item to sell is a Gold Ingot and the selling tool is a Gold Sword. The price of gold starts at 100 and decreases by 0.1 for each gold ingot sold until the price reaches 50, at that point it will stay at 50 until either transactions older than 7 days get cleaned out (assuming that a lot of the transactions didn’t just now take place) or the price gets reset by an admin. In other words, If the price is currently at the ceiling, and I sell enough gold to bring it down to the floor price right now, the price will stay at the minimum for 7 days unless reset by an admin. However, if I were to sell about half of my gold now and bring the price down to 75, and than 4 days later sell the rest of my gold to bring it down to 50 (assuming the rest of the players on the server haven’t sold any gold in the past 4 days) after 3 more days from this point (7 days from the first sale), the price will adjust as if I had only sold the second half of my gold.

    Example config.yml file using Static Pricing
    config.yml (open)

    SellTool: 283
    Reload Interval: 60
    Allow Block: true
    Buyback: false
    SellMethods:
    - Command
    Protection: none
    Data: none


    That’s really all you need. You can keep the above items.yml exactly as it is in the dynamic example above, and all of the scaling options will be ignored. Just be sure to set data to “none”, because it will cut down on the resources this plugin uses by A LOT. The same goes for block protection, if you don't want to enforce block protection (which is recommended if you are only using the command option), set the option to "none".

    Permission Nodes
    Code:
    goldstandard.sell - enables selling and use of the commands /gsa, /gsr, and /gsl sell
    goldstandard.buy - enables buyback and use of the commands /gss, and /gsl buy
    goldstandard.worth - enables the command to check the price
    goldstandard.reset - enables force resetting back to the base price (recommended as an admin-only command)
    goldstandard.history - allows the player to run history queries
    
    Planned Features for the Future
    • Ability to use SQL to store item information
    • Formula declarations for relative items (e.g. '<Gold>/10') to declare relative items more intuitively, or at least a yaml node to set what an item is relative to, instead of having the relation necessarily relating to the base item.
    • Add option to /gshistory to select based on the user who did the transaction, and head/tail options
    • "odd-item" support (like dyes and cloths)
    Wishlist (things I’d like to do if I have the time)
    • Exponential price scaling (dynamic relations)
    • Create an option to retain logged transactions even after they have expired
    • A web-api to query transactions (even past their expiration) to show trending of item prices.
    Known Issues:
    • Double chests act strange, selling from a double chest will only sell half of the items, thus requiring users to hit both sides of a double chest to sell all items within it.
    • Fractions in the .yml file no longer work, you have to put them in decimal format
    • There is no support for "odd items" such as dyes and cloth, and there is currently no way of using such items as currency.
    Changelog

    • Version 1.0.1
      • Fixed table creation with MySQL, and improved default player values for both H2 and MySQL database tables.
    • Version 1.0
      • Added support for multiple items. (see the example configs for how to implement)
      • Fixed an exploit with buyback by making the buy price have a pre-increment price adjustment
      • Added option to not use permissions.
      • Further implementation of trove to help reduce the memory footprint
      • Added action cooldown for buying and selling (independently)
      • Options for "buyback" and "allow block" can now be overridden on a per-item basis
      • A bunch of other tweaks and bugfixes, too many to list.
    Older versions (open)

    • Version 0.8
      • Switched to a new configuration format, containing 2 files: config.yml and items.yml, see the configuration above for more info.
      • Added command /gshistory for admins to run a basic query of past transactions from in game
      • Added an option to sell Iron,Gold, and Diamond blocks as 9x ingots/gems.
      • Redesigned the internals for buy and sell procedures in preparation for v1.0
      • A few other minor bugfixes
    • Version 0.7.2
      • Resolved some database connection issues that caused issues when reloading the plugin rapidly (like by doing a /reload from in-game)
    • Version 0.7.1
      • Fixed a bug causing errors when selling the last of your item via command
    • Version 0.7
      • Added H2SQL support :D
      • Updated to iConomy5
      • Added "Reload Interval" parameter in the config
      • Added "item" database column to prepare for multi-tiered currencies
        • If you were using a previous version you will either have to alter the table to include the "item" column or just delete the table (which will obviously reset your price)
        • If you switched to using H2SQL, no worries, your DB is already properly formatted
    • Version 0.6
      • Added Option to enforce LWC block protection while selling from containers
    • Version 0.5
      • Added Buyback option (has an increase in price per transaction)
      • You can now use any of: Chest, Furnace, Dispenser to buy/sell gold
      • Added option to buy/sell via command
    • Version 0.4
      • Initial release to the public
     
    Llamageddon, smickles and kahlilnc like this.
  2. Offline

    mike0fmikes

    So I just thought of something...
    Adding world guard support could be interesting. For instance, we have a town on our server, and making it so that the market was only accessible while in the market district would give players even more of a reason to go to town.
     
    Bjourk likes this.
  3. Offline

    Don Redhorse

    hi, are you still there?
     
  4. Offline

    Zathras

    Darn, I want realistic economics in my minecraft... where supply and demand move prices constantly. It seems this plugin almost had a good thing going and then fizzled.
     
  5. Offline

    Bjourk

    This is a fantastic idea. I'd love to see it updated!
     
  6. Offline

    mike0fmikes

    I WOULD TOO!!! I don't think this plugin got enough attention from the start, and the dev has left it hanging. Anyone out there want to pick up the mantle?
     
  7. I live in hope.
     
  8. Offline

    mike0fmikes

    I don't want it to die...it was so awesome...nearly crucial to my server (and if you run it, it will soon be crucial to your's as well)
     
  9. Hey all, just popping my head in here to let you know that I am still here. Over the past few months my interest in plugin development and even minecraft as a whole has declined. However, 1.8 has recently sparked up my interest in minecraft again so I think I might be getting back into development and attempt to pick up where I left off.

    However, if someone else who has more time and initiative than me wants to fork this project, please, I encourage you to do so. If you have that kind of interest, feel free to fork it and I will gladly also walk you though some of the design of the plugin through private messages and whatnot to help you get started, but my work and personal lives have been getting in the way of this project recently.
     
    smickles likes this.
  10. Offline

    smickles

    Well, I'm forking (on github, so any changes I make will be there) it just to try to keep it working for myself.
     
  11. Offline

    Llamageddon

    I really hope this gets updated too. If you get somewhere with forking it (I only have the barest concept of what that is) could you link us a working version? This is such a great plugin, my server is effectively on hold in the hopes this will be updated again. Your work is really appreciated Buddha.
     
  12. Offline

    mike0fmikes


    Any chance you've still got a fork up? I'm still running this on my server, and would love to be able to update it. It's the only mod I'm running that is this many builds behind. Would love to see colored wool and the like supported. Being able to toggle whether transactions keep driving the buy count up in spite of the price being at the floor would be great. The ability to have a price set by the sum of other prices would be great; i.e. : the price of a diamond helmet = 5 diamonds
     
  13. Offline

    smickles

    What I have didn't end up being a fork. But it does have some similar features.
    here's mine: http://dev.bukkit.org/server-mods/dynamicmarket/ it's currently built for CB 1337.
     
    Bjourk likes this.

Share This Page