示例#1
0
  private void teleportGroup(String command, L2PcInstance activeChar) {
    int groupId;
    String targetPlayerStr = null;
    L2PcInstance targetPlayer = null;

    try {
      groupId = Integer.parseInt(command.split(" ")[1]);
      targetPlayerStr = command.split(" ")[2];

      if (targetPlayerStr != null) {
        targetPlayer = L2World.getInstance().getPlayer(targetPlayerStr);
      }

      if (targetPlayer == null) {
        targetPlayer = activeChar;
      }
    } catch (Exception e) {
      activeChar.sendMessage("Usage: //mobgroup_teleport <groupId> [playerName]");
      return;
    }

    final MobGroup group = MobGroupTable.getInstance().getGroup(groupId);

    if (group == null) {
      activeChar.sendMessage("Invalid group specified.");
      return;
    }

    group.teleportGroup(activeChar);
  }
示例#2
0
  /**
   * Removes a TvTEvent player from it's team<br>
   * 1. Get team id of the player<br>
   * 2. Remove player from it's team<br>
   * <br>
   *
   * @param playerObjectId
   * @return boolean: true if success, otherwise false
   */
  public static boolean removeParticipant(int playerObjectId) {
    // Get the teamId of the player
    final byte teamId = getParticipantTeamId(playerObjectId);

    // Check if the player is participant
    if (teamId != -1) {
      // Remove the player from team
      _teams[teamId].removePlayer(playerObjectId);

      final L2PcInstance player = L2World.getInstance().getPlayer(playerObjectId);
      if (player != null) {
        player.removeEventListener(TvTEventListener.class);
      }
      return true;
    }

    return false;
  }
  @Override
  public void runImpl() {
    final L2PcInstance activeChar = getClient().getActiveChar();
    if ((activeChar == null) || !Config.ALLOW_MAIL || !Config.ALLOW_ATTACHMENTS) {
      return;
    }

    if (!getClient().getFloodProtectors().getTransaction().tryPerformAction("cancelpost")) {
      return;
    }

    final Message msg = MailManager.getInstance().getMessage(_msgId);
    if (msg == null) {
      return;
    }
    if (msg.getSenderId() != activeChar.getObjectId()) {
      Util.handleIllegalPlayerAction(
          activeChar,
          "Player " + activeChar.getName() + " tried to cancel not own post!",
          Config.DEFAULT_PUNISH);
      return;
    }

    if (!activeChar.isInsideZone(ZoneId.PEACE)) {
      activeChar.sendPacket(SystemMessageId.YOU_CANNOT_CANCEL_IN_A_NON_PEACE_ZONE_LOCATION);
      return;
    }

    if (activeChar.getActiveTradeList() != null) {
      activeChar.sendPacket(SystemMessageId.YOU_CANNOT_CANCEL_DURING_AN_EXCHANGE);
      return;
    }

    if (activeChar.hasItemRequest()) {
      activeChar.sendPacket(
          SystemMessageId.YOU_CANNOT_CANCEL_DURING_AN_ITEM_ENHANCEMENT_OR_ATTRIBUTE_ENHANCEMENT);
      return;
    }

    if (activeChar.getPrivateStoreType() != PrivateStoreType.NONE) {
      activeChar.sendPacket(
          SystemMessageId.YOU_CANNOT_CANCEL_BECAUSE_THE_PRIVATE_STORE_OR_WORKSHOP_IS_IN_PROGRESS);
      return;
    }

    if (!msg.hasAttachments()) {
      activeChar.sendPacket(
          SystemMessageId.YOU_CANNOT_CANCEL_SENT_MAIL_SINCE_THE_RECIPIENT_RECEIVED_IT);
      return;
    }

    final ItemContainer attachments = msg.getAttachments();
    if ((attachments == null) || (attachments.getSize() == 0)) {
      activeChar.sendPacket(
          SystemMessageId.YOU_CANNOT_CANCEL_SENT_MAIL_SINCE_THE_RECIPIENT_RECEIVED_IT);
      return;
    }

    int weight = 0;
    int slots = 0;

    for (L2ItemInstance item : attachments.getItems()) {
      if (item == null) {
        continue;
      }

      if (item.getOwnerId() != activeChar.getObjectId()) {
        Util.handleIllegalPlayerAction(
            activeChar,
            "Player "
                + activeChar.getName()
                + " tried to get not own item from cancelled attachment!",
            Config.DEFAULT_PUNISH);
        return;
      }

      if (item.getItemLocation() != ItemLocation.MAIL) {
        Util.handleIllegalPlayerAction(
            activeChar,
            "Player " + activeChar.getName() + " tried to get items not from mail !",
            Config.DEFAULT_PUNISH);
        return;
      }

      if (item.getLocationSlot() != msg.getId()) {
        Util.handleIllegalPlayerAction(
            activeChar,
            "Player " + activeChar.getName() + " tried to get items from different attachment!",
            Config.DEFAULT_PUNISH);
        return;
      }

      weight += item.getCount() * item.getItem().getWeight();
      if (!item.isStackable()) {
        slots += item.getCount();
      } else if (activeChar.getInventory().getItemByItemId(item.getId()) == null) {
        slots++;
      }
    }

    if (!activeChar.getInventory().validateCapacity(slots)) {
      activeChar.sendPacket(
          SystemMessageId.YOU_COULD_NOT_CANCEL_RECEIPT_BECAUSE_YOUR_INVENTORY_IS_FULL);
      return;
    }

    if (!activeChar.getInventory().validateWeight(weight)) {
      activeChar.sendPacket(
          SystemMessageId.YOU_COULD_NOT_CANCEL_RECEIPT_BECAUSE_YOUR_INVENTORY_IS_FULL);
      return;
    }

    // Proceed to the transfer
    final InventoryUpdate playerIU = Config.FORCE_INVENTORY_UPDATE ? null : new InventoryUpdate();
    for (L2ItemInstance item : attachments.getItems()) {
      if (item == null) {
        continue;
      }

      final long count = item.getCount();
      final L2ItemInstance newItem =
          attachments.transferItem(
              attachments.getName(),
              item.getObjectId(),
              count,
              activeChar.getInventory(),
              activeChar,
              null);
      if (newItem == null) {
        return;
      }

      if (playerIU != null) {
        if (newItem.getCount() > count) {
          playerIU.addModifiedItem(newItem);
        } else {
          playerIU.addNewItem(newItem);
        }
      }
      final SystemMessage sm =
          SystemMessage.getSystemMessage(SystemMessageId.YOU_HAVE_ACQUIRED_S2_S1);
      sm.addItemName(item.getId());
      sm.addLong(count);
      activeChar.sendPacket(sm);
    }

    msg.removeAttachments();

    // Send updated item list to the player
    if (playerIU != null) {
      activeChar.sendPacket(playerIU);
    } else {
      activeChar.sendPacket(new ItemList(activeChar, false));
    }

    // Update current load status on player
    activeChar.sendPacket(new ExUserInfoInvenWeight(activeChar));

    final L2PcInstance receiver = L2World.getInstance().getPlayer(msg.getReceiverId());
    if (receiver != null) {
      final SystemMessage sm =
          SystemMessage.getSystemMessage(SystemMessageId.S1_CANCELED_THE_SENT_MAIL);
      sm.addCharName(activeChar);
      receiver.sendPacket(sm);
      receiver.sendPacket(new ExChangePostState(true, _msgId, Message.DELETED));
    }

    MailManager.getInstance().deleteMessageInDb(_msgId);

    activeChar.sendPacket(new ExChangePostState(false, _msgId, Message.DELETED));
    activeChar.sendPacket(SystemMessageId.MAIL_SUCCESSFULLY_CANCELLED);
  }
