예제 #1
0
  public boolean sendActivePetitionMessage(L2PcInstance player, String messageText) {
    // if (!isPlayerInConsultation(player))
    // return false;

    CreatureSay cs;

    for (Petition currPetition : getPendingPetitions().values()) {
      if (currPetition == null) continue;

      if (currPetition.getPetitioner() != null
          && currPetition.getPetitioner().getObjectId() == player.getObjectId()) {
        cs =
            new CreatureSay(
                player.getObjectId(), Say2.PETITION_PLAYER, player.getName(), messageText);
        currPetition.addLogMessage(cs);

        currPetition.sendResponderPacket(cs);
        currPetition.sendPetitionerPacket(cs);
        return true;
      }

      if (currPetition.getResponder() != null
          && currPetition.getResponder().getObjectId() == player.getObjectId()) {
        cs = new CreatureSay(player.getObjectId(), Say2.PETITION_GM, player.getName(), messageText);
        currPetition.addLogMessage(cs);

        currPetition.sendResponderPacket(cs);
        currPetition.sendPetitionerPacket(cs);
        return true;
      }
    }

    return false;
  }
예제 #2
0
  public int submitPetition(L2PcInstance petitioner, String petitionText, int petitionType) {
    // Create a new petition instance and add it to the list of pending petitions.
    Petition newPetition = new Petition(petitioner, petitionText, petitionType);
    int newPetitionId = newPetition.getId();
    getPendingPetitions().put(newPetitionId, newPetition);

    // Notify all GMs that a new petition has been submitted.
    String msgContent =
        petitioner.getName() + " has submitted a new petition."; // (ID: " + newPetitionId + ").";
    GmListTable.broadcastToGMs(
        new CreatureSay(petitioner.getObjectId(), 17, "Petition System", msgContent));

    return newPetitionId;
  }
예제 #3
0
  @Override
  protected void runImpl() {
    final L2PcInstance activeChar = getClient().getActiveChar();
    if (activeChar == null) return;

    final L2PcInstance friend = L2World.getInstance().getPlayer(_name);

    // can't use friend invite for locating invisible characters
    if (friend == null || !friend.isOnline() || friend.getAppearance().getInvisible()) {
      // Target is not found in the game.
      activeChar.sendPacket(SystemMessageId.THE_USER_YOU_REQUESTED_IS_NOT_IN_GAME);
      return;
    }

    if (friend == activeChar) {
      // You cannot add yourself to your own friend list.
      activeChar.sendPacket(SystemMessageId.YOU_CANNOT_ADD_YOURSELF_TO_OWN_FRIEND_LIST);
      return;
    }

    if (BlockList.isBlocked(activeChar, friend)) {
      activeChar.sendMessage("You have blocked " + _name + ".");
      return;
    }

    if (BlockList.isBlocked(friend, activeChar)) {
      activeChar.sendMessage("You are in " + _name + "'s block list.");
      return;
    }

    if (activeChar.getFriendList().contains(friend.getObjectId())) {
      // Player already is in your friendlist
      activeChar.sendPacket(
          SystemMessage.getSystemMessage(SystemMessageId.S1_ALREADY_IN_FRIENDS_LIST)
              .addString(_name));
      return;
    }

    if (!friend.isProcessingRequest()) {
      // request to become friend
      activeChar.onTransactionRequest(friend);
      friend.sendPacket(
          SystemMessage.getSystemMessage(SystemMessageId.S1_REQUESTED_TO_BECOME_FRIENDS)
              .addPcName(activeChar));
      friend.sendPacket(new FriendAddRequest(activeChar.getName()));
    } else
      activeChar.sendPacket(
          SystemMessage.getSystemMessage(SystemMessageId.S1_IS_BUSY_TRY_LATER).addString(_name));
  }
