String translit = activeChar.getVar("translit");
if(translit != null)
{
_text = Strings.fromTranslit(_text, translit.equals("tl") ? 1 : 2);
}
Say2 cs = new Say2(activeChar.getObjectId(), _type, activeChar.getName(), _text);
int mapregion = MapRegion.getInstance().getMapRegion(activeChar.getX(), activeChar.getY());
long curTime = System.currentTimeMillis();
switch(_type)
{
case TELL:
L2Player receiver = L2World.getPlayer(_target);
if(receiver == null && Config.ALLOW_FAKE_PLAYERS && FakePlayersTable.getActiveFakePlayers().contains(_target))
{
cs = new Say2(activeChar.getObjectId(), _type, "->" + _target, _text);
activeChar.sendPacket(cs);
return;
}
else if(receiver != null && receiver.isInOfflineMode())
{
activeChar.sendMessage("The person is in offline trade mode");
activeChar.sendActionFailed();
}
else if(receiver != null && !receiver.isInBlockList(activeChar) && !receiver.isBlockAll())
{
Long lastShoutTime = (Long) activeChar.getProperty(PropertyCollection.TellChatLaunched);
if(lastShoutTime != null && lastShoutTime + (activeChar.getLevel() >= 20 ? 1000L : 10000L) > curTime)
{
activeChar.sendMessage("Tell chat is allowed once per " + (activeChar.getLevel() >= 20 ? "1 second." : "10 seconds."));
return;
}
activeChar.addProperty(PropertyCollection.TellChatLaunched, curTime);
if(!receiver.getMessageRefusal())
{
receiver.sendPacket(cs);
cs = new Say2(activeChar.getObjectId(), _type, "->" + receiver.getName(), _text);
activeChar.sendPacket(cs);
}
else
{
activeChar.sendPacket(Msg.THE_PERSON_IS_IN_A_MESSAGE_REFUSAL_MODE);
}
}
else if(receiver == null)
{
activeChar.sendPacket(new SystemMessage(SystemMessage.S1_IS_NOT_CURRENTLY_LOGGED_IN).addString(_target), Msg.ActionFail);
}
else
{
activeChar.sendPacket(Msg.YOU_HAVE_BEEN_BLOCKED_FROM_THE_CONTACT_YOU_SELECTED, Msg.ActionFail);
}
break;
case SHOUT:
if(activeChar.isCursedWeaponEquipped())
{
activeChar.sendPacket(Msg.SHOUT_AND_TRADE_CHATING_CANNOT_BE_USED_SHILE_POSSESSING_A_CURSED_WEAPON);
return;
}
if(activeChar.inObserverMode())
{
activeChar.sendPacket(Msg.YOU_CANNOT_CHAT_LOCALLY_WHILE_OBSERVING);
return;
}
Long lastShoutTime = (Long) activeChar.getProperty(PropertyCollection.ShoutChatLaunched);
if(lastShoutTime != null && lastShoutTime + Config.SHOUT_CHAT_TIME * 1000L > curTime)
{
activeChar.sendMessage("Shout chat is allowed once per " + Config.SHOUT_CHAT_TIME + " seconds.");
return;
}
if(Config.CHAT_RESTRICTIONS)
{
if(activeChar.getLevel() < Config.SHOUT_CHAT)
{
activeChar.sendMessage("You must be " + Config.SHOUT_CHAT + " level to use Shout chat!");
return;
}
}
activeChar.addProperty(PropertyCollection.ShoutChatLaunched, curTime);
if(activeChar.getLevel() >= Config.GLOBAL_CHAT || activeChar.isGM() && Config.GLOBAL_CHAT < Experience.LEVEL.length)
{
for(L2Player player : L2ObjectsStorage.getAllPlayersForIterate())
{
if(!player.isInBlockList(activeChar) && !player.isBlockAll())
{
player.sendPacket(cs);
}
}
}
else
{
if(Config.SHOUT_CHAT_MODE == 1)
{
for(L2Player player : L2World.getAroundPlayers(activeChar, 10000, 1500))
{
if(!player.isInBlockList(activeChar) && !player.isBlockAll() && player != activeChar)
{
player.sendPacket(cs);
}
}
}
else
{
for(L2Player player : L2ObjectsStorage.getAllPlayersForIterate())
{
if(MapRegion.getInstance().getMapRegion(player.getX(), player.getY()) == mapregion && !player.isInBlockList(activeChar) && !player.isBlockAll() && player != activeChar)
{
player.sendPacket(cs);
}
}
}
activeChar.sendPacket(cs);
}
break;
case TRADE:
if(activeChar.isCursedWeaponEquipped())
{
activeChar.sendPacket(Msg.SHOUT_AND_TRADE_CHATING_CANNOT_BE_USED_SHILE_POSSESSING_A_CURSED_WEAPON);
return;
}
if(activeChar.inObserverMode())
{
activeChar.sendPacket(Msg.YOU_CANNOT_CHAT_LOCALLY_WHILE_OBSERVING);
return;
}
Long lastTradeTime = (Long) activeChar.getProperty(PropertyCollection.TradeChatLaunched);
if(lastTradeTime != null && lastTradeTime + Config.TRADE_CHAT_TIME * 1000L > curTime)
{
activeChar.sendMessage("Trade chat is allowed once per " + Config.TRADE_CHAT_TIME + " seconds.");
return;
}
if(Config.CHAT_RESTRICTIONS)
{
if(activeChar.getLevel() < Config.TRADE_CHAT)
{
activeChar.sendMessage("You must be " + Config.TRADE_CHAT + " level to use Trade chat!");
return;
}
}
activeChar.addProperty(PropertyCollection.TradeChatLaunched, curTime);
if(activeChar.getLevel() >= Config.GLOBAL_TRADE_CHAT || activeChar.isGM() && Config.GLOBAL_TRADE_CHAT < Experience.LEVEL.length)
{
for(L2Player player : L2ObjectsStorage.getAllPlayersForIterate())
{
if(!player.isInBlockList(activeChar) && !player.isBlockAll())
{
player.sendPacket(cs);
}
}
}
else
{
if(Config.TRADE_CHAT_MODE == 1)
{
for(L2Player player : L2World.getAroundPlayers(activeChar, 10000, 1500))
{
if(!player.isInBlockList(activeChar) && !player.isBlockAll() && player != activeChar)
{
player.sendPacket(cs);
}
}
}
else
{
for(L2Player player : L2ObjectsStorage.getAllPlayersForIterate())
{
if(MapRegion.getInstance().getMapRegion(player.getX(), player.getY()) == mapregion && !player.isInBlockList(activeChar) && !player.isBlockAll() && player != activeChar)
{
player.sendPacket(cs);
}
}
}
activeChar.sendPacket(cs);
}
break;
case ALL:
if(activeChar.isCursedWeaponEquipped())
{
cs = new Say2(activeChar.getObjectId(), _type, activeChar.getTransformationName(), _text);
}
if(activeChar.inObserverMode() && activeChar.getObservNeighbor() != null)
{
GArray<L2Player> result = new GArray<L2Player>(50);
for(L2WorldRegion neighbor : activeChar.getObservNeighbor().getNeighbors())