示例#4
0
  @Override
  public boolean useBypass(String command, L2PcInstance activeChar, L2Character bypassOrigin) {
    final StringTokenizer st = new StringTokenizer(command);
    st.nextToken();

    if (!st.hasMoreTokens()) {
      _log.warning("Bypass[NpcViewMod] used without enough parameters.");
      return false;
    }

    final String actualCommand = st.nextToken();
    switch (actualCommand.toLowerCase()) {
      case "view":
        {
          final L2Object target;
          if (st.hasMoreElements()) {
            try {
              target = L2World.getInstance().findObject(Integer.parseInt(st.nextToken()));
            } catch (NumberFormatException e) {
              return false;
            }
          } else {
            target = activeChar.getTarget();
          }

          final L2Npc npc = target instanceof L2Npc ? (L2Npc) target : null;
          if (npc == null) {
            return false;
          }

          NpcViewMod.sendNpcView(activeChar, npc);
          break;
        }
      case "droplist":
        {
          if (st.countTokens() < 2) {
            _log.warning("Bypass[NpcViewMod] used without enough parameters.");
            return false;
          }

          final String dropListScopeString = st.nextToken();
          try {
            final DropListScope dropListScope =
                Enum.valueOf(DropListScope.class, dropListScopeString);
            final L2Object target =
                L2World.getInstance().findObject(Integer.parseInt(st.nextToken()));
            final L2Npc npc = target instanceof L2Npc ? (L2Npc) target : null;
            if (npc == null) {
              return false;
            }
            final int page = st.hasMoreElements() ? Integer.parseInt(st.nextToken()) : 0;
            sendNpcDropList(activeChar, npc, dropListScope, page);
          } catch (NumberFormatException e) {
            return false;
          } catch (IllegalArgumentException e) {
            _log.warning("Bypass[NpcViewMod] unknown drop list scope: " + dropListScopeString);
            return false;
          }
          break;
        }
    }

    return true;
  }