Exemplo n.º 1
0
  @Override
  public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
    switch (args.length) {
      case 2:
        String targetName = CommandUtils.getMatchedPlayerName(args[1]);
        McMMOPlayer mcMMOTarget = UserManager.getOfflinePlayer(targetName);

        if (!CommandUtils.checkPlayerExistence(sender, targetName, mcMMOTarget)) {
          return false;
        }

        Player target = mcMMOTarget.getPlayer();
        Player player = (Player) sender;
        McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player);
        String playerName = player.getName();

        if (player.equals(target)) {
          sender.sendMessage(LocaleLoader.getString("Party.Invite.Self"));
          return true;
        }

        if (PartyManager.inSameParty(player, target)) {
          sender.sendMessage(LocaleLoader.getString("Party.Player.InSameParty", targetName));
          return true;
        }

        if (!PartyManager.canInvite(mcMMOPlayer)) {
          player.sendMessage(LocaleLoader.getString("Party.Locked"));
          return true;
        }

        Party playerParty = mcMMOPlayer.getParty();
        mcMMOTarget.setPartyInvite(playerParty);

        sender.sendMessage(LocaleLoader.getString("Commands.Invite.Success"));
        target.sendMessage(
            LocaleLoader.getString("Commands.Party.Invite.0", playerParty.getName(), playerName));
        target.sendMessage(LocaleLoader.getString("Commands.Party.Invite.1"));
        return true;

      default:
        sender.sendMessage(
            LocaleLoader.getString(
                "Commands.Usage.2",
                "party",
                "invite",
                "<" + LocaleLoader.getString("Commands.Usage.Player") + ">"));
        return true;
    }
  }
Exemplo n.º 2
0
  @Override
  public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
    switch (args.length) {
      case 0:
        if (CommandUtils.noConsoleUsage(sender)) {
          return true;
        }

        if (!hasSelfPermission(sender)) {
          sender.sendMessage(command.getPermissionMessage());
          return true;
        }

        applyCommandAction(UserManager.getPlayer(sender.getName()));
        return true;

      case 1:
        if (!hasOtherPermission(sender)) {
          sender.sendMessage(command.getPermissionMessage());
          return true;
        }

        String playerName = CommandUtils.getMatchedPlayerName(args[0]);
        McMMOPlayer mcMMOPlayer = UserManager.getPlayer(playerName);

        if (!CommandUtils.checkPlayerExistence(sender, playerName, mcMMOPlayer)) {
          return true;
        }

        if (CommandUtils.isOffline(sender, mcMMOPlayer.getPlayer())) {
          return true;
        }

        applyCommandAction(mcMMOPlayer);
        sendSuccessMessage(sender, playerName);
        return true;

      default:
        return false;
    }
  }