/*
* This program is free software: you can redistribute it and/or modify it under
* the terms of the GNU General Public License as published by the Free Software
* Foundation, either version 3 of the License, or (at your option) any later
* version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
* details.
*
* You should have received a copy of the GNU General Public License along with
* this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jserver.gameserver.network.clientpackets;
import java.util.logging.Level;
import java.util.logging.LogRecord;
import java.util.logging.Logger;
import com.l2jserver.Config;
import com.l2jserver.gameserver.GameServer;
import com.l2jserver.gameserver.GmListTable;
import com.l2jserver.gameserver.datatables.CharNameTable;
import com.l2jserver.gameserver.handler.ChatHandler;
import com.l2jserver.gameserver.handler.IChatHandler;
import com.l2jserver.gameserver.instancemanager.AntiFeedManager;
import com.l2jserver.gameserver.model.L2ItemInstance;
import com.l2jserver.gameserver.model.L2Object;
import com.l2jserver.gameserver.model.L2World;
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance.PunishLevel;
import com.l2jserver.gameserver.network.SystemMessageId;
import com.l2jserver.gameserver.network.serverpackets.SystemMessage;
import com.l2jserver.gameserver.util.Broadcast;
import com.l2jserver.gameserver.util.Util;
import com.l2jserver.gameserver.util.BotPunish;
/**
*
* @version $Revision: 1.16.2.12.2.7 $ $Date: 2005/04/11 10:06:11 $
* @author Extended by Szponiasty(Angakaran)
*/
public final class Say2 extends L2GameClientPacket
{
private static final String _C__38_SAY2 = "[C] 38 Say2";
private static Logger _log = Logger.getLogger(Say2.class.getName());
private static Logger _logChat = Logger.getLogger("chat");
public final static int ALL = 0;
public final static int SHOUT = 1; //!
public final static int TELL = 2;
public final static int PARTY = 3; //#
public final static int CLAN = 4; //@
public final static int GM = 5;
public final static int PETITION_PLAYER = 6; // used for petition
public final static int PETITION_GM = 7; //* used for petition
public final static int TRADE = 8; //+
public final static int ALLIANCE = 9; //$
public final static int ANNOUNCEMENT = 10;
public final static int BOAT = 11;
public final static int L2FRIEND = 12;
public final static int MSNCHAT = 13;
public final static int PARTYMATCH_ROOM = 14;
public final static int PARTYROOM_COMMANDER = 15; //(Yellow)
public final static int PARTYROOM_ALL = 16; //(Red)
public final static int HERO_VOICE = 17;
public final static int CRITICAL_ANNOUNCE = 18;
public final static int SCREEN_ANNOUNCE = 19;
public final static int BATTLEFIELD = 20;
public final static int MPCC_ROOM = 21;
//-- SL2 ADDON: new chat names
public final static int SL2SYSTEM = 22;
public final static int SL2EVENTS = 23;
public final static int SL2ITEMBROKERS = 24;
public final static int SL2COMBAT = 25;
public final static int SL2SECURITY = 26;
public final static int SL2LOGS = 27;
public final static int SL2POLLS = 28;
public final static int SL2SPECIAL = 29;
public final static int SL2ADBOARD = 30;
public final static int SL2ANTICHEAT = 31;
public final static int SL2NEWS = 32;
private final static String[] CHAT_NAMES =
{
"ALL",
"SHOUT",
"TELL",
"PARTY",
"CLAN",
"GM",
"PETITION_PLAYER",
"PETITION_GM",
"TRADE",
"ALLIANCE",
"ANNOUNCEMENT", //10
"BOAT",
"L2FRIEND",
"MSNCHAT",
"PARTYMATCH_ROOM",
"PARTYROOM_COMMANDER",
"PARTYROOM_ALL",
"HERO_VOICE",
"CRITICAL_ANNOUNCE",
"SCREEN_ANNOUNCE",
"BATTLEFIELD", //20
"MPCC_ROOM",
//-- SL2 ADDON: new chat names
"SL2SYSTEM", // id = 22
"SL2EVENTS", // id = 23
"SL2ITEMBROKERS",
"SL2COMBAT",
"SL2SECURITY",
"SL2LOGS",
"SL2POLLS", //-- 28
"SL2SPECIAL",
"SL2ADBOARD",
"SL2ANTICHEAT",
"SL2NEWS" //-- 32
};
private static final String[] WALKER_COMMAND_LIST = { "USESKILL", "USEITEM", "BUYITEM", "SELLITEM", "SAVEITEM", "LOADITEM", "MSG", "SET", "DELAY", "LABEL", "JMP", "CALL",
"RETURN", "MOVETO", "NPCSEL", "NPCDLG", "DLGSEL", "CHARSTATUS", "POSOUTRANGE", "POSINRANGE", "GOHOME", "SAY", "EXIT", "PAUSE", "STRINDLG", "STRNOTINDLG", "CHANGEWAITTYPE",
"FORCEATTACK", "ISMEMBER", "REQUESTJOINPARTY", "REQUESTOUTPARTY", "QUITPARTY", "MEMBERSTATUS", "CHARBUFFS", "ITEMCOUNT", "FOLLOWTELEPORT" };
private String _text;
private int _type;
private String _target;
@Override
protected void readImpl()
{
try
{
_text = readS();
_type = readD();
_target = (_type == TELL) ? readS() : null;
}
catch (Exception e)
{
//--
}
}
@Override
protected void runImpl()
{
try
{
if (Config.DEBUG)
_log.info("Say2: Msg Type = '" + _type + "' Text = '" + _text + "'.");
L2PcInstance activeChar = getClient().getActiveChar();
if (activeChar == null)
return;
if ((_type == TELL) && (_target.equalsIgnoreCase("Administrator")))
{
GameServer._statusServer.sendMessageToTelnets("PRV MSG --- "+activeChar.getName()+" ->"+_text);
}
if (Config.SL2EXTENSIONS_SHOW_ALL_CHATS_ON_CONSOLE) //-- SL2 ADDED - in v0.3099
{
// _log.info("##### CHAT: " + activeChar + " --------- '" + CHAT_NAMES[_type] + "' (" + _type + ") ---> '" + _text + "'.");
if (_type != TELL)
GameServer._statusServer.sendMessageToTelnets(CHAT_NAMES[_type]+" --- "+activeChar.getName()+" === "+_text);
else
GameServer._statusServer.sendMessageToTelnets(CHAT_NAMES[_type]+" --- "+activeChar.getName()+" TO "+_target+" ->>> "+_text);
}
// Check for bot punishment
if(activeChar.isBeingPunished())
{
// Check if punishment expired
if(activeChar.getPlayerPunish().canTalk() && activeChar.getBotPunishType() == BotPunish.Punish.CHATBAN)
{
activeChar.endPunishment();
}
// Else, apply it
else
{
// Inform player
activeChar.sendPacket(new SystemMessage(SystemMessageId.REPORTED_10_MINS_WITHOUT_CHAT));
return;
}
}
if (_type < 0 || _type >= CHAT_NAMES.length)
{
_log.warning("Say2: Invalid type: " +_type + " Player : " + activeChar.getName() + " text: " + String.valueOf(_text));
return;
}
if (_text.isEmpty())
{
_log.warning(activeChar.getName() + ": sending empty text. Possible packet hack!");
return;
}
// Even though the client can handle more characters than it's current limit allows, an overflow (critical error) happens if you pass a huge (1000+) message.
// April 27, 2009 - Verified on Gracia P2 & Final official client as 105
if (_text.length() > 105 && !activeChar.isGM())
{
activeChar.sendPacket(new SystemMessage(SystemMessageId.DONT_SPAM));
return;
}
if (Config.L2WALKER_PROTECTION && _type == TELL && checkBot(_text))
{
Util.handleIllegalPlayerAction(activeChar, "Client Emulator Detect: Player " + activeChar.getName() + " using l2walker.", Config.DEFAULT_PUNISH);
return;
}
if (activeChar.isCursedWeaponEquipped() && (_type == TRADE || _type == SHOUT))
{
activeChar.sendPacket(new SystemMessage(SystemMessageId.SHOUT_AND_TRADE_CHAT_CANNOT_BE_USED_WHILE_POSSESSING_CURSED_WEAPON));
return;
}
if (activeChar.isChatBanned())
{
if (_type == ALL || _type == SHOUT || _type == TRADE || _type == HERO_VOICE)
{
activeChar.sendPacket(new SystemMessage(SystemMessageId.CHATTING_IS_CURRENTLY_PROHIBITED));
return;
}
}
if (activeChar.isInJail() && Config.JAIL_DISABLE_CHAT)
{
if (_type == TELL || _type == SHOUT || _type == TRADE || _type == HERO_VOICE)
{
activeChar.sendMessage("You can not chat with players outside of the jail.");
return;
}
}
if (_type == PETITION_PLAYER && activeChar.isGM())
_type = PETITION_GM;
if (Config.LOG_CHAT)
{
LogRecord record = new LogRecord(Level.INFO, _text);
record.setLoggerName("chat");
if (_type == TELL)
record.setParameters(new Object[]{CHAT_NAMES[_type], "[" + activeChar.getName() + " to "+_target+"]"});
else
record.setParameters(new Object[]{CHAT_NAMES[_type], "[" + activeChar.getName() + "]"});
_logChat.log(record);
}
if (Config.SL2_ENABLE_CHAT_RULES && ((activeChar.isGM() && Config.SERVER_IN_BETA_TESTS) || !activeChar.isGM()))
{
boolean _pm = Config.SL2_RULES_ON_CHATS.contains("pm,") && (_type == TELL);
boolean _abort = false;
if (_pm)
{
final String _tAccountName = CharNameTable.getInstance().accountNameByCharId(CharNameTable.getInstance().getIdByName(_target));
boolean _skipSelfPM = Config.SL2_PMCHAT_RULE_SKIP_WHEN.toLowerCase().contains("self,");
boolean _skipClanPM = Config.SL2_PMCHAT_RULE_SKIP_WHEN.toLowerCase().contains("clan,") && (activeChar.getClanId() > 0);
boolean _skipAllyPM = Config.SL2_PMCHAT_RULE_SKIP_WHEN.toLowerCase().contains("ally,") && (activeChar.getAllyId() > 0);
boolean _skipPartyPM = Config.SL2_PMCHAT_RULE_SKIP_WHEN.toLowerCase().contains("party,") && (activeChar.getParty() != null);
if (_skipPartyPM)
{
boolean _skipPartyPMtmp = false;
for (L2PcInstance _member: activeChar.getParty().getPartyMembers())
{
if ((_member != null) && (_member.getName().equalsIgnoreCase(_target)))
{
_skipPartyPMtmp = true;
break;
}
}
_skipPartyPM = _skipPartyPMtmp;
_abort = _skipPartyPM;
}
if (!_abort && activeChar._accfeeddata.getOtherAccounts().containsKey(_tAccountName))
{
int _relation = activeChar._accfeeddata.getOtherAccounts().getEntry(_tAccountName).getValue();
switch (_relation)
{
case AntiFeedManager.AccountFeedData.ACC_TYPE_OTHER:
case AntiFeedManager.AccountFeedData.ACC_TYPE_LOGGED:
case AntiFeedManager.AccountFeedData.ACC_TYPE_SAME_NETWORK:
_abort = _skipSelfPM;
break;
case AntiFeedManager.AccountFeedData.ACC_TYPE_CLANMATE:
_abort = _skipClanPM;
break;
case AntiFeedManager.AccountFeedData.ACC_TYPE_ALLYMATE:
_abort = _skipAllyPM;
break;
}
}
else
{
//-- COMPLETELY UNKNOWN PM TARGET (_tAccountName) -- NOT ON ANTIFEED INDEX LIST ---
_abort = false;
}
_pm = (!_abort);
}
if (!_abort)
{
boolean _shout = Config.SL2_RULES_ON_CHATS.contains("shout,") && (_type == SHOUT);
boolean _hero = Config.SL2_RULES_ON_CHATS.contains("hero,") && (_type == HERO_VOICE);
boolean _trade = Config.SL2_RULES_ON_CHATS.contains("trade,") && (_type == TRADE);
boolean _normal = Config.SL2_RULES_ON_CHATS.contains("all,") && (_type == ALL);
boolean _check = (_pm || _shout || _hero || _trade || _normal);
if (_check)
{
int _abuse = /*(Config.SL2_CHECK_FOR_BANNED ? Config.SL2_AUTO_CHAT_BANNING : 0) + */ checkTextLock();
if (_abuse > 0)
{
// SL2 CHAT ABUSE SCORE TIMER RESETS AFTER 45s SINCE LAST "ABUSE" --
_abuse += activeChar.ChatabusePoints;
if (_abuse <= Config.SL2_AUTOCHAT_IGNORING)
{
activeChar.SendSL2CustomMessage(SL2SECURITY, null, "Abuse Protection", Config.SL2_AUTORESPONSE_ON_ABUSE);
GmListTable.broadcastMessageToGMs("CHAT ABUSE: "+activeChar+" / account "+activeChar.getAccountName()+" Abuse = "+_abuse+"\nMsg: "+_text+"\n----");
activeChar.ChatabusePoints = _abuse;
//-- ADD TIMER FOR ChatabusePoints RESETTING --
activeChar._lastChatAbuseScoreUpdate = System.currentTimeMillis();
return;
}
if ((_abuse > Config.SL2_AUTOCHAT_IGNORING) && (_abuse <= Config.SL2_AUTO_CHAT_BANNING) && (!activeChar.AlreadyAutochatbanned && Config.SL2_NEXT_OFFENCE_JAIL))
{
activeChar.AlreadyAutochatbanned = true;
activeChar.SendSL2CustomMessage(SL2SECURITY, null, "Abuse Protection", "You are chat banned for "+Broadcast.getTimeFormatted(Config.SL2_CHATBAN_TIME*1000));
if (Config.SL2_NEXT_OFFENCE_JAIL)
activeChar.SendSL2CustomMessage(SL2SECURITY, null, "Abuse Protection", "For continous offence, you will end in jail, for at least "+Broadcast.getTimeFormatted(Config.SL2_CHATOFFENCE_JAIL_TIME*1000));
GmListTable.broadcastMessageToGMs("CHAT ABUSE (player auto chatbanned): "+activeChar+" / account "+activeChar.getAccountName()+" Abuse = "+_abuse+"\nMsg: "+_text+"\n----");
activeChar.setPunishLevel(PunishLevel.CHAT, Config.SL2_CHATBAN_TIME/60);
activeChar.ChatabusePoints = _abuse;
//-- ADD TIMER FOR ChatabusePoints RESETTING --
activeChar._lastChatAbuseScoreUpdate = System.currentTimeMillis();
return;
}
if (activeChar.AlreadyAutochatbanned || (_abuse >= Config.SL2_AUTO_CHAT_BANNING))
{
if (Config.SL2_NEXT_OFFENCE_JAIL)
{
activeChar.SendSL2CustomMessage(SL2SECURITY, null, "Abuse Protection", "You are jailed for "+Broadcast.getTimeFormatted(Config.SL2_CHATOFFENCE_JAIL_TIME*1000));
GmListTable.broadcastMessageToGMs("CHAT ABUSE (player jailed): "+activeChar+" / account "+activeChar.getAccountName()+" Abuse = "+_abuse+"\nMsg: "+_text+"\n----");
activeChar.setPunishLevel(PunishLevel.JAIL, Config.SL2_CHATOFFENCE_JAIL_TIME/60);
}
else
{
activeChar.SendSL2CustomMessage(SL2SECURITY, null, "Abuse Protection", "You are chat banned for "+Broadcast.getTimeFormatted(Config.SL2_CHATBAN_TIME*1000));
GmListTable.broadcastMessageToGMs("CHAT ABUSE (player auto chatbanned): "+activeChar+" / account "+activeChar.getAccountName()+" Abuse = "+_abuse+"\nMsg: "+_text+"\n----");
activeChar.setPunishLevel(PunishLevel.CHAT, Config.SL2_CHATBAN_TIME/60);
}
activeChar.ChatabusePoints = _abuse;
//-- ADD TIMER FOR ChatabusePoints RESETTING --
activeChar._lastChatAbuseScoreUpdate = System.currentTimeMillis();
return;
}
else
{
activeChar.SendSL2CustomMessage(SL2SECURITY, null, "Abuse Protection", "You are chat banned for "+Broadcast.getTimeFormatted(Config.SL2_CHATBAN_TIME*1000));
GmListTable.broadcastMessageToGMs("CHAT ABUSE (player auto chatbanned): "+activeChar+" / account "+activeChar.getAccountName()+" Abuse = "+_abuse+"\nMsg: "+_text+"\n----");
activeChar.setPunishLevel(PunishLevel.CHAT, Config.SL2_CHATBAN_TIME/60);
activeChar.ChatabusePoints = _abuse;
//-- ADD TIMER FOR ChatabusePoints RESETTING --
activeChar._lastChatAbuseScoreUpdate = System.currentTimeMillis();
return;
}
}
}
}
}
if (_text.indexOf(8) >= 0)
if (!parseAndPublishItem(activeChar))
return;
// Say Filter implementation
if (Config.USE_SAY_FILTER)
checkText();
IChatHandler handler = ChatHandler.getInstance().getChatHandler(_type);
if (handler != null)
handler.handleChat(_type, activeChar, _target, _text);
else
_log.info("No handler registered for ChatType: "+_type+ " Player: "+getClient());
}
catch (Exception e)
{
//--- just ignore any exceptions...
}
}
private boolean checkBot(String text)
{
for (String botCommand : WALKER_COMMAND_LIST)
{
if (text.startsWith(botCommand))
return true;
}
return false;
}
private void checkText()
{
String filteredText = _text;
for (String pattern : Config.FILTER_LIST)
filteredText = filteredText.replaceAll("(?i)" + pattern, Config.CHAT_FILTER_CHARS);
_text = filteredText;
}
private int checkTextLock()
{
String filteredText = ""; //_text;
for (char _char : _text.toCharArray())
{
boolean _put = true;
for (char _checkC : Config.SL2_CHATCHARS_IGNORE)
if (_checkC == _char)
_put = false;
if (_put) filteredText += _char;
}
int _abuseCounter = 0;
for (String pattern : Config.LOCK_LIST)
if (filteredText.toLowerCase().contains(pattern.toLowerCase()))
_abuseCounter++;
return _abuseCounter;
}
private boolean parseAndPublishItem(L2PcInstance owner)
{
int pos1 = -1;
while ((pos1 = _text.indexOf(8, pos1)) > -1)
{
int pos = _text.indexOf("ID=", pos1);
if (pos == -1)
return false;
StringBuilder result = new StringBuilder(9);
pos += 3;
while (Character.isDigit(_text.charAt(pos)))
result.append(_text.charAt(pos++));
int id = Integer.parseInt(result.toString());
L2Object item = L2World.getInstance().findObject(id);
if (item instanceof L2ItemInstance)
{
if (owner.getInventory().getItemByObjectId(id) == null)
{
_log.info(getClient() + " trying publish item which doesnt own! ID:" + id);
return false;
}
((L2ItemInstance) item).publish();
}
else
{
_log.info(getClient() + " trying publish object which is not item! Object:" + item);
return false;
}
pos1 = _text.indexOf(8, pos) + 1;
if (pos1 == 0) // missing ending tag
{
_log.info(getClient() + " sent invalid publish item msg! ID:" + id);
return false;
}
}
return true;
}
/* (non-Javadoc)
* @see com.l2jserver.gameserver.clientpackets.ClientBasePacket#getType()
*/
@Override
public String getType()
{
return _C__38_SAY2;
}
@Override
protected boolean triggersOnActionRequest()
{
return false;
}
}
Y esto para las tiendas:
### Eclipse Workspace Patch 1.0
#P L2_GameServer
Index: java/com/l2jserver/gameserver/network/clientpackets/SetPrivateStoreMsgBuy.java
===================================================================
--- java/com/l2jserver/gameserver/network/clientpackets/SetPrivateStoreMsgBuy.java (revision 4422)
+++ java/com/l2jserver/gameserver/network/clientpackets/SetPrivateStoreMsgBuy.java (working copy)
@@ -52,6 +52,14 @@
return;
}
+ if (Config.USE_SAY_FILTER && _storeMsg != null)
+ {
+ String filteredText = _storeMsg;
+ for (String pattern : Config.FILTER_LIST)
+ filteredText = filteredText.replaceAll("(?i)" + pattern, Config.CHAT_FILTER_CHARS);
+ _storeMsg = filteredText;
+ }
+
player.getBuyList().setTitle(_storeMsg);
player.sendPacket(new PrivateStoreMsgBuy(player));
}
Index: java/com/l2jserver/gameserver/network/clientpackets/SetPrivateStoreWholeMsg.java
===================================================================
--- java/com/l2jserver/gameserver/network/clientpackets/SetPrivateStoreWholeMsg.java (revision 4422)
+++ java/com/l2jserver/gameserver/network/clientpackets/SetPrivateStoreWholeMsg.java (working copy)
@@ -63,6 +63,14 @@
return;
}
+ if (Config.USE_SAY_FILTER && _msg != null)
+ {
+ String filteredText = _msg;
+ for (String pattern : Config.FILTER_LIST)
+ filteredText = filteredText.replaceAll("(?i)" + pattern, Config.CHAT_FILTER_CHARS);
+ _msg = filteredText;
+ }
+
player.getSellList().setTitle(_msg);
sendPacket(new ExPrivateStoreSetWholeMsg(player));
}
Index: java/com/l2jserver/gameserver/network/clientpackets/SetPrivateStoreMsgSell.java
===================================================================
--- java/com/l2jserver/gameserver/network/clientpackets/SetPrivateStoreMsgSell.java (revision 4422)
+++ java/com/l2jserver/gameserver/network/clientpackets/SetPrivateStoreMsgSell.java (working copy)
@@ -52,6 +52,14 @@
return;
}
+ if (Config.USE_SAY_FILTER && _storeMsg != null)
+ {
+ String filteredText = _storeMsg;
+ for (String pattern : Config.FILTER_LIST)
+ filteredText = filteredText.replaceAll("(?i)" + pattern, Config.CHAT_FILTER_CHARS);
+ _storeMsg = filteredText;
+ }
+
player.getSellList().setTitle(_storeMsg);
sendPacket(new PrivateStoreMsgSell(player));
}