Exemplo n.º 1
0
  /** Handle chat type 'all' */
  @Override
  public void handleChat(int type, L2PcInstance activeChar, String params, String text) {
    boolean vcd_used = false;
    if (text.startsWith(".")) {
      StringTokenizer st = new StringTokenizer(text);
      IVoicedCommandHandler vch;
      String command = "";

      if (st.countTokens() > 1) {
        command = st.nextToken().substring(1);
        params = text.substring(command.length() + 2);
        vch = VoicedCommandHandler.getInstance().getHandler(command);
      } else {
        command = text.substring(1);
        if (Config.DEBUG) {
          _log.info("Command: " + command);
        }
        vch = VoicedCommandHandler.getInstance().getHandler(command);
      }
      if (vch != null) {
        vch.useVoicedCommand(command, activeChar, params);
        vcd_used = true;
      } else {
        if (Config.DEBUG) {
          _log.warning("No handler registered for bypass '" + command + "'");
        }
        vcd_used = false;
      }
    }
    if (!vcd_used) {
      if (activeChar.isChatBanned() && Util.contains(Config.BAN_CHAT_CHANNELS, type)) {
        activeChar.sendPacket(SystemMessageId.CHATTING_IS_CURRENTLY_PROHIBITED);
        return;
      }

      /**
       * Match the character "." literally (Exactly 1 time) Match any character that is NOT a .
       * character. Between one and unlimited times as possible, giving back as needed (greedy)
       */
      if (text.matches("\\.{1}[^\\.]+")) {
        activeChar.sendPacket(SystemMessageId.INCORRECT_SYNTAX);
      } else {
        CreatureSay cs =
            new CreatureSay(
                activeChar.getObjectId(), type, activeChar.getAppearance().getVisibleName(), text);
        Collection<L2PcInstance> plrs = activeChar.getKnownList().getKnownPlayers().values();
        for (L2PcInstance player : plrs) {
          if ((player != null)
              && activeChar.isInsideRadius(player, 1250, false, true)
              && !BlockList.isBlocked(player, activeChar)) {
            player.sendPacket(cs);
          }
        }

        activeChar.sendPacket(cs);
      }
    }
  }
  @Override
  protected void runImpl() {
    final L2PcInstance activeChar = getClient().getActiveChar();
    if (activeChar == null) return;

    if (_colorNum < 0 || _colorNum >= COLORS.length) return;

    final L2ItemInstance item = activeChar.getInventory().getItemByObjectId(_itemObjectId);
    if (item == null
        || item.getEtcItem() == null
        || item.getEtcItem().getHandlerName() == null
        || !item.getEtcItem().getHandlerName().equalsIgnoreCase("NicknameColor")) return;

    if (activeChar.destroyItem("Consume", item, 1, null, true)) {
      activeChar.setTitle(_title);
      activeChar.getAppearance().setTitleColor(COLORS[_colorNum]);
      activeChar.broadcastUserInfo();
    }
  }
Exemplo n.º 3
0
 public ConfirmDlg addPcName(L2PcInstance pc) {
   return addString(pc.getAppearance().getVisibleName());
 }