예제 #1
0
 public ArrayList<String> getEconomyList() {
   ArrayList<String> econs = new ArrayList<String>();
   for (Map.Entry<String, HyperEconomy> entry : economies.entrySet()) {
     HyperEconomy he = entry.getValue();
     econs.add(he.getEconomy());
   }
   return econs;
 }
예제 #2
0
 public boolean economyExists(String economy) {
   for (Map.Entry<String, HyperEconomy> entry : economies.entrySet()) {
     HyperEconomy he = entry.getValue();
     if (he.getEconomy().equalsIgnoreCase(economy)) {
       return true;
     }
   }
   return false;
 }
예제 #3
0
 public HyperEconomy getEconomy(String name) {
   for (Map.Entry<String, HyperEconomy> entry : economies.entrySet()) {
     HyperEconomy he = entry.getValue();
     if (he.getEconomy().equalsIgnoreCase(name)) {
       return he;
     }
   }
   return null;
 }
예제 #4
0
 public ArrayList<HyperObject> getHyperObjects() {
   ArrayList<HyperObject> hyperObjects = new ArrayList<HyperObject>();
   for (Map.Entry<String, HyperEconomy> entry : economies.entrySet()) {
     HyperEconomy he = entry.getValue();
     for (HyperObject ho : he.getHyperObjects()) {
       hyperObjects.add(ho);
     }
   }
   return hyperObjects;
 }
예제 #5
0
 public Item makeDisplay() {
   HyperEconomy he = hc.getEconomyManager().getEconomy("default");
   Location l = new Location(w, x, y + 1, z);
   ItemStack dropstack = he.getHyperItem(name).getItemStack();
   dropstack.setDurability((short) he.getHyperItem(name).getDurability());
   this.item = w.dropItem(l, dropstack);
   this.entityId = item.getEntityId();
   item.setVelocity(new Vector(0, 0, 0));
   item.setMetadata("HyperConomy", new FixedMetadataValue(hc, "item_display"));
   return item;
 }
예제 #6
0
 ItemDisplay(Location location, String name) {
   this.hc = HyperConomy.hc;
   this.location = location;
   HyperEconomy he = hc.getEconomyManager().getEconomy("default");
   this.x = this.location.getX();
   this.y = this.location.getY();
   this.z = this.location.getZ();
   this.w = this.location.getWorld();
   this.name = he.fixName(name);
   storeDisplay();
   setProtectedBlocks();
 }
예제 #7
0
 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();
   }
 }
예제 #8
0
 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();
 }
예제 #9
0
 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"));
   }
 }
예제 #10
0
 public void clearData() {
   for (HyperEconomy he : economies.values()) {
     he.clearData();
   }
   economies.clear();
 }