Stock Market
StockMarket
StockMarket is a plugin designed to create a virtual and random in game Stock Market that has random events and can be a lot of fun.
You can customize the plugin so in general players will lose money, but the smart ones will come out making money. You can customize it so just about everyone is constantly making money. You can customize it so in general the stocks price stay about the same, with max and min prices so players cannot profit much from it.
Theres lots of random events and always room for more, where stocks prices are affected by certain world events or company events. The frequency of these events can be customized.
All data is stored using mySQL. Support for other DBs including flatfiles and sqlite will come later.
Plugin is currently in alpha (or whatever you want to think of it as).
Dependencies
- Vault
- Vault Compatible Economy Plugin
- MySQL Database
Commands
- /sm help <page> - Displays StockMarket help. - Permission Node: stockMarket.user.help
- /sm info - Displays plugin version & status. - Permission Node: stockMarket.user.info
- /sm list - Displays a list of stocks you are allowed to buy and their current price. - Permission Node: stockMarket.user.list
- /sm list mine - Displays a list of stocks that you currently own and their current price. - Permission Node: stockMarket.user.list
- /sm buy <stockID> <amount> - Buys the stock & amount specified. - Permission Node: stockMarket.user.buy
- /sm sell <stockID> <amount> - Sells the stock & amount specified - Permission Node: stockMarket.user.sell
- /sm add <stockID> <basePrice> <maxPrice> <minPrice> <volatility> <amount> <dividend> <stockName> - Adds a new stock to the list of all stocks. - Permission Node: stockMarket.admin.add
- /sm remove <stockID> - Removes an existing stock from the list of all stocks. Cannot be undone. - Permission Node: stockMarket.admin.remove
- /sm set <stockID> <newBasePrice> <newMaxPrice> <newMinPrice> <newVolatility> <newAmount> <newDividend> <newStockName> - Edits an existing stocks information. - Permission Node: stockMarket.admin.set
- /sm forcerandom - Forces a random event to occur on a random stock. Does nothing if no stocks exist - Permission Node: stockMarket.admin.event
- /sm reload - Reloads the plugins config. - Permission Node: stockMarket.admin.reload
- /sm <stockID> - displays more info about stock requested. - Permission Node: stockMarket.user.detail
Configuration
So right now the plugin is purely MySQL, as stated above support for other formats will be added later. Run the plugin once to generate the default config file. By default the MySQL server is localhost:3306 user: root pass: "" database: sm. If the database does not exist, it will be created. There are a few other options in there as well. :)
This plugin depends on Vault. It also requires that there be an economy plugin and a permissions plugin, else it unloads on start-up.
Adding Stocks
To add a stock use /sm add.
For example:
- /sm add MASH 100 200 1 100 -1 1 Mashlol's Epic Business of Amazingness
- /sm add AAPL 500 1000 1 25 500 2 Apple Inc.
In general:
- /sm add ID BasePrice MaxPrice MinPrice Volatility Amount Dividend (Name Can Continue For As Long As You Want)
Creating Events
#: <-- This number must follow order (i.e. don't have events 0-3 and 5-7, that would be pointless and also wouldn't work) message: Message <-- This message will be displayed when the event occurs. All instances of %s will be replaced with the Stock ID. effect: 50 <-- This is the base effect based on the base price. I.e. the max price change that can occur if this is 50, is an increase in the stocks price equal to 50% of the base price (that is of course if the volatility of the stock is 100) up: true <-- Does this event increase the price or decrease it? True for increase, false for decrease. frequency: 50 <-- This has a chance of 50/(sum of all frequencies) to be selected. For example if there are 3 events, each with a frequency of 1, they each have a 1/3 chance of occuring.
Default Config
# How many stocks is the player allowed in total? max-total-stocks-per-player: 250 # How many stocks is the player allowed of each stock? max-total-stocks-per-player-per-stock: 50 # How often in minutes should random events occur? random-event-frequency: 60 # How often in minutes should dividends be paid out? dividend-frequency: 1440 # Should offline players be paid during dividend payouts? pay-offline-players: true # Broadcast events? broadcast-events: true # Broadcast dividend payouts? broadcast-payouts: true mysql: ip: localhost port: 3306 username: root password: "" database: sm events: 0: message: "The CEO of %s has died of a heart attack. The replacement is looking to be a poor one." effect: 40 up: false frequency: 50 1: message: "The CEO of %s has died of a heart attack. The replacement looks like he is even better than his successor!" effect: 40 up: true frequency: 50 2: message: "%s has announced a new product to be released! Speculation is high!" effect: 8 up: true frequency: 250 3: message: "%s has announced a new product to be released! Speculation is high!" effect: 8 up: false frequency: 250 4: message: "%s's announced product was a huge success, customers are extremely satisfied!" effect: 45 up: true frequency: 250 5: message: "%s's announced product was poorly made, causing poor customer satisfaction!" effect: 45 up: false frequency: 250 6: message: "%s had a bad quarter." effect: 30 up: false frequency: 100 7: message: "%s had a fantastic quarter." effect: 30 up: true frequency: 100 8: message: "Everyone is speculating that %s is soon to come out with an extremely amazing product!" effect: 65 up: true frequency: 5 9: message: "%s is on the brink of bankruptcy." effect: 65 up: false frequency: 5 10: message: "%s just invented the next best thing since sliced bread!" effect: 400 up: true frequency: 1 11: message: "%s just went bankrupt." effect: 400 up: false frequency: 1 12: message: "%s just announced that they are replacing their current CEO, who has a bad reputation." effect: 25 up: true frequency: 25 13: message: "%s just announced that they are replacing their current CEO, who everyone loves." effect: 25 up: false frequency: 25
Misc
- Source: https://github.com/Mashlol/StockMarket
- Tickets: https://github.com/Mashlol/StockMarket/issues
Warning
If you decide to test this plugin, I hold no responsibility for any possible bugs. As it is in alpha, there are likely to be exploits and such which may possibly allow a player to abuse the economy. If you run a server that is based solely on economy, you might want to wait until beta or release :)
@btesch
Really not up to me to do that, it requires a mySQL database, look up how to set one up. You just need a mySQL server running, plugin can handle the rest.
The directions on setting up the data base seems to discomfit me slightly could you be so kind and explain in more detail?
@btesch
Did you set up your database correctly & modify the config?
OK i have downloaded Vault and then i got this:
2012-04-07 17:41:35 [INFO] [StockMarket] Enabling StockMarket v0.06 2012-04-07 17:41:35 [INFO] [StockMarket] Economy plugin detected and hooked into. 2012-04-07 17:41:35 [INFO] [StockMarket] Permissions plugin detected and hooked into. 2012-04-07 17:41:39 [SEVERE] com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure
The last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server. 2012-04-07 17:41:39 [SEVERE] at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) 2012-04-07 17:41:39 [SEVERE] at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source) 2012-04-07 17:41:39 [SEVERE] at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source) 2012-04-07 17:41:39 [SEVERE] at java.lang.reflect.Constructor.newInstance(Unknown Source) 2012-04-07 17:41:39 [SEVERE] at com.mysql.jdbc.Util.handleNewInstance(Util.java:407) 2012-04-07 17:41:39 [SEVERE] at com.mysql.jdbc.SQLError.createCommunicationsException(SQLError.java:1116) 2012-04-07 17:41:39 [SEVERE] at com.mysql.jdbc.MysqlIO.<init>(MysqlIO.java:343) 2012-04-07 17:41:39 [SEVERE] at com.mysql.jdbc.ConnectionImpl.coreConnect(ConnectionImpl.java:2334) 2012-04-07 17:41:39 [SEVERE] at com.mysql.jdbc.ConnectionImpl.connectOneTryOnly(ConnectionImpl.java:2371) 2012-04-07 17:41:39 [SEVERE] at com.mysql.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:2163) 2012-04-07 17:41:39 [SEVERE] at com.mysql.jdbc.ConnectionImpl.<init>(ConnectionImpl.java:794) 2012-04-07 17:41:39 [SEVERE] at com.mysql.jdbc.JDBC4Connection.<init>(JDBC4Connection.java:47) 2012-04-07 17:41:39 [SEVERE] at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) 2012-04-07 17:41:39 [SEVERE] at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source) 2012-04-07 17:41:39 [SEVERE] at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source) 2012-04-07 17:41:39 [SEVERE] at java.lang.reflect.Constructor.newInstance(Unknown Source) 2012-04-07 17:41:39 [SEVERE] at com.mysql.jdbc.Util.handleNewInstance(Util.java:407) 2012-04-07 17:41:39 [SEVERE] at com.mysql.jdbc.ConnectionImpl.getInstance(ConnectionImpl.java:378) 2012-04-07 17:41:39 [SEVERE] at com.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:305) 2012-04-07 17:41:39 [SEVERE] at java.sql.DriverManager.getConnection(Unknown Source) 2012-04-07 17:41:39 [SEVERE] at java.sql.DriverManager.getConnection(Unknown Source) 2012-04-07 17:41:39 [SEVERE] at com.github.mashlol.MySQL.<init>(MySQL.java:30) 2012-04-07 17:41:39 [SEVERE] at com.github.mashlol.Threads.StockMarketEventThread.<init>(StockMarketEventThread.java:20) 2012-04-07 17:41:40 [SEVERE] at com.github.mashlol.StockMarket.onEnable(StockMarket.java:80) 2012-04-07 17:41:40 [SEVERE] at org.bukkit.plugin.java.JavaPlugin.setEnabled(JavaPlugin.java:215) 2012-04-07 17:41:40 [SEVERE] at org.bukkit.plugin.java.JavaPluginLoader.enablePlugin(JavaPluginLoader.java:336) 2012-04-07 17:41:40 [SEVERE] at org.bukkit.plugin.SimplePluginManager.enablePlugin(SimplePluginManager.java:381) 2012-04-07 17:41:40 [SEVERE] at org.bukkit.craftbukkit.CraftServer.loadPlugin(CraftServer.java:250) 2012-04-07 17:41:40 [SEVERE] at org.bukkit.craftbukkit.CraftServer.enablePlugins(CraftServer.java:232) 2012-04-07 17:41:40 [SEVERE] at org.bukkit.craftbukkit.CraftServer.reload(CraftServer.java:543) 2012-04-07 17:41:40 [SEVERE] at org.bukkit.Bukkit.reload(Bukkit.java:182) 2012-04-07 17:41:40 [SEVERE] at org.bukkit.command.defaults.ReloadCommand.execute(ReloadCommand.java:22) 2012-04-07 17:41:40 [SEVERE] at org.bukkit.command.SimpleCommandMap.dispatch(SimpleCommandMap.java:166) 2012-04-07 17:41:40 [SEVERE] at org.bukkit.craftbukkit.CraftServer.dispatchCommand(CraftServer.java:473) 2012-04-07 17:41:40 [SEVERE] at org.bukkit.craftbukkit.CraftServer.dispatchServerCommand(CraftServer.java:469) 2012-04-07 17:41:40 [SEVERE] at net.minecraft.server.MinecraftServer.b(MinecraftServer.java:596) 2012-04-07 17:41:40 [SEVERE] at net.minecraft.server.MinecraftServer.w(MinecraftServer.java:565) 2012-04-07 17:41:40 [SEVERE] at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:449) 2012-04-07 17:41:40 [SEVERE] at net.minecraft.server.ThreadServerApplication.run(SourceFile:492) 2012-04-07 17:41:40 [SEVERE] Caused by: java.net.ConnectException: Connection refused: connect 2012-04-07 17:41:40 [SEVERE] at java.net.DualStackPlainSocketImpl.connect0(Native Method) 2012-04-07 17:41:40 [SEVERE] at java.net.DualStackPlainSocketImpl.socketConnect(Unknown Source) 2012-04-07 17:41:40 [SEVERE] at java.net.AbstractPlainSocketImpl.doConnect(Unknown Source) 2012-04-07 17:41:40 [SEVERE] at java.net.AbstractPlainSocketImpl.connectToAddress(Unknown Source) 2012-04-07 17:41:40 [SEVERE] at java.net.AbstractPlainSocketImpl.connect(Unknown Source) 2012-04-07 17:41:40 [SEVERE] at java.net.PlainSocketImpl.connect(Unknown Source) 2012-04-07 17:41:40 [SEVERE] at java.net.SocksSocketImpl.connect(Unknown Source) 2012-04-07 17:41:40 [SEVERE] at java.net.Socket.connect(Unknown Source) 2012-04-07 17:41:40 [SEVERE] at java.net.Socket.connect(Unknown Source) 2012-04-07 17:41:40 [SEVERE] at java.net.Socket.<init>(Unknown Source) 2012-04-07 17:41:40 [SEVERE] at java.net.Socket.<init>(Unknown Source) 2012-04-07 17:41:40 [SEVERE] at com.mysql.jdbc.StandardSocketFactory.connect(StandardSocketFactory.java:254) 2012-04-07 17:41:40 [SEVERE] at com.mysql.jdbc.MysqlIO.<init>(MysqlIO.java:292) 2012-04-07 17:41:40 [SEVERE] ... 32 more 2012-04-07 17:41:40 [SEVERE] Error occurred while enabling StockMarket v0.06 (Is it up to date?) java.lang.NullPointerException at com.github.mashlol.MySQL.prepareStatement(MySQL.java:144) at com.github.mashlol.MySQL.query(MySQL.java:107) at com.github.mashlol.Threads.StockMarketEventThread.<init>(StockMarketEventThread.java:22) at com.github.mashlol.StockMarket.onEnable(StockMarket.java:80) at org.bukkit.plugin.java.JavaPlugin.setEnabled(JavaPlugin.java:215) at org.bukkit.plugin.java.JavaPluginLoader.enablePlugin(JavaPluginLoader.java:336) at org.bukkit.plugin.SimplePluginManager.enablePlugin(SimplePluginManager.java:381) at org.bukkit.craftbukkit.CraftServer.loadPlugin(CraftServer.java:250) at org.bukkit.craftbukkit.CraftServer.enablePlugins(CraftServer.java:232) at org.bukkit.craftbukkit.CraftServer.reload(CraftServer.java:543) at org.bukkit.Bukkit.reload(Bukkit.java:182) at org.bukkit.command.defaults.ReloadCommand.execute(ReloadCommand.java:22) at org.bukkit.command.SimpleCommandMap.dispatch(SimpleCommandMap.java:166) at org.bukkit.craftbukkit.CraftServer.dispatchCommand(CraftServer.java:473) at org.bukkit.craftbukkit.CraftServer.dispatchServerCommand(CraftServer.java:469) at net.minecraft.server.MinecraftServer.b(MinecraftServer.java:596) at net.minecraft.server.MinecraftServer.w(MinecraftServer.java:565) at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:449) at net.minecraft.server.ThreadServerApplication.run(SourceFile:492)
Any Ideas? :)
@btesch
It depends on Vault. Download Vault and put that in your plugin folder.
Hey i Saw this plugin and it looks amazing!!!! But it does not seem to work i keep getting this error code:
2012-04-03 18:13:18 [SEVERE] Could not load 'plugins\StockMarket.jar' in folder 'plugins' org.bukkit.plugin.UnknownDependencyException: Vault at org.bukkit.plugin.SimplePluginManager.loadPlugins(SimplePluginManager.java:195) at org.bukkit.craftbukkit.CraftServer.loadPlugins(CraftServer.java:207) at org.bukkit.craftbukkit.CraftServer.<init>(CraftServer.java:183) at net.minecraft.server.ServerConfigurationManager.<init>(ServerConfigurationManager.java:53) at net.minecraft.server.MinecraftServer.init(MinecraftServer.java:156) at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:425) at net.minecraft.server.ThreadServerApplication.run(SourceFile:490)
Whats do you guys think?
@Joymo
Busy with other things atm, will be updating when I am inspired to add new stuff =)
Hmm still Alpha but no update in weeks, is there anything you need right now to move it to Beta/Release, or did you give up already ? :<
@6y7t8h
At the moment, only at the time of the events.
@KnightsOfTables
Ah, thank you for the quick reply. And do stock prices change only by random events, or do they fluctuate in between these events?
@6y7t8h
The volatility is a % based number which represents the scale of the price changes of the stock. A stock with 100% volatility for example will not fluctuate in price as much as one with 200%, and a stock with only 20% volatility will fluctuate 1/5 as much as one with 100%.
Hi, this plugin looks really promising and I was wondering whether you could clarify the Volatility of a stock in terms of the plugin? What does the number represent?
@MontegroDK
Updated main post with a better description of it under configuration.
I can't seem to get to /sm add command syntax right, mind providing an example for the command?
Updated so you can create your own events or edit current events from the config.yml. Also fixed a few bugs and grouped the permission nodes.
Just waiting on approval :)
@Joymo
Yep, its tough to simulate a real stock market in a virtual scenario. Unfortunately right now the stocks aren't really linked to anything, thus no actual in game event can really cause a logical price change to occur. There is no simple/universal way to track item sales or prices, and every server will have different prices for items. One thing I'd like to add is the possibility for earning dividends for owning stocks. Certain stocks would have a higher dividend and thus be in more demand, naturally increasing the price on them. Possibly the dividends could also change based on random events as well.
Mostly in reality a stock market is gambling & very difficult to predict. I think it would be great if certain random events might be predictable but not guaranteed, and as you said be done slowly after their announcement. There is currently for example an event that will "bankrupt" a company which will drastically reduce their stock price. A good addition would be if a bankruptcy were to occur, some special event would have to occur in order to bring them out of bankruptcy, such as another company buying them out, which would also have a low chance of happening.
Currently stock prices are not affected by purchase/sale of them, which is something I'd like to add in the future. I'll have to work out a way to do this without allowing abuse.
Oh a new attempt at a Stock Market, love it, already looking good by having a nice selection of random events!
Will surely help test this. One thing that's always troubled me, to be more than simply a different form of utter Gambling, there needs to be some way to either predict events, or see them coming, or when an event is announced, it's effects need to be delayed but mysterious, so people can react.
If you get my drift, not sure if you have ideas about that yet :P
Keep it up \o/
Did some basic testing of functionality on Test server, no issues so far :)
I've just updated with some nice event changes. Try it out and force some events when its approved, they are pretty cool. I'll create a setup guide on the weekend probably for anyone worried about setting it up, its pretty easy.
@fisherman77
I'm not sure what you mean by 'awed' ?
@BehindTheMatrix
Hadn't seen the part about signs before, I had that planned in the future. Also had planned support for regions (can only buy in a stock market designated region orso)
Sticks = stocks
I use Citizens on my server. You know what would be awesome? If the sticks could be awed on an npc's sales!