private void waitForLoad() {
   wait =
       hc.getServer()
           .getScheduler()
           .runTaskTimer(
               hc,
               new Runnable() {
                 public void run() {
                   boolean loaded = true;
                   for (HyperEconomy he : getEconomies()) {
                     if (!he.dataLoaded() || !dataLoaded) {
                       loaded = false;
                     }
                   }
                   if (loaded) {
                     hc.getHyperLock().setLoadLock(false);
                     economiesLoaded = true;
                     wait.cancel();
                     hc.getHyperEventHandler().fireDataLoadEvent();
                     loadActive = false;
                     updateAfterLoad();
                   }
                 }
               },
               1L,
               1L);
 }
 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);
 }
Beispiel #3
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"));
    }
  }
 public void startShopCheck() {
   shopCheckTask =
       hc.getServer()
           .getScheduler()
           .runTaskTimer(
               hc,
               new Runnable() {
                 public void run() {
                   for (Shop shop : shops.values()) {
                     shop.updatePlayerStatus();
                   }
                 }
               },
               shopinterval,
               shopinterval);
 }
Beispiel #5
0
 /** Limits messages sent to player to 1 per second. */
 private void sendMessage(String message) {
   messages.put(player, message);
   if (!messageActive) {
     messageActive = true;
     hc.getServer()
         .getScheduler()
         .scheduleSyncDelayedTask(
             hc,
             new Runnable() {
               public void run() {
                 player.sendMessage(messages.get(player));
                 messages.remove(player);
                 messageActive = false;
               }
             },
             20L);
   }
 }
 public void load5() {
   hc.getServer()
       .getScheduler()
       .runTaskAsynchronously(
           hc,
           new Runnable() {
             public void run() {
               economies.clear();
               ArrayList<String> econs =
                   sr.getStringList("SELECT DISTINCT ECONOMY FROM hyperconomy_objects");
               for (String e : econs) {
                 economies.put(e, new HyperEconomy(e));
               }
               loadData();
               waitForLoad();
             }
           });
 }
 private void loadData() {
   hc.getServer()
       .getScheduler()
       .runTaskAsynchronously(
           hc,
           new Runnable() {
             public void run() {
               hyperPlayers.clear();
               QueryResult result = sr.aSyncSelect("SELECT * FROM hyperconomy_players");
               while (result.next()) {
                 HyperPlayer hplayer =
                     new HyperPlayer(
                         result.getString("PLAYER"),
                         result.getString("ECONOMY"),
                         result.getDouble("BALANCE"),
                         result.getDouble("X"),
                         result.getDouble("Y"),
                         result.getDouble("Z"),
                         result.getString("WORLD"),
                         result.getString("HASH"),
                         result.getString("SALT"));
                 hyperPlayers.put(hplayer.getName(), hplayer);
               }
               result.close();
               hc.getServer()
                   .getScheduler()
                   .runTask(
                       hc,
                       new Runnable() {
                         public void run() {
                           addOnlinePlayers();
                           createGlobalShopAccount();
                           loadShops();
                           dataLoaded = true;
                         }
                       });
             }
           });
 }