Faction balance online players.

This commit is contained in:
mobius
2015-01-15 02:08:27 +00:00
parent 37b9e72fe2
commit 01bb57d197
9 changed files with 106 additions and 2 deletions

View File

@@ -28,6 +28,7 @@ import com.l2jserver.gameserver.datatables.SecondaryAuthData;
import com.l2jserver.gameserver.instancemanager.AntiFeedManager;
import com.l2jserver.gameserver.instancemanager.PunishmentManager;
import com.l2jserver.gameserver.model.CharSelectInfoPackage;
import com.l2jserver.gameserver.model.L2World;
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
import com.l2jserver.gameserver.model.events.Containers;
import com.l2jserver.gameserver.model.events.EventDispatcher;
@@ -126,6 +127,28 @@ public class CharacterSelect extends L2GameClientPacket
return;
}
if (Config.FACTION_SYSTEM_ENABLED && Config.FACTION_BALANCE_ONLINE_PLAYERS)
{
if (info.isGood() && (L2World.getInstance().getAllGoodPlayersCount() >= ((L2World.getInstance().getAllEvilPlayersCount() + Config.FACTION_BALANCE_PLAYER_EXCEED_LIMIT))))
{
final NpcHtmlMessage msg = new NpcHtmlMessage();
msg.setFile(info.getHtmlPrefix(), "data/html/mods/Faction/ExceededOnlineLimit.htm");
msg.replace("%more%", Config.FACTION_GOOD_TEAM_NAME);
msg.replace("%less%", Config.FACTION_EVIL_TEAM_NAME);
client.sendPacket(msg);
return;
}
if (info.isEvil() && (L2World.getInstance().getAllEvilPlayersCount() >= ((L2World.getInstance().getAllGoodPlayersCount() + Config.FACTION_BALANCE_PLAYER_EXCEED_LIMIT))))
{
final NpcHtmlMessage msg = new NpcHtmlMessage();
msg.setFile(info.getHtmlPrefix(), "data/html/mods/Faction/ExceededOnlineLimit.htm");
msg.replace("%more%", Config.FACTION_EVIL_TEAM_NAME);
msg.replace("%less%", Config.FACTION_GOOD_TEAM_NAME);
client.sendPacket(msg);
return;
}
}
// The L2PcInstance must be created here, so that it can be attached to the L2GameClient
if (Config.DEBUG)
{

View File

@@ -132,6 +132,11 @@ public abstract class AbstractHtmlPacket extends L2GameServerPacket
public final void runImpl()
{
L2PcInstance player = getClient().getActiveChar();
if (player == null)
{
return;
}
player.clearHtmlActions(getScope());
if (_disabledValidation)

View File

@@ -307,6 +307,16 @@ public class CharSelectionInfo extends L2GameServerPacket
charInfopackage.setY(chardata.getInt("y"));
charInfopackage.setZ(chardata.getInt("z"));
final int faction = chardata.getInt("faction");
if (faction == 1)
{
charInfopackage.setGood();
}
if (faction == 2)
{
charInfopackage.setEvil();
}
if (Config.L2JMOD_MULTILANG_ENABLE)
{
String lang = chardata.getString("language");