Advertisement
Guest User

Untitled

a guest
Jul 19th, 2016
145
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 21.51 KB | None | 0 0
  1.  
  2. View this plugin on these servers
  3. (PM me to have your server added here)
  4. HossNation - hoss.im​
  5.  
  6. Features​
  7.  
  8. 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)
  9. 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.
  10. After-hours trading, this plugin supports the latest real time rates including support for up to date after hours rates.
  11. Forex support, want to lookup the conversion rate of two currencies, do so using the Forex lookup command (Example: EURUSD).
  12. Stock Broker NPCs, allows the spawning of NPCs that provide all command functionality through an interactive user interface.
  13.  
  14. 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.
  15. 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.
  16. Stock leaderboard, allows users to quickly view the top 54 stock market players sorted in descending order by portfolio value.
  17. 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.
  18. 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.
  19.  
  20. 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.
  21. Developer API, documented below, allows for developers to hook into this plugin and retrieve data.
  22. 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.
  23. 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.
  24. Efficient, MySQL/SQLite 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.
  25.  
  26. Requirements​
  27.  
  28. Vault and Vault-compatible Economy Plugin
  29. Citizens (Optional, only needed if NPCs are enabled in the config)
  30.  
  31. Supported Stock Exchanges​
  32.  
  33. New York Stock Exchange
  34. NASDAQ
  35. Toronto Stock Exchange
  36. Mexican Stock Exchange
  37. Berlin Stock Exchange
  38. Munich Stock Exchange
  39. Germany Stock Exchange
  40. Stuttgart Stock Exchange
  41. London Stock Exchange
  42. Hong Kong Stock Exchange
  43. Euronext
  44.  
  45. and more
  46.  
  47. [​IMG]
  48.  
  49. ** <> are required arguments, {} are optional arguments. **
  50.  
  51. /stock help - stockmarket.use
  52.  
  53. /stock tutorial - stockmarket.use
  54.  
  55. /stock lookup <SYMBOL> - Lookup a stock by symbol - stockmarket.lookup
  56.  
  57. /stock flookup <FOREX SYMBOL> - Lookup a Forex symbol (Ex. EURUSD) - stockmarket.lookup.forex
  58.  
  59. /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
  60.  
  61. /stock buy <symbol> <quantity> - Buy a stock - stockmarket.use
  62.  
  63. /stock sell <symbol> <quantity> - Sell a stock - stockmarket.use
  64.  
  65. /stock compare <SYMBOL1>,<SYMBOL2>,{SYMBOL3} - Compare a minimum of two stocks with a maximum of three - stockmarket.compare
  66.  
  67. /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
  68.  
  69. /stock cportfolio {player} - View a combined portfolio, a portfolio which shows all stocks of the same type combined in one, 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
  70.  
  71. /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
  72.  
  73. /stock shistory <symbol> - View the transaction history of the specified stock - stockmarket.stockhistory
  74.  
  75. /stock leaderboard - View the top 45 players on the leaderboard, sorted by portfolio value. - stockmarket.leaderboard
  76.  
  77. /stock leaderboard profit - View the top 45 players on the leaderboard, sorted by profit margin. - stockmarket.leaderboard
  78.  
  79. Aliases for non-administrator commands: /stocks, /sm, /stockmarket
  80.  
  81.  
  82. /sma reload - Reload the configuration file - stockmarket.admin
  83.  
  84. /sma tables - Wipes all plugin tables in the MySQL database - stockmarket.admin
  85.  
  86. /sma broker - Spawn a Broker NPC, if enabled in the config file - stockmarket.admin
  87.  
  88. /sma broker simple - Spawn a simple Broker NPC, if brokers are enabled in the config file. - stockmarket.admin
  89.  
  90. /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
  91.  
  92. stockmarket.nocommandbypass - Bypass for users if commands are disabled.
  93.  
  94.  
  95. [​IMG]
  96.  
  97. Code (Text):
  98. database:
  99. # Whether MySQL is enabled, setting this to false makes use of SQLite
  100. # which requires no setup.
  101. mysql-enabled: true
  102. # MySQL server IP Address
  103. ip: "localhost"
  104. # MySQL server port
  105. port: 3306
  106. # MySQL database
  107. database: "stockmarket"
  108. # MySQL username
  109. username: "root"
  110. # MySQL password
  111. password: "password"
  112. options:
  113. # Whether NPCs are enabled or not, if set to true Citizens is required.
  114. npc-enabled: true
  115. # Whether commands are enabled or disabled, useful if you want players to use broker NPCs only.
  116. commands-disabled: true
  117. # Account broker fees are paid to, should be one word. Set to "" to disable.
  118. fees-account: ""
  119. # Account stock purchases are paid to, should be one word. Set to "" to disable.
  120. stock-account: ""
  121. # Account stock sales are paid from, should be one word. Set to "" to disable.
  122. stock-purchasing-account: ""
  123. # Price multiplier, set to 0 to disable.
  124. # Used if stock prices need to be inflated for your server economy (ex. 60
  125. # dollar stock would become 600 with a 10 multiplier)
  126. multiplier: 10
  127. # Prevents users from buying stocks that don’t have a USD price
  128. prevent-non-usd-sale: false
  129. # Convert non-USD stocks to USD (ex. CAD, EUR, GBP would be
  130. # converted to USD)
  131. convert-non-usd-to-usd: true
  132. # Prevents users from buying or selling stocks at a zero value (usually
  133. # caused by some sort of error on YahooFinance’s end). This is STRONGLY
  134. # recommended to remain at true, invalid stocks may also return a zero
  135. # value.
  136. prevent-sale-of-zero-value: true
  137. # Prevents people from buying and selling within the specified number of
  138. # seconds, this is to prevent user’s abusing the data delay by knowing
  139. # what will happen to the price of a stock in critical scenarios
  140. # (ex. a company’s profit earning announcements)
  141. abuse-prevention: true
  142. # The number of seconds abuse prevention should be enforced for
  143. abuse-prevention-time: 3600
  144. # Whether to enforce a minimum stock purchase price
  145. penny-stock-check: true
  146. # If penny-stock-check is true, penny-stock-minimum is the minimum
  147. # price of a stock to allow it to be purchased.
  148. penny-stock-minimum: 5
  149. # If set to false, users will only be charged broker fees on stock purchases.
  150. charge-broker-on-sale: true
  151. # A flat rate added on to all transactions to simulate real broker fees. Set to
  152. # 0 to disable.
  153. broker-fee-flat: 10
  154. # A percentage added on to stock value (base price * (purchasing/selling
  155. # quantity) to simulate real broker fees. Set to 0 to disable.
  156. broker-fee-percent: 0
  157. # If true, players will not be able to buy or sell when the corresponding
  158. # market in real life is closed.
  159. disable-trading-when-closed: false
  160. # If true, the simple broker inventory will close on purchase/sale
  161. close-inventory-on-simple: false
  162. messages:
  163. # Server currency suffix
  164. server-currency: "Dollars"
  165. # Used in certain scenarios, tell users to inform you if this message pops up
  166. # as an error corresponds in the server log.
  167. error-occured: "&4An error occurred, Yahoo Finance may be down."
  168. # Success on admin purge command
  169. purged-tables: "&4Purged MySQL tables"
  170. # Used in case an error occurs with conversion, this will most likely and
  171. # should never happen.
  172. purchase-currency-not-supported: "&4The stock you are trying to buy has an unsupported original currency."
  173. # Used when user tries to purchase a stock that is not of USD currency if it
  174. # is toggled on under options
  175. no-purchase-non-USD: "&4You can not purchase stocks which are not of USD currency."
  176. # Used when user attempts to sell more of a stock than they own
  177. no-stock-to-sell: "&4You can not sell <symbol> as you do not own enough of the stock."
  178. # Used when a user tries to sell a stock they bought within 24 hours, used if
  179. # abuse prevention is true
  180. day-not-passed: "&4You can not sell &c<symbol> &4for another &c<hours> &4hours."
  181. # Used when a user tries to purchase/sell a stock with a zero value, used if
  182. # prevent zero value is true
  183. invalid-price: "&4<symbol> &ccurrently has an invalid price and can not be bought/sold."
  184. # Used when user tries to purchase more of a stock than the user can
  185. # afford.
  186. not-enough-money: "&4You can not afford <quantity> of <symbol> with a grand total of <total>."
  187. # Used when a user purchases a stock, displays purchase summary
  188. bought-stock:
  189. - "&4Purchase Summary (<date>):"
  190. - "&4You purchased &c<quantity> &4of &c<company> (<symbol>)"
  191. - "&4Stock Value: &c<stock-value>"
  192. - "&4Broker Fees: &c<broker-fees>"
  193. - "&4Grand Total: &c<total>"
  194. # Used when a user sells a stock, this portion is the header.
  195. sold-stock:
  196. - "&4Sale Summary:"
  197. - "&4You sold &c<quantity> &4of &c<company> (<symbol>)"
  198. # Used when a user sells a stock, this portion is the portion that will repeat
  199. # depending on how many individual transactions of a stock are sold from.
  200. stock-sold-report:
  201. - "&4Stock ID: &c<stock-id> &4- Quantity: &c<quantity-of-stock>"
  202. - " &4Stock Value: &c<stock-value> &4- Broker Fees: &c<broker-fees> &4- Total: &c<total>"
  203. - " &4Purchased for: &c<purchase> &4- Net Gain/Loss: &c<net>"
  204. # Footer of stock sale summary
  205. stock-sold-footer: "&4Total Net: &c<total-net>"
  206. # Used when a user specifies an invalid forex quote
  207. invalid-forex-quote: "&4You specified an invalid Forex quote (Proper example: USDEUR)."
  208. # Used when a user specifies an invalid quantity
  209. invalid-quantity: "&4You specified an invalid quantity."
  210. # Used when the user uses the compare command incorrectly.
  211. improper-compare-syntax: "&cIncorrect syntax"
  212. # Used when the user tries to use the compare command to compare only
  213. # one stock.
  214. compare-minimum-two: "&cYou need to compare at least two stocks."
  215. # Used when the user tries to compare more than three stocks
  216. compare-maximum-three: "&cYou can only compare three stocks at a time with the compare command."
  217. # Used when the user specifies an invalid stock symbol.
  218. invalid-stock: "&cThat stock could not be found."
  219. # Used when the user uses a command incorrectly.
  220. invalid-syntax: "&cYou did not use the proper command syntax."
  221. # Used when the config is reloaded successfully.
  222. config-reloaded: "&cSuccessfully reloaded configuration file."
  223. # Used when the user attempts to use a command that he does not have
  224. # permission for.
  225. no-permission: "&cYou do not have permission to use that command."
  226. # Used when the console is uses to execute a player only command.
  227. you-need-to-be-a-player: "Stock Market - You need to be a player to use that command."
  228. # Used when the portfolio is attempted to be opened for a player who has
  229. # no portfolio stocks.
  230. no-stocks-to-list: "&cThe specified player owns no stocks, portfolio not generated."
  231. # Used when the history is attempted to be opened for a player who has
  232. # no transaction history.
  233. no-transactions-to-list: "&cThe specified player has no transactions, history not generated."
  234. # Used when there are no players to list for the leaderboard.
  235. no-stock-players: "&4There are no stock players, leaderboard not generated."
  236. # Used when there are no transactions for a specified stock
  237. no-stock-transactions-to-list: "&cThe specified stock has no transactions, history not generated."
  238. # Used to broadcast when a player purchases a stock, set to "" to disable
  239. 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."
  240. # Used to broadcast when a player sells a stock, set to "" to disable
  241. 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)."
  242. # Used when no historical data is found, usually for companies less than a
  243. # year old.
  244. no-historical-data: "&cNo historical data found, this is most likely caused by the company not have existing for the past year."
  245. # Used when the player uses the help command.
  246. help:
  247. - "&cWe run a virtual stock market, for a list of stocks you can buy, visit YahooFinance."
  248. - "&cStocks are a great way to earn money by investing in virtual stocks in companies you think will be sucessful on the stock market."
  249. - "&cOur virtual broker will charge you <percent>% in addition to a flat rate of <flat-rate> on each transaction."
  250. # Used when a stock broker is spawned
  251. stock-broker-spawned: "&4Spawned stock broker."
  252. # Used to let the user know what to do when they execute the remove command.
  253. stock-broker-removal: "&4Hit the stock broker you would like to remove."
  254. # Used when a stock broker is removed.
  255. stock-broker-removed: "&4Stock broker removed."
  256. # Used when a player has removal mode on and does not hit a Stock Broker NPC.
  257. stock-broker-no-npc: "&4You did not hit a stock broker, removal mode disabled."
  258. # Used when attempts are made to spawn or kill stock brokers when npcs are disabled in the config.
  259. stock-brokers-disabled: "&4Stock Brokers are disabled in the config, command failed."
  260. # Used when a player attempts to use a stock market command while commands are disabled.
  261. stock-commands-disabled: "&4Stock Market commands are disabled, make use of our Stock Brokers!"
  262. # Used to let the user know how to lookup symbols through the broker.
  263. stock-broker-stock-symbol-lookup: "&4Chat disabled. &cEnter the stock symbol you want to lookup in chat (Example: AAPL)."
  264. # Used to let the user know how to lookup forex stocks through the broker.
  265. stock-broker-forex-symbol-lookup: "&4Chat disabled. &cEnter the forex symbol you want to lookup in chat (Example: EURUSD)."
  266. # Used to let the user know how to use the compare command through the broker.
  267. stock-broker-compare: "&4Chat disabled. &cEnter the symbols you want to compare in chat (Example: AAPL,GOOG,TSCO.L)."
  268. # Used to let the user know how to use the portfolio command through the broker.
  269. stock-broker-portfolio: "&4Chat disabled. &cEnter the player you want to view the portfolio of in chat."
  270. # Used to let the user know how to use the stock history command through the broker.
  271. stock-broker-stock-history: "&4Chat disabled. &cEnter the symbol you want to view the history of in chat (Example: AAPL)."
  272. # Used to let the user know how to use the transaction history command through the broker.
  273. stock-broker-transaction-history: "&4Chat disabled. &cEnter the player you want to view the transaction history of in chat."
  274. # Used to let the user know how to use the buy command through the broker.
  275. stock-broker-buy-stocks: "&4Chat disabled. &cEnter the symbol and the amount you would like to buy of the stock. (Example: AAPL 2)"
  276. # Used to let the user know how to use the sell command through the broker.
  277. stock-broker-sell-stocks: "&4Chat disabled. &cEnter the symbol and the amount you would like to sell of the stock. (Example: AAPL 2)"
  278. # Used to let the user know when they provide incorrect arguments to the broker.
  279. stock-broker-invalid-provided: "&4You provided invalid arguments to the stock broker."
  280. # Used to let the user know when the stock market corresponding to the symbol they selected is closed.
  281. no-trading-when-market-is-closed: "&4The stock market corresponding to the symbol you selected is closed, therefore you can not make any transactions with that symbol."
  282. # Used when a user attempts to purchase a stock with a price that is below
  283. # penny-stock-minimum when penny-stock-check is true.
  284. penny-stock-minimum-not-met: "&4You can not buy that stock as it's price is too low."
  285. Events​
  286.  
  287. StockPurchaseEvent - Called when a stock is purchased.
  288.  
  289. getPlayer() (Player) - Returns player who purchased the stock.
  290. getSymbol() (String) - Returns the stock symbol purchased.
  291. getQuantity() (Integer) - Returns the quantity purchased.
  292. getStockValue() (String) - Returns the stock value (current price * quantity) in a formatted string.
  293. getBrokerFees() (String) - Returns the broker fees applied in a formatted string.
  294. getGrandTotal() (String) - Returns the grand total in a formatted string.
  295.  
  296.  
  297. StockSaleEvent - Called when a stock is sold
  298.  
  299. getPlayer() (Player) - Returns player who sold the stock.
  300. getStockSymbol() (String) - Returns the stock symbol sold.
  301. getQuantity() (Integer) - Returns the quantity sold.
  302. getStockValue() (String) - Returns the stock value (current price * quantity) in a formatted string.
  303. getBrokerFees() (String) - Returns the broker fees applied in a formatted string.
  304. getGrandTotal() (String) - Returns the grand total in a formatted string.
  305. getInitialPurchase() (String) - Returns the initial purchase value in a formatted string.
  306. getNetOnTransaction() (String) - Returns the net on the sale in a formatted string.
  307.  
  308. API
  309. This API is still very basic, the API will continue to grow as the plugin grows.​
  310.  
  311. getPortfolioValue (UUID playerUUID) - Returns the specified player's portfolio value in a formatted string. If player is not found, returns a portfolio value of 0.00.
  312. getProfitMargin (UUID playerUUID) - Returns the specified player's profit margin in a formatted string. If player is not found, returns a profit margin of 0.00.
  313. 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.
  314.  
  315. API Usage​
  316.  
  317. 1. Add the following to your plugin.yml
  318. Code (Text):
  319. depend: [StockMarket]
  320. 2. Use StockMarket API
  321. Code (Java):
  322. StockMarketAPI stockMarketAPI = new StockMarketAPI();
  323. String formattedPortfolioValue = stockMarketAPI.getPortfolioValue(pUUID);
  324. String formattedProfitMargin = stockMarketAPI.getProfitMargin(pUUID);
  325. Map<UUID, Double> topMap = stockMarketAPI.getSortedPortfolioValues();
  326.  
  327. [​IMG]
  328.  
  329. Reporting Bugs and making suggestions​
  330.  
  331. 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.)
  332.  
  333. 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 bugs.
  334.  
  335. Terms of Service​
  336.  
  337. By purchasing/using this plugin, you agree to the following.
  338.  
  339. No refunds will be provided under any circumstance.
  340. You will not distribute this plugin to anyone or post this plugin anywhere.
  341. You will not decompile or modify this plugin in any form.
  342. 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.
  343. 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.
  344. 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.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement