@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
  public void onPlayerJoin(PlayerJoinEvent event) {
    final Player player = event.getPlayer();
    ClanPlayer clanPlayer = clanManager.getClanPlayer(player);
    if (clanPlayer == null) return;
    System.out.println(player.getName() + " is in SimpleClans db.");
    Clan clan = clanPlayer.getClan();
    if (clan == null) // If not part of a clan, do no more
    return;

    final String tag = clan.getColorTag();
    System.out.println(player.getName() + " has a clan: " + tag);

    // Feature: set prefix in tablist
    // compatible with other prefix/suffix plugins since we just set PlayerListName
    scheduler.scheduleSyncDelayedTask(
        instance,
        new Runnable() {
          public void run() {
            player.setPlayerListName(tag + " " + player.getDisplayName());
          }
        },
        30L); // Long delay to ensure this has priority & no need to instantly set

    scheduler.scheduleSyncDelayedTask(
        instance,
        new Runnable() {
          public void run() {
            Team team = sb.getTeam(player.getName());
            if (team == null) return;
            team.setPrefix(tag + " "); // TODO: Check if a colored tag colors name
          }
        },
        40L); // Ensure healthbar made the team
  }
Beispiel #2
0
  public void PlayerFreezing() {
    BukkitScheduler scheduler = Bukkit.getServer().getScheduler();
    scheduler.scheduleSyncRepeatingTask(
        main,
        new Runnable() {
          @Override
          public void run() {
            Material playerChest = player.getInventory().getChestplate().getType();

            if (freezoMeter > 0) {
              freezoMeter = -1;
            } else if (freezoMeter < 0 && player.getInventory().getArmorContents() == null) {
              player.damage(20);
              freezoMeter = 100;
            } else if (freezoMeter < 0 && playerChest == Material.LEATHER_CHESTPLATE) {
              player.damage(0);
              freezoMeter = 100;
            } else if (freezoMeter < 0 && playerChest == Material.IRON_CHESTPLATE
                || playerChest == Material.GOLD_CHESTPLATE) {
              player.damage(15);
              freezoMeter = 100;
            } else if (freezoMeter < 0 && playerChest == Material.DIAMOND_CHESTPLATE) {
              player.damage(10);
              freezoMeter = 100;
            }
          }
        },
        10L,
        20L * 30);
  }
  @Override
  public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {

    if (!sender.hasPermission(GoldRushPerms.SCHEDULE)) {
      deny(sender);
      return true;
    }

    int taskID = Departure.getTaskID();
    BukkitScheduler s = Bukkit.getScheduler();

    if (args[0].equalsIgnoreCase("Start") && taskID == -1) {
      sender.sendMessage("Starting Train Cycle...");
      Departure.setTaskID(
          Bukkit.getScheduler().scheduleSyncRepeatingTask(plugin, new Departure(plugin), 100, 400));
      return true;
    } else if (taskID != 0) {
      sender.sendMessage("Train Cycle already started!");
      return true;
    } else if (args[0].equalsIgnoreCase("Stop")
        && (s.isCurrentlyRunning(taskID) || s.isQueued(taskID))) {
      sender.sendMessage("Stopping Train Cycle...");
      Bukkit.getScheduler().cancelTask(taskID);
      Departure.resetTaskID();
      return true;
    } else if (taskID == -1) {
      sender.sendMessage("Train Cycle is not running.");
      return true;
    }
    return false;
  }
  // Not really a SimpleClans feature but too lazy to make it a separate plugin right now
  @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
  public void onPlayerChat(AsyncPlayerChatEvent event) {
    if (event.getRecipients().size() < 2) return; // ignore if they're the only one on or softmuted

    final Player player = event.getPlayer();
    String mess = event.getMessage();
    if (mess.length() > 30) mess = mess.substring(mess.indexOf(0, 27)) + "...";
    final String message = mess;
    scheduler.scheduleSyncDelayedTask(
        instance,
        new Runnable() {
          public void run() {
            // TODO: are the 3 lines below thread-safe?
            Team team = sb.getTeam(player.getName());
            if (team == null) return;
            team.setSuffix(": " + message);
          }
        });

    scheduler.scheduleSyncDelayedTask(
        instance,
        new Runnable() {
          public void run() {
            Team team = sb.getTeam(player.getName());
            if (team == null) return;
            if (team.getSuffix().equals(": " + message))
              Bukkit.dispatchCommand(
                  Bukkit.getConsoleSender(), "healthbar reloadplayer " + player.getName());
          }
        },
        70L);
  }
  public void process() {
    preLogout();
    if (!canLogout) return;
    final Player p = player;
    BukkitScheduler sched = p.getServer().getScheduler();
    PlayerAuth auth = PlayerCache.getInstance().getAuth(name);
    database.updateSession(auth);
    auth.setQuitLocX(p.getLocation().getX());
    auth.setQuitLocY(p.getLocation().getY());
    auth.setQuitLocZ(p.getLocation().getZ());
    auth.setWorld(p.getWorld().getName());
    database.updateQuitLoc(auth);

    PlayerCache.getInstance().removePlayer(name);
    database.setUnlogged(name);
    sched.scheduleSyncDelayedTask(
        plugin,
        new Runnable() {
          @Override
          public void run() {
            Utils.teleportToSpawn(p);
          }
        });
    if (LimboCache.getInstance().hasLimboPlayer(name))
      LimboCache.getInstance().deleteLimboPlayer(name);
    LimboCache.getInstance().addLimboPlayer(player);
    Utils.setGroup(player, GroupType.NOTLOGGEDIN);

    sched.scheduleSyncDelayedTask(plugin, new ProcessSyncronousPlayerLogout(p, plugin));
  }
 /*
  * The only problem with this method is that the player may not teleport on the next tick
  *
  */
 public void updateInvisibleForPlayerDelayed(Player player) {
   //
   // Set it up to wait 1/2 second before firing
   scheduler.scheduleSyncDelayedTask(this, new UpdateInvisibleTimerTask(player.getName()), 10);
   scheduler.scheduleSyncDelayedTask(this, new UpdateInvisibleTimerTask(player.getName()), 20);
   scheduler.scheduleSyncDelayedTask(this, new UpdateInvisibleTimerTask(player.getName()), 40);
   scheduler.scheduleSyncDelayedTask(this, new UpdateInvisibleTimerTask(player.getName()), 60);
 }
  public void process() {
    preLogout();
    if (!canLogout) return;
    final Player p = player;
    BukkitScheduler sched = p.getServer().getScheduler();
    PlayerAuth auth = PlayerCache.getInstance().getAuth(name);
    database.updateSession(auth);
    auth.setQuitLocX(p.getLocation().getX());
    auth.setQuitLocY(p.getLocation().getY());
    auth.setQuitLocZ(p.getLocation().getZ());
    auth.setWorld(p.getWorld().getName());
    database.updateQuitLoc(auth);

    PlayerCache.getInstance().removePlayer(name);
    database.setUnlogged(name);
    if (Settings.isTeleportToSpawnEnabled && !Settings.noTeleport) {
      Location spawnLoc = plugin.getSpawnLocation(p);
      final AuthMeTeleportEvent tpEvent = new AuthMeTeleportEvent(p, spawnLoc);
      sched.scheduleSyncDelayedTask(
          plugin,
          new Runnable() {

            @Override
            public void run() {
              plugin.getServer().getPluginManager().callEvent(tpEvent);
              if (!tpEvent.isCancelled()) {
                if (tpEvent.getTo() != null) p.teleport(tpEvent.getTo());
              }
            }
          });
    }

    if (LimboCache.getInstance().hasLimboPlayer(name))
      LimboCache.getInstance().deleteLimboPlayer(name);
    LimboCache.getInstance().addLimboPlayer(player);
    utils.setGroup(player, GroupType.NOTLOGGEDIN);
    if (Settings.protectInventoryBeforeLogInEnabled) {
      player.getInventory().clear();
      // create cache file for handling lost of inventories on unlogged in
      // status
      DataFileCache playerData =
          new DataFileCache(
              LimboCache.getInstance().getLimboPlayer(name).getInventory(),
              LimboCache.getInstance().getLimboPlayer(name).getArmour());
      playerBackup.createCache(player, playerData);
    }
    sched.scheduleSyncDelayedTask(plugin, new ProcessSyncronousPlayerLogout(p, plugin));
  }
 public void StartIntervalBackup() {
   _bukkitScheduler.runTaskTimer(
       getPlugin(),
       new StartIntervalBackup(),
       72000L * p.getSaveItConfig().intv,
       72000L * p.getSaveItConfig().intv);
 }