예제 #4
0
  /**
   * Add a L2Object in the world.<br>
   * <br>
   * <B><U> Concept</U> :</B><br>
   * <br>
   * L2Object (including L2PcInstance) are identified in <B>_visibleObjects</B> of his current
   * L2WorldRegion and in <B>_knownObjects</B> of other surrounding L2Characters <br>
   * L2PcInstance are identified in <B>_allPlayers</B> of L2World, in <B>_allPlayers</B> of his
   * current L2WorldRegion and in <B>_knownPlayer</B> of other surrounding L2Characters <br>
   * <br>
   * <B><U> Actions</U> :</B><br>
   * <br>
   * <li>Add the L2Object object in _allPlayers* of L2World
   * <li>Add the L2Object object in _gmList** of GmListTable
   * <li>Add object in _knownObjects and _knownPlayer* of all surrounding L2WorldRegion L2Characters
   *     <br>
   * <li>If object is a L2Character, add all surrounding L2Object in its _knownObjects and all
   *     surrounding L2PcInstance in its _knownPlayer <br>
   *     <I>* only if object is a L2PcInstance</I><br>
   *     <I>** only if object is a GM L2PcInstance</I><br>
   *     <br>
   *     <FONT COLOR=#FF0000><B> <U>Caution</U> : This method DOESN'T ADD the object in
   *     _visibleObjects and _allPlayers* of L2WorldRegion (need synchronisation)</B></FONT><br>
   *     <FONT COLOR=#FF0000><B> <U>Caution</U> : This method DOESN'T ADD the object to _allObjects
   *     and _allPlayers* of L2World (need synchronisation)</B></FONT><br>
   *     <br>
   *     <B><U> Example of use </U> :</B><br>
   *     <br>
   * <li>Drop an Item
   * <li>Spawn a L2Character
   * <li>Apply Death Penalty of a L2PcInstance<br>
   *     <br>
   *
   * @param object L2object to add in the world
   * @param newRegion L2WorldRegion in wich the object will be add (not used)
   */
  public void addVisibleObject(L2Object object, L2WorldRegion newRegion) {
    // If selected L2Object is a L2PcIntance, add it in L2ObjectHashSet(L2PcInstance) _allPlayers of
    // L2World
    // XXX TODO: this code should be obsoleted by protection in putObject func...
    if (object instanceof L2PcInstance) {
      L2PcInstance player = (L2PcInstance) object;

      if (!player.isTeleporting()) {
        L2PcInstance tmp = _allPlayers.get(Integer.valueOf(player.getObjectId()));
        if (tmp != null) {
          _log.warn("Duplicate character!? Closing both characters (" + player.getName() + ")");
          player.logout();
          tmp.logout();
          return;
        }
        _allPlayers.put(player.getObjectId(), player);
      }
    }

    if (!newRegion.isActive()) return;

    // Get all visible objects contained in the _visibleObjects of
    // L2WorldRegions in a circular area of 2000 units
    List<L2Object> visibles = getVisibleObjects(object, 2000);

    _log.trace("objects in range:" + visibles.size());

    // tell the player about the surroundings
    // Go through the visible objects contained in the circular area
    for (L2Object visible : visibles) {
      // Add the object in L2ObjectHashSet(L2Object) _knownObjects of the visible L2Character
      // according to conditions :
      // - L2Character is visible
      // - object is not already known
      // - object is in the watch distance
      // If L2Object is a L2PcInstance, add L2Object in L2ObjectHashSet(L2PcInstance) _knownPlayer
      // of the visible
      // L2Character
      visible.getKnownList().addKnownObject(object);

      // Add the visible L2Object in L2ObjectHashSet(L2Object) _knownObjects of the object according
      // to conditions
      // If visible L2Object is a L2PcInstance, add visible L2Object in
      // L2ObjectHashSet(L2PcInstance) _knownPlayer of the
      // object
      object.getKnownList().addKnownObject(visible);
    }
  }
예제 #5
0
 public final SystemMessage addPcName(final L2PcInstance pc) {
   append(new SMParam(TYPE_TEXT, pc.getName()));
   return this;
 }