예제 #1
0
  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"));
    }
  }
예제 #2
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;
 }
예제 #3
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();
 }
예제 #4
0
  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"));
    }
  }
예제 #5
0
 public void createTables(SQLWrite sw) {
   sw.convertExecuteSynchronously(
       "CREATE TABLE IF NOT EXISTS hyperconomy_settings (SETTING VARCHAR(255) NOT NULL, VALUE TEXT, TIME DATETIME NOT NULL, PRIMARY KEY (SETTING))");
   sw.convertExecuteSynchronously("DELETE FROM hyperconomy_settings");
   sw.convertExecuteSynchronously(
       "INSERT INTO hyperconomy_settings (SETTING, VALUE, TIME) VALUES ('version', '"
           + hc.getEconomyManager().getVersion()
           + "', NOW() )");
   sw.convertExecuteSynchronously(
       "CREATE TABLE IF NOT EXISTS hyperconomy_objects (NAME VARCHAR(255) NOT NULL, ECONOMY VARCHAR(255) NOT NULL, DISPLAY_NAME VARCHAR(255), ALIASES VARCHAR(1000), TYPE TINYTEXT, MATERIAL TINYTEXT, DATA INTEGER, DURABILITY INTEGER, VALUE DOUBLE, STATIC TINYTEXT, STATICPRICE DOUBLE, STOCK DOUBLE, MEDIAN DOUBLE, INITIATION TINYTEXT, STARTPRICE DOUBLE, CEILING DOUBLE, FLOOR DOUBLE, MAXSTOCK DOUBLE NOT NULL DEFAULT '1000000', PRIMARY KEY (NAME, ECONOMY))");
   sw.convertExecuteSynchronously(
       "CREATE TABLE IF NOT EXISTS hyperconomy_players (PLAYER VARCHAR(255) NOT NULL PRIMARY KEY, ECONOMY TINYTEXT, BALANCE DOUBLE NOT NULL DEFAULT '0', X DOUBLE NOT NULL DEFAULT '0', Y DOUBLE NOT NULL DEFAULT '0', Z DOUBLE NOT NULL DEFAULT '0', WORLD TINYTEXT NOT NULL, HASH VARCHAR(255) NOT NULL DEFAULT '', SALT VARCHAR(255) NOT NULL DEFAULT '')");
   sw.convertExecuteSynchronously(
       "CREATE TABLE IF NOT EXISTS hyperconomy_log (ID INTEGER NOT NULL PRIMARY KEY AUTO_INCREMENT, TIME DATETIME, CUSTOMER TINYTEXT, ACTION TINYTEXT, OBJECT TINYTEXT, AMOUNT DOUBLE, MONEY DOUBLE, TAX DOUBLE, STORE TINYTEXT, TYPE TINYTEXT)");
   sw.convertExecuteSynchronously(
       "CREATE TABLE IF NOT EXISTS hyperconomy_history (ID INTEGER NOT NULL PRIMARY KEY AUTO_INCREMENT, OBJECT TINYTEXT, ECONOMY TINYTEXT, TIME DATETIME, PRICE DOUBLE)");
   sw.convertExecuteSynchronously(
       "CREATE TABLE IF NOT EXISTS hyperconomy_audit_log (ID INTEGER NOT NULL PRIMARY KEY AUTO_INCREMENT, TIME DATETIME NOT NULL, ACCOUNT TINYTEXT NOT NULL, ACTION TINYTEXT NOT NULL, AMOUNT DOUBLE NOT NULL, ECONOMY TINYTEXT NOT NULL)");
   sw.convertExecuteSynchronously(
       "CREATE TABLE IF NOT EXISTS hyperconomy_shop_objects (ID INTEGER NOT NULL PRIMARY KEY AUTO_INCREMENT, SHOP VARCHAR(255) NOT NULL, HYPEROBJECT VARCHAR(255) NOT NULL, QUANTITY DOUBLE NOT NULL, PRICE DOUBLE NOT NULL, STATUS VARCHAR(255) NOT NULL)");
   sw.convertExecuteSynchronously(
       "CREATE TABLE IF NOT EXISTS hyperconomy_frame_shops (ID INTEGER NOT NULL PRIMARY KEY, HYPEROBJECT VARCHAR(255) NOT NULL, ECONOMY TINYTEXT, SHOP VARCHAR(255), X DOUBLE NOT NULL DEFAULT '0', Y DOUBLE NOT NULL DEFAULT '0', Z DOUBLE NOT NULL DEFAULT '0', WORLD TINYTEXT NOT NULL)");
 }
예제 #6
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"));
   }
 }
