Пример #1
0
 private void alterBalance() throws CommandUsageException {
   try {
     account.setBalance(amount);
   } catch (IllegalArgumentException exception) {
     throw new CommandUsageException(plugin.getMessage(exception.getMessage()));
   }
   handler.save(account);
 }
Пример #2
0
  public void execute(CommandSender sender)
      throws CommandArgumentException, CommandPermissionException, CommandUsageException {

    if (playerName != null) {
      account = handler.getPlayerPersonalAccount(playerName);
      if (account == null)
        throw new CommandUsageException(
            this.plugin.getSimpleFormattedMessage("player-has-no-personal-account", playerName));
      this.alterBalance();
      Object[] tokens = {playerName, handler.formatAmount(account.getBalance())};
      sender.sendMessage(
          plugin.getSimpleFormattedMessage("setcommand-personal-account-success", tokens));
    } else {
      account = handler.getAccount(accountNumber);
      if (account == null)
        throw new CommandUsageException(this.plugin.getMessage("account-does-not-exist"));
      this.alterBalance();
      Object[] tokens = {accountNumber, handler.formatAmount(account.getBalance())};
      sender.sendMessage(
          plugin.getSimpleFormattedMessage("setcommand-bank-account-success", tokens));
    }
  }