Browse Source

BETA: Minor cleanup.

Rumen Nikiforov 12 years ago
parent
commit
2b8619d811
21 changed files with 1662 additions and 676 deletions
  1. 5 3
      L2J_Server_BETA/java/com/l2jserver/gameserver/model/actor/instance/L2PcInstance.java
  2. 2 4
      L2J_Server_BETA/java/com/l2jserver/gameserver/model/entity/ActionKey.java
  3. 43 27
      L2J_Server_BETA/java/com/l2jserver/gameserver/model/entity/Auction.java
  4. 185 129
      L2J_Server_BETA/java/com/l2jserver/gameserver/model/entity/BlockCheckerEngine.java
  5. 124 26
      L2J_Server_BETA/java/com/l2jserver/gameserver/model/entity/Castle.java
  6. 82 27
      L2J_Server_BETA/java/com/l2jserver/gameserver/model/entity/ClanHall.java
  7. 3 6
      L2J_Server_BETA/java/com/l2jserver/gameserver/model/entity/Couple.java
  8. 78 20
      L2J_Server_BETA/java/com/l2jserver/gameserver/model/entity/DimensionalRift.java
  9. 126 38
      L2J_Server_BETA/java/com/l2jserver/gameserver/model/entity/Duel.java
  10. 166 58
      L2J_Server_BETA/java/com/l2jserver/gameserver/model/entity/Fort.java
  11. 168 48
      L2J_Server_BETA/java/com/l2jserver/gameserver/model/entity/FortSiege.java
  12. 16 12
      L2J_Server_BETA/java/com/l2jserver/gameserver/model/entity/Hero.java
  13. 116 97
      L2J_Server_BETA/java/com/l2jserver/gameserver/model/entity/L2Event.java
  14. 28 9
      L2J_Server_BETA/java/com/l2jserver/gameserver/model/entity/Message.java
  15. 119 13
      L2J_Server_BETA/java/com/l2jserver/gameserver/model/entity/RecoBonus.java
  16. 2 1
      L2J_Server_BETA/java/com/l2jserver/gameserver/model/entity/Siegable.java
  17. 207 22
      L2J_Server_BETA/java/com/l2jserver/gameserver/model/entity/Siege.java
  18. 144 95
      L2J_Server_BETA/java/com/l2jserver/gameserver/model/entity/TvTEvent.java
  19. 15 15
      L2J_Server_BETA/java/com/l2jserver/gameserver/model/entity/TvTEventTeam.java
  20. 16 5
      L2J_Server_BETA/java/com/l2jserver/gameserver/model/entity/TvTEventTeleporter.java
  21. 17 21
      L2J_Server_BETA/java/com/l2jserver/gameserver/model/entity/TvTManager.java

+ 5 - 3
L2J_Server_BETA/java/com/l2jserver/gameserver/model/actor/instance/L2PcInstance.java

@@ -1787,19 +1787,21 @@ public final class L2PcInstance extends L2Playable
 		QuestState qs = getQuestState(quest);
 		QuestState qs = getQuestState(quest);
 		if (qs == null && event.length() == 0)
 		if (qs == null && event.length() == 0)
 			return retval;
 			return retval;
-		if (qs == null) {
+		if (qs == null)
+		{
 			Quest q = QuestManager.getInstance().getQuest(quest);
 			Quest q = QuestManager.getInstance().getQuest(quest);
 			if (q == null)
 			if (q == null)
 				return retval;
 				return retval;
 			qs = q.newQuestState(this);
 			qs = q.newQuestState(this);
 		}
 		}
-		if (qs != null) {
+		if (qs != null)
+		{
 			if (getLastQuestNpcObject() > 0)
 			if (getLastQuestNpcObject() > 0)
 			{
 			{
 				L2Object object = L2World.getInstance().findObject(getLastQuestNpcObject());
 				L2Object object = L2World.getInstance().findObject(getLastQuestNpcObject());
 				if (object instanceof L2Npc && isInsideRadius(object, L2Npc.INTERACTION_DISTANCE, false, false))
 				if (object instanceof L2Npc && isInsideRadius(object, L2Npc.INTERACTION_DISTANCE, false, false))
 				{
 				{
-					L2Npc npc = (L2Npc)object;
+					L2Npc npc = (L2Npc) object;
 					QuestState[] states = getQuestsForTalk(npc.getNpcId());
 					QuestState[] states = getQuestsForTalk(npc.getNpcId());
 					
 					
 					if (states != null)
 					if (states != null)

+ 2 - 4
L2J_Server_BETA/java/com/l2jserver/gameserver/model/entity/ActionKey.java

@@ -15,8 +15,7 @@
 package com.l2jserver.gameserver.model.entity;
 package com.l2jserver.gameserver.model.entity;
 
 
 /**
 /**
- *
- * @author  mrTJO
+ * @author mrTJO
  */
  */
 public class ActionKey
 public class ActionKey
 {
 {
@@ -78,7 +77,6 @@ public class ActionKey
 	
 	
 	public String getSqlSaveString(int playerId, int order)
 	public String getSqlSaveString(int playerId, int order)
 	{
 	{
-		return "("+playerId+", "+_cat+", "+order+", "+_cmd+","
-		+_key+", "+_tgKey1+", "+_tgKey2+", "+_show+")";
+		return "(" + playerId + ", " + _cat + ", " + order + ", " + _cmd + "," + _key + ", " + _tgKey1 + ", " + _tgKey2 + ", " + _show + ")";
 	}
 	}
 }
 }

+ 43 - 27
L2J_Server_BETA/java/com/l2jserver/gameserver/model/entity/Auction.java

@@ -38,7 +38,6 @@ import com.l2jserver.gameserver.model.L2World;
 import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
 import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
 import com.l2jserver.gameserver.network.SystemMessageId;
 import com.l2jserver.gameserver.network.SystemMessageId;
 
 
-
 public class Auction
 public class Auction
 {
 {
 	protected static final Logger _log = Logger.getLogger(Auction.class.getName());
 	protected static final Logger _log = Logger.getLogger(Auction.class.getName());
@@ -50,7 +49,7 @@ public class Auction
 	private int _itemId = 0;
 	private int _itemId = 0;
 	private String _itemName = "";
 	private String _itemName = "";
 	private int _itemObjectId = 0;
 	private int _itemObjectId = 0;
-	private long _itemQuantity = 0;
+	private final long _itemQuantity = 0;
 	private String _itemType = "";
 	private String _itemType = "";
 	private int _sellerId = 0;
 	private int _sellerId = 0;
 	private String _sellerClanName = "";
 	private String _sellerClanName = "";
@@ -58,7 +57,7 @@ public class Auction
 	private long _currentBid = 0;
 	private long _currentBid = 0;
 	private long _startingBid = 0;
 	private long _startingBid = 0;
 	
 	
-	private Map<Integer, Bidder> _bidders = new FastMap<>();
+	private final Map<Integer, Bidder> _bidders = new FastMap<>();
 	
 	
 	private static final String[] ItemTypeName =
 	private static final String[] ItemTypeName =
 	{
 	{
@@ -72,10 +71,10 @@ public class Auction
 	
 	
 	public static class Bidder
 	public static class Bidder
 	{
 	{
-		private String _name;  //TODO replace with objid
-		private String _clanName;
+		private final String _name; // TODO replace with objid
+		private final String _clanName;
 		private long _bid;
 		private long _bid;
-		private Calendar _timeBid;
+		private final Calendar _timeBid;
 		
 		
 		public Bidder(String name, String clanName, long bid, long timeBid)
 		public Bidder(String name, String clanName, long bid, long timeBid)
 		{
 		{
@@ -139,7 +138,7 @@ public class Auction
 	}
 	}
 	
 	
 	/**
 	/**
-	 * Constructor 
+	 * Constructor
 	 * @param auctionId
 	 * @param auctionId
 	 */
 	 */
 	public Auction(int auctionId)
 	public Auction(int auctionId)
@@ -231,11 +230,13 @@ public class Auction
 		long taskDelay = 0;
 		long taskDelay = 0;
 		if (_endDate <= currentTime)
 		if (_endDate <= currentTime)
 		{
 		{
-			_endDate = currentTime + 7 * 24 * 60 * 60 * 1000;
+			_endDate = currentTime + (7 * 24 * 60 * 60 * 1000);
 			saveAuctionDate();
 			saveAuctionDate();
 		}
 		}
 		else
 		else
+		{
 			taskDelay = _endDate - currentTime;
 			taskDelay = _endDate - currentTime;
+		}
 		ThreadPoolManager.getInstance().scheduleGeneral(new AutoEndTask(), taskDelay);
 		ThreadPoolManager.getInstance().scheduleGeneral(new AutoEndTask(), taskDelay);
 	}
 	}
 	
 	
@@ -261,16 +262,18 @@ public class Auction
 	}
 	}
 	
 	
 	/**
 	/**
-	 * Set a bid 
-	 * @param bidder 
+	 * Set a bid
+	 * @param bidder
 	 * @param bid
 	 * @param bid
 	 */
 	 */
 	public synchronized void setBid(L2PcInstance bidder, long bid)
 	public synchronized void setBid(L2PcInstance bidder, long bid)
 	{
 	{
 		long requiredAdena = bid;
 		long requiredAdena = bid;
 		if (getHighestBidderName().equals(bidder.getClan().getLeaderName()))
 		if (getHighestBidderName().equals(bidder.getClan().getLeaderName()))
+		{
 			requiredAdena = bid - getHighestBidderMaxBid();
 			requiredAdena = bid - getHighestBidderMaxBid();
-		if ((getHighestBidderId() > 0 && bid > getHighestBidderMaxBid()) || (getHighestBidderId() == 0 && bid >= getStartingBid()))
+		}
+		if (((getHighestBidderId() > 0) && (bid > getHighestBidderMaxBid())) || ((getHighestBidderId() == 0) && (bid >= getStartingBid())))
 		{
 		{
 			if (takeItem(bidder, requiredAdena))
 			if (takeItem(bidder, requiredAdena))
 			{
 			{
@@ -280,19 +283,23 @@ public class Auction
 			}
 			}
 		}
 		}
 		if ((bid < getStartingBid()) || (bid <= getHighestBidderMaxBid()))
 		if ((bid < getStartingBid()) || (bid <= getHighestBidderMaxBid()))
+		{
 			bidder.sendPacket(SystemMessageId.BID_PRICE_MUST_BE_HIGHER);
 			bidder.sendPacket(SystemMessageId.BID_PRICE_MUST_BE_HIGHER);
+		}
 	}
 	}
 	
 	
 	/**
 	/**
-	 * Return Item in WHC 
-	 * @param Clan 
-	 * @param quantity 
+	 * Return Item in WHC
+	 * @param Clan
+	 * @param quantity
 	 * @param penalty
 	 * @param penalty
 	 */
 	 */
 	private void returnItem(String Clan, long quantity, boolean penalty)
 	private void returnItem(String Clan, long quantity, boolean penalty)
 	{
 	{
 		if (penalty)
 		if (penalty)
-			quantity *= 0.9; //take 10% tax fee if needed
+		{
+			quantity *= 0.9; // take 10% tax fee if needed
+		}
 		
 		
 		// avoid overflow on return
 		// avoid overflow on return
 		final long limit = MAX_ADENA - ClanTable.getInstance().getClanByName(Clan).getWarehouse().getAdena();
 		final long limit = MAX_ADENA - ClanTable.getInstance().getClanByName(Clan).getWarehouse().getAdena();
@@ -302,14 +309,14 @@ public class Auction
 	}
 	}
 	
 	
 	/**
 	/**
-	 * Take Item in WHC 
-	 * @param bidder 
-	 * @param quantity 
+	 * Take Item in WHC
+	 * @param bidder
+	 * @param quantity
 	 * @return
 	 * @return
 	 */
 	 */
 	private boolean takeItem(L2PcInstance bidder, long quantity)
 	private boolean takeItem(L2PcInstance bidder, long quantity)
 	{
 	{
-		if (bidder.getClan() != null && bidder.getClan().getWarehouse().getAdena() >= quantity)
+		if ((bidder.getClan() != null) && (bidder.getClan().getWarehouse().getAdena() >= quantity))
 		{
 		{
 			bidder.getClan().getWarehouse().destroyItemByItemId("Buy", ADENA_ID, quantity, bidder, bidder);
 			bidder.getClan().getWarehouse().destroyItemByItemId("Buy", ADENA_ID, quantity, bidder, bidder);
 			return true;
 			return true;
@@ -319,8 +326,8 @@ public class Auction
 	}
 	}
 	
 	
 	/**
 	/**
-	 * Update auction in DB 
-	 * @param bidder 
+	 * Update auction in DB
+	 * @param bidder
 	 * @param bid
 	 * @param bid
 	 */
 	 */
 	private void updateInDB(L2PcInstance bidder, long bid)
 	private void updateInDB(L2PcInstance bidder, long bid)
@@ -354,14 +361,18 @@ public class Auction
 					statement.execute();
 					statement.execute();
 				}
 				}
 				if (L2World.getInstance().getPlayer(_highestBidderName) != null)
 				if (L2World.getInstance().getPlayer(_highestBidderName) != null)
+				{
 					L2World.getInstance().getPlayer(_highestBidderName).sendMessage("You have been out bidded");
 					L2World.getInstance().getPlayer(_highestBidderName).sendMessage("You have been out bidded");
+				}
 			}
 			}
 			
 			
 			_highestBidderId = bidder.getClanId();
 			_highestBidderId = bidder.getClanId();
 			_highestBidderMaxBid = bid;
 			_highestBidderMaxBid = bid;
 			_highestBidderName = bidder.getClan().getLeaderName();
 			_highestBidderName = bidder.getClan().getLeaderName();
 			if (_bidders.get(_highestBidderId) == null)
 			if (_bidders.get(_highestBidderId) == null)
+			{
 				_bidders.put(_highestBidderId, new Bidder(_highestBidderName, bidder.getClan().getName(), bid, Calendar.getInstance().getTimeInMillis()));
 				_bidders.put(_highestBidderId, new Bidder(_highestBidderName, bidder.getClan().getName(), bid, Calendar.getInstance().getTimeInMillis()));
+			}
 			else
 			else
 			{
 			{
 				_bidders.get(_highestBidderId).setBid(bid);
 				_bidders.get(_highestBidderId).setBid(bid);
@@ -392,11 +403,15 @@ public class Auction
 		for (Bidder b : _bidders.values())
 		for (Bidder b : _bidders.values())
 		{
 		{
 			if (ClanTable.getInstance().getClanByName(b.getClanName()).getHideoutId() == 0)
 			if (ClanTable.getInstance().getClanByName(b.getClanName()).getHideoutId() == 0)
+			{
 				returnItem(b.getClanName(), b.getBid(), true); // 10 % tax
 				returnItem(b.getClanName(), b.getBid(), true); // 10 % tax
+			}
 			else
 			else
 			{
 			{
 				if (L2World.getInstance().getPlayer(b.getName()) != null)
 				if (L2World.getInstance().getPlayer(b.getName()) != null)
+				{
 					L2World.getInstance().getPlayer(b.getName()).sendMessage("Congratulation you have won ClanHall!");
 					L2World.getInstance().getPlayer(b.getName()).sendMessage("Congratulation you have won ClanHall!");
+				}
 			}
 			}
 			ClanTable.getInstance().getClanByName(b.getClanName()).setAuctionBiddedAt(0, true);
 			ClanTable.getInstance().getClanByName(b.getClanName()).setAuctionBiddedAt(0, true);
 		}
 		}
@@ -424,15 +439,16 @@ public class Auction
 	{
 	{
 		if (ClanHallManager.getInstance().loaded())
 		if (ClanHallManager.getInstance().loaded())
 		{
 		{
-			if (_highestBidderId == 0 && _sellerId == 0)
+			if ((_highestBidderId == 0) && (_sellerId == 0))
 			{
 			{
 				startAutoTask();
 				startAutoTask();
 				return;
 				return;
 			}
 			}
-			if (_highestBidderId == 0 && _sellerId > 0)
+			if ((_highestBidderId == 0) && (_sellerId > 0))
 			{
 			{
-				/** If seller haven't sell ClanHall, auction removed,
-				 *  THIS MUST BE CONFIRMED */
+				/**
+				 * If seller haven't sell ClanHall, auction removed, THIS MUST BE CONFIRMED
+				 */
 				int aucId = AuctionManager.getInstance().getAuctionIndex(_id);
 				int aucId = AuctionManager.getInstance().getAuctionIndex(_id);
 				AuctionManager.getInstance().getAuctions().remove(aucId);
 				AuctionManager.getInstance().getAuctions().remove(aucId);
 				return;
 				return;
@@ -457,7 +473,7 @@ public class Auction
 	}
 	}
 	
 	
 	/**
 	/**
-	 * Cancel bid 
+	 * Cancel bid
 	 * @param bidder
 	 * @param bidder
 	 */
 	 */
 	public synchronized void cancelBid(int bidder)
 	public synchronized void cancelBid(int bidder)
@@ -516,7 +532,7 @@ public class Auction
 	}
 	}
 	
 	
 	/**
 	/**
-	 * Get var auction 
+	 * Get var auction
 	 * @return
 	 * @return
 	 */
 	 */
 	public final int getId()
 	public final int getId()

+ 185 - 129
L2J_Server_BETA/java/com/l2jserver/gameserver/model/entity/BlockCheckerEngine.java

@@ -76,13 +76,41 @@ public final class BlockCheckerEngine
 	protected static final int[][] _arenaCoordinates =
 	protected static final int[][] _arenaCoordinates =
 	{
 	{
 		// Arena 0 - Team 1 XY, Team 2 XY - CENTER XY
 		// Arena 0 - Team 1 XY, Team 2 XY - CENTER XY
-		{ -58368, -62745, -57751, -62131, -58053, -62417 },
+		{
+			-58368,
+			-62745,
+			-57751,
+			-62131,
+			-58053,
+			-62417
+		},
 		// Arena 1 - Team 1 XY, Team 2 XY - CENTER XY
 		// Arena 1 - Team 1 XY, Team 2 XY - CENTER XY
-		{ -58350, -63853, -57756, -63266, -58053, -63551 },
+		{
+			-58350,
+			-63853,
+			-57756,
+			-63266,
+			-58053,
+			-63551
+		},
 		// Arena 2 - Team 1 XY, Team 2 XY - CENTER XY
 		// Arena 2 - Team 1 XY, Team 2 XY - CENTER XY
-		{ -57194, -63861, -56580, -63249, -56886, -63551 },
+		{
+			-57194,
+			-63861,
+			-56580,
+			-63249,
+			-56886,
+			-63551
+		},
 		// Arena 3 - Team 1 XY, Team 2 XY - CENTER XY
 		// Arena 3 - Team 1 XY, Team 2 XY - CENTER XY
-		{ -57200, -62727, -56584, -62115, -56850, -62391 }	
+		{
+			-57200,
+			-62727,
+			-56584,
+			-62115,
+			-56850,
+			-62391
+		}
 	};
 	};
 	// Common z coordinate
 	// Common z coordinate
 	private static final int _zCoord = -2405;
 	private static final int _zCoord = -2405;
@@ -100,18 +128,23 @@ public final class BlockCheckerEngine
 	public BlockCheckerEngine(HandysBlockCheckerManager.ArenaParticipantsHolder holder, int arena)
 	public BlockCheckerEngine(HandysBlockCheckerManager.ArenaParticipantsHolder holder, int arena)
 	{
 	{
 		_holder = holder;
 		_holder = holder;
-		if(arena > -1 && arena < 4)
+		if ((arena > -1) && (arena < 4))
+		{
 			_arena = arena;
 			_arena = arena;
+		}
 		
 		
-		for(L2PcInstance player : holder.getRedPlayers())
+		for (L2PcInstance player : holder.getRedPlayers())
+		{
 			_redTeamPoints.put(player, 0);
 			_redTeamPoints.put(player, 0);
-		for(L2PcInstance player : holder.getBluePlayers())
+		}
+		for (L2PcInstance player : holder.getBluePlayers())
+		{
 			_blueTeamPoints.put(player, 0);
 			_blueTeamPoints.put(player, 0);
+		}
 	}
 	}
 	
 	
 	/**
 	/**
-	 * Updates the player holder before the event starts
-	 * to synchronize all info
+	 * Updates the player holder before the event starts to synchronize all info
 	 * @param holder
 	 * @param holder
 	 */
 	 */
 	public void updatePlayersOnStart(ArenaParticipantsHolder holder)
 	public void updatePlayersOnStart(ArenaParticipantsHolder holder)
@@ -120,8 +153,7 @@ public final class BlockCheckerEngine
 	}
 	}
 	
 	
 	/**
 	/**
-	 * Returns the current holder object of this
-	 * object engine
+	 * Returns the current holder object of this object engine
 	 * @return HandysBlockCheckerManager.ArenaParticipantsHolder
 	 * @return HandysBlockCheckerManager.ArenaParticipantsHolder
 	 */
 	 */
 	public ArenaParticipantsHolder getHolder()
 	public ArenaParticipantsHolder getHolder()
@@ -130,8 +162,7 @@ public final class BlockCheckerEngine
 	}
 	}
 	
 	
 	/**
 	/**
-	 * Will return the id of the arena used
-	 * by this event
+	 * Will return the id of the arena used by this event
 	 * @return false;
 	 * @return false;
 	 */
 	 */
 	public int getArena()
 	public int getArena()
@@ -140,8 +171,7 @@ public final class BlockCheckerEngine
 	}
 	}
 	
 	
 	/**
 	/**
-	 * Returns the time when the event
-	 * started
+	 * Returns the time when the event started
 	 * @return long
 	 * @return long
 	 */
 	 */
 	public long getStarterTime()
 	public long getStarterTime()
@@ -155,7 +185,7 @@ public final class BlockCheckerEngine
 	 */
 	 */
 	public int getRedPoints()
 	public int getRedPoints()
 	{
 	{
-		synchronized(this)
+		synchronized (this)
 		{
 		{
 			return _redPoints;
 			return _redPoints;
 		}
 		}
@@ -167,7 +197,7 @@ public final class BlockCheckerEngine
 	 */
 	 */
 	public int getBluePoints()
 	public int getBluePoints()
 	{
 	{
-		synchronized(this)
+		synchronized (this)
 		{
 		{
 			return _bluePoints;
 			return _bluePoints;
 		}
 		}
@@ -181,10 +211,12 @@ public final class BlockCheckerEngine
 	 */
 	 */
 	public int getPlayerPoints(L2PcInstance player, boolean isRed)
 	public int getPlayerPoints(L2PcInstance player, boolean isRed)
 	{
 	{
-		if(!_redTeamPoints.containsKey(player) && !_blueTeamPoints.containsKey(player))
+		if (!_redTeamPoints.containsKey(player) && !_blueTeamPoints.containsKey(player))
+		{
 			return 0;
 			return 0;
+		}
 		
 		
-		if(isRed)
+		if (isRed)
 		{
 		{
 			return _redTeamPoints.get(player);
 			return _redTeamPoints.get(player);
 		}
 		}
@@ -198,10 +230,12 @@ public final class BlockCheckerEngine
 	 */
 	 */
 	public synchronized void increasePlayerPoints(L2PcInstance player, int team)
 	public synchronized void increasePlayerPoints(L2PcInstance player, int team)
 	{
 	{
-		if(player == null)
+		if (player == null)
+		{
 			return;
 			return;
+		}
 		
 		
-		if(team == 0)
+		if (team == 0)
 		{
 		{
 			int points = _redTeamPoints.get(player) + 1;
 			int points = _redTeamPoints.get(player) + 1;
 			_redTeamPoints.put(player, points);
 			_redTeamPoints.put(player, points);
@@ -218,19 +252,19 @@ public final class BlockCheckerEngine
 	}
 	}
 	
 	
 	/**
 	/**
-	 * Will add a new drop into the list of
-	 * dropped items
+	 * Will add a new drop into the list of dropped items
 	 * @param item
 	 * @param item
 	 */
 	 */
 	public void addNewDrop(L2ItemInstance item)
 	public void addNewDrop(L2ItemInstance item)
 	{
 	{
-		if(item != null)
+		if (item != null)
+		{
 			_drops.add(item);
 			_drops.add(item);
+		}
 	}
 	}
 	
 	
 	/**
 	/**
-	 * Will return true if the event is already
-	 * started
+	 * Will return true if the event is already started
 	 * @return boolean
 	 * @return boolean
 	 */
 	 */
 	public boolean isStarted()
 	public boolean isStarted()
@@ -239,55 +273,56 @@ public final class BlockCheckerEngine
 	}
 	}
 	
 	
 	/**
 	/**
-	 * Will send all packets for the event members with 
-	 * the relation info
-	 * @param plr 
+	 * Will send all packets for the event members with the relation info
+	 * @param plr
 	 */
 	 */
 	protected void broadcastRelationChanged(L2PcInstance plr)
 	protected void broadcastRelationChanged(L2PcInstance plr)
 	{
 	{
-		for(L2PcInstance p : _holder.getAllPlayers())
+		for (L2PcInstance p : _holder.getAllPlayers())
 		{
 		{
 			p.sendPacket(new RelationChanged(plr, plr.getRelation(p), plr.isAutoAttackable(p)));
 			p.sendPacket(new RelationChanged(plr, plr.getRelation(p), plr.isAutoAttackable(p)));
 		}
 		}
 	}
 	}
 	
 	
 	/**
 	/**
-	 * Called when a there is an empty team. The event
-	 * will end.
+	 * Called when a there is an empty team. The event will end.
 	 */
 	 */
 	public void endEventAbnormally()
 	public void endEventAbnormally()
 	{
 	{
 		try
 		try
 		{
 		{
-			synchronized(this)
+			synchronized (this)
 			{
 			{
 				_isStarted = false;
 				_isStarted = false;
 				
 				
-				if(_task != null)
+				if (_task != null)
+				{
 					_task.cancel(true);
 					_task.cancel(true);
+				}
 				
 				
 				_abnormalEnd = true;
 				_abnormalEnd = true;
 				
 				
 				ThreadPoolManager.getInstance().executeTask(new EndEvent());
 				ThreadPoolManager.getInstance().executeTask(new EndEvent());
 				
 				
-				if(Config.DEBUG)
-					_log.config("Handys Block Checker Event at arena "+_arena+" ended due lack of players!");
+				if (Config.DEBUG)
+				{
+					_log.config("Handys Block Checker Event at arena " + _arena + " ended due lack of players!");
+				}
 			}
 			}
 		}
 		}
-		catch(Exception e)
+		catch (Exception e)
 		{
 		{
-			_log.log(Level.SEVERE, "Couldnt end Block Checker event at "+_arena, e);
+			_log.log(Level.SEVERE, "Couldnt end Block Checker event at " + _arena, e);
 		}
 		}
 	}
 	}
 	
 	
 	/**
 	/**
-	 * This inner class set ups all player
-	 * and arena parameters to start the event
+	 * This inner class set ups all player and arena parameters to start the event
 	 */
 	 */
 	public class StartEvent implements Runnable
 	public class StartEvent implements Runnable
-	{		
+	{
 		// In event used skills
 		// In event used skills
-		private L2Skill _freeze, _transformationRed, _transformationBlue;
+		private final L2Skill _freeze, _transformationRed, _transformationBlue;
 		// Common and unparametizer packet
 		// Common and unparametizer packet
 		private final ExCubeGameCloseUI _closeUserInterface = new ExCubeGameCloseUI();
 		private final ExCubeGameCloseUI _closeUserInterface = new ExCubeGameCloseUI();
 		
 		
@@ -298,11 +333,9 @@ public final class BlockCheckerEngine
 			_transformationRed = SkillTable.getInstance().getInfo(6035, 1);
 			_transformationRed = SkillTable.getInstance().getInfo(6035, 1);
 			_transformationBlue = SkillTable.getInstance().getInfo(6036, 1);
 			_transformationBlue = SkillTable.getInstance().getInfo(6036, 1);
 		}
 		}
-				
+		
 		/**
 		/**
-		 * Will set up all player parameters and 
-		 * port them to their respective location 
-		 * based on their teams
+		 * Will set up all player parameters and port them to their respective location based on their teams
 		 */
 		 */
 		private void setUpPlayers()
 		private void setUpPlayers()
 		{
 		{
@@ -312,13 +345,16 @@ public final class BlockCheckerEngine
 			// Initialize packets avoiding create a new one per player
 			// Initialize packets avoiding create a new one per player
 			_redPoints = _spawns.size() / 2;
 			_redPoints = _spawns.size() / 2;
 			_bluePoints = _spawns.size() / 2;
 			_bluePoints = _spawns.size() / 2;
-			final ExCubeGameChangePoints initialPoints = new ExCubeGameChangePoints(300,_bluePoints,_redPoints);
+			final ExCubeGameChangePoints initialPoints = new ExCubeGameChangePoints(300, _bluePoints, _redPoints);
 			ExCubeGameExtendedChangePoints clientSetUp;
 			ExCubeGameExtendedChangePoints clientSetUp;
 			
 			
-			for(L2PcInstance player : _holder.getAllPlayers())
+			for (L2PcInstance player : _holder.getAllPlayers())
 			{
 			{
-				if(player == null) continue;
-							
+				if (player == null)
+				{
+					continue;
+				}
+				
 				// Send the secret client packet set up
 				// Send the secret client packet set up
 				boolean isRed = _holder.getRedPlayers().contains(player);
 				boolean isRed = _holder.getRedPlayers().contains(player);
 				
 				
@@ -336,29 +372,35 @@ public final class BlockCheckerEngine
 				int y = _arenaCoordinates[_arena][tc + 1];
 				int y = _arenaCoordinates[_arena][tc + 1];
 				player.teleToLocation(x, y, _zCoord);
 				player.teleToLocation(x, y, _zCoord);
 				// Set the player team
 				// Set the player team
-				if(isRed)
+				if (isRed)
 				{
 				{
-					_redTeamPoints.put(player,0);
+					_redTeamPoints.put(player, 0);
 					player.setTeam(2);
 					player.setTeam(2);
 				}
 				}
 				else
 				else
 				{
 				{
-					_blueTeamPoints.put(player,0);
+					_blueTeamPoints.put(player, 0);
 					player.setTeam(1);
 					player.setTeam(1);
 				}
 				}
 				player.stopAllEffects();
 				player.stopAllEffects();
 				
 				
-				if(player.getPet() != null)
+				if (player.getPet() != null)
+				{
 					player.getPet().unSummon(player);
 					player.getPet().unSummon(player);
+				}
 				
 				
 				// Give the player start up effects
 				// Give the player start up effects
 				// Freeze
 				// Freeze
 				_freeze.getEffects(player, player);
 				_freeze.getEffects(player, player);
 				// Transformation
 				// Transformation
-				if(_holder.getPlayerTeam(player) == 0)
+				if (_holder.getPlayerTeam(player) == 0)
+				{
 					_transformationRed.getEffects(player, player);
 					_transformationRed.getEffects(player, player);
+				}
 				else
 				else
+				{
 					_transformationBlue.getEffects(player, player);
 					_transformationBlue.getEffects(player, player);
+				}
 				// Set the current player arena
 				// Set the current player arena
 				player.setBlockCheckerArena((byte) _arena);
 				player.setBlockCheckerArena((byte) _arena);
 				player.setInsideZone(L2Character.ZONE_PVP, true);
 				player.setInsideZone(L2Character.ZONE_PVP, true);
@@ -367,16 +409,16 @@ public final class BlockCheckerEngine
 				player.sendPacket(_closeUserInterface);
 				player.sendPacket(_closeUserInterface);
 				// ExBasicActionList
 				// ExBasicActionList
 				final ExBasicActionList actionList = ExBasicActionList.getStaticPacket(player);
 				final ExBasicActionList actionList = ExBasicActionList.getStaticPacket(player);
-				player.sendPacket(actionList);	
+				player.sendPacket(actionList);
 				broadcastRelationChanged(player);
 				broadcastRelationChanged(player);
 			}
 			}
 		}
 		}
-				
+		
 		@Override
 		@Override
 		public void run()
 		public void run()
 		{
 		{
 			// Wrong arena passed, stop event
 			// Wrong arena passed, stop event
-			if(_arena == -1)
+			if (_arena == -1)
 			{
 			{
 				_log.severe("Couldnt set up the arena Id for the Block Checker event, cancelling event...");
 				_log.severe("Couldnt set up the arena Id for the Block Checker event, cancelling event...");
 				return;
 				return;
@@ -392,8 +434,7 @@ public final class BlockCheckerEngine
 	}
 	}
 	
 	
 	/**
 	/**
-	 * This class spawns the second round of boxes
-	 * and schedules the event end
+	 * This class spawns the second round of boxes and schedules the event end
 	 */
 	 */
 	private class SpawnRound implements Runnable
 	private class SpawnRound implements Runnable
 	{
 	{
@@ -409,9 +450,12 @@ public final class BlockCheckerEngine
 		@Override
 		@Override
 		public void run()
 		public void run()
 		{
 		{
-			if(!_isStarted) return;
+			if (!_isStarted)
+			{
+				return;
+			}
 			
 			
-			switch(_round)
+			switch (_round)
 			{
 			{
 				case 1:
 				case 1:
 					// Schedule second spawn round
 					// Schedule second spawn round
@@ -435,41 +479,47 @@ public final class BlockCheckerEngine
 			try
 			try
 			{
 			{
 				// Creates 50 new blocks
 				// Creates 50 new blocks
-				for(int i = 0; i < _numOfBoxes; i++)
+				for (int i = 0; i < _numOfBoxes; i++)
 				{
 				{
 					L2Spawn spawn = new L2Spawn(template);
 					L2Spawn spawn = new L2Spawn(template);
-					spawn.setLocx(_arenaCoordinates[_arena][4] + Rnd.get(-400,400));
-					spawn.setLocy(_arenaCoordinates[_arena][5] + Rnd.get(-400,400));
+					spawn.setLocx(_arenaCoordinates[_arena][4] + Rnd.get(-400, 400));
+					spawn.setLocy(_arenaCoordinates[_arena][5] + Rnd.get(-400, 400));
 					spawn.setLocz(_zCoord);
 					spawn.setLocz(_zCoord);
 					spawn.setAmount(1);
 					spawn.setAmount(1);
 					spawn.setHeading(1);
 					spawn.setHeading(1);
 					spawn.setRespawnDelay(1);
 					spawn.setRespawnDelay(1);
 					SpawnTable.getInstance().addNewSpawn(spawn, false);
 					SpawnTable.getInstance().addNewSpawn(spawn, false);
 					spawn.init();
 					spawn.init();
-					L2BlockInstance block = (L2BlockInstance)spawn.getLastSpawn();
+					L2BlockInstance block = (L2BlockInstance) spawn.getLastSpawn();
 					// switch color
 					// switch color
-					if(random % 2 == 0) block.setRed(true);
-					else block.setRed(false);
+					if ((random % 2) == 0)
+					{
+						block.setRed(true);
+					}
+					else
+					{
+						block.setRed(false);
+					}
 					
 					
 					block.disableCoreAI(true);
 					block.disableCoreAI(true);
 					_spawns.add(spawn);
 					_spawns.add(spawn);
 					random++;
 					random++;
 				}
 				}
 			}
 			}
-			catch(Exception e)
+			catch (Exception e)
 			{
 			{
 				_log.warning(getClass().getSimpleName() + ": " + e.getMessage());
 				_log.warning(getClass().getSimpleName() + ": " + e.getMessage());
 			}
 			}
 			
 			
 			// Spawn the block carrying girl
 			// Spawn the block carrying girl
-			if(_round == 1 || _round == 2)
+			if ((_round == 1) || (_round == 2))
 			{
 			{
 				L2NpcTemplate girl = NpcTable.getInstance().getTemplate(18676);
 				L2NpcTemplate girl = NpcTable.getInstance().getTemplate(18676);
 				try
 				try
 				{
 				{
 					final L2Spawn girlSpawn = new L2Spawn(girl);
 					final L2Spawn girlSpawn = new L2Spawn(girl);
-					girlSpawn.setLocx(_arenaCoordinates[_arena][4] + Rnd.get(-400,400));
-					girlSpawn.setLocy(_arenaCoordinates[_arena][5] + Rnd.get(-400,400));
+					girlSpawn.setLocx(_arenaCoordinates[_arena][4] + Rnd.get(-400, 400));
+					girlSpawn.setLocy(_arenaCoordinates[_arena][5] + Rnd.get(-400, 400));
 					girlSpawn.setLocz(_zCoord);
 					girlSpawn.setLocz(_zCoord);
 					girlSpawn.setAmount(1);
 					girlSpawn.setAmount(1);
 					girlSpawn.setHeading(1);
 					girlSpawn.setHeading(1);
@@ -479,7 +529,7 @@ public final class BlockCheckerEngine
 					// Schedule his deletion after 9 secs of spawn
 					// Schedule his deletion after 9 secs of spawn
 					ThreadPoolManager.getInstance().scheduleGeneral(new CarryingGirlUnspawn(girlSpawn), 9000);
 					ThreadPoolManager.getInstance().scheduleGeneral(new CarryingGirlUnspawn(girlSpawn), 9000);
 				}
 				}
-				catch(Exception e) 
+				catch (Exception e)
 				{
 				{
 					_log.warning("Couldnt Spawn Block Checker NPCs! Wrong instance type at npc table?");
 					_log.warning("Couldnt Spawn Block Checker NPCs! Wrong instance type at npc table?");
 					_log.warning(getClass().getSimpleName() + ": " + e.getMessage());
 					_log.warning(getClass().getSimpleName() + ": " + e.getMessage());
@@ -489,7 +539,7 @@ public final class BlockCheckerEngine
 			_redPoints += _numOfBoxes / 2;
 			_redPoints += _numOfBoxes / 2;
 			_bluePoints += _numOfBoxes / 2;
 			_bluePoints += _numOfBoxes / 2;
 			
 			
-			int timeLeft = (int)((getStarterTime() - System.currentTimeMillis()) / 1000);
+			int timeLeft = (int) ((getStarterTime() - System.currentTimeMillis()) / 1000);
 			ExCubeGameChangePoints changePoints = new ExCubeGameChangePoints(timeLeft, getBluePoints(), getRedPoints());
 			ExCubeGameChangePoints changePoints = new ExCubeGameChangePoints(timeLeft, getBluePoints(), getRedPoints());
 			getHolder().broadCastPacketToTeam(changePoints);
 			getHolder().broadCastPacketToTeam(changePoints);
 		}
 		}
@@ -497,7 +547,7 @@ public final class BlockCheckerEngine
 	
 	
 	private class CarryingGirlUnspawn implements Runnable
 	private class CarryingGirlUnspawn implements Runnable
 	{
 	{
-		private L2Spawn _spawn;
+		private final L2Spawn _spawn;
 		
 		
 		protected CarryingGirlUnspawn(L2Spawn spawn)
 		protected CarryingGirlUnspawn(L2Spawn spawn)
 		{
 		{
@@ -507,7 +557,7 @@ public final class BlockCheckerEngine
 		@Override
 		@Override
 		public void run()
 		public void run()
 		{
 		{
-			if(_spawn == null)
+			if (_spawn == null)
 			{
 			{
 				_log.warning("HBCE: Block Carrying Girl is null");
 				_log.warning("HBCE: Block Carrying Girl is null");
 				return;
 				return;
@@ -519,25 +569,15 @@ public final class BlockCheckerEngine
 	}
 	}
 	
 	
 	/*
 	/*
-	private class CountDown implements Runnable
-	{
-		@Override
-		public void run()
-		{
-			_holder.broadCastPacketToTeam(SystemMessage.getSystemMessage(SystemMessageId.BLOCK_CHECKER_ENDS_5));
-			ThreadPoolManager.getInstance().scheduleGeneral(new EndEvent(), 5000);
-		}
-	}
-	*/
-		
+	 * private class CountDown implements Runnable {
+	 * @Override public void run() { _holder.broadCastPacketToTeam(SystemMessage.getSystemMessage(SystemMessageId.BLOCK_CHECKER_ENDS_5)); ThreadPoolManager.getInstance().scheduleGeneral(new EndEvent(), 5000); } }
+	 */
+	
 	/**
 	/**
-	 * This class erase all event parameters on player
-	 * and port them back near Handy. Also, unspawn
-	 * blocks, runs a garbage collector and set as free
-	 * the used arena
+	 * This class erase all event parameters on player and port them back near Handy. Also, unspawn blocks, runs a garbage collector and set as free the used arena
 	 */
 	 */
 	protected class EndEvent implements Runnable
 	protected class EndEvent implements Runnable
-	{		
+	{
 		// Garbage collector and arena free setter
 		// Garbage collector and arena free setter
 		private void clearMe()
 		private void clearMe()
 		{
 		{
@@ -547,7 +587,7 @@ public final class BlockCheckerEngine
 			_redTeamPoints.clear();
 			_redTeamPoints.clear();
 			HandysBlockCheckerManager.getInstance().setArenaFree(_arena);
 			HandysBlockCheckerManager.getInstance().setArenaFree(_arena);
 			
 			
-			for(L2Spawn spawn : _spawns)
+			for (L2Spawn spawn : _spawns)
 			{
 			{
 				spawn.stopRespawn();
 				spawn.stopRespawn();
 				spawn.getLastSpawn().deleteMe();
 				spawn.getLastSpawn().deleteMe();
@@ -556,34 +596,39 @@ public final class BlockCheckerEngine
 			}
 			}
 			_spawns.clear();
 			_spawns.clear();
 			
 			
-			for(L2ItemInstance item : _drops)
+			for (L2ItemInstance item : _drops)
 			{
 			{
 				// npe
 				// npe
-				if(item == null)
+				if (item == null)
+				{
 					continue;
 					continue;
+				}
 				
 				
 				// a player has it, it will be deleted later
 				// a player has it, it will be deleted later
-				if(!item.isVisible() || item.getOwnerId() != 0)
+				if (!item.isVisible() || (item.getOwnerId() != 0))
+				{
 					continue;
 					continue;
+				}
 				
 				
 				item.decayMe();
 				item.decayMe();
 				L2World.getInstance().removeObject(item);
 				L2World.getInstance().removeObject(item);
 			}
 			}
 			_drops.clear();
 			_drops.clear();
 		}
 		}
-
+		
 		/**
 		/**
-		 * Reward players after event.
-		 * Tie - No Reward
+		 * Reward players after event. Tie - No Reward
 		 */
 		 */
 		private void rewardPlayers()
 		private void rewardPlayers()
 		{
 		{
-			if(_redPoints == _bluePoints)
+			if (_redPoints == _bluePoints)
+			{
 				return;
 				return;
+			}
 			
 			
 			_isRedWinner = _redPoints > _bluePoints ? true : false;
 			_isRedWinner = _redPoints > _bluePoints ? true : false;
 			
 			
-			if(_isRedWinner)
+			if (_isRedWinner)
 			{
 			{
 				rewardAsWinner(true);
 				rewardAsWinner(true);
 				rewardAsLooser(false);
 				rewardAsLooser(false);
@@ -591,7 +636,7 @@ public final class BlockCheckerEngine
 				msg.addString("Red Team");
 				msg.addString("Red Team");
 				_holder.broadCastPacketToTeam(msg);
 				_holder.broadCastPacketToTeam(msg);
 			}
 			}
-			else if(_bluePoints > _redPoints)
+			else if (_bluePoints > _redPoints)
 			{
 			{
 				rewardAsWinner(false);
 				rewardAsWinner(false);
 				rewardAsLooser(true);
 				rewardAsLooser(true);
@@ -607,34 +652,38 @@ public final class BlockCheckerEngine
 		}
 		}
 		
 		
 		/**
 		/**
-		 * Reward the speicifed team as a winner team
-		 * 1) Higher score - 8 extra
-		 * 2) Higher score - 5 extra
+		 * Reward the speicifed team as a winner team 1) Higher score - 8 extra 2) Higher score - 5 extra
 		 * @param isRed
 		 * @param isRed
 		 */
 		 */
 		private void rewardAsWinner(boolean isRed)
 		private void rewardAsWinner(boolean isRed)
 		{
 		{
-			FastMap<L2PcInstance, Integer> tempPoints = isRed? _redTeamPoints : _blueTeamPoints;
+			FastMap<L2PcInstance, Integer> tempPoints = isRed ? _redTeamPoints : _blueTeamPoints;
 			
 			
 			// Main give
 			// Main give
-			for(Entry<L2PcInstance, Integer> points : tempPoints.entrySet())
+			for (Entry<L2PcInstance, Integer> points : tempPoints.entrySet())
 			{
 			{
-				if(points.getKey() == null)
+				if (points.getKey() == null)
+				{
 					continue;
 					continue;
+				}
 				
 				
-				if(points.getValue() >= 10)
+				if (points.getValue() >= 10)
+				{
 					points.getKey().addItem("Block Checker", 13067, 2, points.getKey(), true);
 					points.getKey().addItem("Block Checker", 13067, 2, points.getKey(), true);
+				}
 				else
 				else
+				{
 					tempPoints.remove(points.getKey());
 					tempPoints.remove(points.getKey());
+				}
 			}
 			}
 			
 			
 			int first = 0, second = 0;
 			int first = 0, second = 0;
 			L2PcInstance winner1 = null, winner2 = null;
 			L2PcInstance winner1 = null, winner2 = null;
-			for(Entry<L2PcInstance, Integer> entry : tempPoints.entrySet())
+			for (Entry<L2PcInstance, Integer> entry : tempPoints.entrySet())
 			{
 			{
 				L2PcInstance pc = entry.getKey();
 				L2PcInstance pc = entry.getKey();
 				int pcPoints = entry.getValue();
 				int pcPoints = entry.getValue();
-				if(pcPoints > first)
+				if (pcPoints > first)
 				{
 				{
 					// Move old data
 					// Move old data
 					second = first;
 					second = first;
@@ -643,48 +692,53 @@ public final class BlockCheckerEngine
 					first = pcPoints;
 					first = pcPoints;
 					winner1 = pc;
 					winner1 = pc;
 				}
 				}
-				else if(pcPoints > second)
+				else if (pcPoints > second)
 				{
 				{
 					second = pcPoints;
 					second = pcPoints;
 					winner2 = pc;
 					winner2 = pc;
 				}
 				}
 			}
 			}
-			if(winner1 != null)
+			if (winner1 != null)
+			{
 				winner1.addItem("Block Checker", 13067, 8, winner1, true);
 				winner1.addItem("Block Checker", 13067, 8, winner1, true);
-			if(winner2 != null)
+			}
+			if (winner2 != null)
+			{
 				winner2.addItem("Block Checker", 13067, 5, winner2, true);
 				winner2.addItem("Block Checker", 13067, 5, winner2, true);
+			}
 		}
 		}
 		
 		
 		/**
 		/**
-		 * Will reward the looser team with the
-		 * predefined rewards
-		 * Player got >= 10 points: 2 coins
-		 * Player got < 10 points: 0 coins
+		 * Will reward the looser team with the predefined rewards Player got >= 10 points: 2 coins Player got < 10 points: 0 coins
 		 * @param isRed
 		 * @param isRed
 		 */
 		 */
 		private void rewardAsLooser(boolean isRed)
 		private void rewardAsLooser(boolean isRed)
 		{
 		{
-			FastMap<L2PcInstance, Integer> tempPoints = isRed? _redTeamPoints : _blueTeamPoints;
+			FastMap<L2PcInstance, Integer> tempPoints = isRed ? _redTeamPoints : _blueTeamPoints;
 			
 			
-			for(Entry<L2PcInstance, Integer> entry : tempPoints.entrySet())
+			for (Entry<L2PcInstance, Integer> entry : tempPoints.entrySet())
 			{
 			{
 				L2PcInstance player = entry.getKey();
 				L2PcInstance player = entry.getKey();
-				if(player != null && entry.getValue() >= 10)
+				if ((player != null) && (entry.getValue() >= 10))
+				{
 					player.addItem("Block Checker", 13067, 2, player, true);
 					player.addItem("Block Checker", 13067, 2, player, true);
+				}
 			}
 			}
 		}
 		}
 		
 		
 		/**
 		/**
-		 * Telport players back, give status back and 
-		 * send final packet
+		 * Telport players back, give status back and send final packet
 		 */
 		 */
 		private void setPlayersBack()
 		private void setPlayersBack()
 		{
 		{
 			final ExCubeGameEnd end = new ExCubeGameEnd(_isRedWinner);
 			final ExCubeGameEnd end = new ExCubeGameEnd(_isRedWinner);
 			
 			
-			for(L2PcInstance player : _holder.getAllPlayers())
+			for (L2PcInstance player : _holder.getAllPlayers())
 			{
 			{
-				if(player == null) continue;
+				if (player == null)
+				{
+					continue;
+				}
 				
 				
 				player.stopAllEffects();
 				player.stopAllEffects();
 				// Remove team aura
 				// Remove team aura
@@ -693,12 +747,12 @@ public final class BlockCheckerEngine
 				player.setBlockCheckerArena(DEFAULT_ARENA);
 				player.setBlockCheckerArena(DEFAULT_ARENA);
 				// Remove the event items
 				// Remove the event items
 				PcInventory inv = player.getInventory();
 				PcInventory inv = player.getInventory();
-				if(inv.getItemByItemId(13787) != null)
+				if (inv.getItemByItemId(13787) != null)
 				{
 				{
 					long count = inv.getInventoryItemCount(13787, 0);
 					long count = inv.getInventoryItemCount(13787, 0);
 					inv.destroyItemByItemId("Handys Block Checker", 13787, count, player, player);
 					inv.destroyItemByItemId("Handys Block Checker", 13787, count, player, player);
 				}
 				}
-				if(inv.getItemByItemId(13788) != null)
+				if (inv.getItemByItemId(13788) != null)
 				{
 				{
 					long count = inv.getInventoryItemCount(13788, 0);
 					long count = inv.getInventoryItemCount(13788, 0);
 					inv.destroyItemByItemId("Handys Block Checker", 13788, count, player, player);
 					inv.destroyItemByItemId("Handys Block Checker", 13788, count, player, player);
@@ -712,12 +766,14 @@ public final class BlockCheckerEngine
 				player.broadcastUserInfo();
 				player.broadcastUserInfo();
 			}
 			}
 		}
 		}
-				
+		
 		@Override
 		@Override
 		public void run()
 		public void run()
 		{
 		{
-			if(!_abnormalEnd)
+			if (!_abnormalEnd)
+			{
 				rewardPlayers();
 				rewardPlayers();
+			}
 			setPlayersBack();
 			setPlayersBack();
 			clearMe();
 			clearMe();
 			_isStarted = false;
 			_isStarted = false;

+ 124 - 26
L2J_Server_BETA/java/com/l2jserver/gameserver/model/entity/Castle.java

@@ -78,7 +78,7 @@ public class Castle
 	private static final String CASTLE_UPDATE_SEED = "UPDATE castle_manor_production SET can_produce=? WHERE seed_id=? AND castle_id=? AND period=?";
 	private static final String CASTLE_UPDATE_SEED = "UPDATE castle_manor_production SET can_produce=? WHERE seed_id=? AND castle_id=? AND period=?";
 	
 	
 	private int _castleId = 0;
 	private int _castleId = 0;
-	private List<L2DoorInstance> _doors = new ArrayList<>();
+	private final List<L2DoorInstance> _doors = new ArrayList<>();
 	private String _name = "";
 	private String _name = "";
 	private int _ownerId = 0;
 	private int _ownerId = 0;
 	private Siege _siege = null;
 	private Siege _siege = null;
@@ -93,10 +93,10 @@ public class Castle
 	private L2CastleZone _castleZone = null;
 	private L2CastleZone _castleZone = null;
 	private L2ResidenceTeleportZone _teleZone;
 	private L2ResidenceTeleportZone _teleZone;
 	private L2Clan _formerOwner = null;
 	private L2Clan _formerOwner = null;
-	private List<L2ArtefactInstance> _artefacts = new ArrayList<>(1);
-	private TIntIntHashMap _engrave = new TIntIntHashMap(1);
-	private Map<Integer, CastleFunction> _function;
-	private List<L2Skill> _residentialSkills = new ArrayList<>();
+	private final List<L2ArtefactInstance> _artefacts = new ArrayList<>(1);
+	private final TIntIntHashMap _engrave = new TIntIntHashMap(1);
+	private final Map<Integer, CastleFunction> _function;
+	private final List<L2Skill> _residentialSkills = new ArrayList<>();
 	private int _bloodAlliance = 0;
 	private int _bloodAlliance = 0;
 	
 	
 	/** Castle Functions */
 	/** Castle Functions */
@@ -108,11 +108,11 @@ public class Castle
 	
 	
 	public class CastleFunction
 	public class CastleFunction
 	{
 	{
-		private int _type;
+		private final int _type;
 		private int _lvl;
 		private int _lvl;
 		protected int _fee;
 		protected int _fee;
 		protected int _tempFee;
 		protected int _tempFee;
-		private long _rate;
+		private final long _rate;
 		private long _endDate;
 		private long _endDate;
 		protected boolean _inDebt;
 		protected boolean _inDebt;
 		public boolean _cwh;
 		public boolean _cwh;
@@ -171,12 +171,18 @@ public class Castle
 		private void initializeTask(boolean cwh)
 		private void initializeTask(boolean cwh)
 		{
 		{
 			if (getOwnerId() <= 0)
 			if (getOwnerId() <= 0)
+			{
 				return;
 				return;
+			}
 			long currentTime = System.currentTimeMillis();
 			long currentTime = System.currentTimeMillis();
 			if (_endDate > currentTime)
 			if (_endDate > currentTime)
+			{
 				ThreadPoolManager.getInstance().scheduleGeneral(new FunctionTask(cwh), _endDate - currentTime);
 				ThreadPoolManager.getInstance().scheduleGeneral(new FunctionTask(cwh), _endDate - currentTime);
+			}
 			else
 			else
+			{
 				ThreadPoolManager.getInstance().scheduleGeneral(new FunctionTask(cwh), 0);
 				ThreadPoolManager.getInstance().scheduleGeneral(new FunctionTask(cwh), 0);
+			}
 		}
 		}
 		
 		
 		private class FunctionTask implements Runnable
 		private class FunctionTask implements Runnable
@@ -192,12 +198,16 @@ public class Castle
 				try
 				try
 				{
 				{
 					if (getOwnerId() <= 0)
 					if (getOwnerId() <= 0)
+					{
 						return;
 						return;
-					if (ClanTable.getInstance().getClan(getOwnerId()).getWarehouse().getAdena() >= _fee || !_cwh)
+					}
+					if ((ClanTable.getInstance().getClan(getOwnerId()).getWarehouse().getAdena() >= _fee) || !_cwh)
 					{
 					{
 						int fee = _fee;
 						int fee = _fee;
 						if (getEndTime() == -1)
 						if (getEndTime() == -1)
+						{
 							fee = _tempFee;
 							fee = _tempFee;
+						}
 						
 						
 						setEndTime(System.currentTimeMillis() + getRate());
 						setEndTime(System.currentTimeMillis() + getRate());
 						dbSave();
 						dbSave();
@@ -205,12 +215,16 @@ public class Castle
 						{
 						{
 							ClanTable.getInstance().getClan(getOwnerId()).getWarehouse().destroyItemByItemId("CS_function_fee", PcInventory.ADENA_ID, fee, null, null);
 							ClanTable.getInstance().getClan(getOwnerId()).getWarehouse().destroyItemByItemId("CS_function_fee", PcInventory.ADENA_ID, fee, null, null);
 							if (Config.DEBUG)
 							if (Config.DEBUG)
+							{
 								_log.warning("deducted " + fee + " adena from " + getName() + " owner's cwh for function id : " + getType());
 								_log.warning("deducted " + fee + " adena from " + getName() + " owner's cwh for function id : " + getType());
+							}
 						}
 						}
 						ThreadPoolManager.getInstance().scheduleGeneral(new FunctionTask(true), getRate());
 						ThreadPoolManager.getInstance().scheduleGeneral(new FunctionTask(true), getRate());
 					}
 					}
 					else
 					else
+					{
 						removeFunction(getType());
 						removeFunction(getType());
+					}
 				}
 				}
 				catch (Exception e)
 				catch (Exception e)
 				{
 				{
@@ -274,21 +288,27 @@ public class Castle
 	public CastleFunction getFunction(int type)
 	public CastleFunction getFunction(int type)
 	{
 	{
 		if (_function.containsKey(type))
 		if (_function.containsKey(type))
+		{
 			return _function.get(type);
 			return _function.get(type);
+		}
 		return null;
 		return null;
 	}
 	}
 	
 	
 	public synchronized void engrave(L2Clan clan, L2Object target)
 	public synchronized void engrave(L2Clan clan, L2Object target)
 	{
 	{
 		if (!_artefacts.contains(target))
 		if (!_artefacts.contains(target))
+		{
 			return;
 			return;
+		}
 		_engrave.put(target.getObjectId(), clan.getClanId());
 		_engrave.put(target.getObjectId(), clan.getClanId());
 		if (_engrave.size() == _artefacts.size())
 		if (_engrave.size() == _artefacts.size())
 		{
 		{
 			for (L2ArtefactInstance art : _artefacts)
 			for (L2ArtefactInstance art : _artefacts)
 			{
 			{
 				if (_engrave.get(art.getObjectId()) != clan.getClanId())
 				if (_engrave.get(art.getObjectId()) != clan.getClanId())
+				{
 					return;
 					return;
+				}
 			}
 			}
 			_engrave.clear();
 			_engrave.clear();
 			setOwner(clan);
 			setOwner(clan);
@@ -315,7 +335,9 @@ public class Castle
 			{
 			{
 				long runeTax = (long) (amount * rune.getTaxRate());
 				long runeTax = (long) (amount * rune.getTaxRate());
 				if (rune.getOwnerId() > 0)
 				if (rune.getOwnerId() > 0)
+				{
 					rune.addToTreasury(runeTax);
 					rune.addToTreasury(runeTax);
+				}
 				amount -= runeTax;
 				amount -= runeTax;
 			}
 			}
 		}
 		}
@@ -326,8 +348,10 @@ public class Castle
 			{
 			{
 				long adenTax = (long) (amount * aden.getTaxRate()); // Find out what Aden gets from the current castle instance's income
 				long adenTax = (long) (amount * aden.getTaxRate()); // Find out what Aden gets from the current castle instance's income
 				if (aden.getOwnerId() > 0)
 				if (aden.getOwnerId() > 0)
+				{
 					aden.addToTreasury(adenTax); // Only bother to really add the tax to the treasury if not npc owned
 					aden.addToTreasury(adenTax); // Only bother to really add the tax to the treasury if not npc owned
-					
+				}
+				
 				amount -= adenTax; // Subtract Aden's income from current castle instance's income
 				amount -= adenTax; // Subtract Aden's income from current castle instance's income
 			}
 			}
 		}
 		}
@@ -343,21 +367,29 @@ public class Castle
 	public boolean addToTreasuryNoTax(long amount)
 	public boolean addToTreasuryNoTax(long amount)
 	{
 	{
 		if (getOwnerId() <= 0)
 		if (getOwnerId() <= 0)
+		{
 			return false;
 			return false;
+		}
 		
 		
 		if (amount < 0)
 		if (amount < 0)
 		{
 		{
 			amount *= -1;
 			amount *= -1;
 			if (_treasury < amount)
 			if (_treasury < amount)
+			{
 				return false;
 				return false;
+			}
 			_treasury -= amount;
 			_treasury -= amount;
 		}
 		}
 		else
 		else
 		{
 		{
-			if (_treasury + amount > PcInventory.MAX_ADENA) // TODO is this valid after gracia final?
+			if ((_treasury + amount) > PcInventory.MAX_ADENA)
+			{
 				_treasury = PcInventory.MAX_ADENA;
 				_treasury = PcInventory.MAX_ADENA;
+			}
 			else
 			else
+			{
 				_treasury += amount;
 				_treasury += amount;
+			}
 		}
 		}
 		
 		
 		try (Connection con = L2DatabaseFactory.getInstance().getConnection();
 		try (Connection con = L2DatabaseFactory.getInstance().getConnection();
@@ -470,15 +502,21 @@ public class Castle
 	public void openCloseDoor(L2PcInstance activeChar, int doorId, boolean open)
 	public void openCloseDoor(L2PcInstance activeChar, int doorId, boolean open)
 	{
 	{
 		if (activeChar.getClanId() != getOwnerId())
 		if (activeChar.getClanId() != getOwnerId())
+		{
 			return;
 			return;
+		}
 		
 		
 		L2DoorInstance door = getDoor(doorId);
 		L2DoorInstance door = getDoor(doorId);
 		if (door != null)
 		if (door != null)
 		{
 		{
 			if (open)
 			if (open)
+			{
 				door.openMe();
 				door.openMe();
+			}
 			else
 			else
+			{
 				door.closeMe();
 				door.closeMe();
+			}
 		}
 		}
 	}
 	}
 	
 	
@@ -497,7 +535,7 @@ public class Castle
 	public void setOwner(L2Clan clan)
 	public void setOwner(L2Clan clan)
 	{
 	{
 		// Remove old owner
 		// Remove old owner
-		if (getOwnerId() > 0 && (clan == null || clan.getClanId() != getOwnerId()))
+		if ((getOwnerId() > 0) && ((clan == null) || (clan.getClanId() != getOwnerId())))
 		{
 		{
 			L2Clan oldOwner = ClanTable.getInstance().getClan(getOwnerId()); // Try to find clan instance
 			L2Clan oldOwner = ClanTable.getInstance().getClan(getOwnerId()); // Try to find clan instance
 			if (oldOwner != null)
 			if (oldOwner != null)
@@ -516,7 +554,9 @@ public class Castle
 					if (oldleader != null)
 					if (oldleader != null)
 					{
 					{
 						if (oldleader.getMountType() == 2)
 						if (oldleader.getMountType() == 2)
+						{
 							oldleader.dismount();
 							oldleader.dismount();
+						}
 					}
 					}
 				}
 				}
 				catch (Exception e)
 				catch (Exception e)
@@ -536,12 +576,16 @@ public class Castle
 		setShowNpcCrest(false);
 		setShowNpcCrest(false);
 		
 		
 		// if clan have fortress, remove it
 		// if clan have fortress, remove it
-		if ((clan != null) && clan.getFortId() > 0)
+		if ((clan != null) && (clan.getFortId() > 0))
+		{
 			FortManager.getInstance().getFortByOwner(clan).removeOwner(true);
 			FortManager.getInstance().getFortByOwner(clan).removeOwner(true);
+		}
 		
 		
-		if (getSiege().getIsInProgress()) // If siege in progress
+		if (getSiege().getIsInProgress())
+		{
 			getSiege().midVictory(); // Mid victory phase of siege
 			getSiege().midVictory(); // Mid victory phase of siege
-			
+		}
+		
 		TerritoryWarManager.getInstance().getTerritory(_castleId).setOwnerClan(clan);
 		TerritoryWarManager.getInstance().getTerritory(_castleId).setOwnerClan(clan);
 		
 		
 		if (clan != null)
 		if (clan != null)
@@ -574,7 +618,9 @@ public class Castle
 		
 		
 		updateOwnerInDB(null);
 		updateOwnerInDB(null);
 		if (getSiege().getIsInProgress())
 		if (getSiege().getIsInProgress())
+		{
 			getSiege().midVictory();
 			getSiege().midVictory();
+		}
 		
 		
 		for (Integer fc : _function.keySet())
 		for (Integer fc : _function.keySet())
 		{
 		{
@@ -599,7 +645,7 @@ public class Castle
 				maxTax = 15;
 				maxTax = 15;
 		}
 		}
 		
 		
-		if (taxPercent < 0 || taxPercent > maxTax)
+		if ((taxPercent < 0) || (taxPercent > maxTax))
 		{
 		{
 			activeChar.sendMessage("Tax value must be between 0 and " + maxTax + ".");
 			activeChar.sendMessage("Tax value must be between 0 and " + maxTax + ".");
 			return;
 			return;
@@ -648,13 +694,19 @@ public class Castle
 			{
 			{
 				door.doRevive();
 				door.doRevive();
 				if (isDoorWeak)
 				if (isDoorWeak)
+				{
 					door.setCurrentHp(door.getMaxHp() / 2);
 					door.setCurrentHp(door.getMaxHp() / 2);
+				}
 				else
 				else
+				{
 					door.setCurrentHp(door.getMaxHp());
 					door.setCurrentHp(door.getMaxHp());
+				}
 			}
 			}
 			
 			
 			if (door.getOpen())
 			if (door.getOpen())
+			{
 				door.closeMe();
 				door.closeMe();
+			}
 		}
 		}
 		loadDoorUpgrade(); // Check for any upgrade the doors may have
 		loadDoorUpgrade(); // Check for any upgrade the doors may have
 	}
 	}
@@ -664,7 +716,9 @@ public class Castle
 	{
 	{
 		L2DoorInstance door = getDoor(doorId);
 		L2DoorInstance door = getDoor(doorId);
 		if (door == null)
 		if (door == null)
+		{
 			return;
 			return;
+		}
 		
 		
 		door.setCurrentHp(door.getMaxHp() + hp);
 		door.setCurrentHp(door.getMaxHp() + hp);
 		
 		
@@ -767,25 +821,37 @@ public class Castle
 	public boolean updateFunctions(L2PcInstance player, int type, int lvl, int lease, long rate, boolean addNew)
 	public boolean updateFunctions(L2PcInstance player, int type, int lvl, int lease, long rate, boolean addNew)
 	{
 	{
 		if (player == null)
 		if (player == null)
+		{
 			return false;
 			return false;
+		}
 		if (Config.DEBUG)
 		if (Config.DEBUG)
+		{
 			_log.warning("Called Castle.updateFunctions(int type, int lvl, int lease, long rate, boolean addNew) Owner : " + getOwnerId());
 			_log.warning("Called Castle.updateFunctions(int type, int lvl, int lease, long rate, boolean addNew) Owner : " + getOwnerId());
+		}
 		if (lease > 0)
 		if (lease > 0)
+		{
 			if (!player.destroyItemByItemId("Consume", PcInventory.ADENA_ID, lease, null, true))
 			if (!player.destroyItemByItemId("Consume", PcInventory.ADENA_ID, lease, null, true))
+			{
 				return false;
 				return false;
+			}
+		}
 		if (addNew)
 		if (addNew)
 		{
 		{
 			_function.put(type, new CastleFunction(type, lvl, lease, 0, rate, 0, false));
 			_function.put(type, new CastleFunction(type, lvl, lease, 0, rate, 0, false));
 		}
 		}
 		else
 		else
 		{
 		{
-			if (lvl == 0 && lease == 0)
+			if ((lvl == 0) && (lease == 0))
+			{
 				removeFunction(type);
 				removeFunction(type);
+			}
 			else
 			else
 			{
 			{
 				int diffLease = lease - _function.get(type).getLease();
 				int diffLease = lease - _function.get(type).getLease();
 				if (Config.DEBUG)
 				if (Config.DEBUG)
+				{
 					_log.warning("Called Castle.updateFunctions diffLease : " + diffLease);
 					_log.warning("Called Castle.updateFunctions diffLease : " + diffLease);
+				}
 				if (diffLease > 0)
 				if (diffLease > 0)
 				{
 				{
 					_function.remove(type);
 					_function.remove(type);
@@ -801,7 +867,7 @@ public class Castle
 		}
 		}
 		return true;
 		return true;
 	}
 	}
-
+	
 	public void activateInstance()
 	public void activateInstance()
 	{
 	{
 		loadDoor();
 		loadDoor();
@@ -812,12 +878,16 @@ public class Castle
 	{
 	{
 		for (L2DoorInstance door : DoorTable.getInstance().getDoors())
 		for (L2DoorInstance door : DoorTable.getInstance().getDoors())
 		{
 		{
-			if (door.getCastle() != null && door.getCastle().getCastleId() == getCastleId())
+			if ((door.getCastle() != null) && (door.getCastle().getCastleId() == getCastleId()))
+			{
 				_doors.add(door);
 				_doors.add(door);
+			}
 		}
 		}
 		
 		
 		if (Config.DEBUG)
 		if (Config.DEBUG)
-			_log.info("Castle "+this+" loaded "+_doors.size()+" doors.");
+		{
+			_log.info("Castle " + this + " loaded " + _doors.size() + " doors.");
+		}
 	}
 	}
 	
 	
 	// This method loads castle door upgrade data from database
 	// This method loads castle door upgrade data from database
@@ -827,9 +897,11 @@ public class Castle
 		{
 		{
 			StringBuilder doorIds = new StringBuilder(100);
 			StringBuilder doorIds = new StringBuilder(100);
 			for (L2DoorInstance door : getDoors())
 			for (L2DoorInstance door : getDoors())
+			{
 				doorIds.append(door.getDoorId()).append(',');
 				doorIds.append(door.getDoorId()).append(',');
-			doorIds.deleteCharAt(doorIds.length()-1);
-			PreparedStatement statement = con.prepareStatement("Select * from castle_doorupgrade where doorId in ("+doorIds.toString()+")");
+			}
+			doorIds.deleteCharAt(doorIds.length() - 1);
+			PreparedStatement statement = con.prepareStatement("Select * from castle_doorupgrade where doorId in (" + doorIds.toString() + ")");
 			ResultSet rs = statement.executeQuery();
 			ResultSet rs = statement.executeQuery();
 			
 			
 			while (rs.next())
 			while (rs.next())
@@ -851,9 +923,11 @@ public class Castle
 		{
 		{
 			StringBuilder doorIds = new StringBuilder(100);
 			StringBuilder doorIds = new StringBuilder(100);
 			for (L2DoorInstance door : getDoors())
 			for (L2DoorInstance door : getDoors())
+			{
 				doorIds.append(door.getDoorId()).append(',');
 				doorIds.append(door.getDoorId()).append(',');
-			doorIds.deleteCharAt(doorIds.length()-1);
-			PreparedStatement statement = con.prepareStatement("delete from castle_doorupgrade where doorId in ("+doorIds.toString()+")");
+			}
+			doorIds.deleteCharAt(doorIds.length() - 1);
+			PreparedStatement statement = con.prepareStatement("delete from castle_doorupgrade where doorId in (" + doorIds.toString() + ")");
 			statement.execute();
 			statement.execute();
 			statement.close();
 			statement.close();
 		}
 		}
@@ -884,7 +958,9 @@ public class Castle
 	private void updateOwnerInDB(L2Clan clan)
 	private void updateOwnerInDB(L2Clan clan)
 	{
 	{
 		if (clan != null)
 		if (clan != null)
+		{
 			_ownerId = clan.getClanId(); // Update owner id property
 			_ownerId = clan.getClanId(); // Update owner id property
+		}
 		else
 		else
 		{
 		{
 			_ownerId = 0; // Remove owner
 			_ownerId = 0; // Remove owner
@@ -929,12 +1005,16 @@ public class Castle
 	public final L2DoorInstance getDoor(int doorId)
 	public final L2DoorInstance getDoor(int doorId)
 	{
 	{
 		if (doorId <= 0)
 		if (doorId <= 0)
+		{
 			return null;
 			return null;
+		}
 		
 		
 		for (L2DoorInstance door : getDoors())
 		for (L2DoorInstance door : getDoors())
 		{
 		{
 			if (door.getDoorId() == doorId)
 			if (door.getDoorId() == doorId)
+			{
 				return door;
 				return door;
+			}
 		}
 		}
 		return null;
 		return null;
 	}
 	}
@@ -957,10 +1037,12 @@ public class Castle
 	public final Siege getSiege()
 	public final Siege getSiege()
 	{
 	{
 		if (_siege == null)
 		if (_siege == null)
+		{
 			_siege = new Siege(new Castle[]
 			_siege = new Siege(new Castle[]
 			{
 			{
 				this
 				this
 			});
 			});
+		}
 		return _siege;
 		return _siege;
 	}
 	}
 	
 	
@@ -982,7 +1064,9 @@ public class Castle
 	public Calendar getTimeRegistrationOverDate()
 	public Calendar getTimeRegistrationOverDate()
 	{
 	{
 		if (_siegeTimeRegistrationEndDate == null)
 		if (_siegeTimeRegistrationEndDate == null)
+		{
 			_siegeTimeRegistrationEndDate = Calendar.getInstance();
 			_siegeTimeRegistrationEndDate = Calendar.getInstance();
+		}
 		return _siegeTimeRegistrationEndDate;
 		return _siegeTimeRegistrationEndDate;
 	}
 	}
 	
 	
@@ -1028,17 +1112,25 @@ public class Castle
 	public void setSeedProduction(List<SeedProduction> seed, int period)
 	public void setSeedProduction(List<SeedProduction> seed, int period)
 	{
 	{
 		if (period == CastleManorManager.PERIOD_CURRENT)
 		if (period == CastleManorManager.PERIOD_CURRENT)
+		{
 			_production = seed;
 			_production = seed;
+		}
 		else
 		else
+		{
 			_productionNext = seed;
 			_productionNext = seed;
+		}
 	}
 	}
 	
 	
 	public void setCropProcure(List<CropProcure> crop, int period)
 	public void setCropProcure(List<CropProcure> crop, int period)
 	{
 	{
 		if (period == CastleManorManager.PERIOD_CURRENT)
 		if (period == CastleManorManager.PERIOD_CURRENT)
+		{
 			_procure = crop;
 			_procure = crop;
+		}
 		else
 		else
+		{
 			_procureNext = crop;
 			_procureNext = crop;
+		}
 	}
 	}
 	
 	
 	public SeedProduction getSeed(int seedId, int period)
 	public SeedProduction getSeed(int seedId, int period)
@@ -1285,7 +1377,7 @@ public class Castle
 			List<CropProcure> proc = null;
 			List<CropProcure> proc = null;
 			proc = getCropProcure(period);
 			proc = getCropProcure(period);
 			
 			
-			if (proc != null && proc.size() > 0)
+			if ((proc != null) && (proc.size() > 0))
 			{
 			{
 				int count = 0;
 				int count = 0;
 				StringBuilder query = new StringBuilder();
 				StringBuilder query = new StringBuilder();
@@ -1372,10 +1464,14 @@ public class Castle
 				_formerOwner.takeReputationScore(Config.LOOSE_CASTLE_POINTS, true);
 				_formerOwner.takeReputationScore(Config.LOOSE_CASTLE_POINTS, true);
 				L2Clan owner = ClanTable.getInstance().getClan(getOwnerId());
 				L2Clan owner = ClanTable.getInstance().getClan(getOwnerId());
 				if (owner != null)
 				if (owner != null)
+				{
 					owner.addReputationScore(Math.min(Config.TAKE_CASTLE_POINTS, maxreward), true);
 					owner.addReputationScore(Math.min(Config.TAKE_CASTLE_POINTS, maxreward), true);
+				}
 			}
 			}
 			else
 			else
+			{
 				_formerOwner.addReputationScore(Config.CASTLE_DEFENDED_POINTS, true);
 				_formerOwner.addReputationScore(Config.CASTLE_DEFENDED_POINTS, true);
+			}
 		}
 		}
 		else
 		else
 		{
 		{
@@ -1415,7 +1511,7 @@ public class Castle
 			player.addSkill(sk, false);
 			player.addSkill(sk, false);
 		}
 		}
 		Territory territory = TerritoryWarManager.getInstance().getTerritory(getCastleId());
 		Territory territory = TerritoryWarManager.getInstance().getTerritory(getCastleId());
-		if (territory != null && territory.getOwnedWardIds().contains(getCastleId() + 80))
+		if ((territory != null) && territory.getOwnedWardIds().contains(getCastleId() + 80))
 		{
 		{
 			for (int wardId : territory.getOwnedWardIds())
 			for (int wardId : territory.getOwnedWardIds())
 			{
 			{
@@ -1470,7 +1566,9 @@ public class Castle
 	public void registerArtefact(L2ArtefactInstance artefact)
 	public void registerArtefact(L2ArtefactInstance artefact)
 	{
 	{
 		if (Config.DEBUG)
 		if (Config.DEBUG)
+		{
 			_log.info("ArtefactId: " + artefact.getObjectId() + " is registered to " + getName() + " castle.");
 			_log.info("ArtefactId: " + artefact.getObjectId() + " is registered to " + getName() + " castle.");
+		}
 		_artefacts.add(artefact);
 		_artefacts.add(artefact);
 	}
 	}
 	
 	
@@ -1518,6 +1616,6 @@ public class Castle
 	@Override
 	@Override
 	public String toString()
 	public String toString()
 	{
 	{
-		return _name+"("+_castleId+")";
+		return _name + "(" + _castleId + ")";
 	}
 	}
 }
 }

+ 82 - 27
L2J_Server_BETA/java/com/l2jserver/gameserver/model/entity/ClanHall.java

@@ -40,16 +40,16 @@ public abstract class ClanHall
 {
 {
 	protected static final Logger _log = Logger.getLogger(ClanHall.class.getName());
 	protected static final Logger _log = Logger.getLogger(ClanHall.class.getName());
 	
 	
-	private int _clanHallId;
+	private final int _clanHallId;
 	private ArrayList<L2DoorInstance> _doors;
 	private ArrayList<L2DoorInstance> _doors;
-	private String _name;
+	private final String _name;
 	private int _ownerId;
 	private int _ownerId;
-	private String _desc;
-	private String _location;
+	private final String _desc;
+	private final String _location;
 	private L2ClanHallZone _zone;
 	private L2ClanHallZone _zone;
 	protected final int _chRate = 604800000;
 	protected final int _chRate = 604800000;
 	protected boolean _isFree = true;
 	protected boolean _isFree = true;
-	private Map<Integer, ClanHallFunction> _functions;
+	private final Map<Integer, ClanHallFunction> _functions;
 	
 	
 	/** Clan Hall Functions */
 	/** Clan Hall Functions */
 	public static final int FUNC_TELEPORT = 1;
 	public static final int FUNC_TELEPORT = 1;
@@ -58,16 +58,16 @@ public abstract class ClanHall
 	public static final int FUNC_RESTORE_MP = 4;
 	public static final int FUNC_RESTORE_MP = 4;
 	public static final int FUNC_RESTORE_EXP = 5;
 	public static final int FUNC_RESTORE_EXP = 5;
 	public static final int FUNC_SUPPORT = 6;
 	public static final int FUNC_SUPPORT = 6;
-	public static final int FUNC_DECO_FRONTPLATEFORM = 7; 	//Only Auctionable Halls
-	public static final int FUNC_DECO_CURTAINS = 8;			//Only Auctionable Halls
+	public static final int FUNC_DECO_FRONTPLATEFORM = 7; // Only Auctionable Halls
+	public static final int FUNC_DECO_CURTAINS = 8; // Only Auctionable Halls
 	
 	
 	public class ClanHallFunction
 	public class ClanHallFunction
 	{
 	{
-		private int _type;
+		private final int _type;
 		private int _lvl;
 		private int _lvl;
 		protected int _fee;
 		protected int _fee;
 		protected int _tempFee;
 		protected int _tempFee;
-		private long _rate;
+		private final long _rate;
 		private long _endDate;
 		private long _endDate;
 		protected boolean _inDebt;
 		protected boolean _inDebt;
 		public boolean _cwh; // first activating clanhall function is payed from player inventory, any others from clan warehouse
 		public boolean _cwh; // first activating clanhall function is payed from player inventory, any others from clan warehouse
@@ -126,12 +126,18 @@ public abstract class ClanHall
 		private void initializeTask(boolean cwh)
 		private void initializeTask(boolean cwh)
 		{
 		{
 			if (_isFree)
 			if (_isFree)
+			{
 				return;
 				return;
+			}
 			long currentTime = System.currentTimeMillis();
 			long currentTime = System.currentTimeMillis();
 			if (_endDate > currentTime)
 			if (_endDate > currentTime)
+			{
 				ThreadPoolManager.getInstance().scheduleGeneral(new FunctionTask(cwh), _endDate - currentTime);
 				ThreadPoolManager.getInstance().scheduleGeneral(new FunctionTask(cwh), _endDate - currentTime);
+			}
 			else
 			else
+			{
 				ThreadPoolManager.getInstance().scheduleGeneral(new FunctionTask(cwh), 0);
 				ThreadPoolManager.getInstance().scheduleGeneral(new FunctionTask(cwh), 0);
+			}
 		}
 		}
 		
 		
 		private class FunctionTask implements Runnable
 		private class FunctionTask implements Runnable
@@ -147,12 +153,16 @@ public abstract class ClanHall
 				try
 				try
 				{
 				{
 					if (_isFree)
 					if (_isFree)
+					{
 						return;
 						return;
-					if (ClanTable.getInstance().getClan(getOwnerId()).getWarehouse().getAdena() >= _fee || !_cwh)
+					}
+					if ((ClanTable.getInstance().getClan(getOwnerId()).getWarehouse().getAdena() >= _fee) || !_cwh)
 					{
 					{
 						int fee = _fee;
 						int fee = _fee;
 						if (getEndTime() == -1)
 						if (getEndTime() == -1)
+						{
 							fee = _tempFee;
 							fee = _tempFee;
+						}
 						
 						
 						setEndTime(System.currentTimeMillis() + getRate());
 						setEndTime(System.currentTimeMillis() + getRate());
 						dbSave();
 						dbSave();
@@ -160,12 +170,16 @@ public abstract class ClanHall
 						{
 						{
 							ClanTable.getInstance().getClan(getOwnerId()).getWarehouse().destroyItemByItemId("CH_function_fee", PcInventory.ADENA_ID, fee, null, null);
 							ClanTable.getInstance().getClan(getOwnerId()).getWarehouse().destroyItemByItemId("CH_function_fee", PcInventory.ADENA_ID, fee, null, null);
 							if (Config.DEBUG)
 							if (Config.DEBUG)
+							{
 								_log.warning("deducted " + fee + " adena from " + getName() + " owner's cwh for function id : " + getType());
 								_log.warning("deducted " + fee + " adena from " + getName() + " owner's cwh for function id : " + getType());
+							}
 						}
 						}
 						ThreadPoolManager.getInstance().scheduleGeneral(new FunctionTask(true), getRate());
 						ThreadPoolManager.getInstance().scheduleGeneral(new FunctionTask(true), getRate());
 					}
 					}
 					else
 					else
+					{
 						removeFunction(getType());
 						removeFunction(getType());
+					}
 				}
 				}
 				catch (Exception e)
 				catch (Exception e)
 				{
 				{
@@ -190,8 +204,7 @@ public abstract class ClanHall
 			}
 			}
 			catch (Exception e)
 			catch (Exception e)
 			{
 			{
-				_log.log(Level.SEVERE, "Exception: ClanHall.updateFunctions(int type, int lvl, int lease, long rate, long time, boolean addNew): "
-						+ e.getMessage(), e);
+				_log.log(Level.SEVERE, "Exception: ClanHall.updateFunctions(int type, int lvl, int lease, long rate, long time, boolean addNew): " + e.getMessage(), e);
 			}
 			}
 		}
 		}
 	}
 	}
@@ -202,18 +215,24 @@ public abstract class ClanHall
 		_name = set.getString("name");
 		_name = set.getString("name");
 		_ownerId = set.getInteger("ownerId");
 		_ownerId = set.getInteger("ownerId");
 		if (Config.DEBUG)
 		if (Config.DEBUG)
+		{
 			_log.warning("Init Owner : " + _ownerId);
 			_log.warning("Init Owner : " + _ownerId);
+		}
 		_desc = set.getString("desc");
 		_desc = set.getString("desc");
 		_location = set.getString("location");
 		_location = set.getString("location");
 		_functions = new FastMap<>();
 		_functions = new FastMap<>();
 		
 		
-		if(_ownerId > 0)
+		if (_ownerId > 0)
 		{
 		{
 			L2Clan clan = ClanTable.getInstance().getClan(_ownerId);
 			L2Clan clan = ClanTable.getInstance().getClan(_ownerId);
-			if(clan != null)
+			if (clan != null)
+			{
 				clan.setHideoutId(getId());
 				clan.setHideoutId(getId());
+			}
 			else
 			else
+			{
 				free();
 				free();
+			}
 		}
 		}
 	}
 	}
 	
 	
@@ -263,34 +282,42 @@ public abstract class ClanHall
 	public final ArrayList<L2DoorInstance> getDoors()
 	public final ArrayList<L2DoorInstance> getDoors()
 	{
 	{
 		if (_doors == null)
 		if (_doors == null)
+		{
 			_doors = new ArrayList<>();
 			_doors = new ArrayList<>();
+		}
 		return _doors;
 		return _doors;
 	}
 	}
 	
 	
 	/**
 	/**
-	 * @param doorId 
+	 * @param doorId
 	 * @return Door
 	 * @return Door
 	 */
 	 */
 	public final L2DoorInstance getDoor(int doorId)
 	public final L2DoorInstance getDoor(int doorId)
 	{
 	{
 		if (doorId <= 0)
 		if (doorId <= 0)
+		{
 			return null;
 			return null;
+		}
 		for (L2DoorInstance door : getDoors())
 		for (L2DoorInstance door : getDoors())
 		{
 		{
 			if (door.getDoorId() == doorId)
 			if (door.getDoorId() == doorId)
+			{
 				return door;
 				return door;
+			}
 		}
 		}
 		return null;
 		return null;
 	}
 	}
 	
 	
 	/**
 	/**
-	 * @param type 
+	 * @param type
 	 * @return function with id
 	 * @return function with id
 	 */
 	 */
 	public ClanHallFunction getFunction(int type)
 	public ClanHallFunction getFunction(int type)
 	{
 	{
 		if (_functions.get(type) != null)
 		if (_functions.get(type) != null)
+		{
 			return _functions.get(type);
 			return _functions.get(type);
+		}
 		return null;
 		return null;
 	}
 	}
 	
 	
@@ -304,9 +331,9 @@ public abstract class ClanHall
 	}
 	}
 	
 	
 	/**
 	/**
-	 * @param x 
-	 * @param y 
-	 * @param z 
+	 * @param x
+	 * @param y
+	 * @param z
 	 * @return true if object is inside the zone
 	 * @return true if object is inside the zone
 	 */
 	 */
 	public boolean checkIfInZone(int x, int y, int z)
 	public boolean checkIfInZone(int x, int y, int z)
@@ -328,20 +355,24 @@ public abstract class ClanHall
 		_ownerId = 0;
 		_ownerId = 0;
 		_isFree = true;
 		_isFree = true;
 		for (Map.Entry<Integer, ClanHallFunction> fc : _functions.entrySet())
 		for (Map.Entry<Integer, ClanHallFunction> fc : _functions.entrySet())
+		{
 			removeFunction(fc.getKey());
 			removeFunction(fc.getKey());
+		}
 		_functions.clear();
 		_functions.clear();
 		updateDb();
 		updateDb();
 	}
 	}
 	
 	
 	/**
 	/**
 	 * Set owner if clan hall is free
 	 * Set owner if clan hall is free
-	 * @param clan 
+	 * @param clan
 	 */
 	 */
 	public void setOwner(L2Clan clan)
 	public void setOwner(L2Clan clan)
 	{
 	{
 		// Verify that this ClanHall is Free and Clan isn't null
 		// Verify that this ClanHall is Free and Clan isn't null
-		if (_ownerId > 0 || clan == null)
+		if ((_ownerId > 0) || (clan == null))
+		{
 			return;
 			return;
+		}
 		_ownerId = clan.getClanId();
 		_ownerId = clan.getClanId();
 		_isFree = false;
 		_isFree = false;
 		clan.setHideoutId(getId());
 		clan.setHideoutId(getId());
@@ -349,17 +380,19 @@ public abstract class ClanHall
 		clan.broadcastToOnlineMembers(new PledgeShowInfoUpdate(clan));
 		clan.broadcastToOnlineMembers(new PledgeShowInfoUpdate(clan));
 		updateDb();
 		updateDb();
 	}
 	}
-		
+	
 	/**
 	/**
 	 * Open or Close Door
 	 * Open or Close Door
-	 * @param activeChar 
-	 * @param doorId 
+	 * @param activeChar
+	 * @param doorId
 	 * @param open
 	 * @param open
 	 */
 	 */
 	public void openCloseDoor(L2PcInstance activeChar, int doorId, boolean open)
 	public void openCloseDoor(L2PcInstance activeChar, int doorId, boolean open)
 	{
 	{
-		if (activeChar != null && activeChar.getClanId() == getOwnerId())
+		if ((activeChar != null) && (activeChar.getClanId() == getOwnerId()))
+		{
 			openCloseDoor(doorId, open);
 			openCloseDoor(doorId, open);
+		}
 	}
 	}
 	
 	
 	public void openCloseDoor(int doorId, boolean open)
 	public void openCloseDoor(int doorId, boolean open)
@@ -372,16 +405,22 @@ public abstract class ClanHall
 		if (door != null)
 		if (door != null)
 		{
 		{
 			if (open)
 			if (open)
+			{
 				door.openMe();
 				door.openMe();
+			}
 			else
 			else
+			{
 				door.closeMe();
 				door.closeMe();
+			}
 		}
 		}
 	}
 	}
 	
 	
 	public void openCloseDoors(L2PcInstance activeChar, boolean open)
 	public void openCloseDoors(L2PcInstance activeChar, boolean open)
 	{
 	{
-		if (activeChar != null && activeChar.getClanId() == getOwnerId())
+		if ((activeChar != null) && (activeChar.getClanId() == getOwnerId()))
+		{
 			openCloseDoors(open);
 			openCloseDoors(open);
+		}
 	}
 	}
 	
 	
 	public void openCloseDoors(boolean open)
 	public void openCloseDoors(boolean open)
@@ -391,9 +430,13 @@ public abstract class ClanHall
 			if (door != null)
 			if (door != null)
 			{
 			{
 				if (open)
 				if (open)
+				{
 					door.openMe();
 					door.openMe();
+				}
 				else
 				else
+				{
 					door.closeMe();
 					door.closeMe();
+				}
 			}
 			}
 		}
 		}
 	}
 	}
@@ -449,25 +492,37 @@ public abstract class ClanHall
 	public boolean updateFunctions(L2PcInstance player, int type, int lvl, int lease, long rate, boolean addNew)
 	public boolean updateFunctions(L2PcInstance player, int type, int lvl, int lease, long rate, boolean addNew)
 	{
 	{
 		if (player == null)
 		if (player == null)
+		{
 			return false;
 			return false;
+		}
 		if (Config.DEBUG)
 		if (Config.DEBUG)
+		{
 			_log.warning("Called ClanHall.updateFunctions(int type, int lvl, int lease, long rate, boolean addNew) Owner : " + getOwnerId());
 			_log.warning("Called ClanHall.updateFunctions(int type, int lvl, int lease, long rate, boolean addNew) Owner : " + getOwnerId());
+		}
 		if (lease > 0)
 		if (lease > 0)
 		{
 		{
 			if (!player.destroyItemByItemId("Consume", PcInventory.ADENA_ID, lease, null, true))
 			if (!player.destroyItemByItemId("Consume", PcInventory.ADENA_ID, lease, null, true))
+			{
 				return false;
 				return false;
+			}
 		}
 		}
 		if (addNew)
 		if (addNew)
+		{
 			_functions.put(type, new ClanHallFunction(type, lvl, lease, 0, rate, 0, false));
 			_functions.put(type, new ClanHallFunction(type, lvl, lease, 0, rate, 0, false));
+		}
 		else
 		else
 		{
 		{
-			if (lvl == 0 && lease == 0)
+			if ((lvl == 0) && (lease == 0))
+			{
 				removeFunction(type);
 				removeFunction(type);
+			}
 			else
 			else
 			{
 			{
 				int diffLease = lease - _functions.get(type).getLease();
 				int diffLease = lease - _functions.get(type).getLease();
 				if (Config.DEBUG)
 				if (Config.DEBUG)
+				{
 					_log.warning("Called ClanHall.updateFunctions diffLease : " + diffLease);
 					_log.warning("Called ClanHall.updateFunctions diffLease : " + diffLease);
+				}
 				if (diffLease > 0)
 				if (diffLease > 0)
 				{
 				{
 					_functions.remove(type);
 					_functions.remove(type);

+ 3 - 6
L2J_Server_BETA/java/com/l2jserver/gameserver/model/entity/Couple.java

@@ -45,11 +45,9 @@ public class Couple
 		
 		
 		try (Connection con = L2DatabaseFactory.getInstance().getConnection())
 		try (Connection con = L2DatabaseFactory.getInstance().getConnection())
 		{
 		{
-			PreparedStatement statement;
-			ResultSet rs;
-			statement = con.prepareStatement("SELECT * FROM mods_wedding WHERE id = ?");
+			PreparedStatement statement = con.prepareStatement("SELECT * FROM mods_wedding WHERE id = ?");
 			statement.setInt(1, _Id);
 			statement.setInt(1, _Id);
-			rs = statement.executeQuery();
+			ResultSet rs = statement.executeQuery();
 			
 			
 			while (rs.next())
 			while (rs.next())
 			{
 			{
@@ -88,9 +86,8 @@ public class Couple
 		
 		
 		try (Connection con = L2DatabaseFactory.getInstance().getConnection())
 		try (Connection con = L2DatabaseFactory.getInstance().getConnection())
 		{
 		{
-			PreparedStatement statement;
 			_Id = IdFactory.getInstance().getNextId();
 			_Id = IdFactory.getInstance().getNextId();
-			statement = con.prepareStatement("INSERT INTO mods_wedding (id, player1Id, player2Id, married, affianceDate, weddingDate) VALUES (?, ?, ?, ?, ?, ?)");
+			PreparedStatement statement = con.prepareStatement("INSERT INTO mods_wedding (id, player1Id, player2Id, married, affianceDate, weddingDate) VALUES (?, ?, ?, ?, ?, ?)");
 			statement.setInt(1, _Id);
 			statement.setInt(1, _Id);
 			statement.setInt(2, _player1Id);
 			statement.setInt(2, _player1Id);
 			statement.setInt(3, _player2Id);
 			statement.setInt(3, _player2Id);

+ 78 - 20
L2J_Server_BETA/java/com/l2jserver/gameserver/model/entity/DimensionalRift.java

@@ -41,7 +41,7 @@ public class DimensionalRift
 	protected L2Party _party;
 	protected L2Party _party;
 	protected FastList<Byte> _completedRooms = new FastList<>();
 	protected FastList<Byte> _completedRooms = new FastList<>();
 	private static final long seconds_5 = 5000L;
 	private static final long seconds_5 = 5000L;
-	//private static final int MILLISECONDS_IN_MINUTE = 60000;
+	// private static final int MILLISECONDS_IN_MINUTE = 60000;
 	protected byte jumps_current = 0;
 	protected byte jumps_current = 0;
 	
 	
 	private Timer teleporterTimer;
 	private Timer teleporterTimer;
@@ -72,9 +72,13 @@ public class DimensionalRift
 			{
 			{
 				QuestState qs = p.getQuestState(riftQuest.getName());
 				QuestState qs = p.getQuestState(riftQuest.getName());
 				if (qs == null)
 				if (qs == null)
+				{
 					qs = riftQuest.newQuestState(p);
 					qs = riftQuest.newQuestState(p);
-				if (qs.getInt("cond") != 1)
-					qs.set("cond", "1");
+				}
+				if (qs.getCond() != 1)
+				{
+					qs.setCond(1);
+				}
 			}
 			}
 			p.teleToLocation(coords[0], coords[1], coords[2]);
 			p.teleToLocation(coords[0], coords[1], coords[2]);
 		}
 		}
@@ -113,14 +117,17 @@ public class DimensionalRift
 		}
 		}
 		
 		
 		teleporterTimer = new Timer();
 		teleporterTimer = new Timer();
-		teleporterTimerTask = new TimerTask() {
+		teleporterTimerTask = new TimerTask()
+		{
 			@Override
 			@Override
 			public void run()
 			public void run()
 			{
 			{
 				if (_choosenRoom > -1)
 				if (_choosenRoom > -1)
+				{
 					DimensionalRiftManager.getInstance().getRoom(_type, _choosenRoom).unspawn().setPartyInside(false);
 					DimensionalRiftManager.getInstance().getRoom(_type, _choosenRoom).unspawn().setPartyInside(false);
+				}
 				
 				
-				if (reasonTP && jumps_current < getMaxJumps() && _party.getMemberCount() > deadPlayers.size())
+				if (reasonTP && (jumps_current < getMaxJumps()) && (_party.getMemberCount() > deadPlayers.size()))
 				{
 				{
 					jumps_current++;
 					jumps_current++;
 					
 					
@@ -128,16 +135,24 @@ public class DimensionalRift
 					_choosenRoom = -1;
 					_choosenRoom = -1;
 					
 					
 					for (L2PcInstance p : _party.getMembers())
 					for (L2PcInstance p : _party.getMembers())
+					{
 						if (!revivedInWaitingRoom.contains(p))
 						if (!revivedInWaitingRoom.contains(p))
+						{
 							teleportToNextRoom(p);
 							teleportToNextRoom(p);
+						}
+					}
 					createTeleporterTimer(true);
 					createTeleporterTimer(true);
 					createSpawnTimer(_choosenRoom);
 					createSpawnTimer(_choosenRoom);
 				}
 				}
 				else
 				else
 				{
 				{
 					for (L2PcInstance p : _party.getMembers())
 					for (L2PcInstance p : _party.getMembers())
+					{
 						if (!revivedInWaitingRoom.contains(p))
 						if (!revivedInWaitingRoom.contains(p))
+						{
 							teleportToWaitingRoom(p);
 							teleportToWaitingRoom(p);
+						}
+					}
 					killRift();
 					killRift();
 					cancel();
 					cancel();
 				}
 				}
@@ -147,21 +162,27 @@ public class DimensionalRift
 		if (reasonTP)
 		if (reasonTP)
 		{
 		{
 			long jumpTime = calcTimeToNextJump();
 			long jumpTime = calcTimeToNextJump();
-			teleporterTimer.schedule(teleporterTimerTask, jumpTime); //Teleporter task, 8-10 minutes
+			teleporterTimer.schedule(teleporterTimerTask, jumpTime); // Teleporter task, 8-10 minutes
 			
 			
-			earthQuakeTask = ThreadPoolManager.getInstance().scheduleGeneral(new Runnable() {
+			earthQuakeTask = ThreadPoolManager.getInstance().scheduleGeneral(new Runnable()
+			{
 				@Override
 				@Override
 				public void run()
 				public void run()
 				{
 				{
 					for (L2PcInstance p : _party.getMembers())
 					for (L2PcInstance p : _party.getMembers())
+					{
 						if (!revivedInWaitingRoom.contains(p))
 						if (!revivedInWaitingRoom.contains(p))
+						{
 							p.sendPacket(new Earthquake(p.getX(), p.getY(), p.getZ(), 65, 9));
 							p.sendPacket(new Earthquake(p.getX(), p.getY(), p.getZ(), 65, 9));
+						}
+					}
 				}
 				}
-			}
-			, jumpTime - 7000);
+			}, jumpTime - 7000);
 		}
 		}
 		else
 		else
-			teleporterTimer.schedule(teleporterTimerTask, seconds_5); //incorrect party member invited.
+		{
+			teleporterTimer.schedule(teleporterTimerTask, seconds_5); // incorrect party member invited.
+		}
 	}
 	}
 	
 	
 	public void createSpawnTimer(final byte room)
 	public void createSpawnTimer(final byte room)
@@ -179,7 +200,8 @@ public class DimensionalRift
 		}
 		}
 		
 		
 		spawnTimer = new Timer();
 		spawnTimer = new Timer();
-		spawnTimerTask = new TimerTask() {
+		spawnTimerTask = new TimerTask()
+		{
 			@Override
 			@Override
 			public void run()
 			public void run()
 			{
 			{
@@ -198,15 +220,21 @@ public class DimensionalRift
 	public void partyMemberExited(L2PcInstance player)
 	public void partyMemberExited(L2PcInstance player)
 	{
 	{
 		if (deadPlayers.contains(player))
 		if (deadPlayers.contains(player))
+		{
 			deadPlayers.remove(player);
 			deadPlayers.remove(player);
+		}
 		
 		
 		if (revivedInWaitingRoom.contains(player))
 		if (revivedInWaitingRoom.contains(player))
+		{
 			revivedInWaitingRoom.remove(player);
 			revivedInWaitingRoom.remove(player);
+		}
 		
 		
-		if (_party.getMemberCount() < Config.RIFT_MIN_PARTY_SIZE || _party.getMemberCount() == 1)
+		if ((_party.getMemberCount() < Config.RIFT_MIN_PARTY_SIZE) || (_party.getMemberCount() == 1))
 		{
 		{
 			for (L2PcInstance p : _party.getMembers())
 			for (L2PcInstance p : _party.getMembers())
+			{
 				teleportToWaitingRoom(p);
 				teleportToWaitingRoom(p);
+			}
 			killRift();
 			killRift();
 		}
 		}
 	}
 	}
@@ -214,7 +242,9 @@ public class DimensionalRift
 	public void manualTeleport(L2PcInstance player, L2Npc npc)
 	public void manualTeleport(L2PcInstance player, L2Npc npc)
 	{
 	{
 		if (!player.isInParty() || !player.getParty().isInDimensionalRift())
 		if (!player.isInParty() || !player.getParty().isInDimensionalRift())
+		{
 			return;
 			return;
+		}
 		
 		
 		if (player.getObjectId() != player.getParty().getLeaderObjectId())
 		if (player.getObjectId() != player.getParty().getLeaderObjectId())
 		{
 		{
@@ -234,7 +264,9 @@ public class DimensionalRift
 		_choosenRoom = -1;
 		_choosenRoom = -1;
 		
 		
 		for (L2PcInstance p : _party.getMembers())
 		for (L2PcInstance p : _party.getMembers())
+		{
 			teleportToNextRoom(p);
 			teleportToNextRoom(p);
+		}
 		
 		
 		DimensionalRiftManager.getInstance().getRoom(_type, _choosenRoom).setPartyInside(true);
 		DimensionalRiftManager.getInstance().getRoom(_type, _choosenRoom).setPartyInside(true);
 		
 		
@@ -245,7 +277,9 @@ public class DimensionalRift
 	public void manualExitRift(L2PcInstance player, L2Npc npc)
 	public void manualExitRift(L2PcInstance player, L2Npc npc)
 	{
 	{
 		if (!player.isInParty() || !player.getParty().isInDimensionalRift())
 		if (!player.isInParty() || !player.getParty().isInDimensionalRift())
+		{
 			return;
 			return;
+		}
 		
 		
 		if (player.getObjectId() != player.getParty().getLeaderObjectId())
 		if (player.getObjectId() != player.getParty().getLeaderObjectId())
 		{
 		{
@@ -254,7 +288,9 @@ public class DimensionalRift
 		}
 		}
 		
 		
 		for (L2PcInstance p : player.getParty().getMembers())
 		for (L2PcInstance p : player.getParty().getMembers())
+		{
 			teleportToWaitingRoom(p);
 			teleportToWaitingRoom(p);
+		}
 		killRift();
 		killRift();
 	}
 	}
 	
 	
@@ -271,8 +307,10 @@ public class DimensionalRift
 				emptyRooms.removeAll(_completedRooms);
 				emptyRooms.removeAll(_completedRooms);
 				// If no room left, find any empty
 				// If no room left, find any empty
 				if (emptyRooms.isEmpty())
 				if (emptyRooms.isEmpty())
+				{
 					emptyRooms = DimensionalRiftManager.getInstance().getFreeRooms(_type);
 					emptyRooms = DimensionalRiftManager.getInstance().getFreeRooms(_type);
-				_choosenRoom = emptyRooms.get(Rnd.get(1, emptyRooms.size())-1);
+				}
+				_choosenRoom = emptyRooms.get(Rnd.get(1, emptyRooms.size()) - 1);
 			}
 			}
 			while (DimensionalRiftManager.getInstance().getRoom(_type, _choosenRoom).ispartyInside());
 			while (DimensionalRiftManager.getInstance().getRoom(_type, _choosenRoom).ispartyInside());
 		}
 		}
@@ -290,8 +328,10 @@ public class DimensionalRift
 		if (riftQuest != null)
 		if (riftQuest != null)
 		{
 		{
 			QuestState qs = player.getQuestState(riftQuest.getName());
 			QuestState qs = player.getQuestState(riftQuest.getName());
-			if (qs != null && qs.getInt("cond") == 1)
+			if ((qs != null) && (qs.getInt("cond") == 1))
+			{
 				qs.set("cond", "0");
 				qs.set("cond", "0");
+			}
 		}
 		}
 	}
 	}
 	
 	
@@ -300,7 +340,9 @@ public class DimensionalRift
 		_completedRooms = null;
 		_completedRooms = null;
 		
 		
 		if (_party != null)
 		if (_party != null)
+		{
 			_party.setDimensionalRift(null);
 			_party.setDimensionalRift(null);
+		}
 		
 		
 		_party = null;
 		_party = null;
 		revivedInWaitingRoom = null;
 		revivedInWaitingRoom = null;
@@ -361,39 +403,53 @@ public class DimensionalRift
 		int time = Rnd.get(Config.RIFT_AUTO_JUMPS_TIME_MIN, Config.RIFT_AUTO_JUMPS_TIME_MAX) * 1000;
 		int time = Rnd.get(Config.RIFT_AUTO_JUMPS_TIME_MIN, Config.RIFT_AUTO_JUMPS_TIME_MAX) * 1000;
 		
 		
 		if (isBossRoom)
 		if (isBossRoom)
+		{
 			return (long) (time * Config.RIFT_BOSS_ROOM_TIME_MUTIPLY);
 			return (long) (time * Config.RIFT_BOSS_ROOM_TIME_MUTIPLY);
+		}
 		return time;
 		return time;
 	}
 	}
 	
 	
 	public void memberDead(L2PcInstance player)
 	public void memberDead(L2PcInstance player)
 	{
 	{
 		if (!deadPlayers.contains(player))
 		if (!deadPlayers.contains(player))
+		{
 			deadPlayers.add(player);
 			deadPlayers.add(player);
+		}
 	}
 	}
 	
 	
 	public void memberRessurected(L2PcInstance player)
 	public void memberRessurected(L2PcInstance player)
 	{
 	{
 		if (deadPlayers.contains(player))
 		if (deadPlayers.contains(player))
+		{
 			deadPlayers.remove(player);
 			deadPlayers.remove(player);
+		}
 	}
 	}
 	
 	
 	public void usedTeleport(L2PcInstance player)
 	public void usedTeleport(L2PcInstance player)
 	{
 	{
 		if (!revivedInWaitingRoom.contains(player))
 		if (!revivedInWaitingRoom.contains(player))
+		{
 			revivedInWaitingRoom.add(player);
 			revivedInWaitingRoom.add(player);
+		}
 		
 		
 		if (!deadPlayers.contains(player))
 		if (!deadPlayers.contains(player))
+		{
 			deadPlayers.add(player);
 			deadPlayers.add(player);
+		}
 		
 		
-		if (_party.getMemberCount() - revivedInWaitingRoom.size() < Config.RIFT_MIN_PARTY_SIZE)
+		if ((_party.getMemberCount() - revivedInWaitingRoom.size()) < Config.RIFT_MIN_PARTY_SIZE)
 		{
 		{
-			//int pcm = _party.getMemberCount();
-			//int rev = revivedInWaitingRoom.size();
-			//int min = Config.RIFT_MIN_PARTY_SIZE;
+			// int pcm = _party.getMemberCount();
+			// int rev = revivedInWaitingRoom.size();
+			// int min = Config.RIFT_MIN_PARTY_SIZE;
 			
 			
 			for (L2PcInstance p : _party.getMembers())
 			for (L2PcInstance p : _party.getMembers())
-				if (p != null && !revivedInWaitingRoom.contains(p))
+			{
+				if ((p != null) && !revivedInWaitingRoom.contains(p))
+				{
 					teleportToWaitingRoom(p);
 					teleportToWaitingRoom(p);
+				}
+			}
 			killRift();
 			killRift();
 		}
 		}
 	}
 	}
@@ -420,8 +476,10 @@ public class DimensionalRift
 	
 	
 	public byte getMaxJumps()
 	public byte getMaxJumps()
 	{
 	{
-		if (Config.RIFT_MAX_JUMPS <= 8 && Config.RIFT_MAX_JUMPS >= 1)
+		if ((Config.RIFT_MAX_JUMPS <= 8) && (Config.RIFT_MAX_JUMPS >= 1))
+		{
 			return (byte) Config.RIFT_MAX_JUMPS;
 			return (byte) Config.RIFT_MAX_JUMPS;
+		}
 		return 4;
 		return 4;
 	}
 	}
 }
 }

+ 126 - 38
L2J_Server_BETA/java/com/l2jserver/gameserver/model/entity/Duel.java

@@ -47,11 +47,11 @@ public class Duel
 	public static final int DUELSTATE_WINNER = 3;
 	public static final int DUELSTATE_WINNER = 3;
 	public static final int DUELSTATE_INTERRUPTED = 4;
 	public static final int DUELSTATE_INTERRUPTED = 4;
 	
 	
-	private int _duelId;
+	private final int _duelId;
 	private L2PcInstance _playerA;
 	private L2PcInstance _playerA;
 	private L2PcInstance _playerB;
 	private L2PcInstance _playerB;
-	private boolean _partyDuel;
-	private Calendar _duelEndTime;
+	private final boolean _partyDuel;
+	private final Calendar _duelEndTime;
 	private int _surrenderRequest = 0;
 	private int _surrenderRequest = 0;
 	private int _countdown = 4;
 	private int _countdown = 4;
 	private boolean _finished = false;
 	private boolean _finished = false;
@@ -78,9 +78,13 @@ public class Duel
 		
 		
 		_duelEndTime = Calendar.getInstance();
 		_duelEndTime = Calendar.getInstance();
 		if (_partyDuel)
 		if (_partyDuel)
+		{
 			_duelEndTime.add(Calendar.SECOND, 300);
 			_duelEndTime.add(Calendar.SECOND, 300);
+		}
 		else
 		else
+		{
 			_duelEndTime.add(Calendar.SECOND, 120);
 			_duelEndTime.add(Calendar.SECOND, 120);
+		}
 		
 		
 		_playerConditions = new FastList<>();
 		_playerConditions = new FastList<>();
 		
 		
@@ -112,7 +116,9 @@ public class Duel
 		public PlayerCondition(L2PcInstance player, boolean partyDuel)
 		public PlayerCondition(L2PcInstance player, boolean partyDuel)
 		{
 		{
 			if (player == null)
 			if (player == null)
+			{
 				return;
 				return;
+			}
 			_player = player;
 			_player = player;
 			_hp = _player.getCurrentHp();
 			_hp = _player.getCurrentHp();
 			_mp = _player.getCurrentMp();
 			_mp = _player.getCurrentMp();
@@ -130,7 +136,9 @@ public class Duel
 		public void restoreCondition()
 		public void restoreCondition()
 		{
 		{
 			if (_player == null)
 			if (_player == null)
+			{
 				return;
 				return;
+			}
 			_player.setCurrentHp(_hp);
 			_player.setCurrentHp(_hp);
 			_player.setCurrentMp(_mp);
 			_player.setCurrentMp(_mp);
 			_player.setCurrentCp(_cp);
 			_player.setCurrentCp(_cp);
@@ -142,15 +150,21 @@ public class Duel
 			if (_debuffs != null) // Debuff removal
 			if (_debuffs != null) // Debuff removal
 			{
 			{
 				for (L2Effect temp : _debuffs)
 				for (L2Effect temp : _debuffs)
+				{
 					if (temp != null)
 					if (temp != null)
+					{
 						temp.exit();
 						temp.exit();
+					}
+				}
 			}
 			}
 		}
 		}
 		
 		
 		public void registerDebuff(L2Effect debuff)
 		public void registerDebuff(L2Effect debuff)
 		{
 		{
 			if (_debuffs == null)
 			if (_debuffs == null)
+			{
 				_debuffs = new FastList<>();
 				_debuffs = new FastList<>();
+			}
 			
 			
 			_debuffs.add(debuff);
 			_debuffs.add(debuff);
 		}
 		}
@@ -158,7 +172,9 @@ public class Duel
 		public void teleportBack()
 		public void teleportBack()
 		{
 		{
 			if (_paDuel)
 			if (_paDuel)
+			{
 				_player.teleToLocation(_x, _y, _z);
 				_player.teleToLocation(_x, _y, _z);
+			}
 		}
 		}
 		
 		
 		public L2PcInstance getPlayer()
 		public L2PcInstance getPlayer()
@@ -169,7 +185,7 @@ public class Duel
 	
 	
 	public class ScheduleDuelTask implements Runnable
 	public class ScheduleDuelTask implements Runnable
 	{
 	{
-		private Duel _duel;
+		private final Duel _duel;
 		
 		
 		public ScheduleDuelTask(Duel duel)
 		public ScheduleDuelTask(Duel duel)
 		{
 		{
@@ -196,7 +212,9 @@ public class Duel
 					ThreadPoolManager.getInstance().scheduleGeneral(new ScheduleEndDuelTask(_duel, status), 5000);
 					ThreadPoolManager.getInstance().scheduleGeneral(new ScheduleEndDuelTask(_duel, status), 5000);
 				}
 				}
 				else
 				else
+				{
 					ThreadPoolManager.getInstance().scheduleGeneral(this, 1000);
 					ThreadPoolManager.getInstance().scheduleGeneral(this, 1000);
+				}
 			}
 			}
 			catch (Exception e)
 			catch (Exception e)
 			{
 			{
@@ -207,7 +225,7 @@ public class Duel
 	
 	
 	public static class ScheduleStartDuelTask implements Runnable
 	public static class ScheduleStartDuelTask implements Runnable
 	{
 	{
-		private Duel _duel;
+		private final Duel _duel;
 		
 		
 		public ScheduleStartDuelTask(Duel duel)
 		public ScheduleStartDuelTask(Duel duel)
 		{
 		{
@@ -225,7 +243,7 @@ public class Duel
 				if (count == 4)
 				if (count == 4)
 				{
 				{
 					// players need to be teleportet first
 					// players need to be teleportet first
-					//TODO: stadia manager needs a function to return an unused stadium for duels
+					// TODO: stadia manager needs a function to return an unused stadium for duels
 					// currently only teleports to the same stadium
 					// currently only teleports to the same stadium
 					_duel.teleportPlayers(-83760, -238825, -3331);
 					_duel.teleportPlayers(-83760, -238825, -3331);
 					
 					
@@ -237,7 +255,9 @@ public class Duel
 					ThreadPoolManager.getInstance().scheduleGeneral(this, 1000);
 					ThreadPoolManager.getInstance().scheduleGeneral(this, 1000);
 				}
 				}
 				else
 				else
+				{
 					_duel.startDuel();
 					_duel.startDuel();
+				}
 			}
 			}
 			catch (Exception e)
 			catch (Exception e)
 			{
 			{
@@ -248,8 +268,8 @@ public class Duel
 	
 	
 	public static class ScheduleEndDuelTask implements Runnable
 	public static class ScheduleEndDuelTask implements Runnable
 	{
 	{
-		private Duel _duel;
-		private DuelResultEnum _result;
+		private final Duel _duel;
+		private final DuelResultEnum _result;
 		
 		
 		public ScheduleEndDuelTask(Duel duel, DuelResultEnum result)
 		public ScheduleEndDuelTask(Duel duel, DuelResultEnum result)
 		{
 		{
@@ -272,9 +292,7 @@ public class Duel
 	}
 	}
 	
 	
 	/**
 	/**
-	 * Stops all players from attacking.
-	 * Used for duel timeout / interrupt.
-	 *
+	 * Stops all players from attacking. Used for duel timeout / interrupt.
 	 */
 	 */
 	private void stopFighting()
 	private void stopFighting()
 	{
 	{
@@ -311,7 +329,7 @@ public class Duel
 	
 	
 	/**
 	/**
 	 * Check if a player engaged in pvp combat (only for 1on1 duels)
 	 * Check if a player engaged in pvp combat (only for 1on1 duels)
-	 * @param sendMessage 
+	 * @param sendMessage
 	 * @return returns true if a duelist is engaged in Pvp combat
 	 * @return returns true if a duelist is engaged in Pvp combat
 	 */
 	 */
 	public boolean isDuelistInPvp(boolean sendMessage)
 	public boolean isDuelistInPvp(boolean sendMessage)
@@ -321,7 +339,7 @@ public class Duel
 			// Party duels take place in arenas - should be no other players there
 			// Party duels take place in arenas - should be no other players there
 			return false;
 			return false;
 		}
 		}
-		else if (_playerA.getPvpFlag() != 0 || _playerB.getPvpFlag() != 0)
+		else if ((_playerA.getPvpFlag() != 0) || (_playerB.getPvpFlag() != 0))
 		{
 		{
 			if (sendMessage)
 			if (sendMessage)
 			{
 			{
@@ -336,14 +354,13 @@ public class Duel
 	
 	
 	/**
 	/**
 	 * Starts the duel
 	 * Starts the duel
-	 *
 	 */
 	 */
 	public void startDuel()
 	public void startDuel()
 	{
 	{
 		// Save player Conditions
 		// Save player Conditions
 		savePlayerConditions();
 		savePlayerConditions();
 		
 		
-		if (_playerA == null || _playerB == null || _playerA.isInDuel() || _playerB.isInDuel())
+		if ((_playerA == null) || (_playerB == null) || _playerA.isInDuel() || _playerB.isInDuel())
 		{
 		{
 			// clean up
 			// clean up
 			_playerConditions.clear();
 			_playerConditions.clear();
@@ -417,7 +434,6 @@ public class Duel
 	
 	
 	/**
 	/**
 	 * Save the current player condition: hp, mp, cp, location
 	 * Save the current player condition: hp, mp, cp, location
-	 *
 	 */
 	 */
 	public void savePlayerConditions()
 	public void savePlayerConditions()
 	{
 	{
@@ -473,7 +489,9 @@ public class Duel
 		
 		
 		// if it is an abnormal DuelEnd do not restore hp, mp, cp
 		// if it is an abnormal DuelEnd do not restore hp, mp, cp
 		if (abnormalDuelEnd)
 		if (abnormalDuelEnd)
+		{
 			return;
 			return;
+		}
 		
 		
 		// restore player conditions
 		// restore player conditions
 		for (FastList.Node<PlayerCondition> e = _playerConditions.head(), end = _playerConditions.tail(); (e = e.getNext()) != end;)
 		for (FastList.Node<PlayerCondition> e = _playerConditions.head(), end = _playerConditions.tail(); (e = e.getNext()) != end;)
@@ -545,58 +563,72 @@ public class Duel
 	 */
 	 */
 	public void teleportPlayers(int x, int y, int z)
 	public void teleportPlayers(int x, int y, int z)
 	{
 	{
-		//TODO: adjust the values if needed... or implement something better (especially using more then 1 arena)
+		// TODO: adjust the values if needed... or implement something better (especially using more then 1 arena)
 		if (!_partyDuel)
 		if (!_partyDuel)
+		{
 			return;
 			return;
+		}
 		int offset = 0;
 		int offset = 0;
 		
 		
 		for (L2PcInstance temp : _playerA.getParty().getMembers())
 		for (L2PcInstance temp : _playerA.getParty().getMembers())
 		{
 		{
-			temp.teleToLocation(x + offset - 180, y - 150, z);
+			temp.teleToLocation((x + offset) - 180, y - 150, z);
 			offset += 40;
 			offset += 40;
 		}
 		}
 		offset = 0;
 		offset = 0;
 		for (L2PcInstance temp : _playerB.getParty().getMembers())
 		for (L2PcInstance temp : _playerB.getParty().getMembers())
 		{
 		{
-			temp.teleToLocation(x + offset - 180, y + 150, z);
+			temp.teleToLocation((x + offset) - 180, y + 150, z);
 			offset += 40;
 			offset += 40;
 		}
 		}
 	}
 	}
 	
 	
 	/**
 	/**
 	 * Broadcast a packet to the challenger team
 	 * Broadcast a packet to the challenger team
-	 * @param packet 
+	 * @param packet
 	 */
 	 */
 	public void broadcastToTeam1(L2GameServerPacket packet)
 	public void broadcastToTeam1(L2GameServerPacket packet)
 	{
 	{
 		if (_playerA == null)
 		if (_playerA == null)
+		{
 			return;
 			return;
+		}
 		
 		
-		if (_partyDuel && _playerA.getParty() != null)
+		if (_partyDuel && (_playerA.getParty() != null))
 		{
 		{
 			for (L2PcInstance temp : _playerA.getParty().getMembers())
 			for (L2PcInstance temp : _playerA.getParty().getMembers())
+			{
 				temp.sendPacket(packet);
 				temp.sendPacket(packet);
+			}
 		}
 		}
 		else
 		else
+		{
 			_playerA.sendPacket(packet);
 			_playerA.sendPacket(packet);
+		}
 	}
 	}
 	
 	
 	/**
 	/**
 	 * Broadcast a packet to the challenged team
 	 * Broadcast a packet to the challenged team
-	 * @param packet 
+	 * @param packet
 	 */
 	 */
 	public void broadcastToTeam2(L2GameServerPacket packet)
 	public void broadcastToTeam2(L2GameServerPacket packet)
 	{
 	{
 		if (_playerB == null)
 		if (_playerB == null)
+		{
 			return;
 			return;
+		}
 		
 		
-		if (_partyDuel && _playerB.getParty() != null)
+		if (_partyDuel && (_playerB.getParty() != null))
 		{
 		{
 			for (L2PcInstance temp : _playerB.getParty().getMembers())
 			for (L2PcInstance temp : _playerB.getParty().getMembers())
+			{
 				temp.sendPacket(packet);
 				temp.sendPacket(packet);
+			}
 		}
 		}
 		else
 		else
+		{
 			_playerB.sendPacket(packet);
 			_playerB.sendPacket(packet);
+		}
 	}
 	}
 	
 	
 	/**
 	/**
@@ -605,12 +637,18 @@ public class Duel
 	 */
 	 */
 	public L2PcInstance getWinner()
 	public L2PcInstance getWinner()
 	{
 	{
-		if (!getFinished() || _playerA == null || _playerB == null)
+		if (!getFinished() || (_playerA == null) || (_playerB == null))
+		{
 			return null;
 			return null;
+		}
 		if (_playerA.getDuelState() == DUELSTATE_WINNER)
 		if (_playerA.getDuelState() == DUELSTATE_WINNER)
+		{
 			return _playerA;
 			return _playerA;
+		}
 		if (_playerB.getDuelState() == DUELSTATE_WINNER)
 		if (_playerB.getDuelState() == DUELSTATE_WINNER)
+		{
 			return _playerB;
 			return _playerB;
+		}
 		return null;
 		return null;
 	}
 	}
 	
 	
@@ -620,33 +658,44 @@ public class Duel
 	 */
 	 */
 	public L2PcInstance getLooser()
 	public L2PcInstance getLooser()
 	{
 	{
-		if (!getFinished() || _playerA == null || _playerB == null)
+		if (!getFinished() || (_playerA == null) || (_playerB == null))
+		{
 			return null;
 			return null;
+		}
 		if (_playerA.getDuelState() == DUELSTATE_WINNER)
 		if (_playerA.getDuelState() == DUELSTATE_WINNER)
+		{
 			return _playerB;
 			return _playerB;
+		}
 		else if (_playerB.getDuelState() == DUELSTATE_WINNER)
 		else if (_playerB.getDuelState() == DUELSTATE_WINNER)
+		{
 			return _playerA;
 			return _playerA;
+		}
 		return null;
 		return null;
 	}
 	}
 	
 	
 	/**
 	/**
 	 * Playback the bow animation for all loosers
 	 * Playback the bow animation for all loosers
-	 *
 	 */
 	 */
 	public void playKneelAnimation()
 	public void playKneelAnimation()
 	{
 	{
 		L2PcInstance looser = getLooser();
 		L2PcInstance looser = getLooser();
 		
 		
 		if (looser == null)
 		if (looser == null)
+		{
 			return;
 			return;
+		}
 		
 		
-		if (_partyDuel && looser.getParty() != null)
+		if (_partyDuel && (looser.getParty() != null))
 		{
 		{
 			for (L2PcInstance temp : looser.getParty().getMembers())
 			for (L2PcInstance temp : looser.getParty().getMembers())
+			{
 				temp.broadcastPacket(new SocialAction(temp.getObjectId(), 7));
 				temp.broadcastPacket(new SocialAction(temp.getObjectId(), 7));
+			}
 		}
 		}
 		else
 		else
+		{
 			looser.broadcastPacket(new SocialAction(looser.getObjectId(), 7));
 			looser.broadcastPacket(new SocialAction(looser.getObjectId(), 7));
+		}
 	}
 	}
 	
 	
 	/**
 	/**
@@ -658,7 +707,9 @@ public class Duel
 		_countdown--;
 		_countdown--;
 		
 		
 		if (_countdown > 3)
 		if (_countdown > 3)
+		{
 			return _countdown;
 			return _countdown;
+		}
 		
 		
 		// Broadcast countdown to duelists
 		// Broadcast countdown to duelists
 		SystemMessage sm = null;
 		SystemMessage sm = null;
@@ -668,7 +719,9 @@ public class Duel
 			sm.addNumber(_countdown);
 			sm.addNumber(_countdown);
 		}
 		}
 		else
 		else
+		{
 			sm = SystemMessage.getSystemMessage(SystemMessageId.LET_THE_DUEL_BEGIN);
 			sm = SystemMessage.getSystemMessage(SystemMessageId.LET_THE_DUEL_BEGIN);
+		}
 		
 		
 		broadcastToTeam1(sm);
 		broadcastToTeam1(sm);
 		broadcastToTeam2(sm);
 		broadcastToTeam2(sm);
@@ -682,9 +735,9 @@ public class Duel
 	 */
 	 */
 	public void endDuel(DuelResultEnum result)
 	public void endDuel(DuelResultEnum result)
 	{
 	{
-		if (_playerA == null || _playerB == null)
+		if ((_playerA == null) || (_playerB == null))
 		{
 		{
-			//clean up
+			// clean up
 			_playerConditions.clear();
 			_playerConditions.clear();
 			_playerConditions = null;
 			_playerConditions = null;
 			DuelManager.getInstance().removeDuel(this);
 			DuelManager.getInstance().removeDuel(this);
@@ -700,9 +753,13 @@ public class Duel
 				restorePlayerConditions(false);
 				restorePlayerConditions(false);
 				// send SystemMessage
 				// send SystemMessage
 				if (_partyDuel)
 				if (_partyDuel)
+				{
 					sm = SystemMessage.getSystemMessage(SystemMessageId.C1_PARTY_HAS_WON_THE_DUEL);
 					sm = SystemMessage.getSystemMessage(SystemMessageId.C1_PARTY_HAS_WON_THE_DUEL);
+				}
 				else
 				else
+				{
 					sm = SystemMessage.getSystemMessage(SystemMessageId.C1_HAS_WON_THE_DUEL);
 					sm = SystemMessage.getSystemMessage(SystemMessageId.C1_HAS_WON_THE_DUEL);
+				}
 				sm.addString(_playerA.getName());
 				sm.addString(_playerA.getName());
 				
 				
 				broadcastToTeam1(sm);
 				broadcastToTeam1(sm);
@@ -713,9 +770,13 @@ public class Duel
 				restorePlayerConditions(false);
 				restorePlayerConditions(false);
 				// send SystemMessage
 				// send SystemMessage
 				if (_partyDuel)
 				if (_partyDuel)
+				{
 					sm = SystemMessage.getSystemMessage(SystemMessageId.C1_PARTY_HAS_WON_THE_DUEL);
 					sm = SystemMessage.getSystemMessage(SystemMessageId.C1_PARTY_HAS_WON_THE_DUEL);
+				}
 				else
 				else
+				{
 					sm = SystemMessage.getSystemMessage(SystemMessageId.C1_HAS_WON_THE_DUEL);
 					sm = SystemMessage.getSystemMessage(SystemMessageId.C1_HAS_WON_THE_DUEL);
+				}
 				sm.addString(_playerB.getName());
 				sm.addString(_playerB.getName());
 				
 				
 				broadcastToTeam1(sm);
 				broadcastToTeam1(sm);
@@ -725,7 +786,7 @@ public class Duel
 				stopFighting();
 				stopFighting();
 				// dont restore hp, mp, cp
 				// dont restore hp, mp, cp
 				restorePlayerConditions(true);
 				restorePlayerConditions(true);
-				//TODO: is there no other message for a canceled duel?
+				// TODO: is there no other message for a canceled duel?
 				// send SystemMessage
 				// send SystemMessage
 				sm = SystemMessage.getSystemMessage(SystemMessageId.THE_DUEL_HAS_ENDED_IN_A_TIE);
 				sm = SystemMessage.getSystemMessage(SystemMessageId.THE_DUEL_HAS_ENDED_IN_A_TIE);
 				
 				
@@ -747,14 +808,18 @@ public class Duel
 		// Send end duel packet
 		// Send end duel packet
 		ExDuelEnd duelEnd = null;
 		ExDuelEnd duelEnd = null;
 		if (_partyDuel)
 		if (_partyDuel)
+		{
 			duelEnd = new ExDuelEnd(1);
 			duelEnd = new ExDuelEnd(1);
+		}
 		else
 		else
+		{
 			duelEnd = new ExDuelEnd(0);
 			duelEnd = new ExDuelEnd(0);
+		}
 		
 		
 		broadcastToTeam1(duelEnd);
 		broadcastToTeam1(duelEnd);
 		broadcastToTeam2(duelEnd);
 		broadcastToTeam2(duelEnd);
 		
 		
-		//clean up
+		// clean up
 		_playerConditions.clear();
 		_playerConditions.clear();
 		_playerConditions = null;
 		_playerConditions = null;
 		DuelManager.getInstance().removeDuel(this);
 		DuelManager.getInstance().removeDuel(this);
@@ -767,14 +832,18 @@ public class Duel
 	public DuelResultEnum checkEndDuelCondition()
 	public DuelResultEnum checkEndDuelCondition()
 	{
 	{
 		// one of the players might leave during duel
 		// one of the players might leave during duel
-		if (_playerA == null || _playerB == null)
+		if ((_playerA == null) || (_playerB == null))
+		{
 			return DuelResultEnum.Canceled;
 			return DuelResultEnum.Canceled;
+		}
 		
 		
 		// got a duel surrender request?
 		// got a duel surrender request?
 		if (_surrenderRequest != 0)
 		if (_surrenderRequest != 0)
 		{
 		{
 			if (_surrenderRequest == 1)
 			if (_surrenderRequest == 1)
+			{
 				return DuelResultEnum.Team1Surrender;
 				return DuelResultEnum.Team1Surrender;
+			}
 			return DuelResultEnum.Team2Surrender;
 			return DuelResultEnum.Team2Surrender;
 		}
 		}
 		// duel timed out
 		// duel timed out
@@ -800,21 +869,28 @@ public class Duel
 		else if (!_partyDuel)
 		else if (!_partyDuel)
 		{
 		{
 			// Duel was interrupted e.g.: player was attacked by mobs / other players
 			// Duel was interrupted e.g.: player was attacked by mobs / other players
-			if (_playerA.getDuelState() == DUELSTATE_INTERRUPTED || _playerB.getDuelState() == DUELSTATE_INTERRUPTED)
+			if ((_playerA.getDuelState() == DUELSTATE_INTERRUPTED) || (_playerB.getDuelState() == DUELSTATE_INTERRUPTED))
+			{
 				return DuelResultEnum.Canceled;
 				return DuelResultEnum.Canceled;
+			}
 			
 			
 			// Are the players too far apart?
 			// Are the players too far apart?
 			if (!_playerA.isInsideRadius(_playerB, 1600, false, false))
 			if (!_playerA.isInsideRadius(_playerB, 1600, false, false))
+			{
 				return DuelResultEnum.Canceled;
 				return DuelResultEnum.Canceled;
+			}
 			
 			
 			// Did one of the players engage in PvP combat?
 			// Did one of the players engage in PvP combat?
 			if (isDuelistInPvp(true))
 			if (isDuelistInPvp(true))
+			{
 				return DuelResultEnum.Canceled;
 				return DuelResultEnum.Canceled;
+			}
 			
 			
 			// is one of the players in a Siege, Peace or PvP zone?
 			// is one of the players in a Siege, Peace or PvP zone?
-			if (_playerA.isInsideZone(L2Character.ZONE_PEACE) || _playerB.isInsideZone(L2Character.ZONE_PEACE) || _playerA.isInsideZone(L2Character.ZONE_SIEGE) || _playerB.isInsideZone(L2Character.ZONE_SIEGE)
-					|| _playerA.isInsideZone(L2Character.ZONE_PVP) || _playerB.isInsideZone(L2Character.ZONE_PVP))
+			if (_playerA.isInsideZone(L2Character.ZONE_PEACE) || _playerB.isInsideZone(L2Character.ZONE_PEACE) || _playerA.isInsideZone(L2Character.ZONE_SIEGE) || _playerB.isInsideZone(L2Character.ZONE_SIEGE) || _playerA.isInsideZone(L2Character.ZONE_PVP) || _playerB.isInsideZone(L2Character.ZONE_PVP))
+			{
 				return DuelResultEnum.Canceled;
 				return DuelResultEnum.Canceled;
+			}
 		}
 		}
 		
 		
 		return DuelResultEnum.Continue;
 		return DuelResultEnum.Continue;
@@ -828,7 +904,9 @@ public class Duel
 	{
 	{
 		// already recived a surrender request
 		// already recived a surrender request
 		if (_surrenderRequest != 0)
 		if (_surrenderRequest != 0)
+		{
 			return;
 			return;
+		}
 		
 		
 		// stop the fight
 		// stop the fight
 		stopFighting();
 		stopFighting();
@@ -904,7 +982,9 @@ public class Duel
 			{
 			{
 				L2PcInstance winner = _playerA;
 				L2PcInstance winner = _playerA;
 				if (_playerA.getParty().getMembers().contains(player))
 				if (_playerA.getParty().getMembers().contains(player))
+				{
 					winner = _playerB;
 					winner = _playerB;
+				}
 				
 				
 				for (L2PcInstance temp : winner.getParty().getMembers())
 				for (L2PcInstance temp : winner.getParty().getMembers())
 				{
 				{
@@ -914,13 +994,19 @@ public class Duel
 		}
 		}
 		else
 		else
 		{
 		{
-			if (player != _playerA && player != _playerB)
+			if ((player != _playerA) && (player != _playerB))
+			{
 				_log.warning("Error in onPlayerDefeat(): player is not part of this 1vs1 duel");
 				_log.warning("Error in onPlayerDefeat(): player is not part of this 1vs1 duel");
+			}
 			
 			
 			if (_playerA == player)
 			if (_playerA == player)
+			{
 				_playerB.setDuelState(DUELSTATE_WINNER);
 				_playerB.setDuelState(DUELSTATE_WINNER);
+			}
 			else
 			else
+			{
 				_playerA.setDuelState(DUELSTATE_WINNER);
 				_playerA.setDuelState(DUELSTATE_WINNER);
+			}
 		}
 		}
 	}
 	}
 	
 	
@@ -932,11 +1018,13 @@ public class Duel
 	{
 	{
 		// if it isnt a party duel ignore this
 		// if it isnt a party duel ignore this
 		if (!_partyDuel)
 		if (!_partyDuel)
+		{
 			return;
 			return;
+		}
 		
 		
 		// this player is leaving his party during party duel
 		// this player is leaving his party during party duel
 		// if hes either playerA or playerB cancel the duel and port the players back
 		// if hes either playerA or playerB cancel the duel and port the players back
-		if (player == _playerA || player == _playerB)
+		if ((player == _playerA) || (player == _playerB))
 		{
 		{
 			for (FastList.Node<PlayerCondition> e = _playerConditions.head(), end = _playerConditions.tail(); (e = e.getNext()) != end;)
 			for (FastList.Node<PlayerCondition> e = _playerConditions.head(), end = _playerConditions.tail(); (e = e.getNext()) != end;)
 			{
 			{
@@ -948,7 +1036,7 @@ public class Duel
 			_playerB = null;
 			_playerB = null;
 		}
 		}
 		else
 		else
-			// teleport the player back & delete his PlayerCondition record
+		// teleport the player back & delete his PlayerCondition record
 		{
 		{
 			for (FastList.Node<PlayerCondition> e = _playerConditions.head(), end = _playerConditions.tail(); (e = e.getNext()) != end;)
 			for (FastList.Node<PlayerCondition> e = _playerConditions.head(), end = _playerConditions.tail(); (e = e.getNext()) != end;)
 			{
 			{

+ 166 - 58
L2J_Server_BETA/java/com/l2jserver/gameserver/model/entity/Fort.java

@@ -68,7 +68,7 @@ public class Fort
 	protected static final Logger _log = Logger.getLogger(Fort.class.getName());
 	protected static final Logger _log = Logger.getLogger(Fort.class.getName());
 	
 	
 	private int _fortId = 0;
 	private int _fortId = 0;
-	private List<L2DoorInstance> _doors = new ArrayList<>();
+	private final List<L2DoorInstance> _doors = new ArrayList<>();
 	private L2StaticObjectInstance _flagPole = null;
 	private L2StaticObjectInstance _flagPole = null;
 	private String _name = "";
 	private String _name = "";
 	private FortSiege _siege = null;
 	private FortSiege _siege = null;
@@ -82,17 +82,17 @@ public class Fort
 	private int _castleId = 0;
 	private int _castleId = 0;
 	private int _blood = 0;
 	private int _blood = 0;
 	private int _supplyLvL = 0;
 	private int _supplyLvL = 0;
-	private FastMap<Integer, FortFunction> _function;
-	private FastList<L2Skill> _residentialSkills = new FastList<>();
-	private ScheduledFuture<?>[] _FortUpdater = new ScheduledFuture<?>[2];
+	private final FastMap<Integer, FortFunction> _function;
+	private final FastList<L2Skill> _residentialSkills = new FastList<>();
+	private final ScheduledFuture<?>[] _FortUpdater = new ScheduledFuture<?>[2];
 	
 	
 	// Spawn Data
 	// Spawn Data
 	private boolean _isSuspiciousMerchantSpawned = false;
 	private boolean _isSuspiciousMerchantSpawned = false;
-	private FastList<L2Spawn> _siegeNpcs = new FastList<>();
-	private FastList<L2Spawn> _npcCommanders = new FastList<>();
-	private FastList<L2Spawn> _specialEnvoys = new FastList<>();
+	private final FastList<L2Spawn> _siegeNpcs = new FastList<>();
+	private final FastList<L2Spawn> _npcCommanders = new FastList<>();
+	private final FastList<L2Spawn> _specialEnvoys = new FastList<>();
 	
 	
-	private TIntIntHashMap _envoyCastles = new TIntIntHashMap(2);
+	private final TIntIntHashMap _envoyCastles = new TIntIntHashMap(2);
 	
 	
 	/** Fortress Functions */
 	/** Fortress Functions */
 	public static final int FUNC_TELEPORT = 1;
 	public static final int FUNC_TELEPORT = 1;
@@ -103,11 +103,11 @@ public class Fort
 	
 	
 	public class FortFunction
 	public class FortFunction
 	{
 	{
-		private int _type;
+		private final int _type;
 		private int _lvl;
 		private int _lvl;
 		protected int _fee;
 		protected int _fee;
 		protected int _tempFee;
 		protected int _tempFee;
-		private long _rate;
+		private final long _rate;
 		private long _endDate;
 		private long _endDate;
 		protected boolean _inDebt;
 		protected boolean _inDebt;
 		public boolean _cwh;
 		public boolean _cwh;
@@ -166,12 +166,18 @@ public class Fort
 		private void initializeTask(boolean cwh)
 		private void initializeTask(boolean cwh)
 		{
 		{
 			if (getOwnerClan() == null)
 			if (getOwnerClan() == null)
+			{
 				return;
 				return;
+			}
 			long currentTime = System.currentTimeMillis();
 			long currentTime = System.currentTimeMillis();
 			if (_endDate > currentTime)
 			if (_endDate > currentTime)
+			{
 				ThreadPoolManager.getInstance().scheduleGeneral(new FunctionTask(cwh), _endDate - currentTime);
 				ThreadPoolManager.getInstance().scheduleGeneral(new FunctionTask(cwh), _endDate - currentTime);
+			}
 			else
 			else
+			{
 				ThreadPoolManager.getInstance().scheduleGeneral(new FunctionTask(cwh), 0);
 				ThreadPoolManager.getInstance().scheduleGeneral(new FunctionTask(cwh), 0);
+			}
 		}
 		}
 		
 		
 		private class FunctionTask implements Runnable
 		private class FunctionTask implements Runnable
@@ -187,12 +193,16 @@ public class Fort
 				try
 				try
 				{
 				{
 					if (getOwnerClan() == null)
 					if (getOwnerClan() == null)
+					{
 						return;
 						return;
-					if (getOwnerClan().getWarehouse().getAdena() >= _fee || !_cwh)
+					}
+					if ((getOwnerClan().getWarehouse().getAdena() >= _fee) || !_cwh)
 					{
 					{
 						int fee = _fee;
 						int fee = _fee;
 						if (getEndTime() == -1)
 						if (getEndTime() == -1)
+						{
 							fee = _tempFee;
 							fee = _tempFee;
+						}
 						
 						
 						setEndTime(System.currentTimeMillis() + getRate());
 						setEndTime(System.currentTimeMillis() + getRate());
 						dbSave();
 						dbSave();
@@ -200,12 +210,16 @@ public class Fort
 						{
 						{
 							getOwnerClan().getWarehouse().destroyItemByItemId("CS_function_fee", PcInventory.ADENA_ID, fee, null, null);
 							getOwnerClan().getWarehouse().destroyItemByItemId("CS_function_fee", PcInventory.ADENA_ID, fee, null, null);
 							if (Config.DEBUG)
 							if (Config.DEBUG)
+							{
 								_log.warning("Deducted " + fee + " adena from " + getName() + " owner's cwh for function id : " + getType());
 								_log.warning("Deducted " + fee + " adena from " + getName() + " owner's cwh for function id : " + getType());
+							}
 						}
 						}
 						ThreadPoolManager.getInstance().scheduleGeneral(new FunctionTask(true), getRate());
 						ThreadPoolManager.getInstance().scheduleGeneral(new FunctionTask(true), getRate());
 					}
 					}
 					else
 					else
+					{
 						removeFunction(getType());
 						removeFunction(getType());
+					}
 				}
 				}
 				catch (Throwable t)
 				catch (Throwable t)
 				{
 				{
@@ -260,11 +274,11 @@ public class Fort
 		}
 		}
 		initNpcs(); // load and spawn npcs (Always spawned)
 		initNpcs(); // load and spawn npcs (Always spawned)
 		initSiegeNpcs(); // load suspicious merchants (Despawned 10mins before siege)
 		initSiegeNpcs(); // load suspicious merchants (Despawned 10mins before siege)
-		//spawnSuspiciousMerchant();// spawn suspicious merchants
+		// spawnSuspiciousMerchant();// spawn suspicious merchants
 		initNpcCommanders(); // npc Commanders (not monsters) (Spawned during siege)
 		initNpcCommanders(); // npc Commanders (not monsters) (Spawned during siege)
 		spawnNpcCommanders(); // spawn npc Commanders
 		spawnNpcCommanders(); // spawn npc Commanders
-		initSpecialEnvoys(); // envoys from castles  (Spawned after fort taken)
-		if (getOwnerClan() != null && getFortState() == 0)
+		initSpecialEnvoys(); // envoys from castles (Spawned after fort taken)
+		if ((getOwnerClan() != null) && (getFortState() == 0))
 		{
 		{
 			spawnSpecialEnvoys();
 			spawnSpecialEnvoys();
 			ThreadPoolManager.getInstance().scheduleGeneral(new ScheduleSpecialEnvoysDeSpawn(this), 1 * 60 * 60 * 1000); // Prepare 1hr task for special envoys despawn
 			ThreadPoolManager.getInstance().scheduleGeneral(new ScheduleSpecialEnvoysDeSpawn(this), 1 * 60 * 60 * 1000); // Prepare 1hr task for special envoys despawn
@@ -272,20 +286,22 @@ public class Fort
 	}
 	}
 	
 	
 	/**
 	/**
-	 * Return function with id 
-	 * @param type 
+	 * Return function with id
+	 * @param type
 	 * @return
 	 * @return
 	 */
 	 */
 	public FortFunction getFunction(int type)
 	public FortFunction getFunction(int type)
 	{
 	{
 		if (_function.get(type) != null)
 		if (_function.get(type) != null)
+		{
 			return _function.get(type);
 			return _function.get(type);
+		}
 		return null;
 		return null;
 	}
 	}
 	
 	
 	public static class ScheduleSpecialEnvoysDeSpawn implements Runnable
 	public static class ScheduleSpecialEnvoysDeSpawn implements Runnable
 	{
 	{
-		private Fort _fortInst;
+		private final Fort _fortInst;
 		
 		
 		public ScheduleSpecialEnvoysDeSpawn(Fort pFort)
 		public ScheduleSpecialEnvoysDeSpawn(Fort pFort)
 		{
 		{
@@ -299,7 +315,9 @@ public class Fort
 			{
 			{
 				// if state not decided, change state to indenpendent
 				// if state not decided, change state to indenpendent
 				if (_fortInst.getFortState() == 0)
 				if (_fortInst.getFortState() == 0)
+				{
 					_fortInst.setFortState(1, 0);
 					_fortInst.setFortState(1, 0);
+				}
 				_fortInst.despawnSpecialEnvoys();
 				_fortInst.despawnSpecialEnvoys();
 			}
 			}
 			catch (Exception e)
 			catch (Exception e)
@@ -320,7 +338,8 @@ public class Fort
 	}
 	}
 	
 	
 	/**
 	/**
-	 * Move non clan members off fort area and to nearest town.<BR><BR>
+	 * Move non clan members off fort area and to nearest town.<BR>
+	 * <BR>
 	 */
 	 */
 	public void banishForeigners()
 	public void banishForeigners()
 	{
 	{
@@ -328,9 +347,9 @@ public class Fort
 	}
 	}
 	
 	
 	/**
 	/**
-	 * @param x 
-	 * @param y 
-	 * @param z 
+	 * @param x
+	 * @param y
+	 * @param z
 	 * @return true if object is inside the zone
 	 * @return true if object is inside the zone
 	 */
 	 */
 	public boolean checkIfInZone(int x, int y, int z)
 	public boolean checkIfInZone(int x, int y, int z)
@@ -393,15 +412,21 @@ public class Fort
 	public void openCloseDoor(L2PcInstance activeChar, int doorId, boolean open)
 	public void openCloseDoor(L2PcInstance activeChar, int doorId, boolean open)
 	{
 	{
 		if (activeChar.getClan() != getOwnerClan())
 		if (activeChar.getClan() != getOwnerClan())
+		{
 			return;
 			return;
+		}
 		
 		
 		L2DoorInstance door = getDoor(doorId);
 		L2DoorInstance door = getDoor(doorId);
 		if (door != null)
 		if (door != null)
 		{
 		{
 			if (open)
 			if (open)
+			{
 				door.openMe();
 				door.openMe();
+			}
 			else
 			else
+			{
 				door.closeMe();
 				door.closeMe();
+			}
 		}
 		}
 	}
 	}
 	
 	
@@ -415,7 +440,7 @@ public class Fort
 	 * This method will set owner for Fort
 	 * This method will set owner for Fort
 	 * @param clan
 	 * @param clan
 	 * @param updateClansReputation
 	 * @param updateClansReputation
-	 * @return 
+	 * @return
 	 */
 	 */
 	public boolean setOwner(L2Clan clan, boolean updateClansReputation)
 	public boolean setOwner(L2Clan clan, boolean updateClansReputation)
 	{
 	{
@@ -425,7 +450,7 @@ public class Fort
 			return false;
 			return false;
 		}
 		}
 		final L2Clan oldowner = getOwnerClan();
 		final L2Clan oldowner = getOwnerClan();
-		if (oldowner != null && clan != oldowner)
+		if ((oldowner != null) && (clan != oldowner))
 		{
 		{
 			// Remove points from old owner
 			// Remove points from old owner
 			updateClansReputation(oldowner, true);
 			updateClansReputation(oldowner, true);
@@ -435,7 +460,9 @@ public class Fort
 				if (oldleader != null)
 				if (oldleader != null)
 				{
 				{
 					if (oldleader.getMountType() == 2)
 					if (oldleader.getMountType() == 2)
+					{
 						oldleader.dismount();
 						oldleader.dismount();
+					}
 				}
 				}
 			}
 			}
 			catch (Exception e)
 			catch (Exception e)
@@ -446,7 +473,7 @@ public class Fort
 		}
 		}
 		setFortState(0, 0); // initialize fort state
 		setFortState(0, 0); // initialize fort state
 		
 		
-		//	if clan already have castle, don't store him in fortress
+		// if clan already have castle, don't store him in fortress
 		if (clan.getCastleId() > 0)
 		if (clan.getCastleId() > 0)
 		{
 		{
 			getSiege().announceToPlayer(SystemMessage.getSystemMessage(SystemMessageId.NPCS_RECAPTURED_FORTRESS));
 			getSiege().announceToPlayer(SystemMessage.getSystemMessage(SystemMessageId.NPCS_RECAPTURED_FORTRESS));
@@ -455,13 +482,17 @@ public class Fort
 		
 		
 		// Give points to new owner
 		// Give points to new owner
 		if (updateClansReputation)
 		if (updateClansReputation)
+		{
 			updateClansReputation(clan, false);
 			updateClansReputation(clan, false);
+		}
 		
 		
 		spawnSpecialEnvoys();
 		spawnSpecialEnvoys();
 		ThreadPoolManager.getInstance().scheduleGeneral(new ScheduleSpecialEnvoysDeSpawn(this), 1 * 60 * 60 * 1000); // Prepare 1hr task for special envoys despawn
 		ThreadPoolManager.getInstance().scheduleGeneral(new ScheduleSpecialEnvoysDeSpawn(this), 1 * 60 * 60 * 1000); // Prepare 1hr task for special envoys despawn
 		// if clan have already fortress, remove it
 		// if clan have already fortress, remove it
 		if (clan.getFortId() > 0)
 		if (clan.getFortId() > 0)
+		{
 			FortManager.getInstance().getFortByOwner(clan).removeOwner(true);
 			FortManager.getInstance().getFortByOwner(clan).removeOwner(true);
+		}
 		
 		
 		setBloodOathReward(0);
 		setBloodOathReward(0);
 		setSupplyLvL(0);
 		setSupplyLvL(0);
@@ -469,8 +500,10 @@ public class Fort
 		updateOwnerInDB(); // Update in database
 		updateOwnerInDB(); // Update in database
 		saveFortVariables();
 		saveFortVariables();
 		
 		
-		if (getSiege().getIsInProgress()) // If siege in progress
+		if (getSiege().getIsInProgress())
+		{
 			getSiege().endSiege();
 			getSiege().endSiege();
+		}
 		
 		
 		for (L2PcInstance member : clan.getOnlineMembers(0))
 		for (L2PcInstance member : clan.getOnlineMembers(0))
 		{
 		{
@@ -498,7 +531,9 @@ public class Fort
 			saveFortVariables();
 			saveFortVariables();
 			removeAllFunctions();
 			removeAllFunctions();
 			if (updateDB)
 			if (updateDB)
+			{
 				updateOwnerInDB();
 				updateOwnerInDB();
+			}
 		}
 		}
 	}
 	}
 	
 	
@@ -516,13 +551,17 @@ public class Fort
 	{
 	{
 		_supplyLvL++;
 		_supplyLvL++;
 		if (_supplyLvL > Config.FS_MAX_SUPPLY_LEVEL)
 		if (_supplyLvL > Config.FS_MAX_SUPPLY_LEVEL)
+		{
 			_supplyLvL = Config.FS_MAX_SUPPLY_LEVEL;
 			_supplyLvL = Config.FS_MAX_SUPPLY_LEVEL;
+		}
 	}
 	}
 	
 	
 	public void setSupplyLvL(int val)
 	public void setSupplyLvL(int val)
 	{
 	{
 		if (val <= Config.FS_MAX_SUPPLY_LEVEL)
 		if (val <= Config.FS_MAX_SUPPLY_LEVEL)
+		{
 			_supplyLvL = val;
 			_supplyLvL = val;
+		}
 	}
 	}
 	
 	
 	public int getSupplyLvL()
 	public int getSupplyLvL()
@@ -548,29 +587,39 @@ public class Fort
 	}
 	}
 	
 	
 	/**
 	/**
-	 * Show or hide flag inside flagpole<BR><BR>
-	 * @param val 
+	 * Show or hide flag inside flagpole<BR>
+	 * <BR>
+	 * @param val
 	 */
 	 */
 	public void setVisibleFlag(boolean val)
 	public void setVisibleFlag(boolean val)
 	{
 	{
 		L2StaticObjectInstance flagPole = getFlagPole();
 		L2StaticObjectInstance flagPole = getFlagPole();
 		if (flagPole != null)
 		if (flagPole != null)
+		{
 			flagPole.setMeshIndex(val ? 1 : 0);
 			flagPole.setMeshIndex(val ? 1 : 0);
+		}
 	}
 	}
 	
 	
 	/**
 	/**
-	 * Respawn all doors on fort grounds<BR><BR>
+	 * Respawn all doors on fort grounds<BR>
+	 * <BR>
 	 */
 	 */
 	public void resetDoors()
 	public void resetDoors()
 	{
 	{
 		for (L2DoorInstance door : _doors)
 		for (L2DoorInstance door : _doors)
 		{
 		{
 			if (door.getOpen())
 			if (door.getOpen())
+			{
 				door.closeMe();
 				door.closeMe();
+			}
 			if (door.isDead())
 			if (door.isDead())
+			{
 				door.doRevive();
 				door.doRevive();
+			}
 			if (door.getCurrentHp() < door.getMaxHp())
 			if (door.getCurrentHp() < door.getMaxHp())
+			{
 				door.setCurrentHp(door.getMaxHp());
 				door.setCurrentHp(door.getMaxHp());
+			}
 		}
 		}
 		loadDoorUpgrade(); // Check for any upgrade the doors may have
 		loadDoorUpgrade(); // Check for any upgrade the doors may have
 	}
 	}
@@ -579,7 +628,7 @@ public class Fort
 	public void upgradeDoor(int doorId, int hp, int pDef, int mDef)
 	public void upgradeDoor(int doorId, int hp, int pDef, int mDef)
 	{
 	{
 		L2DoorInstance door = getDoor(doorId);
 		L2DoorInstance door = getDoor(doorId);
-		if (door != null && door.getDoorId() == doorId)
+		if ((door != null) && (door.getDoorId() == doorId))
 		{
 		{
 			door.setCurrentHp(door.getMaxHp() + hp);
 			door.setCurrentHp(door.getMaxHp() + hp);
 			
 			
@@ -625,19 +674,27 @@ public class Fort
 				int runCount = getOwnedTime() / (Config.FS_UPDATE_FRQ * 60);
 				int runCount = getOwnedTime() / (Config.FS_UPDATE_FRQ * 60);
 				long initial = System.currentTimeMillis() - _lastOwnedTime.getTimeInMillis();
 				long initial = System.currentTimeMillis() - _lastOwnedTime.getTimeInMillis();
 				while (initial > (Config.FS_UPDATE_FRQ * 60000L))
 				while (initial > (Config.FS_UPDATE_FRQ * 60000L))
+				{
 					initial -= (Config.FS_UPDATE_FRQ * 60000L);
 					initial -= (Config.FS_UPDATE_FRQ * 60000L);
+				}
 				initial = (Config.FS_UPDATE_FRQ * 60000L) - initial;
 				initial = (Config.FS_UPDATE_FRQ * 60000L) - initial;
-				if (Config.FS_MAX_OWN_TIME <= 0 || getOwnedTime() < Config.FS_MAX_OWN_TIME * 3600)
+				if ((Config.FS_MAX_OWN_TIME <= 0) || (getOwnedTime() < (Config.FS_MAX_OWN_TIME * 3600)))
 				{
 				{
 					_FortUpdater[0] = ThreadPoolManager.getInstance().scheduleGeneralAtFixedRate(new FortUpdater(this, clan, runCount, UpdaterType.PERIODIC_UPDATE), initial, Config.FS_UPDATE_FRQ * 60000L); // Schedule owner tasks to start running
 					_FortUpdater[0] = ThreadPoolManager.getInstance().scheduleGeneralAtFixedRate(new FortUpdater(this, clan, runCount, UpdaterType.PERIODIC_UPDATE), initial, Config.FS_UPDATE_FRQ * 60000L); // Schedule owner tasks to start running
 					if (Config.FS_MAX_OWN_TIME > 0)
 					if (Config.FS_MAX_OWN_TIME > 0)
+					{
 						_FortUpdater[1] = ThreadPoolManager.getInstance().scheduleGeneralAtFixedRate(new FortUpdater(this, clan, runCount, UpdaterType.MAX_OWN_TIME), 3600000, 3600000); // Schedule owner tasks to remove owener
 						_FortUpdater[1] = ThreadPoolManager.getInstance().scheduleGeneralAtFixedRate(new FortUpdater(this, clan, runCount, UpdaterType.MAX_OWN_TIME), 3600000, 3600000); // Schedule owner tasks to remove owener
+					}
 				}
 				}
 				else
 				else
+				{
 					_FortUpdater[1] = ThreadPoolManager.getInstance().scheduleGeneral(new FortUpdater(this, clan, 0, UpdaterType.MAX_OWN_TIME), 60000); // Schedule owner tasks to remove owner
 					_FortUpdater[1] = ThreadPoolManager.getInstance().scheduleGeneral(new FortUpdater(this, clan, 0, UpdaterType.MAX_OWN_TIME), 60000); // Schedule owner tasks to remove owner
+				}
 			}
 			}
 			else
 			else
+			{
 				setOwnerClan(null);
 				setOwnerClan(null);
+			}
 			
 			
 		}
 		}
 		catch (Exception e)
 		catch (Exception e)
@@ -670,7 +727,7 @@ public class Fort
 	}
 	}
 	
 	
 	/**
 	/**
-	 * Remove function In List and in DB 
+	 * Remove function In List and in DB
 	 * @param functionType
 	 * @param functionType
 	 */
 	 */
 	public void removeFunction(int functionType)
 	public void removeFunction(int functionType)
@@ -704,25 +761,37 @@ public class Fort
 	public boolean updateFunctions(L2PcInstance player, int type, int lvl, int lease, long rate, boolean addNew)
 	public boolean updateFunctions(L2PcInstance player, int type, int lvl, int lease, long rate, boolean addNew)
 	{
 	{
 		if (player == null)
 		if (player == null)
+		{
 			return false;
 			return false;
+		}
 		if (Config.DEBUG)
 		if (Config.DEBUG)
+		{
 			_log.warning("Called Fort.updateFunctions(int type, int lvl, int lease, long rate, boolean addNew) Owner : " + getOwnerClan());
 			_log.warning("Called Fort.updateFunctions(int type, int lvl, int lease, long rate, boolean addNew) Owner : " + getOwnerClan());
+		}
 		if (lease > 0)
 		if (lease > 0)
+		{
 			if (!player.destroyItemByItemId("Consume", PcInventory.ADENA_ID, lease, null, true))
 			if (!player.destroyItemByItemId("Consume", PcInventory.ADENA_ID, lease, null, true))
+			{
 				return false;
 				return false;
+			}
+		}
 		if (addNew)
 		if (addNew)
 		{
 		{
 			_function.put(type, new FortFunction(type, lvl, lease, 0, rate, 0, false));
 			_function.put(type, new FortFunction(type, lvl, lease, 0, rate, 0, false));
 		}
 		}
 		else
 		else
 		{
 		{
-			if (lvl == 0 && lease == 0)
+			if ((lvl == 0) && (lease == 0))
+			{
 				removeFunction(type);
 				removeFunction(type);
+			}
 			else
 			else
 			{
 			{
 				int diffLease = lease - _function.get(type).getLease();
 				int diffLease = lease - _function.get(type).getLease();
 				if (Config.DEBUG)
 				if (Config.DEBUG)
+				{
 					_log.warning("Called Fort.updateFunctions diffLease : " + diffLease);
 					_log.warning("Called Fort.updateFunctions diffLease : " + diffLease);
+				}
 				if (diffLease > 0)
 				if (diffLease > 0)
 				{
 				{
 					_function.remove(type);
 					_function.remove(type);
@@ -749,18 +818,22 @@ public class Fort
 	{
 	{
 		for (L2DoorInstance door : DoorTable.getInstance().getDoors())
 		for (L2DoorInstance door : DoorTable.getInstance().getDoors())
 		{
 		{
-			if (door.getFort() != null && door.getFort().getFortId() == getFortId())
+			if ((door.getFort() != null) && (door.getFort().getFortId() == getFortId()))
+			{
 				_doors.add(door);
 				_doors.add(door);
+			}
 		}
 		}
 		if (Config.DEBUG)
 		if (Config.DEBUG)
-			_log.info("Fort "+this+" loaded "+_doors.size()+" doors.");
+		{
+			_log.info("Fort " + this + " loaded " + _doors.size() + " doors.");
+		}
 	}
 	}
 	
 	
 	private void loadFlagPoles()
 	private void loadFlagPoles()
 	{
 	{
-		for(L2StaticObjectInstance obj : StaticObjects.getInstance().getStaticObjects())
+		for (L2StaticObjectInstance obj : StaticObjects.getInstance().getStaticObjects())
 		{
 		{
-			if (obj.getType() == 3 && obj.getName().startsWith(_name))
+			if ((obj.getType() == 3) && obj.getName().startsWith(_name))
 			{
 			{
 				_flagPole = obj;
 				_flagPole = obj;
 				break;
 				break;
@@ -837,7 +910,9 @@ public class Fort
 			_lastOwnedTime.setTimeInMillis(System.currentTimeMillis());
 			_lastOwnedTime.setTimeInMillis(System.currentTimeMillis());
 		}
 		}
 		else
 		else
+		{
 			_lastOwnedTime.setTimeInMillis(0);
 			_lastOwnedTime.setTimeInMillis(0);
+		}
 		
 		
 		try (Connection con = L2DatabaseFactory.getInstance().getConnection())
 		try (Connection con = L2DatabaseFactory.getInstance().getConnection())
 		{
 		{
@@ -863,20 +938,30 @@ public class Fort
 				clan.broadcastToOnlineMembers(new PledgeShowInfoUpdate(clan));
 				clan.broadcastToOnlineMembers(new PledgeShowInfoUpdate(clan));
 				clan.broadcastToOnlineMembers(new PlaySound(1, "Siege_Victory", 0, 0, 0, 0, 0));
 				clan.broadcastToOnlineMembers(new PlaySound(1, "Siege_Victory", 0, 0, 0, 0, 0));
 				if (_FortUpdater[0] != null)
 				if (_FortUpdater[0] != null)
+				{
 					_FortUpdater[0].cancel(false);
 					_FortUpdater[0].cancel(false);
+				}
 				if (_FortUpdater[1] != null)
 				if (_FortUpdater[1] != null)
+				{
 					_FortUpdater[1].cancel(false);
 					_FortUpdater[1].cancel(false);
+				}
 				_FortUpdater[0] = ThreadPoolManager.getInstance().scheduleGeneralAtFixedRate(new FortUpdater(this, clan, 0, UpdaterType.PERIODIC_UPDATE), Config.FS_UPDATE_FRQ * 60000L, Config.FS_UPDATE_FRQ * 60000L); // Schedule owner tasks to start running
 				_FortUpdater[0] = ThreadPoolManager.getInstance().scheduleGeneralAtFixedRate(new FortUpdater(this, clan, 0, UpdaterType.PERIODIC_UPDATE), Config.FS_UPDATE_FRQ * 60000L, Config.FS_UPDATE_FRQ * 60000L); // Schedule owner tasks to start running
 				if (Config.FS_MAX_OWN_TIME > 0)
 				if (Config.FS_MAX_OWN_TIME > 0)
+				{
 					_FortUpdater[1] = ThreadPoolManager.getInstance().scheduleGeneralAtFixedRate(new FortUpdater(this, clan, 0, UpdaterType.MAX_OWN_TIME), 3600000, 3600000); // Schedule owner tasks to remove owener
 					_FortUpdater[1] = ThreadPoolManager.getInstance().scheduleGeneralAtFixedRate(new FortUpdater(this, clan, 0, UpdaterType.MAX_OWN_TIME), 3600000, 3600000); // Schedule owner tasks to remove owener
+				}
 			}
 			}
 			else
 			else
 			{
 			{
 				if (_FortUpdater[0] != null)
 				if (_FortUpdater[0] != null)
+				{
 					_FortUpdater[0].cancel(false);
 					_FortUpdater[0].cancel(false);
+				}
 				_FortUpdater[0] = null;
 				_FortUpdater[0] = null;
 				if (_FortUpdater[1] != null)
 				if (_FortUpdater[1] != null)
+				{
 					_FortUpdater[1].cancel(false);
 					_FortUpdater[1].cancel(false);
+				}
 				_FortUpdater[1] = null;
 				_FortUpdater[1] = null;
 			}
 			}
 		}
 		}
@@ -905,12 +990,16 @@ public class Fort
 	public final L2DoorInstance getDoor(int doorId)
 	public final L2DoorInstance getDoor(int doorId)
 	{
 	{
 		if (doorId <= 0)
 		if (doorId <= 0)
+		{
 			return null;
 			return null;
+		}
 		
 		
 		for (L2DoorInstance door : getDoors())
 		for (L2DoorInstance door : getDoors())
 		{
 		{
 			if (door.getDoorId() == doorId)
 			if (door.getDoorId() == doorId)
+			{
 				return door;
 				return door;
+			}
 		}
 		}
 		return null;
 		return null;
 	}
 	}
@@ -928,7 +1017,9 @@ public class Fort
 	public final FortSiege getSiege()
 	public final FortSiege getSiege()
 	{
 	{
 		if (_siege == null)
 		if (_siege == null)
+		{
 			_siege = new FortSiege(this);
 			_siege = new FortSiege(this);
+		}
 		return _siege;
 		return _siege;
 	}
 	}
 	
 	
@@ -945,7 +1036,9 @@ public class Fort
 	public final int getOwnedTime()
 	public final int getOwnedTime()
 	{
 	{
 		if (_lastOwnedTime.getTimeInMillis() == 0)
 		if (_lastOwnedTime.getTimeInMillis() == 0)
+		{
 			return 0;
 			return 0;
+		}
 		
 		
 		return (int) ((System.currentTimeMillis() - _lastOwnedTime.getTimeInMillis()) / 1000);
 		return (int) ((System.currentTimeMillis() - _lastOwnedTime.getTimeInMillis()) / 1000);
 	}
 	}
@@ -953,15 +1046,19 @@ public class Fort
 	public final int getTimeTillRebelArmy()
 	public final int getTimeTillRebelArmy()
 	{
 	{
 		if (_lastOwnedTime.getTimeInMillis() == 0)
 		if (_lastOwnedTime.getTimeInMillis() == 0)
+		{
 			return 0;
 			return 0;
+		}
 		
 		
-		return (int) ((_lastOwnedTime.getTimeInMillis() + Config.FS_MAX_OWN_TIME * 3600000L - System.currentTimeMillis()) / 1000L);
+		return (int) (((_lastOwnedTime.getTimeInMillis() + (Config.FS_MAX_OWN_TIME * 3600000L)) - System.currentTimeMillis()) / 1000L);
 	}
 	}
 	
 	
 	public final long getTimeTillNextFortUpdate()
 	public final long getTimeTillNextFortUpdate()
 	{
 	{
 		if (_FortUpdater[0] == null)
 		if (_FortUpdater[0] == null)
+		{
 			return 0;
 			return 0;
+		}
 		return _FortUpdater[0].getDelay(TimeUnit.SECONDS);
 		return _FortUpdater[0].getDelay(TimeUnit.SECONDS);
 	}
 	}
 	
 	
@@ -975,16 +1072,20 @@ public class Fort
 		if (owner != null)
 		if (owner != null)
 		{
 		{
 			if (removePoints)
 			if (removePoints)
+			{
 				owner.takeReputationScore(Config.LOOSE_FORT_POINTS, true);
 				owner.takeReputationScore(Config.LOOSE_FORT_POINTS, true);
+			}
 			else
 			else
+			{
 				owner.addReputationScore(Config.TAKE_FORT_POINTS, true);
 				owner.addReputationScore(Config.TAKE_FORT_POINTS, true);
+			}
 		}
 		}
 	}
 	}
 	
 	
 	private static class endFortressSiege implements Runnable
 	private static class endFortressSiege implements Runnable
 	{
 	{
-		private Fort _f;
-		private L2Clan _clan;
+		private final Fort _f;
+		private final L2Clan _clan;
 		
 		
 		public endFortressSiege(Fort f, L2Clan clan)
 		public endFortressSiege(Fort f, L2Clan clan)
 		{
 		{
@@ -1008,10 +1109,11 @@ public class Fort
 	}
 	}
 	
 	
 	/**
 	/**
-	 * @return Returns state of fortress.<BR><BR>
-	 * 0 - not decided yet<BR>
-	 * 1 - independent<BR>
-	 * 2 - contracted with castle<BR>
+	 * @return Returns state of fortress.<BR>
+	 * <BR>
+	 *         0 - not decided yet<BR>
+	 *         1 - independent<BR>
+	 *         2 - contracted with castle<BR>
 	 */
 	 */
 	public final int getFortState()
 	public final int getFortState()
 	{
 	{
@@ -1019,12 +1121,11 @@ public class Fort
 	}
 	}
 	
 	
 	/**
 	/**
-	 * @param state
-	 * <ul>
-	 * 	<li>0 - not decided yet</li>
-	 * 	<li>1 - independent</li>
-	 * 	<li>2 - contracted with castle</li>
-	 * </ul>
+	 * @param state <ul>
+	 *            <li>0 - not decided yet</li>
+	 *            <li>1 - independent</li>
+	 *            <li>2 - contracted with castle</li>
+	 *            </ul>
 	 * @param castleId set Castle Id for contracted fort
 	 * @param castleId set Castle Id for contracted fort
 	 */
 	 */
 	public final void setFortState(int state, int castleId)
 	public final void setFortState(int state, int castleId)
@@ -1055,9 +1156,10 @@ public class Fort
 	}
 	}
 	
 	
 	/**
 	/**
-	 * @return Returns fortress type.<BR><BR>
-	 * 0 - small (3 commanders) <BR>
-	 * 1 - big (4 commanders + control room)
+	 * @return Returns fortress type.<BR>
+	 * <BR>
+	 *         0 - small (3 commanders) <BR>
+	 *         1 - big (4 commanders + control room)
 	 */
 	 */
 	public final int getFortType()
 	public final int getFortType()
 	{
 	{
@@ -1080,7 +1182,9 @@ public class Fort
 	public void spawnSuspiciousMerchant()
 	public void spawnSuspiciousMerchant()
 	{
 	{
 		if (_isSuspiciousMerchantSpawned)
 		if (_isSuspiciousMerchantSpawned)
+		{
 			return;
 			return;
+		}
 		_isSuspiciousMerchantSpawned = true;
 		_isSuspiciousMerchantSpawned = true;
 		
 		
 		for (L2Spawn spawnDat : _siegeNpcs)
 		for (L2Spawn spawnDat : _siegeNpcs)
@@ -1093,7 +1197,9 @@ public class Fort
 	public void despawnSuspiciousMerchant()
 	public void despawnSuspiciousMerchant()
 	{
 	{
 		if (!_isSuspiciousMerchantSpawned)
 		if (!_isSuspiciousMerchantSpawned)
+		{
 			return;
 			return;
+		}
 		_isSuspiciousMerchantSpawned = false;
 		_isSuspiciousMerchantSpawned = false;
 		
 		
 		for (L2Spawn spawnDat : _siegeNpcs)
 		for (L2Spawn spawnDat : _siegeNpcs)
@@ -1252,8 +1358,7 @@ public class Fort
 				}
 				}
 				else
 				else
 				{
 				{
-					_log.warning("Fort " + getFortId() + " initNpcCommanders: Data missing in NPC table for ID: " + rset.getInt("npcId")
-							+ ".");
+					_log.warning("Fort " + getFortId() + " initNpcCommanders: Data missing in NPC table for ID: " + rset.getInt("npcId") + ".");
 				}
 				}
 			}
 			}
 			rset.close();
 			rset.close();
@@ -1298,8 +1403,7 @@ public class Fort
 				}
 				}
 				else
 				else
 				{
 				{
-					_log.warning("Fort " + getFortId() + " initSpecialEnvoys: Data missing in NPC table for ID: " + rset.getInt("npcId")
-							+ ".");
+					_log.warning("Fort " + getFortId() + " initSpecialEnvoys: Data missing in NPC table for ID: " + rset.getInt("npcId") + ".");
 				}
 				}
 			}
 			}
 			rset.close();
 			rset.close();
@@ -1319,19 +1423,23 @@ public class Fort
 	
 	
 	public void giveResidentialSkills(L2PcInstance player)
 	public void giveResidentialSkills(L2PcInstance player)
 	{
 	{
-		if (_residentialSkills != null && !_residentialSkills.isEmpty())
+		if ((_residentialSkills != null) && !_residentialSkills.isEmpty())
 		{
 		{
 			for (L2Skill sk : _residentialSkills)
 			for (L2Skill sk : _residentialSkills)
+			{
 				player.addSkill(sk, false);
 				player.addSkill(sk, false);
+			}
 		}
 		}
 	}
 	}
 	
 	
 	public void removeResidentialSkills(L2PcInstance player)
 	public void removeResidentialSkills(L2PcInstance player)
 	{
 	{
-		if (_residentialSkills != null && !_residentialSkills.isEmpty())
+		if ((_residentialSkills != null) && !_residentialSkills.isEmpty())
 		{
 		{
 			for (L2Skill sk : _residentialSkills)
 			for (L2Skill sk : _residentialSkills)
+			{
 				player.removeSkill(sk, false, true);
 				player.removeSkill(sk, false, true);
+			}
 		}
 		}
 	}
 	}
 	
 	

+ 168 - 48
L2J_Server_BETA/java/com/l2jserver/gameserver/model/entity/FortSiege.java

@@ -59,10 +59,12 @@ public class FortSiege implements Siegable
 	protected static final Logger _log = Logger.getLogger(FortSiege.class.getName());
 	protected static final Logger _log = Logger.getLogger(FortSiege.class.getName());
 	
 	
 	private static FastList<FortSiegeListener> fortSiegeListeners = new FastList<FortSiegeListener>().shared();
 	private static FastList<FortSiegeListener> fortSiegeListeners = new FastList<FortSiegeListener>().shared();
-
+	
 	public static enum TeleportWhoType
 	public static enum TeleportWhoType
 	{
 	{
-		All, Attacker, Owner,
+		All,
+		Attacker,
+		Owner,
 	}
 	}
 	
 	
 	// SQL
 	// SQL
@@ -75,16 +77,18 @@ public class FortSiege implements Siegable
 		public void run()
 		public void run()
 		{
 		{
 			if (!getIsInProgress())
 			if (!getIsInProgress())
+			{
 				return;
 				return;
+			}
 			
 			
 			try
 			try
 			{
 			{
 				_siegeEnd = null;
 				_siegeEnd = null;
-				FortSiege.this.endSiege();
+				endSiege();
 			}
 			}
 			catch (Exception e)
 			catch (Exception e)
 			{
 			{
-				_log.log(Level.WARNING, "Exception: ScheduleEndSiegeTask() for Fort: " + FortSiege.this._fort.getName() + " " + e.getMessage(), e);
+				_log.log(Level.WARNING, "Exception: ScheduleEndSiegeTask() for Fort: " + _fort.getName() + " " + e.getMessage(), e);
 			}
 			}
 		}
 		}
 	}
 	}
@@ -96,7 +100,7 @@ public class FortSiege implements Siegable
 		
 		
 		public ScheduleStartSiegeTask(int time)
 		public ScheduleStartSiegeTask(int time)
 		{
 		{
-			_fortInst = FortSiege.this._fort;
+			_fortInst = _fort;
 			_time = time;
 			_time = time;
 		}
 		}
 		
 		
@@ -104,7 +108,9 @@ public class FortSiege implements Siegable
 		public void run()
 		public void run()
 		{
 		{
 			if (getIsInProgress())
 			if (getIsInProgress())
+			{
 				return;
 				return;
+			}
 			
 			
 			try
 			try
 			{
 			{
@@ -168,7 +174,9 @@ public class FortSiege implements Siegable
 					_fortInst.getSiege().startSiege();
 					_fortInst.getSiege().startSiege();
 				}
 				}
 				else
 				else
+				{
 					_log.warning("Exception: ScheduleStartSiegeTask(): unknown siege time: " + String.valueOf(_time));
 					_log.warning("Exception: ScheduleStartSiegeTask(): unknown siege time: " + String.valueOf(_time));
+				}
 			}
 			}
 			catch (Exception e)
 			catch (Exception e)
 			{
 			{
@@ -183,15 +191,17 @@ public class FortSiege implements Siegable
 		public void run()
 		public void run()
 		{
 		{
 			if (getIsInProgress())
 			if (getIsInProgress())
+			{
 				return;
 				return;
+			}
 			
 			
 			try
 			try
 			{
 			{
-				FortSiege.this._fort.spawnSuspiciousMerchant();
+				_fort.spawnSuspiciousMerchant();
 			}
 			}
 			catch (Exception e)
 			catch (Exception e)
 			{
 			{
-				_log.log(Level.WARNING, "Exception: ScheduleSuspicoiusMerchantSpawn() for Fort: " + FortSiege.this._fort.getName() + " " + e.getMessage(), e);
+				_log.log(Level.WARNING, "Exception: ScheduleSuspicoiusMerchantSpawn() for Fort: " + _fort.getName() + " " + e.getMessage(), e);
 			}
 			}
 		}
 		}
 	}
 	}
@@ -202,22 +212,24 @@ public class FortSiege implements Siegable
 		public void run()
 		public void run()
 		{
 		{
 			if (!getIsInProgress())
 			if (!getIsInProgress())
+			{
 				return;
 				return;
+			}
 			
 			
 			try
 			try
 			{
 			{
 				_siegeRestore = null;
 				_siegeRestore = null;
-				FortSiege.this.resetSiege();
+				resetSiege();
 				announceToPlayer(SystemMessage.getSystemMessage(SystemMessageId.BARRACKS_FUNCTION_RESTORED));
 				announceToPlayer(SystemMessage.getSystemMessage(SystemMessageId.BARRACKS_FUNCTION_RESTORED));
 			}
 			}
 			catch (Exception e)
 			catch (Exception e)
 			{
 			{
-				_log.log(Level.WARNING, "Exception: ScheduleSiegeRestore() for Fort: " + FortSiege.this._fort.getName() + " " + e.getMessage(), e);
+				_log.log(Level.WARNING, "Exception: ScheduleSiegeRestore() for Fort: " + _fort.getName() + " " + e.getMessage(), e);
 			}
 			}
 		}
 		}
 	}
 	}
 	
 	
-	private List<L2SiegeClan> _attackerClans = new FastList<>();
+	private final List<L2SiegeClan> _attackerClans = new FastList<>();
 	
 	
 	// Fort setting
 	// Fort setting
 	protected FastList<L2Spawn> _commanders = new FastList<>();
 	protected FastList<L2Spawn> _commanders = new FastList<>();
@@ -237,7 +249,8 @@ public class FortSiege implements Siegable
 	}
 	}
 	
 	
 	/**
 	/**
-	 * When siege ends<BR><BR>
+	 * When siege ends<BR>
+	 * <BR>
 	 */
 	 */
 	@Override
 	@Override
 	public void endSiege()
 	public void endSiege()
@@ -256,7 +269,9 @@ public class FortSiege implements Siegable
 			
 			
 			int ownerId = -1;
 			int ownerId = -1;
 			if (getFort().getOwnerClan() != null)
 			if (getFort().getOwnerClan() != null)
+			{
 				ownerId = getFort().getOwnerClan().getClanId();
 				ownerId = getFort().getOwnerClan().getClanId();
+			}
 			getFort().getZone().banishForeigners(ownerId);
 			getFort().getZone().banishForeigners(ownerId);
 			getFort().getZone().setIsActive(false);
 			getFort().getZone().setIsActive(false);
 			getFort().getZone().updateZoneStatusForCharactersInside();
 			getFort().getZone().updateZoneStatusForCharactersInside();
@@ -284,8 +299,10 @@ public class FortSiege implements Siegable
 				_siegeRestore = null;
 				_siegeRestore = null;
 			}
 			}
 			
 			
-			if (getFort().getOwnerClan() != null && getFort().getFlagPole().getMeshIndex() == 0)
+			if ((getFort().getOwnerClan() != null) && (getFort().getFlagPole().getMeshIndex() == 0))
+			{
 				getFort().setVisibleFlag(true);
 				getFort().setVisibleFlag(true);
+			}
 			
 			
 			_log.info("Siege of " + getFort().getName() + " fort finished.");
 			_log.info("Siege of " + getFort().getName() + " fort finished.");
 			fireFortSiegeEventListeners(EventStage.END);
 			fireFortSiegeEventListeners(EventStage.END);
@@ -293,7 +310,8 @@ public class FortSiege implements Siegable
 	}
 	}
 	
 	
 	/**
 	/**
-	 * When siege starts<BR><BR>
+	 * When siege starts<BR>
+	 * <BR>
 	 */
 	 */
 	@Override
 	@Override
 	public void startSiege()
 	public void startSiege()
@@ -312,7 +330,9 @@ public class FortSiege implements Siegable
 			_siegeStartTask = null;
 			_siegeStartTask = null;
 			
 			
 			if (getAttackerClans().isEmpty())
 			if (getAttackerClans().isEmpty())
+			{
 				return;
 				return;
+			}
 			
 			
 			_isInProgress = true; // Flag so that same siege instance cannot be started again
 			_isInProgress = true; // Flag so that same siege instance cannot be started again
 			
 			
@@ -342,7 +362,8 @@ public class FortSiege implements Siegable
 	}
 	}
 	
 	
 	/**
 	/**
-	 * Announce to player.<BR><BR>
+	 * Announce to player.<BR>
+	 * <BR>
 	 * @param sm the system message to send to player
 	 * @param sm the system message to send to player
 	 */
 	 */
 	public void announceToPlayer(SystemMessage sm)
 	public void announceToPlayer(SystemMessage sm)
@@ -355,7 +376,9 @@ public class FortSiege implements Siegable
 			for (L2PcInstance member : clan.getOnlineMembers(0))
 			for (L2PcInstance member : clan.getOnlineMembers(0))
 			{
 			{
 				if (member != null)
 				if (member != null)
+				{
 					member.sendPacket(sm);
 					member.sendPacket(sm);
+				}
 			}
 			}
 		}
 		}
 		if (getFort().getOwnerClan() != null)
 		if (getFort().getOwnerClan() != null)
@@ -364,7 +387,9 @@ public class FortSiege implements Siegable
 			for (L2PcInstance member : clan.getOnlineMembers(0))
 			for (L2PcInstance member : clan.getOnlineMembers(0))
 			{
 			{
 				if (member != null)
 				if (member != null)
+				{
 					member.sendPacket(sm);
 					member.sendPacket(sm);
+				}
 			}
 			}
 		}
 		}
 	}
 	}
@@ -384,7 +409,9 @@ public class FortSiege implements Siegable
 			for (L2PcInstance member : clan.getOnlineMembers(0))
 			for (L2PcInstance member : clan.getOnlineMembers(0))
 			{
 			{
 				if (member == null)
 				if (member == null)
+				{
 					continue;
 					continue;
+				}
 				
 				
 				if (clear)
 				if (clear)
 				{
 				{
@@ -412,7 +439,9 @@ public class FortSiege implements Siegable
 			for (L2PcInstance member : clan.getOnlineMembers(0))
 			for (L2PcInstance member : clan.getOnlineMembers(0))
 			{
 			{
 				if (member == null)
 				if (member == null)
+				{
 					continue;
 					continue;
+				}
 				
 				
 				if (clear)
 				if (clear)
 				{
 				{
@@ -437,8 +466,8 @@ public class FortSiege implements Siegable
 	}
 	}
 	
 	
 	/**
 	/**
-	 * @param object 
-	 * @return true if object is inside the zone 
+	 * @param object
+	 * @return true if object is inside the zone
 	 */
 	 */
 	public boolean checkIfInZone(L2Object object)
 	public boolean checkIfInZone(L2Object object)
 	{
 	{
@@ -446,9 +475,9 @@ public class FortSiege implements Siegable
 	}
 	}
 	
 	
 	/**
 	/**
-	 * @param x 
-	 * @param y 
-	 * @param z 
+	 * @param x
+	 * @param y
+	 * @param z
 	 * @return true if object is inside the zone
 	 * @return true if object is inside the zone
 	 */
 	 */
 	public boolean checkIfInZone(int x, int y, int z)
 	public boolean checkIfInZone(int x, int y, int z)
@@ -473,8 +502,10 @@ public class FortSiege implements Siegable
 	@Override
 	@Override
 	public boolean checkIsDefender(L2Clan clan)
 	public boolean checkIsDefender(L2Clan clan)
 	{
 	{
-		if (clan != null && getFort().getOwnerClan() == clan)
+		if ((clan != null) && (getFort().getOwnerClan() == clan))
+		{
 			return true;
 			return true;
+		}
 		
 		
 		return false;
 		return false;
 	}
 	}
@@ -501,7 +532,9 @@ public class FortSiege implements Siegable
 			
 			
 			// if siege is in progress, end siege
 			// if siege is in progress, end siege
 			if (getIsInProgress())
 			if (getIsInProgress())
+			{
 				endSiege();
 				endSiege();
+			}
 			
 			
 			// if siege isn't in progress (1hr waiting time till siege starts), cancel waiting time
 			// if siege isn't in progress (1hr waiting time till siege starts), cancel waiting time
 			if (_siegeStartTask != null)
 			if (_siegeStartTask != null)
@@ -536,10 +569,14 @@ public class FortSiege implements Siegable
 			for (L2PcInstance player : clan.getOnlineMembers(0))
 			for (L2PcInstance player : clan.getOnlineMembers(0))
 			{
 			{
 				if (player == null)
 				if (player == null)
+				{
 					continue;
 					continue;
+				}
 				
 				
 				if (player.isInSiege())
 				if (player.isInSiege())
+				{
 					players.add(player);
 					players.add(player);
+				}
 			}
 			}
 		}
 		}
 		return players;
 		return players;
@@ -564,27 +601,33 @@ public class FortSiege implements Siegable
 		{
 		{
 			clan = ClanTable.getInstance().getClan(getFort().getOwnerClan().getClanId());
 			clan = ClanTable.getInstance().getClan(getFort().getOwnerClan().getClanId());
 			if (clan != getFort().getOwnerClan())
 			if (clan != getFort().getOwnerClan())
+			{
 				return null;
 				return null;
+			}
 			
 			
 			for (L2PcInstance player : clan.getOnlineMembers(0))
 			for (L2PcInstance player : clan.getOnlineMembers(0))
 			{
 			{
 				if (player == null)
 				if (player == null)
+				{
 					continue;
 					continue;
+				}
 				
 				
 				if (player.isInSiege())
 				if (player.isInSiege())
+				{
 					players.add(player);
 					players.add(player);
+				}
 			}
 			}
 		}
 		}
 		return players;
 		return players;
 	}
 	}
 	
 	
 	/**
 	/**
-	 * Commander was killed 
+	 * Commander was killed
 	 * @param instance
 	 * @param instance
 	 */
 	 */
 	public void killedCommander(L2FortCommanderInstance instance)
 	public void killedCommander(L2FortCommanderInstance instance)
 	{
 	{
-		if (_commanders != null && getFort() != null && _commanders.size() != 0)
+		if ((_commanders != null) && (getFort() != null) && (_commanders.size() != 0))
 		{
 		{
 			L2Spawn spawn = instance.getSpawn();
 			L2Spawn spawn = instance.getSpawn();
 			if (spawn != null)
 			if (spawn != null)
@@ -611,7 +654,9 @@ public class FortSiege implements Siegable
 								break;
 								break;
 						}
 						}
 						if (npcString != null)
 						if (npcString != null)
+						{
 							instance.broadcastPacket(new NpcSay(instance.getObjectId(), 1, instance.getNpcId(), npcString));
 							instance.broadcastPacket(new NpcSay(instance.getObjectId(), 1, instance.getNpcId(), npcString));
+						}
 					}
 					}
 				}
 				}
 				_commanders.remove(spawn);
 				_commanders.remove(spawn);
@@ -628,9 +673,11 @@ public class FortSiege implements Siegable
 					for (L2DoorInstance door : getFort().getDoors())
 					for (L2DoorInstance door : getFort().getDoors())
 					{
 					{
 						if (door.getIsShowHp())
 						if (door.getIsShowHp())
+						{
 							continue;
 							continue;
+						}
 						
 						
-						//TODO this also opens control room door at big fort
+						// TODO this also opens control room door at big fort
 						door.openMe();
 						door.openMe();
 					}
 					}
 					getFort().getSiege().announceToPlayer(SystemMessage.getSystemMessage(SystemMessageId.ALL_BARRACKS_OCCUPIED));
 					getFort().getSiege().announceToPlayer(SystemMessage.getSystemMessage(SystemMessageId.ALL_BARRACKS_OCCUPIED));
@@ -642,39 +689,50 @@ public class FortSiege implements Siegable
 					_siegeRestore = ThreadPoolManager.getInstance().scheduleGeneral(new ScheduleSiegeRestore(), FortSiegeManager.getInstance().getCountDownLength() * 60 * 1000L);
 					_siegeRestore = ThreadPoolManager.getInstance().scheduleGeneral(new ScheduleSiegeRestore(), FortSiegeManager.getInstance().getCountDownLength() * 60 * 1000L);
 				}
 				}
 				else
 				else
+				{
 					getFort().getSiege().announceToPlayer(SystemMessage.getSystemMessage(SystemMessageId.SEIZED_BARRACKS));
 					getFort().getSiege().announceToPlayer(SystemMessage.getSystemMessage(SystemMessageId.SEIZED_BARRACKS));
+				}
 			}
 			}
 			else
 			else
+			{
 				_log.warning("FortSiege.killedCommander(): killed commander, but commander not registered for fortress. NpcId: " + instance.getNpcId() + " FortId: " + getFort().getFortId());
 				_log.warning("FortSiege.killedCommander(): killed commander, but commander not registered for fortress. NpcId: " + instance.getNpcId() + " FortId: " + getFort().getFortId());
+			}
 		}
 		}
 	}
 	}
 	
 	
 	/**
 	/**
-	 * Remove the flag that was killed 
+	 * Remove the flag that was killed
 	 * @param flag
 	 * @param flag
 	 */
 	 */
 	public void killedFlag(L2Npc flag)
 	public void killedFlag(L2Npc flag)
 	{
 	{
 		if (flag == null)
 		if (flag == null)
+		{
 			return;
 			return;
+		}
 		
 		
 		for (L2SiegeClan clan : getAttackerClans())
 		for (L2SiegeClan clan : getAttackerClans())
 		{
 		{
 			if (clan.removeFlag(flag))
 			if (clan.removeFlag(flag))
+			{
 				return;
 				return;
+			}
 		}
 		}
 	}
 	}
 	
 	
 	/**
 	/**
-	 * Register clan as attacker<BR><BR>
+	 * Register clan as attacker<BR>
+	 * <BR>
 	 * @param player The L2PcInstance of the player trying to register
 	 * @param player The L2PcInstance of the player trying to register
-	 * @param force 
-	 * @return 
+	 * @param force
+	 * @return
 	 */
 	 */
 	public boolean registerAttacker(L2PcInstance player, boolean force)
 	public boolean registerAttacker(L2PcInstance player, boolean force)
 	{
 	{
 		if (player.getClan() == null)
 		if (player.getClan() == null)
+		{
 			return false;
 			return false;
+		}
 		
 		
 		if (force || checkIfCanRegister(player))
 		if (force || checkIfCanRegister(player))
 		{
 		{
@@ -683,7 +741,9 @@ public class FortSiege implements Siegable
 			if (getAttackerClans().size() == 1)
 			if (getAttackerClans().size() == 1)
 			{
 			{
 				if (!force)
 				if (!force)
+				{
 					player.reduceAdena("siege", 250000, null, true);
 					player.reduceAdena("siege", 250000, null, true);
+				}
 				startAutoTask(true);
 				startAutoTask(true);
 			}
 			}
 			return true;
 			return true;
@@ -692,7 +752,8 @@ public class FortSiege implements Siegable
 	}
 	}
 	
 	
 	/**
 	/**
-	 * Remove clan from siege<BR><BR>
+	 * Remove clan from siege<BR>
+	 * <BR>
 	 * This function does not do any checks and should not be called from bypass !
 	 * This function does not do any checks and should not be called from bypass !
 	 * @param clanId The int of player's clan id
 	 * @param clanId The int of player's clan id
 	 */
 	 */
@@ -713,9 +774,13 @@ public class FortSiege implements Siegable
 			if (getAttackerClans().isEmpty())
 			if (getAttackerClans().isEmpty())
 			{
 			{
 				if (getIsInProgress())
 				if (getIsInProgress())
+				{
 					endSiege();
 					endSiege();
+				}
 				else
 				else
+				{
 					saveFortSiege(); // Clear siege time in DB
 					saveFortSiege(); // Clear siege time in DB
+				}
 				
 				
 				if (_siegeStartTask != null)
 				if (_siegeStartTask != null)
 				{
 				{
@@ -731,13 +796,16 @@ public class FortSiege implements Siegable
 	}
 	}
 	
 	
 	/**
 	/**
-	 * Remove clan from siege<BR><BR>
+	 * Remove clan from siege<BR>
+	 * <BR>
 	 * @param clan The clan being removed
 	 * @param clan The clan being removed
 	 */
 	 */
 	public void removeSiegeClan(L2Clan clan)
 	public void removeSiegeClan(L2Clan clan)
 	{
 	{
-		if (clan == null || clan.getFortId() == getFort().getFortId() || !FortSiegeManager.getInstance().checkIsRegistered(clan, getFort().getFortId()))
+		if ((clan == null) || (clan.getFortId() == getFort().getFortId()) || !FortSiegeManager.getInstance().checkIsRegistered(clan, getFort().getFortId()))
+		{
 			return;
 			return;
+		}
 		
 		
 		removeSiegeClan(clan.getClanId());
 		removeSiegeClan(clan.getClanId());
 	}
 	}
@@ -748,8 +816,10 @@ public class FortSiege implements Siegable
 	 */
 	 */
 	public void checkAutoTask()
 	public void checkAutoTask()
 	{
 	{
-		if (_siegeStartTask != null) //safety check
+		if (_siegeStartTask != null)
+		{
 			return;
 			return;
+		}
 		
 		
 		final long delay = getFort().getSiegeDate().getTimeInMillis() - Calendar.getInstance().getTimeInMillis();
 		final long delay = getFort().getSiegeDate().getTimeInMillis() - Calendar.getInstance().getTimeInMillis();
 		
 		
@@ -765,8 +835,10 @@ public class FortSiege implements Siegable
 		{
 		{
 			loadSiegeClan();
 			loadSiegeClan();
 			if (getAttackerClans().isEmpty())
 			if (getAttackerClans().isEmpty())
+			{
 				// no attackers - waiting for suspicious merchant spawn
 				// no attackers - waiting for suspicious merchant spawn
 				ThreadPoolManager.getInstance().scheduleGeneral(new ScheduleSuspiciousMerchantSpawn(), delay);
 				ThreadPoolManager.getInstance().scheduleGeneral(new ScheduleSuspiciousMerchantSpawn(), delay);
+			}
 			else
 			else
 			{
 			{
 				// preparing start siege task
 				// preparing start siege task
@@ -780,13 +852,19 @@ public class FortSiege implements Siegable
 					ThreadPoolManager.getInstance().executeTask(new ScheduleSuspiciousMerchantSpawn());
 					ThreadPoolManager.getInstance().executeTask(new ScheduleSuspiciousMerchantSpawn());
 					_siegeStartTask = ThreadPoolManager.getInstance().scheduleGeneral(new FortSiege.ScheduleStartSiegeTask(600), delay - 600000);
 					_siegeStartTask = ThreadPoolManager.getInstance().scheduleGeneral(new FortSiege.ScheduleStartSiegeTask(600), delay - 600000);
 				}
 				}
-				else if (delay > 300000) // more than 5 min
+				else if (delay > 300000)
+				{
 					_siegeStartTask = ThreadPoolManager.getInstance().scheduleGeneral(new FortSiege.ScheduleStartSiegeTask(300), delay - 300000);
 					_siegeStartTask = ThreadPoolManager.getInstance().scheduleGeneral(new FortSiege.ScheduleStartSiegeTask(300), delay - 300000);
-				else if (delay > 60000) //more than 1 min
+				}
+				else if (delay > 60000)
+				{
 					_siegeStartTask = ThreadPoolManager.getInstance().scheduleGeneral(new FortSiege.ScheduleStartSiegeTask(60), delay - 60000);
 					_siegeStartTask = ThreadPoolManager.getInstance().scheduleGeneral(new FortSiege.ScheduleStartSiegeTask(60), delay - 60000);
+				}
 				else
 				else
+				{
 					// lower than 1 min, set to 1 min
 					// lower than 1 min, set to 1 min
 					_siegeStartTask = ThreadPoolManager.getInstance().scheduleGeneral(new FortSiege.ScheduleStartSiegeTask(60), 0);
 					_siegeStartTask = ThreadPoolManager.getInstance().scheduleGeneral(new FortSiege.ScheduleStartSiegeTask(60), 0);
+				}
 				
 				
 				_log.info("Siege of " + getFort().getName() + " fort: " + getFort().getSiegeDate().getTime());
 				_log.info("Siege of " + getFort().getName() + " fort: " + getFort().getSiegeDate().getTime());
 			}
 			}
@@ -794,19 +872,26 @@ public class FortSiege implements Siegable
 	}
 	}
 	
 	
 	/**
 	/**
-	 * Start the auto tasks<BR><BR>
-	 * @param setTime 
+	 * Start the auto tasks<BR>
+	 * <BR>
+	 * @param setTime
 	 */
 	 */
 	public void startAutoTask(boolean setTime)
 	public void startAutoTask(boolean setTime)
 	{
 	{
 		if (_siegeStartTask != null)
 		if (_siegeStartTask != null)
+		{
 			return;
 			return;
+		}
 		
 		
 		if (setTime)
 		if (setTime)
+		{
 			setSiegeDateTime(false);
 			setSiegeDateTime(false);
+		}
 		
 		
 		if (getFort().getOwnerClan() != null)
 		if (getFort().getOwnerClan() != null)
+		{
 			getFort().getOwnerClan().broadcastToOnlineMembers(SystemMessage.getSystemMessage(SystemMessageId.A_FORTRESS_IS_UNDER_ATTACK));
 			getFort().getOwnerClan().broadcastToOnlineMembers(SystemMessage.getSystemMessage(SystemMessageId.A_FORTRESS_IS_UNDER_ATTACK));
+		}
 		
 		
 		// Execute siege auto start
 		// Execute siege auto start
 		_siegeStartTask = ThreadPoolManager.getInstance().scheduleGeneral(new FortSiege.ScheduleStartSiegeTask(3600), 0);
 		_siegeStartTask = ThreadPoolManager.getInstance().scheduleGeneral(new FortSiege.ScheduleStartSiegeTask(3600), 0);
@@ -814,8 +899,8 @@ public class FortSiege implements Siegable
 	
 	
 	/**
 	/**
 	 * Teleport players
 	 * Teleport players
-	 * @param teleportWho 
-	 * @param teleportWhere 
+	 * @param teleportWho
+	 * @param teleportWhere
 	 */
 	 */
 	public void teleportPlayer(TeleportWhoType teleportWho, MapRegionManager.TeleportWhereType teleportWhere)
 	public void teleportPlayer(TeleportWhoType teleportWho, MapRegionManager.TeleportWhereType teleportWhere)
 	{
 	{
@@ -835,14 +920,17 @@ public class FortSiege implements Siegable
 		for (L2PcInstance player : players)
 		for (L2PcInstance player : players)
 		{
 		{
 			if (player.isGM() || player.isInJail())
 			if (player.isGM() || player.isInJail())
+			{
 				continue;
 				continue;
+			}
 			
 			
 			player.teleToLocation(teleportWhere);
 			player.teleToLocation(teleportWhere);
 		}
 		}
 	}
 	}
 	
 	
 	/**
 	/**
-	 * Add clan as attacker<BR><BR>
+	 * Add clan as attacker<BR>
+	 * <BR>
 	 * @param clanId The int of clan's id
 	 * @param clanId The int of clan's id
 	 */
 	 */
 	private void addAttacker(int clanId)
 	private void addAttacker(int clanId)
@@ -857,7 +945,7 @@ public class FortSiege implements Siegable
 	public boolean checkIfCanRegister(L2PcInstance player)
 	public boolean checkIfCanRegister(L2PcInstance player)
 	{
 	{
 		boolean b = true;
 		boolean b = true;
-		if (player.getClan() == null || player.getClan().getLevel() < FortSiegeManager.getInstance().getSiegeClanMinLevel())
+		if ((player.getClan() == null) || (player.getClan().getLevel() < FortSiegeManager.getInstance().getSiegeClanMinLevel()))
 		{
 		{
 			b = false;
 			b = false;
 			player.sendMessage("Only clans with Level " + FortSiegeManager.getInstance().getSiegeClanMinLevel() + " and higher may register for a fortress siege.");
 			player.sendMessage("Only clans with Level " + FortSiegeManager.getInstance().getSiegeClanMinLevel() + " and higher may register for a fortress siege.");
@@ -872,17 +960,17 @@ public class FortSiege implements Siegable
 			b = false;
 			b = false;
 			player.sendPacket(SystemMessageId.CLAN_THAT_OWNS_CASTLE_IS_AUTOMATICALLY_REGISTERED_DEFENDING);
 			player.sendPacket(SystemMessageId.CLAN_THAT_OWNS_CASTLE_IS_AUTOMATICALLY_REGISTERED_DEFENDING);
 		}
 		}
-		else if (getFort().getOwnerClan() != null && player.getClan().getCastleId() > 0 && player.getClan().getCastleId() == getFort().getCastleId())
+		else if ((getFort().getOwnerClan() != null) && (player.getClan().getCastleId() > 0) && (player.getClan().getCastleId() == getFort().getCastleId()))
 		{
 		{
 			b = false;
 			b = false;
 			player.sendPacket(SystemMessageId.CANT_REGISTER_TO_SIEGE_DUE_TO_CONTRACT);
 			player.sendPacket(SystemMessageId.CANT_REGISTER_TO_SIEGE_DUE_TO_CONTRACT);
 		}
 		}
-		else if (getFort().getTimeTillRebelArmy() > 0 && getFort().getTimeTillRebelArmy() <= 7200)
+		else if ((getFort().getTimeTillRebelArmy() > 0) && (getFort().getTimeTillRebelArmy() <= 7200))
 		{
 		{
 			b = false;
 			b = false;
 			player.sendMessage("You cannot register for the fortress siege 2 hours prior to rebel army attack.");
 			player.sendMessage("You cannot register for the fortress siege 2 hours prior to rebel army attack.");
 		}
 		}
-		else if (getFort().getSiege().getAttackerClans().isEmpty() && player.getInventory().getAdena() < 250000)
+		else if (getFort().getSiege().getAttackerClans().isEmpty() && (player.getInventory().getAdena() < 250000))
 		{
 		{
 			b = false;
 			b = false;
 			player.sendMessage("You need 250,000 adena to register"); // replace me with html
 			player.sendMessage("You need 250,000 adena to register"); // replace me with html
@@ -897,7 +985,7 @@ public class FortSiege implements Siegable
 					player.sendPacket(SystemMessageId.ALREADY_REQUESTED_SIEGE_BATTLE);
 					player.sendPacket(SystemMessageId.ALREADY_REQUESTED_SIEGE_BATTLE);
 					break;
 					break;
 				}
 				}
-				if (fort.getOwnerClan() == player.getClan() && (fort.getSiege().getIsInProgress() || fort.getSiege()._siegeStartTask != null))
+				if ((fort.getOwnerClan() == player.getClan()) && (fort.getSiege().getIsInProgress() || (fort.getSiege()._siegeStartTask != null)))
 				{
 				{
 					b = false;
 					b = false;
 					player.sendPacket(SystemMessageId.ALREADY_REQUESTED_SIEGE_BATTLE);
 					player.sendPacket(SystemMessageId.ALREADY_REQUESTED_SIEGE_BATTLE);
@@ -917,14 +1005,20 @@ public class FortSiege implements Siegable
 		for (FortSiege siege : FortSiegeManager.getInstance().getSieges())
 		for (FortSiege siege : FortSiegeManager.getInstance().getSieges())
 		{
 		{
 			if (siege == this)
 			if (siege == this)
+			{
 				continue;
 				continue;
+			}
 			
 			
 			if (siege.getSiegeDate().get(Calendar.DAY_OF_WEEK) == getSiegeDate().get(Calendar.DAY_OF_WEEK))
 			if (siege.getSiegeDate().get(Calendar.DAY_OF_WEEK) == getSiegeDate().get(Calendar.DAY_OF_WEEK))
 			{
 			{
 				if (siege.checkIsAttacker(clan))
 				if (siege.checkIsAttacker(clan))
+				{
 					return true;
 					return true;
+				}
 				if (siege.checkIsDefender(clan))
 				if (siege.checkIsDefender(clan))
+				{
 					return true;
 					return true;
+				}
 			}
 			}
 		}
 		}
 		
 		
@@ -935,9 +1029,13 @@ public class FortSiege implements Siegable
 	{
 	{
 		Calendar newDate = Calendar.getInstance();
 		Calendar newDate = Calendar.getInstance();
 		if (merchant)
 		if (merchant)
+		{
 			newDate.add(Calendar.MINUTE, FortSiegeManager.getInstance().getSuspiciousMerchantRespawnDelay());
 			newDate.add(Calendar.MINUTE, FortSiegeManager.getInstance().getSuspiciousMerchantRespawnDelay());
+		}
 		else
 		else
+		{
 			newDate.add(Calendar.MINUTE, 60);
 			newDate.add(Calendar.MINUTE, 60);
+		}
 		getFort().setSiegeDate(newDate);
 		getFort().setSiegeDate(newDate);
 		saveSiegeDate();
 		saveSiegeDate();
 	}
 	}
@@ -967,7 +1065,7 @@ public class FortSiege implements Siegable
 	/** Remove commanders. */
 	/** Remove commanders. */
 	private void removeCommanders()
 	private void removeCommanders()
 	{
 	{
-		if (_commanders != null && !_commanders.isEmpty())
+		if ((_commanders != null) && !_commanders.isEmpty())
 		{
 		{
 			// Remove all instance of commanders for this fort
 			// Remove all instance of commanders for this fort
 			for (L2Spawn spawn : _commanders)
 			for (L2Spawn spawn : _commanders)
@@ -976,7 +1074,9 @@ public class FortSiege implements Siegable
 				{
 				{
 					spawn.stopRespawn();
 					spawn.stopRespawn();
 					if (spawn.getLastSpawn() != null)
 					if (spawn.getLastSpawn() != null)
+					{
 						spawn.getLastSpawn().deleteMe();
 						spawn.getLastSpawn().deleteMe();
+					}
 				}
 				}
 			}
 			}
 			_commanders.clear();
 			_commanders.clear();
@@ -989,7 +1089,9 @@ public class FortSiege implements Siegable
 		for (L2SiegeClan sc : getAttackerClans())
 		for (L2SiegeClan sc : getAttackerClans())
 		{
 		{
 			if (sc != null)
 			if (sc != null)
+			{
 				sc.removeFlags();
 				sc.removeFlags();
+			}
 		}
 		}
 	}
 	}
 	
 	
@@ -1017,7 +1119,8 @@ public class FortSiege implements Siegable
 	}
 	}
 	
 	
 	/**
 	/**
-	 * Save registration to database.<BR><BR>
+	 * Save registration to database.<BR>
+	 * <BR>
 	 * @param clan The L2Clan of player
 	 * @param clan The L2Clan of player
 	 */
 	 */
 	private void saveSiegeClan(L2Clan clan)
 	private void saveSiegeClan(L2Clan clan)
@@ -1045,7 +1148,7 @@ public class FortSiege implements Siegable
 	/** Spawn commanders. */
 	/** Spawn commanders. */
 	private void spawnCommanders()
 	private void spawnCommanders()
 	{
 	{
-		//Set commanders array size if one does not exist
+		// Set commanders array size if one does not exist
 		try
 		try
 		{
 		{
 			_commanders.clear();
 			_commanders.clear();
@@ -1083,20 +1186,27 @@ public class FortSiege implements Siegable
 	private void spawnFlag(int Id)
 	private void spawnFlag(int Id)
 	{
 	{
 		for (CombatFlag cf : FortSiegeManager.getInstance().getFlagList(Id))
 		for (CombatFlag cf : FortSiegeManager.getInstance().getFlagList(Id))
+		{
 			cf.spawnMe();
 			cf.spawnMe();
+		}
 	}
 	}
 	
 	
 	private void unSpawnFlags()
 	private void unSpawnFlags()
 	{
 	{
 		if (FortSiegeManager.getInstance().getFlagList(getFort().getFortId()) == null)
 		if (FortSiegeManager.getInstance().getFlagList(getFort().getFortId()) == null)
+		{
 			return;
 			return;
+		}
 		
 		
 		for (CombatFlag cf : FortSiegeManager.getInstance().getFlagList(getFort().getFortId()))
 		for (CombatFlag cf : FortSiegeManager.getInstance().getFlagList(getFort().getFortId()))
+		{
 			cf.unSpawnMe();
 			cf.unSpawnMe();
+		}
 	}
 	}
 	
 	
 	/**
 	/**
-	 * Spawn siege guard.<BR><BR>
+	 * Spawn siege guard.<BR>
+	 * <BR>
 	 */
 	 */
 	private void spawnSiegeGuard()
 	private void spawnSiegeGuard()
 	{
 	{
@@ -1107,7 +1217,9 @@ public class FortSiege implements Siegable
 	public final L2SiegeClan getAttackerClan(L2Clan clan)
 	public final L2SiegeClan getAttackerClan(L2Clan clan)
 	{
 	{
 		if (clan == null)
 		if (clan == null)
+		{
 			return null;
 			return null;
+		}
 		
 		
 		return getAttackerClan(clan.getClanId());
 		return getAttackerClan(clan.getClanId());
 	}
 	}
@@ -1116,8 +1228,12 @@ public class FortSiege implements Siegable
 	public final L2SiegeClan getAttackerClan(int clanId)
 	public final L2SiegeClan getAttackerClan(int clanId)
 	{
 	{
 		for (L2SiegeClan sc : getAttackerClans())
 		for (L2SiegeClan sc : getAttackerClans())
-			if (sc != null && sc.getClanId() == clanId)
+		{
+			if ((sc != null) && (sc.getClanId() == clanId))
+			{
 				return sc;
 				return sc;
+			}
+		}
 		
 		
 		return null;
 		return null;
 	}
 	}
@@ -1151,7 +1267,9 @@ public class FortSiege implements Siegable
 		{
 		{
 			L2SiegeClan sc = getAttackerClan(clan);
 			L2SiegeClan sc = getAttackerClan(clan);
 			if (sc != null)
 			if (sc != null)
+			{
 				return sc.getFlag();
 				return sc.getFlag();
+			}
 		}
 		}
 		
 		
 		return null;
 		return null;
@@ -1160,7 +1278,9 @@ public class FortSiege implements Siegable
 	public final FortSiegeGuardManager getSiegeGuardManager()
 	public final FortSiegeGuardManager getSiegeGuardManager()
 	{
 	{
 		if (_siegeGuardManager == null)
 		if (_siegeGuardManager == null)
+		{
 			_siegeGuardManager = new FortSiegeGuardManager(getFort());
 			_siegeGuardManager = new FortSiegeGuardManager(getFort());
+		}
 		
 		
 		return _siegeGuardManager;
 		return _siegeGuardManager;
 	}
 	}

+ 16 - 12
L2J_Server_BETA/java/com/l2jserver/gameserver/model/entity/Hero.java

@@ -269,9 +269,9 @@ public class Hero
 				else if (action == ACTION_CASTLE_TAKEN)
 				else if (action == ACTION_CASTLE_TAKEN)
 				{
 				{
 					Castle castle = CastleManager.getInstance().getCastleById(param);
 					Castle castle = CastleManager.getInstance().getCastleById(param);
-					if(castle != null)
+					if (castle != null)
 					{
 					{
-						_diaryentry.set("action", castle.getName()+" Castle was successfuly taken");
+						_diaryentry.set("action", castle.getName() + " Castle was successfuly taken");
 					}
 					}
 				}
 				}
 				_diary.add(_diaryentry);
 				_diary.add(_diaryentry);
@@ -337,7 +337,7 @@ public class Hero
 				{
 				{
 					String name = CharNameTable.getInstance().getNameById(charTwoId);
 					String name = CharNameTable.getInstance().getNameById(charTwoId);
 					String cls = ClassListData.getInstance().getClass(charTwoClass).getClientCode();
 					String cls = ClassListData.getInstance().getClass(charTwoClass).getClientCode();
-					if(name != null && cls != null)
+					if ((name != null) && (cls != null))
 					{
 					{
 						StatsSet fight = new StatsSet();
 						StatsSet fight = new StatsSet();
 						fight.set("oponent", name);
 						fight.set("oponent", name);
@@ -373,7 +373,7 @@ public class Hero
 				{
 				{
 					String name = CharNameTable.getInstance().getNameById(charOneId);
 					String name = CharNameTable.getInstance().getNameById(charOneId);
 					String cls = ClassListData.getInstance().getClass(charOneClass).getClientCode();
 					String cls = ClassListData.getInstance().getClass(charOneClass).getClientCode();
-					if(name != null && cls != null)
+					if ((name != null) && (cls != null))
 					{
 					{
 						StatsSet fight = new StatsSet();
 						StatsSet fight = new StatsSet();
 						fight.set("oponent", name);
 						fight.set("oponent", name);
@@ -457,8 +457,8 @@ public class Hero
 		{
 		{
 			List<StatsSet> _mainlist = _herodiary.get(charid);
 			List<StatsSet> _mainlist = _herodiary.get(charid);
 			NpcHtmlMessage DiaryReply = new NpcHtmlMessage(5);
 			NpcHtmlMessage DiaryReply = new NpcHtmlMessage(5);
-			final String htmContent = HtmCache.getInstance().getHtm(activeChar.getHtmlPrefix(),"data/html/olympiad/herodiary.htm");
-			if (htmContent != null && _heroMessage.containsKey(charid))
+			final String htmContent = HtmCache.getInstance().getHtm(activeChar.getHtmlPrefix(), "data/html/olympiad/herodiary.htm");
+			if ((htmContent != null) && _heroMessage.containsKey(charid))
 			{
 			{
 				DiaryReply.setHtml(htmContent);
 				DiaryReply.setHtml(htmContent);
 				DiaryReply.replace("%heroname%", CharNameTable.getInstance().getNameById(charid));
 				DiaryReply.replace("%heroname%", CharNameTable.getInstance().getNameById(charid));
@@ -546,7 +546,7 @@ public class Hero
 			List<StatsSet> _list = _herofights.get(charid);
 			List<StatsSet> _list = _herofights.get(charid);
 			
 			
 			NpcHtmlMessage FightReply = new NpcHtmlMessage(5);
 			NpcHtmlMessage FightReply = new NpcHtmlMessage(5);
-			final String htmContent = HtmCache.getInstance().getHtm(activeChar.getHtmlPrefix(),"data/html/olympiad/herohistory.htm");
+			final String htmContent = HtmCache.getInstance().getHtm(activeChar.getHtmlPrefix(), "data/html/olympiad/herohistory.htm");
 			if (htmContent != null)
 			if (htmContent != null)
 			{
 			{
 				FightReply.setHtml(htmContent);
 				FightReply.setHtml(htmContent);
@@ -719,7 +719,7 @@ public class Hero
 		updateHeroes(false);
 		updateHeroes(false);
 		
 		
 		L2PcInstance player;
 		L2PcInstance player;
-		for(Integer charId : _heroes.keySet())
+		for (Integer charId : _heroes.keySet())
 		{
 		{
 			player = L2World.getInstance().getPlayer(charId);
 			player = L2World.getInstance().getPlayer(charId);
 			if (player != null)
 			if (player != null)
@@ -787,8 +787,8 @@ public class Hero
 	
 	
 	public void updateHeroes(boolean setDefault)
 	public void updateHeroes(boolean setDefault)
 	{
 	{
-		//_herofights = new FastMap<Integer, List<StatsSet>>();
-		//_herocounts = new FastMap<Integer, StatsSet>();
+		// _herofights = new FastMap<Integer, List<StatsSet>>();
+		// _herocounts = new FastMap<Integer, StatsSet>();
 		
 		
 		try (Connection con = L2DatabaseFactory.getInstance().getConnection())
 		try (Connection con = L2DatabaseFactory.getInstance().getConnection())
 		{
 		{
@@ -957,7 +957,9 @@ public class Hero
 	{
 	{
 		_heroMessage.put(player.getObjectId(), message);
 		_heroMessage.put(player.getObjectId(), message);
 		if (player.isDebug())
 		if (player.isDebug())
-			_log.info("Hero message for player: "+player.getName()+":["+player.getObjectId()+"] set to: ["+message+"]");
+		{
+			_log.info("Hero message for player: " + player.getName() + ":[" + player.getObjectId() + "] set to: [" + message + "]");
+		}
 	}
 	}
 	
 	
 	/**
 	/**
@@ -967,7 +969,9 @@ public class Hero
 	public void saveHeroMessage(int charId)
 	public void saveHeroMessage(int charId)
 	{
 	{
 		if (_heroMessage.get(charId) == null)
 		if (_heroMessage.get(charId) == null)
+		{
 			return;
 			return;
+		}
 		
 		
 		try (Connection con = L2DatabaseFactory.getInstance().getConnection())
 		try (Connection con = L2DatabaseFactory.getInstance().getConnection())
 		{
 		{
@@ -1003,7 +1007,7 @@ public class Hero
 	 */
 	 */
 	public void shutdown()
 	public void shutdown()
 	{
 	{
-		for (int charId: _heroMessage.keySet())
+		for (int charId : _heroMessage.keySet())
 		{
 		{
 			saveHeroMessage(charId);
 			saveHeroMessage(charId);
 		}
 		}

+ 116 - 97
L2J_Server_BETA/java/com/l2jserver/gameserver/model/entity/L2Event.java

@@ -43,9 +43,7 @@ import com.l2jserver.gameserver.util.PlayerEventStatus;
 import com.l2jserver.util.ValueSortMap;
 import com.l2jserver.util.ValueSortMap;
 
 
 /**
 /**
- * @since $Revision: 1.3.4.1 $ $Date: 2005/03/27 15:29:32 $
- * This ancient thingie got reworked by Nik at $Date: 2011/05/17 21:51:39 $
- * Yeah, for 6 years no one bothered reworking this buggy event engine.
+ * @since $Revision: 1.3.4.1 $ $Date: 2005/03/27 15:29:32 $ This ancient thingie got reworked by Nik at $Date: 2011/05/17 21:51:39 $ Yeah, for 6 years no one bothered reworking this buggy event engine.
  */
  */
 public class L2Event
 public class L2Event
 {
 {
@@ -59,7 +57,7 @@ public class L2Event
 	public static final List<L2PcInstance> _registeredPlayers = new FastList<>();
 	public static final List<L2PcInstance> _registeredPlayers = new FastList<>();
 	public static final Map<Integer, FastList<L2PcInstance>> _teams = new FastMap<>();
 	public static final Map<Integer, FastList<L2PcInstance>> _teams = new FastMap<>();
 	public static int _npcId = 0;
 	public static int _npcId = 0;
-	//public static final List<L2Npc> _npcs = new FastList<L2Npc>();
+	// public static final List<L2Npc> _npcs = new FastList<L2Npc>();
 	private static final Map<L2PcInstance, PlayerEventStatus> _connectionLossData = new FastMap<>();
 	private static final Map<L2PcInstance, PlayerEventStatus> _connectionLossData = new FastMap<>();
 	
 	
 	public enum EventState
 	public enum EventState
@@ -70,19 +68,22 @@ public class L2Event
 	}
 	}
 	
 	
 	/**
 	/**
-	 * 
 	 * @param player
 	 * @param player
 	 * @return The team ID where the player is in, or -1 if player is null or team not found.
 	 * @return The team ID where the player is in, or -1 if player is null or team not found.
 	 */
 	 */
 	public static int getPlayerTeamId(L2PcInstance player)
 	public static int getPlayerTeamId(L2PcInstance player)
 	{
 	{
 		if (player == null)
 		if (player == null)
+		{
 			return -1;
 			return -1;
+		}
 		
 		
 		for (Entry<Integer, FastList<L2PcInstance>> team : _teams.entrySet())
 		for (Entry<Integer, FastList<L2PcInstance>> team : _teams.entrySet())
 		{
 		{
 			if (team.getValue().contains(player))
 			if (team.getValue().contains(player))
+			{
 				return team.getKey();
 				return team.getKey();
+			}
 		}
 		}
 		
 		
 		return -1;
 		return -1;
@@ -97,7 +98,9 @@ public class L2Event
 			for (L2PcInstance player : teamList)
 			for (L2PcInstance player : teamList)
 			{
 			{
 				if (player.getEventStatus() == null)
 				if (player.getEventStatus() == null)
+				{
 					continue;
 					continue;
+				}
 				
 				
 				tmp.put(player, player.getEventStatus().kills.size());
 				tmp.put(player, player.getEventStatus().kills.size());
 			}
 			}
@@ -117,10 +120,10 @@ public class L2Event
 		toReturn.addAll(tmp.keySet());
 		toReturn.addAll(tmp.keySet());
 		return toReturn.subList(1, n);
 		return toReturn.subList(1, n);
 	}
 	}
-
+	
 	public static void showEventHtml(L2PcInstance player, String objectid)
 	public static void showEventHtml(L2PcInstance player, String objectid)
-	{//TODO: work on this
-		
+	{// TODO: work on this
+	
 		if (eventState == EventState.STANDBY)
 		if (eventState == EventState.STANDBY)
 		{
 		{
 			try
 			try
@@ -129,12 +132,18 @@ public class L2Event
 				NpcHtmlMessage html = new NpcHtmlMessage(5);
 				NpcHtmlMessage html = new NpcHtmlMessage(5);
 				
 				
 				if (_registeredPlayers.contains(player))
 				if (_registeredPlayers.contains(player))
+				{
 					htmContent = HtmCache.getInstance().getHtm(player.getHtmlPrefix(), "data/html/mods/EventEngine/Participating.htm");
 					htmContent = HtmCache.getInstance().getHtm(player.getHtmlPrefix(), "data/html/mods/EventEngine/Participating.htm");
+				}
 				else
 				else
+				{
 					htmContent = HtmCache.getInstance().getHtm(player.getHtmlPrefix(), "data/html/mods/EventEngine/Participation.htm");
 					htmContent = HtmCache.getInstance().getHtm(player.getHtmlPrefix(), "data/html/mods/EventEngine/Participation.htm");
+				}
 				
 				
 				if (htmContent != null)
 				if (htmContent != null)
+				{
 					html.setHtml(htmContent);
 					html.setHtml(htmContent);
+				}
 				
 				
 				html.replace("%objectId%", objectid); // Yeah, we need this.
 				html.replace("%objectId%", objectid); // Yeah, we need this.
 				html.replace("%eventName%", _eventName);
 				html.replace("%eventName%", _eventName);
@@ -150,9 +159,8 @@ public class L2Event
 	}
 	}
 	
 	
 	/**
 	/**
-	 * Spawns an event participation NPC near the player.
-	 * The npc id used to spawning is L2Event._npcId
-	 * @param target 
+	 * Spawns an event participation NPC near the player. The npc id used to spawning is L2Event._npcId
+	 * @param target
 	 */
 	 */
 	public static void spawnEventNpc(L2PcInstance target)
 	public static void spawnEventNpc(L2PcInstance target)
 	{
 	{
@@ -175,12 +183,12 @@ public class L2Event
 			spawn.getLastSpawn().setCurrentHp(999999999);
 			spawn.getLastSpawn().setCurrentHp(999999999);
 			spawn.getLastSpawn().setTitle(_eventName);
 			spawn.getLastSpawn().setTitle(_eventName);
 			spawn.getLastSpawn().isEventMob = true;
 			spawn.getLastSpawn().isEventMob = true;
-			//spawn.getLastSpawn().decayMe();
-			//spawn.getLastSpawn().spawnMe(spawn.getLastSpawn().getX(), spawn.getLastSpawn().getY(), spawn.getLastSpawn().getZ());
+			// spawn.getLastSpawn().decayMe();
+			// spawn.getLastSpawn().spawnMe(spawn.getLastSpawn().getX(), spawn.getLastSpawn().getY(), spawn.getLastSpawn().getZ());
 			
 			
 			spawn.getLastSpawn().broadcastPacket(new MagicSkillUse(spawn.getLastSpawn(), spawn.getLastSpawn(), 1034, 1, 1, 1));
 			spawn.getLastSpawn().broadcastPacket(new MagicSkillUse(spawn.getLastSpawn(), spawn.getLastSpawn(), 1034, 1, 1, 1));
 			
 			
-			//_npcs.add(spawn.getLastSpawn());
+			// _npcs.add(spawn.getLastSpawn());
 			
 			
 		}
 		}
 		catch (Exception e)
 		catch (Exception e)
@@ -192,30 +200,30 @@ public class L2Event
 	
 	
 	public static void unspawnEventNpcs()
 	public static void unspawnEventNpcs()
 	{
 	{
-		//Its a little rough, but for sure it will remove every damn event NPC.
+		// Its a little rough, but for sure it will remove every damn event NPC.
 		for (L2Spawn spawn : SpawnTable.getInstance().getSpawnTable())
 		for (L2Spawn spawn : SpawnTable.getInstance().getSpawnTable())
 		{
 		{
-			if (spawn.getLastSpawn() != null && spawn.getLastSpawn().isEventMob)
+			if ((spawn.getLastSpawn() != null) && spawn.getLastSpawn().isEventMob)
 			{
 			{
 				spawn.getLastSpawn().deleteMe();
 				spawn.getLastSpawn().deleteMe();
 				spawn.stopRespawn();
 				spawn.stopRespawn();
 				SpawnTable.getInstance().deleteSpawn(spawn, false);
 				SpawnTable.getInstance().deleteSpawn(spawn, false);
 			}
 			}
 		}
 		}
-		//for (L2Npc npc : _npcs)
-		//	npc.deleteMe();
+		// for (L2Npc npc : _npcs)
+		// npc.deleteMe();
 	}
 	}
 	
 	
 	/**
 	/**
-	 * @param player 
-	 * @return False: If player is null, his event status is null or the event state is off.
-	 * True: if the player is inside the _registeredPlayers list while the event state is STANDBY.
-	 * If the event state is ON, it will check if the player is inside in one of the teams.
+	 * @param player
+	 * @return False: If player is null, his event status is null or the event state is off. True: if the player is inside the _registeredPlayers list while the event state is STANDBY. If the event state is ON, it will check if the player is inside in one of the teams.
 	 */
 	 */
 	public static boolean isParticipant(L2PcInstance player)
 	public static boolean isParticipant(L2PcInstance player)
 	{
 	{
-		if (player == null || player.getEventStatus() == null)
+		if ((player == null) || (player.getEventStatus() == null))
+		{
 			return false;
 			return false;
+		}
 		
 		
 		switch (eventState)
 		switch (eventState)
 		{
 		{
@@ -227,7 +235,9 @@ public class L2Event
 				for (FastList<L2PcInstance> teamList : _teams.values())
 				for (FastList<L2PcInstance> teamList : _teams.values())
 				{
 				{
 					if (teamList.contains(player))
 					if (teamList.contains(player))
+					{
 						return true;
 						return true;
+					}
 				}
 				}
 		}
 		}
 		return false;
 		return false;
@@ -235,10 +245,8 @@ public class L2Event
 	}
 	}
 	
 	
 	/**
 	/**
-	 * 
-	 * Adds the player to the list of participants.
-	 * If the event state is NOT STANDBY, the player wont be registered.
-	 * @param player 
+	 * Adds the player to the list of participants. If the event state is NOT STANDBY, the player wont be registered.
+	 * @param player
 	 */
 	 */
 	public static void registerPlayer(L2PcInstance player)
 	public static void registerPlayer(L2PcInstance player)
 	{
 	{
@@ -248,28 +256,27 @@ public class L2Event
 			return;
 			return;
 		}
 		}
 		
 		
-		if (Config.L2JMOD_DUALBOX_CHECK_MAX_L2EVENT_PARTICIPANTS_PER_IP == 0 || AntiFeedManager.getInstance().tryAddPlayer(AntiFeedManager.L2EVENT_ID, player, Config.L2JMOD_DUALBOX_CHECK_MAX_L2EVENT_PARTICIPANTS_PER_IP))
+		if ((Config.L2JMOD_DUALBOX_CHECK_MAX_L2EVENT_PARTICIPANTS_PER_IP == 0) || AntiFeedManager.getInstance().tryAddPlayer(AntiFeedManager.L2EVENT_ID, player, Config.L2JMOD_DUALBOX_CHECK_MAX_L2EVENT_PARTICIPANTS_PER_IP))
+		{
 			_registeredPlayers.add(player);
 			_registeredPlayers.add(player);
+		}
 		else
 		else
 		{
 		{
 			player.sendMessage("You have reached the maximum allowed participants per IP.");
 			player.sendMessage("You have reached the maximum allowed participants per IP.");
 			return;
 			return;
 		}
 		}
 		
 		
-		
 	}
 	}
 	
 	
 	/**
 	/**
-	 * 
-	 * Removes the player from the participating players and the teams and restores
-	 * his init stats before he registered at the event (loc, pvp, pk, title etc)
-	 * @param player 
+	 * Removes the player from the participating players and the teams and restores his init stats before he registered at the event (loc, pvp, pk, title etc)
+	 * @param player
 	 */
 	 */
 	public static void removeAndResetPlayer(L2PcInstance player)
 	public static void removeAndResetPlayer(L2PcInstance player)
 	{
 	{
 		
 		
 		try
 		try
-		{			
+		{
 			if (isParticipant(player))
 			if (isParticipant(player))
 			{
 			{
 				if (player.isDead())
 				if (player.isDead())
@@ -293,14 +300,18 @@ public class L2Event
 			}
 			}
 			
 			
 			if (player.getEventStatus() != null)
 			if (player.getEventStatus() != null)
+			{
 				player.getEventStatus().restoreInits();
 				player.getEventStatus().restoreInits();
+			}
 			
 			
 			player.setEventStatus(null);
 			player.setEventStatus(null);
 			
 			
 			_registeredPlayers.remove(player);
 			_registeredPlayers.remove(player);
 			int teamId = getPlayerTeamId(player);
 			int teamId = getPlayerTeamId(player);
 			if (_teams.containsKey(teamId))
 			if (_teams.containsKey(teamId))
+			{
 				_teams.get(teamId).remove(player);
 				_teams.get(teamId).remove(player);
+			}
 		}
 		}
 		catch (Exception e)
 		catch (Exception e)
 		{
 		{
@@ -310,17 +321,16 @@ public class L2Event
 	
 	
 	/**
 	/**
 	 * The player's event status will be saved at _connectionLossData
 	 * The player's event status will be saved at _connectionLossData
-	 * @param player 
+	 * @param player
 	 */
 	 */
 	public static void savePlayerEventStatus(L2PcInstance player)
 	public static void savePlayerEventStatus(L2PcInstance player)
 	{
 	{
-			_connectionLossData.put(player, player.getEventStatus());
+		_connectionLossData.put(player, player.getEventStatus());
 	}
 	}
 	
 	
 	/**
 	/**
-	 * If _connectionLossData contains the player, it will restore the player's event status.
-	 * Also it will remove the player from the _connectionLossData.
-	 * @param player 
+	 * If _connectionLossData contains the player, it will restore the player's event status. Also it will remove the player from the _connectionLossData.
+	 * @param player
 	 */
 	 */
 	public static void restorePlayerEventStatus(L2PcInstance player)
 	public static void restorePlayerEventStatus(L2PcInstance player)
 	{
 	{
@@ -332,8 +342,7 @@ public class L2Event
 	}
 	}
 	
 	
 	/**
 	/**
-	 * If the event is ON or STANDBY, it will not start.
-	 * Sets the event state to STANDBY and spawns registration NPCs
+	 * If the event is ON or STANDBY, it will not start. Sets the event state to STANDBY and spawns registration NPCs
 	 * @return a string with information if the event participation has been successfully started or not.
 	 * @return a string with information if the event participation has been successfully started or not.
 	 */
 	 */
 	public static String startEventParticipation()
 	public static String startEventParticipation()
@@ -358,10 +367,12 @@ public class L2Event
 			// Just in case
 			// Just in case
 			unspawnEventNpcs();
 			unspawnEventNpcs();
 			_registeredPlayers.clear();
 			_registeredPlayers.clear();
-			//_npcs.clear();
+			// _npcs.clear();
 			
 			
 			if (NpcTable.getInstance().getTemplate(_npcId) == null)
 			if (NpcTable.getInstance().getTemplate(_npcId) == null)
+			{
 				return "Cannot start event, invalid npc id.";
 				return "Cannot start event, invalid npc id.";
+			}
 			
 			
 			try (FileReader fr = new FileReader(Config.DATAPACK_ROOT + "/data/events/" + _eventName);
 			try (FileReader fr = new FileReader(Config.DATAPACK_ROOT + "/data/events/" + _eventName);
 				BufferedReader br = new BufferedReader(fr))
 				BufferedReader br = new BufferedReader(fr))
@@ -373,8 +384,10 @@ public class L2Event
 			List<L2PcInstance> temp = new FastList<>();
 			List<L2PcInstance> temp = new FastList<>();
 			for (L2PcInstance player : L2World.getInstance().getAllPlayersArray())
 			for (L2PcInstance player : L2World.getInstance().getAllPlayersArray())
 			{
 			{
-				if (!player.isOnline()) // Offline shops? 
+				if (!player.isOnline())
+				{
 					continue;
 					continue;
+				}
 				
 				
 				if (!temp.contains(player))
 				if (!temp.contains(player))
 				{
 				{
@@ -384,9 +397,11 @@ public class L2Event
 				for (L2PcInstance playertemp : player.getKnownList().getKnownPlayers().values())
 				for (L2PcInstance playertemp : player.getKnownList().getKnownPlayers().values())
 				{
 				{
 					if ((Math.abs(playertemp.getX() - player.getX()) < 1000) && (Math.abs(playertemp.getY() - player.getY()) < 1000) && (Math.abs(playertemp.getZ() - player.getZ()) < 1000))
 					if ((Math.abs(playertemp.getX() - player.getX()) < 1000) && (Math.abs(playertemp.getY() - player.getY()) < 1000) && (Math.abs(playertemp.getZ() - player.getZ()) < 1000))
+					{
 						temp.add(playertemp);
 						temp.add(playertemp);
+					}
 				}
 				}
-			}	
+			}
 		}
 		}
 		catch (Exception e)
 		catch (Exception e)
 		{
 		{
@@ -398,10 +413,7 @@ public class L2Event
 	}
 	}
 	
 	
 	/**
 	/**
-	 * If the event is ON or OFF, it will not start.
-	 * Sets the event state to ON, creates the teams, 
-	 * adds the registered players ordered by level at the teams
-	 * and adds a new event status to the players.
+	 * If the event is ON or OFF, it will not start. Sets the event state to ON, creates the teams, adds the registered players ordered by level at the teams and adds a new event status to the players.
 	 * @return a string with information if the event has been successfully started or not.
 	 * @return a string with information if the event has been successfully started or not.
 	 */
 	 */
 	public static String startEvent()
 	public static String startEvent()
@@ -426,28 +438,34 @@ public class L2Event
 			
 			
 			// Insert empty lists at _teams.
 			// Insert empty lists at _teams.
 			for (int i = 0; i < _teamsNumber; i++)
 			for (int i = 0; i < _teamsNumber; i++)
+			{
 				_teams.put(i + 1, new FastList<L2PcInstance>());
 				_teams.put(i + 1, new FastList<L2PcInstance>());
+			}
 			
 			
 			int i = 0;
 			int i = 0;
 			while (!_registeredPlayers.isEmpty())
 			while (!_registeredPlayers.isEmpty())
 			{
 			{
-				//Get the player with the biggest level
+				// Get the player with the biggest level
 				int max = 0;
 				int max = 0;
 				L2PcInstance biggestLvlPlayer = null;
 				L2PcInstance biggestLvlPlayer = null;
 				for (L2PcInstance player : _registeredPlayers)
 				for (L2PcInstance player : _registeredPlayers)
 				{
 				{
-						if (player == null)
-							continue;
-						
-						if (max < player.getLevel())
-						{
-							max = player.getLevel();
-							biggestLvlPlayer = player;
-						}
+					if (player == null)
+					{
+						continue;
+					}
+					
+					if (max < player.getLevel())
+					{
+						max = player.getLevel();
+						biggestLvlPlayer = player;
+					}
 				}
 				}
 				
 				
 				if (biggestLvlPlayer == null)
 				if (biggestLvlPlayer == null)
+				{
 					continue;
 					continue;
+				}
 				
 				
 				_registeredPlayers.remove(biggestLvlPlayer);
 				_registeredPlayers.remove(biggestLvlPlayer);
 				_teams.get(i + 1).add(biggestLvlPlayer);
 				_teams.get(i + 1).add(biggestLvlPlayer);
@@ -466,52 +484,53 @@ public class L2Event
 	}
 	}
 	
 	
 	/**
 	/**
-	 * If the event state is OFF, it will not finish.
-	 * Sets the event state to OFF, unregisters and resets the players,
-	 * unspawns and clers the event NPCs, clears the teams, registered players,
-	 * connection loss data, sets the teams number to 0, sets the event name to empty.
+	 * If the event state is OFF, it will not finish. Sets the event state to OFF, unregisters and resets the players, unspawns and clers the event NPCs, clears the teams, registered players, connection loss data, sets the teams number to 0, sets the event name to empty.
 	 * @return a string with information if the event has been successfully stopped or not.
 	 * @return a string with information if the event has been successfully stopped or not.
 	 */
 	 */
 	public static String finishEvent()
 	public static String finishEvent()
 	{
 	{
-			switch (eventState)
-			{
-				case OFF:
-					return "Cannot finish event, it is already off.";
-				case STANDBY:
-					for (L2PcInstance player : _registeredPlayers)
-						removeAndResetPlayer(player);
-					
-					unspawnEventNpcs();
-					//_npcs.clear();
-					_registeredPlayers.clear();
-					_teams.clear();
-					_connectionLossData.clear();
-					_teamsNumber = 0;
-					_eventName = "";
-					eventState = EventState.OFF;
-					return "The event has been stopped at STANDBY mode, all players unregistered and all event npcs unspawned.";
-				case ON:
-					for (FastList<L2PcInstance> teamList : _teams.values())
+		switch (eventState)
+		{
+			case OFF:
+				return "Cannot finish event, it is already off.";
+			case STANDBY:
+				for (L2PcInstance player : _registeredPlayers)
+				{
+					removeAndResetPlayer(player);
+				}
+				
+				unspawnEventNpcs();
+				// _npcs.clear();
+				_registeredPlayers.clear();
+				_teams.clear();
+				_connectionLossData.clear();
+				_teamsNumber = 0;
+				_eventName = "";
+				eventState = EventState.OFF;
+				return "The event has been stopped at STANDBY mode, all players unregistered and all event npcs unspawned.";
+			case ON:
+				for (FastList<L2PcInstance> teamList : _teams.values())
+				{
+					for (L2PcInstance player : teamList)
 					{
 					{
-						for (L2PcInstance player : teamList)
-							removeAndResetPlayer(player);
+						removeAndResetPlayer(player);
 					}
 					}
-					
-					eventState = EventState.OFF;
-					AntiFeedManager.getInstance().clear(AntiFeedManager.TVT_ID);
-					unspawnEventNpcs(); // Just in case
-					//_npcs.clear();
-					_registeredPlayers.clear();
-					_teams.clear();
-					_connectionLossData.clear();
-					_teamsNumber = 0;
-					_eventName = "";
-					_npcId = 0;
-					_eventCreator = "";
-					_eventInfo = "";
-					return "The event has been stopped, all players unregistered and all event npcs unspawned.";
-			}
+				}
+				
+				eventState = EventState.OFF;
+				AntiFeedManager.getInstance().clear(AntiFeedManager.TVT_ID);
+				unspawnEventNpcs(); // Just in case
+				// _npcs.clear();
+				_registeredPlayers.clear();
+				_teams.clear();
+				_connectionLossData.clear();
+				_teamsNumber = 0;
+				_eventName = "";
+				_npcId = 0;
+				_eventCreator = "";
+				_eventInfo = "";
+				return "The event has been stopped, all players unregistered and all event npcs unspawned.";
+		}
 		
 		
 		return "The event has been successfully finished.";
 		return "The event has been successfully finished.";
 	}
 	}

+ 28 - 9
L2J_Server_BETA/java/com/l2jserver/gameserver/model/entity/Message.java

@@ -28,8 +28,7 @@ import com.l2jserver.gameserver.model.itemcontainer.Mail;
 import com.l2jserver.util.Rnd;
 import com.l2jserver.util.Rnd;
 
 
 /**
 /**
- *
- * @author  Migi, DS
+ * @author Migi, DS
  */
  */
 public class Message
 public class Message
 {
 {
@@ -52,7 +51,7 @@ public class Message
 	private int _sendBySystem;
 	private int _sendBySystem;
 	private boolean _deletedBySender;
 	private boolean _deletedBySender;
 	private boolean _deletedByReceiver;
 	private boolean _deletedByReceiver;
-	private long _reqAdena;
+	private final long _reqAdena;
 	private boolean _hasAttachments;
 	private boolean _hasAttachments;
 	private Mail _attachments = null;
 	private Mail _attachments = null;
 	private ScheduledFuture<?> _unloadTask = null;
 	private ScheduledFuture<?> _unloadTask = null;
@@ -95,7 +94,7 @@ public class Message
 		_receiverId = receiverId;
 		_receiverId = receiverId;
 		_subject = subject;
 		_subject = subject;
 		_content = text;
 		_content = text;
-		_expiration = (isCod ? System.currentTimeMillis() + COD_EXPIRATION * 3600000 : System.currentTimeMillis() + EXPIRATION * 3600000);
+		_expiration = (isCod ? System.currentTimeMillis() + (COD_EXPIRATION * 3600000) : System.currentTimeMillis() + (EXPIRATION * 3600000));
 		_hasAttachments = false;
 		_hasAttachments = false;
 		_unread = true;
 		_unread = true;
 		_deletedBySender = false;
 		_deletedBySender = false;
@@ -111,9 +110,9 @@ public class Message
 		_messageId = IdFactory.getInstance().getNextId();
 		_messageId = IdFactory.getInstance().getNextId();
 		_senderId = -1;
 		_senderId = -1;
 		_receiverId = receiverId;
 		_receiverId = receiverId;
-		_subject = subject; 
+		_subject = subject;
 		_content = content;
 		_content = content;
-		_expiration = System.currentTimeMillis() + EXPIRATION * 3600000;
+		_expiration = System.currentTimeMillis() + (EXPIRATION * 3600000);
 		_reqAdena = 0;
 		_reqAdena = 0;
 		_hasAttachments = false;
 		_hasAttachments = false;
 		_unread = true;
 		_unread = true;
@@ -133,7 +132,7 @@ public class Message
 		_receiverId = msg.getSenderId();
 		_receiverId = msg.getSenderId();
 		_subject = "";
 		_subject = "";
 		_content = "";
 		_content = "";
-		_expiration = System.currentTimeMillis() + EXPIRATION * 3600000;
+		_expiration = System.currentTimeMillis() + (EXPIRATION * 3600000);
 		_unread = true;
 		_unread = true;
 		_deletedBySender = true;
 		_deletedBySender = true;
 		_deletedByReceiver = false;
 		_deletedByReceiver = false;
@@ -188,11 +187,15 @@ public class Message
 		if (_senderName == null)
 		if (_senderName == null)
 		{
 		{
 			if (_sendBySystem != 0)
 			if (_sendBySystem != 0)
+			{
 				return "****";
 				return "****";
+			}
 			
 			
 			_senderName = CharNameTable.getInstance().getNameById(_senderId);
 			_senderName = CharNameTable.getInstance().getNameById(_senderId);
 			if (_senderName == null)
 			if (_senderName == null)
+			{
 				_senderName = "";
 				_senderName = "";
+			}
 		}
 		}
 		return _senderName;
 		return _senderName;
 	}
 	}
@@ -203,7 +206,9 @@ public class Message
 		{
 		{
 			_receiverName = CharNameTable.getInstance().getNameById(_receiverId);
 			_receiverName = CharNameTable.getInstance().getNameById(_receiverId);
 			if (_receiverName == null)
 			if (_receiverName == null)
+			{
 				_receiverName = "";
 				_receiverName = "";
+			}
 		}
 		}
 		return _receiverName;
 		return _receiverName;
 	}
 	}
@@ -230,7 +235,7 @@ public class Message
 	
 	
 	public final int getExpirationSeconds()
 	public final int getExpirationSeconds()
 	{
 	{
-		return (int)(_expiration / 1000);
+		return (int) (_expiration / 1000);
 	}
 	}
 	
 	
 	public final boolean isUnread()
 	public final boolean isUnread()
@@ -258,9 +263,13 @@ public class Message
 		{
 		{
 			_deletedBySender = true;
 			_deletedBySender = true;
 			if (_deletedByReceiver)
 			if (_deletedByReceiver)
+			{
 				MailManager.getInstance().deleteMessageInDb(_messageId);
 				MailManager.getInstance().deleteMessageInDb(_messageId);
+			}
 			else
 			else
+			{
 				MailManager.getInstance().markAsDeletedBySenderInDb(_messageId);
 				MailManager.getInstance().markAsDeletedBySenderInDb(_messageId);
+			}
 		}
 		}
 	}
 	}
 	
 	
@@ -275,9 +284,13 @@ public class Message
 		{
 		{
 			_deletedByReceiver = true;
 			_deletedByReceiver = true;
 			if (_deletedBySender)
 			if (_deletedBySender)
+			{
 				MailManager.getInstance().deleteMessageInDb(_messageId);
 				MailManager.getInstance().deleteMessageInDb(_messageId);
+			}
 			else
 			else
+			{
 				MailManager.getInstance().markAsDeletedByReceiverInDb(_messageId);
 				MailManager.getInstance().markAsDeletedByReceiverInDb(_messageId);
+			}
 		}
 		}
 	}
 	}
 	
 	
@@ -304,7 +317,9 @@ public class Message
 	public final synchronized Mail getAttachments()
 	public final synchronized Mail getAttachments()
 	{
 	{
 		if (!_hasAttachments)
 		if (!_hasAttachments)
+		{
 			return null;
 			return null;
+		}
 		
 		
 		if (_attachments == null)
 		if (_attachments == null)
 		{
 		{
@@ -328,14 +343,18 @@ public class Message
 			_hasAttachments = false;
 			_hasAttachments = false;
 			MailManager.getInstance().removeAttachmentsInDb(_messageId);
 			MailManager.getInstance().removeAttachmentsInDb(_messageId);
 			if (_unloadTask != null)
 			if (_unloadTask != null)
+			{
 				_unloadTask.cancel(false);
 				_unloadTask.cancel(false);
+			}
 		}
 		}
 	}
 	}
 	
 	
 	public final synchronized Mail createAttachments()
 	public final synchronized Mail createAttachments()
 	{
 	{
-		if (_hasAttachments || _attachments != null)
+		if (_hasAttachments || (_attachments != null))
+		{
 			return null;
 			return null;
+		}
 		
 		
 		_attachments = new Mail(_senderId, _messageId);
 		_attachments = new Mail(_senderId, _messageId);
 		_hasAttachments = true;
 		_hasAttachments = true;

+ 119 - 13
L2J_Server_BETA/java/com/l2jserver/gameserver/model/entity/RecoBonus.java

@@ -21,24 +21,126 @@ import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
  */
  */
 public final class RecoBonus
 public final class RecoBonus
 {
 {
-	private static final int[][] _recoBonus = {
-		{ 25, 50, 50, 50, 50, 50, 50, 50, 50, 50 },
-		{ 16, 33, 50, 50, 50, 50, 50, 50, 50, 50 },
-		{ 12, 25, 37, 50, 50, 50, 50, 50, 50, 50 },
-		{ 10, 20, 30, 40, 50, 50, 50, 50, 50, 50 },
-		{  8, 16, 25, 33, 41, 50, 50, 50, 50, 50 },
-		{  7, 14, 21, 28, 35, 42, 50, 50, 50, 50 },
-		{  6, 12, 18, 25, 31, 37, 43, 50, 50, 50 },
-		{  5, 11, 16, 22, 27, 33, 38, 44, 50, 50 },
-		{  5, 10, 15, 20, 25, 30, 35, 40, 45, 50 }
+	private static final int[][] _recoBonus =
+	{
+		{
+			25,
+			50,
+			50,
+			50,
+			50,
+			50,
+			50,
+			50,
+			50,
+			50
+		},
+		{
+			16,
+			33,
+			50,
+			50,
+			50,
+			50,
+			50,
+			50,
+			50,
+			50
+		},
+		{
+			12,
+			25,
+			37,
+			50,
+			50,
+			50,
+			50,
+			50,
+			50,
+			50
+		},
+		{
+			10,
+			20,
+			30,
+			40,
+			50,
+			50,
+			50,
+			50,
+			50,
+			50
+		},
+		{
+			8,
+			16,
+			25,
+			33,
+			41,
+			50,
+			50,
+			50,
+			50,
+			50
+		},
+		{
+			7,
+			14,
+			21,
+			28,
+			35,
+			42,
+			50,
+			50,
+			50,
+			50
+		},
+		{
+			6,
+			12,
+			18,
+			25,
+			31,
+			37,
+			43,
+			50,
+			50,
+			50
+		},
+		{
+			5,
+			11,
+			16,
+			22,
+			27,
+			33,
+			38,
+			44,
+			50,
+			50
+		},
+		{
+			5,
+			10,
+			15,
+			20,
+			25,
+			30,
+			35,
+			40,
+			45,
+			50
+		}
 	};
 	};
 	
 	
 	public static int getRecoBonus(L2PcInstance activeChar)
 	public static int getRecoBonus(L2PcInstance activeChar)
 	{
 	{
-		if (activeChar != null && activeChar.isOnline())
+		if ((activeChar != null) && activeChar.isOnline())
 		{
 		{
 			if (activeChar.getRecomHave() == 0)
 			if (activeChar.getRecomHave() == 0)
+			{
 				return 0;
 				return 0;
+			}
 			
 			
 			int _lvl = activeChar.getLevel() / 10;
 			int _lvl = activeChar.getLevel() / 10;
 			int _exp = (Math.min(100, activeChar.getRecomHave()) - 1) / 10;
 			int _exp = (Math.min(100, activeChar.getRecomHave()) - 1) / 10;
@@ -53,11 +155,15 @@ public final class RecoBonus
 		double _multiplier = 1;
 		double _multiplier = 1;
 		
 		
 		double bonus = getRecoBonus(activeChar);
 		double bonus = getRecoBonus(activeChar);
-		if(bonus > 0)
+		if (bonus > 0)
+		{
 			_multiplier = (1 + (bonus / 100));
 			_multiplier = (1 + (bonus / 100));
+		}
 		
 		
-		if(_multiplier < 1)
+		if (_multiplier < 1)
+		{
 			_multiplier = 1;
 			_multiplier = 1;
+		}
 		
 		
 		return _multiplier;
 		return _multiplier;
 	}
 	}

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

@@ -24,7 +24,6 @@ import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
 
 
 /**
 /**
  * @author JIV
  * @author JIV
- *
  */
  */
 public interface Siegable
 public interface Siegable
 {
 {
@@ -55,7 +54,9 @@ public interface Siegable
 	public Calendar getSiegeDate();
 	public Calendar getSiegeDate();
 	
 	
 	public boolean giveFame();
 	public boolean giveFame();
+	
 	public int getFameFrequency();
 	public int getFameFrequency();
+	
 	public int getFameAmount();
 	public int getFameAmount();
 	
 	
 	public void updateSiege();
 	public void updateSiege();

+ 207 - 22
L2J_Server_BETA/java/com/l2jserver/gameserver/model/entity/Siege.java

@@ -99,7 +99,9 @@ public class Siege implements Siegable
 		public void run()
 		public void run()
 		{
 		{
 			if (!getIsInProgress())
 			if (!getIsInProgress())
+			{
 				return;
 				return;
+			}
 			
 			
 			try
 			try
 			{
 			{
@@ -165,7 +167,9 @@ public class Siege implements Siegable
 		{
 		{
 			_scheduledStartSiegeTask.cancel(false);
 			_scheduledStartSiegeTask.cancel(false);
 			if (getIsInProgress())
 			if (getIsInProgress())
+			{
 				return;
 				return;
+			}
 			
 			
 			try
 			try
 			{
 			{
@@ -270,7 +274,9 @@ public class Siege implements Siegable
 					final int num = SiegeManager.getInstance().getBloodAllianceReward();
 					final int num = SiegeManager.getInstance().getBloodAllianceReward();
 					int count = getCastle().getBloodAlliance();
 					int count = getCastle().getBloodAlliance();
 					if (num > 0)
 					if (num > 0)
+					{
 						getCastle().setBloodAlliance(count + num);
 						getCastle().setBloodAlliance(count + num);
+					}
 				}
 				}
 				else
 				else
 				{
 				{
@@ -280,7 +286,7 @@ public class Siege implements Siegable
 						if (member != null)
 						if (member != null)
 						{
 						{
 							L2PcInstance player = member.getPlayerInstance();
 							L2PcInstance player = member.getPlayerInstance();
-							if (player != null && player.isNoble())
+							if ((player != null) && player.isNoble())
 							{
 							{
 								Hero.getInstance().setCastleTaken(player.getObjectId(), getCastle().getCastleId());
 								Hero.getInstance().setCastleTaken(player.getObjectId(), getCastle().getCastleId());
 							}
 							}
@@ -308,7 +314,9 @@ public class Siege implements Siegable
 			removeFlameTower();
 			removeFlameTower();
 			_siegeGuardManager.unspawnSiegeGuard(); // Remove all spawned siege guard from this castle
 			_siegeGuardManager.unspawnSiegeGuard(); // Remove all spawned siege guard from this castle
 			if (getCastle().getOwnerId() > 0)
 			if (getCastle().getOwnerId() > 0)
+			{
 				_siegeGuardManager.removeMercs();
 				_siegeGuardManager.removeMercs();
+			}
 			getCastle().spawnDoor(); // Respawn door to castle
 			getCastle().spawnDoor(); // Respawn door to castle
 			getCastle().getZone().setIsActive(false);
 			getCastle().getZone().setIsActive(false);
 			getCastle().getZone().updateZoneStatusForCharactersInside();
 			getCastle().getZone().updateZoneStatusForCharactersInside();
@@ -320,19 +328,25 @@ public class Siege implements Siegable
 	private void removeDefender(L2SiegeClan sc)
 	private void removeDefender(L2SiegeClan sc)
 	{
 	{
 		if (sc != null)
 		if (sc != null)
+		{
 			getDefenderClans().remove(sc);
 			getDefenderClans().remove(sc);
+		}
 	}
 	}
 	
 	
 	private void removeAttacker(L2SiegeClan sc)
 	private void removeAttacker(L2SiegeClan sc)
 	{
 	{
 		if (sc != null)
 		if (sc != null)
+		{
 			getAttackerClans().remove(sc);
 			getAttackerClans().remove(sc);
+		}
 	}
 	}
 	
 	
 	private void addDefender(L2SiegeClan sc, SiegeClanType type)
 	private void addDefender(L2SiegeClan sc, SiegeClanType type)
 	{
 	{
 		if (sc == null)
 		if (sc == null)
+		{
 			return;
 			return;
+		}
 		sc.setType(type);
 		sc.setType(type);
 		getDefenderClans().add(sc);
 		getDefenderClans().add(sc);
 	}
 	}
@@ -340,7 +354,9 @@ public class Siege implements Siegable
 	private void addAttacker(L2SiegeClan sc)
 	private void addAttacker(L2SiegeClan sc)
 	{
 	{
 		if (sc == null)
 		if (sc == null)
+		{
 			return;
 			return;
+		}
 		sc.setType(SiegeClanType.ATTACKER);
 		sc.setType(SiegeClanType.ATTACKER);
 		getAttackerClans().add(sc);
 		getAttackerClans().add(sc);
 	}
 	}
@@ -354,11 +370,13 @@ public class Siege implements Siegable
 		if (getIsInProgress()) // Siege still in progress
 		if (getIsInProgress()) // Siege still in progress
 		{
 		{
 			if (getCastle().getOwnerId() > 0)
 			if (getCastle().getOwnerId() > 0)
+			{
 				_siegeGuardManager.removeMercs(); // Remove all merc entry from db
 				_siegeGuardManager.removeMercs(); // Remove all merc entry from db
-				
+			}
+			
 			if (getDefenderClans().isEmpty() && // If defender doesn't exist (Pc vs Npc)
 			if (getDefenderClans().isEmpty() && // If defender doesn't exist (Pc vs Npc)
-			getAttackerClans().size() == 1 // Only 1 attacker
-			)
+			(getAttackerClans().size() == 1 // Only 1 attacker
+			))
 			{
 			{
 				L2SiegeClan sc_newowner = getAttackerClan(getCastle().getOwnerId());
 				L2SiegeClan sc_newowner = getAttackerClan(getCastle().getOwnerId());
 				removeAttacker(sc_newowner);
 				removeAttacker(sc_newowner);
@@ -381,7 +399,9 @@ public class Siege implements Siegable
 							if (sc != null)
 							if (sc != null)
 							{
 							{
 								if (ClanTable.getInstance().getClan(sc.getClanId()).getAllyId() != allyId)
 								if (ClanTable.getInstance().getClan(sc.getClanId()).getAllyId() != allyId)
+								{
 									allinsamealliance = false;
 									allinsamealliance = false;
+								}
 							}
 							}
 						}
 						}
 						if (allinsamealliance)
 						if (allinsamealliance)
@@ -448,16 +468,22 @@ public class Siege implements Siegable
 		if (!getIsInProgress())
 		if (!getIsInProgress())
 		{
 		{
 			if (!fireSiegeListeners(EventStage.START))
 			if (!fireSiegeListeners(EventStage.START))
+			{
 				return;
 				return;
+			}
 			_firstOwnerClanId = getCastle().getOwnerId();
 			_firstOwnerClanId = getCastle().getOwnerId();
 			
 			
 			if (getAttackerClans().isEmpty())
 			if (getAttackerClans().isEmpty())
 			{
 			{
 				SystemMessage sm;
 				SystemMessage sm;
 				if (getCastle().getOwnerId() <= 0)
 				if (getCastle().getOwnerId() <= 0)
+				{
 					sm = SystemMessage.getSystemMessage(SystemMessageId.SIEGE_OF_S1_HAS_BEEN_CANCELED_DUE_TO_LACK_OF_INTEREST);
 					sm = SystemMessage.getSystemMessage(SystemMessageId.SIEGE_OF_S1_HAS_BEEN_CANCELED_DUE_TO_LACK_OF_INTEREST);
+				}
 				else
 				else
+				{
 					sm = SystemMessage.getSystemMessage(SystemMessageId.S1_SIEGE_WAS_CANCELED_BECAUSE_NO_CLANS_PARTICIPATED);
 					sm = SystemMessage.getSystemMessage(SystemMessageId.S1_SIEGE_WAS_CANCELED_BECAUSE_NO_CLANS_PARTICIPATED);
+				}
 				sm.addCastleId(getCastle().getCastleId());
 				sm.addCastleId(getCastle().getCastleId());
 				Announcements.getInstance().announceToAll(sm);
 				Announcements.getInstance().announceToAll(sm);
 				saveCastleSiege();
 				saveCastleSiege();
@@ -507,7 +533,9 @@ public class Siege implements Siegable
 			for (L2PcInstance member : clan.getOnlineMembers(0))
 			for (L2PcInstance member : clan.getOnlineMembers(0))
 			{
 			{
 				if (member != null)
 				if (member != null)
+				{
 					member.sendPacket(message);
 					member.sendPacket(message);
+				}
 			}
 			}
 		}
 		}
 		
 		
@@ -519,7 +547,9 @@ public class Siege implements Siegable
 				for (L2PcInstance member : clan.getOnlineMembers(0))
 				for (L2PcInstance member : clan.getOnlineMembers(0))
 				{
 				{
 					if (member != null)
 					if (member != null)
+					{
 						member.sendPacket(message);
 						member.sendPacket(message);
+					}
 				}
 				}
 			}
 			}
 		}
 		}
@@ -531,13 +561,17 @@ public class Siege implements Siegable
 		for (L2SiegeClan siegeclan : getAttackerClans())
 		for (L2SiegeClan siegeclan : getAttackerClans())
 		{
 		{
 			if (siegeclan == null)
 			if (siegeclan == null)
+			{
 				continue;
 				continue;
+			}
 			
 			
 			clan = ClanTable.getInstance().getClan(siegeclan.getClanId());
 			clan = ClanTable.getInstance().getClan(siegeclan.getClanId());
 			for (L2PcInstance member : clan.getOnlineMembers(0))
 			for (L2PcInstance member : clan.getOnlineMembers(0))
 			{
 			{
 				if (member == null)
 				if (member == null)
+				{
 					continue;
 					continue;
+				}
 				
 				
 				if (clear)
 				if (clear)
 				{
 				{
@@ -561,24 +595,32 @@ public class Siege implements Siegable
 				for (L2PcInstance player : member.getKnownList().getKnownPlayers().values())
 				for (L2PcInstance player : member.getKnownList().getKnownPlayers().values())
 				{
 				{
 					if (player == null)
 					if (player == null)
+					{
 						continue;
 						continue;
+					}
 					
 					
 					player.sendPacket(new RelationChanged(member, member.getRelation(player), member.isAutoAttackable(player)));
 					player.sendPacket(new RelationChanged(member, member.getRelation(player), member.isAutoAttackable(player)));
 					if (member.getPet() != null)
 					if (member.getPet() != null)
+					{
 						player.sendPacket(new RelationChanged(member.getPet(), member.getRelation(player), member.isAutoAttackable(player)));
 						player.sendPacket(new RelationChanged(member.getPet(), member.getRelation(player), member.isAutoAttackable(player)));
+					}
 				}
 				}
 			}
 			}
 		}
 		}
 		for (L2SiegeClan siegeclan : getDefenderClans())
 		for (L2SiegeClan siegeclan : getDefenderClans())
 		{
 		{
 			if (siegeclan == null)
 			if (siegeclan == null)
+			{
 				continue;
 				continue;
+			}
 			
 			
 			clan = ClanTable.getInstance().getClan(siegeclan.getClanId());
 			clan = ClanTable.getInstance().getClan(siegeclan.getClanId());
 			for (L2PcInstance member : clan.getOnlineMembers(0))
 			for (L2PcInstance member : clan.getOnlineMembers(0))
 			{
 			{
 				if (member == null)
 				if (member == null)
+				{
 					continue;
 					continue;
+				}
 				
 				
 				if (clear)
 				if (clear)
 				{
 				{
@@ -603,10 +645,14 @@ public class Siege implements Siegable
 				for (L2PcInstance player : member.getKnownList().getKnownPlayers().values())
 				for (L2PcInstance player : member.getKnownList().getKnownPlayers().values())
 				{
 				{
 					if (player == null)
 					if (player == null)
+					{
 						continue;
 						continue;
+					}
 					player.sendPacket(new RelationChanged(member, member.getRelation(player), member.isAutoAttackable(player)));
 					player.sendPacket(new RelationChanged(member, member.getRelation(player), member.isAutoAttackable(player)));
 					if (member.getPet() != null)
 					if (member.getPet() != null)
+					{
 						player.sendPacket(new RelationChanged(member.getPet(), member.getRelation(player), member.isAutoAttackable(player)));
 						player.sendPacket(new RelationChanged(member.getPet(), member.getRelation(player), member.isAutoAttackable(player)));
+					}
 				}
 				}
 			}
 			}
 		}
 		}
@@ -620,7 +666,9 @@ public class Siege implements Siegable
 	public void approveSiegeDefenderClan(int clanId)
 	public void approveSiegeDefenderClan(int clanId)
 	{
 	{
 		if (clanId <= 0)
 		if (clanId <= 0)
+		{
 			return;
 			return;
+		}
 		saveSiegeClan(ClanTable.getInstance().getClan(clanId), DEFENDER, true);
 		saveSiegeClan(ClanTable.getInstance().getClan(clanId), DEFENDER, true);
 		loadSiegeClan();
 		loadSiegeClan();
 	}
 	}
@@ -733,10 +781,14 @@ public class Siege implements Siegable
 			for (L2PcInstance player : clan.getOnlineMembers(0))
 			for (L2PcInstance player : clan.getOnlineMembers(0))
 			{
 			{
 				if (player == null)
 				if (player == null)
+				{
 					continue;
 					continue;
+				}
 				
 				
 				if (player.isInSiege())
 				if (player.isInSiege())
+				{
 					players.add(player);
 					players.add(player);
+				}
 			}
 			}
 		}
 		}
 		return players;
 		return players;
@@ -753,14 +805,20 @@ public class Siege implements Siegable
 		{
 		{
 			clan = ClanTable.getInstance().getClan(siegeclan.getClanId());
 			clan = ClanTable.getInstance().getClan(siegeclan.getClanId());
 			if (clan.getClanId() == getCastle().getOwnerId())
 			if (clan.getClanId() == getCastle().getOwnerId())
+			{
 				continue;
 				continue;
+			}
 			for (L2PcInstance player : clan.getOnlineMembers(0))
 			for (L2PcInstance player : clan.getOnlineMembers(0))
 			{
 			{
 				if (player == null)
 				if (player == null)
+				{
 					continue;
 					continue;
+				}
 				
 				
 				if (player.isInSiege())
 				if (player.isInSiege())
+				{
 					players.add(player);
 					players.add(player);
+				}
 			}
 			}
 		}
 		}
 		return players;
 		return players;
@@ -785,14 +843,20 @@ public class Siege implements Siegable
 		{
 		{
 			clan = ClanTable.getInstance().getClan(siegeclan.getClanId());
 			clan = ClanTable.getInstance().getClan(siegeclan.getClanId());
 			if (clan.getClanId() != getCastle().getOwnerId())
 			if (clan.getClanId() != getCastle().getOwnerId())
+			{
 				continue;
 				continue;
+			}
 			for (L2PcInstance player : clan.getOnlineMembers(0))
 			for (L2PcInstance player : clan.getOnlineMembers(0))
 			{
 			{
 				if (player == null)
 				if (player == null)
+				{
 					continue;
 					continue;
+				}
 				
 				
 				if (player.isInSiege())
 				if (player.isInSiege())
+				{
 					players.add(player);
 					players.add(player);
+				}
 			}
 			}
 		}
 		}
 		return players;
 		return players;
@@ -808,10 +872,14 @@ public class Siege implements Siegable
 		for (L2PcInstance player : getCastle().getZone().getPlayersInside())
 		for (L2PcInstance player : getCastle().getZone().getPlayersInside())
 		{
 		{
 			if (player == null)
 			if (player == null)
+			{
 				continue;
 				continue;
+			}
 			
 			
 			if (!player.isInSiege())
 			if (!player.isInSiege())
+			{
 				players.add(player);
 				players.add(player);
+			}
 		}
 		}
 		return players;
 		return players;
 	}
 	}
@@ -824,7 +892,9 @@ public class Siege implements Siegable
 	{
 	{
 		_controlTowerCount--;
 		_controlTowerCount--;
 		if (_controlTowerCount < 0)
 		if (_controlTowerCount < 0)
+		{
 			_controlTowerCount = 0;
 			_controlTowerCount = 0;
+		}
 	}
 	}
 	
 	
 	/**
 	/**
@@ -834,11 +904,15 @@ public class Siege implements Siegable
 	public void killedFlag(L2Npc flag)
 	public void killedFlag(L2Npc flag)
 	{
 	{
 		if (flag == null)
 		if (flag == null)
+		{
 			return;
 			return;
+		}
 		for (L2SiegeClan clan : getAttackerClans())
 		for (L2SiegeClan clan : getAttackerClans())
 		{
 		{
 			if (clan.removeFlag(flag))
 			if (clan.removeFlag(flag))
+			{
 				return;
 				return;
+			}
 		}
 		}
 	}
 	}
 	
 	
@@ -864,20 +938,26 @@ public class Siege implements Siegable
 	public void registerAttacker(L2PcInstance player, boolean force)
 	public void registerAttacker(L2PcInstance player, boolean force)
 	{
 	{
 		if (player.getClan() == null)
 		if (player.getClan() == null)
+		{
 			return;
 			return;
+		}
 		int allyId = 0;
 		int allyId = 0;
 		if (getCastle().getOwnerId() != 0)
 		if (getCastle().getOwnerId() != 0)
+		{
 			allyId = ClanTable.getInstance().getClan(getCastle().getOwnerId()).getAllyId();
 			allyId = ClanTable.getInstance().getClan(getCastle().getOwnerId()).getAllyId();
+		}
 		if (allyId != 0)
 		if (allyId != 0)
 		{
 		{
-			if (player.getClan().getAllyId() == allyId && !force)
+			if ((player.getClan().getAllyId() == allyId) && !force)
 			{
 			{
 				player.sendPacket(SystemMessageId.CANNOT_ATTACK_ALLIANCE_CASTLE);
 				player.sendPacket(SystemMessageId.CANNOT_ATTACK_ALLIANCE_CASTLE);
 				return;
 				return;
 			}
 			}
 		}
 		}
 		if (force || checkIfCanRegister(player, ATTACKER))
 		if (force || checkIfCanRegister(player, ATTACKER))
+		{
 			saveSiegeClan(player.getClan(), ATTACKER, false); // Save to database
 			saveSiegeClan(player.getClan(), ATTACKER, false); // Save to database
+		}
 	}
 	}
 	
 	
 	/**
 	/**
@@ -893,9 +973,13 @@ public class Siege implements Siegable
 	public void registerDefender(L2PcInstance player, boolean force)
 	public void registerDefender(L2PcInstance player, boolean force)
 	{
 	{
 		if (getCastle().getOwnerId() <= 0)
 		if (getCastle().getOwnerId() <= 0)
+		{
 			player.sendMessage("You cannot register as a defender because " + getCastle().getName() + " is owned by NPC.");
 			player.sendMessage("You cannot register as a defender because " + getCastle().getName() + " is owned by NPC.");
+		}
 		else if (force || checkIfCanRegister(player, DEFENDER_NOT_APPROWED))
 		else if (force || checkIfCanRegister(player, DEFENDER_NOT_APPROWED))
+		{
 			saveSiegeClan(player.getClan(), DEFENDER_NOT_APPROWED, false); // Save to database
 			saveSiegeClan(player.getClan(), DEFENDER_NOT_APPROWED, false); // Save to database
+		}
 	}
 	}
 	
 	
 	/**
 	/**
@@ -906,7 +990,9 @@ public class Siege implements Siegable
 	public void removeSiegeClan(int clanId)
 	public void removeSiegeClan(int clanId)
 	{
 	{
 		if (clanId <= 0)
 		if (clanId <= 0)
+		{
 			return;
 			return;
+		}
 		
 		
 		try (Connection con = L2DatabaseFactory.getInstance().getConnection();
 		try (Connection con = L2DatabaseFactory.getInstance().getConnection();
 			PreparedStatement statement = con.prepareStatement("DELETE FROM siege_clans WHERE castle_id=? and clan_id=?"))
 			PreparedStatement statement = con.prepareStatement("DELETE FROM siege_clans WHERE castle_id=? and clan_id=?"))
@@ -930,8 +1016,10 @@ public class Siege implements Siegable
 	 */
 	 */
 	public void removeSiegeClan(L2Clan clan)
 	public void removeSiegeClan(L2Clan clan)
 	{
 	{
-		if (clan == null || clan.getCastleId() == getCastle().getCastleId() || !SiegeManager.getInstance().checkIsRegistered(clan, getCastle().getCastleId()))
+		if ((clan == null) || (clan.getCastleId() == getCastle().getCastleId()) || !SiegeManager.getInstance().checkIsRegistered(clan, getCastle().getCastleId()))
+		{
 			return;
 			return;
+		}
 		removeSiegeClan(clan.getClanId());
 		removeSiegeClan(clan.getClanId());
 	}
 	}
 	
 	
@@ -959,7 +1047,9 @@ public class Siege implements Siegable
 		
 		
 		// Schedule siege auto start
 		// Schedule siege auto start
 		if (_scheduledStartSiegeTask != null)
 		if (_scheduledStartSiegeTask != null)
+		{
 			_scheduledStartSiegeTask.cancel(false);
 			_scheduledStartSiegeTask.cancel(false);
+		}
 		_scheduledStartSiegeTask = ThreadPoolManager.getInstance().scheduleGeneral(new Siege.ScheduleStartSiegeTask(getCastle()), 1000);
 		_scheduledStartSiegeTask = ThreadPoolManager.getInstance().scheduleGeneral(new Siege.ScheduleStartSiegeTask(getCastle()), 1000);
 	}
 	}
 	
 	
@@ -992,7 +1082,9 @@ public class Siege implements Siegable
 		for (L2PcInstance player : players)
 		for (L2PcInstance player : players)
 		{
 		{
 			if (player.isGM() || player.isInJail())
 			if (player.isGM() || player.isInJail())
+			{
 				continue;
 				continue;
+			}
 			player.teleToLocation(teleportWhere);
 			player.teleToLocation(teleportWhere);
 		}
 		}
 	}
 	}
@@ -1053,23 +1145,41 @@ public class Siege implements Siegable
 			player.sendPacket(sm);
 			player.sendPacket(sm);
 		}
 		}
 		else if (getIsInProgress())
 		else if (getIsInProgress())
+		{
 			player.sendPacket(SystemMessageId.NOT_SIEGE_REGISTRATION_TIME2);
 			player.sendPacket(SystemMessageId.NOT_SIEGE_REGISTRATION_TIME2);
-		else if (player.getClan() == null || player.getClan().getLevel() < SiegeManager.getInstance().getSiegeClanMinLevel())
+		}
+		else if ((player.getClan() == null) || (player.getClan().getLevel() < SiegeManager.getInstance().getSiegeClanMinLevel()))
+		{
 			player.sendPacket(SystemMessageId.ONLY_CLAN_LEVEL_5_ABOVE_MAY_SIEGE);
 			player.sendPacket(SystemMessageId.ONLY_CLAN_LEVEL_5_ABOVE_MAY_SIEGE);
+		}
 		else if (player.getClan().getClanId() == getCastle().getOwnerId())
 		else if (player.getClan().getClanId() == getCastle().getOwnerId())
+		{
 			player.sendPacket(SystemMessageId.CLAN_THAT_OWNS_CASTLE_IS_AUTOMATICALLY_REGISTERED_DEFENDING);
 			player.sendPacket(SystemMessageId.CLAN_THAT_OWNS_CASTLE_IS_AUTOMATICALLY_REGISTERED_DEFENDING);
+		}
 		else if (player.getClan().getCastleId() > 0)
 		else if (player.getClan().getCastleId() > 0)
+		{
 			player.sendPacket(SystemMessageId.CLAN_THAT_OWNS_CASTLE_CANNOT_PARTICIPATE_OTHER_SIEGE);
 			player.sendPacket(SystemMessageId.CLAN_THAT_OWNS_CASTLE_CANNOT_PARTICIPATE_OTHER_SIEGE);
+		}
 		else if (SiegeManager.getInstance().checkIsRegistered(player.getClan(), getCastle().getCastleId()))
 		else if (SiegeManager.getInstance().checkIsRegistered(player.getClan(), getCastle().getCastleId()))
+		{
 			player.sendPacket(SystemMessageId.ALREADY_REQUESTED_SIEGE_BATTLE);
 			player.sendPacket(SystemMessageId.ALREADY_REQUESTED_SIEGE_BATTLE);
+		}
 		else if (checkIfAlreadyRegisteredForSameDay(player.getClan()))
 		else if (checkIfAlreadyRegisteredForSameDay(player.getClan()))
+		{
 			player.sendPacket(SystemMessageId.APPLICATION_DENIED_BECAUSE_ALREADY_SUBMITTED_A_REQUEST_FOR_ANOTHER_SIEGE_BATTLE);
 			player.sendPacket(SystemMessageId.APPLICATION_DENIED_BECAUSE_ALREADY_SUBMITTED_A_REQUEST_FOR_ANOTHER_SIEGE_BATTLE);
+		}
 		else if ((typeId == ATTACKER) && (getAttackerClans().size() >= SiegeManager.getInstance().getAttackerMaxClans()))
 		else if ((typeId == ATTACKER) && (getAttackerClans().size() >= SiegeManager.getInstance().getAttackerMaxClans()))
+		{
 			player.sendPacket(SystemMessageId.ATTACKER_SIDE_FULL);
 			player.sendPacket(SystemMessageId.ATTACKER_SIDE_FULL);
-		else if ((typeId == DEFENDER || typeId == DEFENDER_NOT_APPROWED || typeId == OWNER) && (getDefenderClans().size() + getDefenderWaitingClans().size() >= SiegeManager.getInstance().getDefenderMaxClans()))
+		}
+		else if (((typeId == DEFENDER) || (typeId == DEFENDER_NOT_APPROWED) || (typeId == OWNER)) && ((getDefenderClans().size() + getDefenderWaitingClans().size()) >= SiegeManager.getInstance().getDefenderMaxClans()))
+		{
 			player.sendPacket(SystemMessageId.DEFENDER_SIDE_FULL);
 			player.sendPacket(SystemMessageId.DEFENDER_SIDE_FULL);
+		}
 		else
 		else
+		{
 			return true;
 			return true;
+		}
 		
 		
 		return false;
 		return false;
 	}
 	}
@@ -1083,15 +1193,23 @@ public class Siege implements Siegable
 		for (Siege siege : SiegeManager.getInstance().getSieges())
 		for (Siege siege : SiegeManager.getInstance().getSieges())
 		{
 		{
 			if (siege == this)
 			if (siege == this)
+			{
 				continue;
 				continue;
-			if (siege.getSiegeDate().get(Calendar.DAY_OF_WEEK) == this.getSiegeDate().get(Calendar.DAY_OF_WEEK))
+			}
+			if (siege.getSiegeDate().get(Calendar.DAY_OF_WEEK) == getSiegeDate().get(Calendar.DAY_OF_WEEK))
 			{
 			{
 				if (siege.checkIsAttacker(clan))
 				if (siege.checkIsAttacker(clan))
+				{
 					return true;
 					return true;
+				}
 				if (siege.checkIsDefender(clan))
 				if (siege.checkIsDefender(clan))
+				{
 					return true;
 					return true;
+				}
 				if (siege.checkIsDefenderWaiting(clan))
 				if (siege.checkIsDefenderWaiting(clan))
+				{
 					return true;
 					return true;
+				}
 			}
 			}
 		}
 		}
 		return false;
 		return false;
@@ -1122,7 +1240,9 @@ public class Siege implements Siegable
 		}
 		}
 		
 		
 		if (corrected)
 		if (corrected)
+		{
 			saveSiegeDate();
 			saveSiegeDate();
+		}
 	}
 	}
 	
 	
 	/** Load siege clans. */
 	/** Load siege clans. */
@@ -1138,7 +1258,9 @@ public class Siege implements Siegable
 			
 			
 			// Add castle owner as defender (add owner first so that they are on the top of the defender list)
 			// Add castle owner as defender (add owner first so that they are on the top of the defender list)
 			if (getCastle().getOwnerId() > 0)
 			if (getCastle().getOwnerId() > 0)
+			{
 				addDefender(getCastle().getOwnerId(), SiegeClanType.OWNER);
 				addDefender(getCastle().getOwnerId(), SiegeClanType.OWNER);
+			}
 			
 			
 			statement.setInt(1, getCastle().getCastleId());
 			statement.setInt(1, getCastle().getCastleId());
 			try (ResultSet rs = statement.executeQuery())
 			try (ResultSet rs = statement.executeQuery())
@@ -1148,11 +1270,17 @@ public class Siege implements Siegable
 				{
 				{
 					typeId = rs.getInt("type");
 					typeId = rs.getInt("type");
 					if (typeId == DEFENDER)
 					if (typeId == DEFENDER)
+					{
 						addDefender(rs.getInt("clan_id"));
 						addDefender(rs.getInt("clan_id"));
+					}
 					else if (typeId == ATTACKER)
 					else if (typeId == ATTACKER)
+					{
 						addAttacker(rs.getInt("clan_id"));
 						addAttacker(rs.getInt("clan_id"));
+					}
 					else if (typeId == DEFENDER_NOT_APPROWED)
 					else if (typeId == DEFENDER_NOT_APPROWED)
+					{
 						addDefenderWaiting(rs.getInt("clan_id"));
 						addDefenderWaiting(rs.getInt("clan_id"));
+					}
 				}
 				}
 			}
 			}
 		}
 		}
@@ -1165,7 +1293,7 @@ public class Siege implements Siegable
 	/** Remove all control tower spawned. */
 	/** Remove all control tower spawned. */
 	private void removeControlTower()
 	private void removeControlTower()
 	{
 	{
-		if (_controlTowers != null && !_controlTowers.isEmpty())
+		if ((_controlTowers != null) && !_controlTowers.isEmpty())
 		{
 		{
 			// Remove all instances of control tower for this castle
 			// Remove all instances of control tower for this castle
 			for (L2ControlTowerInstance ct : _controlTowers)
 			for (L2ControlTowerInstance ct : _controlTowers)
@@ -1190,7 +1318,7 @@ public class Siege implements Siegable
 	/** Remove all flame towers spawned. */
 	/** Remove all flame towers spawned. */
 	private void removeFlameTower()
 	private void removeFlameTower()
 	{
 	{
-		if (_flameTowers != null && !_flameTowers.isEmpty())
+		if ((_flameTowers != null) && !_flameTowers.isEmpty())
 		{
 		{
 			// Remove all instances of control tower for this castle
 			// Remove all instances of control tower for this castle
 			for (L2FlameTowerInstance ct : _flameTowers)
 			for (L2FlameTowerInstance ct : _flameTowers)
@@ -1218,12 +1346,16 @@ public class Siege implements Siegable
 		for (L2SiegeClan sc : getAttackerClans())
 		for (L2SiegeClan sc : getAttackerClans())
 		{
 		{
 			if (sc != null)
 			if (sc != null)
+			{
 				sc.removeFlags();
 				sc.removeFlags();
+			}
 		}
 		}
 		for (L2SiegeClan sc : getDefenderClans())
 		for (L2SiegeClan sc : getDefenderClans())
 		{
 		{
 			if (sc != null)
 			if (sc != null)
+			{
 				sc.removeFlags();
 				sc.removeFlags();
+			}
 		}
 		}
 	}
 	}
 	
 	
@@ -1233,7 +1365,9 @@ public class Siege implements Siegable
 		for (L2SiegeClan sc : getDefenderClans())
 		for (L2SiegeClan sc : getDefenderClans())
 		{
 		{
 			if (sc != null)
 			if (sc != null)
+			{
 				sc.removeFlags();
 				sc.removeFlags();
+			}
 		}
 		}
 	}
 	}
 	
 	
@@ -1259,7 +1393,6 @@ public class Siege implements Siegable
 			_scheduledStartSiegeTask = ThreadPoolManager.getInstance().scheduleGeneral(new Siege.ScheduleStartSiegeTask(getCastle()), 1000);
 			_scheduledStartSiegeTask = ThreadPoolManager.getInstance().scheduleGeneral(new Siege.ScheduleStartSiegeTask(getCastle()), 1000);
 		}
 		}
 		
 		
-		
 		try (Connection con = L2DatabaseFactory.getInstance().getConnection();
 		try (Connection con = L2DatabaseFactory.getInstance().getConnection();
 			PreparedStatement statement = con.prepareStatement("UPDATE castle SET siegeDate = ?, regTimeEnd = ?, regTimeOver = ?  WHERE id = ?"))
 			PreparedStatement statement = con.prepareStatement("UPDATE castle SET siegeDate = ?, regTimeEnd = ?, regTimeOver = ?  WHERE id = ?"))
 		{
 		{
@@ -1285,19 +1418,25 @@ public class Siege implements Siegable
 	private void saveSiegeClan(L2Clan clan, byte typeId, boolean isUpdateRegistration)
 	private void saveSiegeClan(L2Clan clan, byte typeId, boolean isUpdateRegistration)
 	{
 	{
 		if (clan.getCastleId() > 0)
 		if (clan.getCastleId() > 0)
+		{
 			return;
 			return;
+		}
 		
 		
 		try (Connection con = L2DatabaseFactory.getInstance().getConnection())
 		try (Connection con = L2DatabaseFactory.getInstance().getConnection())
 		{
 		{
-			if (typeId == DEFENDER || typeId == DEFENDER_NOT_APPROWED || typeId == OWNER)
+			if ((typeId == DEFENDER) || (typeId == DEFENDER_NOT_APPROWED) || (typeId == OWNER))
 			{
 			{
-				if (getDefenderClans().size() + getDefenderWaitingClans().size() >= SiegeManager.getInstance().getDefenderMaxClans())
+				if ((getDefenderClans().size() + getDefenderWaitingClans().size()) >= SiegeManager.getInstance().getDefenderMaxClans())
+				{
 					return;
 					return;
+				}
 			}
 			}
 			else
 			else
 			{
 			{
 				if (getAttackerClans().size() >= SiegeManager.getInstance().getAttackerMaxClans())
 				if (getAttackerClans().size() >= SiegeManager.getInstance().getAttackerMaxClans())
+				{
 					return;
 					return;
+				}
 			}
 			}
 			
 			
 			if (!isUpdateRegistration)
 			if (!isUpdateRegistration)
@@ -1321,7 +1460,7 @@ public class Siege implements Siegable
 				}
 				}
 			}
 			}
 			
 			
-			if (typeId == DEFENDER || typeId == OWNER)
+			if ((typeId == DEFENDER) || (typeId == OWNER))
 			{
 			{
 				addDefender(clan.getClanId());
 				addDefender(clan.getClanId());
 			}
 			}
@@ -1345,18 +1484,24 @@ public class Siege implements Siegable
 	{
 	{
 		while (getCastle().getSiegeDate().getTimeInMillis() < Calendar.getInstance().getTimeInMillis())
 		while (getCastle().getSiegeDate().getTimeInMillis() < Calendar.getInstance().getTimeInMillis())
 		{
 		{
-			if (getCastle().getSiegeDate().get(Calendar.DAY_OF_WEEK) != Calendar.SATURDAY && getCastle().getSiegeDate().get(Calendar.DAY_OF_WEEK) != Calendar.SUNDAY)
+			if ((getCastle().getSiegeDate().get(Calendar.DAY_OF_WEEK) != Calendar.SATURDAY) && (getCastle().getSiegeDate().get(Calendar.DAY_OF_WEEK) != Calendar.SUNDAY))
+			{
 				getCastle().getSiegeDate().set(Calendar.DAY_OF_WEEK, Calendar.SATURDAY);
 				getCastle().getSiegeDate().set(Calendar.DAY_OF_WEEK, Calendar.SATURDAY);
+			}
 			// from CT2.3 Castle sieges are on Sunday, but if server admins allow to set day of the siege
 			// from CT2.3 Castle sieges are on Sunday, but if server admins allow to set day of the siege
 			// than sieges can occur on Saturdays as well
 			// than sieges can occur on Saturdays as well
-			if (getCastle().getSiegeDate().get(Calendar.DAY_OF_WEEK) == Calendar.SATURDAY && !Config.CL_SET_SIEGE_TIME_LIST.contains("day"))
+			if ((getCastle().getSiegeDate().get(Calendar.DAY_OF_WEEK) == Calendar.SATURDAY) && !Config.CL_SET_SIEGE_TIME_LIST.contains("day"))
+			{
 				getCastle().getSiegeDate().set(Calendar.DAY_OF_WEEK, Calendar.SUNDAY);
 				getCastle().getSiegeDate().set(Calendar.DAY_OF_WEEK, Calendar.SUNDAY);
+			}
 			// set the next siege day to the next weekend
 			// set the next siege day to the next weekend
 			getCastle().getSiegeDate().add(Calendar.DAY_OF_MONTH, 7);
 			getCastle().getSiegeDate().add(Calendar.DAY_OF_MONTH, 7);
 		}
 		}
 		
 		
 		if (!SevenSigns.getInstance().isDateInSealValidPeriod(getCastle().getSiegeDate()))
 		if (!SevenSigns.getInstance().isDateInSealValidPeriod(getCastle().getSiegeDate()))
+		{
 			getCastle().getSiegeDate().add(Calendar.DAY_OF_MONTH, 7);
 			getCastle().getSiegeDate().add(Calendar.DAY_OF_MONTH, 7);
+		}
 		
 		
 		SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.S1_ANNOUNCED_SIEGE_TIME);
 		SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.S1_ANNOUNCED_SIEGE_TIME);
 		sm.addCastleId(getCastle().getCastleId());
 		sm.addCastleId(getCastle().getCastleId());
@@ -1373,7 +1518,9 @@ public class Siege implements Siegable
 	{
 	{
 		// Set control tower array size if one does not exist
 		// Set control tower array size if one does not exist
 		if (_controlTowers == null)
 		if (_controlTowers == null)
+		{
 			_controlTowers = new ArrayList<>();
 			_controlTowers = new ArrayList<>();
+		}
 		
 		
 		for (SiegeSpawn _sp : SiegeManager.getInstance().getControlTowerSpawnList(Id))
 		for (SiegeSpawn _sp : SiegeManager.getInstance().getControlTowerSpawnList(Id))
 		{
 		{
@@ -1399,7 +1546,9 @@ public class Siege implements Siegable
 	{
 	{
 		// Set control tower array size if one does not exist
 		// Set control tower array size if one does not exist
 		if (_flameTowers == null)
 		if (_flameTowers == null)
+		{
 			_flameTowers = new ArrayList<>();
 			_flameTowers = new ArrayList<>();
+		}
 		
 		
 		for (SiegeSpawn _sp : SiegeManager.getInstance().getFlameTowerSpawnList(Id))
 		for (SiegeSpawn _sp : SiegeManager.getInstance().getFlameTowerSpawnList(Id))
 		{
 		{
@@ -1420,8 +1569,10 @@ public class Siege implements Siegable
 			_flameTowerMaxCount++;
 			_flameTowerMaxCount++;
 			_flameTowers.add(ct);
 			_flameTowers.add(ct);
 		}
 		}
-		if (_flameTowerCount == 0) // TODO: temp fix until flame towers are assigned in config
+		if (_flameTowerCount == 0)
+		{
 			_flameTowerCount = 1;
 			_flameTowerCount = 1;
+		}
 	}
 	}
 	
 	
 	/**
 	/**
@@ -1443,7 +1594,9 @@ public class Siege implements Siegable
 			for (L2Spawn spawn : getSiegeGuardManager().getSiegeGuardSpawn())
 			for (L2Spawn spawn : getSiegeGuardManager().getSiegeGuardSpawn())
 			{
 			{
 				if (spawn == null)
 				if (spawn == null)
+				{
 					continue;
 					continue;
+				}
 				
 				
 				closestCt = null;
 				closestCt = null;
 				distanceClosest = Integer.MAX_VALUE;
 				distanceClosest = Integer.MAX_VALUE;
@@ -1455,7 +1608,9 @@ public class Siege implements Siegable
 				for (L2ControlTowerInstance ct : _controlTowers)
 				for (L2ControlTowerInstance ct : _controlTowers)
 				{
 				{
 					if (ct == null)
 					if (ct == null)
+					{
 						continue;
 						continue;
+					}
 					
 					
 					distance = ct.getDistanceSq(x, y, z);
 					distance = ct.getDistanceSq(x, y, z);
 					
 					
@@ -1466,7 +1621,9 @@ public class Siege implements Siegable
 					}
 					}
 				}
 				}
 				if (closestCt != null)
 				if (closestCt != null)
+				{
 					closestCt.registerGuard(spawn);
 					closestCt.registerGuard(spawn);
+				}
 			}
 			}
 		}
 		}
 	}
 	}
@@ -1475,7 +1632,9 @@ public class Siege implements Siegable
 	public final L2SiegeClan getAttackerClan(L2Clan clan)
 	public final L2SiegeClan getAttackerClan(L2Clan clan)
 	{
 	{
 		if (clan == null)
 		if (clan == null)
+		{
 			return null;
 			return null;
+		}
 		return getAttackerClan(clan.getClanId());
 		return getAttackerClan(clan.getClanId());
 	}
 	}
 	
 	
@@ -1483,8 +1642,12 @@ public class Siege implements Siegable
 	public final L2SiegeClan getAttackerClan(int clanId)
 	public final L2SiegeClan getAttackerClan(int clanId)
 	{
 	{
 		for (L2SiegeClan sc : getAttackerClans())
 		for (L2SiegeClan sc : getAttackerClans())
-			if (sc != null && sc.getClanId() == clanId)
+		{
+			if ((sc != null) && (sc.getClanId() == clanId))
+			{
 				return sc;
 				return sc;
+			}
+		}
 		return null;
 		return null;
 	}
 	}
 	
 	
@@ -1492,7 +1655,9 @@ public class Siege implements Siegable
 	public final List<L2SiegeClan> getAttackerClans()
 	public final List<L2SiegeClan> getAttackerClans()
 	{
 	{
 		if (_isNormalSide)
 		if (_isNormalSide)
+		{
 			return _attackerClans;
 			return _attackerClans;
+		}
 		return _defenderClans;
 		return _defenderClans;
 	}
 	}
 	
 	
@@ -1503,8 +1668,10 @@ public class Siege implements Siegable
 	
 	
 	public final Castle getCastle()
 	public final Castle getCastle()
 	{
 	{
-		if (_castle == null || _castle.length <= 0)
+		if ((_castle == null) || (_castle.length <= 0))
+		{
 			return null;
 			return null;
+		}
 		return _castle[0];
 		return _castle[0];
 	}
 	}
 	
 	
@@ -1512,7 +1679,9 @@ public class Siege implements Siegable
 	public final L2SiegeClan getDefenderClan(L2Clan clan)
 	public final L2SiegeClan getDefenderClan(L2Clan clan)
 	{
 	{
 		if (clan == null)
 		if (clan == null)
+		{
 			return null;
 			return null;
+		}
 		return getDefenderClan(clan.getClanId());
 		return getDefenderClan(clan.getClanId());
 	}
 	}
 	
 	
@@ -1520,8 +1689,12 @@ public class Siege implements Siegable
 	public final L2SiegeClan getDefenderClan(int clanId)
 	public final L2SiegeClan getDefenderClan(int clanId)
 	{
 	{
 		for (L2SiegeClan sc : getDefenderClans())
 		for (L2SiegeClan sc : getDefenderClans())
-			if (sc != null && sc.getClanId() == clanId)
+		{
+			if ((sc != null) && (sc.getClanId() == clanId))
+			{
 				return sc;
 				return sc;
+			}
+		}
 		return null;
 		return null;
 	}
 	}
 	
 	
@@ -1529,22 +1702,30 @@ public class Siege implements Siegable
 	public final List<L2SiegeClan> getDefenderClans()
 	public final List<L2SiegeClan> getDefenderClans()
 	{
 	{
 		if (_isNormalSide)
 		if (_isNormalSide)
+		{
 			return _defenderClans;
 			return _defenderClans;
+		}
 		return _attackerClans;
 		return _attackerClans;
 	}
 	}
 	
 	
 	public final L2SiegeClan getDefenderWaitingClan(L2Clan clan)
 	public final L2SiegeClan getDefenderWaitingClan(L2Clan clan)
 	{
 	{
 		if (clan == null)
 		if (clan == null)
+		{
 			return null;
 			return null;
+		}
 		return getDefenderWaitingClan(clan.getClanId());
 		return getDefenderWaitingClan(clan.getClanId());
 	}
 	}
 	
 	
 	public final L2SiegeClan getDefenderWaitingClan(int clanId)
 	public final L2SiegeClan getDefenderWaitingClan(int clanId)
 	{
 	{
 		for (L2SiegeClan sc : getDefenderWaitingClans())
 		for (L2SiegeClan sc : getDefenderWaitingClans())
-			if (sc != null && sc.getClanId() == clanId)
+		{
+			if ((sc != null) && (sc.getClanId() == clanId))
+			{
 				return sc;
 				return sc;
+			}
+		}
 		return null;
 		return null;
 	}
 	}
 	
 	
@@ -1583,7 +1764,9 @@ public class Siege implements Siegable
 	{
 	{
 		getCastle().setIsTimeRegistrationOver(true);
 		getCastle().setIsTimeRegistrationOver(true);
 		if (!automatic)
 		if (!automatic)
+		{
 			saveSiegeDate();
 			saveSiegeDate();
+		}
 	}
 	}
 	
 	
 	@Override
 	@Override
@@ -1593,7 +1776,9 @@ public class Siege implements Siegable
 		{
 		{
 			L2SiegeClan sc = getAttackerClan(clan);
 			L2SiegeClan sc = getAttackerClan(clan);
 			if (sc != null)
 			if (sc != null)
+			{
 				return sc.getFlag();
 				return sc.getFlag();
+			}
 		}
 		}
 		return null;
 		return null;
 	}
 	}

+ 144 - 95
L2J_Server_BETA/java/com/l2jserver/gameserver/model/entity/TvTEvent.java

@@ -75,7 +75,7 @@ public class TvTEvent
 	protected static final Logger _log = Logger.getLogger(TvTEvent.class.getName());
 	protected static final Logger _log = Logger.getLogger(TvTEvent.class.getName());
 	/** html path **/
 	/** html path **/
 	private static final String htmlPath = "data/html/mods/TvTEvent/";
 	private static final String htmlPath = "data/html/mods/TvTEvent/";
-	/**	The teams of the TvTEvent<br> */
+	/** The teams of the TvTEvent<br> */
 	private static TvTEventTeam[] _teams = new TvTEventTeam[2];
 	private static TvTEventTeam[] _teams = new TvTEventTeam[2];
 	/** The state of the TvTEvent<br> */
 	/** The state of the TvTEvent<br> */
 	private static EventState _state = EventState.INACTIVE;
 	private static EventState _state = EventState.INACTIVE;
@@ -108,8 +108,8 @@ public class TvTEvent
 	/**
 	/**
 	 * Starts the participation of the TvTEvent<br>
 	 * Starts the participation of the TvTEvent<br>
 	 * 1. Get L2NpcTemplate by Config.TVT_EVENT_PARTICIPATION_NPC_ID<br>
 	 * 1. Get L2NpcTemplate by Config.TVT_EVENT_PARTICIPATION_NPC_ID<br>
-	 * 2. Try to spawn a new npc of it<br><br>
-	 *
+	 * 2. Try to spawn a new npc of it<br>
+	 * <br>
 	 * @return boolean: true if success, otherwise false<br>
 	 * @return boolean: true if success, otherwise false<br>
 	 */
 	 */
 	public static boolean startParticipation()
 	public static boolean startParticipation()
@@ -154,7 +154,7 @@ public class TvTEvent
 		return true;
 		return true;
 	}
 	}
 	
 	
-	private static int highestLevelPcInstanceOf(Map< Integer, L2PcInstance > players)
+	private static int highestLevelPcInstanceOf(Map<Integer, L2PcInstance> players)
 	{
 	{
 		int maxLevel = Integer.MIN_VALUE, maxLevelId = -1;
 		int maxLevel = Integer.MIN_VALUE, maxLevelId = -1;
 		for (L2PcInstance player : players.values())
 		for (L2PcInstance player : players.values())
@@ -174,8 +174,8 @@ public class TvTEvent
 	 * 2. Close doors specified in configs<br>
 	 * 2. Close doors specified in configs<br>
 	 * 3. Abort if not enought participants(return false)<br>
 	 * 3. Abort if not enought participants(return false)<br>
 	 * 4. Set state EventState.STARTED<br>
 	 * 4. Set state EventState.STARTED<br>
-	 * 5. Teleport all participants to team spot<br><br>
-	 *
+	 * 5. Teleport all participants to team spot<br>
+	 * <br>
 	 * @return boolean: true if success, otherwise false<br>
 	 * @return boolean: true if success, otherwise false<br>
 	 */
 	 */
 	public static boolean startFight()
 	public static boolean startFight()
@@ -184,12 +184,12 @@ public class TvTEvent
 		setState(EventState.STARTING);
 		setState(EventState.STARTING);
 		
 		
 		// Randomize and balance team distribution
 		// Randomize and balance team distribution
-		Map< Integer, L2PcInstance > allParticipants = new FastMap<>();
+		Map<Integer, L2PcInstance> allParticipants = new FastMap<>();
 		allParticipants.putAll(_teams[0].getParticipatedPlayers());
 		allParticipants.putAll(_teams[0].getParticipatedPlayers());
 		allParticipants.putAll(_teams[1].getParticipatedPlayers());
 		allParticipants.putAll(_teams[1].getParticipatedPlayers());
 		_teams[0].cleanMe();
 		_teams[0].cleanMe();
 		_teams[1].cleanMe();
 		_teams[1].cleanMe();
-
+		
 		L2PcInstance player;
 		L2PcInstance player;
 		Iterator<L2PcInstance> iter;
 		Iterator<L2PcInstance> iter;
 		if (needParticipationFee())
 		if (needParticipationFee())
@@ -199,11 +199,17 @@ public class TvTEvent
 			{
 			{
 				player = iter.next();
 				player = iter.next();
 				if (!hasParticipationFee(player))
 				if (!hasParticipationFee(player))
+				{
 					iter.remove();
 					iter.remove();
+				}
 			}
 			}
 		}
 		}
 		
 		
-		int balance[] = { 0, 0 }, priority = 0, highestLevelPlayerId;
+		int balance[] =
+		{
+			0,
+			0
+		}, priority = 0, highestLevelPlayerId;
 		L2PcInstance highestLevelPlayer;
 		L2PcInstance highestLevelPlayer;
 		// XXX: allParticipants should be sorted by level instead of using highestLevelPcInstanceOf for every fetch
 		// XXX: allParticipants should be sorted by level instead of using highestLevelPcInstanceOf for every fetch
 		while (!allParticipants.isEmpty())
 		while (!allParticipants.isEmpty())
@@ -215,10 +221,13 @@ public class TvTEvent
 			_teams[priority].addPlayer(highestLevelPlayer);
 			_teams[priority].addPlayer(highestLevelPlayer);
 			balance[priority] += highestLevelPlayer.getLevel();
 			balance[priority] += highestLevelPlayer.getLevel();
 			// Exiting if no more players
 			// Exiting if no more players
-			if (allParticipants.isEmpty()) break;
+			if (allParticipants.isEmpty())
+			{
+				break;
+			}
 			// The other team gets one player
 			// The other team gets one player
 			// XXX: Code not dry
 			// XXX: Code not dry
-			priority = 1-priority;
+			priority = 1 - priority;
 			highestLevelPlayerId = highestLevelPcInstanceOf(allParticipants);
 			highestLevelPlayerId = highestLevelPcInstanceOf(allParticipants);
 			highestLevelPlayer = allParticipants.get(highestLevelPlayerId);
 			highestLevelPlayer = allParticipants.get(highestLevelPlayerId);
 			allParticipants.remove(highestLevelPlayerId);
 			allParticipants.remove(highestLevelPlayerId);
@@ -229,7 +238,7 @@ public class TvTEvent
 		}
 		}
 		
 		
 		// Check for enought participants
 		// Check for enought participants
-		if (_teams[0].getParticipatedPlayerCount() < Config.TVT_EVENT_MIN_PLAYERS_IN_TEAMS || _teams[1].getParticipatedPlayerCount() < Config.TVT_EVENT_MIN_PLAYERS_IN_TEAMS)
+		if ((_teams[0].getParticipatedPlayerCount() < Config.TVT_EVENT_MIN_PLAYERS_IN_TEAMS) || (_teams[1].getParticipatedPlayerCount() < Config.TVT_EVENT_MIN_PLAYERS_IN_TEAMS))
 		{
 		{
 			// Set state INACTIVE
 			// Set state INACTIVE
 			setState(EventState.INACTIVE);
 			setState(EventState.INACTIVE);
@@ -249,14 +258,18 @@ public class TvTEvent
 			{
 			{
 				player = iter.next();
 				player = iter.next();
 				if (!payParticipationFee(player))
 				if (!payParticipationFee(player))
+				{
 					iter.remove();
 					iter.remove();
+				}
 			}
 			}
 			iter = _teams[1].getParticipatedPlayers().values().iterator();
 			iter = _teams[1].getParticipatedPlayers().values().iterator();
 			while (iter.hasNext())
 			while (iter.hasNext())
 			{
 			{
 				player = iter.next();
 				player = iter.next();
 				if (!payParticipationFee(player))
 				if (!payParticipationFee(player))
+				{
 					iter.remove();
 					iter.remove();
+				}
 			}
 			}
 		}
 		}
 		
 		
@@ -267,7 +280,7 @@ public class TvTEvent
 				_TvTEventInstance = InstanceManager.getInstance().createDynamicInstance(Config.TVT_EVENT_INSTANCE_FILE);
 				_TvTEventInstance = InstanceManager.getInstance().createDynamicInstance(Config.TVT_EVENT_INSTANCE_FILE);
 				InstanceManager.getInstance().getInstance(_TvTEventInstance).setAllowSummon(false);
 				InstanceManager.getInstance().getInstance(_TvTEventInstance).setAllowSummon(false);
 				InstanceManager.getInstance().getInstance(_TvTEventInstance).setPvPInstance(true);
 				InstanceManager.getInstance().getInstance(_TvTEventInstance).setPvPInstance(true);
-				InstanceManager.getInstance().getInstance(_TvTEventInstance).setEmptyDestroyTime(Config.TVT_EVENT_START_LEAVE_TELEPORT_DELAY * 1000 + 60000L);
+				InstanceManager.getInstance().getInstance(_TvTEventInstance).setEmptyDestroyTime((Config.TVT_EVENT_START_LEAVE_TELEPORT_DELAY * 1000) + 60000L);
 			}
 			}
 			catch (Exception e)
 			catch (Exception e)
 			{
 			{
@@ -307,8 +320,8 @@ public class TvTEvent
 	 * 2. Wait till teams are not at a tie anymore<br>
 	 * 2. Wait till teams are not at a tie anymore<br>
 	 * 3. Set state EvcentState.REWARDING<br>
 	 * 3. Set state EvcentState.REWARDING<br>
 	 * 4. Reward team with more points<br>
 	 * 4. Reward team with more points<br>
-	 * 5. Show win html to wining team participants<br><br>
-	 *
+	 * 5. Show win html to wining team participants<br>
+	 * <br>
 	 * @return String: winning team name<br>
 	 * @return String: winning team name<br>
 	 */
 	 */
 	public static String calculateRewards()
 	public static String calculateRewards()
@@ -316,7 +329,7 @@ public class TvTEvent
 		if (_teams[0].getPoints() == _teams[1].getPoints())
 		if (_teams[0].getPoints() == _teams[1].getPoints())
 		{
 		{
 			// Check if one of the teams have no more players left
 			// Check if one of the teams have no more players left
-			if (_teams[0].getParticipatedPlayerCount() == 0 || _teams[1].getParticipatedPlayerCount() == 0)
+			if ((_teams[0].getParticipatedPlayerCount() == 0) || (_teams[1].getParticipatedPlayerCount() == 0))
 			{
 			{
 				// set state to rewarding
 				// set state to rewarding
 				setState(EventState.REWARDING);
 				setState(EventState.REWARDING);
@@ -398,7 +411,7 @@ public class TvTEvent
 			NpcHtmlMessage npcHtmlMessage = new NpcHtmlMessage(0);
 			NpcHtmlMessage npcHtmlMessage = new NpcHtmlMessage(0);
 			
 			
 			statusUpdate.addAttribute(StatusUpdate.CUR_LOAD, playerInstance.getCurrentLoad());
 			statusUpdate.addAttribute(StatusUpdate.CUR_LOAD, playerInstance.getCurrentLoad());
-			npcHtmlMessage.setHtml(HtmCache.getInstance().getHtm(playerInstance.getHtmlPrefix(), htmlPath+"Reward.htm"));
+			npcHtmlMessage.setHtml(HtmCache.getInstance().getHtm(playerInstance.getHtmlPrefix(), htmlPath + "Reward.htm"));
 			playerInstance.sendPacket(statusUpdate);
 			playerInstance.sendPacket(statusUpdate);
 			playerInstance.sendPacket(npcHtmlMessage);
 			playerInstance.sendPacket(npcHtmlMessage);
 		}
 		}
@@ -417,7 +430,7 @@ public class TvTEvent
 	{
 	{
 		// Set state INACTIVATING
 		// Set state INACTIVATING
 		setState(EventState.INACTIVATING);
 		setState(EventState.INACTIVATING);
-		//Unspawn event npc
+		// Unspawn event npc
 		unSpawnNpc();
 		unSpawnNpc();
 		// Opens all doors specified in configs for tvt
 		// Opens all doors specified in configs for tvt
 		openDoors(Config.TVT_DOORS_IDS_TO_CLOSE);
 		openDoors(Config.TVT_DOORS_IDS_TO_CLOSE);
@@ -448,8 +461,8 @@ public class TvTEvent
 	/**
 	/**
 	 * Adds a player to a TvTEvent team<br>
 	 * Adds a player to a TvTEvent team<br>
 	 * 1. Calculate the id of the team in which the player should be added<br>
 	 * 1. Calculate the id of the team in which the player should be added<br>
-	 * 2. Add the player to the calculated team<br><br>
-	 *
+	 * 2. Add the player to the calculated team<br>
+	 * <br>
 	 * @param playerInstance as L2PcInstance<br>
 	 * @param playerInstance as L2PcInstance<br>
 	 * @return boolean: true if success, otherwise false<br>
 	 * @return boolean: true if success, otherwise false<br>
 	 */
 	 */
@@ -479,8 +492,8 @@ public class TvTEvent
 	/**
 	/**
 	 * Removes a TvTEvent player from it's team<br>
 	 * Removes a TvTEvent player from it's team<br>
 	 * 1. Get team id of the player<br>
 	 * 1. Get team id of the player<br>
-	 * 2. Remove player from it's team<br><br>
-	 *
+	 * 2. Remove player from it's team<br>
+	 * <br>
 	 * @param playerObjectId
 	 * @param playerObjectId
 	 * @return boolean: true if success, otherwise false
 	 * @return boolean: true if success, otherwise false
 	 */
 	 */
@@ -502,7 +515,7 @@ public class TvTEvent
 	
 	
 	public static boolean needParticipationFee()
 	public static boolean needParticipationFee()
 	{
 	{
-		return Config.TVT_EVENT_PARTICIPATION_FEE[0] != 0 && Config.TVT_EVENT_PARTICIPATION_FEE[1] != 0;
+		return (Config.TVT_EVENT_PARTICIPATION_FEE[0] != 0) && (Config.TVT_EVENT_PARTICIPATION_FEE[1] != 0);
 	}
 	}
 	
 	
 	public static boolean hasParticipationFee(L2PcInstance playerInstance)
 	public static boolean hasParticipationFee(L2PcInstance playerInstance)
@@ -520,8 +533,10 @@ public class TvTEvent
 		int itemId = Config.TVT_EVENT_PARTICIPATION_FEE[0];
 		int itemId = Config.TVT_EVENT_PARTICIPATION_FEE[0];
 		int itemNum = Config.TVT_EVENT_PARTICIPATION_FEE[1];
 		int itemNum = Config.TVT_EVENT_PARTICIPATION_FEE[1];
 		
 		
-		if (itemId == 0 || itemNum == 0)
+		if ((itemId == 0) || (itemNum == 0))
+		{
 			return "-";
 			return "-";
+		}
 		
 		
 		return StringUtil.concat(String.valueOf(itemNum), " ", ItemTable.getInstance().getTemplate(itemId).getName());
 		return StringUtil.concat(String.valueOf(itemNum), " ", ItemTable.getInstance().getTemplate(itemId).getName());
 	}
 	}
@@ -529,8 +544,8 @@ public class TvTEvent
 	/**
 	/**
 	 * Send a SystemMessage to all participated players<br>
 	 * Send a SystemMessage to all participated players<br>
 	 * 1. Send the message to all players of team number one<br>
 	 * 1. Send the message to all players of team number one<br>
-	 * 2. Send the message to all players of team number two<br><br>
-	 *
+	 * 2. Send the message to all players of team number two<br>
+	 * <br>
 	 * @param message as String<br>
 	 * @param message as String<br>
 	 */
 	 */
 	public static void sysMsgToAllParticipants(String message)
 	public static void sysMsgToAllParticipants(String message)
@@ -554,7 +569,7 @@ public class TvTEvent
 	
 	
 	/**
 	/**
 	 * Close doors specified in configs
 	 * Close doors specified in configs
-	 * @param doors 
+	 * @param doors
 	 */
 	 */
 	private static void closeDoors(List<Integer> doors)
 	private static void closeDoors(List<Integer> doors)
 	{
 	{
@@ -571,7 +586,7 @@ public class TvTEvent
 	
 	
 	/**
 	/**
 	 * Open doors specified in configs
 	 * Open doors specified in configs
-	 * @param doors 
+	 * @param doors
 	 */
 	 */
 	private static void openDoors(List<Integer> doors)
 	private static void openDoors(List<Integer> doors)
 	{
 	{
@@ -601,13 +616,13 @@ public class TvTEvent
 	}
 	}
 	
 	
 	/**
 	/**
-	 * Called when a player logs in<br><br>
-	 *
+	 * Called when a player logs in<br>
+	 * <br>
 	 * @param playerInstance as L2PcInstance<br>
 	 * @param playerInstance as L2PcInstance<br>
 	 */
 	 */
 	public static void onLogin(L2PcInstance playerInstance)
 	public static void onLogin(L2PcInstance playerInstance)
 	{
 	{
-		if (playerInstance == null || (!isStarting() && !isStarted()))
+		if ((playerInstance == null) || (!isStarting() && !isStarted()))
 		{
 		{
 			return;
 			return;
 		}
 		}
@@ -624,32 +639,34 @@ public class TvTEvent
 	}
 	}
 	
 	
 	/**
 	/**
-	 * Called when a player logs out<br><br>
-	 *
+	 * Called when a player logs out<br>
+	 * <br>
 	 * @param playerInstance as L2PcInstance<br>
 	 * @param playerInstance as L2PcInstance<br>
 	 */
 	 */
 	public static void onLogout(L2PcInstance playerInstance)
 	public static void onLogout(L2PcInstance playerInstance)
 	{
 	{
-		if (playerInstance != null && (isStarting() || isStarted() || isParticipating()))
+		if ((playerInstance != null) && (isStarting() || isStarted() || isParticipating()))
 		{
 		{
 			if (removeParticipant(playerInstance.getObjectId()))
 			if (removeParticipant(playerInstance.getObjectId()))
-				playerInstance.setXYZInvisible(Config.TVT_EVENT_PARTICIPATION_NPC_COORDINATES[0] + Rnd.get(101)-50,
-						Config.TVT_EVENT_PARTICIPATION_NPC_COORDINATES[1] + Rnd.get(101)-50,
-						Config.TVT_EVENT_PARTICIPATION_NPC_COORDINATES[2]);
+			{
+				playerInstance.setXYZInvisible((Config.TVT_EVENT_PARTICIPATION_NPC_COORDINATES[0] + Rnd.get(101)) - 50, (Config.TVT_EVENT_PARTICIPATION_NPC_COORDINATES[1] + Rnd.get(101)) - 50, Config.TVT_EVENT_PARTICIPATION_NPC_COORDINATES[2]);
+			}
 		}
 		}
 	}
 	}
 	
 	
 	/**
 	/**
 	 * Called on every bypass by npc of type L2TvTEventNpc<br>
 	 * Called on every bypass by npc of type L2TvTEventNpc<br>
-	 * Needs synchronization cause of the max player check<br><br>
-	 *
+	 * Needs synchronization cause of the max player check<br>
+	 * <br>
 	 * @param command as String<br>
 	 * @param command as String<br>
 	 * @param playerInstance as L2PcInstance<br>
 	 * @param playerInstance as L2PcInstance<br>
 	 */
 	 */
 	public static synchronized void onBypass(String command, L2PcInstance playerInstance)
 	public static synchronized void onBypass(String command, L2PcInstance playerInstance)
 	{
 	{
-		if (playerInstance == null || !isParticipating())
+		if ((playerInstance == null) || !isParticipating())
+		{
 			return;
 			return;
+		}
 		
 		
 		final String htmContent;
 		final String htmContent;
 		
 		
@@ -660,25 +677,31 @@ public class TvTEvent
 			
 			
 			if (playerInstance.isCursedWeaponEquipped())
 			if (playerInstance.isCursedWeaponEquipped())
 			{
 			{
-				htmContent = HtmCache.getInstance().getHtm(playerInstance.getHtmlPrefix(), htmlPath+"CursedWeaponEquipped.htm");
+				htmContent = HtmCache.getInstance().getHtm(playerInstance.getHtmlPrefix(), htmlPath + "CursedWeaponEquipped.htm");
 				if (htmContent != null)
 				if (htmContent != null)
+				{
 					npcHtmlMessage.setHtml(htmContent);
 					npcHtmlMessage.setHtml(htmContent);
+				}
 			}
 			}
 			else if (OlympiadManager.getInstance().isRegistered(playerInstance))
 			else if (OlympiadManager.getInstance().isRegistered(playerInstance))
 			{
 			{
-				htmContent = HtmCache.getInstance().getHtm(playerInstance.getHtmlPrefix(), htmlPath+"Olympiad.htm");
+				htmContent = HtmCache.getInstance().getHtm(playerInstance.getHtmlPrefix(), htmlPath + "Olympiad.htm");
 				if (htmContent != null)
 				if (htmContent != null)
+				{
 					npcHtmlMessage.setHtml(htmContent);
 					npcHtmlMessage.setHtml(htmContent);
+				}
 			}
 			}
 			else if (playerInstance.getKarma() > 0)
 			else if (playerInstance.getKarma() > 0)
 			{
 			{
-				htmContent = HtmCache.getInstance().getHtm(playerInstance.getHtmlPrefix(), htmlPath+"Karma.htm");
+				htmContent = HtmCache.getInstance().getHtm(playerInstance.getHtmlPrefix(), htmlPath + "Karma.htm");
 				if (htmContent != null)
 				if (htmContent != null)
+				{
 					npcHtmlMessage.setHtml(htmContent);
 					npcHtmlMessage.setHtml(htmContent);
+				}
 			}
 			}
-			else if (playerLevel < Config.TVT_EVENT_MIN_LVL || playerLevel > Config.TVT_EVENT_MAX_LVL)
+			else if ((playerLevel < Config.TVT_EVENT_MIN_LVL) || (playerLevel > Config.TVT_EVENT_MAX_LVL))
 			{
 			{
-				htmContent = HtmCache.getInstance().getHtm(playerInstance.getHtmlPrefix(), htmlPath+"Level.htm");
+				htmContent = HtmCache.getInstance().getHtm(playerInstance.getHtmlPrefix(), htmlPath + "Level.htm");
 				if (htmContent != null)
 				if (htmContent != null)
 				{
 				{
 					npcHtmlMessage.setHtml(htmContent);
 					npcHtmlMessage.setHtml(htmContent);
@@ -686,19 +709,18 @@ public class TvTEvent
 					npcHtmlMessage.replace("%max%", String.valueOf(Config.TVT_EVENT_MAX_LVL));
 					npcHtmlMessage.replace("%max%", String.valueOf(Config.TVT_EVENT_MAX_LVL));
 				}
 				}
 			}
 			}
-			else if (_teams[0].getParticipatedPlayerCount() == Config.TVT_EVENT_MAX_PLAYERS_IN_TEAMS && _teams[1].getParticipatedPlayerCount() == Config.TVT_EVENT_MAX_PLAYERS_IN_TEAMS)
+			else if ((_teams[0].getParticipatedPlayerCount() == Config.TVT_EVENT_MAX_PLAYERS_IN_TEAMS) && (_teams[1].getParticipatedPlayerCount() == Config.TVT_EVENT_MAX_PLAYERS_IN_TEAMS))
 			{
 			{
-				htmContent = HtmCache.getInstance().getHtm(playerInstance.getHtmlPrefix(), htmlPath+"TeamsFull.htm");
+				htmContent = HtmCache.getInstance().getHtm(playerInstance.getHtmlPrefix(), htmlPath + "TeamsFull.htm");
 				if (htmContent != null)
 				if (htmContent != null)
 				{
 				{
 					npcHtmlMessage.setHtml(htmContent);
 					npcHtmlMessage.setHtml(htmContent);
 					npcHtmlMessage.replace("%max%", String.valueOf(Config.TVT_EVENT_MAX_PLAYERS_IN_TEAMS));
 					npcHtmlMessage.replace("%max%", String.valueOf(Config.TVT_EVENT_MAX_PLAYERS_IN_TEAMS));
 				}
 				}
 			}
 			}
-			else if (Config.TVT_EVENT_MAX_PARTICIPANTS_PER_IP > 0
-					&& !AntiFeedManager.getInstance().tryAddPlayer(AntiFeedManager.TVT_ID, playerInstance, Config.TVT_EVENT_MAX_PARTICIPANTS_PER_IP))
+			else if ((Config.TVT_EVENT_MAX_PARTICIPANTS_PER_IP > 0) && !AntiFeedManager.getInstance().tryAddPlayer(AntiFeedManager.TVT_ID, playerInstance, Config.TVT_EVENT_MAX_PARTICIPANTS_PER_IP))
 			{
 			{
-				htmContent = HtmCache.getInstance().getHtm(playerInstance.getHtmlPrefix(), htmlPath+"IPRestriction.htm");
+				htmContent = HtmCache.getInstance().getHtm(playerInstance.getHtmlPrefix(), htmlPath + "IPRestriction.htm");
 				if (htmContent != null)
 				if (htmContent != null)
 				{
 				{
 					npcHtmlMessage.setHtml(htmContent);
 					npcHtmlMessage.setHtml(htmContent);
@@ -707,7 +729,7 @@ public class TvTEvent
 			}
 			}
 			else if (needParticipationFee() && !hasParticipationFee(playerInstance))
 			else if (needParticipationFee() && !hasParticipationFee(playerInstance))
 			{
 			{
-				htmContent = HtmCache.getInstance().getHtm(playerInstance.getHtmlPrefix(), htmlPath+"ParticipationFee.htm");
+				htmContent = HtmCache.getInstance().getHtm(playerInstance.getHtmlPrefix(), htmlPath + "ParticipationFee.htm");
 				if (htmContent != null)
 				if (htmContent != null)
 				{
 				{
 					npcHtmlMessage.setHtml(htmContent);
 					npcHtmlMessage.setHtml(htmContent);
@@ -715,9 +737,13 @@ public class TvTEvent
 				}
 				}
 			}
 			}
 			else if (addParticipant(playerInstance))
 			else if (addParticipant(playerInstance))
-				npcHtmlMessage.setHtml(HtmCache.getInstance().getHtm(playerInstance.getHtmlPrefix(), htmlPath+"Registered.htm"));
+			{
+				npcHtmlMessage.setHtml(HtmCache.getInstance().getHtm(playerInstance.getHtmlPrefix(), htmlPath + "Registered.htm"));
+			}
 			else
 			else
+			{
 				return;
 				return;
+			}
 			
 			
 			playerInstance.sendPacket(npcHtmlMessage);
 			playerInstance.sendPacket(npcHtmlMessage);
 		}
 		}
@@ -725,25 +751,27 @@ public class TvTEvent
 		{
 		{
 			removeParticipant(playerInstance.getObjectId());
 			removeParticipant(playerInstance.getObjectId());
 			if (Config.TVT_EVENT_MAX_PARTICIPANTS_PER_IP > 0)
 			if (Config.TVT_EVENT_MAX_PARTICIPANTS_PER_IP > 0)
+			{
 				AntiFeedManager.getInstance().removePlayer(AntiFeedManager.TVT_ID, playerInstance);
 				AntiFeedManager.getInstance().removePlayer(AntiFeedManager.TVT_ID, playerInstance);
+			}
 			
 			
 			NpcHtmlMessage npcHtmlMessage = new NpcHtmlMessage(0);
 			NpcHtmlMessage npcHtmlMessage = new NpcHtmlMessage(0);
 			
 			
-			npcHtmlMessage.setHtml(HtmCache.getInstance().getHtm(playerInstance.getHtmlPrefix(), htmlPath+"Unregistered.htm"));
+			npcHtmlMessage.setHtml(HtmCache.getInstance().getHtm(playerInstance.getHtmlPrefix(), htmlPath + "Unregistered.htm"));
 			playerInstance.sendPacket(npcHtmlMessage);
 			playerInstance.sendPacket(npcHtmlMessage);
 		}
 		}
 	}
 	}
 	
 	
 	/**
 	/**
-	 * Called on every onAction in L2PcIstance<br><br>
-	 *
+	 * Called on every onAction in L2PcIstance<br>
+	 * <br>
 	 * @param playerInstance
 	 * @param playerInstance
 	 * @param targetedPlayerObjectId
 	 * @param targetedPlayerObjectId
 	 * @return boolean: true if player is allowed to target, otherwise false
 	 * @return boolean: true if player is allowed to target, otherwise false
 	 */
 	 */
 	public static boolean onAction(L2PcInstance playerInstance, int targetedPlayerObjectId)
 	public static boolean onAction(L2PcInstance playerInstance, int targetedPlayerObjectId)
 	{
 	{
-		if (playerInstance == null || !isStarted())
+		if ((playerInstance == null) || !isStarted())
 		{
 		{
 			return true;
 			return true;
 		}
 		}
@@ -756,12 +784,12 @@ public class TvTEvent
 		byte playerTeamId = getParticipantTeamId(playerInstance.getObjectId());
 		byte playerTeamId = getParticipantTeamId(playerInstance.getObjectId());
 		byte targetedPlayerTeamId = getParticipantTeamId(targetedPlayerObjectId);
 		byte targetedPlayerTeamId = getParticipantTeamId(targetedPlayerObjectId);
 		
 		
-		if ((playerTeamId != -1 && targetedPlayerTeamId == -1) || (playerTeamId == -1 && targetedPlayerTeamId != -1))
+		if (((playerTeamId != -1) && (targetedPlayerTeamId == -1)) || ((playerTeamId == -1) && (targetedPlayerTeamId != -1)))
 		{
 		{
 			return false;
 			return false;
 		}
 		}
 		
 		
-		if (playerTeamId != -1 && targetedPlayerTeamId != -1 && playerTeamId == targetedPlayerTeamId && playerInstance.getObjectId() != targetedPlayerObjectId && !Config.TVT_EVENT_TARGET_TEAM_MEMBERS_ALLOWED)
+		if ((playerTeamId != -1) && (targetedPlayerTeamId != -1) && (playerTeamId == targetedPlayerTeamId) && (playerInstance.getObjectId() != targetedPlayerObjectId) && !Config.TVT_EVENT_TARGET_TEAM_MEMBERS_ALLOWED)
 		{
 		{
 			return false;
 			return false;
 		}
 		}
@@ -770,18 +798,22 @@ public class TvTEvent
 	}
 	}
 	
 	
 	/**
 	/**
-	 * Called on every scroll use<br><br>
-	 *
+	 * Called on every scroll use<br>
+	 * <br>
 	 * @param playerObjectId
 	 * @param playerObjectId
 	 * @return boolean: true if player is allowed to use scroll, otherwise false
 	 * @return boolean: true if player is allowed to use scroll, otherwise false
 	 */
 	 */
 	public static boolean onScrollUse(int playerObjectId)
 	public static boolean onScrollUse(int playerObjectId)
 	{
 	{
 		if (!isStarted())
 		if (!isStarted())
+		{
 			return true;
 			return true;
+		}
 		
 		
 		if (isPlayerParticipant(playerObjectId) && !Config.TVT_EVENT_SCROLL_ALLOWED)
 		if (isPlayerParticipant(playerObjectId) && !Config.TVT_EVENT_SCROLL_ALLOWED)
+		{
 			return false;
 			return false;
+		}
 		
 		
 		return true;
 		return true;
 	}
 	}
@@ -794,10 +826,14 @@ public class TvTEvent
 	public static boolean onPotionUse(int playerObjectId)
 	public static boolean onPotionUse(int playerObjectId)
 	{
 	{
 		if (!isStarted())
 		if (!isStarted())
+		{
 			return true;
 			return true;
+		}
 		
 		
 		if (isPlayerParticipant(playerObjectId) && !Config.TVT_EVENT_POTIONS_ALLOWED)
 		if (isPlayerParticipant(playerObjectId) && !Config.TVT_EVENT_POTIONS_ALLOWED)
+		{
 			return false;
 			return false;
+		}
 		
 		
 		return true;
 		return true;
 	}
 	}
@@ -843,14 +879,14 @@ public class TvTEvent
 	}
 	}
 	
 	
 	/**
 	/**
-	 * Is called when a player is killed<br><br>
-	 * 
+	 * Is called when a player is killed<br>
+	 * <br>
 	 * @param killerCharacter as L2Character<br>
 	 * @param killerCharacter as L2Character<br>
 	 * @param killedPlayerInstance as L2PcInstance<br>
 	 * @param killedPlayerInstance as L2PcInstance<br>
 	 */
 	 */
 	public static void onKill(L2Character killerCharacter, L2PcInstance killedPlayerInstance)
 	public static void onKill(L2Character killerCharacter, L2PcInstance killedPlayerInstance)
 	{
 	{
-		if (killedPlayerInstance == null || !isStarted())
+		if ((killedPlayerInstance == null) || !isStarted())
 		{
 		{
 			return;
 			return;
 		}
 		}
@@ -871,7 +907,7 @@ public class TvTEvent
 		
 		
 		L2PcInstance killerPlayerInstance = null;
 		L2PcInstance killerPlayerInstance = null;
 		
 		
-		if (killerCharacter instanceof L2PetInstance || killerCharacter instanceof L2ServitorInstance)
+		if ((killerCharacter instanceof L2PetInstance) || (killerCharacter instanceof L2ServitorInstance))
 		{
 		{
 			killerPlayerInstance = ((L2Summon) killerCharacter).getOwner();
 			killerPlayerInstance = ((L2Summon) killerCharacter).getOwner();
 			
 			
@@ -891,7 +927,7 @@ public class TvTEvent
 		
 		
 		byte killerTeamId = getParticipantTeamId(killerPlayerInstance.getObjectId());
 		byte killerTeamId = getParticipantTeamId(killerPlayerInstance.getObjectId());
 		
 		
-		if (killerTeamId != -1 && killedTeamId != -1 && killerTeamId != killedTeamId)
+		if ((killerTeamId != -1) && (killedTeamId != -1) && (killerTeamId != killedTeamId))
 		{
 		{
 			TvTEventTeam killerTeam = _teams[killerTeamId];
 			TvTEventTeam killerTeam = _teams[killerTeamId];
 			
 			
@@ -906,7 +942,7 @@ public class TvTEvent
 					playerInstance.sendPacket(cs);
 					playerInstance.sendPacket(cs);
 				}
 				}
 			}
 			}
-			fireTvtKillListeners(killerPlayerInstance,killedPlayerInstance,killerTeam);
+			fireTvtKillListeners(killerPlayerInstance, killedPlayerInstance, killerTeam);
 		}
 		}
 	}
 	}
 	
 	
@@ -916,45 +952,53 @@ public class TvTEvent
 	 */
 	 */
 	public static void onTeleported(L2PcInstance playerInstance)
 	public static void onTeleported(L2PcInstance playerInstance)
 	{
 	{
-		if (!isStarted() || playerInstance == null || !isPlayerParticipant(playerInstance.getObjectId()))
+		if (!isStarted() || (playerInstance == null) || !isPlayerParticipant(playerInstance.getObjectId()))
+		{
 			return;
 			return;
+		}
 		
 		
 		if (playerInstance.isMageClass())
 		if (playerInstance.isMageClass())
 		{
 		{
-			if (Config.TVT_EVENT_MAGE_BUFFS != null && !Config.TVT_EVENT_MAGE_BUFFS.isEmpty())
+			if ((Config.TVT_EVENT_MAGE_BUFFS != null) && !Config.TVT_EVENT_MAGE_BUFFS.isEmpty())
 			{
 			{
 				for (int i : Config.TVT_EVENT_MAGE_BUFFS.keySet())
 				for (int i : Config.TVT_EVENT_MAGE_BUFFS.keySet())
 				{
 				{
 					L2Skill skill = SkillTable.getInstance().getInfo(i, Config.TVT_EVENT_MAGE_BUFFS.get(i));
 					L2Skill skill = SkillTable.getInstance().getInfo(i, Config.TVT_EVENT_MAGE_BUFFS.get(i));
 					if (skill != null)
 					if (skill != null)
+					{
 						skill.getEffects(playerInstance, playerInstance);
 						skill.getEffects(playerInstance, playerInstance);
+					}
 				}
 				}
 			}
 			}
 		}
 		}
 		else
 		else
 		{
 		{
-			if (Config.TVT_EVENT_FIGHTER_BUFFS != null && !Config.TVT_EVENT_FIGHTER_BUFFS.isEmpty())
+			if ((Config.TVT_EVENT_FIGHTER_BUFFS != null) && !Config.TVT_EVENT_FIGHTER_BUFFS.isEmpty())
 			{
 			{
 				for (int i : Config.TVT_EVENT_FIGHTER_BUFFS.keySet())
 				for (int i : Config.TVT_EVENT_FIGHTER_BUFFS.keySet())
 				{
 				{
 					L2Skill skill = SkillTable.getInstance().getInfo(i, Config.TVT_EVENT_FIGHTER_BUFFS.get(i));
 					L2Skill skill = SkillTable.getInstance().getInfo(i, Config.TVT_EVENT_FIGHTER_BUFFS.get(i));
 					if (skill != null)
 					if (skill != null)
+					{
 						skill.getEffects(playerInstance, playerInstance);
 						skill.getEffects(playerInstance, playerInstance);
+					}
 				}
 				}
 			}
 			}
 		}
 		}
 	}
 	}
 	
 	
 	/**
 	/**
-	 * @param source 
-	 * @param target 
-	 * @param skill 
+	 * @param source
+	 * @param target
+	 * @param skill
 	 * @return true if player valid for skill
 	 * @return true if player valid for skill
 	 */
 	 */
 	public static final boolean checkForTvTSkill(L2PcInstance source, L2PcInstance target, L2Skill skill)
 	public static final boolean checkForTvTSkill(L2PcInstance source, L2PcInstance target, L2Skill skill)
 	{
 	{
 		if (!isStarted())
 		if (!isStarted())
+		{
 			return true;
 			return true;
+		}
 		// TvT is started
 		// TvT is started
 		final int sourcePlayerId = source.getObjectId();
 		final int sourcePlayerId = source.getObjectId();
 		final int targetPlayerId = target.getObjectId();
 		final int targetPlayerId = target.getObjectId();
@@ -963,22 +1007,28 @@ public class TvTEvent
 		
 		
 		// both players not participating
 		// both players not participating
 		if (!isSourceParticipant && !isTargetParticipant)
 		if (!isSourceParticipant && !isTargetParticipant)
+		{
 			return true;
 			return true;
+		}
 		// one player not participating
 		// one player not participating
 		if (!(isSourceParticipant && isTargetParticipant))
 		if (!(isSourceParticipant && isTargetParticipant))
+		{
 			return false;
 			return false;
+		}
 		// players in the different teams ?
 		// players in the different teams ?
 		if (getParticipantTeamId(sourcePlayerId) != getParticipantTeamId(targetPlayerId))
 		if (getParticipantTeamId(sourcePlayerId) != getParticipantTeamId(targetPlayerId))
 		{
 		{
 			if (!skill.isOffensive())
 			if (!skill.isOffensive())
+			{
 				return false;
 				return false;
+			}
 		}
 		}
 		return true;
 		return true;
 	}
 	}
 	
 	
 	/**
 	/**
-	 * Sets the TvTEvent state<br><br>
-	 *
+	 * Sets the TvTEvent state<br>
+	 * <br>
 	 * @param state as EventState<br>
 	 * @param state as EventState<br>
 	 */
 	 */
 	private static void setState(EventState state)
 	private static void setState(EventState state)
@@ -990,8 +1040,8 @@ public class TvTEvent
 	}
 	}
 	
 	
 	/**
 	/**
-	 * Is TvTEvent inactive?<br><br>
-	 *
+	 * Is TvTEvent inactive?<br>
+	 * <br>
 	 * @return boolean: true if event is inactive(waiting for next event cycle), otherwise false<br>
 	 * @return boolean: true if event is inactive(waiting for next event cycle), otherwise false<br>
 	 */
 	 */
 	public static boolean isInactive()
 	public static boolean isInactive()
@@ -1007,8 +1057,8 @@ public class TvTEvent
 	}
 	}
 	
 	
 	/**
 	/**
-	 * Is TvTEvent in inactivating?<br><br>
-	 *
+	 * Is TvTEvent in inactivating?<br>
+	 * <br>
 	 * @return boolean: true if event is in inactivating progress, otherwise false<br>
 	 * @return boolean: true if event is in inactivating progress, otherwise false<br>
 	 */
 	 */
 	public static boolean isInactivating()
 	public static boolean isInactivating()
@@ -1024,8 +1074,8 @@ public class TvTEvent
 	}
 	}
 	
 	
 	/**
 	/**
-	 * Is TvTEvent in participation?<br><br>
-	 *
+	 * Is TvTEvent in participation?<br>
+	 * <br>
 	 * @return boolean: true if event is in participation progress, otherwise false<br>
 	 * @return boolean: true if event is in participation progress, otherwise false<br>
 	 */
 	 */
 	public static boolean isParticipating()
 	public static boolean isParticipating()
@@ -1041,8 +1091,8 @@ public class TvTEvent
 	}
 	}
 	
 	
 	/**
 	/**
-	 * Is TvTEvent starting?<br><br>
-	 *
+	 * Is TvTEvent starting?<br>
+	 * <br>
 	 * @return boolean: true if event is starting up(setting up fighting spot, teleport players etc.), otherwise false<br>
 	 * @return boolean: true if event is starting up(setting up fighting spot, teleport players etc.), otherwise false<br>
 	 */
 	 */
 	public static boolean isStarting()
 	public static boolean isStarting()
@@ -1058,8 +1108,8 @@ public class TvTEvent
 	}
 	}
 	
 	
 	/**
 	/**
-	 * Is TvTEvent started?<br><br>
-	 *
+	 * Is TvTEvent started?<br>
+	 * <br>
 	 * @return boolean: true if event is started, otherwise false<br>
 	 * @return boolean: true if event is started, otherwise false<br>
 	 */
 	 */
 	public static boolean isStarted()
 	public static boolean isStarted()
@@ -1075,8 +1125,8 @@ public class TvTEvent
 	}
 	}
 	
 	
 	/**
 	/**
-	 * Is TvTEvent rewarding?<br><br>
-	 *
+	 * Is TvTEvent rewarding?<br>
+	 * <br>
 	 * @return boolean: true if event is currently rewarding, otherwise false<br>
 	 * @return boolean: true if event is currently rewarding, otherwise false<br>
 	 */
 	 */
 	public static boolean isRewarding()
 	public static boolean isRewarding()
@@ -1147,8 +1197,8 @@ public class TvTEvent
 	}
 	}
 	
 	
 	/**
 	/**
-	 * Returns participated player count<br><br>
-	 *
+	 * Returns participated player count<br>
+	 * <br>
 	 * @return int: amount of players registered in the event<br>
 	 * @return int: amount of players registered in the event<br>
 	 */
 	 */
 	public static int getParticipatedPlayersCount()
 	public static int getParticipatedPlayersCount()
@@ -1162,8 +1212,8 @@ public class TvTEvent
 	}
 	}
 	
 	
 	/**
 	/**
-	 * Returns teams names<br><br>
-	 *
+	 * Returns teams names<br>
+	 * <br>
 	 * @return String[]: names of teams, 2 elements, index 0 for team 1 and index 1 for team 2<br>
 	 * @return String[]: names of teams, 2 elements, index 0 for team 1 and index 1 for team 2<br>
 	 */
 	 */
 	public static String[] getTeamNames()
 	public static String[] getTeamNames()
@@ -1176,8 +1226,8 @@ public class TvTEvent
 	}
 	}
 	
 	
 	/**
 	/**
-	 * Returns player count of both teams<br><br>
-	 *
+	 * Returns player count of both teams<br>
+	 * <br>
 	 * @return int[]: player count of teams, 2 elements, index 0 for team 1 and index 1 for team 2<br>
 	 * @return int[]: player count of teams, 2 elements, index 0 for team 1 and index 1 for team 2<br>
 	 */
 	 */
 	public static int[] getTeamsPlayerCounts()
 	public static int[] getTeamsPlayerCounts()
@@ -1191,14 +1241,13 @@ public class TvTEvent
 	
 	
 	/**
 	/**
 	 * Returns points count of both teams
 	 * Returns points count of both teams
-	 *
 	 * @return int[]: points of teams, 2 elements, index 0 for team 1 and index 1 for team 2<br>
 	 * @return int[]: points of teams, 2 elements, index 0 for team 1 and index 1 for team 2<br>
 	 */
 	 */
 	public static int[] getTeamsPoints()
 	public static int[] getTeamsPoints()
 	{
 	{
 		return new int[]
 		return new int[]
 		{
 		{
-			_teams[0].getPoints(), 
+			_teams[0].getPoints(),
 			_teams[1].getPoints()
 			_teams[1].getPoints()
 		};
 		};
 	}
 	}
@@ -1217,7 +1266,7 @@ public class TvTEvent
 	 */
 	 */
 	private static void fireTvtKillListeners(L2PcInstance killer, L2PcInstance victim, TvTEventTeam killerTeam)
 	private static void fireTvtKillListeners(L2PcInstance killer, L2PcInstance victim, TvTEventTeam killerTeam)
 	{
 	{
-		if (!tvtListeners.isEmpty() && killer != null && victim != null && killerTeam != null)
+		if (!tvtListeners.isEmpty() && (killer != null) && (victim != null) && (killerTeam != null))
 		{
 		{
 			TvtKillEvent event = new TvtKillEvent();
 			TvtKillEvent event = new TvtKillEvent();
 			event.setKiller(killer);
 			event.setKiller(killer);

+ 15 - 15
L2J_Server_BETA/java/com/l2jserver/gameserver/model/entity/TvTEventTeam.java

@@ -26,7 +26,7 @@ import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
 public class TvTEventTeam
 public class TvTEventTeam
 {
 {
 	/** The name of the team<br> */
 	/** The name of the team<br> */
-	private String _name;
+	private final String _name;
 	/** The team spot coordinated<br> */
 	/** The team spot coordinated<br> */
 	private int[] _coordinates = new int[3];
 	private int[] _coordinates = new int[3];
 	/** The points of the team<br> */
 	/** The points of the team<br> */
@@ -35,8 +35,8 @@ public class TvTEventTeam
 	private Map<Integer, L2PcInstance> _participatedPlayers = new FastMap<>();
 	private Map<Integer, L2PcInstance> _participatedPlayers = new FastMap<>();
 	
 	
 	/**
 	/**
-	 * C'tor initialize the team<br><br>
-	 *
+	 * C'tor initialize the team<br>
+	 * <br>
 	 * @param name as String<br>
 	 * @param name as String<br>
 	 * @param coordinates as int[]<br>
 	 * @param coordinates as int[]<br>
 	 */
 	 */
@@ -48,8 +48,8 @@ public class TvTEventTeam
 	}
 	}
 	
 	
 	/**
 	/**
-	 * Adds a player to the team<br><br>
-	 *
+	 * Adds a player to the team<br>
+	 * <br>
 	 * @param playerInstance as L2PcInstance<br>
 	 * @param playerInstance as L2PcInstance<br>
 	 * @return boolean: true if success, otherwise false<br>
 	 * @return boolean: true if success, otherwise false<br>
 	 */
 	 */
@@ -116,8 +116,8 @@ public class TvTEventTeam
 	}
 	}
 	
 	
 	/**
 	/**
-	 * Returns the name of the team<br><br>
-	 *
+	 * Returns the name of the team<br>
+	 * <br>
 	 * @return String: name of the team<br>
 	 * @return String: name of the team<br>
 	 */
 	 */
 	public String getName()
 	public String getName()
@@ -126,8 +126,8 @@ public class TvTEventTeam
 	}
 	}
 	
 	
 	/**
 	/**
-	 * Returns the coordinates of the team spot<br><br>
-	 *
+	 * Returns the coordinates of the team spot<br>
+	 * <br>
 	 * @return int[]: team coordinates<br>
 	 * @return int[]: team coordinates<br>
 	 */
 	 */
 	public int[] getCoordinates()
 	public int[] getCoordinates()
@@ -136,8 +136,8 @@ public class TvTEventTeam
 	}
 	}
 	
 	
 	/**
 	/**
-	 * Returns the points of the team<br><br>
-	 *
+	 * Returns the points of the team<br>
+	 * <br>
 	 * @return short: team points<br>
 	 * @return short: team points<br>
 	 */
 	 */
 	public short getPoints()
 	public short getPoints()
@@ -146,8 +146,8 @@ public class TvTEventTeam
 	}
 	}
 	
 	
 	/**
 	/**
-	 * Returns name and instance of all participated players in FastMap<br><br>
-	 *
+	 * Returns name and instance of all participated players in FastMap<br>
+	 * <br>
 	 * @return Map<String, L2PcInstance>: map of players in this team<br>
 	 * @return Map<String, L2PcInstance>: map of players in this team<br>
 	 */
 	 */
 	public Map<Integer, L2PcInstance> getParticipatedPlayers()
 	public Map<Integer, L2PcInstance> getParticipatedPlayers()
@@ -163,8 +163,8 @@ public class TvTEventTeam
 	}
 	}
 	
 	
 	/**
 	/**
-	 * Returns player count of this team<br><br>
-	 *
+	 * Returns player count of this team<br>
+	 * <br>
 	 * @return int: number of players in team<br>
 	 * @return int: number of players in team<br>
 	 */
 	 */
 	public int getParticipatedPlayerCount()
 	public int getParticipatedPlayerCount()

+ 16 - 5
L2J_Server_BETA/java/com/l2jserver/gameserver/model/entity/TvTEventTeleporter.java

@@ -53,27 +53,34 @@ public class TvTEventTeleporter implements Runnable
 	 * 2. Remove all effects<br>
 	 * 2. Remove all effects<br>
 	 * 3. Revive and full heal the player<br>
 	 * 3. Revive and full heal the player<br>
 	 * 4. Teleport the player<br>
 	 * 4. Teleport the player<br>
-	 * 5. Broadcast status and user info<br><br>
-	 *
+	 * 5. Broadcast status and user info<br>
+	 * <br>
 	 * @see java.lang.Runnable#run()
 	 * @see java.lang.Runnable#run()
 	 */
 	 */
 	@Override
 	@Override
 	public void run()
 	public void run()
 	{
 	{
 		if (_playerInstance == null)
 		if (_playerInstance == null)
+		{
 			return;
 			return;
+		}
 		
 		
 		L2Summon summon = _playerInstance.getPet();
 		L2Summon summon = _playerInstance.getPet();
 		
 		
 		if (summon != null)
 		if (summon != null)
+		{
 			summon.unSummon(_playerInstance);
 			summon.unSummon(_playerInstance);
+		}
 		
 		
-		if (Config.TVT_EVENT_EFFECTS_REMOVAL == 0
-				|| (Config.TVT_EVENT_EFFECTS_REMOVAL == 1 && (_playerInstance.getTeam() == 0 || (_playerInstance.isInDuel() && _playerInstance.getDuelState() != Duel.DUELSTATE_INTERRUPTED))))
+		if ((Config.TVT_EVENT_EFFECTS_REMOVAL == 0) || ((Config.TVT_EVENT_EFFECTS_REMOVAL == 1) && ((_playerInstance.getTeam() == 0) || (_playerInstance.isInDuel() && (_playerInstance.getDuelState() != Duel.DUELSTATE_INTERRUPTED)))))
+		{
 			_playerInstance.stopAllEffectsExceptThoseThatLastThroughDeath();
 			_playerInstance.stopAllEffectsExceptThoseThatLastThroughDeath();
+		}
 		
 		
 		if (_playerInstance.isInDuel())
 		if (_playerInstance.isInDuel())
+		{
 			_playerInstance.setDuelState(Duel.DUELSTATE_INTERRUPTED);
 			_playerInstance.setDuelState(Duel.DUELSTATE_INTERRUPTED);
+		}
 		
 		
 		int TvTInstance = TvTEvent.getTvTEventInstance();
 		int TvTInstance = TvTEvent.getTvTEventInstance();
 		if (TvTInstance != 0)
 		if (TvTInstance != 0)
@@ -94,12 +101,16 @@ public class TvTEventTeleporter implements Runnable
 		
 		
 		_playerInstance.doRevive();
 		_playerInstance.doRevive();
 		
 		
-		_playerInstance.teleToLocation( _coordinates[ 0 ] + Rnd.get(101)-50, _coordinates[ 1 ] + Rnd.get(101)-50, _coordinates[ 2 ], false );
+		_playerInstance.teleToLocation((_coordinates[0] + Rnd.get(101)) - 50, (_coordinates[1] + Rnd.get(101)) - 50, _coordinates[2], false);
 		
 		
 		if (TvTEvent.isStarted() && !_adminRemove)
 		if (TvTEvent.isStarted() && !_adminRemove)
+		{
 			_playerInstance.setTeam(TvTEvent.getParticipantTeamId(_playerInstance.getObjectId()) + 1);
 			_playerInstance.setTeam(TvTEvent.getParticipantTeamId(_playerInstance.getObjectId()) + 1);
+		}
 		else
 		else
+		{
 			_playerInstance.setTeam(0);
 			_playerInstance.setTeam(0);
+		}
 		
 		
 		_playerInstance.setCurrentCp(_playerInstance.getMaxCp());
 		_playerInstance.setCurrentCp(_playerInstance.getMaxCp());
 		_playerInstance.setCurrentHp(_playerInstance.getMaxHp());
 		_playerInstance.setCurrentHp(_playerInstance.getMaxHp());

+ 17 - 21
L2J_Server_BETA/java/com/l2jserver/gameserver/model/entity/TvTManager.java

@@ -22,7 +22,6 @@ import com.l2jserver.Config;
 import com.l2jserver.gameserver.Announcements;
 import com.l2jserver.gameserver.Announcements;
 import com.l2jserver.gameserver.ThreadPoolManager;
 import com.l2jserver.gameserver.ThreadPoolManager;
 
 
-
 /**
 /**
  * @author FBIagent
  * @author FBIagent
  */
  */
@@ -42,7 +41,7 @@ public class TvTManager
 		{
 		{
 			TvTEvent.init();
 			TvTEvent.init();
 			
 			
-			this.scheduleEventStart();
+			scheduleEventStart();
 			_log.info("TvTEventEngine[TvTManager.TvTManager()]: Started.");
 			_log.info("TvTEventEngine[TvTManager.TvTManager()]: Started.");
 		}
 		}
 		else
 		else
@@ -52,8 +51,8 @@ public class TvTManager
 	}
 	}
 	
 	
 	/**
 	/**
-	 * Initialize new/Returns the one and only instance<br><br>
-	 *
+	 * Initialize new/Returns the one and only instance<br>
+	 * <br>
 	 * @return TvTManager<br>
 	 * @return TvTManager<br>
 	 */
 	 */
 	public static TvTManager getInstance()
 	public static TvTManager getInstance()
@@ -85,7 +84,7 @@ public class TvTManager
 					testStartTime.add(Calendar.DAY_OF_MONTH, 1);
 					testStartTime.add(Calendar.DAY_OF_MONTH, 1);
 				}
 				}
 				// Check for the test date to be the minimum (smallest in the specified list)
 				// Check for the test date to be the minimum (smallest in the specified list)
-				if (nextStartTime == null || testStartTime.getTimeInMillis() < nextStartTime.getTimeInMillis())
+				if ((nextStartTime == null) || (testStartTime.getTimeInMillis() < nextStartTime.getTimeInMillis()))
 				{
 				{
 					nextStartTime = testStartTime;
 					nextStartTime = testStartTime;
 				}
 				}
@@ -112,15 +111,14 @@ public class TvTManager
 			Announcements.getInstance().announceToAll("TvT Event: Event was cancelled.");
 			Announcements.getInstance().announceToAll("TvT Event: Event was cancelled.");
 			_log.warning("TvTEventEngine[TvTManager.run()]: Error spawning event npc for participation.");
 			_log.warning("TvTEventEngine[TvTManager.run()]: Error spawning event npc for participation.");
 			
 			
-			this.scheduleEventStart();
+			scheduleEventStart();
 		}
 		}
 		else
 		else
 		{
 		{
-			Announcements.getInstance().announceToAll("TvT Event: Registration opened for " + Config.TVT_EVENT_PARTICIPATION_TIME
-					+ " minute(s).");
+			Announcements.getInstance().announceToAll("TvT Event: Registration opened for " + Config.TVT_EVENT_PARTICIPATION_TIME + " minute(s).");
 			
 			
 			// schedule registration end
 			// schedule registration end
-			_task.setStartTime(System.currentTimeMillis() + 60000L * Config.TVT_EVENT_PARTICIPATION_TIME);
+			_task.setStartTime(System.currentTimeMillis() + (60000L * Config.TVT_EVENT_PARTICIPATION_TIME));
 			ThreadPoolManager.getInstance().executeTask(_task);
 			ThreadPoolManager.getInstance().executeTask(_task);
 		}
 		}
 	}
 	}
@@ -135,13 +133,12 @@ public class TvTManager
 			Announcements.getInstance().announceToAll("TvT Event: Event cancelled due to lack of Participation.");
 			Announcements.getInstance().announceToAll("TvT Event: Event cancelled due to lack of Participation.");
 			_log.info("TvTEventEngine[TvTManager.run()]: Lack of registration, abort event.");
 			_log.info("TvTEventEngine[TvTManager.run()]: Lack of registration, abort event.");
 			
 			
-			this.scheduleEventStart();
+			scheduleEventStart();
 		}
 		}
 		else
 		else
 		{
 		{
-			TvTEvent.sysMsgToAllParticipants("TvT Event: Teleporting participants to an arena in "
-					+ Config.TVT_EVENT_START_LEAVE_TELEPORT_DELAY + " second(s).");
-			_task.setStartTime(System.currentTimeMillis() + 60000L * Config.TVT_EVENT_RUNNING_TIME);
+			TvTEvent.sysMsgToAllParticipants("TvT Event: Teleporting participants to an arena in " + Config.TVT_EVENT_START_LEAVE_TELEPORT_DELAY + " second(s).");
+			_task.setStartTime(System.currentTimeMillis() + (60000L * Config.TVT_EVENT_RUNNING_TIME));
 			ThreadPoolManager.getInstance().executeTask(_task);
 			ThreadPoolManager.getInstance().executeTask(_task);
 		}
 		}
 	}
 	}
@@ -152,11 +149,10 @@ public class TvTManager
 	public void endEvent()
 	public void endEvent()
 	{
 	{
 		Announcements.getInstance().announceToAll(TvTEvent.calculateRewards());
 		Announcements.getInstance().announceToAll(TvTEvent.calculateRewards());
-		TvTEvent.sysMsgToAllParticipants("TvT Event: Teleporting back to the registration npc in "
-				+ Config.TVT_EVENT_START_LEAVE_TELEPORT_DELAY + " second(s).");
+		TvTEvent.sysMsgToAllParticipants("TvT Event: Teleporting back to the registration npc in " + Config.TVT_EVENT_START_LEAVE_TELEPORT_DELAY + " second(s).");
 		TvTEvent.stopFight();
 		TvTEvent.stopFight();
 		
 		
-		this.scheduleEventStart();
+		scheduleEventStart();
 	}
 	}
 	
 	
 	public void skipDelay()
 	public void skipDelay()
@@ -196,7 +192,7 @@ public class TvTManager
 			
 			
 			if (delay > 0)
 			if (delay > 0)
 			{
 			{
-				this.announce(delay);
+				announce(delay);
 			}
 			}
 			
 			
 			int nextMsg = 0;
 			int nextMsg = 0;
@@ -237,15 +233,15 @@ public class TvTManager
 				// start
 				// start
 				if (TvTEvent.isInactive())
 				if (TvTEvent.isInactive())
 				{
 				{
-					TvTManager.this.startReg();
+					startReg();
 				}
 				}
 				else if (TvTEvent.isParticipating())
 				else if (TvTEvent.isParticipating())
 				{
 				{
-					TvTManager.this.startEvent();
+					startEvent();
 				}
 				}
 				else
 				else
 				{
 				{
-					TvTManager.this.endEvent();
+					endEvent();
 				}
 				}
 			}
 			}
 			
 			
@@ -257,7 +253,7 @@ public class TvTManager
 		
 		
 		private void announce(long time)
 		private void announce(long time)
 		{
 		{
-			if (time >= 3600 && time % 3600 == 0)
+			if ((time >= 3600) && ((time % 3600) == 0))
 			{
 			{
 				if (TvTEvent.isParticipating())
 				if (TvTEvent.isParticipating())
 				{
 				{