Beispiel #9
0
 @EventHandler
 public void WeatherChange(WeatherChangeEvent e) {
   BukkitScheduler scheduler = Bukkit.getServer().getScheduler();
   scheduler.scheduleSyncRepeatingTask(
       main,
       new Runnable() {
         @Override
         public void run() {
           boolean weather = Bukkit.getWorlds().get(0).hasStorm();
           if (weather) {
             PlayerFreezing();
           }
         }
       },
       0L,
       20L);
 }
 /**
  * Alert the plugin that changes have been made to mines, but wait 60 seconds before we save. This
  * process saves on disk I/O by waiting until a long string of changes have finished before
  * writing to disk.
  */
 public void buffSave() {
   BukkitScheduler scheduler = getServer().getScheduler();
   if (saveTaskId != -1) {
     // Cancel old task
     scheduler.cancelTask(saveTaskId);
   }
   // Schedule save
   final MineResetLite plugin = this;
   scheduler.scheduleSyncDelayedTask(
       this,
       new Runnable() {
         public void run() {
           plugin.save();
         }
       },
       60 * 20L);
 }
Beispiel #11
0
  public void cast(Player caster) {
    BukkitScheduler scheduler = caster.getServer().getScheduler();
    final World world = caster.getWorld();
    final long finalTime =
        world.getTime() - 12000 < 0 ? world.getTime() + 12000 : world.getTime() - 12000;

    for (long i = 0; i < 64; i++) {
      scheduler.scheduleSyncDelayedTask(
          caster.getServer().getPluginManager().getPlugin("Magica"),
          new Runnable() {
            public void run() {
              if (world.getTime() != finalTime)
                world.setTime((long) (world.getTime() + (finalTime - world.getTime()) * 0.1));
            }
          },
          i);
    }
  }
 private void scheduleWorldDeletion(final File worldFolder, final String dimension) {
   BukkitScheduler scheduler = Bukkit.getServer().getScheduler();
   scheduler.scheduleSyncDelayedTask(
       plugin,
       new Runnable() {
         public void run() {
           if (!copyFolder(worldFolder, dimension)) {
             plugin
                 .getLogger()
                 .warning("Error copying dimension folder " + worldFolder.getAbsolutePath());
             return;
           }
           deleteFolder(worldFolder);
           plugin.getLogger().info("Dimension " + dimension + " has been deleted.");
         }
       },
       20L);
 }
  private void callHome(final String msg) {
    BukkitRunnable r =
        new BukkitRunnable() {
          String m = msg;

          @Override
          public void run() {
            ds.instance.getLogger().info(m);
          }
        };

    bs.scheduleSyncDelayedTask(ds.instance, r, 0);
  }
Beispiel #14
0
  /*private void WaterSprite(Player p) {
  	// TODO Auto-generated method stub
  	p.setVelocity(new Vector(p.getLocation().getDirection().multiply(2.7)
  			.getX(),
  			p.getLocation().getDirection().multiply(1.5).getY() + .7, p
  					.getLocation().getDirection().multiply(2.7).getZ()));
  	p.playSound(p.getLocation(), Sound.ZOMBIE_REMEDY, 1F, 1F);
  	p.addPotionEffect(new PotionEffect(PotionEffectType.INCREASE_DAMAGE, 20*5, 0));
  	p.addPotionEffect(new PotionEffect(PotionEffectType.REGENERATION, 20*5, 1));
  	p.addPotionEffect(new PotionEffect(PotionEffectType.SPEED, 20*5, 0));
  	p.sendMessage(ChatColor.BLUE + "Poseidon pounce!");
  }*/
  @EventHandler
  public void move(PlayerMoveEvent e) {
    if (Util.getKit(e.getPlayer()) instanceof Poseidon) {
      if (e.getPlayer().getAllowFlight() == true) {
        final Player p = e.getPlayer();
        final Block b = p.getLocation().getBlock();
        if (b.getType() == Material.AIR) {
          b.setType(Material.STATIONARY_WATER, false);
          ParticleEffect effect =
              new ParticleEffect(ParticleEffect.ParticleType.WATER_BUBBLE, 0.02, 10, .5);
          ParticleEffect effect2 =
              new ParticleEffect(ParticleEffect.ParticleType.WATER_DROP, 0.02, 10, .5);
          ParticleEffect effect3 =
              new ParticleEffect(ParticleEffect.ParticleType.DRIP_WATER, 0.02, 10, .5);
          ParticleEffect effect4 =
              new ParticleEffect(ParticleEffect.ParticleType.WATER_WAKE, 0.02, 10, .5);

          effect.sendToLocation(p.getLocation());
          effect2.sendToLocation(p.getLocation());
          effect3.sendToLocation(p.getLocation());
          effect4.sendToLocation(p.getLocation());
          BukkitScheduler scheduler = Bukkit.getScheduler();
          scheduler.scheduleSyncDelayedTask(
              plugin,
              new Runnable() {

                public void run() {
                  // TODO Auto-generated method stub
                  if (b.getType() == Material.STATIONARY_WATER) {
                    b.setType(Material.AIR, false);
                  }
                }
              },
              20L * 2);
        }
      }
    }
  }
  private boolean updatePlugin(final String u, final Plugin plugin) {
    final BukkitScheduler bs = plugin.getServer().getScheduler();
    bs.scheduleAsyncDelayedTask(
        plugin,
        new Runnable() {

          @Override
          public void run() {
            try {
              String updateURL = getPluginUpdateURL(u);
              if (u == null) return;
              File to =
                  new File(
                      plugin.getServer().getUpdateFolderFile(),
                      updateURL.substring(updateURL.lastIndexOf('/') + 1, updateURL.length()));
              File tmp = new File(to.getPath() + ".au");
              if (!tmp.exists()) {
                plugin.getServer().getUpdateFolderFile().mkdirs();
                tmp.createNewFile();
              }
              URL url = new URL(updateURL);
              InputStream is = url.openStream();
              OutputStream os = new FileOutputStream(tmp);
              byte[] buffer = new byte[4096];
              int fetched;
              while ((fetched = is.read(buffer)) != -1) os.write(buffer, 0, fetched);
              is.close();
              os.flush();
              os.close();
              if (to.exists()) to.delete();
              tmp.renameTo(to);
            } catch (Exception e) {
              e.printStackTrace();
            }
          }
        });
    return false;
  }
Beispiel #16
0
 public void run() {
   try {
     if (!lock.compareAndSet(false, true)) return;
     BukkitScheduler bs = plugin.getServer().getScheduler();
     if (bs.isQueued(AutoUpdate.this.pid) || bs.isCurrentlyRunning(AutoUpdate.this.pid))
       bs.cancelTask(AutoUpdate.this.pid);
     if (restart)
       AutoUpdate.this.pid = bs.scheduleAsyncRepeatingTask(plugin, AutoUpdate.this, 5L, delay);
     else AutoUpdate.this.pid = -1;
     lock.set(false);
     bs.cancelTask(pid);
   } catch (Throwable t) {
     printStackTraceSync(t, false);
   }
 }
  @Override
  public void onEnable() {
    // Setup Permissions
    setupPermissions();

    // Create new configuration file
    FileConfiguration config = getConfig();
    File VanishNoPickup = new File(getDataFolder(), "config.yml");

    // Load the config if it's there
    try {
      config.load(VanishNoPickup);
    } catch (Exception ex) {
      // Ignore the errors
    }

    // Load our variables from configuration
    RANGE = config.getInt("range", 512);
    RANGE_SQUARED = RANGE * RANGE;
    REFRESH_TIMER = config.getInt("refresh_delay", 20);

    // Save the configuration(especially if it wasn't before)
    try {
      config.save(VanishNoPickup);
    } catch (Exception ex) {
      // Ignore the errors
    }
    PluginManager pm = getServer().getPluginManager();
    pm.registerEvents(entityListener, this);
    pm.registerEvents(playerListener, this);

    log.info("[" + getDescription().getName() + "] " + getDescription().getVersion() + " enabled.");

    scheduler = getServer().getScheduler();

    // Scheduler is set to update all invisible player statuses every 20 seconds?!  That seems like
    // a lot.
    scheduler.scheduleSyncRepeatingTask(
        this, new UpdateInvisibleTimerTask(), 10, 20 * REFRESH_TIMER);
  }
 @Override
 public void onDisable() {
   scheduler.cancelTasks(this);
   log.info(
       "[" + getDescription().getName() + "] " + getDescription().getVersion() + " disabled.");
 }
Beispiel #19
0
 public void StartSavingAllPlayers() {
   if (getPlugin().getSaveItConfig().SavingStats)
     getPlugin().playercheck = System.currentTimeMillis();
   Delay2 = 1;
   _bukkitScheduler.runTaskLater(getPlugin(), new SaveAllPlayers(), 20L * Delay2);
 }
Beispiel #20
0
 public void StartManualBackup() {
   _bukkitScheduler.runTaskLater(getPlugin(), new StartManualBackup(), 20L * 5);
 }
Beispiel #21
0
 protected void scheduleForce() {
   scheduler.scheduleSyncDelayedTask(plugin, this, tickSpan);
 }
  public void process() {
    if (AuthMePlayerListener.gameMode.containsKey(name)) AuthMePlayerListener.gameMode.remove(name);
    AuthMePlayerListener.gameMode.putIfAbsent(name, player.getGameMode());
    BukkitScheduler sched = plugin.getServer().getScheduler();

    if (Utils.isNPC(player) || Utils.isUnrestricted(player)) {
      return;
    }

    if (plugin.ess != null && Settings.disableSocialSpy) {
      plugin.ess.getUser(player).setSocialSpyEnabled(false);
    }

    if (!plugin.canConnect()) {
      final GameMode gM = AuthMePlayerListener.gameMode.get(name);
      sched.scheduleSyncDelayedTask(
          plugin,
          new Runnable() {

            @Override
            public void run() {
              AuthMePlayerListener.causeByAuthMe.putIfAbsent(name, true);
              player.setGameMode(gM);
              player.kickPlayer("Server is loading, please wait before joining!");
            }
          });
      return;
    }

    final String ip = plugin.getIP(player);
    if (Settings.isAllowRestrictedIp && !Settings.getRestrictedIp(name, ip)) {
      final GameMode gM = AuthMePlayerListener.gameMode.get(name);
      sched.scheduleSyncDelayedTask(
          plugin,
          new Runnable() {

            @Override
            public void run() {
              AuthMePlayerListener.causeByAuthMe.putIfAbsent(name, true);
              player.setGameMode(gM);
              player.kickPlayer("You are not the Owner of this account, please try another name!");
              if (Settings.banUnsafeIp) plugin.getServer().banIP(ip);
            }
          });
      return;
    }
    if (Settings.getMaxJoinPerIp > 0
        && !plugin.authmePermissible(player, "authme.allow2accounts")
        && !ip.equalsIgnoreCase("127.0.0.1")
        && !ip.equalsIgnoreCase("localhost")) {
      if (plugin.hasJoinedIp(player.getName(), ip)) {
        sched.scheduleSyncDelayedTask(
            plugin,
            new Runnable() {

              @Override
              public void run() {
                player.kickPlayer("A player with the same IP is already in game!");
              }
            });
        return;
      }
    }
    final Location spawnLoc = plugin.getSpawnLocation(player);
    final boolean isAuthAvailable = database.isAuthAvailable(name);
    if (isAuthAvailable) {
      if (Settings.isForceSurvivalModeEnabled && !Settings.forceOnlyAfterLogin) {
        sched.scheduleSyncDelayedTask(
            plugin,
            new Runnable() {

              @Override
              public void run() {
                AuthMePlayerListener.causeByAuthMe.putIfAbsent(name, true);
                Utils.forceGM(player);
              }
            });
      }
      if (!Settings.noTeleport)
        if (Settings.isTeleportToSpawnEnabled
            || (Settings.isForceSpawnLocOnJoinEnabled
                && Settings.getForcedWorlds.contains(player.getWorld().getName()))) {
          sched.scheduleSyncDelayedTask(
              plugin,
              new Runnable() {

                @Override
                public void run() {
                  SpawnTeleportEvent tpEvent =
                      new SpawnTeleportEvent(
                          player,
                          player.getLocation(),
                          spawnLoc,
                          PlayerCache.getInstance().isAuthenticated(name));
                  plugin.getServer().getPluginManager().callEvent(tpEvent);
                  if (!tpEvent.isCancelled()) {
                    if (player.isOnline() && tpEvent.getTo() != null) {
                      if (tpEvent.getTo().getWorld() != null) player.teleport(tpEvent.getTo());
                    }
                  }
                }
              });
        }
      placePlayerSafely(player, spawnLoc);
      LimboCache.getInstance().updateLimboPlayer(player);
      // protect inventory
      if (Settings.protectInventoryBeforeLogInEnabled && plugin.inventoryProtector != null) {
        ProtectInventoryEvent ev = new ProtectInventoryEvent(player);
        plugin.getServer().getPluginManager().callEvent(ev);
        if (ev.isCancelled()) {
          plugin.inventoryProtector.sendInventoryPacket(player);
          if (!Settings.noConsoleSpam)
            ConsoleLogger.info(
                "ProtectInventoryEvent has been cancelled for " + player.getName() + " ...");
        }
      }
    } else {
      if (Settings.isForceSurvivalModeEnabled && !Settings.forceOnlyAfterLogin) {
        sched.scheduleSyncDelayedTask(
            plugin,
            new Runnable() {

              @Override
              public void run() {
                AuthMePlayerListener.causeByAuthMe.putIfAbsent(name, true);
                Utils.forceGM(player);
              }
            });
      }
      if (!Settings.unRegisteredGroup.isEmpty()) {
        Utils.setGroup(player, Utils.GroupType.UNREGISTERED);
      }
      if (!Settings.isForcedRegistrationEnabled) {
        return;
      }
      if (!Settings.noTeleport)
        if (!needFirstspawn() && Settings.isTeleportToSpawnEnabled
            || (Settings.isForceSpawnLocOnJoinEnabled
                && Settings.getForcedWorlds.contains(player.getWorld().getName()))) {
          sched.scheduleSyncDelayedTask(
              plugin,
              new Runnable() {

                @Override
                public void run() {
                  SpawnTeleportEvent tpEvent =
                      new SpawnTeleportEvent(
                          player,
                          player.getLocation(),
                          spawnLoc,
                          PlayerCache.getInstance().isAuthenticated(name));
                  plugin.getServer().getPluginManager().callEvent(tpEvent);
                  if (!tpEvent.isCancelled()) {
                    if (player.isOnline() && tpEvent.getTo() != null) {
                      if (tpEvent.getTo().getWorld() != null) player.teleport(tpEvent.getTo());
                    }
                  }
                }
              });
        }
    }
    String[] msg;
    if (Settings.emailRegistration) {
      msg = isAuthAvailable ? m.send("login_msg") : m.send("reg_email_msg");
    } else {
      msg = isAuthAvailable ? m.send("login_msg") : m.send("reg_msg");
    }
    int time = Settings.getRegistrationTimeout * 20;
    int msgInterval = Settings.getWarnMessageInterval;
    if (time != 0) {
      BukkitTask id =
          sched.runTaskLaterAsynchronously(plugin, new TimeoutTask(plugin, name, player), time);
      if (!LimboCache.getInstance().hasLimboPlayer(name))
        LimboCache.getInstance().addLimboPlayer(player);
      LimboCache.getInstance().getLimboPlayer(name).setTimeoutTaskId(id);
    }
    if (!LimboCache.getInstance().hasLimboPlayer(name))
      LimboCache.getInstance().addLimboPlayer(player);
    if (isAuthAvailable) {
      Utils.setGroup(player, GroupType.NOTLOGGEDIN);
    } else {
      Utils.setGroup(player, GroupType.UNREGISTERED);
    }
    sched.scheduleSyncDelayedTask(
        plugin,
        new Runnable() {

          @Override
          public void run() {
            if (player.isOp()) player.setOp(false);
            if (player.getGameMode() != GameMode.CREATIVE && !Settings.isMovementAllowed) {
              player.setAllowFlight(true);
              player.setFlying(true);
            }
            player.setNoDamageTicks(Settings.getRegistrationTimeout * 20);
            if (Settings.useEssentialsMotd) player.performCommand("motd");
            if (Settings.applyBlindEffect)
              player.addPotionEffect(
                  new PotionEffect(
                      PotionEffectType.BLINDNESS, Settings.getRegistrationTimeout * 20, 2));
            if (!Settings.isMovementAllowed && Settings.isRemoveSpeedEnabled) {
              player.setWalkSpeed(0.0f);
              player.setFlySpeed(0.0f);
            }
          }
        });
    if (Settings.isSessionsEnabled
        && isAuthAvailable
        && (PlayerCache.getInstance().isAuthenticated(name) || database.isLogged(name))) {
      if (plugin.sessions.containsKey(name)) plugin.sessions.get(name).cancel();
      plugin.sessions.remove(name);
      PlayerAuth auth = database.getAuth(name);
      if (auth != null && auth.getIp().equals(ip)) {
        m.send(player, "valid_session");
        PlayerCache.getInstance().removePlayer(name);
        database.setUnlogged(name);
        plugin.management.performLogin(player, "dontneed", true);
      } else if (Settings.sessionExpireOnIpChange) {
        PlayerCache.getInstance().removePlayer(name);
        database.setUnlogged(name);
        m.send(player, "invalid_session");
      }
      return;
    }
    BukkitTask msgT =
        sched.runTaskAsynchronously(plugin, new MessageTask(plugin, name, msg, msgInterval));
    LimboCache.getInstance().getLimboPlayer(name).setMessageTaskId(msgT);
  }
Beispiel #23
0
 private void printStackTraceSync(Throwable t, boolean expected) {
   BukkitScheduler bs = plugin.getServer().getScheduler();
   try {
     String prefix = plugin.getName() + " [AutoUpdate] ";
     StringWriter sw = new StringWriter();
     PrintWriter pw = new PrintWriter(sw);
     t.printStackTrace(pw);
     String[] sts = sw.toString().replace("\r", "").split("\n");
     String[] out;
     if (expected) out = new String[sts.length + 31];
     else out = new String[sts.length + 33];
     out[0] = prefix;
     out[1] = prefix + "Internal error!";
     out[2] =
         prefix
             + "If this bug hasn't been reported please open a ticket at http://dev.bukkit.org/server-mods/iFail";
     out[3] = prefix + "Include the following into your bug report:";
     out[4] = prefix + "          ======= SNIP HERE =======";
     int i = 5;
     for (; i - 5 < sts.length; i++) out[i] = prefix + sts[i - 5];
     out[++i] = prefix + "          ======= DUMP =======";
     out[++i] = prefix + "version        : " + version;
     out[++i] = prefix + "delay          : " + delay;
     out[++i] = prefix + "ymlPrefix      : " + ymlPrefix;
     out[++i] = prefix + "ymlSuffix      : " + ymlSuffix;
     out[++i] = prefix + "bukkitdevPrefix: " + bukkitdevPrefix;
     out[++i] = prefix + "bukkitdevSuffix: " + bukkitdevSuffix;
     out[++i] = prefix + "bukkitdevSlug  : " + bukkitdevSlug;
     out[++i] = prefix + "COLOR_INFO     : " + COLOR_INFO.name();
     out[++i] = prefix + "COLO_OK        : " + COLOR_OK.name();
     out[++i] = prefix + "COLOR_ERROR    : " + COLOR_ERROR.name();
     out[++i] = prefix + "bukget         : " + bukget;
     out[++i] = prefix + "bukgetFallback : " + bukgetFallback;
     out[++i] = prefix + "pid            : " + pid;
     out[++i] = prefix + "av             : " + av;
     out[++i] = prefix + "config         : " + config;
     out[++i] = prefix + "lock           : " + lock.get();
     out[++i] = prefix + "needUpdate     : " + needUpdate;
     out[++i] = prefix + "updatePending  : " + updatePending;
     out[++i] = prefix + "UpdateUrl      : " + updateURL;
     out[++i] = prefix + "updateVersion  : " + updateVersion;
     out[++i] = prefix + "pluginURL      : " + pluginURL;
     out[++i] = prefix + "type           : " + type;
     out[++i] = prefix + "          ======= SNIP HERE =======";
     out[++i] = prefix;
     if (!expected) {
       out[++i] = prefix + "DISABLING UPDATER!";
       out[++i] = prefix;
     }
     bs.scheduleSyncDelayedTask(plugin, new SyncMessageDelayer(null, out));
   } catch (Throwable e) // This prevents endless loops.
   {
     e.printStackTrace();
   }
   if (!expected) {
     bs.cancelTask(pid);
     bs.scheduleAsyncDelayedTask(
         plugin,
         new Runnable() {
           public void run() {
             while (!lock.compareAndSet(false, true)) {
               try {
                 Thread.sleep(1L);
               } catch (InterruptedException e) {
               }
             }
             pid = -1;
             config = null;
             needUpdate = updatePending = false;
             updateURL = updateVersion = pluginURL = type = null;
           }
         });
   }
 }
Beispiel #24
0
 public void cancelTasks(BukkitScheduler scheduler) {
   for (Integer id : getTaskIds()) scheduler.cancelTask(id);
   clearTaskIds();
 }
