Package org.bukkit.scheduler

Examples of org.bukkit.scheduler.BukkitTask


                    final Pair<String, String> pair = new Pair<String, String>(target.getName(), sName);
                    if (requests.containsKey(pair)){
                      requests.remove(pair);
                    }
                   
                    BukkitTask task = Bukkit.getScheduler().runTaskLaterAsynchronously(CommandsEX.plugin, new Runnable(){
                      @Override
                      public void run() {
                        requests.remove(pair);
                        Player player = Bukkit.getPlayerExact(pair.second);
                        if (player != null){
                          LogHelper.showWarning("economyRequestExpired1#####[" + getCurrencySymbol() + fixDecimals(amount) + " #####from#####[ " + pair.first + "#####economyRequestExpired2", player);
                        }
                       
                        Player target = Bukkit.getPlayerExact(pair.first);
                        if (target != null){
                          LogHelper.showInfo("economyRequestExpiredNotify1#####[" + pair.second + " #####for#####[ " + getCurrencySymbol() + fixDecimals(amount) + " #####economyRequestExpiredNotify1", target);
                        }
                      }
                    }, CommandsEX.getConf().getInt("economy.requestExpireTime") * 20);
                   
                    requests.put(pair, new Pair<Double, BukkitTask>(amount, task));
                   
                    LogHelper.showInfo("economyRequest#####[" + getCurrencySymbol() + fixDecimals(amount) + " #####to#####[ " + target, sender);
                   
                    LogHelper.showInfo("[" + sName + "economyRequestNotify1#####[" + fixDecimals(amount) + " #####economyRequestNotify2", target);
                    LogHelper.showInfo("economyRequestNotify3#####[" + sName, target);
                    LogHelper.showInfo("economyRequestNotify4#####[" + sName, target);
                  } else {
                    LogHelper.showWarning("economyTakeNotEnough", sender);
                  }
                } catch (NumberFormatException e){
                  LogHelper.showWarning("economyIncorrectAmount", sender);
                }
              } else {
                LogHelper.showWarning("invalidPlayer", sender);
              }
            } else {
              sender.sendMessage(getEconomyHelp(sender));
            }
          }
        }
      } else {
        sender.sendMessage(getEconomyHelp(sender));
      }
    } else if (function.equalsIgnoreCase("spawn")){
      if (Permissions.checkPerms(sender, "cex.economy.spawn")){
        if (args.length != 2 || args.length != 3){
          sender.sendMessage(getEconomyHelp(sender));
        } else {
          Player target = null;
         
          if (args.length == 2){
            if (sender instanceof Player){
              target = (Player) sender;
            } else {
              sender.sendMessage(getEconomyHelp(sender));
              return true;
            }
          } else {
            target = Bukkit.getPlayer(args[1]);
          }
         
          if (target == null){
            LogHelper.showWarning("invalidPlayer", sender);
          }
         
          boolean self = false;
         
          if (target.equals(sender)){
            self = true;
          }

          try {
            double amount = Double.parseDouble((self ? args[1] : args[2]));
           
            // this avoids players giving a negative number
            if (amount < 0){
              LogHelper.showWarning("economyNegative", sender);
              return true;
            }
           
            deposit(target.getName(), amount);
            LogHelper.showInfo("economySpawn#####[" + fixDecimals(amount) + " #####" + (self ? "economySpawnAccount" : "for#####[ " + target.getName()), sender);
          } catch (NumberFormatException e){
            LogHelper.showWarning("economyIncorrectAmount", sender);
          }
        }
      }
    }  else if (function.equalsIgnoreCase("purge")){
      if (args.length > 1){
        sender.sendMessage(getEconomyHelp(sender));
      } else {
        if (Permissions.checkPerms(sender, "cex.economy.purge")){
          int amount = Econ.purgeAccounts();
         
          if (amount > 1){
            LogHelper.showInfo("economyPurge1#####[" + amount + " #####economyPurge2", sender);
          } else {
            LogHelper.showWarning("economyPurgeNone", sender);
          }
        }
      }
    } else if (function.equalsIgnoreCase("save")){
      if (Permissions.checkPerms(sender, "cex.economy.save")){
        Econ.saveDatabase();
        LogHelper.showInfo("economySave", sender);
      }
    } else if (function.equalsIgnoreCase("clear")){
      if (args.length == 1){
        if (clearRequests.containsKey(sName)){
         
        } else {
          LogHelper.showWarnings(sender, "economyClear1", "economyClear2", "economyClear3");
          BukkitTask task = Bukkit.getScheduler().runTaskLaterAsynchronously(CommandsEX.plugin, new Runnable(){
            @Override
            public void run() {
              if (clearRequests.containsKey(sName)){
                clearRequests.remove(sName);
                LogHelper.showWarning("economyClearExpired", sender);
View Full Code Here


    Integer time = CommandsEX.getConf().getInt("nanoSuitTime", 60);
    if (nanoSuit) {
      if ((!lastUse.containsKey(pName) || ((stamp - lastUse.get(pName)) > CommandsEX.getConf().getInt("nanoSuitRechargeTime")))) {
       
        // set up periodic time, informing the suited person about NanoSuit power time left
        BukkitTask task = Bukkit.getServer().getScheduler().runTaskTimerAsynchronously(CommandsEX.plugin, new TimeRemaining(pName), 20, 20);
       
        Map<String, Object> m = new HashMap<String, Object>();
        m.put("timeBegin", stamp);
        m.put("taskID", task.getTaskId());
        suitedPlayers.put(pName, m);
        lastUse.put(pName, stamp + (time * 20));
        // tell the player
        LogHelper.showInfo("nanoSuitActive#####[" + time + " #####seconds", p);
        LogHelper.showInfo("nanoSuitActiveHelp", p);
View Full Code Here

   * @param firstDelay - the amount of time to wait until executing the task for the first time.
   * @param repeatDelay - the amount of time inbetween each execution. If less than zero, the task is only executed once.
   * @return A cancel token.
   */
  private static TaskWrapper tryUpdatedVersion(final Plugin plugin, final BukkitScheduler scheduler, Runnable runnable, long firstDelay, long repeatDelay) {
    final BukkitTask task = scheduler.runTaskTimerAsynchronously(plugin, runnable, firstDelay, repeatDelay);
   
    return new TaskWrapper() {
      @Override
      public void cancel() {
        task.cancel();
      }
    };
  }
View Full Code Here

      //It's an NPC, we can safely exit...
      return;
    }
   
    if(playerremoval.containsKey(event.getPlayer().getName())) {
      BukkitTask task = playerremoval.get(player.getName());
      task.cancel();
    }
    players.put(player.getName(), new MIPlayer(player, plugin));
    if(!player.hasPermission("multiinv.exempt") || !player.hasPermission("multiinv.enderchestexempt")) {
      // Let's set a task to run once they get switched to the proper world by bukkit.
      plugin.getServer().getScheduler().scheduleSyncDelayedTask(plugin, new DeferredWorldCheck(player, this), 1);
View Full Code Here

                // Load the inventory for this world from file.
                savePlayerState(player, currentworld);
            }
            //Remove the player from the list immediately if saveonquit is true.
            //Prevents a bug where stuff is saved to file within the 60 seconds time out.
        BukkitTask task = plugin.getServer().getScheduler().runTask(plugin, new PlayerLogoutRemover(event.getPlayer().getName()));
        playerremoval.put(event.getPlayer().getName(), task);
        }else {
        BukkitTask task = plugin.getServer().getScheduler().runTaskLater(plugin, new PlayerLogoutRemover(event.getPlayer().getName()), 20*60);
        playerremoval.put(event.getPlayer().getName(), task);
        }
  }
View Full Code Here

                // Load the inventory for this world from file.
                savePlayerState(player, currentworld);
            }
            //Remove the player from the list immediately if saveonquit is true.
            //Prevents a bug where stuff is saved to file within the 60 seconds time out.
        BukkitTask task = plugin.getServer().getScheduler().runTask(plugin, new PlayerLogoutRemover(event.getPlayer().getName()));
        playerremoval.put(event.getPlayer().getName(), task);
        }else {
        BukkitTask task = plugin.getServer().getScheduler().runTaskLater(plugin, new PlayerLogoutRemover(event.getPlayer().getName()), 20*60);
        playerremoval.put(event.getPlayer().getName(), task);
        }
  }
View Full Code Here

TOP

Related Classes of org.bukkit.scheduler.BukkitTask

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.