public void createGlobalShopAccount() { HyperConomy hc = HyperConomy.hc; Log l = hc.getLog(); String globalaccount = hc.gYH().gFC("config").getString("config.global-shop-account"); if (hc.useExternalEconomy()) { if (!hc.getEconomy().hasAccount(globalaccount)) { getHyperPlayer(globalaccount) .setBalance(hc.gYH().gFC("config").getDouble("config.initialshopbalance")); l.writeAuditLog( globalaccount, "setbalance", hc.gYH().gFC("config").getDouble("config.initialshopbalance"), hc.getEconomy().getName()); } } else { if (!hasAccount(globalaccount)) { createPlayerAccount(globalaccount); getHyperPlayer(globalaccount) .setBalance(hc.gYH().gFC("config").getDouble("config.initialshopbalance")); l.writeAuditLog( globalaccount, "setbalance", hc.gYH().gFC("config").getDouble("config.initialshopbalance"), "HyperConomy"); } } }
private void loadShops() { stopShopCheck(); shops.clear(); FileConfiguration sh = hc.gYH().gFC("shops"); if (!useShops) { Shop shop = new ServerShop("GlobalShop", getGlobalShopAccount().getEconomy(), getGlobalShopAccount()); shop.setGlobal(); shops.put("GlobalShop", shop); return; } Iterator<String> it = sh.getKeys(false).iterator(); while (it.hasNext()) { Object element = it.next(); String name = element.toString(); if (name.equalsIgnoreCase("GlobalShop")) { continue; } String owner = sh.getString(name + ".owner"); String economy = sh.getString(name + ".economy"); if (owner == null) { owner = getGlobalShopAccount().getName(); } if (owner.equalsIgnoreCase(getGlobalShopAccount().getName())) { Shop shop = new ServerShop(name, economy, getHyperPlayer(owner)); shop.setPoint1( sh.getString(name + ".world"), sh.getInt(name + ".p1.x"), sh.getInt(name + ".p1.y"), sh.getInt(name + ".p1.z")); shop.setPoint2( sh.getString(name + ".world"), sh.getInt(name + ".p2.x"), sh.getInt(name + ".p2.y"), sh.getInt(name + ".p2.z")); shop.setMessage1(sh.getString(name + ".shopmessage1")); shop.setMessage2(sh.getString(name + ".shopmessage2")); shops.put(name, shop); } else { if (hc.gYH().gFC("config").getBoolean("config.use-player-shops")) { Shop shop = new PlayerShop(name, economy, getHyperPlayer(owner)); shop.setPoint1( sh.getString(name + ".world"), sh.getInt(name + ".p1.x"), sh.getInt(name + ".p1.y"), sh.getInt(name + ".p1.z")); shop.setPoint2( sh.getString(name + ".world"), sh.getInt(name + ".p2.x"), sh.getInt(name + ".p2.y"), sh.getInt(name + ".p2.z")); shop.setMessage1(sh.getString(name + ".shopmessage1")); shop.setMessage2(sh.getString(name + ".shopmessage2")); shops.put(name, shop); } } } startShopCheck(); }
public EconomyManager() { hc = HyperConomy.hc; dataLoaded = false; loadActive = false; economiesLoaded = false; useShops = hc.gYH().gFC("config").getBoolean("config.use-shops"); shopinterval = hc.gYH().gFC("config").getLong("config.shopcheckinterval"); hc.getServer().getPluginManager().registerEvents(this, hc); }
public void createEconomyFromYml(String econ, boolean restart) { if (hc.gYH().gFC("config").getBoolean("config.run-automatic-backups")) { new Backup(); } FileConfiguration objects = hc.gYH().gFC("objects"); SQLWrite sw = hc.getSQLWrite(); Iterator<String> it = objects.getKeys(false).iterator(); while (it.hasNext()) { String itemname = it.next().toString(); String category = objects.getString(itemname + ".information.category"); if (category == null) { category = "unknown"; } HashMap<String, String> values = new HashMap<String, String>(); values.put("NAME", itemname); values.put("ECONOMY", econ); values.put("DISPLAY_NAME", objects.getString(itemname + ".name.display")); values.put("ALIASES", objects.getString(itemname + ".name.aliases")); values.put("TYPE", objects.getString(itemname + ".information.type")); values.put("VALUE", objects.getDouble(itemname + ".value") + ""); values.put("STATIC", objects.getString(itemname + ".price.static")); values.put("STATICPRICE", objects.getDouble(itemname + ".price.staticprice") + ""); values.put("STOCK", objects.getDouble(itemname + ".stock.stock") + ""); values.put("MEDIAN", objects.getDouble(itemname + ".stock.median") + ""); values.put("INITIATION", objects.getString(itemname + ".initiation.initiation")); values.put("STARTPRICE", objects.getDouble(itemname + ".initiation.startprice") + ""); values.put("CEILING", objects.getDouble(itemname + ".price.ceiling") + ""); values.put("FLOOR", objects.getDouble(itemname + ".price.floor") + ""); values.put("MAXSTOCK", objects.getDouble(itemname + ".stock.maxstock") + ""); if (objects.getString(itemname + ".information.type").equalsIgnoreCase("item")) { values.put("MATERIAL", objects.getString(itemname + ".information.material")); values.put("DATA", objects.getInt(itemname + ".information.data") + ""); values.put("DURABILITY", objects.getInt(itemname + ".information.data") + ""); } else if (objects .getString(itemname + ".information.type") .equalsIgnoreCase("enchantment")) { values.put("MATERIAL", objects.getString(itemname + ".information.material")); values.put("DATA", "-1"); values.put("DURABILITY", "-1"); } else if (objects.getString(itemname + ".information.type").equalsIgnoreCase("experience")) { values.put("MATERIAL", "none"); values.put("DATA", "-1"); values.put("DURABILITY", "-1"); } sw.performInsert("hyperconomy_objects", values); } if (restart) { hc.restart(); } }
private void addOnlinePlayers() { for (Player p : Bukkit.getOnlinePlayers()) { if (p.getName() .equalsIgnoreCase(hc.gYH().gFC("config").getString("config.global-shop-account"))) { if (hc.gYH() .gFC("config") .getBoolean("config.block-player-with-same-name-as-global-shop-account")) { p.kickPlayer(hc.getLanguageFile().get("CANT_USE_ACCOUNT")); } } if (!hasAccount(p.getName())) { addPlayer(p.getName()); } } }
public void storeDisplay() { Iterator<String> it = hc.gYH().gFC("displays").getKeys(false).iterator(); int numdisplays = 0; while (it.hasNext()) { String key = it.next().toString(); int number = Integer.parseInt(key.substring(1, key.length())); if (number > numdisplays) { numdisplays = number; } } numdisplays++; FileConfiguration disp = hc.gYH().gFC("displays"); key = "d" + numdisplays; disp.set(key + ".name", name); disp.set(key + ".x", x); disp.set(key + ".y", y); disp.set(key + ".z", z); disp.set(key + ".world", w.getName()); }
@EventHandler(priority = EventPriority.NORMAL) public void onPlayerJoin(PlayerJoinEvent event) { try { if (!economiesLoaded()) { return; } String name = event.getPlayer().getName(); if (name.equalsIgnoreCase(hc.gYH().gFC("config").getString("config.global-shop-account"))) { if (hc.gYH() .gFC("config") .getBoolean("config.block-player-with-same-name-as-global-shop-account")) { event.getPlayer().kickPlayer(hc.getLanguageFile().get("CANT_USE_ACCOUNT")); } } if (!hasAccount(name)) { addPlayer(name); } } catch (Exception e) { hc.gDB().writeError(e); } }
public void deleteDisplay() { FileConfiguration disp = hc.gYH().gFC("displays"); disp.set(key, null); clearDisplay(); }
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")); } }
public HyperPlayer getGlobalShopAccount() { return getHyperPlayer(hc.gYH().gFC("config").getString("config.global-shop-account")); }