/**
   * Executes the command
   *
   * @param command owning command
   * @param plugin plugin reference
   * @param sender sender of the command
   * @param args arguments
   */
  @Override
  public void execute(
      ConfigurableCommand command, Plugin plugin, CommandSender sender, String[] args) {
    // Needs two arguments
    if (args.length < 2) {
      command.displayHelp(sender);
    }

    // Switch accounts if valid number
    else {
      OfflinePlayer player = VersionManager.getOfflinePlayer(args[0], false);

      if (player == null) {
        command.sendMessage(sender, NOT_PLAYER, "&4That is not a valid player name");
        return;
      }

      PlayerAccounts accounts = SkillAPI.getPlayerAccountData(player);
      try {
        int id = Integer.parseInt(args[1]);

        if (accounts.getAccountLimit() >= id && id > 0) {
          accounts.setAccount(id);
          command.sendMessage(
              sender,
              CHANGED,
              ChatColor.GOLD
                  + "{player}'s"
                  + ChatColor.DARK_GREEN
                  + " active account has been changed",
              Filter.PLAYER.setReplacement(player.getName()));
          if (player.isOnline()) {
            command.sendMessage(
                (Player) player,
                TARGET,
                ChatColor.DARK_GREEN
                    + "Your account has been forced to "
                    + ChatColor.GOLD
                    + "Account #{account}",
                RPGFilter.ACCOUNT.setReplacement(id + ""));
          }
          return;
        }
      } catch (Exception ex) {
        // Invalid ID
      }

      command.sendMessage(sender, NOT_ACCOUNT, ChatColor.RED + "That is not a valid account ID");
    }
  }
Beispiel #2
0
  /**
   * Executes the command
   *
   * @param command owning command
   * @param plugin plugin reference
   * @param sender sender of the command
   * @param args arguments provided
   */
  @Override
  public void execute(
      ConfigurableCommand command, Plugin plugin, CommandSender sender, String[] args) {

    Parties parties = (Parties) plugin;
    Player player = (Player) sender;

    // Check the sender's party status
    Party party = parties.getParty(player);
    if (party != null && party.isInvited(player)) {
      party.decline(player);
      party.sendMessages(
          parties.getMessage(
              PartyNodes.PLAYER_DECLINED, true, Filter.PLAYER.setReplacement(player.getName())));
      parties.sendMessage(player, IndividualNodes.DECLINED);
    } else parties.sendMessage(player, ErrorNodes.NO_INVITES);
  }