Faction chat system.
This commit is contained in:
parent
89f53b2c3d
commit
5395d59c41
3
trunk/dist/game/config/Custom.properties
vendored
3
trunk/dist/game/config/Custom.properties
vendored
@ -657,6 +657,9 @@ GoodNameColor = 00FF00
|
||||
# Default: 0000FF
|
||||
EvilNameColor = 0000FF
|
||||
|
||||
# Disable chat between factions.
|
||||
# Default: True
|
||||
EnableFactionChat = True
|
||||
|
||||
# ---------------------------------------------------------------------------
|
||||
# Premium System (VIP)
|
||||
|
@ -105,12 +105,34 @@ public class ChatAll implements IChatHandler
|
||||
else
|
||||
{
|
||||
CreatureSay cs = new CreatureSay(activeChar.getObjectId(), type, activeChar.getAppearance().getVisibleName(), text);
|
||||
CreatureSay csRandom = new CreatureSay(activeChar.getObjectId(), type, activeChar.getAppearance().getVisibleName(), ChatRandomizer.randomize(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);
|
||||
if (Config.FACTION_SYSTEM_ENABLED)
|
||||
{
|
||||
if (Config.FACTION_SPECIFIC_CHAT)
|
||||
{
|
||||
if ((activeChar.isGood() && player.isEvil()) || (activeChar.isEvil() && player.isGood()))
|
||||
{
|
||||
player.sendPacket(csRandom);
|
||||
}
|
||||
else
|
||||
{
|
||||
player.sendPacket(cs);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
player.sendPacket(cs);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
player.sendPacket(cs);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -64,7 +64,24 @@ public class ChatHeroVoice implements IChatHandler
|
||||
{
|
||||
if ((player != null) && !BlockList.isBlocked(player, activeChar))
|
||||
{
|
||||
player.sendPacket(cs);
|
||||
if (Config.FACTION_SYSTEM_ENABLED)
|
||||
{
|
||||
if (Config.FACTION_SPECIFIC_CHAT)
|
||||
{
|
||||
if ((activeChar.isGood() && player.isGood()) || (activeChar.isEvil() && player.isEvil()))
|
||||
{
|
||||
player.sendPacket(cs);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
player.sendPacket(cs);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
player.sendPacket(cs);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -58,7 +58,24 @@ public class ChatPartyMatchRoom implements IChatHandler
|
||||
CreatureSay cs = new CreatureSay(activeChar.getObjectId(), type, activeChar.getName(), text);
|
||||
for (L2PcInstance _member : _room.getPartyMembers())
|
||||
{
|
||||
_member.sendPacket(cs);
|
||||
if (Config.FACTION_SYSTEM_ENABLED)
|
||||
{
|
||||
if (Config.FACTION_SPECIFIC_CHAT)
|
||||
{
|
||||
if ((activeChar.isGood() && _member.isGood()) || (activeChar.isEvil() && _member.isEvil()))
|
||||
{
|
||||
_member.sendPacket(cs);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
_member.sendPacket(cs);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
_member.sendPacket(cs);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
52
trunk/dist/game/data/scripts/handlers/chathandlers/ChatRandomizer.java
vendored
Normal file
52
trunk/dist/game/data/scripts/handlers/chathandlers/ChatRandomizer.java
vendored
Normal file
@ -0,0 +1,52 @@
|
||||
/*
|
||||
* Copyright (C) 2004-2015 L2J Server
|
||||
*
|
||||
* This file is part of L2J Server.
|
||||
*
|
||||
* L2J Server 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.
|
||||
*
|
||||
* L2J Server 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 handlers.chathandlers;
|
||||
|
||||
import com.l2jserver.util.Rnd;
|
||||
|
||||
/**
|
||||
* @author Mobius
|
||||
*/
|
||||
public class ChatRandomizer
|
||||
{
|
||||
public static String randomize(String text)
|
||||
{
|
||||
final StringBuilder textOut = new StringBuilder();
|
||||
for (char c : text.toCharArray())
|
||||
{
|
||||
if ((c > 96) && (c < 123))
|
||||
{
|
||||
textOut.append(Character.toString((char) Rnd.get(96, 123)));
|
||||
}
|
||||
else if ((c > 64) && (c < 91))
|
||||
{
|
||||
textOut.append(Character.toString((char) Rnd.get(64, 91)));
|
||||
}
|
||||
else if ((c == 32) || (c == 44) || (c == 46))
|
||||
{
|
||||
textOut.append(c);
|
||||
}
|
||||
else
|
||||
{
|
||||
textOut.append(Character.toString((char) Rnd.get(47, 64)));
|
||||
}
|
||||
}
|
||||
return textOut.toString();
|
||||
}
|
||||
}
|
@ -60,7 +60,27 @@ public class ChatShout implements IChatHandler
|
||||
{
|
||||
if ((region == MapRegionManager.getInstance().getMapRegionLocId(player)) && !BlockList.isBlocked(player, activeChar) && (player.getInstanceId() == activeChar.getInstanceId()))
|
||||
{
|
||||
player.sendPacket(cs);
|
||||
if (!BlockList.isBlocked(player, activeChar))
|
||||
{
|
||||
if (Config.FACTION_SYSTEM_ENABLED)
|
||||
{
|
||||
if (Config.FACTION_SPECIFIC_CHAT)
|
||||
{
|
||||
if ((activeChar.isGood() && player.isGood()) || (activeChar.isEvil() && player.isEvil()))
|
||||
{
|
||||
player.sendPacket(cs);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
player.sendPacket(cs);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
player.sendPacket(cs);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -76,7 +96,24 @@ public class ChatShout implements IChatHandler
|
||||
{
|
||||
if (!BlockList.isBlocked(player, activeChar))
|
||||
{
|
||||
player.sendPacket(cs);
|
||||
if (Config.FACTION_SYSTEM_ENABLED)
|
||||
{
|
||||
if (Config.FACTION_SPECIFIC_CHAT)
|
||||
{
|
||||
if ((activeChar.isGood() && player.isGood()) || (activeChar.isEvil() && player.isEvil()))
|
||||
{
|
||||
player.sendPacket(cs);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
player.sendPacket(cs);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
player.sendPacket(cs);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -84,6 +84,11 @@ public class ChatTell implements IChatHandler
|
||||
activeChar.sendMessage("Player is in offline mode.");
|
||||
return;
|
||||
}
|
||||
if (Config.FACTION_SYSTEM_ENABLED && Config.FACTION_SPECIFIC_CHAT && ((activeChar.isGood() && receiver.isEvil()) || (activeChar.isEvil() && receiver.isGood())))
|
||||
{
|
||||
activeChar.sendMessage("Player belongs to the opposing faction.");
|
||||
return;
|
||||
}
|
||||
if (!BlockList.isBlocked(receiver, activeChar))
|
||||
{
|
||||
// Allow reciever to send PMs to this char, which is in silence mode.
|
||||
|
@ -60,7 +60,24 @@ public class ChatTrade implements IChatHandler
|
||||
{
|
||||
if ((region == MapRegionManager.getInstance().getMapRegionLocId(player)) && !BlockList.isBlocked(player, activeChar) && (player.getInstanceId() == activeChar.getInstanceId()))
|
||||
{
|
||||
player.sendPacket(cs);
|
||||
if (Config.FACTION_SYSTEM_ENABLED)
|
||||
{
|
||||
if (Config.FACTION_SPECIFIC_CHAT)
|
||||
{
|
||||
if ((activeChar.isGood() && player.isGood()) || (activeChar.isEvil() && player.isEvil()))
|
||||
{
|
||||
player.sendPacket(cs);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
player.sendPacket(cs);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
player.sendPacket(cs);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -76,7 +93,24 @@ public class ChatTrade implements IChatHandler
|
||||
{
|
||||
if (!BlockList.isBlocked(player, activeChar))
|
||||
{
|
||||
player.sendPacket(cs);
|
||||
if (Config.FACTION_SYSTEM_ENABLED)
|
||||
{
|
||||
if (Config.FACTION_SPECIFIC_CHAT)
|
||||
{
|
||||
if ((activeChar.isGood() && player.isGood()) || (activeChar.isEvil() && player.isEvil()))
|
||||
{
|
||||
player.sendPacket(cs);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
player.sendPacket(cs);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
player.sendPacket(cs);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -79,7 +79,24 @@ public class ChatWorld implements IChatHandler
|
||||
final Duration timeDiff = Duration.between(instant, now);
|
||||
final SystemMessage msg = SystemMessage.getSystemMessage(SystemMessageId.YOU_HAVE_S1_SEC_UNTIL_YOU_ARE_ABLE_TO_USE_WORLD_CHAT);
|
||||
msg.addInt((int) timeDiff.getSeconds());
|
||||
activeChar.sendPacket(msg);
|
||||
if (Config.FACTION_SYSTEM_ENABLED)
|
||||
{
|
||||
if (Config.FACTION_SPECIFIC_CHAT)
|
||||
{
|
||||
if ((activeChar.isGood() && activeChar.isGood()) || (activeChar.isEvil() && activeChar.isEvil()))
|
||||
{
|
||||
activeChar.sendPacket(msg);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
activeChar.sendPacket(msg);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
activeChar.sendPacket(msg);
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
@ -88,7 +105,24 @@ public class ChatWorld implements IChatHandler
|
||||
L2World.getInstance().getPlayers().stream().filter(activeChar::isNotBlocked).forEach(cs::sendTo);
|
||||
|
||||
activeChar.setWorldChatPoints(activeChar.getWorldChatPoints() - 1);
|
||||
activeChar.sendPacket(new ExWorldChatCnt(activeChar));
|
||||
if (Config.FACTION_SYSTEM_ENABLED)
|
||||
{
|
||||
if (Config.FACTION_SPECIFIC_CHAT)
|
||||
{
|
||||
if ((activeChar.isGood() && activeChar.isGood()) || (activeChar.isEvil() && activeChar.isEvil()))
|
||||
{
|
||||
activeChar.sendPacket(new ExWorldChatCnt(activeChar));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
activeChar.sendPacket(new ExWorldChatCnt(activeChar));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
activeChar.sendPacket(new ExWorldChatCnt(activeChar));
|
||||
}
|
||||
if (Config.WORLD_CHAT_INTERVAL.getSeconds() > 0)
|
||||
{
|
||||
REUSE.put(activeChar.getObjectId(), now.plus(Config.WORLD_CHAT_INTERVAL));
|
||||
|
@ -831,6 +831,7 @@ public final class Config
|
||||
public static String FACTION_EVIL_TEAM_NAME;
|
||||
public static int FACTION_GOOD_NAME_COLOR;
|
||||
public static int FACTION_EVIL_NAME_COLOR;
|
||||
public static boolean FACTION_SPECIFIC_CHAT;
|
||||
public static boolean PREMIUM_SYSTEM_ENABLED;
|
||||
public static float PREMIUM_RATE_XP;
|
||||
public static float PREMIUM_RATE_SP;
|
||||
@ -2650,6 +2651,7 @@ public final class Config
|
||||
FACTION_EVIL_TEAM_NAME = CustomSettings.getString("EvilTeamName", "Evil");
|
||||
FACTION_GOOD_NAME_COLOR = Integer.decode("0x" + CustomSettings.getString("GoodNameColor", "00FF00"));
|
||||
FACTION_EVIL_NAME_COLOR = Integer.decode("0x" + CustomSettings.getString("EvilNameColor", "0000FF"));
|
||||
FACTION_SPECIFIC_CHAT = Boolean.valueOf(CustomSettings.getBoolean("EnableFactionChat", true));
|
||||
|
||||
PREMIUM_SYSTEM_ENABLED = CustomSettings.getBoolean("EnablePremiumSystem", false);
|
||||
PREMIUM_RATE_XP = CustomSettings.getFloat("PremiumRateXp", 2);
|
||||
|
@ -200,12 +200,12 @@ public final class L2World
|
||||
return _allPlayers.size();
|
||||
}
|
||||
|
||||
public int getAllgoodPlayersCount()
|
||||
public int getAllGoodPlayersCount()
|
||||
{
|
||||
return _allGoodPlayers.size();
|
||||
}
|
||||
|
||||
public int getAllevilPlayersCount()
|
||||
public int getAllEvilPlayersCount()
|
||||
{
|
||||
return _allEvilPlayers.size();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user