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 :)
Can I continue this plugin? I will update, etc.
Can someone continue this plugin
Another dead plugin, sad :(
Hi! I'm using iConomy for this plugin that looks really awesome. Everything works well except for that you don't loose money when you buy stocks is there any recommended economy plugin to use?
Please update, this is a great idea!
Im having the same problem. It says that the stocks have been brought, but the balance doesnt update. I am using BOSEconomy personnaly. I am also running tekkit. I would love it if you would fix :D
Has anyone else experienced a bug in purchasing stocks? When I buy stocks it fails to communicate this to Vault and update iConomy (my balance doesn't change but I am given the stocks). Oddly enough, when I go to sell the stocks it succeeds and my balance is updated. I've had to disable this as you can see where an exploit would exist.
Edit: I've changed over to CraftConomy on an unrelated note. This issue is duplicated in this economy plugin so it must be a purchasing code bug or the hook to Vault that is failing.
Please help.... I cant edit my config! When I reload it wipes out.
Abandoned? :(
@KnightsOfTables
thx and srry
@Spartan3222
This is a database error, not a plugin issue. Look up how to setup a mysql DB.
@KnightsOfTables
not for me i get 20:06:37 [SEVERE] com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Commu nications link failure
The last packet sent successfully to the server was 0 milliseconds ago. The driv er has not received any packets from the server. 20:06:37 [SEVERE] at sun.reflect.NativeConstructorAccessorImpl.newInstance 0(Native Method) 20:06:37 [SEVERE] at sun.reflect.NativeConstructorAccessorImpl.newInstance (Unknown Source) 20:06:37 [SEVERE] at sun.reflect.DelegatingConstructorAccessorImpl.newInst ance(Unknown Source) 20:06:37 [SEVERE] at java.lang.reflect.Constructor.newInstance(Unknown Sou rce) 20:06:37 [SEVERE] at com.mysql.jdbc.Util.handleNewInstance(Util.java:407) 20:06:37 [SEVERE] at com.mysql.jdbc.SQLError.createCommunicationsException (SQLError.java:1116) 20:06:37 [SEVERE] at com.mysql.jdbc.MysqlIO.<init>(MysqlIO.java:343) 20:06:37 [SEVERE] at com.mysql.jdbc.ConnectionImpl.coreConnect(ConnectionI mpl.java:2334) 20:06:37 [SEVERE] at com.mysql.jdbc.ConnectionImpl.connectOneTryOnly(Conne ctionImpl.java:2371) 20:06:37 [SEVERE] at com.mysql.jdbc.ConnectionImpl.createNewIO(ConnectionI mpl.java:2163) 20:06:37 [SEVERE] at com.mysql.jdbc.ConnectionImpl.<init>(ConnectionImpl.j ava:794) 20:06:37 [SEVERE] at com.mysql.jdbc.JDBC4Connection.<init>(JDBC4Connection .java:47) 20:06:37 [SEVERE] at sun.reflect.NativeConstructorAccessorImpl.newInstance 0(Native Method) 20:06:37 [SEVERE] at sun.reflect.NativeConstructorAccessorImpl.newInstance (Unknown Source) 20:06:37 [SEVERE] at sun.reflect.DelegatingConstructorAccessorImpl.newInst ance(Unknown Source) 20:06:37 [SEVERE] at java.lang.reflect.Constructor.newInstance(Unknown Sou rce) 20:06:37 [SEVERE] at com.mysql.jdbc.Util.handleNewInstance(Util.java:407) 20:06:37 [SEVERE] at com.mysql.jdbc.ConnectionImpl.getInstance(ConnectionI mpl.java:378) 20:06:37 [SEVERE] at com.mysql.jdbc.NonRegisteringDriver.connect(NonRegist eringDriver.java:305) 20:06:37 [SEVERE] at java.sql.DriverManager.getConnection(Unknown Source) 20:06:37 [SEVERE] at java.sql.DriverManager.getConnection(Unknown Source) 20:06:37 [SEVERE] at com.github.mashlol.MySQL.<init>(MySQL.java:30) 20:06:37 [SEVERE] at com.github.mashlol.Stocks.Stock.getInfo(Stock.java:33 ) 20:06:37 [SEVERE] at com.github.mashlol.Stocks.Stock.<init>(Stock.java:28)
20:06:37 [SEVERE] at com.github.mashlol.StockMarketCommandExecutor.onComma nd(StockMarketCommandExecutor.java:125) 20:06:37 [SEVERE] at org.bukkit.command.PluginCommand.execute(PluginComman d.java:40) 20:06:37 [SEVERE] at org.bukkit.command.SimpleCommandMap.dispatch(SimpleCo mmandMap.java:166) 20:06:37 [SEVERE] at org.bukkit.craftbukkit.CraftServer.dispatchCommand(Cr aftServer.java:479) 20:06:37 [SEVERE] at net.minecraft.server.NetServerHandler.handleCommand(N etServerHandler.java:821) 20:06:37 [SEVERE] at net.minecraft.server.NetServerHandler.chat(NetServerH andler.java:781) 20:06:37 [SEVERE] at net.minecraft.server.NetServerHandler.a(NetServerHand ler.java:764) 20:06:37 [SEVERE] at net.minecraft.server.Packet3Chat.handle(Packet3Chat.j ava:34) 20:06:37 [SEVERE] at net.minecraft.server.NetworkManager.b(NetworkManager. java:229) 20:06:37 [SEVERE] at net.minecraft.server.NetServerHandler.a(NetServerHand ler.java:113) 20:06:37 [SEVERE] at net.minecraft.server.NetworkListenThread.a(NetworkLis tenThread.java:78) 20:06:37 [SEVERE] at net.minecraft.server.MinecraftServer.w(MinecraftServe r.java:567) 20:06:37 [SEVERE] at net.minecraft.server.MinecraftServer.run(MinecraftSer ver.java:459) 20:06:37 [SEVERE] at net.minecraft.server.ThreadServerApplication.run(Sour ceFile:492) 20:06:37 [SEVERE] Caused by: java.net.ConnectException: Connection refused: conn ect 20:06:37 [SEVERE] at java.net.DualStackPlainSocketImpl.connect0(Native Met hod) 20:06:37 [SEVERE] at java.net.DualStackPlainSocketImpl.socketConnect(Unkno wn Source) 20:06:37 [SEVERE] at java.net.AbstractPlainSocketImpl.doConnect(Unknown So urce) 20:06:37 [SEVERE] at java.net.AbstractPlainSocketImpl.connectToAddress(Unk nown Source) 20:06:37 [SEVERE] at java.net.AbstractPlainSocketImpl.connect(Unknown Sour ce) 20:06:37 [SEVERE] at java.net.PlainSocketImpl.connect(Unknown Source) 20:06:37 [SEVERE] at java.net.SocksSocketImpl.connect(Unknown Source) 20:06:37 [SEVERE] at java.net.Socket.connect(Unknown Source) 20:06:37 [SEVERE] at java.net.Socket.connect(Unknown Source) 20:06:37 [SEVERE] at java.net.Socket.<init>(Unknown Source) 20:06:37 [SEVERE] at java.net.Socket.<init>(Unknown Source) 20:06:37 [SEVERE] at com.mysql.jdbc.StandardSocketFactory.connect(Standard SocketFactory.java:254) 20:06:37 [SEVERE] at com.mysql.jdbc.MysqlIO.<init>(MysqlIO.java:292) 20:06:37 [SEVERE] ... 31 more 20:06:37 [SEVERE] null org.bukkit.command.CommandException: Unhandled exception executing command 'sm' in plugin StockMarket v0.06 at org.bukkit.command.PluginCommand.execute(PluginCommand.java:42) at org.bukkit.command.SimpleCommandMap.dispatch(SimpleCommandMap.java:16 6) at org.bukkit.craftbukkit.CraftServer.dispatchCommand(CraftServer.java:4 79) at net.minecraft.server.NetServerHandler.handleCommand(NetServerHandler. java:821) at net.minecraft.server.NetServerHandler.chat(NetServerHandler.java:781)
at net.minecraft.server.NetServerHandler.a(NetServerHandler.java:764) at net.minecraft.server.Packet3Chat.handle(Packet3Chat.java:34) at net.minecraft.server.NetworkManager.b(NetworkManager.java:229) at net.minecraft.server.NetServerHandler.a(NetServerHandler.java:113) at net.minecraft.server.NetworkListenThread.a(NetworkListenThread.java:7 8) at net.minecraft.server.MinecraftServer.w(MinecraftServer.java:567) at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:459) at net.minecraft.server.ThreadServerApplication.run(SourceFile:492) Caused by: java.lang.NullPointerException at com.github.mashlol.MySQL.prepareStatement(MySQL.java:144) at com.github.mashlol.Stocks.Stock.getInfo(Stock.java:35) at com.github.mashlol.Stocks.Stock.<init>(Stock.java:28) at com.github.mashlol.StockMarketCommandExecutor.onCommand(StockMarketCo mmandExecutor.java:125) at org.bukkit.command.PluginCommand.execute(PluginCommand.java:40) ... 12 more when i try to use it
also include something like a wall street thing
@Spartan3222
It works fine for 1.2.5
Hey not for mean purposes but when r u updating the plugin to 1.2.5
@botskonet
Help is always welcome and appreciated.
I really love this plugin and want to add some improvements and help out if I can. I have already added a feature that will record the buy price of the stock because I want to the user to be able to see the total difference when they sell it. So if you buy a stock for $20 and a week later sell it for $30, I want to show that difference.
I have several other ideas and will submit them as I complete them as pull requests on github.
@KnightsOfTables
Cool! Thanks. The stock ticker sign would be a good addition, but a stock ticker for websites would be just as useful. Also, I don't know much PHP, so I wouldn't know how to display data from MySQL tables on my webpages. I would if I could. I guess someone could make one easily, and it would be extremely useful.
@josdog7
I'll be making some good updates within the next week or two, a web interface is currently do-able since its all mySQL, feel free to write one yourself, not sure if it will be something on my to-do list or not.
One thing that possibly IS on the to-do list is a stock ticker sign, where it will cycle through the stocks and make them green or red depending on if they are up or down, and show the amount up or down.
It would be cool if you made twitter integration with this, or made a web interface with stock levels. I love the idea of stocks in the economy of my server, and this would be a nice addition.