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
  public static void handlePartyTeleportEvent(Player teleportingPlayer, Player targetPlayer) {
    McMMOPlayer mcMMOPlayer = UserManager.getPlayer(teleportingPlayer);

    McMMOPartyTeleportEvent event =
        new McMMOPartyTeleportEvent(
            teleportingPlayer, targetPlayer, mcMMOPlayer.getParty().getName());
    mcMMO.p.getServer().getPluginManager().callEvent(event);

    if (event.isCancelled()) {
      return;
    }

    teleportingPlayer.teleport(targetPlayer);

    teleportingPlayer.sendMessage(
        LocaleLoader.getString("Party.Teleport.Player", targetPlayer.getName()));
    targetPlayer.sendMessage(
        LocaleLoader.getString("Party.Teleport.Target", teleportingPlayer.getName()));

    mcMMOPlayer.getPartyTeleportRecord().actualizeLastUse();
  }