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

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

    • 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)

    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

    #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
        - Furnace
        - Chest
        - Command
    #Protection system to use (LWC or none)
    Protection: LWC
    #MySQL, H2SQL or none
    Data: MySQL
        database: minecraft
        hostname: localhost
        port: 3306
        username: mc
        password: pass
    #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
            #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
    - 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
    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.

    • 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. Are you getting any new errors with stack traces (if so could you please post them) or does the functionality just seem to cut out without notice?
  3. Offline


    So, the prices are set, and they automatically increase over time to pay out?

    Gold Ingot starts at 10 gold
    after xyz sells 20 it goes up by 1 gold, making the gold 11gold each?

    Can it be made unique to sell to, not just anywhere, that way users have to go to place "XZ" to sell gold..?

    + 2
    Buy back as in if I Sell something i didn't want to I can buy it back, and or buy gold?
  4. @BioRage

    I'm sorry but i'm not 100% on what you're asking but here's my input.

    If the ratio is set to .05 for the item Gold Ingot, then yes. The price will start at 10 dollars (i'm using dollars as an example iconomy currency name as using the currency name "gold", which is what i think you were referring to in your post, was throwing me off a bit because your item is also gold ingot). Then, anytime ANY user sells 1 gold ingot, the price of gold ingot (for both buying and selling) goes down by .05 dollars. So, after 20 sales the price of gold ingot will be 9 dollars.

    I'm not really sure what you are asking in the second part of your post but i'll explain buying here too.

    Conversely, if the price of gold ingot is at 10 dollars right now, and the ratio for gold ingot is .05, each purchase of a single gold ingot by any player will increase the price of gold by .05 dollars. So if at this point a player buys 20 gold ingots, the price of gold ingot (for both buying and selling) is now 11 dollars.

    So, as a final note, the concept of buyback is in the fact that if you do the following:
        $10 <-- Initial price
    -   $1 <-- User sells 20 gold ingots, decreasing the price by $1 (given that the ratio for the item is .05)
        $9 <--- The price of gold is now $9
    NOW, say the user made a mistake and didn't mean to sell those 20 items, and he wants his money back.
    So, he buys the gold back and the following happens to the price of the item:
        $9 <-- Current price after the sale in the above example
    +   $1 <-- User buys 20 gold ingots, increasing the price by $1
        $10 <-- The price of gold is now back at it's initial price
    Now, as long as these were the only transactions performed on the server while the user did this, it will be as if nothing ever happened. The Price of gold is exactly as it was before these transactions, and the user has the exact same funds as he did before and will have the items that he sold back.

    I hope this clears up at least something.
  5. Offline


    I've been running this on 819 for a couple days now with no issues anyone's mentioned.
  6. Offline


    @Ballistic Buddha

    Thanks for the reply, still understanding it a bit.

    Does the gold every go up? in price wise,. (inflation) -- because user's can only make money from gold, and maybe a compliment plugin EcoCreatures, and activity based.

    So basically it auto manages deflation.

    -- Okay, read about your inflation conversely.


    Also, can anyone sell from ANYWHERE? or can it be set to only one place?

    Thanks man,.
  7. Offline

    Matt Gill

    No errors while starting or when trying to exchange gold. I have it set to only furnace. Should I try chest or commands?
  8. What about if, with our current setup, try to execute /gsworth or /gshistory. Is there any on screen response? Do you get the "invalid command" message or nothing at all? Also, does this perhaps trigger an error in console?
  9. Offline

    Matt Gill

    Oh wait I figured it out. Reinstalling it did work, but I had it set to a stick for the selling tool, and it reset to the gold sword, but then that still doesn't explain why it up and quit. Hopefully it was just a one time thing and there isn't a problem :D.
  10. Can you release a version with no permissions no everyone can use it?
  11. Not a bad idea, and should be pretty easy to implement. Consider this "in progress".
  12. Thanks caue after having to go to my 7 year old brothers bday party this would just make my weekend.
    p.S. Maybe make this work for all items? Make that a buy and sell any item? (option)
  13. Okay, I just put something in that has a new boolean option in the config.yml called Permissions. When set to true, it will enforce permissions based on what your permissions plugin states. When false, all players have access to everything except the /gsclear command, which is only for ops. I will include this in the next update.

    Secondly, the way buy permissions works currently is a two step (technically three step) process.
    1. If a user does not have permission to sell as specified in your permissions configuration (via an external plugin), that user simply cannot sell any items. The same applies to buying.
    2. There is an option in config.yml called buyback, this option is just the default option of whether or not items can be bought. This applies to all items but can be overridden as explained in the next step.
    3. There is also an option for each item in items.yml where you can override the buy setting specified in config.yml just for this item. If unspecified it will default to the option specified in step 2.
    So, as of now, the plugin will always permit all items to be sold, but only items that were explicitly specified to be bought.

    In the next update, with Permissions set to false in the config, all users will be able to sell any item listed in items.yml, and will be able to buy items listed in items.yml if and only if, your configuration allows that item to be bought.
  14. Thanks for replying
  15. Offline


    goldstandard.buy - enables buyback

    Does that turn off the buying function.

    I.E. gold sword hitting furnace, I buy gold.

    Is there a way to get rid of that? (See no need to purchase gold)
  16. Get rid of that for a specific user or everyone?

    P.S.: the buy option for gold is usually set to be able to play it like a stock market. Sell it when the price is high, buy it when the price is low.

    If you want to disable it just for the item "gold ingot" for everyone on your server, set the buyback option in items.yml to false for the item.


    Set "Buyback: false" in config.yml and remove the line for buyback for every item you don't want to be sold.

    The option you stated in your post disables buying anything for that specific user (or group).
  17. Offline


    OH ok, so it can act like a stock market, DURR @ me

    Thanks that helps too!
  18. Offline


    So im trying to use the command based selling and it keeps telling me selling on command is disabled. How the hell do i change that? An where do i change it at?

  19. In your config.yml there is a list called SellMethods, just add the entry command like so:
        - Command
    and add entries for: chest, furnace, and/or dispenser if you wish to also use those to buy/sell.
  20. Offline


    I must of used a tab by accident cause it looked just like that. Added spaces and it works. Now its saying i do not have permission to do that. Im OP...

    Fixed it never mind, thanks!

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
    Last edited by a moderator: May 14, 2016
  21. Offline


    I'm a bit confused. Does this mean that a player could sell (for example) the gold they have and then sell the iron they have *as long as* the config files are properly setup?

    (aside) Sorry if this annoys... I'm just having a stupid moment... i think.
  22. Actually, i'm sorry about that, the plugin currently only supports one item, you can add more items to your config but only the base item will be used in the plugin.

    I've been working on the next version of the plugin which supports multiple items, so once that is finished, yes, that will be the case.
    smickles likes this.
  23. Offline


    Thanks! I look forward to the next version :D
  24. Offline


    A guy on my server has worked out (and I am kicking myself for not noticing this before) that with buyback enabled, it seems you can do the following, assuming you have the appropriate settings of course:

    1.) Sell gold for $2. Price drops to $1.
    2.) Buy gold back for $1. You now have gold + $1. Price goes back to $2.
    3.) Sell gold again for $2. Rinse, repeat.

    With the /gsell and /gbuy commands on a macro key, and no other external effects on the price, this becomes a fairly epic exploit in short order.

    Possible solutions:
    1.) I can just disable buyback. No work on plugin author's part but this would be a bit unfortunate for users. It solves the problem in the short term, though it kind of calls attention to the issue :)
    2.) Separate ratios for buying and selling, ensuring that the buy price is always slightly higher than the sell price. Maybe just a simple amount added to the sell price. I am a bit tired so I'm not 100% sure of the math here :)
    3.) Random fluctuations in price. This might not work quickly enough to fix quick-fire exploits.
    4.) Time limits on using the commands. If you made it so people can only sell or buy gold in a certain period or just limit the number of commands per unit time this could limit the effect of the exploit.

    Are any of 2.) through 4.) feasible? Would be great to hear your thoughts on this. Thanks!
  25. @freefish

    Now I'M kicking myself for not noticing this during development and testing! Sheesh, Don't know why I didn't think of a way around this in the first place.

    Well, I can definitely see solution #4 being implemented, shouldn't be too hard to do, and I have seen it been done in other plugins before (see: essentials' tp cooldown time), and even if it isn't a complete solution, a configurable cool-down rate would be a nice thing to have.
  26. Offline


    Excellent, I'll keep an eye out for updates. Thanks for your work on this plugin, it has been great for our server so far :)
  27. Actually, I think I just figured out a better way to solve this problem, and it's probalby the easiest to implement and I think is the solution I was looking for all along.

    Currently, both buying and selling operations work like so:
    for (int i=0;i<amountToSell;i++){
        thisSale += getCurrentPrice(); //adds the current going price of the item to the total transaction amount
        transactions++; //or transactions-- for buying
    To calculate the dollar amount of a transaction for each single item to sell, it will:
    1. Add the current going price to the total sale
    2. increment the number of transactions
    The problem with this being done for both buying AND selling is that because this works on a post-increment (add the number, THEN increment), it creates an exploit when buying due to the buy procedure not undoing the increment before it calculates price, instead it does this afterwards. However the solution would be to simply change the buying procedure to work with a pre-increment (increment first, THEN add the number), i.e. undo the last sale first, then buy the item at the price it was previously. So in this case I'll just have to swap those two lines.

    However, as a result of this whenever you do a /gsworth to show the current going price, it will only be the price for selling items, and the price for buying will actually be one increment (or your ratio x 1) higher. I'll probably end up adding a new message sent to players executing this command that also states the buy price to prevent players from being confused.

    TL;DR / TT;DU
    The problem was with some overlooked logic in the buy procedure. Because buying is essentially the inverse of selling (price goes up instead of down), the buying procedure should also be inverted to effectively reverse the action of selling BEFORE the price is calculated. From now on (coming in the next release, which I really need to light a fire under my ass to get finished), the buy price will always be one increment higher than the sell price.

    However, a cooldown still could not hurt and I'll end up including that as well, but maybe not in the next release. I've been bogged down at work lately and haven't had much time for personal coding so I'm trying to limit the amount of changes I want to make in 1.0
  28. Offline


    Totally understand about being busy, and this fix sounds like it'll solve the problem neatly and effectively :)
  29. Offline


    I registered on the forums specially to thank you for this plugin, it is exactly what I was looking for. I tried another gold based mod and it's like you read my mind and solved all the problems I saw with that one. Just wanted to encourage you so you keep this updated :D
  30. Offline


    I have a question about the formula to calculate the prices of gold. I need something similar in my plugin. I calculate the number of transactions

    The problem is, can't a person sell gold, drive price down, buy gold drive price up, sell gold make profit infinitely?
    Is the only way to solve this by ignoring a person's own transactions? But then each person has a different price for gold and someone with a low price can make someone with a high price sell their gold for profit.

    Any thoughts?
  31. lol, funny you should ask, go back a couple of posts on the previous page and I believe you'll find your answer. A user had reported this exact problem and I explained how it is fixed in the upcoming version. It basically is solved by making selling post-increment, and buying pre-increment.

Share This Page