예제 #7
0
  public void load1(QueryResult qr) {
    hc = HyperConomy.hc;
    hc.getSQLRead().setErrorLogging(true);
    if (qr.next()) {
      double version = Double.parseDouble(qr.getString("VALUE"));
      if (version < 1.2) {
        // update adds hyperconomy_shop_objects table
        hc.getLogger().info("[HyperConomy]Updating HyperConomy database to version 1.2.");
        hc.getSQLWrite()
            .convertExecuteSynchronously(
                "CREATE TABLE IF NOT EXISTS hyperconomy_shop_objects (ID INTEGER NOT NULL PRIMARY KEY AUTO_INCREMENT, SHOP VARCHAR(255) NOT NULL, HYPEROBJECT VARCHAR(255) NOT NULL, QUANTITY DOUBLE NOT NULL, PRICE DOUBLE NOT NULL, STATUS VARCHAR(255) NOT NULL)");
        hc.getSQLWrite()
            .executeSynchronously(
                "UPDATE hyperconomy_settings SET VALUE = '1.2' WHERE SETTING = 'version'");
      }
      if (version < 1.21) {
        // update removes unnecessary fields from hyperconomy_objects (id, category)
        hc.getLogger().info("[HyperConomy]Updating HyperConomy database to version 1.21.");
        hc.getSQLWrite()
            .convertExecuteSynchronously(
                "CREATE TABLE IF NOT EXISTS hyperconomy_objects_temp (NAME VARCHAR(255) NOT NULL, ECONOMY VARCHAR(255) NOT NULL, TYPE TINYTEXT, MATERIAL TINYTEXT, DATA INTEGER, DURABILITY INTEGER, VALUE DOUBLE, STATIC TINYTEXT, STATICPRICE DOUBLE, STOCK DOUBLE, MEDIAN DOUBLE, INITIATION TINYTEXT, STARTPRICE DOUBLE, CEILING DOUBLE, FLOOR DOUBLE, MAXSTOCK DOUBLE NOT NULL DEFAULT '1000000', PRIMARY KEY (NAME, ECONOMY))");
        hc.getSQLWrite()
            .executeSynchronously(
                "INSERT INTO hyperconomy_objects_temp (NAME, ECONOMY, TYPE, MATERIAL, DATA, DURABILITY, VALUE, STATIC, STATICPRICE, STOCK, MEDIAN, INITIATION, STARTPRICE, CEILING, FLOOR, MAXSTOCK) SELECT NAME, ECONOMY, TYPE, MATERIAL, DATA, DURABILITY, VALUE, STATIC, STATICPRICE, STOCK, MEDIAN, INITIATION, STARTPRICE, CEILING, FLOOR, MAXSTOCK FROM hyperconomy_objects");
        hc.getSQLWrite().executeSynchronously("DROP TABLE hyperconomy_objects");
        hc.getSQLWrite()
            .convertExecuteSynchronously(
                "CREATE TABLE IF NOT EXISTS hyperconomy_objects (NAME VARCHAR(255) NOT NULL, ECONOMY VARCHAR(255) NOT NULL, TYPE TINYTEXT, MATERIAL TINYTEXT, DATA INTEGER, DURABILITY INTEGER, VALUE DOUBLE, STATIC TINYTEXT, STATICPRICE DOUBLE, STOCK DOUBLE, MEDIAN DOUBLE, INITIATION TINYTEXT, STARTPRICE DOUBLE, CEILING DOUBLE, FLOOR DOUBLE, MAXSTOCK DOUBLE NOT NULL DEFAULT '1000000', PRIMARY KEY (NAME, ECONOMY))");
        hc.getSQLWrite()
            .executeSynchronously(
                "INSERT INTO hyperconomy_objects (NAME, ECONOMY, TYPE, MATERIAL, DATA, DURABILITY, VALUE, STATIC, STATICPRICE, STOCK, MEDIAN, INITIATION, STARTPRICE, CEILING, FLOOR, MAXSTOCK) SELECT NAME, ECONOMY, TYPE, MATERIAL, DATA, DURABILITY, VALUE, STATIC, STATICPRICE, STOCK, MEDIAN, INITIATION, STARTPRICE, CEILING, FLOOR, MAXSTOCK FROM hyperconomy_objects_temp");
        hc.getSQLWrite().executeSynchronously("DROP TABLE hyperconomy_objects_temp");
        hc.getSQLWrite()
            .executeSynchronously(
                "UPDATE hyperconomy_settings SET VALUE = '1.21' WHERE SETTING = 'version'");
      }
      if (version < 1.22) {
        // update adds frame shop table
        hc.getLogger().info("[HyperConomy]Updating HyperConomy database to version 1.22.");
        hc.getSQLWrite()
            .convertExecuteSynchronously(
                "CREATE TABLE IF NOT EXISTS hyperconomy_frame_shops (ID INTEGER NOT NULL PRIMARY KEY, HYPEROBJECT VARCHAR(255) NOT NULL, ECONOMY TINYTEXT, SHOP VARCHAR(255), X DOUBLE NOT NULL DEFAULT '0', Y DOUBLE NOT NULL DEFAULT '0', Z DOUBLE NOT NULL DEFAULT '0', WORLD TINYTEXT NOT NULL)");
        hc.getSQLWrite()
            .executeSynchronously(
                "UPDATE hyperconomy_settings SET VALUE = '1.22' WHERE SETTING = 'version'");
      }
      if (version < 1.23) {
        // update adds new fields ALIASES and DISPLAY_NAME to hyperconomy_objects, backs up
        // composites.yml and objects.yml and replaces them with the new ones
        // and then calls an after load update to update the names, aliases, and display names in
        // the database
        hc.getLogger().info("[HyperConomy]Updating HyperConomy database to version 1.23.");
        hc.getSQLWrite()
            .convertExecuteSynchronously(
                "CREATE TABLE IF NOT EXISTS hyperconomy_objects_temp (NAME VARCHAR(255) NOT NULL, ECONOMY VARCHAR(255) NOT NULL, DISPLAY_NAME VARCHAR(255), ALIASES VARCHAR(1000), TYPE TINYTEXT, MATERIAL TINYTEXT, DATA INTEGER, DURABILITY INTEGER, VALUE DOUBLE, STATIC TINYTEXT, STATICPRICE DOUBLE, STOCK DOUBLE, MEDIAN DOUBLE, INITIATION TINYTEXT, STARTPRICE DOUBLE, CEILING DOUBLE, FLOOR DOUBLE, MAXSTOCK DOUBLE NOT NULL DEFAULT '1000000', PRIMARY KEY (NAME, ECONOMY))");
        hc.getSQLWrite()
            .executeSynchronously(
                "INSERT INTO hyperconomy_objects_temp (NAME, ECONOMY, TYPE, MATERIAL, DATA, DURABILITY, VALUE, STATIC, STATICPRICE, STOCK, MEDIAN, INITIATION, STARTPRICE, CEILING, FLOOR, MAXSTOCK) SELECT NAME, ECONOMY, TYPE, MATERIAL, DATA, DURABILITY, VALUE, STATIC, STATICPRICE, STOCK, MEDIAN, INITIATION, STARTPRICE, CEILING, FLOOR, MAXSTOCK FROM hyperconomy_objects");
        hc.getSQLWrite().executeSynchronously("DROP TABLE hyperconomy_objects");
        hc.getSQLWrite()
            .convertExecuteSynchronously(
                "CREATE TABLE IF NOT EXISTS hyperconomy_objects (NAME VARCHAR(255) NOT NULL, ECONOMY VARCHAR(255) NOT NULL, DISPLAY_NAME VARCHAR(255), ALIASES VARCHAR(1000), TYPE TINYTEXT, MATERIAL TINYTEXT, DATA INTEGER, DURABILITY INTEGER, VALUE DOUBLE, STATIC TINYTEXT, STATICPRICE DOUBLE, STOCK DOUBLE, MEDIAN DOUBLE, INITIATION TINYTEXT, STARTPRICE DOUBLE, CEILING DOUBLE, FLOOR DOUBLE, MAXSTOCK DOUBLE NOT NULL DEFAULT '1000000', PRIMARY KEY (NAME, ECONOMY))");
        hc.getSQLWrite()
            .executeSynchronously(
                "INSERT INTO hyperconomy_objects (NAME, ECONOMY, DISPLAY_NAME, ALIASES, TYPE, MATERIAL, DATA, DURABILITY, VALUE, STATIC, STATICPRICE, STOCK, MEDIAN, INITIATION, STARTPRICE, CEILING, FLOOR, MAXSTOCK) SELECT NAME, ECONOMY, DISPLAY_NAME, ALIASES, TYPE, MATERIAL, DATA, DURABILITY, VALUE, STATIC, STATICPRICE, STOCK, MEDIAN, INITIATION, STARTPRICE, CEILING, FLOOR, MAXSTOCK FROM hyperconomy_objects_temp");
        hc.getSQLWrite().executeSynchronously("DROP TABLE hyperconomy_objects_temp");
        new Backup();
        YamlHandler yh = hc.getYamlHandler();
        yh.unRegisterFileConfiguration("composites");
        yh.unRegisterFileConfiguration("objects");
        yh.deleteConfigFile("composites");
        yh.deleteConfigFile("objects");
        yh.copyFromJar("composites");
        yh.copyFromJar("objects");
        yh.registerFileConfiguration("composites");
        yh.registerFileConfiguration("objects");
        hc.getEconomyManager().addUpdateAfterLoad(1.23);
        ;
        hc.getSQLWrite()
            .executeSynchronously(
                "UPDATE hyperconomy_settings SET VALUE = '1.23' WHERE SETTING = 'version'");
      }
      if (version < 1.24) {}

    } else {
      createTables(hc.getSQLWrite());
    }
    String query = "SELECT NAME FROM hyperconomy_objects WHERE ECONOMY='default'";
    hc.getSQLRead().syncRead(this, "load3", query, null);
  }
예제 #8
0
 public void load4() {
   hc.getEconomyManager().load5();
 }