Beispiel #25
0
  @EventHandler
  public void crouch(PlayerToggleSneakEvent e) {
    if (e.isSneaking()) {
      final Player p = e.getPlayer();
      if (Util.getKit(p) instanceof Poseidon) {
        if (p.getLevel() >= 1) {
          if (p.getLocation().getBlock().getType() == Material.WATER
              || p.getLocation().getBlock().getType() == Material.STATIONARY_WATER) {
            p.setLevel(0);
            Vector v = p.getLocation().getDirection();
            p.setVelocity(new Vector(0, v.getY() + 4, 0));
            p.setAllowFlight(true);
            p.setFlying(true);
            p.addPotionEffect(new PotionEffect(PotionEffectType.INCREASE_DAMAGE, 20 * 5, 0));
            p.addPotionEffect(new PotionEffect(PotionEffectType.REGENERATION, 20 * 5, 1));
            p.addPotionEffect(new PotionEffect(PotionEffectType.SPEED, 20 * 5, 0));
            p.playSound(p.getLocation(), Sound.ZOMBIE_REMEDY, 1F, 1F);
            p.sendMessage(ChatColor.GREEN + "Poseidon pounce!");
            BukkitScheduler scheduler = Bukkit.getScheduler();
            scheduler.scheduleSyncDelayedTask(
                plugin,
                new Runnable() {

                  public void run() {
                    // TODO Auto-generated method stub
                    if (Util.getKit(p) instanceof Poseidon) {
                      p.setFlying(false);
                      p.setAllowFlight(false);
                    }
                  }
                },
                20 * 3L);
            scheduler.scheduleSyncDelayedTask(
                plugin,
                new Runnable() {

                  public void run() {
                    // TODO Auto-generated method stub
                    if (Util.getKit(p) instanceof Poseidon) {
                      p.setLevel(1);
                    }
                  }
                },
                20 * 10);
            /*p.setLevel(0);
            WaterSprite(p);
            BukkitScheduler  scheduler = Bukkit.getScheduler();
            scheduler.scheduleSyncDelayedTask(plugin, new Runnable() {

            	public void run() {
            		// TODO Auto-generated method stub
            		if(Util.getKit(p) instanceof Poseidon) {
            			p.setLevel(1);
            		}
            	}
            }, 20* 7);*/
          }
        } else {
          p.sendMessage(ChatColor.GRAY + "Poseidon pounce is recharging please wait 10 seconds.");
        }
      }
    }
  }
  public boolean setUp() {
    try {
      FileUtils.deleteFolder(invDirectory);
      FileUtils.deleteFolder(serverDirectory);
      invDirectory.mkdirs();
      Assert.assertTrue(invDirectory.exists());

      MockGateway.MOCK_STANDARD_METHODS = false;

      plugin = PowerMockito.spy(new MultiverseInventories());
      core = PowerMockito.spy(new MultiverseCore());

      // Let's let all MV files go to bin/test
      doReturn(invDirectory).when(plugin).getDataFolder();
      // Let's let all MV files go to bin/test
      doReturn(coreDirectory).when(core).getDataFolder();

      // Return a fake PDF file.
      PluginDescriptionFile pdf =
          PowerMockito.spy(
              new PluginDescriptionFile(
                  "Multiverse-Inventories",
                  "2.4-test",
                  "com.onarandombox.multiverseinventories.MultiverseInventories"));
      when(pdf.getAuthors()).thenReturn(new ArrayList<String>());
      doReturn(pdf).when(plugin).getDescription();
      doReturn(core).when(plugin).getCore();
      doReturn(true).when(plugin).isEnabled();
      PluginDescriptionFile pdfCore =
          PowerMockito.spy(
              new PluginDescriptionFile(
                  "Multiverse-Core", "2.2-Test", "com.onarandombox.MultiverseCore.MultiverseCore"));
      when(pdfCore.getAuthors()).thenReturn(new ArrayList<String>());
      doReturn(pdfCore).when(core).getDescription();
      doReturn(true).when(core).isEnabled();
      plugin.setServerFolder(serverDirectory);

      // Add Core to the list of loaded plugins
      JavaPlugin[] plugins = new JavaPlugin[] {plugin, core};

      // Mock the Plugin Manager
      PluginManager mockPluginManager = PowerMockito.mock(PluginManager.class);
      when(mockPluginManager.getPlugins()).thenReturn(plugins);
      when(mockPluginManager.getPlugin("Multiverse-Inventories")).thenReturn(plugin);
      when(mockPluginManager.getPlugin("Multiverse-Core")).thenReturn(core);
      when(mockPluginManager.getPermission(anyString())).thenReturn(null);

      // Make some fake folders to fool the fake MV into thinking these worlds exist
      File worldNormalFile = new File(plugin.getServerFolder(), "world");
      Util.log("Creating world-folder: " + worldNormalFile.getAbsolutePath());
      worldNormalFile.mkdirs();
      MockWorldFactory.makeNewMockWorld("world", Environment.NORMAL, WorldType.NORMAL);
      File worldNetherFile = new File(plugin.getServerFolder(), "world_nether");
      Util.log("Creating world-folder: " + worldNetherFile.getAbsolutePath());
      worldNetherFile.mkdirs();
      MockWorldFactory.makeNewMockWorld("world_nether", Environment.NETHER, WorldType.NORMAL);
      File worldSkylandsFile = new File(plugin.getServerFolder(), "world_the_end");
      Util.log("Creating world-folder: " + worldSkylandsFile.getAbsolutePath());
      worldSkylandsFile.mkdirs();
      MockWorldFactory.makeNewMockWorld("world_the_end", Environment.THE_END, WorldType.NORMAL);
      File world2File = new File(plugin.getServerFolder(), "world2");
      Util.log("Creating world-folder: " + world2File.getAbsolutePath());
      world2File.mkdirs();
      MockWorldFactory.makeNewMockWorld("world2", Environment.NORMAL, WorldType.NORMAL);

      // Initialize the Mock server.
      mockServer = mock(Server.class);
      when(mockServer.getName()).thenReturn("TestBukkit");
      Logger.getLogger("Minecraft").setParent(Util.logger);
      when(mockServer.getLogger()).thenReturn(Util.logger);
      when(mockServer.getWorldContainer()).thenReturn(worldsDirectory);
      when(plugin.getServer()).thenReturn(mockServer);
      when(core.getServer()).thenReturn(mockServer);
      when(mockServer.getPluginManager()).thenReturn(mockPluginManager);
      Answer<Player> playerAnswer =
          new Answer<Player>() {
            public Player answer(InvocationOnMock invocation) throws Throwable {
              String arg;
              try {
                arg = (String) invocation.getArguments()[0];
              } catch (Exception e) {
                return null;
              }
              Player player = players.get(arg);
              if (player == null) {
                player = new MockPlayer(arg, mockServer);
                players.put(arg, player);
              }
              return player;
            }
          };
      when(mockServer.getPlayer(anyString())).thenAnswer(playerAnswer);
      when(mockServer.getOfflinePlayer(anyString())).thenAnswer(playerAnswer);
      when(mockServer.getOfflinePlayers())
          .thenAnswer(
              new Answer<OfflinePlayer[]>() {
                public OfflinePlayer[] answer(InvocationOnMock invocation) throws Throwable {
                  return players.values().toArray(new Player[players.values().size()]);
                }
              });
      when(mockServer.getOnlinePlayers())
          .thenAnswer(
              new Answer<Player[]>() {
                public Player[] answer(InvocationOnMock invocation) throws Throwable {
                  return players.values().toArray(new Player[players.values().size()]);
                }
              });

      // Give the server some worlds
      when(mockServer.getWorld(anyString()))
          .thenAnswer(
              new Answer<World>() {
                public World answer(InvocationOnMock invocation) throws Throwable {
                  String arg;
                  try {
                    arg = (String) invocation.getArguments()[0];
                  } catch (Exception e) {
                    return null;
                  }
                  return MockWorldFactory.getWorld(arg);
                }
              });

      when(mockServer.getWorld(any(UUID.class)))
          .thenAnswer(
              new Answer<World>() {
                @Override
                public World answer(InvocationOnMock invocation) throws Throwable {
                  UUID arg;
                  try {
                    arg = (UUID) invocation.getArguments()[0];
                  } catch (Exception e) {
                    return null;
                  }
                  return MockWorldFactory.getWorld(arg);
                }
              });

      when(mockServer.getWorlds())
          .thenAnswer(
              new Answer<List<World>>() {
                public List<World> answer(InvocationOnMock invocation) throws Throwable {
                  return MockWorldFactory.getWorlds();
                }
              });

      when(mockServer.createWorld(Matchers.isA(WorldCreator.class)))
          .thenAnswer(
              new Answer<World>() {
                public World answer(InvocationOnMock invocation) throws Throwable {
                  WorldCreator arg;
                  try {
                    arg = (WorldCreator) invocation.getArguments()[0];
                  } catch (Exception e) {
                    return null;
                  }
                  // Add special case for creating null worlds.
                  // Not sure I like doing it this way, but this is a special case
                  if (arg.name().equalsIgnoreCase("nullworld")) {
                    return MockWorldFactory.makeNewNullMockWorld(
                        arg.name(), arg.environment(), arg.type());
                  }
                  return MockWorldFactory.makeNewMockWorld(
                      arg.name(), arg.environment(), arg.type());
                }
              });

      when(mockServer.unloadWorld(anyString(), anyBoolean())).thenReturn(true);

      // add mock scheduler
      BukkitScheduler mockScheduler = mock(BukkitScheduler.class);
      when(mockScheduler.scheduleSyncDelayedTask(any(Plugin.class), any(Runnable.class), anyLong()))
          .thenAnswer(
              new Answer<Integer>() {
                public Integer answer(InvocationOnMock invocation) throws Throwable {
                  Runnable arg;
                  try {
                    arg = (Runnable) invocation.getArguments()[1];
                  } catch (Exception e) {
                    return null;
                  }
                  arg.run();
                  return null;
                }
              });
      when(mockScheduler.scheduleSyncDelayedTask(any(Plugin.class), any(Runnable.class)))
          .thenAnswer(
              new Answer<Integer>() {
                public Integer answer(InvocationOnMock invocation) throws Throwable {
                  Runnable arg;
                  try {
                    arg = (Runnable) invocation.getArguments()[1];
                  } catch (Exception e) {
                    return null;
                  }
                  arg.run();
                  return null;
                }
              });
      when(mockServer.getScheduler()).thenReturn(mockScheduler);

      // Set InventoriesListener
      InventoriesListener il = PowerMockito.spy(new InventoriesListener(plugin));
      Field inventoriesListenerField =
          MultiverseInventories.class.getDeclaredField("inventoriesListener");
      inventoriesListenerField.setAccessible(true);
      inventoriesListenerField.set(plugin, il);

      // Set Core
      Field coreField = MultiverseInventories.class.getDeclaredField("core");
      coreField.setAccessible(true);
      coreField.set(plugin, core);

      // Set server
      Field serverfield = JavaPlugin.class.getDeclaredField("server");
      serverfield.setAccessible(true);
      serverfield.set(plugin, mockServer);

      // Set worldManager
      WorldManager wm = PowerMockito.spy(new WorldManager(core));
      Field worldmanagerfield = MultiverseCore.class.getDeclaredField("worldManager");
      worldmanagerfield.setAccessible(true);
      worldmanagerfield.set(core, wm);

      // Set playerListener
      MVPlayerListener pl = PowerMockito.spy(new MVPlayerListener(core));
      Field playerlistenerfield = MultiverseCore.class.getDeclaredField("playerListener");
      playerlistenerfield.setAccessible(true);
      playerlistenerfield.set(core, pl);

      // Set entityListener
      MVEntityListener el = PowerMockito.spy(new MVEntityListener(core));
      Field entitylistenerfield = MultiverseCore.class.getDeclaredField("entityListener");
      entitylistenerfield.setAccessible(true);
      entitylistenerfield.set(core, el);

      // Set weatherListener
      MVWeatherListener wl = PowerMockito.spy(new MVWeatherListener(core));
      Field weatherlistenerfield = MultiverseCore.class.getDeclaredField("weatherListener");
      weatherlistenerfield.setAccessible(true);
      weatherlistenerfield.set(core, wl);

      // Init our command sender
      final Logger commandSenderLogger = Logger.getLogger("CommandSender");
      commandSenderLogger.setParent(Util.logger);
      commandSender = mock(CommandSender.class);
      doAnswer(
              new Answer<Void>() {
                public Void answer(InvocationOnMock invocation) throws Throwable {
                  commandSenderLogger.info(
                      ChatColor.stripColor((String) invocation.getArguments()[0]));
                  return null;
                }
              })
          .when(commandSender)
          .sendMessage(anyString());
      when(commandSender.getServer()).thenReturn(mockServer);
      when(commandSender.getName()).thenReturn("MockCommandSender");
      when(commandSender.isPermissionSet(anyString())).thenReturn(true);
      when(commandSender.isPermissionSet(Matchers.isA(Permission.class))).thenReturn(true);
      when(commandSender.hasPermission(anyString())).thenReturn(true);
      when(commandSender.hasPermission(Matchers.isA(Permission.class))).thenReturn(true);
      when(commandSender.addAttachment(plugin)).thenReturn(null);
      when(commandSender.isOp()).thenReturn(true);

      Bukkit.setServer(mockServer);

      // Load Multiverse Core
      core.onLoad();
      plugin.onLoad();

      // Enable it.
      core.onEnable();
      plugin.onEnable();

      return true;
    } catch (Exception e) {
      e.printStackTrace();
    }

    return false;
  }
