Bladeren bron

Some fixes to BETA branch:
#4699 Fix for not used configuration options and correcting values by Gnacik.
#4700 Cleanup and code refactoring by GodKratos.
#4701 More cleanup by GodKratos.
#4702 More cleanup by GodKratos.
Some cleanup by me (related with previous one).

Zoey76 14 jaren geleden
bovenliggende
commit
a98bdb14fe
39 gewijzigde bestanden met toevoegingen van 614 en 609 verwijderingen
  1. 2 2
      L2J_Server_BETA/java/com/l2jserver/Config.java
  2. 10 17
      L2J_Server_BETA/java/com/l2jserver/gameserver/SevenSigns.java
  3. 9 3
      L2J_Server_BETA/java/com/l2jserver/gameserver/datatables/ArmorSetsTable.java
  4. 3 2
      L2J_Server_BETA/java/com/l2jserver/gameserver/datatables/CharNameTable.java
  5. 2 1
      L2J_Server_BETA/java/com/l2jserver/gameserver/datatables/CharTemplateTable.java
  6. 3 6
      L2J_Server_BETA/java/com/l2jserver/gameserver/datatables/ClanTable.java
  7. 3 3
      L2J_Server_BETA/java/com/l2jserver/gameserver/datatables/HerbDropTable.java
  8. 59 56
      L2J_Server_BETA/java/com/l2jserver/gameserver/datatables/NpcTable.java
  9. 3 5
      L2J_Server_BETA/java/com/l2jserver/gameserver/datatables/SpawnTable.java
  10. 5 6
      L2J_Server_BETA/java/com/l2jserver/gameserver/instancemanager/AuctionManager.java
  11. 3 5
      L2J_Server_BETA/java/com/l2jserver/gameserver/instancemanager/CastleManager.java
  12. 1 2
      L2J_Server_BETA/java/com/l2jserver/gameserver/instancemanager/CastleManorManager.java
  13. 3 4
      L2J_Server_BETA/java/com/l2jserver/gameserver/instancemanager/ClanHallManager.java
  14. 3 5
      L2J_Server_BETA/java/com/l2jserver/gameserver/instancemanager/CoupleManager.java
  15. 1 0
      L2J_Server_BETA/java/com/l2jserver/gameserver/instancemanager/CursedWeaponsManager.java
  16. 4 3
      L2J_Server_BETA/java/com/l2jserver/gameserver/instancemanager/DimensionalRiftManager.java
  17. 3 4
      L2J_Server_BETA/java/com/l2jserver/gameserver/instancemanager/FortManager.java
  18. 5 6
      L2J_Server_BETA/java/com/l2jserver/gameserver/instancemanager/GlobalVariablesManager.java
  19. 28 29
      L2J_Server_BETA/java/com/l2jserver/gameserver/instancemanager/GrandBossManager.java
  20. 18 8
      L2J_Server_BETA/java/com/l2jserver/gameserver/instancemanager/InstanceManager.java
  21. 4 0
      L2J_Server_BETA/java/com/l2jserver/gameserver/instancemanager/ItemAuctionManager.java
  22. 24 34
      L2J_Server_BETA/java/com/l2jserver/gameserver/instancemanager/ItemsOnGroundManager.java
  23. 8 10
      L2J_Server_BETA/java/com/l2jserver/gameserver/instancemanager/MailManager.java
  24. 3 5
      L2J_Server_BETA/java/com/l2jserver/gameserver/instancemanager/MercTicketManager.java
  25. 4 11
      L2J_Server_BETA/java/com/l2jserver/gameserver/instancemanager/RaidBossSpawnManager.java
  26. 2 4
      L2J_Server_BETA/java/com/l2jserver/gameserver/instancemanager/SiegeGuardManager.java
  27. 2 3
      L2J_Server_BETA/java/com/l2jserver/gameserver/instancemanager/TerritoryWarManager.java
  28. 4 9
      L2J_Server_BETA/java/com/l2jserver/gameserver/model/AutoChatHandler.java
  29. 11 7
      L2J_Server_BETA/java/com/l2jserver/gameserver/model/actor/L2Character.java
  30. 35 41
      L2J_Server_BETA/java/com/l2jserver/gameserver/model/actor/instance/L2PcInstance.java
  31. 2 1
      L2J_Server_BETA/java/com/l2jserver/gameserver/model/entity/Auction.java
  32. 1 0
      L2J_Server_BETA/java/com/l2jserver/gameserver/model/entity/ClanHall.java
  33. 1 0
      L2J_Server_BETA/java/com/l2jserver/gameserver/model/entity/Couple.java
  34. 1 0
      L2J_Server_BETA/java/com/l2jserver/gameserver/model/entity/Fort.java
  35. 24 40
      L2J_Server_BETA/java/com/l2jserver/gameserver/model/entity/Hero.java
  36. 1 2
      L2J_Server_BETA/java/com/l2jserver/gameserver/model/quest/Quest.java
  37. 250 230
      L2J_Server_BETA/java/com/l2jserver/status/GameStatusThread.java
  38. 65 42
      L2J_Server_BETA/java/com/l2jserver/status/LoginStatusThread.java
  39. 4 3
      L2J_Server_BETA/java/config/Character.properties

+ 2 - 2
L2J_Server_BETA/java/com/l2jserver/Config.java

@@ -1467,8 +1467,8 @@ public final class Config
 					RUN_SPD_BOOST = Integer.parseInt(Character.getProperty("RunSpeedBoost", "0"));
 					DEATH_PENALTY_CHANCE = Integer.parseInt(Character.getProperty("DeathPenaltyChance", "20"));
 					RESPAWN_RESTORE_CP = Double.parseDouble(Character.getProperty("RespawnRestoreCP", "0")) / 100;
-					RESPAWN_RESTORE_HP = Double.parseDouble(Character.getProperty("RespawnRestoreHP", "70")) / 100;
-					RESPAWN_RESTORE_MP = Double.parseDouble(Character.getProperty("RespawnRestoreMP", "70")) / 100;
+					RESPAWN_RESTORE_HP = Double.parseDouble(Character.getProperty("RespawnRestoreHP", "65")) / 100;
+					RESPAWN_RESTORE_MP = Double.parseDouble(Character.getProperty("RespawnRestoreMP", "0")) / 100;
 					HP_REGEN_MULTIPLIER = Double.parseDouble(Character.getProperty("HpRegenMultiplier", "100")) /100;
 					MP_REGEN_MULTIPLIER = Double.parseDouble(Character.getProperty("MpRegenMultiplier", "100")) /100;
 					CP_REGEN_MULTIPLIER = Double.parseDouble(Character.getProperty("CpRegenMultiplier", "100")) /100;

+ 10 - 17
L2J_Server_BETA/java/com/l2jserver/gameserver/SevenSigns.java

@@ -751,14 +751,11 @@ public class SevenSigns
 	protected void restoreSevenSignsData()
 	{
 		Connection con = null;
-		PreparedStatement statement = null;
-		ResultSet rset = null;
-		
 		try
 		{
 			con = L2DatabaseFactory.getInstance().getConnection();
-			statement = con.prepareStatement(LOAD_DATA);
-			rset = statement.executeQuery();
+			PreparedStatement statement = con.prepareStatement(LOAD_DATA);
+			ResultSet rset = statement.executeQuery();
 			
 			StatsSet sevenDat = null;
 			int charObjId;
@@ -813,6 +810,7 @@ public class SevenSigns
 				
 				_lastSave.setTimeInMillis(rset.getLong("date"));
 			}
+			rset.close();
 			statement.close();
 		}
 		catch (SQLException e)
@@ -838,16 +836,14 @@ public class SevenSigns
 	 */
 	public void saveSevenSignsData()
 	{
-		Connection con = null;
-		PreparedStatement statement = null;
-		
 		if (Config.DEBUG)
 			_log.info("SevenSigns: Saving data to disk.");
 		
+		Connection con = null;
 		try
 		{
 			con = L2DatabaseFactory.getInstance().getConnection();
-			statement = con.prepareStatement(UPDATE_PLAYER);
+			PreparedStatement statement = con.prepareStatement(UPDATE_PLAYER);
 			
 			for (StatsSet sevenDat : _signsPlayerData.values())
 			{
@@ -860,6 +856,7 @@ public class SevenSigns
 				statement.setDouble(7, sevenDat.getDouble("contribution_score"));
 				statement.setInt(8, sevenDat.getInteger("charId"));
 				statement.execute();
+				statement.clearParameters();
 				if (Config.DEBUG)
 					_log.info("SevenSigns: Updated data in database for char ID " + sevenDat.getInteger("charId") + " (" + sevenDat.getString("cabal") + ")");
 			}
@@ -882,12 +879,11 @@ public class SevenSigns
 			return;
 		
 		Connection con = null;
-		PreparedStatement statement = null;
 		try
 		{
 			con = L2DatabaseFactory.getInstance().getConnection();
 			
-			statement = con.prepareStatement(UPDATE_PLAYER);
+			PreparedStatement statement = con.prepareStatement(UPDATE_PLAYER);
 			statement.setString(1, sevenDat.getString("cabal"));
 			statement.setInt(2, sevenDat.getInteger("seal"));
 			statement.setInt(3, sevenDat.getInteger("red_stones"));
@@ -912,12 +908,11 @@ public class SevenSigns
 	public final void saveSevenSignsStatus()
 	{
 		Connection con = null;
-		PreparedStatement statement = null;
 		try
 		{
 			con = L2DatabaseFactory.getInstance().getConnection();
 			
-			statement = con.prepareStatement(UPDATE_STATUS);
+			PreparedStatement statement = con.prepareStatement(UPDATE_STATUS);
 			statement.setInt(1, _currentCycle);
 			statement.setInt(2, _activePeriod);
 			statement.setInt(3, _previousWinner);
@@ -995,8 +990,6 @@ public class SevenSigns
 	 */
 	public int setPlayerInfo(int objectId, int chosenCabal, int chosenSeal)
 	{
-		Connection con = null;
-		PreparedStatement statement = null;
 		StatsSet currPlayerData = _signsPlayerData.get(objectId);
 		
 		if (currPlayerData != null)
@@ -1023,15 +1016,15 @@ public class SevenSigns
 			_signsPlayerData.put(objectId, currPlayerData);
 			
 			// Update data in database, as we have a new player signing up.
+			Connection con = null;
 			try
 			{
 				con = L2DatabaseFactory.getInstance().getConnection();
-				statement = con.prepareStatement(INSERT_PLAYER);
+				PreparedStatement statement = con.prepareStatement(INSERT_PLAYER);
 				statement.setInt(1, objectId);
 				statement.setString(2, getCabalShortName(chosenCabal));
 				statement.setInt(3, chosenSeal);
 				statement.execute();
-				
 				statement.close();
 				
 				if (Config.DEBUG)

+ 9 - 3
L2J_Server_BETA/java/com/l2jserver/gameserver/datatables/ArmorSetsTable.java

@@ -57,11 +57,10 @@ public class ArmorSetsTable
 	private void loadData()
 	{
 		Connection con = null;
-		PreparedStatement statement = null;
 		try
 		{
 			con = L2DatabaseFactory.getInstance().getConnection();
-			statement = con.prepareStatement("SELECT chest, legs, head, gloves, feet, skill, shield, shield_skill_id, enchant6skill, mw_legs, mw_head, mw_gloves, mw_feet, mw_shield FROM armorsets");
+			PreparedStatement statement = con.prepareStatement("SELECT chest, legs, head, gloves, feet, skill, shield, shield_skill_id, enchant6skill, mw_legs, mw_head, mw_gloves, mw_feet, mw_shield FROM armorsets");
 			ResultSet rset = statement.executeQuery();
 			
 			while (rset.next())
@@ -82,6 +81,9 @@ public class ArmorSetsTable
 				int mw_shield = rset.getInt("mw_shield");
 				_armorSets.put(chest, new L2ArmorSet(chest, legs, head, gloves, feet, skills, shield, shield_skill_id, enchant6skill, mw_legs, mw_head, mw_gloves, mw_feet, mw_shield));
 			}
+			
+			rset.close();
+			statement.close();
 			_log.info("ArmorSetsTable: Loaded " + _armorSets.size() + " armor sets.");
 		}
 		catch (Exception e)
@@ -92,13 +94,14 @@ public class ArmorSetsTable
 		{
 			L2DatabaseFactory.close(con);
 		}
+		
 		if (Config.CUSTOM_ARMORSETS_TABLE)
 		{
 			try
 			{
 				int cSets = _armorSets.size();
 				con = L2DatabaseFactory.getInstance().getConnection();
-				statement = con.prepareStatement("SELECT chest, legs, head, gloves, feet, skill, shield, shield_skill_id, enchant6skill, mw_legs, mw_head, mw_gloves, mw_feet, mw_shield FROM custom_armorsets");
+				PreparedStatement statement = con.prepareStatement("SELECT chest, legs, head, gloves, feet, skill, shield, shield_skill_id, enchant6skill, mw_legs, mw_head, mw_gloves, mw_feet, mw_shield FROM custom_armorsets");
 				ResultSet rset = statement.executeQuery();
 				while (rset.next())
 				{
@@ -118,6 +121,9 @@ public class ArmorSetsTable
 					int mw_shield = rset.getInt("mw_shield");
 					_armorSets.put(chest, new L2ArmorSet(chest, legs, head, gloves, feet, skills, shield, shield_skill_id, enchant6skill, mw_legs, mw_head, mw_gloves, mw_feet, mw_shield));
 				}
+				
+				rset.close();
+				statement.close();
 				_log.info("ArmorSetsTable: Loaded " + (_armorSets.size() - cSets) + " Custom armor sets.");
 			}
 			catch (Exception e)

+ 3 - 2
L2J_Server_BETA/java/com/l2jserver/gameserver/datatables/CharNameTable.java

@@ -100,12 +100,12 @@ public class CharNameTable
 		
 		int id = -1;
 		int accessLevel = 0;
+		
 		Connection con = null;
-		PreparedStatement statement = null;
 		try
 		{
 			con = L2DatabaseFactory.getInstance().getConnection();
-			statement = con.prepareStatement("SELECT charId,accesslevel FROM characters WHERE char_name=?");
+			PreparedStatement statement = con.prepareStatement("SELECT charId,accesslevel FROM characters WHERE char_name=?");
 			statement.setString(1, name);
 			ResultSet rset = statement.executeQuery();
 			while (rset.next())
@@ -124,6 +124,7 @@ public class CharNameTable
 		{
 			L2DatabaseFactory.close(con);
 		}
+		
 		if (id > 0)
 		{
 			_chars.put(id, name);

+ 2 - 1
L2J_Server_BETA/java/com/l2jserver/gameserver/datatables/CharTemplateTable.java

@@ -109,7 +109,6 @@ public final class CharTemplateTable
 				_templates[ct.classId.getId()] = ct;
 				++count;
 			}
-			
 			rset.close();
 			statement.close();
 			
@@ -167,6 +166,8 @@ public final class CharTemplateTable
 					_log.warning("char_creation_items: No data for itemId: " + itemId + " defined for classId " + classId);
 				}
 			}
+			rset.close();
+			statement.close();
 		}
 		catch (SQLException e)
 		{

+ 3 - 6
L2J_Server_BETA/java/com/l2jserver/gameserver/datatables/ClanTable.java

@@ -360,8 +360,7 @@ public class ClanTable
 		try
 		{
 			con = L2DatabaseFactory.getInstance().getConnection();
-			PreparedStatement statement;
-			statement = con.prepareStatement("REPLACE INTO clan_wars (clan1, clan2, wantspeace1, wantspeace2) VALUES(?,?,?,?)");
+			PreparedStatement statement = con.prepareStatement("REPLACE INTO clan_wars (clan1, clan2, wantspeace1, wantspeace2) VALUES(?,?,?,?)");
 			statement.setInt(1, clanId1);
 			statement.setInt(2, clanId2);
 			statement.setInt(3, 0);
@@ -413,8 +412,7 @@ public class ClanTable
 		try
 		{
 			con = L2DatabaseFactory.getInstance().getConnection();
-			PreparedStatement statement;
-			statement = con.prepareStatement("DELETE FROM clan_wars WHERE clan1=? AND clan2=?");
+			PreparedStatement statement = con.prepareStatement("DELETE FROM clan_wars WHERE clan1=? AND clan2=?");
 			statement.setInt(1, clanId1);
 			statement.setInt(2, clanId2);
 			statement.execute();
@@ -467,8 +465,7 @@ public class ClanTable
 		try
 		{
 			con = L2DatabaseFactory.getInstance().getConnection();
-			PreparedStatement statement;
-			statement = con.prepareStatement("SELECT clan1, clan2, wantspeace1, wantspeace2 FROM clan_wars");
+			PreparedStatement statement = con.prepareStatement("SELECT clan1, clan2, wantspeace1, wantspeace2 FROM clan_wars");
 			ResultSet rset = statement.executeQuery();
 			while (rset.next())
 			{

+ 3 - 3
L2J_Server_BETA/java/com/l2jserver/gameserver/datatables/HerbDropTable.java

@@ -59,10 +59,10 @@ public class HerbDropTable
 		try
 		{
 			con = L2DatabaseFactory.getInstance().getConnection();
-			PreparedStatement statement2 = con.prepareStatement("SELECT "
+			PreparedStatement statement = con.prepareStatement("SELECT "
 					+ L2DatabaseFactory.getInstance().safetyString(new String[] { "groupId", "itemId", "min", "max", "category", "chance" })
 					+ " FROM herb_droplist_groups ORDER BY groupId, chance DESC");
-			ResultSet dropData = statement2.executeQuery();
+			ResultSet dropData = statement.executeQuery();
 			L2DropData dropDat = null;
 			
 			while (dropData.next())
@@ -111,7 +111,7 @@ public class HerbDropTable
 			}
 			
 			dropData.close();
-			statement2.close();
+			statement.close();
 		}
 		catch (Exception e)
 		{

+ 59 - 56
L2J_Server_BETA/java/com/l2jserver/gameserver/datatables/NpcTable.java

@@ -70,10 +70,10 @@ public class NpcTable
 		
 		try
 		{
+			con = L2DatabaseFactory.getInstance().getConnection();
+			PreparedStatement statement;
 			try
 			{
-				con = L2DatabaseFactory.getInstance().getConnection();
-				PreparedStatement statement;
 				statement = con.prepareStatement("SELECT "
 						+ L2DatabaseFactory.getInstance().safetyString(new String[] { "id", "idTemplate", "name", "serverSideName",
 								"title", "serverSideTitle", "class", "collision_radius", "collision_height", "level", "sex", "type",
@@ -94,7 +94,6 @@ public class NpcTable
 			{
 				try
 				{
-					PreparedStatement statement;
 					statement = con.prepareStatement("SELECT "
 							+ L2DatabaseFactory.getInstance().safetyString(new String[] { "id", "idTemplate", "name", "serverSideName",
 									"title", "serverSideTitle", "class", "collision_radius", "collision_height", "level", "sex", "type",
@@ -115,7 +114,7 @@ public class NpcTable
 			
 			try
 			{
-				PreparedStatement statement = con.prepareStatement("SELECT npcid, skillid, level FROM npcskills");
+				statement = con.prepareStatement("SELECT npcid, skillid, level FROM npcskills");
 				ResultSet npcskills = statement.executeQuery();
 				L2NpcTemplate npcDat = null;
 				L2Skill npcSkill = null;
@@ -160,7 +159,7 @@ public class NpcTable
 			{
 				try
 				{
-					PreparedStatement statement = con.prepareStatement("SELECT npcid, skillid, level FROM custom_npcskills");
+					statement = con.prepareStatement("SELECT npcid, skillid, level FROM custom_npcskills");
 					ResultSet npcskills = statement.executeQuery();
 					L2NpcTemplate npcDat = null;
 					L2Skill npcSkill = null;
@@ -204,10 +203,10 @@ public class NpcTable
 			
 			try
 			{
-				PreparedStatement statement2 = con.prepareStatement("SELECT "
+				statement = con.prepareStatement("SELECT "
 						+ L2DatabaseFactory.getInstance().safetyString(new String[] { "mobId", "itemId", "min", "max", "category", "chance" })
 						+ " FROM droplist ORDER BY mobId, chance DESC");
-				ResultSet dropData = statement2.executeQuery();
+				ResultSet dropData = statement.executeQuery();
 				L2DropData dropDat = null;
 				L2NpcTemplate npcDat = null;
 				
@@ -239,7 +238,7 @@ public class NpcTable
 				}
 				
 				dropData.close();
-				statement2.close();
+				statement.close();
 			}
 			catch (Exception e)
 			{
@@ -250,10 +249,10 @@ public class NpcTable
 			{
 				try
 				{
-					PreparedStatement statement2 = con.prepareStatement("SELECT "
+					statement = con.prepareStatement("SELECT "
 							+ L2DatabaseFactory.getInstance().safetyString(new String[] { "mobId", "itemId", "min", "max", "category",
 							"chance" }) + " FROM custom_droplist ORDER BY mobId, chance DESC");
-					ResultSet dropData = statement2.executeQuery();
+					ResultSet dropData = statement.executeQuery();
 					L2DropData dropDat = null;
 					L2NpcTemplate npcDat = null;
 					int cCount = 0;
@@ -283,7 +282,7 @@ public class NpcTable
 						cCount++;
 					}
 					dropData.close();
-					statement2.close();
+					statement.close();
 					_log.info("CustomDropList: Added " + cCount + " custom droplist.");
 				}
 				catch (Exception e)
@@ -294,9 +293,9 @@ public class NpcTable
 			
 			try
 			{
-				PreparedStatement statement3 = con.prepareStatement("SELECT "
+				statement = con.prepareStatement("SELECT "
 						+ L2DatabaseFactory.getInstance().safetyString(new String[] { "npc_id", "class_id" }) + " FROM skill_learn");
-				ResultSet learndata = statement3.executeQuery();
+				ResultSet learndata = statement.executeQuery();
 				
 				while (learndata.next())
 				{
@@ -314,7 +313,7 @@ public class NpcTable
 				}
 				
 				learndata.close();
-				statement3.close();
+				statement.close();
 			}
 			catch (Exception e)
 			{
@@ -323,10 +322,10 @@ public class NpcTable
 			
 			try
 			{
-				PreparedStatement statement4 = con.prepareStatement("SELECT "
+				statement = con.prepareStatement("SELECT "
 						+ L2DatabaseFactory.getInstance().safetyString(new String[] { "boss_id", "minion_id", "amount_min", "amount_max" })
 						+ " FROM minions");
-				ResultSet minionData = statement4.executeQuery();
+				ResultSet minionData = statement.executeQuery();
 				L2MinionData minionDat = null;
 				L2NpcTemplate npcDat = null;
 				int cnt = 0;
@@ -349,7 +348,7 @@ public class NpcTable
 				}
 				
 				minionData.close();
-				statement4.close();
+				statement.close();
 				_log.info("NpcTable: Loaded " + cnt + " Minions.");
 			}
 			catch (Exception e)
@@ -362,8 +361,8 @@ public class NpcTable
 			
 			try
 			{
-				PreparedStatement statement10 = con.prepareStatement("SELECT " + L2DatabaseFactory.getInstance().safetyString(new String[] {"npc_id", "primary_attack","skill_chance","can_move","soulshot","spiritshot","sschance","spschance","minrangeskill","minrangechance","maxrangeskill","maxrangechance","ischaos","clan","clan_range","enemyClan","enemyRange","ai_type","dodge"}) + " FROM npcaidata ORDER BY npc_id");
-				ResultSet NpcAIDataTable = statement10.executeQuery();
+				statement = con.prepareStatement("SELECT " + L2DatabaseFactory.getInstance().safetyString(new String[] {"npc_id", "primary_attack","skill_chance","can_move","soulshot","spiritshot","sschance","spschance","minrangeskill","minrangechance","maxrangeskill","maxrangechance","ischaos","clan","clan_range","enemyClan","enemyRange","ai_type","dodge"}) + " FROM npcaidata ORDER BY npc_id");
+				ResultSet NpcAIDataTable = statement.executeQuery();
 				L2NpcAIData npcAIDat = null;
 				L2NpcTemplate npcDat = null;
 				int cont=0;
@@ -407,7 +406,7 @@ public class NpcTable
 				}
 				
 				NpcAIDataTable.close();
-				statement10.close();
+				statement.close();
 				_log.info("NPC AI Data Table: Loaded " + cont + " AI Data.");
 			}
 			catch (Exception e)
@@ -419,7 +418,7 @@ public class NpcTable
 			{
 				try
 				{
-					PreparedStatement statement = con.prepareStatement("SELECT " + L2DatabaseFactory.getInstance().safetyString(new String[] { "npc_id", "primary_attack", "skill_chance", "can_move", "soulshot", "spiritshot", "sschance", "spschance", "minrangeskill", "minrangechance", "maxrangeskill", "maxrangechance", "ischaos", "clan", "clan_range", "enemyClan", "enemyRange", "ai_type", "dodge" }) + " FROM custom_npcaidata ORDER BY npc_id");
+					statement = con.prepareStatement("SELECT " + L2DatabaseFactory.getInstance().safetyString(new String[] { "npc_id", "primary_attack", "skill_chance", "can_move", "soulshot", "spiritshot", "sschance", "spschance", "minrangeskill", "minrangechance", "maxrangeskill", "maxrangechance", "ischaos", "clan", "clan_range", "enemyClan", "enemyRange", "ai_type", "dodge" }) + " FROM custom_npcaidata ORDER BY npc_id");
 					ResultSet NpcAIDataTable = statement.executeQuery();
 					L2NpcAIData npcAIDat = null;
 					L2NpcTemplate npcDat = null;
@@ -474,8 +473,8 @@ public class NpcTable
 			
 			try
 			{
-				PreparedStatement statement10 = con.prepareStatement("SELECT " + L2DatabaseFactory.getInstance().safetyString(new String[] {"npc_id", "elemAtkType","elemAtkValue","fireDefValue","waterDefValue","earthDefValue","windDefValue","holyDefValue","darkDefValue"}) + " FROM npc_elementals ORDER BY npc_id");
-				ResultSet NpcElementals = statement10.executeQuery();
+				statement = con.prepareStatement("SELECT " + L2DatabaseFactory.getInstance().safetyString(new String[] {"npc_id", "elemAtkType","elemAtkValue","fireDefValue","waterDefValue","earthDefValue","windDefValue","holyDefValue","darkDefValue"}) + " FROM npc_elementals ORDER BY npc_id");
+				ResultSet NpcElementals = statement.executeQuery();
 				L2NpcTemplate npcDat = null;
 				int cont=0;
 				while (NpcElementals.next())
@@ -520,7 +519,7 @@ public class NpcTable
 					cont++;
 				}
 				NpcElementals.close();
-				statement10.close();
+				statement.close();
 				_log.info("NPC Elementals Data Table: Loaded " + cont + " elementals Data.");
 			}
 			catch (Exception e)
@@ -532,8 +531,8 @@ public class NpcTable
 			{
 				try
 				{
-					PreparedStatement statement10 = con.prepareStatement("SELECT " + L2DatabaseFactory.getInstance().safetyString(new String[] {"npc_id", "elemAtkType","elemAtkValue","fireDefValue","waterDefValue","earthDefValue","windDefValue","holyDefValue","darkDefValue"}) + " FROM custom_npc_elementals ORDER BY npc_id");
-					ResultSet NpcElementals = statement10.executeQuery();
+					statement = con.prepareStatement("SELECT " + L2DatabaseFactory.getInstance().safetyString(new String[] {"npc_id", "elemAtkType","elemAtkValue","fireDefValue","waterDefValue","earthDefValue","windDefValue","holyDefValue","darkDefValue"}) + " FROM custom_npc_elementals ORDER BY npc_id");
+					ResultSet NpcElementals = statement.executeQuery();
 					L2NpcTemplate npcDat = null;
 					int cont=0;
 					while (NpcElementals.next())
@@ -578,7 +577,7 @@ public class NpcTable
 						cont++;
 					}
 					NpcElementals.close();
-					statement10.close();
+					statement.close();
 					_log.info("NPC Elementals Data Table: Loaded " + cont + " custom elementals Data.");
 				}
 				catch (Exception e)
@@ -587,6 +586,10 @@ public class NpcTable
 				}
 			}
 		}
+		catch (Exception e)
+		{
+			_log.log(Level.SEVERE, "NPCTable: Failed loading database connection: " + e.getMessage(), e);
+		}
 		finally
 		{
 			L2DatabaseFactory.close(con);
@@ -765,41 +768,41 @@ public class NpcTable
 	
 	public void saveNpc(StatsSet npc)
 	{
-		Connection con = null;
-		try
+		Map<String, Object> set = npc.getSet();
+		
+		int length = 0;
+		
+		for (Object obj : set.keySet())
 		{
-			con = L2DatabaseFactory.getInstance().getConnection();
-			Map<String, Object> set = npc.getSet();
-			
-			int length = 0;
-			
-			for (Object obj : set.keySet())
-			{
-				// 15 is just guessed npc name length
-				length += ((String) obj).length() + 7 + 15;
-			}
-			
-			final StringBuilder sbValues = new StringBuilder(length);
+			// 15 is just guessed npc name length
+			length += ((String) obj).length() + 7 + 15;
+		}
+		
+		final StringBuilder sbValues = new StringBuilder(length);
+		
+		for (Object obj : set.keySet())
+		{
+			final String name = (String) obj;
 			
-			for (Object obj : set.keySet())
+			if (!name.equalsIgnoreCase("npcId"))
 			{
-				final String name = (String) obj;
-				
-				if (!name.equalsIgnoreCase("npcId"))
+				if (sbValues.length() > 0)
 				{
-					if (sbValues.length() > 0)
-					{
-						sbValues.append(", ");
-					}
-					
-					sbValues.append(name);
-					sbValues.append(" = '");
-					sbValues.append(set.get(name));
-					sbValues.append('\'');
+					sbValues.append(", ");
 				}
+				
+				sbValues.append(name);
+				sbValues.append(" = '");
+				sbValues.append(set.get(name));
+				sbValues.append('\'');
 			}
-			
-			
+		}
+		
+		
+		Connection con = null;
+		try
+		{
+			con = L2DatabaseFactory.getInstance().getConnection();
 			int updated = 0;
 			if (Config.CUSTOM_NPC_TABLE)
 			{

+ 3 - 5
L2J_Server_BETA/java/com/l2jserver/gameserver/datatables/SpawnTable.java

@@ -67,8 +67,7 @@ public class SpawnTable
 		try
 		{
 			con = L2DatabaseFactory.getInstance().getConnection();
-			PreparedStatement statement;
-			statement = con.prepareStatement("SELECT count, npc_templateid, locx, locy, locz, heading, respawn_delay, loc_id, periodOfDay FROM spawnlist");
+			PreparedStatement statement = con.prepareStatement("SELECT count, npc_templateid, locx, locy, locz, heading, respawn_delay, loc_id, periodOfDay FROM spawnlist");
 			ResultSet rset = statement.executeQuery();
 			
 			L2Spawn spawnDat;
@@ -146,8 +145,7 @@ public class SpawnTable
 			try
 			{
 				con = L2DatabaseFactory.getInstance().getConnection();
-				PreparedStatement statement;
-				statement = con.prepareStatement("SELECT count, npc_templateid, locx, locy, locz, heading, respawn_delay, loc_id, periodOfDay FROM custom_spawnlist");
+				PreparedStatement statement = con.prepareStatement("SELECT count, npc_templateid, locx, locy, locz, heading, respawn_delay, loc_id, periodOfDay FROM custom_spawnlist");
 				ResultSet rset = statement.executeQuery();
 				
 				L2Spawn spawnDat;
@@ -233,13 +231,13 @@ public class SpawnTable
 		
 		if (storeInDb)
 		{
-			Connection con = null;
 			String spawnTable;
 			if (spawn.isCustom() && Config.CUSTOM_SPAWNLIST_TABLE)
 				spawnTable = "custom_spawnlist";
 			else
 				spawnTable = "spawnlist";
 			
+			Connection con = null;
 			try
 			{
 				con = L2DatabaseFactory.getInstance().getConnection();

+ 5 - 6
L2J_Server_BETA/java/com/l2jserver/gameserver/instancemanager/AuctionManager.java

@@ -102,13 +102,12 @@ public class AuctionManager
 		Connection con = null;
 		try
 		{
-			PreparedStatement statement;
-			ResultSet rs;
 			con = L2DatabaseFactory.getInstance().getConnection();
-			statement = con.prepareStatement("SELECT id FROM auction ORDER BY id");
-			rs = statement.executeQuery();
+			PreparedStatement statement = con.prepareStatement("SELECT id FROM auction ORDER BY id");
+			ResultSet rs = statement.executeQuery();
 			while (rs.next())
 				_auctions.add(new Auction(rs.getInt("id")));
+			rs.close();
 			statement.close();
 			_log.info("Loaded: " + getAuctions().size() + " auction(s)");
 		}
@@ -116,7 +115,6 @@ public class AuctionManager
 		{
 			_log.log(Level.WARNING, "Exception: AuctionManager.load(): " + e.getMessage(), e);
 		}
-		
 		finally
 		{
 			L2DatabaseFactory.close(con);
@@ -151,7 +149,6 @@ public class AuctionManager
 	/** Init Clan NPC aution */
 	public void initNPC(int id)
 	{
-		Connection con = null;
 		int i;
 		for (i = 0; i < ItemInitDataId.length; i++)
 		{
@@ -163,6 +160,8 @@ public class AuctionManager
 			_log.warning("Clan Hall auction not found for Id :" + id);
 			return;
 		}
+		
+		Connection con = null;
 		try
 		{
 			con = L2DatabaseFactory.getInstance().getConnection();

+ 3 - 5
L2J_Server_BETA/java/com/l2jserver/gameserver/instancemanager/CastleManager.java

@@ -267,18 +267,16 @@ public class CastleManager implements InstanceListManager
 		Connection con = null;
 		try
 		{
-			PreparedStatement statement;
-			ResultSet rs;
 			con = L2DatabaseFactory.getInstance().getConnection();
 			
-			statement = con.prepareStatement("SELECT id FROM castle ORDER BY id");
-			rs = statement.executeQuery();
+			PreparedStatement statement = con.prepareStatement("SELECT id FROM castle ORDER BY id");
+			ResultSet rs = statement.executeQuery();
 			
 			while (rs.next())
 			{
 				getCastles().add(new Castle(rs.getInt("id")));
 			}
-			
+			rs.close();
 			statement.close();
 			
 			_log.info("Loaded: " + getCastles().size() + " castles");

+ 1 - 2
L2J_Server_BETA/java/com/l2jserver/gameserver/instancemanager/CastleManorManager.java

@@ -206,7 +206,6 @@ public class CastleManorManager
 	private void load()
 	{
 		Connection con = null;
-		ResultSet rs;
 		try
 		{
 			// Get Connection
@@ -222,7 +221,7 @@ public class CastleManorManager
 				
 				// restore seed production info
 				statementProduction.setInt(1, castle.getCastleId());
-				rs = statementProduction.executeQuery();
+				ResultSet rs = statementProduction.executeQuery();
 				statementProduction.clearParameters();
 				while (rs.next())
 				{

+ 3 - 4
L2J_Server_BETA/java/com/l2jserver/gameserver/instancemanager/ClanHallManager.java

@@ -81,11 +81,9 @@ public class ClanHallManager
 			String Name, Desc, Location;
 			long paidUntil = 0;
 			boolean paid = false;
-			PreparedStatement statement;
-			ResultSet rs;
 			con = L2DatabaseFactory.getInstance().getConnection();
-			statement = con.prepareStatement("SELECT * FROM clanhall ORDER BY id");
-			rs = statement.executeQuery();
+			PreparedStatement statement = con.prepareStatement("SELECT * FROM clanhall ORDER BY id");
+			ResultSet rs = statement.executeQuery();
 			while (rs.next())
 			{
 				id = rs.getInt("id");
@@ -120,6 +118,7 @@ public class ClanHallManager
 					AuctionManager.getInstance().initNPC(id);
 			}
 			
+			rs.close();
 			statement.close();
 			_log.info("Loaded: " + getClanHalls().size() + " clan halls");
 			_log.info("Loaded: " + getFreeClanHalls().size() + " free clan halls");

+ 3 - 5
L2J_Server_BETA/java/com/l2jserver/gameserver/instancemanager/CoupleManager.java

@@ -66,19 +66,17 @@ public class CoupleManager
 		Connection con = null;
 		try
 		{
-			PreparedStatement statement;
-			ResultSet rs;
-			
 			con = L2DatabaseFactory.getInstance().getConnection();
 			
-			statement = con.prepareStatement("Select id from mods_wedding order by id");
-			rs = statement.executeQuery();
+			PreparedStatement statement = con.prepareStatement("Select id from mods_wedding order by id");
+			ResultSet rs = statement.executeQuery();
 			
 			while (rs.next())
 			{
 				getCouples().add(new Couple(rs.getInt("id")));
 			}
 			
+			rs.close();
 			statement.close();
 			
 			_log.info("Loaded: " + getCouples().size() + " couples(s)");

+ 1 - 0
L2J_Server_BETA/java/com/l2jserver/gameserver/instancemanager/CursedWeaponsManager.java

@@ -272,6 +272,7 @@ public class CursedWeaponsManager
 						_log.info("PROBLEM : Player " + playerId + " owns the cursed weapon " + itemId + " but he shouldn't.");
 						
 						// Delete the item
+						statement.close();
 						statement = con.prepareStatement("DELETE FROM items WHERE owner_id=? AND item_id=?");
 						statement.setInt(1, playerId);
 						statement.setInt(2, itemId);

+ 4 - 3
L2J_Server_BETA/java/com/l2jserver/gameserver/instancemanager/DimensionalRiftManager.java

@@ -83,8 +83,8 @@ public class DimensionalRiftManager
 		try
 		{
 			con = L2DatabaseFactory.getInstance().getConnection();
-			PreparedStatement s = con.prepareStatement("SELECT * FROM dimensional_rift");
-			ResultSet rs = s.executeQuery();
+			PreparedStatement statement = con.prepareStatement("SELECT * FROM dimensional_rift");
+			ResultSet rs = statement.executeQuery();
 			
 			while (rs.next())
 			{
@@ -110,7 +110,8 @@ public class DimensionalRiftManager
 				_rooms.get(type).put(room_id, new DimensionalRiftRoom(type, room_id, xMin, xMax, yMin, yMax, z1, z2, xT, yT, zT, isBossRoom));
 			}
 			
-			s.close();
+			rs.close();
+			statement.close();
 		}
 		catch (Exception e)
 		{

+ 3 - 4
L2J_Server_BETA/java/com/l2jserver/gameserver/instancemanager/FortManager.java

@@ -165,18 +165,17 @@ public class FortManager implements InstanceListManager
 		Connection con = null;
 		try
 		{
-			PreparedStatement statement;
-			ResultSet rs;
 			con = L2DatabaseFactory.getInstance().getConnection();
 			
-			statement = con.prepareStatement("SELECT id FROM fort ORDER BY id");
-			rs = statement.executeQuery();
+			PreparedStatement statement = con.prepareStatement("SELECT id FROM fort ORDER BY id");
+			ResultSet rs = statement.executeQuery();
 			
 			while (rs.next())
 			{
 				getForts().add(new Fort(rs.getInt("id")));
 			}
 			
+			rs.close();
 			statement.close();
 			
 			_log.info("Loaded: " + getForts().size() + " fortress");

+ 5 - 6
L2J_Server_BETA/java/com/l2jserver/gameserver/instancemanager/GlobalVariablesManager.java

@@ -43,15 +43,13 @@ public class GlobalVariablesManager
 	private final void loadVars()
 	{
 		Connection con = null;
-		PreparedStatement statement = null;
-		ResultSet rset;
-		String var, value;
 		try
 		{
 			con = L2DatabaseFactory.getInstance().getConnection();
-			statement = con.prepareStatement(LOAD_VAR);
-
-			rset = statement.executeQuery();
+			PreparedStatement statement = con.prepareStatement(LOAD_VAR);
+			ResultSet rset = statement.executeQuery();
+			
+			String var, value;
 			while (rset.next())
 			{
 				var = rset.getString(1);
@@ -59,6 +57,7 @@ public class GlobalVariablesManager
 				
 				_variablesMap.put(var, value);
 			}
+			
 			rset.close();
 			statement.close();
 		}

+ 28 - 29
L2J_Server_BETA/java/com/l2jserver/gameserver/instancemanager/GrandBossManager.java

@@ -337,11 +337,11 @@ public class GrandBossManager
 		{
 			con = L2DatabaseFactory.getInstance().getConnection();
 			
-			PreparedStatement deleteStatement = con.prepareStatement(DELETE_GRAND_BOSS_LIST);
-			deleteStatement.executeUpdate();
-			deleteStatement.close();
+			PreparedStatement statement = con.prepareStatement(DELETE_GRAND_BOSS_LIST);
+			statement.executeUpdate();
+			statement.close();
 			
-			PreparedStatement insertStatement = con.prepareStatement(INSERT_GRAND_BOSS_LIST);
+			statement = con.prepareStatement(INSERT_GRAND_BOSS_LIST);
 			for (L2BossZone zone : _zones)
 			{
 				if (zone == null)
@@ -352,34 +352,34 @@ public class GrandBossManager
 					continue;
 				for (Integer player : list)
 				{
-					insertStatement.setInt(1, player);
-					insertStatement.setInt(2, id);
-					insertStatement.executeUpdate();
-					insertStatement.clearParameters();
+					statement.setInt(1, player);
+					statement.setInt(2, id);
+					statement.executeUpdate();
+					statement.clearParameters();
 				}
 			}
-			insertStatement.close();
+			statement.close();
 			
-			PreparedStatement updateStatement1 = con.prepareStatement(UPDATE_GRAND_BOSS_DATA2);
-			PreparedStatement updateStatement2 = con.prepareStatement(UPDATE_GRAND_BOSS_DATA);
 			for (Integer bossId : _storedInfo.keys())
 			{
 				L2GrandBossInstance boss = _bosses.get(bossId);
 				StatsSet info = _storedInfo.get(bossId);
 				if (boss == null || info == null)
 				{
-					updateStatement1.setInt(1, _bossStatus.get(bossId));
-					updateStatement1.setInt(2, bossId);
-					updateStatement1.executeUpdate();
-					updateStatement1.clearParameters();
+					statement = con.prepareStatement(UPDATE_GRAND_BOSS_DATA2);
+					statement.setInt(1, _bossStatus.get(bossId));
+					statement.setInt(2, bossId);
+					statement.executeUpdate();
+					statement.clearParameters();
 				}
 				else
 				{
-					updateStatement2.setInt(1, boss.getX());
-					updateStatement2.setInt(2, boss.getY());
-					updateStatement2.setInt(3, boss.getZ());
-					updateStatement2.setInt(4, boss.getHeading());
-					updateStatement2.setLong(5, info.getLong("respawn_time"));
+					statement = con.prepareStatement(UPDATE_GRAND_BOSS_DATA);
+					statement.setInt(1, boss.getX());
+					statement.setInt(2, boss.getY());
+					statement.setInt(3, boss.getZ());
+					statement.setInt(4, boss.getHeading());
+					statement.setLong(5, info.getLong("respawn_time"));
 					double hp = boss.getCurrentHp();
 					double mp = boss.getCurrentMp();
 					if (boss.isDead())
@@ -387,16 +387,15 @@ public class GrandBossManager
 						hp = boss.getMaxHp();
 						mp = boss.getMaxMp();
 					}
-					updateStatement2.setDouble(6, hp);
-					updateStatement2.setDouble(7, mp);
-					updateStatement2.setInt(8, _bossStatus.get(bossId));
-					updateStatement2.setInt(9, bossId);
-					updateStatement2.executeUpdate();
-					updateStatement2.clearParameters();
+					statement.setDouble(6, hp);
+					statement.setDouble(7, mp);
+					statement.setInt(8, _bossStatus.get(bossId));
+					statement.setInt(9, bossId);
+					statement.executeUpdate();
+					statement.clearParameters();
 				}
 			}
-			updateStatement1.close();
-			updateStatement2.close();
+			statement.close();
 		}
 		catch (SQLException e)
 		{
@@ -411,10 +410,10 @@ public class GrandBossManager
 	private void updateDb(int bossId, boolean statusOnly)
 	{
 		Connection con = null;
-		PreparedStatement statement = null;
 		try
 		{
 			con = L2DatabaseFactory.getInstance().getConnection();
+			PreparedStatement statement = null;
 			L2GrandBossInstance boss = _bosses.get(bossId);
 			StatsSet info = _storedInfo.get(bossId);
 			

+ 18 - 8
L2J_Server_BETA/java/com/l2jserver/gameserver/instancemanager/InstanceManager.java

@@ -80,8 +80,7 @@ public class InstanceManager
 		try
 		{
 			con = L2DatabaseFactory.getInstance().getConnection();
-			PreparedStatement statement = null;
-			statement = con.prepareStatement(ADD_INSTANCE_TIME);
+			PreparedStatement statement = con.prepareStatement(ADD_INSTANCE_TIME);
 			statement.setInt(1, playerObjId);
 			statement.setInt(2, id);
 			statement.setLong(3, time);
@@ -90,8 +89,14 @@ public class InstanceManager
 			statement.close();
 			_playerInstanceTimes.get(playerObjId).put(id, time);
 		}
-		catch (Exception e) { _log.log(Level.WARNING, "Could not insert character instance time data: "+ e.getMessage(), e); }
-		finally { L2DatabaseFactory.close(con); }
+		catch (Exception e)
+		{
+			_log.log(Level.WARNING, "Could not insert character instance time data: "+ e.getMessage(), e); 
+		}
+		finally
+		{
+			L2DatabaseFactory.close(con);
+		}
 	}
 	
 	public void deleteInstanceTime(int playerObjId, int id)
@@ -100,16 +105,21 @@ public class InstanceManager
 		try
 		{
 			con = L2DatabaseFactory.getInstance().getConnection();
-			PreparedStatement statement = null;
-			statement = con.prepareStatement(DELETE_INSTANCE_TIME);
+			PreparedStatement statement = con.prepareStatement(DELETE_INSTANCE_TIME);
 			statement.setInt(1, playerObjId);
 			statement.setInt(2, id);
 			statement.execute();
 			statement.close();
 			_playerInstanceTimes.get(playerObjId).remove(id);
 		}
-		catch (Exception e) { _log.log(Level.WARNING, "Could not delete character instance time data: "+ e.getMessage(), e); }
-		finally { L2DatabaseFactory.close(con); }
+		catch (Exception e)
+		{
+			_log.log(Level.WARNING, "Could not delete character instance time data: "+ e.getMessage(), e);
+		}
+		finally
+		{
+			L2DatabaseFactory.close(con);
+		}
 	}
 	
 	public void restoreInstanceTimes(int playerObjId)

+ 4 - 0
L2J_Server_BETA/java/com/l2jserver/gameserver/instancemanager/ItemAuctionManager.java

@@ -67,8 +67,12 @@ public final class ItemAuctionManager
 			con = L2DatabaseFactory.getInstance().getConnection();
 			PreparedStatement statement = con.prepareStatement("SELECT auctionId FROM item_auction ORDER BY auctionId DESC LIMIT 0, 1");
 			ResultSet rset = statement.executeQuery();
+			
 			if (rset.next())
 				_auctionIds.set(rset.getInt(1) + 1);
+			
+			rset.close();
+			statement.close();
 		}
 		catch (final SQLException e)
 		{

+ 24 - 34
L2J_Server_BETA/java/com/l2jserver/gameserver/instancemanager/ItemsOnGroundManager.java

@@ -18,7 +18,6 @@ import java.sql.Connection;
 import java.sql.PreparedStatement;
 import java.sql.ResultSet;
 import java.sql.SQLException;
-import java.sql.Statement;
 import java.util.List;
 import java.util.logging.Level;
 import java.util.logging.Logger;
@@ -104,23 +103,23 @@ public class ItemsOnGroundManager
 		try
 		{
 			con = L2DatabaseFactory.getInstance().getConnection();
-			Statement s = con.createStatement();
-			ResultSet result;
+			PreparedStatement statement = con.prepareStatement("SELECT object_id,item_id,count,enchant_level,x,y,z,drop_time,equipable FROM itemsonground");
+			ResultSet rset;
 			int count = 0;
-			result = s.executeQuery("select object_id,item_id,count,enchant_level,x,y,z,drop_time,equipable from itemsonground");
-			while (result.next())
+			rset = statement.executeQuery();
+			while (rset.next())
 			{
-				item = new L2ItemInstance(result.getInt(1), result.getInt(2));
+				item = new L2ItemInstance(rset.getInt(1), rset.getInt(2));
 				L2World.getInstance().storeObject(item);
-				if (item.isStackable() && result.getInt(3) > 1) //this check and..
-					item.setCount(result.getInt(3));
-				if (result.getInt(4) > 0) // this, are really necessary?
-					item.setEnchantLevel(result.getInt(4));
-				item.getPosition().setWorldPosition(result.getInt(5), result.getInt(6), result.getInt(7));
+				if (item.isStackable() && rset.getInt(3) > 1) //this check and..
+					item.setCount(rset.getInt(3));
+				if (rset.getInt(4) > 0) // this, are really necessary?
+					item.setEnchantLevel(rset.getInt(4));
+				item.getPosition().setWorldPosition(rset.getInt(5), rset.getInt(6), rset.getInt(7));
 				item.getPosition().setWorldRegion(L2World.getInstance().getRegion(item.getPosition().getWorldPosition()));
 				item.getPosition().getWorldRegion().addVisibleObject(item);
-				item.setDropTime(result.getLong(8));
-				item.setProtected(result.getLong(8) == -1);
+				item.setDropTime(rset.getLong(8));
+				item.setProtected(rset.getLong(8) == -1);
 				item.setIsVisible(true);
 				L2World.getInstance().addVisibleObject(item, item.getPosition().getWorldRegion());
 				_items.add(item);
@@ -128,7 +127,7 @@ public class ItemsOnGroundManager
 				// add to ItemsAutoDestroy only items not protected
 				if (!Config.LIST_PROTECTED_ITEMS.contains(item.getItemId()))
 				{
-					if (result.getLong(8) > -1)
+					if (rset.getLong(8) > -1)
 					{
 						if ((Config.AUTODESTROY_ITEM_AFTER > 0 && item.getItemType() != L2EtcItemType.HERB)
 								|| (Config.HERB_AUTO_DESTROY_TIME > 0 && item.getItemType() == L2EtcItemType.HERB))
@@ -136,8 +135,8 @@ public class ItemsOnGroundManager
 					}
 				}
 			}
-			result.close();
-			s.close();
+			rset.close();
+			statement.close();
 			if (count > 0)
 				_log.info("ItemsOnGroundManager: restored " + count + " items.");
 			else
@@ -182,13 +181,13 @@ public class ItemsOnGroundManager
 	
 	public void emptyTable()
 	{
-		Connection conn = null;
+		Connection con = null;
 		try
 		{
-			conn = L2DatabaseFactory.getInstance().getConnection();
-			PreparedStatement del = conn.prepareStatement("delete from itemsonground");
-			del.execute();
-			del.close();
+			con = L2DatabaseFactory.getInstance().getConnection();
+			PreparedStatement statement = con.prepareStatement("DELETE FROM itemsonground");
+			statement.execute();
+			statement.close();
 		}
 		catch (Exception e1)
 		{
@@ -196,7 +195,7 @@ public class ItemsOnGroundManager
 		}
 		finally
 		{
-			L2DatabaseFactory.close(conn);
+			L2DatabaseFactory.close(con);
 		}
 	}
 	
@@ -218,12 +217,10 @@ public class ItemsOnGroundManager
 			}
 			
 			Connection con = null;
-			PreparedStatement statement = null;
-			
 			try
 			{
 				con = L2DatabaseFactory.getInstance().getConnection();
-				statement = con.prepareStatement("INSERT INTO itemsonground(object_id,item_id,count,enchant_level,x,y,z,drop_time,equipable) VALUES(?,?,?,?,?,?,?,?,?)");
+				PreparedStatement statement = con.prepareStatement("INSERT INTO itemsonground(object_id,item_id,count,enchant_level,x,y,z,drop_time,equipable) VALUES(?,?,?,?,?,?,?,?,?)");
 				
 				for (L2ItemInstance item : _items)
 				{
@@ -242,15 +239,8 @@ public class ItemsOnGroundManager
 						statement.setInt(5, item.getX());
 						statement.setInt(6, item.getY());
 						statement.setInt(7, item.getZ());
-						
-						if (item.isProtected())
-							statement.setLong(8, -1); //item will be protected
-						else
-							statement.setLong(8, item.getDropTime()); //item will be added to ItemsAutoDestroy
-						if (item.isEquipable())
-							statement.setLong(9, 1); //set equip-able
-						else
-							statement.setLong(9, 0);
+						statement.setLong(8, (item.isProtected() ? -1 : item.getDropTime())); //item is protected or AutoDestroyed
+						statement.setLong(9, (item.isEquipable() ? 1 : 0)); //set equip-able
 						statement.execute();
 						statement.clearParameters();
 					}

+ 8 - 10
L2J_Server_BETA/java/com/l2jserver/gameserver/instancemanager/MailManager.java

@@ -57,18 +57,16 @@ public class MailManager
 	
 	private void load()
 	{
-		int readed = 0;
+		int count = 0;
 		Connection con = null;
-		PreparedStatement stmt1 = null;
-		PreparedStatement stmt2 = null;
 		try
 		{
 			con = L2DatabaseFactory.getInstance().getConnection();
 			
-			stmt1 = con.prepareStatement("SELECT * FROM messages ORDER BY expiration");
-			stmt2 = con.prepareStatement("SELECT * FROM attachments WHERE messageId = ?");
+			PreparedStatement statement = con.prepareStatement("SELECT * FROM messages ORDER BY expiration");
+			// stmt2 = con.prepareStatement("SELECT * FROM attachments WHERE messageId = ?");
 			
-			ResultSet rset1 = stmt1.executeQuery();
+			ResultSet rset1 = statement.executeQuery();
 			while (rset1.next())
 			{
 				
@@ -77,7 +75,7 @@ public class MailManager
 				int msgId = msg.getId();
 				_messages.put(msgId, msg);
 				
-				readed++;
+				count++;
 				
 				long expiration = msg.getExpiration();
 				
@@ -86,8 +84,8 @@ public class MailManager
 				else
 					ThreadPoolManager.getInstance().scheduleGeneral(new MessageDeletionTask(msgId), expiration - System.currentTimeMillis());
 			}
-			stmt1.close();
-			stmt2.close();
+			rset1.close();
+			statement.close();
 		}
 		catch (SQLException e)
 		{
@@ -97,7 +95,7 @@ public class MailManager
 		{
 			L2DatabaseFactory.close(con);
 		}
-		_log.info("Mail Manager: Successfully loaded " + readed + " messages.");
+		_log.info("Mail Manager: Successfully loaded " + count + " messages.");
 	}
 	
 	public final Message getMessage(int msgId)

+ 3 - 5
L2J_Server_BETA/java/com/l2jserver/gameserver/instancemanager/MercTicketManager.java

@@ -150,12 +150,9 @@ public class MercTicketManager
 		// load merc tickets into the world
 		try
 		{
-			PreparedStatement statement;
-			ResultSet rs;
-			
 			con = L2DatabaseFactory.getInstance().getConnection();
-			statement = con.prepareStatement("SELECT * FROM castle_siege_guards Where isHired = 1");
-			rs = statement.executeQuery();
+			PreparedStatement statement = con.prepareStatement("SELECT * FROM castle_siege_guards Where isHired = 1");
+			ResultSet rs = statement.executeQuery();
 			
 			int npcId;
 			int itemId;
@@ -201,6 +198,7 @@ public class MercTicketManager
 						break;
 					}
 			}
+			rs.close();
 			statement.close();
 			
 			_log.info("Loaded: " + getDroppedTickets().size() + " Mercenary Tickets");

+ 4 - 11
L2J_Server_BETA/java/com/l2jserver/gameserver/instancemanager/RaidBossSpawnManager.java

@@ -75,13 +75,11 @@ public class RaidBossSpawnManager
 		_spawns = new FastMap<Integer, L2Spawn>();
 		
 		Connection con = null;
-		PreparedStatement statement = null;
-		
 		try
 		{
 			con = L2DatabaseFactory.getInstance().getConnection();
 			
-			statement = con.prepareStatement("SELECT * FROM raidboss_spawnlist ORDER BY boss_id");
+			PreparedStatement statement = con.prepareStatement("SELECT * FROM raidboss_spawnlist ORDER BY boss_id");
 			ResultSet rset = statement.executeQuery();
 			
 			L2Spawn spawnDat;
@@ -267,12 +265,10 @@ public class RaidBossSpawnManager
 		if (storeInDb)
 		{
 			Connection con = null;
-			PreparedStatement statement = null;
-			
 			try
 			{
 				con = L2DatabaseFactory.getInstance().getConnection();
-				statement = con.prepareStatement("INSERT INTO raidboss_spawnlist (boss_id,amount,loc_x,loc_y,loc_z,heading,respawn_time,currentHp,currentMp) VALUES(?,?,?,?,?,?,?,?,?)");
+				PreparedStatement statement = con.prepareStatement("INSERT INTO raidboss_spawnlist (boss_id,amount,loc_x,loc_y,loc_z,heading,respawn_time,currentHp,currentMp) VALUES(?,?,?,?,?,?,?,?,?)");
 				statement.setInt(1, spawnDat.getNpcid());
 				statement.setInt(2, spawnDat.getAmount());
 				statement.setInt(3, spawnDat.getLocx());
@@ -325,12 +321,10 @@ public class RaidBossSpawnManager
 		if (updateDb)
 		{
 			Connection con = null;
-			PreparedStatement statement = null;
-			
 			try
 			{
 				con = L2DatabaseFactory.getInstance().getConnection();
-				statement = con.prepareStatement("DELETE FROM raidboss_spawnlist WHERE boss_id=?");
+				PreparedStatement statement = con.prepareStatement("DELETE FROM raidboss_spawnlist WHERE boss_id=?");
 				statement.setInt(1, bossId);
 				statement.execute();
 				statement.close();
@@ -350,11 +344,10 @@ public class RaidBossSpawnManager
 	private void updateDb()
 	{
 		Connection con = null;
-		PreparedStatement statement = null;
 		try
 		{
 			con = L2DatabaseFactory.getInstance().getConnection();
-			statement = con.prepareStatement("UPDATE raidboss_spawnlist SET respawn_time = ?, currentHP = ?, currentMP = ? WHERE boss_id = ?");
+			PreparedStatement statement = con.prepareStatement("UPDATE raidboss_spawnlist SET respawn_time = ?, currentHP = ?, currentMP = ? WHERE boss_id = ?");
 			
 			for (Integer bossId : _storedInfo.keySet())
 			{

+ 2 - 4
L2J_Server_BETA/java/com/l2jserver/gameserver/instancemanager/SiegeGuardManager.java

@@ -227,6 +227,7 @@ public class SiegeGuardManager
 					_log.warning("Missing npc data in npc table for id: " + rs.getInt("npcId"));
 				}
 			}
+			rs.close();
 			statement.close();
 		}
 		catch (Exception e)
@@ -255,10 +256,7 @@ public class SiegeGuardManager
 			statement.setInt(4, y);
 			statement.setInt(5, z);
 			statement.setInt(6, heading);
-			if (isHire == 1)
-				statement.setInt(7, 0);
-			else
-				statement.setInt(7, 600);
+			statement.setInt(7, (isHire == 1 ? 0 : 600));
 			statement.setInt(8, isHire);
 			statement.execute();
 			statement.close();

+ 2 - 3
L2J_Server_BETA/java/com/l2jserver/gameserver/instancemanager/TerritoryWarManager.java

@@ -657,10 +657,10 @@ public class TerritoryWarManager implements Siegable
 	private void changeRegistration(int castleId, int objId, boolean delete)
 	{
 		Connection con = null;
-		PreparedStatement statement = null;
 		try
 		{
 			con = L2DatabaseFactory.getInstance().getConnection();
+			PreparedStatement statement;
 			if (delete)
 				statement = con.prepareStatement("DELETE FROM territory_registrations WHERE castleId=? and registeredId=?");
 			else
@@ -683,11 +683,10 @@ public class TerritoryWarManager implements Siegable
 	private void updateTerritoryData(Territory ter)
 	{
 		Connection con = null;
-		PreparedStatement statement = null;
 		try
 		{
 			con = L2DatabaseFactory.getInstance().getConnection();
-			statement = con.prepareStatement("UPDATE territories SET ownedWardIds=? WHERE territoryId=?");
+			PreparedStatement statement = con.prepareStatement("UPDATE territories SET ownedWardIds=? WHERE territoryId=?");
 			StringBuilder wardList = new StringBuilder();
 			for (int i : ter.getOwnedWardIds())
 				wardList.append(i + ";");

+ 4 - 9
L2J_Server_BETA/java/com/l2jserver/gameserver/model/AutoChatHandler.java

@@ -65,25 +65,20 @@ public class AutoChatHandler implements SpawnListener
 	{
 		int numLoaded = 0;
 		Connection con = null;
-		PreparedStatement statement = null;
-		PreparedStatement statement2 = null;
-		ResultSet rs = null;
-		ResultSet rs2 = null;
-		
 		try
 		{
 			con = L2DatabaseFactory.getInstance().getConnection();
 			
-			statement = con.prepareStatement("SELECT * FROM auto_chat ORDER BY groupId ASC");
-			rs = statement.executeQuery();
+			PreparedStatement statement = con.prepareStatement("SELECT * FROM auto_chat ORDER BY groupId ASC");
+			ResultSet rs = statement.executeQuery();
 			
-			statement2 = con.prepareStatement("SELECT * FROM auto_chat_text WHERE groupId=?");
+			PreparedStatement statement2 = con.prepareStatement("SELECT * FROM auto_chat_text WHERE groupId=?");
 			while (rs.next())
 			{
 				numLoaded++;
 				
 				statement2.setInt(1, rs.getInt("groupId"));
-				rs2 = statement2.executeQuery();
+				ResultSet rs2 = statement2.executeQuery();
 				statement2.clearParameters();
 				
 				rs2.last();

+ 11 - 7
L2J_Server_BETA/java/com/l2jserver/gameserver/model/actor/L2Character.java

@@ -2291,15 +2291,19 @@ public abstract class L2Character extends L2Object
 			}
 			if(restorefull)
 			{
-				_status.setCurrentCp(getCurrentCp()); //this is not confirmed, so just trigger regeneration
-				_status.setCurrentHp(getMaxHp()); //confirmed
-				_status.setCurrentMp(getMaxMp()); //and also confirmed
+				_status.setCurrentCp(getCurrentCp());	// this is not confirmed, so just trigger regeneration
+				_status.setCurrentHp(getMaxHp());		// confirmed
+				_status.setCurrentMp(getMaxMp());		// and also confirmed
 			}
 			else
-				_status.setCurrentHp(getMaxHp() * Config.RESPAWN_RESTORE_HP);
-			//_status.setCurrentCp(getMaxCp() * Config.RESPAWN_RESTORE_CP);
-			//_Status.setCurrentMp(getMaxMp() * Config.RESPAWN_RESTORE_MP);
-			
+			{
+				if (Config.RESPAWN_RESTORE_CP > 0 && getCurrentCp() < getMaxCp() * Config.RESPAWN_RESTORE_CP)
+					_status.setCurrentCp(getMaxCp() * Config.RESPAWN_RESTORE_CP);
+				if (Config.RESPAWN_RESTORE_HP > 0 && getCurrentHp() < getMaxHp() * Config.RESPAWN_RESTORE_HP)
+					_status.setCurrentHp(getMaxHp() * Config.RESPAWN_RESTORE_HP);
+				if (Config.RESPAWN_RESTORE_MP > 0 && getCurrentMp() < getMaxMp() * Config.RESPAWN_RESTORE_MP)
+					_status.setCurrentMp(getMaxMp() * Config.RESPAWN_RESTORE_MP);
+			}
 			// Start broadcast status
 			broadcastPacket(new Revive(this));
 			if (getWorldRegion() != null)

+ 35 - 41
L2J_Server_BETA/java/com/l2jserver/gameserver/model/actor/instance/L2PcInstance.java

@@ -7367,7 +7367,7 @@ public final class L2PcInstance extends L2Playable
 				// Enforce the correct indexing of _subClasses against their class indexes.
 				player.getSubClasses().put(subClass.getClassIndex(), subClass);
 			}
-			
+			rset.close();
 			statement.close();
 		}
 		catch (Exception e)
@@ -7666,26 +7666,25 @@ public final class L2PcInstance extends L2Playable
 	
 	private void storeCharSub()
 	{
-		Connection con = null;
+		if (getTotalSubClasses() <= 0)
+			return;
 		
+		Connection con = null;
 		try
 		{
 			con = L2DatabaseFactory.getInstance().getConnection();
 			PreparedStatement statement = con.prepareStatement(UPDATE_CHAR_SUBCLASS);
-			
-			if (getTotalSubClasses() > 0)
-			{
-				for (SubClass subClass : getSubClasses().values())
-				{
-					statement.setLong(1, subClass.getExp());
-					statement.setInt(2, subClass.getSp());
-					statement.setInt(3, subClass.getLevel());
-					statement.setInt(4, subClass.getClassId());
-					statement.setInt(5, getObjectId());
-					statement.setInt(6, subClass.getClassIndex());
-					
-					statement.execute();
-				}
+			for (SubClass subClass : getSubClasses().values())
+			{
+				statement.setLong(1, subClass.getExp());
+				statement.setInt(2, subClass.getSp());
+				statement.setInt(3, subClass.getLevel());
+				statement.setInt(4, subClass.getClassId());
+				statement.setInt(5, getObjectId());
+				statement.setInt(6, subClass.getClassIndex());
+				
+				statement.execute();
+				statement.clearParameters();
 			}
 			statement.close();
 		}
@@ -7898,52 +7897,47 @@ public final class L2PcInstance extends L2Playable
 	 * <li> L2PcInstance : Save update in the character_skills table of the database</li><BR><BR>
 	 *
 	 * @param skill The L2Skill to remove from the L2Character
-	 *
 	 * @return The L2Skill removed
-	 *
 	 */
 	@Override
 	public L2Skill removeSkill(L2Skill skill)
 	{
 		// Remove a skill from the L2Character and its Func objects from calculator set of the L2Character
-		L2Skill oldSkill = super.removeSkill(skill);
-		
-		Connection con = null;
-		try
+		final L2Skill oldSkill = super.removeSkill(skill);
+		if (oldSkill != null)
 		{
-			// Remove or update a L2PcInstance skill from the character_skills table of the database
-			con = L2DatabaseFactory.getInstance().getConnection();
-			PreparedStatement statement = con.prepareStatement(DELETE_SKILL_FROM_CHAR);
-			
-			if (oldSkill != null)
+			Connection con = null;
+			try
 			{
+				// Remove or update a L2PcInstance skill from the character_skills table of the database
+				con = L2DatabaseFactory.getInstance().getConnection();
+				PreparedStatement statement = con.prepareStatement(DELETE_SKILL_FROM_CHAR);
+				
 				statement.setInt(1, oldSkill.getId());
 				statement.setInt(2, getObjectId());
 				statement.setInt(3, getClassIndex());
 				statement.execute();
+				statement.close();
+			}
+			catch (Exception e)
+			{
+				_log.log(Level.WARNING, "Error could not delete skill: " + e.getMessage(), e);
+			}
+			finally
+			{
+				L2DatabaseFactory.close(con);
 			}
-			statement.close();
-		}
-		catch (Exception e)
-		{
-			_log.log(Level.WARNING, "Error could not delete skill: " + e.getMessage(), e);
-		}
-		finally
-		{
-			L2DatabaseFactory.close(con);
 		}
 		
-		if (this.transformId() > 0 || this.isCursedWeaponEquipped())
+		if (transformId() > 0 || isCursedWeaponEquipped())
 			return oldSkill;
 		
-		L2ShortCut[] allShortCuts = getAllShortCuts();
-		
+		final L2ShortCut[] allShortCuts = getAllShortCuts();
 		for (L2ShortCut sc : allShortCuts)
 		{
-			if (sc != null && skill != null && sc.getId() == skill.getId() && sc.getType() == L2ShortCut.TYPE_SKILL)
+			if ((sc != null) && (skill != null) && (sc.getId() == skill.getId()) && (sc.getType() == L2ShortCut.TYPE_SKILL))
 				deleteShortCut(sc.getSlot(), sc.getPage());
 		}
-		
 		return oldSkill;
 	}
 	

+ 2 - 1
L2J_Server_BETA/java/com/l2jserver/gameserver/model/entity/Auction.java

@@ -187,6 +187,7 @@ public class Auction
 				_sellerName = rs.getString("sellerName");
 				_startingBid = rs.getLong("startingBid");
 			}
+			rs.close();
 			statement.close();
 			loadBid();
 		}
@@ -229,7 +230,7 @@ public class Auction
 				}
 				_bidders.put(rs.getInt("bidderId"), new Bidder(rs.getString("bidderName"), rs.getString("clan_name"), rs.getLong("maxBid"), rs.getLong("time_bid")));
 			}
-			
+			rs.close();
 			statement.close();
 		}
 		catch (Exception e)

+ 1 - 0
L2J_Server_BETA/java/com/l2jserver/gameserver/model/entity/ClanHall.java

@@ -455,6 +455,7 @@ public class ClanHall
 			{
 				_functions.put(rs.getInt("type"), new ClanHallFunction(rs.getInt("type"), rs.getInt("lvl"), rs.getInt("lease"), 0, rs.getLong("rate"), rs.getLong("endTime"), true));
 			}
+			rs.close();
 			statement.close();
 		}
 		catch (Exception e)

+ 1 - 0
L2J_Server_BETA/java/com/l2jserver/gameserver/model/entity/Couple.java

@@ -73,6 +73,7 @@ public class Couple
 				_weddingDate = Calendar.getInstance();
 				_weddingDate.setTimeInMillis(rs.getLong("weddingDate"));
 			}
+			rs.close();
 			statement.close();
 		}
 		catch (Exception e)

+ 1 - 0
L2J_Server_BETA/java/com/l2jserver/gameserver/model/entity/Fort.java

@@ -688,6 +688,7 @@ public class Fort
 			{
 				_function.put(rs.getInt("type"), new FortFunction(rs.getInt("type"), rs.getInt("lvl"), rs.getInt("lease"), 0, rs.getLong("rate"), rs.getLong("endTime"), true));
 			}
+			rs.close();
 			statement.close();
 		}
 		catch (Exception e)

+ 24 - 40
L2J_Server_BETA/java/com/l2jserver/gameserver/model/entity/Hero.java

@@ -116,20 +116,13 @@ public class Hero
 		_heroMessage = new FastMap<Integer, String>();
 		
 		Connection con = null;
-		Connection con2 = null;
-		
-		PreparedStatement statement;
-		PreparedStatement statement2;
-		
-		ResultSet rset;
-		ResultSet rset2;
-		
 		try
 		{
 			con = L2DatabaseFactory.getInstance().getConnection();
-			con2 = L2DatabaseFactory.getInstance().getConnection();
-			statement = con.prepareStatement(GET_HEROES);
-			rset = statement.executeQuery();
+			PreparedStatement statement = con.prepareStatement(GET_HEROES);
+			ResultSet rset = statement.executeQuery();
+			PreparedStatement statement2 = con.prepareStatement(GET_CLAN_ALLY);
+			ResultSet rset2 = null;
 			
 			while (rset.next())
 			{
@@ -144,7 +137,6 @@ public class Hero
 				loadDiary(charId);
 				loadMessage(charId);
 				
-				statement2 = con2.prepareStatement(GET_CLAN_ALLY);
 				statement2.setInt(1, charId);
 				rset2 = statement2.executeQuery();
 				
@@ -177,7 +169,7 @@ public class Hero
 				}
 				
 				rset2.close();
-				statement2.close();
+				statement2.clearParameters();
 				
 				_heroes.put(charId, hero);
 			}
@@ -197,7 +189,6 @@ public class Hero
 				hero.set(COUNT, rset.getInt(COUNT));
 				hero.set(PLAYED, rset.getInt(PLAYED));
 				
-				statement2 = con2.prepareStatement(GET_CLAN_ALLY);
 				statement2.setInt(1, charId);
 				rset2 = statement2.executeQuery();
 				
@@ -230,11 +221,12 @@ public class Hero
 				}
 				
 				rset2.close();
-				statement2.close();
+				statement2.clearParameters();
 				
 				_completeHeroes.put(charId, hero);
 			}
 			
+			statement2.close();
 			rset.close();
 			statement.close();
 		}
@@ -249,7 +241,6 @@ public class Hero
 		finally
 		{
 			L2DatabaseFactory.close(con);
-			L2DatabaseFactory.close(con2);
 		}
 		
 		_log.info("Hero System: Loaded " + _heroes.size() + " Heroes.");
@@ -302,14 +293,12 @@ public class Hero
 		
 		int diaryentries = 0;
 		Connection con = null;
-		PreparedStatement statement;
-		ResultSet rset;
 		try
 		{
 			con = L2DatabaseFactory.getInstance().getConnection();
-			statement = con.prepareStatement("SELECT * FROM  heroes_diary WHERE charId=? ORDER BY time ASC");
+			PreparedStatement statement = con.prepareStatement("SELECT * FROM  heroes_diary WHERE charId=? ORDER BY time ASC");
 			statement.setInt(1, charId);
-			rset = statement.executeQuery();
+			ResultSet rset = statement.executeQuery();
 			
 			while (rset.next())
 			{
@@ -383,16 +372,14 @@ public class Hero
 		int _draws = 0;
 		
 		Connection con = null;
-		PreparedStatement statement;
-		ResultSet rset;
 		try
 		{
 			con = L2DatabaseFactory.getInstance().getConnection();
-			statement = con.prepareStatement("SELECT * FROM olympiad_fights WHERE (charOneId=? OR charTwoId=?) AND start<? ORDER BY start ASC");
+			PreparedStatement statement = con.prepareStatement("SELECT * FROM olympiad_fights WHERE (charOneId=? OR charTwoId=?) AND start<? ORDER BY start ASC");
 			statement.setInt(1, charId);
 			statement.setInt(2, charId);
 			statement.setLong(3, from);
-			rset = statement.executeQuery();
+			ResultSet rset = statement.executeQuery();
 			
 			while (rset.next())
 			{
@@ -835,7 +822,6 @@ public class Hero
 				_heroMessage.put(charId, "");
 				
 				Connection con = null;
-				
 				try
 				{
 					con = L2DatabaseFactory.getInstance().getConnection();
@@ -883,16 +869,15 @@ public class Hero
 		try
 		{
 			con = L2DatabaseFactory.getInstance().getConnection();
+			PreparedStatement statement;
 			if (setDefault)
 			{
-				PreparedStatement statement = con.prepareStatement(UPDATE_ALL);
+				statement = con.prepareStatement(UPDATE_ALL);
 				statement.execute();
 				statement.close();
 			}
 			else
 			{
-				PreparedStatement statement;
-				
 				for (Integer heroId : _heroes.keySet())
 				{
 					StatsSet hero = _heroes.get(heroId);
@@ -905,16 +890,16 @@ public class Hero
 						statement.setInt(3, hero.getInteger(COUNT));
 						statement.setInt(4, hero.getInteger(PLAYED));
 						statement.execute();
+						statement.close();
 						
-						Connection con2 = L2DatabaseFactory.getInstance().getConnection();
-						PreparedStatement statement2 = con2.prepareStatement(GET_CLAN_ALLY);
-						statement2.setInt(1, heroId);
-						ResultSet rset2 = statement2.executeQuery();
+						statement = con.prepareStatement(GET_CLAN_ALLY);
+						statement.setInt(1, heroId);
+						ResultSet rset = statement.executeQuery();
 						
-						if (rset2.next())
+						if (rset.next())
 						{
-							int clanId = rset2.getInt("clanid");
-							int allyId = rset2.getInt("allyId");
+							int clanId = rset.getInt("clanid");
+							int allyId = rset.getInt("allyId");
 							
 							String clanName = "";
 							String allyName = "";
@@ -939,9 +924,8 @@ public class Hero
 							hero.set(ALLY_NAME, allyName);
 						}
 						
-						rset2.close();
-						statement2.close();
-						con2.close();
+						rset.close();
+						statement.close();
 						
 						_heroes.remove(heroId);
 						_heroes.put(heroId, hero);
@@ -955,9 +939,8 @@ public class Hero
 						statement.setInt(2, hero.getInteger(PLAYED));
 						statement.setInt(3, heroId);
 						statement.execute();
+						statement.close();
 					}
-					
-					statement.close();
 				}
 			}
 		}
@@ -1075,6 +1058,7 @@ public class Hero
 	{
 		if (_heroMessage.get(charId) == null)
 			return;
+		
 		Connection con = null;
 		try
 		{

+ 1 - 2
L2J_Server_BETA/java/com/l2jserver/gameserver/model/quest/Quest.java

@@ -867,12 +867,11 @@ public class Quest extends ManagedScript
 		{
 			// Get list of quests owned by the player from database
 			con = L2DatabaseFactory.getInstance().getConnection();
-			PreparedStatement statement;
 			
 			PreparedStatement invalidQuestData = con.prepareStatement("DELETE FROM character_quests WHERE charId=? and name=?");
 			PreparedStatement invalidQuestDataVar = con.prepareStatement("delete FROM character_quests WHERE charId=? and name=? and var=?");
 			
-			statement = con.prepareStatement("SELECT name,value FROM character_quests WHERE charId=? AND var=?");
+			PreparedStatement statement = con.prepareStatement("SELECT name,value FROM character_quests WHERE charId=? AND var=?");
 			statement.setInt(1, player.getObjectId());
 			statement.setString(2, "<state>");
 			ResultSet rs = statement.executeQuery();

+ 250 - 230
L2J_Server_BETA/java/com/l2jserver/status/GameStatusThread.java

@@ -87,46 +87,53 @@ import com.l2jserver.gameserver.network.serverpackets.UserInfo;
 import com.l2jserver.gameserver.taskmanager.DecayTaskManager;
 import com.l2jserver.gameserver.util.GMAudit;
 
-
 public class GameStatusThread extends Thread
 {
 	//private static final Logger _log = Logger.getLogger(AdminTeleport.class.getName());
 	
-	private Socket                  _cSocket;
+	private Socket _cSocket;
 	
-	private PrintWriter             _print;
-	private BufferedReader          _read;
+	private PrintWriter _print;
+	private BufferedReader _read;
 	
-	private int                     _uptime;
+	private int _uptime;
 	
 	private void telnetOutput(int type, String text)
 	{
 		if (Config.DEVELOPER)
 		{
-			if ( type == 1 ) System.out.println("TELNET | "+text);
-			else if ( type == 2 ) System.out.print("TELNET | "+text);
-			else if ( type == 3 ) System.out.print(text);
-			else if ( type == 4 ) System.out.println(text);
-			else System.out.println("TELNET | "+text);
+			if (type == 1)
+				System.out.println("TELNET | " + text);
+			else if (type == 2)
+				System.out.print("TELNET | " + text);
+			else if (type == 3)
+				System.out.print(text);
+			else if (type == 4)
+				System.out.println(text);
+			else
+				System.out.println("TELNET | " + text);
 		}
 		else
 		{
 			//only print output if the message is rejected
-			if ( type == 5 ) System.out.println("TELNET | "+text);
+			if (type == 5)
+				System.out.println("TELNET | " + text);
 		}
 	}
 	
-	private boolean isValidIP(Socket client) {
+	private boolean isValidIP(Socket client)
+	{
 		boolean result = false;
 		InetAddress ClientIP = client.getInetAddress();
 		
 		// convert IP to String, and compare with list
 		String clientStringIP = ClientIP.getHostAddress();
 		
-		telnetOutput(1, "Connection from: "+clientStringIP);
+		telnetOutput(1, "Connection from: " + clientStringIP);
 		
 		// read and loop thru list of IPs, compare with newIP
-		if ( Config.DEVELOPER ) telnetOutput(2, "");
+		if (Config.DEVELOPER)
+			telnetOutput(2, "");
 		
 		InputStream telnetIS = null;
 		try
@@ -137,23 +144,28 @@ public class GameStatusThread extends Thread
 			
 			String HostList = telnetSettings.getProperty("ListOfHosts", "127.0.0.1,localhost,::1");
 			
-			if ( Config.DEVELOPER ) telnetOutput(3, "Comparing ip to list...");
+			if (Config.DEVELOPER)
+				telnetOutput(3, "Comparing ip to list...");
 			
 			// compare
 			String ipToCompare = null;
-			for (String ip:HostList.split(","))
+			for (String ip : HostList.split(","))
 			{
-				if ( !result )
+				if (!result)
 				{
 					ipToCompare = InetAddress.getByName(ip).getHostAddress();
-					if ( clientStringIP.equals(ipToCompare) ) result = true;
-					if ( Config.DEVELOPER ) telnetOutput(3, clientStringIP + " = " + ipToCompare + "("+ip+") = " + result);
+					if (clientStringIP.equals(ipToCompare))
+						result = true;
+					if (Config.DEVELOPER)
+						telnetOutput(3, clientStringIP + " = " + ipToCompare + "(" + ip + ") = " + result);
 				}
 			}
 		}
-		catch ( IOException e) {
-			if ( Config.DEVELOPER ) telnetOutput(4, "");
-			telnetOutput(1, "Error: "+e);
+		catch (IOException e)
+		{
+			if (Config.DEVELOPER)
+				telnetOutput(4, "");
+			telnetOutput(1, "Error: " + e);
 		}
 		finally
 		{
@@ -166,7 +178,8 @@ public class GameStatusThread extends Thread
 			}
 		}
 		
-		if ( Config.DEVELOPER ) telnetOutput(4, "Allow IP: "+result);
+		if (Config.DEVELOPER)
+			telnetOutput(4, "Allow IP: " + result);
 		return result;
 	}
 	
@@ -177,22 +190,25 @@ public class GameStatusThread extends Thread
 		_uptime = uptime;
 		
 		_print = new PrintWriter(_cSocket.getOutputStream());
-		_read  = new BufferedReader(new InputStreamReader(_cSocket.getInputStream()));
+		_read = new BufferedReader(new InputStreamReader(_cSocket.getInputStream()));
 		
-		if ( isValidIP(client) ) {
-			telnetOutput(1, client.getInetAddress().getHostAddress()+" accepted.");
+		if (isValidIP(client))
+		{
+			telnetOutput(1, client.getInetAddress().getHostAddress() + " accepted.");
 			_print.println("Welcome To The L2J Telnet Session.");
 			_print.println("Please Insert Your Password!");
 			_print.print("Password: ");
 			_print.flush();
 			String tmpLine = _read.readLine();
-			if ( tmpLine == null )  {
+			if (tmpLine == null)
+			{
 				_print.println("Error.");
 				_print.println("Disconnected...");
 				_print.flush();
 				_cSocket.close();
 			}
-			else {
+			else
+			{
 				if (tmpLine.compareTo(StatusPW) != 0)
 				{
 					_print.println("Incorrect Password!");
@@ -210,8 +226,9 @@ public class GameStatusThread extends Thread
 				}
 			}
 		}
-		else {
-			telnetOutput(5, "Connection attempt from "+ client.getInetAddress().getHostAddress() +" rejected.");
+		else
+		{
+			telnetOutput(5, "Connection attempt from " + client.getInetAddress().getHostAddress() + " rejected.");
 			_cSocket.close();
 		}
 	}
@@ -225,12 +242,13 @@ public class GameStatusThread extends Thread
 			while (_usrCommand.compareTo("quit") != 0 && _usrCommand.compareTo("exit") != 0)
 			{
 				_usrCommand = _read.readLine();
-				if(_usrCommand == null)
+				if (_usrCommand == null)
 				{
 					_cSocket.close();
 					break;
 				}
-				if (_usrCommand.equals("help")) {
+				if (_usrCommand.equals("help"))
+				{
 					_print.println("The following is a list of all available commands: ");
 					_print.println("help                  - shows this help.");
 					_print.println("status                - displays basic server statistics.");
@@ -255,7 +273,7 @@ public class GameStatusThread extends Thread
 					_print.println("unjail <player>");
 					_print.println("quit                  - closes telnet session.");
 				}
-				else if(_usrCommand.equals("help debug"))
+				else if (_usrCommand.equals("help debug"))
 				{
 					_print.println("The following is a list of all available debug commands: ");
 					_print.println("full                - Dumps complete debug information to an file (recommended)");
@@ -273,7 +291,7 @@ public class GameStatusThread extends Thread
 				{
 					System.gc();
 					StringBuilder sb = new StringBuilder();
-					sb.append("RAM Used: "+((Runtime.getRuntime().totalMemory()-Runtime.getRuntime().freeMemory())/1048576)); // 1024 * 1024 = 1048576
+					sb.append("RAM Used: " + ((Runtime.getRuntime().totalMemory() - Runtime.getRuntime().freeMemory()) / 1048576)); // 1024 * 1024 = 1048576
 					_print.println(sb.toString());
 				}
 				else if (_usrCommand.equals("performance"))
@@ -315,17 +333,12 @@ public class GameStatusThread extends Thread
 					
 					_print.println("+----");// ...
 					_print.println("| Allowed Memory:" + df2.format(max));
-					_print.println("|    |= Allocated Memory:" + df2.format(allocated)
-							+ df.format(allocated / max * 100));
-					_print.println("|    |= Non-Allocated Memory:" + df2.format(nonAllocated)
-							+ df.format(nonAllocated / max * 100));
+					_print.println("|    |= Allocated Memory:" + df2.format(allocated) + df.format(allocated / max * 100));
+					_print.println("|    |= Non-Allocated Memory:" + df2.format(nonAllocated) + df.format(nonAllocated / max * 100));
 					_print.println("| Allocated Memory:" + df2.format(allocated));
-					_print.println("|    |= Used Memory:" + df2.format(used)
-							+ df.format(used / max * 100));
-					_print.println("|    |= Unused (cached) Memory:" + df2.format(cached)
-							+ df.format(cached / max * 100));
-					_print.println("| Useable Memory:" + df2.format(useable)
-							+ df.format(useable / max * 100)); // ...
+					_print.println("|    |= Used Memory:" + df2.format(used) + df.format(used / max * 100));
+					_print.println("|    |= Unused (cached) Memory:" + df2.format(cached) + df.format(cached / max * 100));
+					_print.println("| Useable Memory:" + df2.format(useable) + df.format(useable / max * 100)); // ...
 					_print.println("+----");
 				}
 				else if (_usrCommand.startsWith("announce"))
@@ -348,10 +361,10 @@ public class GameStatusThread extends Thread
 						String val = _usrCommand.substring(4);
 						StringTokenizer st = new StringTokenizer(val);
 						String name = st.nextToken();
-						String message = val.substring(name.length()+1);
+						String message = val.substring(name.length() + 1);
 						L2PcInstance reciever = L2World.getInstance().getPlayer(name);
 						CreatureSay cs = new CreatureSay(0, Say2.TELL, "Telnet Priv", message);
-						if(reciever != null)
+						if (reciever != null)
 						{
 							reciever.sendPacket(cs);
 							_print.println("Telnet Priv->" + name + ": " + message);
@@ -391,37 +404,38 @@ public class GameStatusThread extends Thread
 						gmList = gmList + ", " + player;
 						igm++;
 					}
-					_print.println("There are currently " + igm +" GM(s) online...");
-					if (!gmList.isEmpty()) _print.println(gmList);
+					_print.println("There are currently " + igm + " GM(s) online...");
+					if (!gmList.isEmpty())
+						_print.println(gmList);
 				}
 				/*else if (_usrCommand.startsWith("unblock"))
-                {
-                    try
-                    {
-                        _usrCommand = _usrCommand.substring(8);
-                        if (LoginServer.getInstance().unblockIp(_usrCommand))
-                        {
-                            _log.warning("IP removed via TELNET by host: " + _csocket.getInetAddress().getHostAddress());
-                            _print.println("The IP " + _usrCommand + " has been removed from the hack protection list!");
-                        }
-                        else
-                        {
-                            _print.println("IP not found in hack protection list...");
-                        }
-                        //TODO: with packet
-                    }
-                    catch (StringIndexOutOfBoundsException e)
-                    {
-                        _print.println("Please Enter the IP to Unblock!");
-                    }
-                }*/
+				{
+				    try
+				    {
+				        _usrCommand = _usrCommand.substring(8);
+				        if (LoginServer.getInstance().unblockIp(_usrCommand))
+				        {
+				            _log.warning("IP removed via TELNET by host: " + _csocket.getInetAddress().getHostAddress());
+				            _print.println("The IP " + _usrCommand + " has been removed from the hack protection list!");
+				        }
+				        else
+				        {
+				            _print.println("IP not found in hack protection list...");
+				        }
+				        //TODO: with packet
+				    }
+				    catch (StringIndexOutOfBoundsException e)
+				    {
+				        _print.println("Please Enter the IP to Unblock!");
+				    }
+				}*/
 				else if (_usrCommand.startsWith("kick"))
 				{
 					try
 					{
 						_usrCommand = _usrCommand.substring(5);
 						L2PcInstance player = L2World.getInstance().getPlayer(_usrCommand);
-						if(player != null)
+						if (player != null)
 						{
 							player.sendMessage("You are kicked by gm");
 							player.logout();
@@ -446,7 +460,8 @@ public class GameStatusThread extends Thread
 					{
 						_print.println("Please Enter * amount of seconds to shutdown!");
 					}
-					catch (Exception NumberFormatException) {
+					catch (Exception NumberFormatException)
+					{
 						_print.println("Numbers Only!");
 					}
 				}
@@ -463,7 +478,8 @@ public class GameStatusThread extends Thread
 					{
 						_print.println("Please Enter * amount of seconds to restart!");
 					}
-					catch (Exception NumberFormatException) {
+					catch (Exception NumberFormatException)
+					{
 						_print.println("Numbers Only!");
 					}
 				}
@@ -472,7 +488,9 @@ public class GameStatusThread extends Thread
 					Shutdown.getInstance().telnetAbort(_cSocket.getInetAddress().getHostAddress());
 					_print.println("OK! - Shutdown/Restart Aborted.");
 				}
-				else if (_usrCommand.equals("quit")) { /* Do Nothing :p - Just here to save us from the "Command Not Understood" Text */ }
+				else if (_usrCommand.equals("quit"))
+				{ /* Do Nothing :p - Just here to save us from the "Command Not Understood" Text */
+				}
 				else if (_usrCommand.startsWith("give"))
 				{
 					StringTokenizer st = new StringTokenizer(_usrCommand.substring(5));
@@ -483,7 +501,7 @@ public class GameStatusThread extends Thread
 						int itemId = Integer.parseInt(st.nextToken());
 						int amount = Integer.parseInt(st.nextToken());
 						
-						if(player != null)
+						if (player != null)
 						{
 							L2ItemInstance item = player.getInventory().addItem("Status-Give", itemId, amount, null, null);
 							InventoryUpdate iu = new InventoryUpdate();
@@ -494,14 +512,14 @@ public class GameStatusThread extends Thread
 							sm.addItemNumber(amount);
 							player.sendPacket(sm);
 							_print.println("ok");
-							GMAudit.auditGMAction("Telnet Admin", "Give Item", player.getName(), "item: "+itemId+" amount: "+amount);
+							GMAudit.auditGMAction("Telnet Admin", "Give Item", player.getName(), "item: " + itemId + " amount: " + amount);
 						}
 						else
 						{
 							_print.println("Player not found");
 						}
 					}
-					catch(Exception e)
+					catch (Exception e)
 					{
 						
 					}
@@ -517,7 +535,7 @@ public class GameStatusThread extends Thread
 						itemType = Integer.parseInt(st.nextToken());
 						enchant = Integer.parseInt(st.nextToken());
 						
-						switch(itemType)
+						switch (itemType)
 						{
 							case 1:
 								itemType = Inventory.PAPERDOLL_HEAD;
@@ -575,15 +593,16 @@ public class GameStatusThread extends Thread
 						
 						boolean success = false;
 						
-						if(player != null && itemType > 0)
+						if (player != null && itemType > 0)
 						{
 							success = setEnchant(player, enchant, itemType);
-							if (success)_print.println("Item enchanted successfully.");
+							if (success)
+								_print.println("Item enchanted successfully.");
 						}
 						else if (!success)
 							_print.println("Item failed to enchant.");
 					}
-					catch(Exception e)
+					catch (Exception e)
 					{
 						
 					}
@@ -599,22 +618,31 @@ public class GameStatusThread extends Thread
 						try
 						{
 							delay = Integer.parseInt(st.nextToken());
-						} catch (NumberFormatException nfe) {
-						} catch (NoSuchElementException nsee) {}
+						}
+						catch (NumberFormatException nfe)
+						{
+						}
+						catch (NoSuchElementException nsee)
+						{
+						}
 						//L2PcInstance playerObj = L2World.getInstance().getPlayer(player);
 						
 						if (playerObj != null)
 						{
 							playerObj.setPunishLevel(L2PcInstance.PunishLevel.JAIL, delay);
-							_print.println("Character "+playerObj.getName()+" jailed for "+(delay>0 ? delay+" minutes." : "ever!"));
-						} else
+							_print.println("Character " + playerObj.getName() + " jailed for " + (delay > 0 ? delay + " minutes." : "ever!"));
+						}
+						else
 							jailOfflinePlayer(playerName, delay);
-					} catch (NoSuchElementException nsee)
+					}
+					catch (NoSuchElementException nsee)
 					{
 						_print.println("Specify a character name.");
-					} catch(Exception e)
+					}
+					catch (Exception e)
 					{
-						if (Config.DEBUG) e.printStackTrace();
+						if (Config.DEBUG)
+							e.printStackTrace();
 					}
 				}
 				else if (_usrCommand.startsWith("unjail"))
@@ -628,15 +656,19 @@ public class GameStatusThread extends Thread
 						if (playerObj != null)
 						{
 							playerObj.setPunishLevel(L2PcInstance.PunishLevel.NONE, 0);
-							_print.println("Character "+playerObj.getName()+" removed from jail");
-						} else
+							_print.println("Character " + playerObj.getName() + " removed from jail");
+						}
+						else
 							unjailOfflinePlayer(playerName);
-					} catch (NoSuchElementException nsee)
+					}
+					catch (NoSuchElementException nsee)
 					{
 						_print.println("Specify a character name.");
-					} catch(Exception e)
+					}
+					catch (Exception e)
 					{
-						if (Config.DEBUG) e.printStackTrace();
+						if (Config.DEBUG)
+							e.printStackTrace();
 					}
 				}
 				else if (_usrCommand.startsWith("debug") && _usrCommand.length() > 6)
@@ -648,78 +680,80 @@ public class GameStatusThread extends Thread
 					{
 						String dbg = st.nextToken();
 						
-						if(dbg.equals("decay"))
+						if (dbg.equals("decay"))
 						{
 							_print.print(DecayTaskManager.getInstance().toString());
 						}
-						else if(dbg.equals("ai"))
+						else if (dbg.equals("ai"))
 						{
 							/*
-                			_print.println("AITaskManagerStats");
-                			for(String line : AITaskManager.getInstance().getStats())
-                			{
-                				_print.println(line);
-                			}
+							_print.println("AITaskManagerStats");
+							for(String line : AITaskManager.getInstance().getStats())
+							{
+								_print.println(line);
+							}
 							 */
 						}
-						else if(dbg.equals("aiflush"))
+						else if (dbg.equals("aiflush"))
 						{
 							//AITaskManager.getInstance().flush();
 						}
-						else if(dbg.equals("PacketTP"))
+						else if (dbg.equals("PacketTP"))
 						{
 							String str = ThreadPoolManager.getInstance().getPacketStats();
 							_print.println(str);
 							int i = 0;
-							File f = new File("./log/StackTrace-PacketTP-"+i+".txt");
-							while(f.exists())
+							File f = new File("./log/StackTrace-PacketTP-" + i + ".txt");
+							while (f.exists())
 							{
 								i++;
-								f = new File("./log/StackTrace-PacketTP-"+i+".txt");
+								f = new File("./log/StackTrace-PacketTP-" + i + ".txt");
 							}
 							f.getParentFile().mkdirs();
 							fos = new FileOutputStream(f);
 							out = new OutputStreamWriter(fos, "UTF-8");
 							out.write(str);
 						}
-						else if(dbg.equals("IOPacketTP"))
+						else if (dbg.equals("IOPacketTP"))
 						{
 							String str = ThreadPoolManager.getInstance().getIOPacketStats();
 							_print.println(str);
 							int i = 0;
-							File f = new File("./log/StackTrace-IOPacketTP-"+i+".txt");
-							while(f.exists())
+							File f = new File("./log/StackTrace-IOPacketTP-" + i + ".txt");
+							while (f.exists())
 							{
 								i++;
-								f = new File("./log/StackTrace-IOPacketTP-"+i+".txt");
+								f = new File("./log/StackTrace-IOPacketTP-" + i + ".txt");
 							}
 							f.getParentFile().mkdirs();
 							fos = new FileOutputStream(f);
 							out = new OutputStreamWriter(fos, "UTF-8");
 							out.write(str);
 						}
-						else if(dbg.equals("GeneralTP"))
+						else if (dbg.equals("GeneralTP"))
 						{
 							String str = ThreadPoolManager.getInstance().getGeneralStats();
 							_print.println(str);
 							int i = 0;
-							File f = new File("./log/StackTrace-GeneralTP-"+i+".txt");
-							while(f.exists())
+							File f = new File("./log/StackTrace-GeneralTP-" + i + ".txt");
+							while (f.exists())
 							{
 								i++;
-								f = new File("./log/StackTrace-GeneralTP-"+i+".txt");
+								f = new File("./log/StackTrace-GeneralTP-" + i + ".txt");
 							}
 							f.getParentFile().mkdirs();
 							fos = new FileOutputStream(f);
 							out = new OutputStreamWriter(fos, "UTF-8");
 							out.write(str);
 						}
-						else if(dbg.equals("full"))
+						else if (dbg.equals("full"))
 						{
 							this.debugAll();
 						}
 					}
-					catch(Exception e){}
+					catch (Exception e)
+					{
+					}
 					finally
 					{
 						try
@@ -747,56 +781,56 @@ public class GameStatusThread extends Thread
 					{
 						String type = st.nextToken();
 						
-						if(type.equals("multisell"))
+						if (type.equals("multisell"))
 						{
 							_print.print("Reloading multisell... ");
 							MultiSell.getInstance().reload();
 							_print.println("done");
 						}
-						else if(type.equals("skill"))
+						else if (type.equals("skill"))
 						{
 							_print.print("Reloading skills... ");
 							SkillTable.getInstance().reload();
 							_print.println("done");
 						}
-						else if(type.equals("npc"))
+						else if (type.equals("npc"))
 						{
 							_print.print("Reloading npc templates... ");
 							NpcTable.getInstance().reloadAllNpc();
 							QuestManager.getInstance().reloadAllQuests();
 							_print.println("done");
 						}
-						else if(type.equals("html"))
+						else if (type.equals("html"))
 						{
 							_print.print("Reloading html cache... ");
 							HtmCache.getInstance().reload();
 							_print.println("done");
 						}
-						else if(type.equals("item"))
+						else if (type.equals("item"))
 						{
 							_print.print("Reloading item templates... ");
 							ItemTable.getInstance().reload();
 							_print.println("done");
 						}
-						else if(type.equals("instancemanager"))
+						else if (type.equals("instancemanager"))
 						{
 							_print.print("Reloading instance managers... ");
 							Manager.reloadAll();
 							_print.println("done");
 						}
-						else if(type.equals("zone"))
+						else if (type.equals("zone"))
 						{
 							_print.print("Reloading zone tables... ");
 							ZoneManager.getInstance().reload();
 							_print.println("done");
 						}
-						else if(type.equals("teleports"))
+						else if (type.equals("teleports"))
 						{
 							_print.print("Reloading telport location table... ");
 							TeleportLocationTable.getInstance().reloadAll();
 							_print.println("done");
 						}
-						else if(type.equals("spawns"))
+						else if (type.equals("spawns"))
 						{
 							_print.print("Reloading spawns... ");
 							RaidBossSpawnManager.getInstance().cleanUp();
@@ -808,7 +842,9 @@ public class GameStatusThread extends Thread
 							_print.println("done\n");
 						}
 					}
-					catch(Exception e){}
+					catch (Exception e)
+					{
+					}
 				}
 				else if (_usrCommand.startsWith("gamestat"))
 				{
@@ -818,7 +854,7 @@ public class GameStatusThread extends Thread
 						String type = st.nextToken();
 						
 						// name;type;x;y;itemId:enchant:price...
-						if(type.equals("privatestore"))
+						if (type.equals("privatestore"))
 						{
 							Collection<L2PcInstance> pls = L2World.getInstance().getAllPlayers().values();
 							//synchronized (L2World.getInstance().getAllPlayers())
@@ -836,16 +872,9 @@ public class GameStatusThread extends Thread
 										list = player.getSellList();
 										for (TradeItem item : list.getItems())
 										{
-											content += item.getItem().getItemId()
-											+ ":"
-											+ item.getEnchant()
-											+ ":"
-											+ item.getPrice()
-											+ ":";
+											content += item.getItem().getItemId() + ":" + item.getEnchant() + ":" + item.getPrice() + ":";
 										}
-										content = player.getName() + ";"
-										+ "sell;" + player.getX() + ";"
-										+ player.getY() + ";" + content;
+										content = player.getName() + ";" + "sell;" + player.getX() + ";" + player.getY() + ";" + content;
 										_print.println(content);
 										continue;
 									}
@@ -854,16 +883,9 @@ public class GameStatusThread extends Thread
 										list = player.getBuyList();
 										for (TradeItem item : list.getItems())
 										{
-											content += item.getItem().getItemId()
-											+ ":"
-											+ item.getEnchant()
-											+ ":"
-											+ item.getPrice()
-											+ ":";
+											content += item.getItem().getItemId() + ":" + item.getEnchant() + ":" + item.getPrice() + ":";
 										}
-										content = player.getName() + ";"
-										+ "buy;" + player.getX() + ";"
-										+ player.getY() + ";" + content;
+										content = player.getName() + ";" + "buy;" + player.getX() + ";" + player.getY() + ";" + content;
 										_print.println(content);
 										continue;
 									}
@@ -872,19 +894,23 @@ public class GameStatusThread extends Thread
 							}
 						}
 					}
-					catch(Exception e){}
+					catch (Exception e)
+					{
+					}
+				}
+				else if (_usrCommand.length() == 0)
+				{ /* Do Nothing Again - Same reason as the quit part */
 				}
-				else if (_usrCommand.length() == 0) { /* Do Nothing Again - Same reason as the quit part */ }
 				_print.print("");
 				_print.flush();
 			}
-			if(!_cSocket.isClosed())
+			if (!_cSocket.isClosed())
 			{
 				_print.println("Bye Bye!");
 				_print.flush();
 				_cSocket.close();
 			}
-			telnetOutput(1, "Connection from "+_cSocket.getInetAddress().getHostAddress()+" was closed by client.");
+			telnetOutput(1, "Connection from " + _cSocket.getInetAddress().getHostAddress() + " was closed by client.");
 		}
 		catch (IOException e)
 		{
@@ -903,7 +929,8 @@ public class GameStatusThread extends Thread
 		if (parmorInstance != null && parmorInstance.getLocationSlot() == armorType)
 		{
 			itemInstance = parmorInstance;
-		} else
+		}
+		else
 		{
 			// for bows/crossbows and double handed weapons
 			parmorInstance = activeChar.getInventory().getPaperdollItem(Inventory.PAPERDOLL_RHAND);
@@ -929,10 +956,8 @@ public class GameStatusThread extends Thread
 			activeChar.broadcastPacket(new ExBrExtraUserInfo(activeChar));
 			
 			// informations
-			activeChar.sendMessage("Changed enchantment of " + activeChar.getName() + "'s "
-					+ itemInstance.getItem().getName() + " from " + curEnchant + " to " + ench + ".");
-			activeChar.sendMessage("Admin has changed the enchantment of your "
-					+ itemInstance.getItem().getName() + " from " + curEnchant + " to " + ench + ".");
+			activeChar.sendMessage("Changed enchantment of " + activeChar.getName() + "'s " + itemInstance.getItem().getName() + " from " + curEnchant + " to " + ench + ".");
+			activeChar.sendMessage("Admin has changed the enchantment of your " + itemInstance.getItem().getName() + " from " + curEnchant + " to " + ench + ".");
 			
 			// log
 			GMAudit.auditGMAction("TelnetAdministrator", "enchant", activeChar.getName(), itemInstance.getItem().getName() + "(" + itemInstance.getObjectId() + ")" + " from " + curEnchant + " to " + ench);
@@ -963,12 +988,13 @@ public class GameStatusThread extends Thread
 			if (count == 0)
 				_print.println("Character not found!");
 			else
-				_print.println("Character "+name+" jailed for "+(delay>0 ? delay+" minutes." : "ever!"));
+				_print.println("Character " + name + " jailed for " + (delay > 0 ? delay + " minutes." : "ever!"));
 		}
 		catch (SQLException se)
 		{
 			_print.println("SQLException while jailing player");
-			if (Config.DEBUG) se.printStackTrace();
+			if (Config.DEBUG)
+				se.printStackTrace();
 		}
 		finally
 		{
@@ -998,12 +1024,13 @@ public class GameStatusThread extends Thread
 			if (count == 0)
 				_print.println("Character not found!");
 			else
-				_print.println("Character "+name+" set free.");
+				_print.println("Character " + name + " set free.");
 		}
 		catch (SQLException se)
 		{
 			_print.println("SQLException while jailing player");
-			if (Config.DEBUG) se.printStackTrace();
+			if (Config.DEBUG)
+				se.printStackTrace();
 		}
 		finally
 		{
@@ -1018,19 +1045,19 @@ public class GameStatusThread extends Thread
 	
 	private String getUptime(int time)
 	{
-		int uptime = (int)System.currentTimeMillis() - time;
+		int uptime = (int) System.currentTimeMillis() - time;
 		uptime = uptime / 1000;
 		int h = uptime / 3600;
-		int m = (uptime-(h*3600))/60;
-		int s = ((uptime-(h*3600))-(m*60));
+		int m = (uptime - (h * 3600)) / 60;
+		int s = ((uptime - (h * 3600)) - (m * 60));
 		return h + "hrs " + m + "mins " + s + "secs";
 	}
 	
 	private String gameTime()
 	{
 		int t = GameTimeController.getInstance().getGameTime();
-		int h = t/60;
-		int m = t%60;
+		int h = t / 60;
+		int m = t % 60;
 		SimpleDateFormat format = new SimpleDateFormat("H:mm");
 		Calendar cal = Calendar.getInstance();
 		cal.set(Calendar.HOUR_OF_DAY, h);
@@ -1047,31 +1074,31 @@ public class GameStatusThread extends Thread
 		playerCount = L2World.getInstance().getAllPlayersCount();
 		objectCount = L2World.getInstance().getAllVisibleObjectsCount();
 		
-		int itemCount=0;
-		int itemVoidCount=0;
-		int monsterCount=0;
+		int itemCount = 0;
+		int itemVoidCount = 0;
+		int monsterCount = 0;
 		int minionCount = 0;
 		int minionsGroupCount = 0;
-		int npcCount=0;
-		int charCount=0;
-		int pcCount=0;
-		int detachedCount=0;
-		int doorCount=0;
-		int summonCount=0;
-		int AICount=0;
+		int npcCount = 0;
+		int charCount = 0;
+		int pcCount = 0;
+		int detachedCount = 0;
+		int doorCount = 0;
+		int summonCount = 0;
+		int AICount = 0;
 		
 		Collection<L2Object> objs = L2World.getInstance().getAllVisibleObjects().values();
 		//synchronized (L2World.getInstance().getAllVisibleObjects())
 		{
 			for (L2Object obj : objs)
 			{
-				if(obj == null)
+				if (obj == null)
 					continue;
 				if (obj instanceof L2Character)
-					if (((L2Character)obj).hasAI())
+					if (((L2Character) obj).hasAI())
 						AICount++;
 				if (obj instanceof L2ItemInstance)
-					if (((L2ItemInstance)obj).getLocation() == L2ItemInstance.ItemLocation.VOID)
+					if (((L2ItemInstance) obj).getLocation() == L2ItemInstance.ItemLocation.VOID)
 						itemVoidCount++;
 					else
 						itemCount++;
@@ -1079,10 +1106,10 @@ public class GameStatusThread extends Thread
 				else if (obj instanceof L2MonsterInstance)
 				{
 					monsterCount++;
-					if (((L2MonsterInstance)obj).hasMinions())
+					if (((L2MonsterInstance) obj).hasMinions())
 					{
-						minionCount += ((L2MonsterInstance)obj).getMinionList().countSpawnedMinions();
-						minionsGroupCount += ((L2MonsterInstance)obj).getMinionList().lazyCountSpawnedMinionsGroups();
+						minionCount += ((L2MonsterInstance) obj).getMinionList().countSpawnedMinions();
+						minionsGroupCount += ((L2MonsterInstance) obj).getMinionList().lazyCountSpawnedMinionsGroups();
 					}
 				}
 				else if (obj instanceof L2Npc)
@@ -1090,8 +1117,7 @@ public class GameStatusThread extends Thread
 				else if (obj instanceof L2PcInstance)
 				{
 					pcCount++;
-					if (((L2PcInstance)obj).getClient() != null
-							&& ((L2PcInstance)obj).getClient().isDetached())
+					if (((L2PcInstance) obj).getClient() != null && ((L2PcInstance) obj).getClient().isDetached())
 						detachedCount++;
 				}
 				else if (obj instanceof L2Summon)
@@ -1122,7 +1148,7 @@ public class GameStatusThread extends Thread
 		sb.append("\r\n  ---> Server Uptime: " + getUptime(_uptime));
 		sb.append("\r\n  --->      GM Count: " + getOnlineGMS());
 		sb.append("\r\n  --->       Threads: " + Thread.activeCount());
-		sb.append("\r\n  RAM Used: "+((Runtime.getRuntime().totalMemory()-Runtime.getRuntime().freeMemory())/1048576)); // 1024 * 1024 = 1048576
+		sb.append("\r\n  RAM Used: " + ((Runtime.getRuntime().totalMemory() - Runtime.getRuntime().freeMemory()) / 1048576)); // 1024 * 1024 = 1048576
 		sb.append("\r\n");
 		
 		return sb.toString();
@@ -1134,36 +1160,34 @@ public class GameStatusThread extends Thread
 		Calendar cal = Calendar.getInstance();
 		SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss Z");
 		
-		
 		StringBuilder sb = new StringBuilder();
 		sb.append(sdf.format(cal.getTime()));
-		sb.append("\n\nL2J Server Version: "+Config.SERVER_VERSION);
-		sb.append("\nDP Revision: "+Config.DATAPACK_VERSION);
+		sb.append("\n\nL2J Server Version: " + Config.SERVER_VERSION);
+		sb.append("\nDP Revision: " + Config.DATAPACK_VERSION);
 		sb.append("\n\n");
 		sb.append(this.getServerStatus());
 		sb.append("\n\n");
 		sb.append("\n## Java Platform Information ##");
-		sb.append("\nJava Runtime Name: "+System.getProperty("java.runtime.name"));
-		sb.append("\nJava Version: "+System.getProperty("java.version"));
-		sb.append("\nJava Class Version: "+System.getProperty("java.class.version"));
+		sb.append("\nJava Runtime Name: " + System.getProperty("java.runtime.name"));
+		sb.append("\nJava Version: " + System.getProperty("java.version"));
+		sb.append("\nJava Class Version: " + System.getProperty("java.class.version"));
 		sb.append('\n');
 		sb.append("\n## Virtual Machine Information ##");
-		sb.append("\nVM Name: "+System.getProperty("java.vm.name"));
-		sb.append("\nVM Version: "+System.getProperty("java.vm.version"));
-		sb.append("\nVM Vendor: "+System.getProperty("java.vm.vendor"));
-		sb.append("\nVM Info: "+System.getProperty("java.vm.info"));
+		sb.append("\nVM Name: " + System.getProperty("java.vm.name"));
+		sb.append("\nVM Version: " + System.getProperty("java.vm.version"));
+		sb.append("\nVM Vendor: " + System.getProperty("java.vm.vendor"));
+		sb.append("\nVM Info: " + System.getProperty("java.vm.info"));
 		sb.append('\n');
 		sb.append("\n## OS Information ##");
-		sb.append("\nName: "+System.getProperty("os.name"));
-		sb.append("\nArchiteture: "+System.getProperty("os.arch"));
-		sb.append("\nVersion: "+System.getProperty("os.version"));
+		sb.append("\nName: " + System.getProperty("os.name"));
+		sb.append("\nArchiteture: " + System.getProperty("os.arch"));
+		sb.append("\nVersion: " + System.getProperty("os.version"));
 		sb.append('\n');
 		sb.append("\n## Runtime Information ##");
-		sb.append("\nCPU Count: "+Runtime.getRuntime().availableProcessors());
-		sb.append("\nCurrent Free Heap Size: "+(Runtime.getRuntime().freeMemory() / 1024 / 1024)+" mb");
-		sb.append("\nCurrent Heap Size: "+(Runtime.getRuntime().totalMemory() / 1024 / 1024)+" mb");
-		sb.append("\nMaximum Heap Size: "+(Runtime.getRuntime().maxMemory() / 1024 / 1024)+" mb");
-		
+		sb.append("\nCPU Count: " + Runtime.getRuntime().availableProcessors());
+		sb.append("\nCurrent Free Heap Size: " + (Runtime.getRuntime().freeMemory() / 1024 / 1024) + " mb");
+		sb.append("\nCurrent Heap Size: " + (Runtime.getRuntime().totalMemory() / 1024 / 1024) + " mb");
+		sb.append("\nMaximum Heap Size: " + (Runtime.getRuntime().maxMemory() / 1024 / 1024) + " mb");
 		
 		sb.append('\n');
 		sb.append("\n## Class Path Information ##\n");
@@ -1180,31 +1204,28 @@ public class GameStatusThread extends Thread
 		Map<Thread, StackTraceElement[]> allThread = Thread.getAllStackTraces();
 		
 		FastTable<Entry<Thread, StackTraceElement[]>> entries = new FastTable<Entry<Thread, StackTraceElement[]>>();
-		entries.setValueComparator
-		(
-				new FastComparator<Entry<Thread, StackTraceElement[]>>()
-				{
-					
-					@Override
-					public boolean areEqual(Entry<Thread, StackTraceElement[]> e1, Entry<Thread, StackTraceElement[]> e2)
-					{
-						return e1.getKey().getName().equals(e2.getKey().getName());
-					}
-					
-					@Override
-					public int compare(Entry<Thread, StackTraceElement[]> e1, Entry<Thread, StackTraceElement[]> e2)
-					{
-						return e1.getKey().getName().compareTo(e2.getKey().getName());
-					}
-					
-					@Override
-					public int hashCodeOf(Entry<Thread, StackTraceElement[]> e)
-					{
-						return e.hashCode();
-					}
-					
-				}
-		);
+		entries.setValueComparator(new FastComparator<Entry<Thread, StackTraceElement[]>>()
+		{
+			
+			@Override
+			public boolean areEqual(Entry<Thread, StackTraceElement[]> e1, Entry<Thread, StackTraceElement[]> e2)
+			{
+				return e1.getKey().getName().equals(e2.getKey().getName());
+			}
+			
+			@Override
+			public int compare(Entry<Thread, StackTraceElement[]> e1, Entry<Thread, StackTraceElement[]> e2)
+			{
+				return e1.getKey().getName().compareTo(e2.getKey().getName());
+			}
+			
+			@Override
+			public int hashCodeOf(Entry<Thread, StackTraceElement[]> e)
+			{
+				return e.hashCode();
+			}
+			
+		});
 		entries.addAll(allThread.entrySet());
 		entries.sort();
 		for (Entry<Thread, StackTraceElement[]> entry : entries)
@@ -1212,9 +1233,9 @@ public class GameStatusThread extends Thread
 			StackTraceElement[] stes = entry.getValue();
 			Thread t = entry.getKey();
 			sb.append("--------------\n");
-			sb.append(t.toString()+" ("+t.getId()+")\n");
-			sb.append("State: "+t.getState()+'\n');
-			sb.append("isAlive: "+t.isAlive()+" | isDaemon: "+t.isDaemon()+" | isInterrupted: "+t.isInterrupted()+'\n');
+			sb.append(t.toString() + " (" + t.getId() + ")\n");
+			sb.append("State: " + t.getState() + '\n');
+			sb.append("isAlive: " + t.isAlive() + " | isDaemon: " + t.isDaemon() + " | isInterrupted: " + t.isInterrupted() + '\n');
 			sb.append('\n');
 			for (StackTraceElement ste : stes)
 			{
@@ -1234,13 +1255,12 @@ public class GameStatusThread extends Thread
 			sb.append('\n');
 		}
 		
-		
 		int i = 0;
-		File f = new File("./log/Debug-"+i+".txt");
-		while(f.exists())
+		File f = new File("./log/Debug-" + i + ".txt");
+		while (f.exists())
 		{
 			i++;
-			f = new File("./log/Debug-"+i+".txt");
+			f = new File("./log/Debug-" + i + ".txt");
 		}
 		f.getParentFile().mkdirs();
 		FileOutputStream fos = new FileOutputStream(f);
@@ -1250,7 +1270,7 @@ public class GameStatusThread extends Thread
 		out.close();
 		fos.close();
 		
-		_print.println("Debug output saved to log/"+f.getName());
+		_print.println("Debug output saved to log/" + f.getName());
 		_print.flush();
 	}
 	

+ 65 - 42
L2J_Server_BETA/java/com/l2jserver/status/LoginStatusThread.java

@@ -14,7 +14,6 @@
  */
 package com.l2jserver.status;
 
-
 import java.io.BufferedReader;
 import java.io.File;
 import java.io.FileInputStream;
@@ -32,63 +31,76 @@ import com.l2jserver.loginserver.GameServerTable;
 import com.l2jserver.loginserver.L2LoginServer;
 import com.l2jserver.loginserver.LoginController;
 
-
-
 public class LoginStatusThread extends Thread
 {
 	private static final Logger _log = Logger.getLogger(LoginStatusThread.class.getName());
 	
-	private Socket                  _cSocket;
-	
-	private PrintWriter             _print;
-	private BufferedReader          _read;
+	private Socket _cSocket;
 	
+	private PrintWriter _print;
+	private BufferedReader _read;
 	
 	private boolean _redirectLogger;
 	
-	private void telnetOutput(int type, String text) {
-		if ( type == 1 ) System.out.println("TELNET | "+text);
-		else if ( type == 2 ) System.out.print("TELNET | "+text);
-		else if ( type == 3 ) System.out.print(text);
-		else if ( type == 4 ) System.out.println(text);
-		else System.out.println("TELNET | "+text);
+	private void telnetOutput(int type, String text)
+	{
+		if (type == 1)
+			System.out.println("TELNET | " + text);
+		else if (type == 2)
+			System.out.print("TELNET | " + text);
+		else if (type == 3)
+			System.out.print(text);
+		else if (type == 4)
+			System.out.println(text);
+		else
+			System.out.println("TELNET | " + text);
 	}
 	
-	private boolean isValidIP(Socket client) {
+	private boolean isValidIP(Socket client)
+	{
 		boolean result = false;
 		InetAddress ClientIP = client.getInetAddress();
 		
 		// convert IP to String, and compare with list
 		String clientStringIP = ClientIP.getHostAddress();
 		
-		telnetOutput(1, "Connection from: "+clientStringIP);
+		telnetOutput(1, "Connection from: " + clientStringIP);
 		
 		// read and loop thru list of IPs, compare with newIP
-		if ( Config.DEVELOPER ) telnetOutput(2, "");
+		if (Config.DEVELOPER)
+			telnetOutput(2, "");
 		
 		InputStream telnetIS = null;
-		try {
+		try
+		{
 			Properties telnetSettings = new Properties();
 			telnetIS = new FileInputStream(new File(Config.TELNET_FILE));
 			telnetSettings.load(telnetIS);
 			
 			String HostList = telnetSettings.getProperty("ListOfHosts", "127.0.0.1,localhost,::1");
 			
-			if ( Config.DEVELOPER ) telnetOutput(3, "Comparing ip to list...");
+			if (Config.DEVELOPER)
+				telnetOutput(3, "Comparing ip to list...");
 			
 			// compare
 			String ipToCompare = null;
-			for (String ip:HostList.split(",")) {
-				if ( !result ) {
+			for (String ip : HostList.split(","))
+			{
+				if (!result)
+				{
 					ipToCompare = InetAddress.getByName(ip).getHostAddress();
-					if ( clientStringIP.equals(ipToCompare) ) result = true;
-					if ( Config.DEVELOPER ) telnetOutput(3, clientStringIP + " = " + ipToCompare + "("+ip+") = " + result);
+					if (clientStringIP.equals(ipToCompare))
+						result = true;
+					if (Config.DEVELOPER)
+						telnetOutput(3, clientStringIP + " = " + ipToCompare + "(" + ip + ") = " + result);
 				}
 			}
 		}
-		catch ( IOException e) {
-			if ( Config.DEVELOPER ) telnetOutput(4, "");
-			telnetOutput(1, "Error: "+e);
+		catch (IOException e)
+		{
+			if (Config.DEVELOPER)
+				telnetOutput(4, "");
+			telnetOutput(1, "Error: " + e);
 		}
 		finally
 		{
@@ -101,7 +113,8 @@ public class LoginStatusThread extends Thread
 			}
 		}
 		
-		if ( Config.DEVELOPER ) telnetOutput(4, "Allow IP: "+result);
+		if (Config.DEVELOPER)
+			telnetOutput(4, "Allow IP: " + result);
 		return result;
 	}
 	
@@ -110,22 +123,25 @@ public class LoginStatusThread extends Thread
 		_cSocket = client;
 		
 		_print = new PrintWriter(_cSocket.getOutputStream());
-		_read  = new BufferedReader(new InputStreamReader(_cSocket.getInputStream()));
+		_read = new BufferedReader(new InputStreamReader(_cSocket.getInputStream()));
 		
-		if ( isValidIP(client) ) {
-			telnetOutput(1, client.getInetAddress().getHostAddress()+" accepted.");
+		if (isValidIP(client))
+		{
+			telnetOutput(1, client.getInetAddress().getHostAddress() + " accepted.");
 			_print.println("Welcome To The L2J Telnet Session.");
 			_print.println("Please Insert Your Password!");
 			_print.print("Password: ");
 			_print.flush();
 			String tmpLine = _read.readLine();
-			if ( tmpLine == null )  {
+			if (tmpLine == null)
+			{
 				_print.println("Error.");
 				_print.println("Disconnected...");
 				_print.flush();
 				_cSocket.close();
 			}
-			else {
+			else
+			{
 				if (tmpLine.compareTo(StatusPW) != 0)
 				{
 					_print.println("Incorrect Password!");
@@ -143,8 +159,9 @@ public class LoginStatusThread extends Thread
 				}
 			}
 		}
-		else {
-			telnetOutput(5, "Connection attempt from "+ client.getInetAddress().getHostAddress() +" rejected.");
+		else
+		{
+			telnetOutput(5, "Connection attempt from " + client.getInetAddress().getHostAddress() + " rejected.");
 			_cSocket.close();
 		}
 	}
@@ -158,7 +175,7 @@ public class LoginStatusThread extends Thread
 			while (_usrCommand.compareTo("quit") != 0 && _usrCommand.compareTo("exit") != 0)
 			{
 				_usrCommand = _read.readLine();
-				if(_usrCommand == null)
+				if (_usrCommand == null)
 				{
 					_cSocket.close();
 					break;
@@ -178,7 +195,7 @@ public class LoginStatusThread extends Thread
 				else if (_usrCommand.equals("status"))
 				{
 					//TODO enhance the output
-					_print.println("Registered Server Count: "+GameServerTable.getInstance().getRegisteredGameServers().size());
+					_print.println("Registered Server Count: " + GameServerTable.getInstance().getRegisteredGameServers().size());
 				}
 				else if (_usrCommand.startsWith("unblock"))
 				{
@@ -214,9 +231,16 @@ public class LoginStatusThread extends Thread
 					_print.flush();
 					_cSocket.close();
 				}
-				else if (_usrCommand.equals("RedirectLogger")) {_redirectLogger = true;}
-				else if (_usrCommand.equals("quit")) { /* Do Nothing :p - Just here to save us from the "Command Not Understood" Text */ }
-				else if (_usrCommand.length() == 0) { /* Do Nothing Again - Same reason as the quit part */ }
+				else if (_usrCommand.equals("RedirectLogger"))
+				{
+					_redirectLogger = true;
+				}
+				else if (_usrCommand.equals("quit"))
+				{ /* Do Nothing :p - Just here to save us from the "Command Not Understood" Text */
+				}
+				else if (_usrCommand.length() == 0)
+				{ /* Do Nothing Again - Same reason as the quit part */
+				}
 				else
 				{
 					_print.println("Invalid Command");
@@ -224,13 +248,13 @@ public class LoginStatusThread extends Thread
 				_print.print("");
 				_print.flush();
 			}
-			if(!_cSocket.isClosed())
+			if (!_cSocket.isClosed())
 			{
 				_print.println("Bye Bye!");
 				_print.flush();
 				_cSocket.close();
 			}
-			telnetOutput(1, "Connection from "+_cSocket.getInetAddress().getHostAddress()+" was closed by client.");
+			telnetOutput(1, "Connection from " + _cSocket.getInetAddress().getHostAddress() + " was closed by client.");
 		}
 		catch (IOException e)
 		{
@@ -238,10 +262,9 @@ public class LoginStatusThread extends Thread
 		}
 	}
 	
-	
 	public void printToTelnet(String msg)
 	{
-		synchronized(_print)
+		synchronized (_print)
 		{
 			_print.println(msg);
 			_print.flush();

+ 4 - 3
L2J_Server_BETA/java/config/Character.properties

@@ -46,10 +46,11 @@ RunSpeedBoost = 0
 DeathPenaltyChance = 20
 
 # Percent of HP, MP, and CP which is restored on character revival.
-# Default: 0, 70, 70
+# Use 0 to disable restore
+# Default: 0, 65, 0
 RespawnRestoreCP = 0
-RespawnRestoreHP = 70
-RespawnRestoreMP = 70
+RespawnRestoreHP = 65
+RespawnRestoreMP = 0
 
 # Percent of HP, MP, and CP regeneration for players.
 # Example: Setting HP to 10 will cause player HP to regenerate 90% slower than normal.