@Override
  public void run() {
    if (messageIndex >= finalIndex) {
      Commons.getInstance().getThreadManager().cancelTask(taskId);
      return;
    }

    Player player = Players.getPlayer(playerId);
    if (messageCooldown.isOnCooldown(player)) {
      return;
    }
    try {
      String message = messages[messageIndex];
      Chat.message(player, message);
      Sounds.playSound(player, sound);
      messageCooldown.setOnCooldown(player);
      messageIndex++;
    } catch (IndexOutOfBoundsException e) {
      Commons.getInstance()
          .debug(
              "Uh oh! Message index["
                  + messageIndex
                  + "] doesn't exist!\n"
                  + StringUtil.joinString(messages, "\n"));
    }
  }
  @EventHandler
  public void onPlayerMove(PlayerMoveEvent event) {
    String playerName = event.getPlayer().getName();

    if (!moveCooldown.isOnCooldown(playerName)) {
      GamePlayer gamePlayer = FakeboardHandler.getPlayer(playerName);
      if (GameSetupHandler.isGameInProgress()) {
        // TODO prevent the null check from being needed
        if (gamePlayer != null && gamePlayer.isAfk()) {
          gamePlayer.setAfk(false, false);
        }
      }
      moveCooldown.setOnCooldown(playerName);
    }
  }
 @EventHandler
 public void onWeaponDamageEntity(WeaponDamageEntityEvent event) {
   if (event.getVictim() instanceof Player) {
     GamePlayer playerShooter = FakeboardHandler.getPlayer(event.getPlayer());
     GamePlayer playerShot = FakeboardHandler.getPlayer((Player) event.getVictim());
     String shooterName = playerShooter.getName();
     String shotName = playerShot.getName();
     if (playerShooter.getTeam() == playerShot.getTeam()
         || respawnInvincibilityCooldown.isOnCooldown(shooterName)
         || respawnInvincibilityCooldown.isOnCooldown(shotName)
         || playerShooter.isAfk()
         || playerShot.isAfk()) {
       event.setCancelled(true);
     } else {
       AssistManager.addData(shotName, shooterName);
     }
   }
 }
  @EventHandler
  public void onPlayerInteract(PlayerInteractEvent event) {
    Player player = event.getPlayer();
    GamePlayer GamePlayer = FakeboardHandler.getPlayer(player);
    String playerName = GamePlayer.getName();

    if (event.getAction() == Action.RIGHT_CLICK_AIR
        || event.getAction() == Action.RIGHT_CLICK_BLOCK) {
      if (player.getItemInHand() != null
          && Items.itemNameContains(player.getItemInHand(), "Select & Edit Loadouts")) {
        event.setCancelled(true);
        // Open the loadout menu for the player
        GameSetupHandler.openLoadoutOptionMenu(player);
      }
    } else if (GameSetupHandler.isGameInProgress()) {
      if (!playerCooldown.isOnCooldown(playerName)) {
        if (GamePlayer.isAfk()) {
          GamePlayer.setAfk(false, false);
        }
        playerCooldown.setOnCooldown(playerName);
      }
    }
  }
 @EventHandler
 public void forceRespawn(final ForceRespawnEvent event) {
   Player player = event.getPlayer();
   String playerName = player.getName();
   GamePlayer GamePlayer = FakeboardHandler.getPlayer(playerName);
   event.setForcedRespawn(true);
   if (GameSetupHandler.isGameInProgress()) {
     Game.runnableManager.runTaskLater(new RestoreInventory(playerName), 10);
   }
   respawnInvincibilityCooldown.setOnCooldown(playerName);
   if (GamePlayer.isAfk()) {
     GamePlayer.setAfk(false, false);
   }
 }