Beispiel #27
0
 public void StartSmoothingonCustomWorlds() {
   if (getPlugin().getSaveItConfig().SavingStats)
     getPlugin().savingcheck = System.currentTimeMillis();
   Delay2 = 1;
   _bukkitScheduler.runTaskLater(getPlugin(), new SaveCustomWorlds(), 20L * Delay2);
 }
  /** Handle the command */
  @Override
  public void handle(final CallInfo call) {

    if (call.getArgs().length <= 1) {
      call.getSender()
          .sendMessage(Prism.messenger.playerError("Invalid command. Use /pr ? for help"));
      return;
    }

    boolean recorderActive = false;
    if (plugin.recordingTask != null) {
      final int taskId = plugin.recordingTask.getTaskId();
      final BukkitScheduler scheduler = Bukkit.getScheduler();
      if (scheduler.isCurrentlyRunning(taskId) || scheduler.isQueued(taskId)) {
        recorderActive = true;
      }
    }

    // Allow for canceling recorders
    if (call.getArg(1).equals("cancel")) {
      if (recorderActive) {
        plugin.recordingTask.cancel();
        plugin.recordingTask = null;
        call.getSender()
            .sendMessage(Prism.messenger.playerMsg("Current recording task has been canceled."));
        call.getSender()
            .sendMessage(
                Prism.messenger.playerError(
                    "WARNING: Actions will collect until queue until recorder restarted manually."));
      } else {
        call.getSender()
            .sendMessage(Prism.messenger.playerError("No recording task is currently running."));
      }
      return;
    }

    // Allow for force-restarting recorders
    if (call.getArg(1).equals("start")) {
      if (recorderActive) {
        call.getSender()
            .sendMessage(
                Prism.messenger.playerError(
                    "Recording tasks are currently running. Cannot start."));
      } else {

        // Run db tests...
        call.getSender()
            .sendMessage(Prism.messenger.playerMsg("Validating database connections..."));

        // Attempt to get db
        Connection conn = null;
        try {

          conn = Prism.dbc();
          if (conn == null || conn.isClosed()) {
            call.getSender()
                .sendMessage(
                    Prism.messenger.playerError(
                        "Valid database connection could not be found. Check the db/console and try again."));
            return;
          }

          call.getSender()
              .sendMessage(Prism.messenger.playerSuccess("Valid connection found. Yay!"));

          call.getSender()
              .sendMessage(Prism.messenger.playerMsg("Restarting recordering tasks..."));
          plugin.actionRecorderTask();

        } catch (final Exception e) {
          e.printStackTrace();
        } finally {
          if (conn != null)
            try {
              conn.close();
            } catch (final Exception ignored) {
            }
          ;
        }
      }
      return;
    }
  }
