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 updateAfterLoad() { boolean restart = false; for (Double d : updateAfterLoad) { if (d.doubleValue() == 1.23) { hc.getLogger().info("[HyperConomy]Updating object names for version 1.23."); for (HyperEconomy he : getEconomies()) { he.updateNamesFromYml(); } restart = true; } else if (d.doubleValue() == 1.24) { hc.getLogger().info("[HyperConomy]Updating for version 1.24."); } } if (restart) { hc.restart(); } }
public void createNewEconomy(String economy) { HyperEconomy defaultEconomy = getEconomy("default"); SQLWrite sw = hc.getSQLWrite(); for (HyperObject ho : defaultEconomy.getHyperObjects()) { HashMap<String, String> values = new HashMap<String, String>(); values.put("NAME", ho.getName()); values.put("DISPLAY_NAME", ho.getDisplayName()); values.put("ALIASES", ho.getAliasesString()); values.put("ECONOMY", economy); values.put("TYPE", ho.getType().toString()); values.put("VALUE", ho.getValue() + ""); values.put("STATIC", ho.getIsstatic()); values.put("STATICPRICE", ho.getStaticprice() + ""); values.put("STOCK", 0 + ""); values.put("MEDIAN", ho.getMedian() + ""); values.put("INITIATION", ho.getInitiation()); values.put("STARTPRICE", ho.getStartprice() + ""); values.put("CEILING", ho.getCeiling() + ""); values.put("FLOOR", ho.getFloor() + ""); values.put("MAXSTOCK", ho.getMaxstock() + ""); if (ho instanceof HyperItem) { HyperItem hi = (HyperItem) ho; values.put("MATERIAL", hi.getMaterial()); values.put("DATA", hi.getData() + ""); values.put("DURABILITY", hi.getDurability() + ""); } else if (ho instanceof HyperEnchant) { HyperEnchant he = (HyperEnchant) ho; values.put("MATERIAL", he.getEnchantmentName()); values.put("DATA", "-1"); values.put("DURABILITY", "-1"); } else { values.put("MATERIAL", "none"); values.put("DATA", "-1"); values.put("DURABILITY", "-1"); } sw.performInsert("hyperconomy_objects", values); } hc.restart(); }
public void deleteEconomy(String economy) { hc.getSQLWrite().addToQueue("DELETE FROM hyperconomy_objects WHERE ECONOMY='" + economy + "'"); hc.restart(); }