This plugin is in BETA, though each version is thoroughly tested, you may encounter bugs. This is due to the nature of the number of possible scenarios which may be encountered with a plugin of this nature. Price will go up after beta so purchase now to secure updates for the lifetime of the development of the plugin.
Test Server: mc.maldahleh.ca
Features
- Add to your economy by allowing players to purchase virtual stocks based on the real world stock market. This plugin hooks into Yahoo Finance making it possible for players to buy virtual stocks of any company on a stock exchange that is listed on Yahoo Finance. (There may be a 15 minute delay on price updates, this is due to the nature of the YahooFinance API)
- Currency conversion, is a player buying a stock such as the Canadian Pizza Pizza Stock? Currency will be converted to USD from CAD before being charged from the player’s account based on real time exchange rates with forex backup support.
- After-hours trading, this plugin supports the latest real time rates including support for up to date after hours rates.
- Forex support, want to lookup the conversion rate of two currencies, do so using the Forex lookup command (Example: EURUSD).
- Stock Broker NPCs, allows the spawning of NPCs that provide all command functionality through an interactive user interface.
- Stock information tool, allows users to quickly look up all statistics pertaining to a stock in game, including information such as: Company Name, Stock Exchange company is listed on, Current Price, Trading Currency, Stock Symbol, Day High, Day Low, Today’s Open Price, Volume, Previous Close Price, Year High and Year Low including historical information for the past year.
- Compare tools, allow users to compare a minimum of two and a maximum of three stocks at the same time side-by-side for the player to choose which stock is the best buy.
- Stock leaderboard, allows users to quickly view the top 54 stock market players sorted in descending order by portfolio value.
- Portfolio, stock and transactions tool, allows users to quickly view details on all their current stocks as well as transaction history which allows users to view all of their past transactions in addition to stock history which displays server wide transactions of a specific stock.
- Administrative tools, including a reload command allowing administrators to quickly reload the configuration file in game without needing to restart the server in addition to a purge command for quickly and easily wiping the MySQL tables.
- Fully customizable messages with variables and colour codes, all messages are defined in the config.yml file in addition to options of implementing items such as broker fees, including a percentage and a set rate.
- Developer API, documented below, allows for developers to hook into this plugin and retrieve data.
- Abuse prevention, toggle this setting on in the config, enforces a one day waiting period between selling a purchased stock. Used to prevent abuse in potential API delays.
- Chest Interface with multiple pages support, all data is displayed in chest interfaces to make it easy for the user to view the information they are looking for quickly and efficiently. All the data not fitting on one chest page? Multiple page support exists which will provide a way to view multiple pages of data.
- Efficient, MySQL with use of the HikariCP connection pool. Database querying and API lookup is done Async in order to ensure delays don’t stall the main server thread.
Demonstrations
* Apologies for cut off lore, my computer was having issues and was not allowing me to resize my Minecraft so it was really small and lore was cut off, these videos will be remade at a later date *
Stock Lookup - US Market - http://recordit.co/U0AncIuowP
Stock Lookup - International Market - http://recordit.co/WHE558UA6y
* In both scenarios, server price was derived from market price with any applicable conversions to USD and a x10 multiplier. *
Forex Lookup - CAD to USD - http://recordit.co/rAnFv7L4J3
Compare - GOOG, AAPL and TSCO.L - http://recordit.co/1ES6IByyR2
Stock List - http://recordit.co/4YOsCI7Lnc
Stock Transaction History - http://recordit.co/KF2R6CNEUu
Stock Leaderboards - http://recordit.co/OSXbMVjDmP
Portfolio - One Page - http://recordit.co/FzwNeuwOT5
Portfolio - Multiple Pages - http://recordit.co/DXHEp4ObPn
* The portfolio lists each individual purchase separately as to display the net of the specific transaction which is only comparable with the price on day of purchase. As a result not all of the same stock can be made one item on the portfolio, though they are grouped alphabetically by symbol. The portfolio also supports an infinite number of pages (to the max of an integer). *
* A large net exists in this portfolio as the stocks in the portfolio were purchased with a 0 multiplier, the net takes into account the x10 multiplier that was in place when the portfolio was generated. *
Transactions - http://recordit.co/9D4bxUeHEr
Buy:
Sell:
* Apologies for cut off lore, my computer was having issues and was not allowing me to resize my Minecraft so it was really small and lore was cut off, these videos will be remade at a later date *
Stock Lookup - US Market - http://recordit.co/U0AncIuowP
Stock Lookup - International Market - http://recordit.co/WHE558UA6y
* In both scenarios, server price was derived from market price with any applicable conversions to USD and a x10 multiplier. *
Forex Lookup - CAD to USD - http://recordit.co/rAnFv7L4J3
Compare - GOOG, AAPL and TSCO.L - http://recordit.co/1ES6IByyR2
Stock List - http://recordit.co/4YOsCI7Lnc
Stock Transaction History - http://recordit.co/KF2R6CNEUu
Stock Leaderboards - http://recordit.co/OSXbMVjDmP
Portfolio - One Page - http://recordit.co/FzwNeuwOT5
Portfolio - Multiple Pages - http://recordit.co/DXHEp4ObPn
* The portfolio lists each individual purchase separately as to display the net of the specific transaction which is only comparable with the price on day of purchase. As a result not all of the same stock can be made one item on the portfolio, though they are grouped alphabetically by symbol. The portfolio also supports an infinite number of pages (to the max of an integer). *
* A large net exists in this portfolio as the stocks in the portfolio were purchased with a 0 multiplier, the net takes into account the x10 multiplier that was in place when the portfolio was generated. *
Transactions - http://recordit.co/9D4bxUeHEr
Buy:
Sell:
Requirements
- MySQL database
- Vault
- Vault-compatible Economy Plugin
- Citizens (Latest build tested) (Optional, only needed if NPCs are enabled in the config)
Supported Stock Exchanges
- New York Stock Exchange
- NASDAQ
- Toronto Stock Exchange
- Mexican Stock Exchange
- Berlin Stock Exchange
- Munich Stock Exchange
- Germany Stock Exchange
- Stuttgart Stock Exchange
- London Stock Exchange
- Hong Kong Stock Exchange
- Euronext
** <> are required arguments, {} are optional arguments. **
/stock help - stockmarket.use
/stock tutorial - stockmarket.use
/stock lookup <SYMBOL> - Lookup a stock by symbol - stockmarket.lookup
/stock flookup <FOREX SYMBOL> - Lookup a Forex symbol (Ex. EURUSD) - stockmarket.lookup.forex
/stock list - List 26 popular stocks, in addition to directing users to YahooFinance to view the thousands of other stocks supported by this plugin - stockmarket.use
/stock buy <symbol> <quantity> - Buy a stock - stockmarket.use
/stock sell <symbol> <quantity> - Sell a stock - stockmarket.use
/stock compare <SYMBOL1>,<SYMBOL2>,{SYMBOL3} - Compare a minimum of two stocks with a maximum of three - stockmarket.compare
/stock portfolio {player} - View a portfolio, no arguments would provide the executor’s portfolio, while providing an argument would provide the target player’s portfolio. - stockmarket.portfolio and stockmarket.portfolio.other
/stock transactions {player} - View transaction history, no arguments would provide the executor's history, while providing an argument would provide the target player's history. stockmarket.transactions and stockmarket.transactions.other
/stock shistory <symbol> - View the transaction history of the specified stock - stockmarket.stockhistory
/stock leaderboard - View the top 54 players on the leaderboard, sorted by portfolio value. - stockmarket.leaderboard
Aliases for non-administrator commands: /stocks, /sm, /stockmarket
/sma reload - Reload the configuration file - stockmarket.admin
/sma tables - Wipes all plugin tables in the MySQL database - stockmarket.admin
/sma broker - Spawn a Broker NPC, if enabled in the config file - stockmarket.admin
/sma broker remove - Remove a Broker NPC by hitting them after executing this command, if you execute this command by mistake hit a block and it will disable itself - stockmarket.admin
stockmarket.nocommandbypass - Bypass for users if commands are disabled.
Code:
database:
# MySQL server IP Address
ip: “localhost"
# MySQL server port
port: 3306
# MySQL database
database: “stockmarket"
# MySQL username
username: “root"
# MySQL password
password: "password"
options:
# Whether NPCs are enabled or not, if set to true Citizens is required.
npc-enabled: true
# Whether commands are enabled or disabled, useful if you want players to use broker NPCs only.
commands-disabled: true
# Account broker fees are paid to, should be one word. Set to "" to disable.
fees-account: ""
# Account stock purchases are paid to, should be one word. Set to "" to disable.
stock-account: ""
# Account stock sales are paid from, should be one word. Set to "" to disable.
stock-purchasing-account: ""
# Price multiplier, set to 0 to disable.
# Used if stock prices need to be inflated for your server economy (ex. 60
# dollar stock would become 600 with a 10 multiplier)
multiplier: 10
# Prevents users from buying stocks that don’t have a USD price
prevent-non-usd-sale: false
# Convert non-USD stocks to USD (ex. CAD, EUR, GBP would be
# converted to USD)
convert-non-usd-to-usd: true
# Prevents users from buying or selling stocks at a zero value (usually
# caused by some sort of error on YahooFinance’s end). This is STRONGLY
# recommended to remain at true, invalid stocks may also return a zero
# value.
prevent-sale-of-zero-value: true
# Prevents people from buying and selling within the same day, this is to
# prevent user’s abusing the data delay by knowing what will happen to the
# price of a stock in critical scenarios (ex. a company’s profit earning
# announcements)
one-day-abuse-prevention: true
# A flat rate added on to all transactions to simulate real broker fees. Set to
# 0 to disable.
broker-fee-flat: 10
# A percentage added on to stock value (base price * (purchasing/selling
# quantity) to simulate real broker fees. Set to 0 to disable.
broker-fee-percent: 0
messages:
# Server currency suffix
server-currency: “Dollars”
# Used in certain scenarios, tell users to inform you if this message pops up
# as an error corresponds in the server log.
error-occured: "&4An error occurred, please inform a server administrator.”
# Success on admin purge command
purged-tables: "&4Purged MySQL tables”
# Used in case an error occurs with conversion, this will most likely and
# should never happen.
purchase-currency-not-supported: "&4The stock you are trying to buy has an unsupported original currency.”
# Used when user tries to purchase a stock that is not of USD currency if it
# is toggled on under options
no-purchase-non-USD: "&4You can not purchase stocks which are not of USD currency.”
# Used when user attempts to sell more of a stock than they own
no-stock-to-sell: "&4You can not sell <symbol> as you do not own enough of the stock.”
# Used when a user tries to sell a stock they bought within 24 hours, used if
# abuse prevention is true
day-not-passed: "&4You can not sell &c<symbol> &4for another &c<hours> &4hours.”
# Used when a user tries to purchase/sell a stock with a zero value, used if
# prevent zero value is true
invalid-price: "&4<symbol> &ccurrently has an invalid price and can not be bought/sold.”
# Used when user tries to purchase more of a stock than the user can
# afford.
not-enough-money: "&4You can not afford <quantity> of <symbol> with a grand total of <total>.”
# Used when a user purchases a stock, displays purchase summary
bought-stock:
- "&4Purchase Summary (<date>):"
- "&4You purchased &c<quantity> &4of &c<company> (<symbol>)"
- "&4Stock Value: &c<stock-value>"
- "&4Broker Fees: &c<broker-fees>"
- "&4Grand Total: &c<total>”
# Used when a user sells a stock, this portion is the header.
sold-stock:
- "&4Sale Summary:"
- "&4You sold &c<quantity> &4of &c<company> (<symbol>)”
# Used when a user sells a stock, this portion is the portion that will repeat
# depending on how many individual transactions of a stock are sold from.
stock-sold-report:
- "&4Stock ID: &c<stock-id> &4- Quantity: &c<quantity-of-stock>"
- " &4Stock Value: &c<stock-value> &4- Broker Fees: &c<broker-fees> &4- Total: &c<total>"
- " &4Purchased for: &c<purchase> &4- Net Gain/Loss: &c<net>”
# Footer of stock sale summary
stock-sold-footer: "&4Total Net: &c<total-net>”
# Used when a user specifies an invalid forex quote
invalid-forex-quote: "&4You specified an invalid Forex quote (Proper example: USDEUR).”
# Used when a user specifies an invalid quantity
invalid-quantity: "&4You specified an invalid quantity.”
# Used when the user uses the compare command incorrectly.
improper-compare-syntax: "&cIncorrect syntax”
# Used when the user tries to use the compare command to compare only
# one stock.
compare-minimum-two: "&cYou need to compare at least two stocks.”
# Used when the user tries to compare more than three stocks
compare-maximum-three: "&cYou can only compare three stocks at a time with the compare command.”
# Used when the user specifies an invalid stock symbol.
invalid-stock: "&cThat stock could not be found.”
# Used when the user uses a command incorrectly.
invalid-syntax: "&cYou did not use the proper command syntax.”
# Used when the config is reloaded successfully.
config-reloaded: "&cSuccessfully reloaded configuration file.”
# Used when the user attempts to use a command that he does not have
# permission for.
no-permission: "&cYou do not have permission to use that command.”
# Used when the console is uses to execute a player only command.
you-need-to-be-a-player: "Stock Market - You need to be a player to use that command.”
# Used when the portfolio is attempted to be opened for a player who has
# no portfolio stocks.
no-stocks-to-list: "&cThe specified player owns no stocks, portfolio not generated.”
# Used when the history is attempted to be opened for a player who has
# no transaction history.
no-transactions-to-list: "&cThe specified player has no transactions, history not generated."
# Used when there are no players to list for the leaderboard.
no-stock-players: "&4There are no stock players, leaderboard not generated."
# Used when there are no transactions for a specified stock
no-stock-transactions-to-list: "&cThe specified stock has no transactions, history not generated."
# Used to broadcast when a player purchases a stock, set to "" to disable
stock-purchase-broadcast: "&4Stock Market &8>> &4<player> &chas purchased &4<quantity> &cof &4<symbol> &cfor a value of &4<purchase-value> &cwith applied broker fees of &4<broker-fees> &cfor a grand total of &4<grand-total>&c."
# Used to broadcast when a player sells a stock, set to "" to disable
stock-sale-broadcast: "&4Stock Market &8>> &4<player> &chas sold &4<quantity> &cof &4<symbol> &cfor a value of &4<purchase-value> &cwith applied broker fees of &4<broker-fees> &cfor a grand total of &4<grand-total> &c(Inital: &4<inital-value> &cNet: &4<net>&c)."
# Used when no historical data is found, usually for companies less than a
# year old.
no-historical-data: "&cNo historical data found, this is most likely caused by the company not have existing for the past year."
# Used when the player uses the help command.
help:
- "&cWe run a virtual stock market, for a list of stocks you can buy, visit YahooFinance."
- "&cStocks are a great way to earn money by investing in virtual stocks in companies you think will be sucessful on the stock market."
- "&cOur virtual broker will charge you <percent>% in addition to a flat rate of <flat-rate> on each transaction."
# Used when a stock broker is spawned
stock-broker-spawned: "&4Spawned stock broker."
# Used to let the user know what to do when they execute the remove command.
stock-broker-removal: "&4Hit the stock broker you would like to remove."
# Used when a stock broker is removed.
stock-broker-removed: "&4Stock broker removed."
# Used when a player has removal mode on and does not hit a Stock Broker NPC.
stock-broker-no-npc: "&4You did not hit a stock broker, removal mode disabled."
# Used when attempts are made to spawn or kill stock brokers when npcs are disabled in the config.
stock-brokers-disabled: "&4Stock Brokers are disabled in the config, command failed."
# Used when a player attempts to use a stock market command while commands are disabled.
stock-commands-disabled: "&4Stock Market commands are disabled, make use of our Stock Brokers!"
# Used to let the user know how to lookup symbols through the broker.
stock-broker-stock-symbol-lookup: "&4Chat disabled. &cEnter the stock symbol you want to lookup in chat (Example: AAPL)."
# Used to let the user know how to lookup forex stocks through the broker.
stock-broker-forex-symbol-lookup: "&4Chat disabled. &cEnter the forex symbol you want to lookup in chat (Example: EURUSD)."
# Used to let the user know how to use the compare command through the broker.
stock-broker-compare: "&4Chat disabled. &cEnter the symbols you want to compare in chat (Example: AAPL,GOOG,TSCO.L)."
# Used to let the user know how to use the portfolio command through the broker.
stock-broker-portfolio: "&4Chat disabled. &cEnter the player you want to view the portfolio of in chat.”
# Used to let the user know how to use the stock history command through the broker.
stock-broker-stock-history: "&4Chat disabled. &cEnter the symbol you want to view the history of in chat (Example: AAPL)."
# Used to let the user know how to use the transaction history command through the broker.
stock-broker-transaction-history: "&4Chat disabled. &cEnter the player you want to view the transaction history of in chat."
# Used to let the user know how to use the buy command through the broker.
stock-broker-buy-stocks: "&4Chat disabled. &cEnter the symbol and the amount you would like to buy of the stock. (Example: AAPL 2)”
# Used to let the user know how to use the sell command through the broker.
stock-broker-sell-stocks: "&4Chat disabled. &cEnter the symbol and the amount you would like to sell of the stock. (Example: AAPL 2)"
# Used to let the user know when they provide incorrect arguments to the broker.
stock-broker-invalid-provided: "&4You provided invalid arguments to the stock broker."
Events
StockPurchaseEvent - Called when a stock is purchased.
- getPlayer() (Player) - Returns player who purchased the stock.
- getSymbol() (String) - Returns the stock symbol purchased.
- getQuantity() (Integer) - Returns the quantity purchased.
- getStockValue() (String) - Returns the stock value (current price * quantity) in a formatted string.
- getBrokerFees() (String) - Returns the broker fees applied in a formatted string.
- getGrandTotal() (String) - Returns the grand total in a formatted string.
StockSaleEvent - Called when a stock is sold
- getPlayer() (Player) - Returns player who sold the stock.
- getStockSymbol() (String) - Returns the stock symbol sold.
- getQuantity() (Integer) - Returns the quantity sold.
- getStockValue() (String) - Returns the stock value (current price * quantity) in a formatted string.
- getBrokerFees() (String) - Returns the broker fees applied in a formatted string.
- getGrandTotal() (String) - Returns the grand total in a formatted string.
- getInitialPurchase() (String) - Returns the initial purchase value in a formatted string.
- getNetOnTransaction() (String) - Returns the net on the sale in a formatted string.
API
This API is still very basic, the API will continue to grow as the plugin grows.
This API is still very basic, the API will continue to grow as the plugin grows.
- getPortfolioValue (UUID playerUUID) - Returns the specified portfolio value in a formatted string. If player is not found, returns a portfolio value of 0.00.
- getSortedPortfolioValues() - Returns Map<UUID, Double> where UUID is the player UUID, and double is their portfolio value. The map is organized in descending order from largest to smallest.
API Usage
1. Add the following to your plugin.yml
Code:
depend: [StockMarket]
Java:
StockMarketAPI stockMarketAPI = new StockMarketAPI()
String formattedPortfolioValue = stockMarketAPI.getPortfolioValue(pUUID)
Map<UUID, Double> topMap = stockMarketAPI.getSortedPortfolioValues()
Planned Features
- Optional RSS news feed broadcasts in game from financial sources (Yahoo Finance, Bloomberg)
- Support for additional stock markets outside of Yahoo Finance.
Versioning
This resource uses a very simple versioning system to let you know what changed each version, 1.0.0 is the base release, every change in the 1.x.0 indicates a significant sub release, with every change in 1.0.x indicating a minor release, usually small feature update or bug fixes. If a version in specific is marked with -b, this indicates that version in specific is a beta version of the main branch, meaning as currently the plugin is in beta, a -b release is a beta of a beta.
Reporting Bugs and making suggestions
This resource uses a very simple versioning system to let you know what changed each version, 1.0.0 is the base release, every change in the 1.x.0 indicates a significant sub release, with every change in 1.0.x indicating a minor release, usually small feature update or bug fixes. If a version in specific is marked with -b, this indicates that version in specific is a beta version of the main branch, meaning as currently the plugin is in beta, a -b release is a beta of a beta.
Reporting Bugs and making suggestions
If reporting a bug or making a suggestion, please do it via either a PM or in the discussion thread. If reporting a bug, please make sure to include your server version, plugin version, server log, in addition to the scenario which produced the bug (If for example was the lookup command, include which stock symbol produced it.)
As this plugin is in beta, please do not leave negative reviews based on bugs, feel free to contact me and I will be more than happy to help you with your issues and push updates to resolve any code-related bugs.
Terms of Service
By purchasing this plugin, you agree to the following.
- No refunds will be provided under any circumstance.
- You will not distribute this plugin to anyone or post this plugin anywhere.
- You will not decompile or modify this plugin in any form.
- You will use this plugin on a maximum of ONE server that you own (BungeeCord-ed servers count as ONE). If will be used on more than ONE server contact me, each additional licences will be available for 5 USD.
- Reviews must reflect your experience based on the plugin description, do not post a bad review because of an issue which you did not attempt to resolve with me first or because you believe this plugin needs an extra feature.
- These Terms can be changed at any time without prior notice, by using this plugin you always agree to the latest version of these terms.
Last edited:
