فهرست منبع

TVT fixes by FBIagent: http://www.l2jserver.com/forum/thread.php?threadid=28612

Sami 17 سال پیش
والد
کامیت
98cc6cbb39

+ 29 - 44
L2_GameServer_T1/java/net/sf/l2j/gameserver/handler/admincommandhandlers/AdminTvTEvent.java

@@ -24,90 +24,75 @@ import net.sf.l2j.gameserver.model.entity.TvTEventTeleporter;
 
 /**
  * @author FBIagent
- *
- * The class handles administrator commands for the TvT Engine which was first implemented by FBIagent
  */
-public class AdminTvTEvent implements IAdminCommandHandler
-{
+public class AdminTvTEvent
+implements IAdminCommandHandler {
 	private static final String[] ADMIN_COMMANDS = {"admin_tvt_add", "admin_tvt_remove"};
 
 	private static final int REQUIRED_LEVEL = Config.GM_MIN;
 
-	public boolean useAdminCommand(String command, L2PcInstance adminInstance)
-	{
-		if (!Config.ALT_PRIVILEGES_ADMIN)
-		{
-			if (!(checkLevel(adminInstance.getAccessLevel()) && adminInstance.isGM()))
+	public boolean useAdminCommand( String command, L2PcInstance adminInstance ) {
+		if ( !Config.ALT_PRIVILEGES_ADMIN ) {
+			if ( !checkLevel( adminInstance.getAccessLevel() ) || !adminInstance.isGM() ) {
 				return false;
+			}
 		}
 
-		GMAudit.auditGMAction(adminInstance.getName(), command, (adminInstance.getTarget() != null ? adminInstance.getTarget().getName() : "no-target"), "");
+		GMAudit.auditGMAction( adminInstance.getName(), command, ( adminInstance.getTarget() != null ? adminInstance.getTarget().getName() : "no-target" ), "" );
 
-		if (command.equals("admin_tvt_add"))
-		{
+		if ( command.equals( "admin_tvt_add" ) ) {
 			L2Object target = adminInstance.getTarget();
 
-			if (target == null || !(target instanceof L2PcInstance))
-			{
-				adminInstance.sendMessage("You should select a player!");
+			if ( target == null || !( target instanceof L2PcInstance ) ) {
+				adminInstance.sendMessage( "You should select a player!" );
 				return true;
 			}
 
-			add(adminInstance, (L2PcInstance)target);
-		}
-		else if (command.equals("admin_tvt_remove"))
-		{
+			add( adminInstance, ( L2PcInstance )target );
+		} else if ( command.equals( "admin_tvt_remove" ) ) {
 			L2Object target = adminInstance.getTarget();
 
-			if (target == null || !(target instanceof L2PcInstance))
-			{
-				adminInstance.sendMessage("You should select a player!");
+			if ( target == null || !( target instanceof L2PcInstance ) ) {
+				adminInstance.sendMessage( "You should select a player!" );
 				return true;
 			}
 
-			remove(adminInstance, (L2PcInstance)target);
+			remove( adminInstance, ( L2PcInstance )target );
 		}
 
 		return true;
 	}
 
-	public String[] getAdminCommandList()
-	{
+	public String[] getAdminCommandList() {
 		return ADMIN_COMMANDS;
 	}
 
-	private boolean checkLevel(int level)
-	{
+	private boolean checkLevel( int level ) {
 		return level >= REQUIRED_LEVEL;
 	}
 
-	private void add(L2PcInstance adminInstance, L2PcInstance playerInstance)
-	{
-		if (TvTEvent.isPlayerParticipant(playerInstance.getName()))
-		{
-			adminInstance.sendMessage("Player already participated in the event!");
+	private void add( L2PcInstance adminInstance, L2PcInstance playerInstance ) {
+		if ( TvTEvent.isPlayerParticipant( playerInstance.getObjectId() ) ) {
+			adminInstance.sendMessage( "Player already participated in the event!" );
 			return;
 		}
 
-		if (!TvTEvent.addParticipant(playerInstance))
-		{
-			adminInstance.sendMessage("Player instance could not be added, it seems to be null!");
+		if ( !TvTEvent.addParticipant( playerInstance ) ) {
+			adminInstance.sendMessage( "Player instance could not be added, it seems to be null!" );
 			return;
 		}
 
-		if (TvTEvent.isStarted())
-			// we don't need to check return value of TvTEvent.getParticipantTeamCoordinates() for null, TvTEvent.addParticipant() returned true so target is in event
-			new TvTEventTeleporter(playerInstance, TvTEvent.getParticipantTeamCoordinates(playerInstance.getName()), true, false);
+		if ( TvTEvent.isStarted() ) {
+			new TvTEventTeleporter( playerInstance, TvTEvent.getParticipantTeamCoordinates( playerInstance.getObjectId() ), true, false );
+		}
 	}
 
-	private void remove(L2PcInstance adminInstance, L2PcInstance playerInstance)
-	{
-		if (!TvTEvent.removeParticipant(playerInstance.getName()))
-		{
-			adminInstance.sendMessage("Player is not part of the event!");
+	private void remove( L2PcInstance adminInstance, L2PcInstance playerInstance ) {
+		if ( !TvTEvent.removeParticipant( playerInstance.getObjectId() ) ) {
+			adminInstance.sendMessage( "Player is not part of the event!" );
 			return;
 		}
 
-		new TvTEventTeleporter(playerInstance, Config.TVT_EVENT_PARTICIPATION_NPC_COORDINATES, true, true);
+		new TvTEventTeleporter( playerInstance, Config.TVT_EVENT_PARTICIPATION_NPC_COORDINATES, true, true );
 	}
 }

+ 1 - 1
L2_GameServer_T1/java/net/sf/l2j/gameserver/handler/itemhandlers/Potions.java

@@ -92,7 +92,7 @@ public class Potions implements IItemHandler
 		else
 			return;
 
-		if (!TvTEvent.onPotionUse(playable.getName()))
+		if (!TvTEvent.onPotionUse(playable.getObjectId()))
 		{
 			playable.sendPacket(ActionFailed.STATIC_PACKET);
 			return;

+ 1 - 1
L2_GameServer_T1/java/net/sf/l2j/gameserver/handler/itemhandlers/ScrollOfEscape.java

@@ -60,7 +60,7 @@ public class ScrollOfEscape implements IItemHandler
         L2PcInstance activeChar = (L2PcInstance)playable;
 
         // Thanks nbd
-        if (!TvTEvent.onEscapeUse(activeChar.getName()))
+        if (!TvTEvent.onEscapeUse(activeChar.getObjectId()))
         {
         	activeChar.sendPacket(ActionFailed.STATIC_PACKET);
         	return;

+ 1 - 1
L2_GameServer_T1/java/net/sf/l2j/gameserver/handler/itemhandlers/SummonItems.java

@@ -48,7 +48,7 @@ public class SummonItems implements IItemHandler
 		if (!(playable instanceof L2PcInstance))
 			return;
 
-		if (!TvTEvent.onItemSummon(playable.getName()))
+		if (!TvTEvent.onItemSummon(playable.getObjectId()))
 			return;
 
 		L2PcInstance activeChar = (L2PcInstance)playable;

+ 1 - 1
L2_GameServer_T1/java/net/sf/l2j/gameserver/handler/skillhandlers/Recall.java

@@ -37,7 +37,7 @@ public class Recall implements ISkillHandler
         if (activeChar instanceof L2PcInstance)
         {
         	// Thanks nbd
-        	if (!TvTEvent.onEscapeUse(((L2PcInstance)activeChar).getName()))
+        	if (!TvTEvent.onEscapeUse(((L2PcInstance)activeChar).getObjectId()))
         	{
         		((L2PcInstance)activeChar).sendPacket(ActionFailed.STATIC_PACKET);
         		return;

+ 1 - 1
L2_GameServer_T1/java/net/sf/l2j/gameserver/handler/usercommandhandlers/Escape.java

@@ -43,7 +43,7 @@ public class Escape implements IUserCommandHandler
     public boolean useUserCommand(@SuppressWarnings("unused") int id, L2PcInstance activeChar)
     {
     	// Thanks nbd
-    	if (!TvTEvent.onEscapeUse(activeChar.getName()))
+    	if (!TvTEvent.onEscapeUse(activeChar.getObjectId()))
     	{
     		activeChar.sendPacket(ActionFailed.STATIC_PACKET);
     		return false;

+ 2 - 2
L2_GameServer_T1/java/net/sf/l2j/gameserver/handler/voicedcommandhandlers/Wedding.java

@@ -328,7 +328,7 @@ public class Wedding implements IVoicedCommandHandler
             	}
             }
         }
-        else if (!TvTEvent.onEscapeUse(partner.getName()))
+        else if (!TvTEvent.onEscapeUse(partner.getObjectId()))
         {
         	activeChar.sendMessage("Your partner is in an event.");
         	return false;
@@ -375,7 +375,7 @@ public class Wedding implements IVoicedCommandHandler
             return false;
         }
         // Thanks nbd
-        else if (!TvTEvent.onEscapeUse(activeChar.getName()))
+        else if (!TvTEvent.onEscapeUse(activeChar.getObjectId()))
         {
         	activeChar.sendPacket(ActionFailed.STATIC_PACKET);
         	return false;

+ 3 - 2
L2_GameServer_T1/java/net/sf/l2j/gameserver/model/actor/instance/L2PcInstance.java

@@ -3442,7 +3442,7 @@ public final class L2PcInstance extends L2PlayableInstance
 	public void onAction(L2PcInstance player)
 	{
 		// See description in TvTEvent.java
-		if (!TvTEvent.onAction(player.getName(), getName()))
+		if (!TvTEvent.onAction( player, getObjectId()))
 		{
 			player.sendPacket(ActionFailed.STATIC_PACKET);
 			return;
@@ -11117,7 +11117,8 @@ public final class L2PcInstance extends L2PlayableInstance
     @Override
     public boolean mustFallDownOnDeath()
     {
-        return super.mustFallDownOnDeath() && !TvTEvent.isPlayerParticipant(getName());
+        return	super.mustFallDownOnDeath() &&
+        		( !TvTEvent.isStarted() || !TvTEvent.isPlayerParticipant( getObjectId() ) );
     }
 
     public void setAgathionId(int npcId)

+ 1 - 1
L2_GameServer_T1/java/net/sf/l2j/gameserver/model/actor/instance/L2TvTEventNpcInstance.java

@@ -44,7 +44,7 @@ public class L2TvTEventNpcInstance extends L2NpcInstance
 		{
 			String htmFile = "data/html/mods/";
 
-			if (!TvTEvent.isPlayerParticipant(playerInstance.getName()))
+			if (!TvTEvent.isPlayerParticipant(playerInstance.getObjectId()))
 				htmFile += "TvTEventParticipation";
 			else
 				htmFile += "TvTEventRemoveParticipation";

+ 289 - 295
L2_GameServer_T1/java/net/sf/l2j/gameserver/model/entity/TvTEvent.java

@@ -25,7 +25,6 @@ import net.sf.l2j.gameserver.datatables.SpawnTable;
 import net.sf.l2j.gameserver.model.L2Character;
 import net.sf.l2j.gameserver.model.L2Spawn;
 import net.sf.l2j.gameserver.model.L2Summon;
-import net.sf.l2j.gameserver.model.L2World;
 import net.sf.l2j.gameserver.model.PcInventory;
 import net.sf.l2j.gameserver.model.actor.instance.L2DoorInstance;
 import net.sf.l2j.gameserver.model.actor.instance.L2NpcInstance;
@@ -44,10 +43,8 @@ import net.sf.l2j.util.Rnd;
 /**
  * @author FBIagent
  */
-public class TvTEvent
-{
-	enum EventState
-	{
+public class TvTEvent {
+	enum EventState {
 		INACTIVE,
 		INACTIVATING,
 		PARTICIPATING,
@@ -56,9 +53,9 @@ public class TvTEvent
 		REWARDING
 	}
 
-	protected static final Logger _log = Logger.getLogger(TvTEvent.class.getName());
+	protected static final Logger _log = Logger.getLogger( TvTEvent.class.getName() );
 	/**	The teams of the TvTEvent<br> */
-	private static TvTEventTeam[] _teams = new TvTEventTeam[2]; // event only allow max 2 teams
+	private static TvTEventTeam[] _teams = new TvTEventTeam[ 2 ];
 	/** The state of the TvTEvent<br> */
 	private static EventState _state = EventState.INACTIVE;
 	/** The spawn of the participation npc<br> */
@@ -69,16 +66,15 @@ public class TvTEvent
 	/**
 	 * No instance of this class!<br>
 	 */
-	private TvTEvent()
-	{}
+	private TvTEvent() {
+	}
 
 	/**
 	 * Teams initializing<br>
 	 */
-	public static void init()
-	{
-		_teams[0] = new TvTEventTeam(Config.TVT_EVENT_TEAM_1_NAME, Config.TVT_EVENT_TEAM_1_COORDINATES);
-		_teams[1] = new TvTEventTeam(Config.TVT_EVENT_TEAM_2_NAME, Config.TVT_EVENT_TEAM_2_COORDINATES);
+	public static void init() {
+		_teams[ 0 ] = new TvTEventTeam( Config.TVT_EVENT_TEAM_1_NAME, Config.TVT_EVENT_TEAM_1_COORDINATES );
+		_teams[ 1 ] = new TvTEventTeam( Config.TVT_EVENT_TEAM_2_NAME, Config.TVT_EVENT_TEAM_2_COORDINATES );
 	}
 
 	/**
@@ -88,44 +84,39 @@ public class TvTEvent
 	 *
 	 * @return boolean: true if success, otherwise false<br>
 	 */
-	public static boolean startParticipation()
-	{
-		L2NpcTemplate tmpl = NpcTable.getInstance().getTemplate(Config.TVT_EVENT_PARTICIPATION_NPC_ID);
+	public static boolean startParticipation() {
+		L2NpcTemplate tmpl = NpcTable.getInstance().getTemplate( Config.TVT_EVENT_PARTICIPATION_NPC_ID );
 
-		if (tmpl == null)
-		{
+		if ( tmpl == null ) {
 			_log.warning("TvTEventEngine[TvTEvent.startParticipation()]: L2NpcTemplate is a NullPointer -> Invalid npc id in configs?");
 			return false;
 		}
 
-        try
-        {
-            _npcSpawn = new L2Spawn(tmpl);
+        try {
+            _npcSpawn = new L2Spawn( tmpl );
 
-            _npcSpawn.setLocx(Config.TVT_EVENT_PARTICIPATION_NPC_COORDINATES[0]);
-            _npcSpawn.setLocy(Config.TVT_EVENT_PARTICIPATION_NPC_COORDINATES[1]);
-            _npcSpawn.setLocz(Config.TVT_EVENT_PARTICIPATION_NPC_COORDINATES[2]);
-            _npcSpawn.setAmount(1);
-            _npcSpawn.setHeading(0);
-            _npcSpawn.setRespawnDelay(1);
+            _npcSpawn.setLocx( Config.TVT_EVENT_PARTICIPATION_NPC_COORDINATES[ 0 ] );
+            _npcSpawn.setLocy( Config.TVT_EVENT_PARTICIPATION_NPC_COORDINATES[ 1 ] );
+            _npcSpawn.setLocz( Config.TVT_EVENT_PARTICIPATION_NPC_COORDINATES[ 2 ] );
+            _npcSpawn.setAmount( 1 );
+            _npcSpawn.setHeading( 0 );
+            _npcSpawn.setRespawnDelay( 1 );
             // later no need to delete spawn from db, we don't store it (false)
-            SpawnTable.getInstance().addNewSpawn(_npcSpawn, false);
+            SpawnTable.getInstance().addNewSpawn( _npcSpawn, false );
             _npcSpawn.init();
             _lastNpcSpawn = _npcSpawn.getLastSpawn();
-            _lastNpcSpawn.setCurrentHp(_lastNpcSpawn.getMaxHp());
-            _lastNpcSpawn.setTitle("TvT Event Participation");
+            _lastNpcSpawn.setCurrentHp( _lastNpcSpawn.getMaxHp() );
+            _lastNpcSpawn.setTitle( "TvT Event Participation" );
             _lastNpcSpawn.isAggressive();
             _lastNpcSpawn.decayMe();
-            _lastNpcSpawn.spawnMe(_npcSpawn.getLastSpawn().getX(), _npcSpawn.getLastSpawn().getY(), _npcSpawn.getLastSpawn().getZ());
-            _lastNpcSpawn.broadcastPacket(new MagicSkillUse(_lastNpcSpawn, _lastNpcSpawn, 1034, 1, 1, 1));
-        }
-        catch (Exception e)
-        {
-            _log.warning("TvTEventEngine[TvTEvent.startParticipation()]: exception: " + e);
+            _lastNpcSpawn.spawnMe( _npcSpawn.getLastSpawn().getX(), _npcSpawn.getLastSpawn().getY(), _npcSpawn.getLastSpawn().getZ() );
+            _lastNpcSpawn.broadcastPacket( new MagicSkillUse( _lastNpcSpawn, _lastNpcSpawn, 1034, 1, 1, 1 ) );
+        } catch ( Exception e ) {
+            _log.warning( "TvTEventEngine[TvTEvent.startParticipation()]: exception: " + e );
             return false;
         }
 
-		setState(EventState.PARTICIPATING);
+		setState( EventState.PARTICIPATING );
 		return true;
 	}
 
@@ -139,35 +130,36 @@ public class TvTEvent
 	 *
 	 * @return boolean: true if success, otherwise false<br>
 	 */
-	public static boolean startFight()
-	{
-		setState(EventState.STARTING);
-
-		// not enough participants
-		if (_teams[0].getParticipatedPlayerCount() < Config.TVT_EVENT_MIN_PLAYERS_IN_TEAMS || _teams[1].getParticipatedPlayerCount() < Config.TVT_EVENT_MIN_PLAYERS_IN_TEAMS)
-		{
-			setState(EventState.INACTIVE);
-			_teams[0].cleanMe();
-			_teams[1].cleanMe();
+	public static boolean startFight() {
+		// Set state to STARTING
+		setState( EventState.STARTING );
+
+		// Check for enought participants
+		if (	_teams[ 0 ].getParticipatedPlayerCount() < Config.TVT_EVENT_MIN_PLAYERS_IN_TEAMS ||
+				_teams[ 1 ].getParticipatedPlayerCount() < Config.TVT_EVENT_MIN_PLAYERS_IN_TEAMS ) {
+			// Set state INACTIVE
+			setState( EventState.INACTIVE );
+			// Cleanup of teams
+			_teams[ 0 ].cleanMe();
+			_teams[ 1 ].cleanMe();
+			// Unspawn the event NPC
 			unSpawnNpc();
 			return false;
 		}
 
+		// Closes all doors specified in configs for tvt
 		closeDoors();
-		setState(EventState.STARTED); // set state to STARTED here, so TvTEventTeleporter know to teleport to team spot
-
-		// teleport all participants to there team spot
-		for (TvTEventTeam team : _teams)
-		{
-			for (String playerName : team.getParticipatedPlayerNames())
-			{
-				L2PcInstance playerInstance = team.getParticipatedPlayers().get(playerName);
-
-				if (playerInstance == null)
-					continue;
-
-				// implements Runnable and starts itself in constructor
-				new TvTEventTeleporter(playerInstance, team.getCoordinates(), false, false);
+		// Set state STARTED
+		setState( EventState.STARTED );
+
+		// Iterate over all teams
+		for ( TvTEventTeam team : _teams ) {
+			// Iterate over all participated player instances in this team
+			for ( L2PcInstance playerInstance : team.getParticipatedPlayers().values() ) {
+				if ( playerInstance != null ) {
+					// Teleporter implements Runnable and starts itself
+					new TvTEventTeleporter( playerInstance, team.getCoordinates(), false, false );
+				}
 			}
 		}
 
@@ -186,78 +178,78 @@ public class TvTEvent
 	 */
 	public static String calculateRewards()
 	{
-		if (_teams[0].getPoints() == _teams[1].getPoints())
-		{
-			if (_teams[0].getParticipatedPlayerCount() == 0 || _teams[1].getParticipatedPlayerCount() == 0)
-			{
-				// the fight cannot be completed
+		if (_teams[ 0 ].getPoints() == _teams[ 1 ].getPoints()) {
+			// Check if one of the teams have no more players left
+			if ( _teams[ 0 ].getParticipatedPlayerCount() == 0 || _teams[ 1 ].getParticipatedPlayerCount() == 0 ) {
+				// set state to rewarding
 				setState(EventState.REWARDING);
+				// return here, the fight can't be completed
 				return "TvT Event: Event finish. No team won, cause of inactivity!";
 			}
 
+			// Both teams have equals points
 			sysMsgToAllParticipants("TvT Event: Both teams are at a tie, next team to get a kill wins!");
 		}
 
-		while (_teams[0].getPoints() == _teams[1].getPoints())
-		{
-			try
-			{
+		// Wait till one of the teams make a kill
+		while ( _teams[ 0 ].getPoints() == _teams[ 1 ].getPoints() ) {
+			try {
+				// We don't want to stress CPU to much
 				Thread.sleep(1);
+			} catch ( InterruptedException ie ) {
 			}
-			catch (InterruptedException ie)
-			{}
 		}
 
-		setState(EventState.REWARDING); // after state REWARDING is set, nobody can point anymore
+		// Set state REWARDING so nobody can point anymore
+		setState( EventState.REWARDING );
 
-		byte teamId = (byte)(_teams[0].getPoints() > _teams[1].getPoints() ? 0 : 1); // which team wins?
-		TvTEventTeam team = _teams[teamId];
+		// Get team which has more points
+		TvTEventTeam team = _teams[ _teams[ 0 ].getPoints() > _teams[ 1 ].getPoints() ? 0 : 1 ];
 
-		for (String playerName : team.getParticipatedPlayerNames())
-		{
-			L2PcInstance playerInstance = team.getParticipatedPlayers().get(playerName);
+		// Iterate over all participated player instances of the winning team
+		for ( L2PcInstance playerInstance : team.getParticipatedPlayers().values() ) {
+			// Check for nullpointer
+			if ( playerInstance == null ) {
+				continue;
+			}
 
-			for (int[] reward : Config.TVT_EVENT_REWARDS)
-			{
-				if (playerInstance == null)
-					continue;
+			SystemMessage systemMessage = null;
 
+			// Iterate over all tvt event rewards
+			for ( int[] reward : Config.TVT_EVENT_REWARDS ) {
 				PcInventory inv = playerInstance.getInventory();
 
-				if (ItemTable.getInstance().createDummyItem(reward[0]).isStackable())
-					inv.addItem("TvT Event", reward[0], reward[1], playerInstance, playerInstance);
-				else
-				{
-					for (int i=0;i<reward[1];i++)
-						inv.addItem("TvT Event", reward[0], 1, playerInstance, playerInstance);
+				// Check for stackable item, non stackabe items need to be added one by one
+				if ( ItemTable.getInstance().createDummyItem( reward[ 0 ] ).isStackable() ) {
+					inv.addItem( "TvT Event", reward[ 0 ], reward[ 1 ], playerInstance, playerInstance );
+
+					if ( reward[ 1 ] > 1 ) {
+						systemMessage = new SystemMessage( SystemMessageId.EARNED_S2_S1_S );
+						systemMessage.addItemName( reward[ 0 ] );
+						systemMessage.addNumber( reward[ 1 ] );
+					} else {
+						systemMessage = new SystemMessage( SystemMessageId.EARNED_ITEM );
+						systemMessage.addItemName( reward[ 0 ] );
+					}
+
+					playerInstance.sendPacket( systemMessage );
+				} else {
+					for ( int i = 0;i < reward[ 1 ];++ i ) {
+						inv.addItem( "TvT Event", reward[ 0 ], 1, playerInstance, playerInstance );
+						systemMessage = new SystemMessage( SystemMessageId.EARNED_ITEM );
+						systemMessage.addItemName( reward[ 0 ] );
+						playerInstance.sendPacket( systemMessage );
+					}
 				}
-
-				SystemMessage systemMessage = null;
-
-				if (reward[1] > 1)
-				{
-					systemMessage = new SystemMessage(SystemMessageId.EARNED_S2_S1_S);
-					systemMessage.addItemName(reward[0]);
-					systemMessage.addNumber(reward[1]);
-				}
-				else
-				{
-					systemMessage = new SystemMessage(SystemMessageId.EARNED_ITEM);
-					systemMessage.addItemName(reward[0]);
-				}
-
-				playerInstance.sendPacket(systemMessage);
 			}
 
-			StatusUpdate statusUpdate = new StatusUpdate(playerInstance.getObjectId());
+			StatusUpdate statusUpdate = new StatusUpdate( playerInstance.getObjectId() );
+			NpcHtmlMessage npcHtmlMessage = new NpcHtmlMessage( 0 );
 
-			statusUpdate.addAttribute(StatusUpdate.CUR_LOAD, playerInstance.getCurrentLoad());
-			playerInstance.sendPacket(statusUpdate);
-
-			NpcHtmlMessage npcHtmlMessage = new NpcHtmlMessage(0);
-
-			npcHtmlMessage.setHtml("<html><head><title>TvT Event</title></head><body>Your team won the event. Look in your inventory, there should be your reward.</body></html>");
-			playerInstance.sendPacket(npcHtmlMessage);
+			statusUpdate.addAttribute( StatusUpdate.CUR_LOAD, playerInstance.getCurrentLoad() );
+			npcHtmlMessage.setHtml( "<html><head><title>TvT Event</title></head><body>Your team won the event. Look in your inventory, there should be your reward.</body></html>" );
+			playerInstance.sendPacket( statusUpdate );
+			playerInstance.sendPacket( npcHtmlMessage );
 		}
 
 		return "TvT Event: Event finish. Team " + team.getName() + " won with " + team.getPoints() + " kills.";
@@ -274,26 +266,28 @@ public class TvTEvent
 	 */
 	public static void stopFight()
 	{
+		// Set state INACTIVATING
 		setState(EventState.INACTIVATING);
+		//Unspawn event npc
 		unSpawnNpc();
+		// Open alldoors specified in configs for tvt
 		openDoors();
 
-		for (TvTEventTeam team : _teams)
-		{
-			for (String playerName : team.getParticipatedPlayerNames())
-			{
-				L2PcInstance playerInstance = team.getParticipatedPlayers().get(playerName);
-
-				if (playerInstance == null)
-					continue;
-
-				new TvTEventTeleporter(playerInstance, Config.TVT_EVENT_PARTICIPATION_NPC_COORDINATES, false, false);
+		// Iterate over all teams
+		for ( TvTEventTeam team : _teams ) {
+			for ( L2PcInstance playerInstance : team.getParticipatedPlayers().values() ) {
+				// Check for nullpointer
+				if ( playerInstance != null ) {
+					new TvTEventTeleporter( playerInstance, Config.TVT_EVENT_PARTICIPATION_NPC_COORDINATES, false, false );
+				}
 			}
 		}
 
-		_teams[0].cleanMe();
-		_teams[1].cleanMe();
-		setState(EventState.INACTIVE);
+		// Cleanup of teams
+		_teams[ 0 ].cleanMe();
+		_teams[ 1 ].cleanMe();
+		// Set state INACTIVE
+		setState( EventState.INACTIVE );
 	}
 
 	/**
@@ -304,19 +298,22 @@ public class TvTEvent
 	 * @param playerInstance as L2PcInstance<br>
 	 * @return boolean: true if success, otherwise false<br>
 	 */
-	public static synchronized boolean addParticipant(L2PcInstance playerInstance)
-	{
-		if (playerInstance == null)
+	public static synchronized boolean addParticipant( L2PcInstance playerInstance ) {
+		// Check for nullpoitner
+		if ( playerInstance == null ) {
 			return false;
+		}
 
 		byte teamId = 0;
 
-		if (_teams[0].getParticipatedPlayerCount() == _teams[1].getParticipatedPlayerCount())
-			teamId = (byte)(Rnd.get(2));
-		else
-			teamId = (byte)(_teams[0].getParticipatedPlayerCount() > _teams[1].getParticipatedPlayerCount() ? 1 : 0);
+		// Check to which team the player should be added
+		if ( _teams[0].getParticipatedPlayerCount() == _teams[1].getParticipatedPlayerCount() ) {
+			teamId = ( byte )( Rnd.get( 2 ) );
+		} else {
+			teamId = ( byte )( _teams[ 0 ].getParticipatedPlayerCount() > _teams[ 1 ].getParticipatedPlayerCount() ? 1 : 0 );
+		}
 
-		return _teams[teamId].addPlayer(playerInstance);
+		return _teams[ teamId ].addPlayer( playerInstance );
 	}
 
 	/**
@@ -327,15 +324,18 @@ public class TvTEvent
 	 * @param playerName as String<br>
 	 * @return boolean: true if success, otherwise false<br>
 	 */
-	public static boolean removeParticipant(String playerName)
-	{
-		byte teamId = getParticipantTeamId(playerName);
+	public static boolean removeParticipant( int playerObjectId ) {
+		// Get the teamId of the player
+		byte teamId = getParticipantTeamId( playerObjectId );
 
-		if (teamId == -1)
-			return false;
+		// Check if the player is participant
+		if ( teamId != -1 ) {
+			// Remove the player from team
+			_teams[ teamId ].removePlayer( playerObjectId );
+			return true;
+		}
 
-		_teams[teamId].removePlayer(playerName);
-		return true;
+		return false;
 	}
 
 	/**
@@ -345,55 +345,53 @@ public class TvTEvent
 	 *
 	 * @param message as String<br>
 	 */
-	public static void sysMsgToAllParticipants(String message)
-	{
-		for (L2PcInstance playerInstance : _teams[0].getParticipatedPlayers().values())
-		{
-			if (playerInstance != null)
-				playerInstance.sendMessage(message);
+	public static void sysMsgToAllParticipants( String message ) {
+		for ( L2PcInstance playerInstance : _teams[ 0 ].getParticipatedPlayers().values() ) {
+			if ( playerInstance != null ) {
+				playerInstance.sendMessage( message );
+			}
 		}
 
-		for (L2PcInstance playerInstance : _teams[1].getParticipatedPlayers().values())
-		{
-			if (playerInstance != null)
-				playerInstance.sendMessage(message);
+		for ( L2PcInstance playerInstance : _teams[ 1 ].getParticipatedPlayers().values() ) {
+			if ( playerInstance != null ) {
+				playerInstance.sendMessage( message );
+			}
 		}
 	}
 
 	/**
 	 * Close doors specified in configs
 	 */
-	private static void closeDoors()
-	{
-		for (int doorId : Config.TVT_EVENT_DOOR_IDS)
-		{
-			L2DoorInstance doorInstance = DoorTable.getInstance().getDoor(doorId);
+	private static void closeDoors() {
+		for ( int doorId : Config.TVT_EVENT_DOOR_IDS ) {
+			L2DoorInstance doorInstance = DoorTable.getInstance().getDoor( doorId );
 
-			if (doorInstance != null)
+			if ( doorInstance != null ) {
 				doorInstance.closeMe();
+			}
 		}
 	}
 
 	/**
 	 * Open doors specified in configs
 	 */
-	private static void openDoors()
-	{
-		for (int doorId : Config.TVT_EVENT_DOOR_IDS)
-		{
-			L2DoorInstance doorInstance = DoorTable.getInstance().getDoor(doorId);
+	private static void openDoors() {
+		for (int doorId : Config.TVT_EVENT_DOOR_IDS ) {
+			L2DoorInstance doorInstance = DoorTable.getInstance().getDoor( doorId );
 
-			if (doorInstance != null)
+			if ( doorInstance != null ) {
 				doorInstance.openMe();
+			}
 		}
 	}
 
 	/**
 	 * UnSpawns the TvTEvent npc
 	 */
-	private static void unSpawnNpc()
-	{
+	private static void unSpawnNpc() {
+		// Delete the npc
 		_lastNpcSpawn.deleteMe();
+		// Stop respawningof the npc
         _npcSpawn.stopRespawn();
         _npcSpawn = null;
 		_lastNpcSpawn = null;
@@ -404,18 +402,20 @@ public class TvTEvent
 	 *
 	 * @param playerInstance as L2PcInstance<br>
 	 */
-	public static void onLogin(L2PcInstance playerInstance)
-	{
-		if (playerInstance == null || (!isStarting() && !isStarted()))
+	public static void onLogin( L2PcInstance playerInstance ) {
+		if (	playerInstance == null ||
+				( !isStarting() && !isStarted() ) ) {
 			return;
+		}
 
-		byte teamId = getParticipantTeamId(playerInstance.getName());
+		byte teamId = getParticipantTeamId( playerInstance.getObjectId() );
 
-		if (teamId == -1)
+		if ( teamId == -1 ) {
 			return;
+		}
 
-		_teams[teamId].addPlayer(playerInstance);
-		new TvTEventTeleporter(playerInstance, _teams[teamId].getCoordinates(), true, false);
+		_teams[ teamId ].addPlayer( playerInstance );
+		new TvTEventTeleporter( playerInstance, _teams[ teamId ].getCoordinates(), true, false );
 	}
 
 	/**
@@ -423,12 +423,12 @@ public class TvTEvent
 	 *
 	 * @param playerInstance as L2PcInstance<br>
 	 */
-	public static void onLogout(L2PcInstance playerInstance)
+	public static void onLogout( L2PcInstance playerInstance )
 	{
-		if (playerInstance == null || (!isStarting() && !isStarted()))
-			return;
-
-		removeParticipant(playerInstance.getName());
+		if (	playerInstance != null &&
+				( isStarting() || isStarted() ) ) {
+			removeParticipant( playerInstance.getObjectId() );
+		}
 	}
 
 	/**
@@ -438,39 +438,38 @@ public class TvTEvent
 	 * @param command as String<br>
 	 * @param playerInstance as L2PcInstance<br>
 	 */
-	public static synchronized void onBypass(String command, L2PcInstance playerInstance)
-	{
-		if (playerInstance == null || !isParticipating())
+	public static synchronized void onBypass( String command, L2PcInstance playerInstance ) {
+		if ( playerInstance == null || !isParticipating() ) {
 			return;
+		}
 
-		if (command.equals("tvt_event_participation"))
-		{
-			NpcHtmlMessage npcHtmlMessage = new NpcHtmlMessage(0);
+		if ( command.equals( "tvt_event_participation" ) ) {
+			NpcHtmlMessage npcHtmlMessage = new NpcHtmlMessage( 0 );
 			int playerLevel = playerInstance.getLevel();
 
-			if (playerInstance.isCursedWeaponEquipped())
+			if ( playerInstance.isCursedWeaponEquipped() ) {
 				npcHtmlMessage.setHtml("<html><head><title>TvT Event</title></head><body>Cursed weapon owners are not allowed to participate.</body></html>");
-			else if (playerInstance.getKarma() > 0)
+			} else if ( playerInstance.getKarma() > 0 ) {
 				npcHtmlMessage.setHtml("<html><head><title>TvT Event</title></head><body>Chaotic players are not allowed to participate.</body></html>");
-			else if (playerLevel < Config.TVT_EVENT_MIN_LVL || playerLevel > Config.TVT_EVENT_MAX_LVL)
+			} else if ( playerLevel < Config.TVT_EVENT_MIN_LVL || playerLevel > Config.TVT_EVENT_MAX_LVL ) {
 				npcHtmlMessage.setHtml("<html><head><title>TvT Event</title></head><body>Only players from level " + Config.TVT_EVENT_MIN_LVL + " to level " + Config.TVT_EVENT_MAX_LVL + " are allowed tro participate.</body></html>");
-			else if (_teams[0].getParticipatedPlayerCount() == Config.TVT_EVENT_MAX_PLAYERS_IN_TEAMS && _teams[1].getParticipatedPlayerCount() == Config.TVT_EVENT_MAX_PLAYERS_IN_TEAMS)
+			} else if (	_teams[ 0 ].getParticipatedPlayerCount() == Config.TVT_EVENT_MAX_PLAYERS_IN_TEAMS &&
+						_teams[ 1 ].getParticipatedPlayerCount() == Config.TVT_EVENT_MAX_PLAYERS_IN_TEAMS ) {
 				npcHtmlMessage.setHtml("<html><head><title>TvT Event</title></head><body>The event is full! Only " + Config.TVT_EVENT_MAX_PLAYERS_IN_TEAMS + " players are allowed per team.</body></html>");
-			else if (addParticipant(playerInstance))
+			} else if ( addParticipant( playerInstance ) ) {
 				npcHtmlMessage.setHtml("<html><head><title>TvT Event</title></head><body>You are on the registration list now.</body></html>");
-			else // addParticipant returned false cause playerInstance == null
+			} else {
 				return;
+			}
 
-			playerInstance.sendPacket(npcHtmlMessage);
-		}
-		else if (command.equals("tvt_event_remove_participation"))
-		{
-			removeParticipant(playerInstance.getName());
+			playerInstance.sendPacket( npcHtmlMessage );
+		} else if ( command.equals( "tvt_event_remove_participation" ) ) {
+			removeParticipant( playerInstance.getObjectId() );
 
 			NpcHtmlMessage npcHtmlMessage = new NpcHtmlMessage(0);
 
-			npcHtmlMessage.setHtml("<html><head><title>TvT Event</title></head><body>You are not longer on the registration list.</body></html>");
-			playerInstance.sendPacket(npcHtmlMessage);
+			npcHtmlMessage.setHtml( "<html><head><title>TvT Event</title></head><body>You are not longer on the registration list.</body></html>" );
+			playerInstance.sendPacket( npcHtmlMessage );
 		}
 	}
 
@@ -481,28 +480,27 @@ public class TvTEvent
 	 * @param targetPlayerName as String<br>
 	 * @return boolean: true if player is allowed to target, otherwise false<br>
 	 */
-	public static boolean onAction(String playerName, String targetPlayerName)
-	{
-		if (!isStarted())
+	public static boolean onAction( L2PcInstance playerInstance, int targetedPlayerObjectId ) {
+		if ( playerInstance == null || !isStarted() ) {
 			return true;
+		}
 
-		L2PcInstance playerInstance = L2World.getInstance().getPlayer(playerName);
-
-		if (playerInstance == null)
-			return false;
-
-		if (playerInstance.isGM())
+		if ( playerInstance.isGM() ) {
 			return true;
+		}
 
-		byte playerTeamId = getParticipantTeamId(playerName);
-		byte targetPlayerTeamId = getParticipantTeamId(targetPlayerName);
+		byte playerTeamId = getParticipantTeamId( playerInstance.getObjectId() );
+		byte targetedPlayerTeamId = getParticipantTeamId( targetedPlayerObjectId );
 
-		if ((playerTeamId != -1 && targetPlayerTeamId == -1) ||
-			(playerTeamId == -1 && targetPlayerTeamId != -1))
+		if (	( playerTeamId != -1 && targetedPlayerTeamId == -1 ) ||
+				( playerTeamId == -1 && targetedPlayerTeamId != -1 ) ) {
 			return false;
+		}
 
-		if (playerTeamId != -1 && targetPlayerTeamId != -1 && playerTeamId == targetPlayerTeamId && !Config.TVT_EVENT_TARGET_TEAM_MEMBERS_ALLOWED)
+		if (	playerTeamId != -1 && targetedPlayerTeamId != -1 && playerTeamId == targetedPlayerTeamId &&
+				!Config.TVT_EVENT_TARGET_TEAM_MEMBERS_ALLOWED ) {
 			return false;
+		}
 
 		return true;
 	}
@@ -513,13 +511,14 @@ public class TvTEvent
 	 * @param playerName as String<br>
 	 * @return boolean: true if player is allowed to use potions, otherwise false<br>
 	 */
-	public static boolean onPotionUse(String playerName)
-	{
-		if (!isStarted())
+	public static boolean onPotionUse( int playerObjectId ) {
+		if ( !isStarted() ) {
 			return true;
+		}
 
-		if (isPlayerParticipant(playerName) && !Config.TVT_EVENT_POTIONS_ALLOWED)
+		if ( isPlayerParticipant( playerObjectId ) && !Config.TVT_EVENT_POTIONS_ALLOWED ) {
 			return false;
+		}
 
 		return true;
 	}
@@ -530,13 +529,14 @@ public class TvTEvent
 	 * @param playerName as String<br>
 	 * @return boolean: true if player is not in tvt event, otherwise false<br>
 	 */
-	public static boolean onEscapeUse(String playerName)
-	{
-		if (!isStarted())
+	public static boolean onEscapeUse( int playerObjectId ) {
+		if ( !isStarted() ) {
 			return true;
+		}
 
-		if (isPlayerParticipant(playerName))
+		if ( isPlayerParticipant( playerObjectId ) ) {
 			return false;
+		}
 
 		return true;
 	}
@@ -547,13 +547,15 @@ public class TvTEvent
 	 * @param playerName as String<br>
 	 * @return boolean: true if player is allowed to summon by item, otherwise false<br>
 	 */
-	public static boolean onItemSummon(String playerName)
+	public static boolean onItemSummon( int playerObjectId )
 	{
-		if (!isStarted())
+		if ( !isStarted() ) {
 			return true;
+		}
 
-		if (isPlayerParticipant(playerName) && !Config.TVT_EVENT_SUMMON_BY_ITEM_ALLOWED)
+		if ( isPlayerParticipant( playerObjectId ) && !Config.TVT_EVENT_SUMMON_BY_ITEM_ALLOWED ) {
 			return false;
+		}
 
 		return true;
 	}
@@ -564,49 +566,51 @@ public class TvTEvent
 	 * @param killerCharacter as L2Character<br>
 	 * @param killedPlayerInstance as L2PcInstance<br>
 	 */
-	public static void onKill(L2Character killerCharacter, L2PcInstance killedPlayerInstance)
+	public static void onKill( L2Character killerCharacter, L2PcInstance killedPlayerInstance )
 	{
-	    if (!isStarted() || killedPlayerInstance == null)
+	    if ( killedPlayerInstance == null || !isStarted() ) {
 	        return;
+	    }
 
-	    byte killedTeamId = getParticipantTeamId(killedPlayerInstance.getName());
+	    byte killedTeamId = getParticipantTeamId( killedPlayerInstance.getObjectId() );
 
-	    if (killedTeamId == -1)
+	    if ( killedTeamId == -1 ) {
 	        return;
+	    }
 
-	    new TvTEventTeleporter(killedPlayerInstance, _teams[killedTeamId].getCoordinates(), false, false);
+	    new TvTEventTeleporter( killedPlayerInstance, _teams[ killedTeamId ].getCoordinates(), false, false );
 
-	    if (killerCharacter == null)
+	    if ( killerCharacter == null ) {
 	        return;
+	    }
 
 		L2PcInstance killerPlayerInstance = null;
 
-		if (killerCharacter instanceof L2PetInstance || killerCharacter instanceof L2SummonInstance)
-		{
-			killerPlayerInstance = ((L2Summon)killerCharacter).getOwner();
+		if ( killerCharacter instanceof L2PetInstance || killerCharacter instanceof L2SummonInstance ) {
+			killerPlayerInstance = ( ( L2Summon )killerCharacter ).getOwner();
 
-			if (killerPlayerInstance == null)
+			if ( killerPlayerInstance == null ) {
 				return;
-		}
-		else if (killerCharacter instanceof L2PcInstance)
-		    killerPlayerInstance = (L2PcInstance)killerCharacter;
-		else
+			}
+		} else if ( killerCharacter instanceof L2PcInstance ) {
+		    killerPlayerInstance = ( L2PcInstance )killerCharacter;
+		} else {
 			return;
+		}
 
-		byte killerTeamId = getParticipantTeamId(killerPlayerInstance.getName());
+		byte killerTeamId = getParticipantTeamId( killerPlayerInstance.getObjectId() );
 
-		if (killerTeamId != -1 && killedTeamId != -1 && killerTeamId != killedTeamId)
-		{
-		    _teams[killerTeamId].increasePoints();
+		if ( killerTeamId != -1 && killedTeamId != -1 && killerTeamId != killedTeamId ) {
+			TvTEventTeam killerTeam = _teams[ killerTeamId ];
 
-		    CreatureSay cs = new CreatureSay(killerPlayerInstance.getObjectId(), Say2.TELL, killerPlayerInstance.getName(), "I have killed " + killedPlayerInstance.getName() + "!");
+		    killerTeam.increasePoints();
 
-		    for (String playerName : _teams[killerTeamId].getParticipatedPlayers().keySet())
-		    {
-		        L2PcInstance playerInstance = _teams[killerTeamId].getParticipatedPlayers().get(playerName);
+		    CreatureSay cs = new CreatureSay( killerPlayerInstance.getObjectId(), Say2.TELL, killerPlayerInstance.getName(), "I have killed " + killedPlayerInstance.getName() + "!" );
 
-		        if (playerInstance != null)
-		            playerInstance.sendPacket(cs);
+		    for ( L2PcInstance playerInstance : _teams[ killerTeamId ].getParticipatedPlayers().values() ) {
+		        if ( playerInstance != null ) {
+		            playerInstance.sendPacket( cs );
+		        }
 		    }
 		}
 	}
@@ -616,10 +620,8 @@ public class TvTEvent
 	 *
 	 * @param state as EventState<br>
 	 */
-	private static void setState(EventState state)
-	{
-		synchronized (_state)
-		{
+	private static void setState( EventState state ) {
+		synchronized ( _state ) {
 			_state = state;
 		}
 	}
@@ -629,12 +631,10 @@ public class TvTEvent
 	 *
 	 * @return boolean: true if event is inactive(waiting for next event cycle), otherwise false<br>
 	 */
-	public static boolean isInactive()
-	{
+	public static boolean isInactive() {
 		boolean isInactive;
 
-		synchronized (_state)
-		{
+		synchronized ( _state ) {
 			isInactive = _state == EventState.INACTIVE;
 		}
 
@@ -646,12 +646,10 @@ public class TvTEvent
 	 *
 	 * @return boolean: true if event is in inactivating progress, otherwise false<br>
 	 */
-	public static boolean isInactivating()
-	{
+	public static boolean isInactivating() {
 		boolean isInactivating;
 
-		synchronized (_state)
-		{
+		synchronized ( _state ) {
 			isInactivating = _state == EventState.INACTIVATING;
 		}
 
@@ -663,12 +661,10 @@ public class TvTEvent
 	 *
 	 * @return boolean: true if event is in participation progress, otherwise false<br>
 	 */
-	public static boolean isParticipating()
-	{
+	public static boolean isParticipating() {
 		boolean isParticipating;
 
-		synchronized (_state)
-		{
+		synchronized ( _state ) {
 			isParticipating = _state == EventState.PARTICIPATING;
 		}
 
@@ -680,12 +676,10 @@ public class TvTEvent
 	 *
 	 * @return boolean: true if event is starting up(setting up fighting spot, teleport players etc.), otherwise false<br>
 	 */
-	public static boolean isStarting()
-	{
+	public static boolean isStarting() {
 		boolean isStarting;
 
-		synchronized (_state)
-		{
+		synchronized ( _state ) {
 			isStarting = _state == EventState.STARTING;
 		}
 
@@ -697,12 +691,10 @@ public class TvTEvent
 	 *
 	 * @return boolean: true if event is started, otherwise false<br>
 	 */
-	public static boolean isStarted()
-	{
+	public static boolean isStarted() {
 		boolean isStarted;
 
-		synchronized (_state)
-		{
+		synchronized ( _state ) {
 			isStarted = _state == EventState.STARTED;
 		}
 
@@ -714,12 +706,10 @@ public class TvTEvent
 	 *
 	 * @return boolean: true if event is currently rewarding, otherwise false<br>
 	 */
-	public static boolean isRewarding()
-	{
+	public static boolean isRewarding() {
 		boolean isRewarding;
 
-		synchronized (_state)
-		{
+		synchronized ( _state ) {
 			isRewarding = _state == EventState.REWARDING;
 		}
 
@@ -732,9 +722,8 @@ public class TvTEvent
 	 * @param playerName as String<br>
 	 * @return byte: team name of the given playerName, if not in event -1<br>
 	 */
-	public static byte getParticipantTeamId(String playerName)
-	{
-		return (byte)(_teams[0].containsPlayer(playerName) ? 0 : (_teams[1].containsPlayer(playerName) ? 1 : -1));
+	public static byte getParticipantTeamId( int playerObjectId ) {
+		return ( byte )( _teams[ 0 ].containsPlayer( playerObjectId ) ? 0 : ( _teams[ 1 ].containsPlayer( playerObjectId ) ? 1 : -1 ) );
 	}
 
 	/**
@@ -743,9 +732,8 @@ public class TvTEvent
 	 * @param playerName as String<br>
 	 * @return int[]: coordinates of teams, 2 elements, index 0 for team 1 and index 1 for team 2<br>
 	 */
-	public static int[] getParticipantTeamCoordinates(String playerName)
-	{
-		return _teams[0].containsPlayer(playerName) ? _teams[0].getCoordinates() : (_teams[1].containsPlayer(playerName) ? _teams[1].getCoordinates() : null);
+	public static int[] getParticipantTeamCoordinates( int playerObjectId ) {
+		return _teams[0].containsPlayer( playerObjectId ) ? _teams[ 0 ].getCoordinates() : ( _teams[ 1 ].containsPlayer( playerObjectId ) ? _teams[ 1 ].getCoordinates() : null);
 	}
 
 
@@ -755,12 +743,12 @@ public class TvTEvent
 	 * @param playerName as String<br>
 	 * @return boolean: true if player is participant, ohterwise false<br>
 	 */
-	public static boolean isPlayerParticipant(String playerName)
-	{
-		if ( !Config.TVT_EVENT_ENABLED )
+	public static boolean isPlayerParticipant( int playerObjectId ) {
+		if ( !isParticipating() && !isStarting() && !isStarted() ) {
 			return false;
+		}
 
-		return _teams[0].containsPlayer(playerName) || _teams[1].containsPlayer(playerName);
+		return _teams[ 0 ].containsPlayer( playerObjectId ) || _teams[ 1 ].containsPlayer( playerObjectId );
 	}
 
 	/**
@@ -768,12 +756,12 @@ public class TvTEvent
 	 *
 	 * @return int: amount of players registered in the event<br>
 	 */
-	public static int getParticipatedPlayersCount()
-	{
-		if ( !Config.TVT_EVENT_ENABLED )
+	public static int getParticipatedPlayersCount() {
+		if ( !isParticipating() && !isStarting() && !isStarted() ) {
 			return 0;
+		}
 
-		return _teams[0].getParticipatedPlayerCount() + _teams[1].getParticipatedPlayerCount();
+		return _teams[ 0 ].getParticipatedPlayerCount() + _teams[ 1 ].getParticipatedPlayerCount();
 	}
 
 	/**
@@ -781,9 +769,11 @@ public class TvTEvent
 	 *
 	 * @return String[]: names of teams, 2 elements, index 0 for team 1 and index 1 for team 2<br>
 	 */
-	public static String[] getTeamNames()
-	{
-		return new String[]{_teams[0].getName(), _teams[1].getName()};
+	public static String[] getTeamNames() {
+		return new	String[] {
+						_teams[ 0 ].getName(),
+						_teams[ 1 ].getName()
+					};
 	}
 
 	/**
@@ -791,9 +781,11 @@ public class TvTEvent
 	 *
 	 * @return int[]: player count of teams, 2 elements, index 0 for team 1 and index 1 for team 2<br>
 	 */
-	public static int[] getTeamsPlayerCounts()
-	{
-		return new int[]{_teams[0].getParticipatedPlayerCount(), _teams[1].getParticipatedPlayerCount()};
+	public static int[] getTeamsPlayerCounts() {
+		return new	int[] {
+						_teams[ 0 ].getParticipatedPlayerCount(),
+						_teams[ 1 ].getParticipatedPlayerCount()
+					};
 	}
 
 	/**
@@ -801,8 +793,10 @@ public class TvTEvent
 	 *
 	 * @return int[]: points of teams, 2 elements, index 0 for team 1 and index 1 for team 2<br>
 	 */
-	public static int[] getTeamsPoints()
-	{
-		return new int[]{_teams[0].getPoints(), _teams[1].getPoints()};
+	public static int[] getTeamsPoints() {
+		return new	int[] {
+						_teams[ 0 ].getPoints(),
+						_teams[ 1 ].getPoints()
+					};
 	}
 }

+ 26 - 69
L2_GameServer_T1/java/net/sf/l2j/gameserver/model/entity/TvTEventTeam.java

@@ -15,7 +15,6 @@
 package net.sf.l2j.gameserver.model.entity;
 
 import java.util.Map;
-import java.util.Vector;
 
 import javolution.util.FastMap;
 import net.sf.l2j.gameserver.model.actor.instance.L2PcInstance;
@@ -23,18 +22,15 @@ import net.sf.l2j.gameserver.model.actor.instance.L2PcInstance;
 /**
  * @author FBIagent
  */
-public class TvTEventTeam
-{
+public class TvTEventTeam {
 	/** The name of the team<br> */
 	private String _name;
 	/** The team spot coordinated<br> */
-	private int[] _coordinates = new int[3];
+	private int[] _coordinates = new int[ 3 ];
 	/** The points of the team<br> */
 	private short _points;
 	/** Name and instance of all participated players in FastMap<br> */
-	private Map<String, L2PcInstance> _participatedPlayers = new FastMap<String, L2PcInstance>();
-	/** Name of all participated players in Vector<br> */
-	private Vector<String> _participatedPlayerNames = new Vector<String>();
+	private Map< Integer, L2PcInstance > _participatedPlayers = new FastMap< Integer, L2PcInstance >();
 
 	/**
 	 * C'tor initialize the team<br><br>
@@ -42,8 +38,7 @@ public class TvTEventTeam
 	 * @param name as String<br>
 	 * @param coordinates as int[]<br>
 	 */
-	public TvTEventTeam(String name, int[] coordinates)
-	{
+	public TvTEventTeam( String name, int[] coordinates ) {
 		_name = name;
 		_coordinates = coordinates;
 		_points = 0;
@@ -55,19 +50,13 @@ public class TvTEventTeam
 	 * @param playerInstance as L2PcInstance<br>
 	 * @return boolean: true if success, otherwise false<br>
 	 */
-	public boolean addPlayer(L2PcInstance playerInstance)
-	{
-		if (playerInstance == null)
+	public boolean addPlayer( L2PcInstance playerInstance ) {
+		if ( playerInstance == null ) {
 			return false;
+		}
 
-		synchronized (_participatedPlayers)
-		{
-			String playerName = playerInstance.getName();
-
-			_participatedPlayers.put(playerName, playerInstance);
-
-			if (!_participatedPlayerNames.contains(playerName))
-				_participatedPlayerNames.add(playerName);
+		synchronized ( _participatedPlayers ) {			
+			_participatedPlayers.put( playerInstance.getObjectId(), playerInstance );
 		}
 
 		return true;
@@ -78,21 +67,17 @@ public class TvTEventTeam
 	 *
 	 * @param playerName as String<br>
 	 */
-	public void removePlayer(String playerName)
-	{
-		synchronized (_participatedPlayers)
-		{
-			_participatedPlayers.remove(playerName);
-			_participatedPlayerNames.remove(playerName);
+	public void removePlayer( int playerObjectId ) {
+		synchronized ( _participatedPlayers ) {
+			_participatedPlayers.remove( playerObjectId );
 		}
 	}
 
 	/**
 	 * Increases the points of the team<br>
 	 */
-	public void increasePoints()
-	{
-		_points++;
+	public void increasePoints() {
+		++ _points;
 	}
 
 	/**
@@ -101,9 +86,7 @@ public class TvTEventTeam
 	public void cleanMe()
 	{
 		_participatedPlayers.clear();
-		_participatedPlayerNames.clear();
-		_participatedPlayers = new FastMap<String, L2PcInstance>();
-		_participatedPlayerNames = new Vector<String>();
+		_participatedPlayers = new FastMap< Integer, L2PcInstance >();
 		_points = 0;
 	}
 
@@ -113,13 +96,11 @@ public class TvTEventTeam
 	 * @param playerName as String<br>
 	 * @return boolean: true if player is in this team, otherwise false<br>
 	 */
-	public boolean containsPlayer(String playerName)
-	{
+	public boolean containsPlayer( int playerObjectId ) {
 		boolean containsPlayer;
 
-		synchronized (_participatedPlayers)
-		{
-			containsPlayer = _participatedPlayerNames.contains(playerName);
+		synchronized ( _participatedPlayers ) {
+			containsPlayer = _participatedPlayers.containsKey( playerObjectId );
 		}
 
 		return containsPlayer;
@@ -130,8 +111,7 @@ public class TvTEventTeam
 	 *
 	 * @return String: name of the team<br>
 	 */
-	public String getName()
-	{
+	public String getName() {
 		return _name;
 	}
 
@@ -140,8 +120,7 @@ public class TvTEventTeam
 	 *
 	 * @return int[]: team coordinates<br>
 	 */
-	public int[] getCoordinates()
-	{
+	public int[] getCoordinates() {
 		return _coordinates;
 	}
 
@@ -150,8 +129,7 @@ public class TvTEventTeam
 	 *
 	 * @return short: team points<br>
 	 */
-	public short getPoints()
-	{
+	public short getPoints() {
 		return _points;
 	}
 
@@ -160,46 +138,25 @@ public class TvTEventTeam
 	 *
 	 * @return Map<String, L2PcInstance>: map of players in this team<br>
 	 */
-	public Map<String, L2PcInstance> getParticipatedPlayers()
-	{
-		Map<String, L2PcInstance> participatedPlayers = null;
+	public Map< Integer, L2PcInstance > getParticipatedPlayers() {
+		Map< Integer, L2PcInstance > participatedPlayers = null;
 
-		synchronized (_participatedPlayers)
-		{
+		synchronized ( _participatedPlayers ) {
 			participatedPlayers = _participatedPlayers;
 		}
 
 		return participatedPlayers;
 	}
 
-	/**
-	 * Returns name of all participated players in Vector<br><br>
-	 *
-	 * @return Vector<String>: player names in vector<br>
-	 */
-	public Vector<String> getParticipatedPlayerNames()
-	{
-		Vector<String> participatedPlayerNames = null;
-
-		synchronized (_participatedPlayers)
-		{
-			participatedPlayerNames = _participatedPlayerNames;
-		}
-
-		return participatedPlayerNames;
-	}
-
 	/**
 	 * Returns player count of this team<br><br>
 	 *
 	 * @return int: number of players in team<br>
 	 */
-	public int getParticipatedPlayerCount()
-	{
+	public int getParticipatedPlayerCount() {
 		int participatedPlayerCount;
 
-		synchronized (_participatedPlayers)
-		{
+		synchronized ( _participatedPlayers ) {
 			participatedPlayerCount = _participatedPlayers.size();
 		}
 

+ 26 - 29
L2_GameServer_T1/java/net/sf/l2j/gameserver/model/entity/TvTEventTeleporter.java

@@ -20,14 +20,14 @@ import net.sf.l2j.gameserver.model.L2Effect;
 import net.sf.l2j.gameserver.model.L2Summon;
 import net.sf.l2j.gameserver.model.actor.instance.L2PcInstance;
 
-public class TvTEventTeleporter implements Runnable
-{
+public class TvTEventTeleporter
+implements Runnable {
 	/** The instance of the player to teleport */
-	private L2PcInstance _playerInstance;
+	private L2PcInstance _playerInstance = null;
 	/** Coordinates of the spot to teleport to */
-	private int[] _coordinates = new int[3];
+	private int[] _coordinates = new int[ 3 ];
 	/** Admin removed this player from event */
-	private boolean _adminRemove;
+	private boolean _adminRemove = false;
 
 	/**
 	 * Initialize the teleporter and start the delayed task<br><br>
@@ -37,19 +37,14 @@ public class TvTEventTeleporter implements Runnable
 	 * @param fastShedule as boolean<br>
 	 * @param adminRemove as boolean<br>
 	 */
-	public TvTEventTeleporter(L2PcInstance playerInstance, int[] coordinates, boolean fastSchedule, boolean adminRemove)
-	{
+	public TvTEventTeleporter( L2PcInstance playerInstance, int[] coordinates, boolean fastSchedule, boolean adminRemove ) {
 		_playerInstance = playerInstance;
 		_coordinates = coordinates;
 		_adminRemove = adminRemove;
 
-		// in config as seconds
-		long delay = (TvTEvent.isStarted() ? Config.TVT_EVENT_RESPAWN_TELEPORT_DELAY : Config.TVT_EVENT_START_LEAVE_TELEPORT_DELAY) * 1000;
+		long delay = ( TvTEvent.isStarted() ? Config.TVT_EVENT_RESPAWN_TELEPORT_DELAY : Config.TVT_EVENT_START_LEAVE_TELEPORT_DELAY ) * 1000;
 
-		if (fastSchedule)
-			delay = 0;
-
-		ThreadPoolManager.getInstance().scheduleGeneral(this, delay);
+		ThreadPoolManager.getInstance().scheduleGeneral( this, fastSchedule ? 0 : delay );
 	}
 
 	/**
@@ -62,32 +57,34 @@ public class TvTEventTeleporter implements Runnable
 	 *
 	 * @see java.lang.Runnable#run()<br>
 	 */
-	public void run()
-	{
-		if (_playerInstance == null)
+	public void run() {
+		if ( _playerInstance == null ) {
 			return;
+		}
 
 		L2Summon summon = _playerInstance.getPet();
 
-		if (summon != null)
-			summon.unSummon(_playerInstance);
+		if ( summon != null ) {
+			summon.unSummon( _playerInstance );
+		}
 
-		for (L2Effect effect : _playerInstance.getAllEffects())
-		{
-			if (effect != null)
+		for ( L2Effect effect : _playerInstance.getAllEffects() ) {
+			if ( effect != null ) {
 				effect.exit();
+			}
 		}
 
 		_playerInstance.doRevive();
-		_playerInstance.setCurrentCp(_playerInstance.getMaxCp());
-		_playerInstance.setCurrentHp(_playerInstance.getMaxHp());
-		_playerInstance.setCurrentMp(_playerInstance.getMaxMp());
-		_playerInstance.teleToLocation(_coordinates[0], _coordinates[1], _coordinates[2], false);
+		_playerInstance.setCurrentCp( _playerInstance.getMaxCp() );
+		_playerInstance.setCurrentHp( _playerInstance.getMaxHp() );
+		_playerInstance.setCurrentMp( _playerInstance.getMaxMp() );
+		_playerInstance.teleToLocation( _coordinates[ 0 ], _coordinates[ 1 ], _coordinates[ 2 ], false );
 
-		if (TvTEvent.isStarted() && !_adminRemove)
-			_playerInstance.setTeam(TvTEvent.getParticipantTeamId(_playerInstance.getName())+1);
-		else
-			_playerInstance.setTeam(0);
+		if (TvTEvent.isStarted() && !_adminRemove) {
+			_playerInstance.setTeam( TvTEvent.getParticipantTeamId( _playerInstance.getObjectId() ) + 1 );
+		} else {
+			_playerInstance.setTeam( 0 );
+		}
 
 		_playerInstance.broadcastStatusUpdate();
 		_playerInstance.broadcastUserInfo();