Ejemplo n.º 1
0
  @Override
  public void execute(CommandSender sender, ICommandArguments args) throws CommandException {

    CommandException.checkNotConsole(getPlugin(), this, sender);

    String name = args.getString("friendName");
    int rawLevel;

    if (args.hasInteger("level")) {
      rawLevel = args.getInteger("level");
    } else {

      String levelName = args.getString("level");

      IFriendLevel level = Nucleus.getProviders().getFriends().getLevel(levelName);
      if (level == null) throw new CommandException(NucLang.get(_LEVEL_NOT_FOUND, levelName));

      rawLevel = level.getRawLevel();
    }

    UUID friendId = PlayerUtils.getPlayerId(name);
    if (friendId == null) throw new CommandException(NucLang.get(_PLAYER_NOT_FOUND, name));

    Player player = (Player) sender;

    IFriend friend = Friends.get(player, friendId);
    if (friend != null) {
      friend.setRawLevel(rawLevel);
      tellSuccess(sender, NucLang.get(_SUCCESS_SET, name));
    } else {
      Friends.add(player, friendId, rawLevel);
      tellSuccess(sender, NucLang.get(_SUCCESS_ADD, name));
    }
  }
Ejemplo n.º 2
0
  @Override
  public void execute(CommandSender sender, ICommandArguments args) throws CommandException {

    CommandException.checkNotConsole(getPlugin(), this, sender);

    String name = args.getString("friendName");

    UUID friendId = PlayerUtils.getPlayerId(name);
    if (friendId == null) throw new CommandException(NucLang.get(_PLAYER_NOT_FOUND, name));

    Player player = (Player) sender;

    if (!Friends.remove(player, friendId)) throw new CommandException(_NOT_FRIEND, name);

    tellSuccess(sender, NucLang.get(_SUCCESS, name));
  }