Beispiel #29
0
 private void update(CommandSender sender) {
   if (!hasPermission(sender, "autoupdate.update." + plugin.getName())) {
     sender.sendMessage(COLOR_ERROR + plugin.getName() + ": You are not allowed to update me!");
     return;
   }
   final BukkitScheduler bs = plugin.getServer().getScheduler();
   final String pn = sender instanceof Player ? ((Player) sender).getName() : null;
   bs.scheduleAsyncDelayedTask(
       plugin,
       new Runnable() {
         public void run() {
           try {
             while (!lock.compareAndSet(false, true)) {
               try {
                 Thread.sleep(1L);
               } catch (InterruptedException e) {
               }
               continue;
             }
             String out;
             try {
               File to =
                   new File(
                       plugin.getServer().getUpdateFolderFile(),
                       updateURL.substring(updateURL.lastIndexOf('/') + 1, updateURL.length()));
               File tmp = new File(to.getAbsolutePath() + ".au");
               if (!tmp.exists()) {
                 plugin.getServer().getUpdateFolderFile().mkdirs();
                 tmp.createNewFile();
               }
               URL url = new URL(updateURL);
               InputStream is = url.openStream();
               OutputStream os = new FileOutputStream(tmp);
               byte[] buffer = new byte[4096];
               int fetched;
               while ((fetched = is.read(buffer)) != -1) os.write(buffer, 0, fetched);
               is.close();
               os.flush();
               os.close();
               if (to.exists()) to.delete();
               if (tmp.renameTo(to)) {
                 out =
                     COLOR_OK + plugin.getName() + " ready! Restart server to finish the update.";
                 needUpdate = false;
                 updatePending = true;
                 updateURL = type = null;
               } else {
                 out = COLOR_ERROR + plugin.getName() + " failed to update!";
                 if (tmp.exists()) tmp.delete();
                 if (to.exists()) to.delete();
               }
             } catch (Exception e) {
               out = COLOR_ERROR + plugin.getName() + " failed to update!";
               printStackTraceSync(e, true);
             }
             bs.scheduleSyncDelayedTask(plugin, new SyncMessageDelayer(pn, new String[] {out}));
             lock.set(false);
           } catch (Throwable t) {
             printStackTraceSync(t, false);
           }
         }
       });
 }
  public boolean check() {

    ArrayList<Integer> rowUpdates = new ArrayList<Integer>();
    try {
      String sPath = c.getString(urlPath + ".url");
      String key = c.getString(urlPath + ".key");
      URL url = new URL(sPath + "?woo_minecraft=check&key=" + key);
      HttpURLConnection con = (HttpURLConnection) url.openConnection();
      con.setRequestMethod("POST");
      con.setRequestProperty("User-Agent", "Mozilla/5.0");
      Collection<? extends Player> list = Bukkit.getOnlinePlayers();
      if (list.size() < 1) return false;

      StringBuilder sb = new StringBuilder();
      for (Player player : Bukkit.getServer().getOnlinePlayers()) {
        sb.append(player.getName() + ", ");
      }
      String playerList = sb.toString();
      Pattern pattern = Pattern.compile(", $");
      Matcher matcher = pattern.matcher(playerList);
      playerList = matcher.replaceAll("");
      String urlParams = playerList;
      con.setDoInput(true);
      con.setDoOutput(true);
      DataOutputStream wr = new DataOutputStream(con.getOutputStream());
      wr.writeBytes("names=" + urlParams);
      wr.flush();
      wr.close();

      BufferedReader in = new BufferedReader(new InputStreamReader(con.getInputStream()));
      // ENDNEW

      StringBuilder sb2 = new StringBuilder();
      String line;
      while ((line = in.readLine()) != null) {
        sb2.append(line);
      }
      in.close();

      JSONObject json = new JSONObject(sb2.toString());

      if (json.getString("status").equalsIgnoreCase("success")) {
        JSONArray jsonArr = json.getJSONArray("data");
        for (int i = 0; i < jsonArr.length(); i++) {
          JSONObject obj = jsonArr.getJSONObject(i);

          String playerName = obj.getString("player_name");
          String x = obj.getString("command");
          final String command = x.replace("%s", playerName);

          Player pN = Bukkit.getServer().getPlayer(playerName);

          if (x.substring(0, 3) == "give") {
            int count = 0;
            for (ItemStack iN : pN.getInventory()) {
              if (iN == null) count++;
            }

            if (count == 0) return false;
          }

          int id = obj.getInt("id");

          BukkitScheduler sch = Bukkit.getServer().getScheduler();
          sch.scheduleSyncDelayedTask(
              instance,
              new Runnable() {
                @Override
                public void run() {
                  Bukkit.getServer()
                      .dispatchCommand(Bukkit.getServer().getConsoleSender(), command);
                }
              },
              20L);
          rowUpdates.add(id);
        }
      } else {
        log.info("Check: No donations for online users.");
      }
      remove(rowUpdates);
    } catch (Exception e) {
      e.printStackTrace();
    }
    return false;
  }