Audit(String args[], CommandSender csender) { sender = csender; hc = HyperConomy.hc; L = hc.getLanguageFile(); em = hc.getEconomyManager(); try { account = args[0]; if (!em.hasAccount(account)) { sender.sendMessage(L.get("ACCOUNT_NOT_FOUND")); return; } hc.getServer() .getScheduler() .runTaskAsynchronously( hc, new Runnable() { public void run() { HyperPlayer hp = em.getHyperPlayer(account); account = hp.getName(); cbalance = hp.getBalance(); logbalance = getHyperLogTotal(account, "sale") - getHyperLogTotal(account, "purchase"); auditbalance = getAuditLogTotal(account); hc.getServer() .getScheduler() .runTask( hc, new Runnable() { public void run() { CommonFunctions cf = hc.gCF(); sender.sendMessage(L.get("LINE_BREAK")); sender.sendMessage(L.f(L.get("AUDIT_TRUE"), cbalance)); sender.sendMessage( L.f(L.get("AUDIT_THEORETICAL1"), cf.twoDecimals(logbalance))); sender.sendMessage( L.f(L.get("AUDIT_THEORETICAL2"), cf.twoDecimals(auditbalance))); // sender.sendMessage("True balance: " + cbalance); // sender.sendMessage("Theoretical balance condsidering only // sales/purchases: " + calc.twoDecimals(logbalance)); // sender.sendMessage("Theoretical balance condsidering all logged // balance changes: " + calc.twoDecimals(auditbalance)); sender.sendMessage(L.get("LINE_BREAK")); } }); } }); } catch (Exception e) { sender.sendMessage(L.get("AUDIT_INVALID")); } }
Esell(Player player, String[] args) { HyperConomy hc = HyperConomy.hc; LanguageFile L = hc.getLanguageFile(); ShopFactory s = hc.getShopFactory(); DataHandler dh = hc.getDataFunctions(); InventoryManipulation im = hc.getInventoryManipulation(); try { if (player.getGameMode() == GameMode.CREATIVE && hc.s().gB("block-selling-in-creative-mode")) { player.sendMessage(L.get("CANT_SELL_CREATIVE")); return; } if (s.inAnyShop(player)) { HyperPlayer hp = dh.getHyperPlayer(player); if (hp.hasSellPermission(s.getShop(player))) { String name = args[0]; if (args[0].equalsIgnoreCase("max")) { if (!im.hasenchants(player.getItemInHand())) { player.sendMessage(L.get("HAS_NO_ENCHANTMENTS")); } ArrayList<String> enchants = im.getEnchantments(player.getItemInHand()); for (String e : enchants) { if (s.getShop(player).has(e)) { PlayerTransaction pt = new PlayerTransaction(TransactionType.SELL); pt.setHyperObject(dh.getHyperObject(e, hp.getEconomy())); TransactionResponse response = hp.processTransaction(pt); response.sendMessages(); } else { player.sendMessage(L.get("CANT_BE_TRADED")); } } } else { if (hc.getDataFunctions().enchantTest(name)) { if (s.getShop(player).has(name)) { PlayerTransaction pt = new PlayerTransaction(TransactionType.SELL); pt.setHyperObject(dh.getHyperObject(name, hp.getEconomy())); TransactionResponse response = hp.processTransaction(pt); response.sendMessages(); } else { player.sendMessage(L.get("CANT_BE_TRADED")); } } else { player.sendMessage(L.get("ENCHANTMENT_NOT_IN_DATABASE")); } } } else { player.sendMessage(L.get("NO_TRADE_PERMISSION")); } } else { player.sendMessage(L.get("MUST_BE_IN_SHOP")); } } catch (Exception e) { player.sendMessage(L.get("ESELL_INVALID")); } }
Importprices(String args[], CommandSender sender) { HyperConomy hc = HyperConomy.hc; LanguageFile L = hc.getLanguageFile(); DataHandler sf = hc.getDataFunctions(); try { if (args.length == 1) { String economy = args[0]; if (sf.testEconomy(economy)) { new Backup(); FileConfiguration itemsyaml = hc.getYaml().getItems(); Iterator<String> it = itemsyaml.getKeys(false).iterator(); while (it.hasNext()) { String name = it.next().toString(); double value = itemsyaml.getDouble(name + ".value"); double staticprice = itemsyaml.getDouble(name + ".price.staticprice"); double startprice = itemsyaml.getDouble(name + ".initiation.startprice"); HyperObject ho = sf.getHyperObject(name, economy); ho.setValue(value); ho.setStartprice(startprice); ho.setStaticprice(staticprice); } FileConfiguration enchantsyaml = hc.getYaml().getEnchants(); Iterator<String> it2 = enchantsyaml.getKeys(false).iterator(); while (it2.hasNext()) { String name = it2.next().toString(); double value = enchantsyaml.getDouble(name + ".value"); double staticprice = enchantsyaml.getDouble(name + ".price.staticprice"); double startprice = enchantsyaml.getDouble(name + ".initiation.startprice"); HyperObject ho = sf.getHyperObject(name, economy); ho.setValue(value); ho.setStartprice(startprice); ho.setStaticprice(staticprice); } sender.sendMessage(L.get("PRICES_IMPORTED")); } else { sender.sendMessage(L.get("ECONOMY_NOT_EXIST")); return; } } else { sender.sendMessage(L.get("IMPORTPRICES_INVALID")); } } catch (Exception e) { sender.sendMessage(L.get("IMPORTPRICES_INVALID")); } }
Seteconomy(_Command command, String args[], CommandSender sender, Player player) { HyperConomy hc = HyperConomy.hc; EconomyManager em = hc.getEconomyManager(); LanguageFile L = hc.getLanguageFile(); try { if (args.length == 1) { String economy = args[0]; if (em.economyExists(economy)) { if (player != null) { em.getHyperPlayer(player.getName()).setEconomy(economy); sender.sendMessage(L.get("ECONOMY_SET")); } else { command.setNonPlayerEconomy(economy); hc.getConsoleSettings().setConsoleEconomy(economy); sender.sendMessage(L.get("ECONOMY_SET")); } } else { sender.sendMessage(L.get("ECONOMY_NOT_EXIST")); } } else { sender.sendMessage(L.get("SETECONOMY_INVALID")); } } catch (Exception e) { sender.sendMessage(L.get("SETECONOMY_INVALID")); } }
Topenchants(String args[], Player player, CommandSender sender, String playerecon) { HyperConomy hc = HyperConomy.hc; HyperEconomy he = hc.getEconomyManager().getEconomy(playerecon); EconomyManager em = hc.getEconomyManager(); LanguageFile L = hc.getLanguageFile(); try { boolean requireShop = hc.gYH().gFC("config").getBoolean("config.limit-info-commands-to-shops"); if (args.length > 1) { sender.sendMessage(L.get("TOPENCHANTS_INVALID")); return; } String nameshop = ""; if (player != null) { if (em.inAnyShop(player)) { nameshop = em.getShop(player).getName(); } if (requireShop && em.getShop(player) == null && !player.hasPermission("hyperconomy.admin")) { sender.sendMessage(L.get("REQUIRE_SHOP_FOR_INFO")); return; } } int page; if (args.length == 0) { page = 1; } else { page = Integer.parseInt(args[0]); } SortedMap<Double, String> enchantstocks = new TreeMap<Double, String>(); for (HyperObject ho : he.getHyperObjects()) { if (!(ho instanceof HyperEnchant)) { continue; } PlayerShopObject pso = null; boolean allowed = false; boolean stocked = false; boolean banned = false; if (nameshop != "") { banned = em.getShop(nameshop).isBanned(ho); } if (ho.getStock() > 0) { stocked = true; } if (ho instanceof PlayerShopObject) { pso = (PlayerShopObject) ho; allowed = pso.getShop().isAllowed(em.getHyperPlayer(player)); if (pso.getStatus() == HyperObjectStatus.NONE && !allowed) { continue; } } boolean unavailable = false; if (nameshop != "") { if (banned && !(allowed && stocked)) { unavailable = true; } } if (!unavailable) { double samount = he.getHyperObject(ho.getName(), em.getShop(player)).getStock(); if (samount > 0) { while (enchantstocks.containsKey(samount * 100)) { samount = samount + .0000001; } enchantstocks.put(samount * 100, ho.getDisplayName()); } } } int numberpage = page * 10; int count = 0; int le = enchantstocks.size(); double maxpages = le / 10; maxpages = Math.ceil(maxpages); int maxpi = (int) maxpages + 1; sender.sendMessage(L.f(L.get("PAGE_NUMBER"), page, maxpi)); try { while (count < numberpage) { double lk = enchantstocks.lastKey(); if (count > ((page * 10) - 11)) { sender.sendMessage( ChatColor.WHITE + enchantstocks.get(lk) + ChatColor.WHITE + ": " + ChatColor.AQUA + "" + Math.floor(lk) / 100); } enchantstocks.remove(lk); count++; } } catch (Exception e) { sender.sendMessage(L.get("YOU_HAVE_REACHED_THE_END")); } } catch (Exception e) { sender.sendMessage(L.get("TOPENCHANTS_INVALID")); } }