Rumen Nikiforov преди 12 години
родител
ревизия
2b8619d811
променени са 21 файла, в които са добавени 1662 реда и са изтрити 676 реда
  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);
 		if (qs == null && event.length() == 0)
 			return retval;
-		if (qs == null) {
+		if (qs == null)
+		{
 			Quest q = QuestManager.getInstance().getQuest(quest);
 			if (q == null)
 				return retval;
 			qs = q.newQuestState(this);
 		}
-		if (qs != null) {
+		if (qs != null)
+		{
 			if (getLastQuestNpcObject() > 0)
 			{
 				L2Object object = L2World.getInstance().findObject(getLastQuestNpcObject());
 				if (object instanceof L2Npc && isInsideRadius(object, L2Npc.INTERACTION_DISTANCE, false, false))
 				{
-					L2Npc npc = (L2Npc)object;
+					L2Npc npc = (L2Npc) object;
 					QuestState[] states = getQuestsForTalk(npc.getNpcId());
 					
 					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;
 
 /**
- *
- * @author  mrTJO
+ * @author mrTJO
  */
 public class ActionKey
 {
@@ -78,7 +77,6 @@ public class ActionKey
 	
 	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.network.SystemMessageId;
 
-
 public class Auction
 {
 	protected static final Logger _log = Logger.getLogger(Auction.class.getName());
@@ -50,7 +49,7 @@ public class Auction
 	private int _itemId = 0;
 	private String _itemName = "";
 	private int _itemObjectId = 0;
-	private long _itemQuantity = 0;
+	private final long _itemQuantity = 0;
 	private String _itemType = "";
 	private int _sellerId = 0;
 	private String _sellerClanName = "";
@@ -58,7 +57,7 @@ public class Auction
 	private long _currentBid = 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 =
 	{
@@ -72,10 +71,10 @@ public class Auction
 	
 	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 Calendar _timeBid;
+		private final Calendar _timeBid;
 		
 		public Bidder(String name, String clanName, long bid, long timeBid)
 		{
@@ -139,7 +138,7 @@ public class Auction
 	}
 	
 	/**
-	 * Constructor 
+	 * Constructor
 	 * @param auctionId
 	 */
 	public Auction(int auctionId)
@@ -231,11 +230,13 @@ public class Auction
 		long taskDelay = 0;
 		if (_endDate <= currentTime)
 		{
-			_endDate = currentTime + 7 * 24 * 60 * 60 * 1000;
+			_endDate = currentTime + (7 * 24 * 60 * 60 * 1000);
 			saveAuctionDate();
 		}
 		else
+		{
 			taskDelay = _endDate - currentTime;
+		}
 		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
 	 */
 	public synchronized void setBid(L2PcInstance bidder, long bid)
 	{
 		long requiredAdena = bid;
 		if (getHighestBidderName().equals(bidder.getClan().getLeaderName()))
+		{
 			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))
 			{
@@ -280,19 +283,23 @@ public class Auction
 			}
 		}
 		if ((bid < getStartingBid()) || (bid <= getHighestBidderMaxBid()))
+		{
 			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
 	 */
 	private void returnItem(String Clan, long quantity, boolean 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
 		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
 	 */
 	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);
 			return true;
@@ -319,8 +326,8 @@ public class Auction
 	}
 	
 	/**
-	 * Update auction in DB 
-	 * @param bidder 
+	 * Update auction in DB
+	 * @param bidder
 	 * @param bid
 	 */
 	private void updateInDB(L2PcInstance bidder, long bid)
@@ -354,14 +361,18 @@ public class Auction
 					statement.execute();
 				}
 				if (L2World.getInstance().getPlayer(_highestBidderName) != null)
+				{
 					L2World.getInstance().getPlayer(_highestBidderName).sendMessage("You have been out bidded");
+				}
 			}
 			
 			_highestBidderId = bidder.getClanId();
 			_highestBidderMaxBid = bid;
 			_highestBidderName = bidder.getClan().getLeaderName();
 			if (_bidders.get(_highestBidderId) == null)
+			{
 				_bidders.put(_highestBidderId, new Bidder(_highestBidderName, bidder.getClan().getName(), bid, Calendar.getInstance().getTimeInMillis()));
+			}
 			else
 			{
 				_bidders.get(_highestBidderId).setBid(bid);
@@ -392,11 +403,15 @@ public class Auction
 		for (Bidder b : _bidders.values())
 		{
 			if (ClanTable.getInstance().getClanByName(b.getClanName()).getHideoutId() == 0)
+			{
 				returnItem(b.getClanName(), b.getBid(), true); // 10 % tax
+			}
 			else
 			{
 				if (L2World.getInstance().getPlayer(b.getName()) != null)
+				{
 					L2World.getInstance().getPlayer(b.getName()).sendMessage("Congratulation you have won ClanHall!");
+				}
 			}
 			ClanTable.getInstance().getClanByName(b.getClanName()).setAuctionBiddedAt(0, true);
 		}
@@ -424,15 +439,16 @@ public class Auction
 	{
 		if (ClanHallManager.getInstance().loaded())
 		{
-			if (_highestBidderId == 0 && _sellerId == 0)
+			if ((_highestBidderId == 0) && (_sellerId == 0))
 			{
 				startAutoTask();
 				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);
 				AuctionManager.getInstance().getAuctions().remove(aucId);
 				return;
@@ -457,7 +473,7 @@ public class Auction
 	}
 	
 	/**
-	 * Cancel bid 
+	 * Cancel bid
 	 * @param bidder
 	 */
 	public synchronized void cancelBid(int bidder)
@@ -516,7 +532,7 @@ public class Auction
 	}
 	
 	/**
-	 * Get var auction 
+	 * Get var auction
 	 * @return
 	 */
 	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 =
 	{
 		// 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
-		{ -58350, -63853, -57756, -63266, -58053, -63551 },
+		{
+			-58350,
+			-63853,
+			-57756,
+			-63266,
+			-58053,
+			-63551
+		},
 		// 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
-		{ -57200, -62727, -56584, -62115, -56850, -62391 }	
+		{
+			-57200,
+			-62727,
+			-56584,
+			-62115,
+			-56850,
+			-62391
+		}
 	};
 	// Common z coordinate
 	private static final int _zCoord = -2405;
@@ -100,18 +128,23 @@ public final class BlockCheckerEngine
 	public BlockCheckerEngine(HandysBlockCheckerManager.ArenaParticipantsHolder holder, int arena)
 	{
 		_holder = holder;
-		if(arena > -1 && arena < 4)
+		if ((arena > -1) && (arena < 4))
+		{
 			_arena = arena;
+		}
 		
-		for(L2PcInstance player : holder.getRedPlayers())
+		for (L2PcInstance player : holder.getRedPlayers())
+		{
 			_redTeamPoints.put(player, 0);
-		for(L2PcInstance player : holder.getBluePlayers())
+		}
+		for (L2PcInstance player : holder.getBluePlayers())
+		{
 			_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
 	 */
 	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
 	 */
 	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;
 	 */
 	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
 	 */
 	public long getStarterTime()
@@ -155,7 +185,7 @@ public final class BlockCheckerEngine
 	 */
 	public int getRedPoints()
 	{
-		synchronized(this)
+		synchronized (this)
 		{
 			return _redPoints;
 		}
@@ -167,7 +197,7 @@ public final class BlockCheckerEngine
 	 */
 	public int getBluePoints()
 	{
-		synchronized(this)
+		synchronized (this)
 		{
 			return _bluePoints;
 		}
@@ -181,10 +211,12 @@ public final class BlockCheckerEngine
 	 */
 	public int getPlayerPoints(L2PcInstance player, boolean isRed)
 	{
-		if(!_redTeamPoints.containsKey(player) && !_blueTeamPoints.containsKey(player))
+		if (!_redTeamPoints.containsKey(player) && !_blueTeamPoints.containsKey(player))
+		{
 			return 0;
+		}
 		
-		if(isRed)
+		if (isRed)
 		{
 			return _redTeamPoints.get(player);
 		}
@@ -198,10 +230,12 @@ public final class BlockCheckerEngine
 	 */
 	public synchronized void increasePlayerPoints(L2PcInstance player, int team)
 	{
-		if(player == null)
+		if (player == null)
+		{
 			return;
+		}
 		
-		if(team == 0)
+		if (team == 0)
 		{
 			int points = _redTeamPoints.get(player) + 1;
 			_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
 	 */
 	public void addNewDrop(L2ItemInstance item)
 	{
-		if(item != null)
+		if (item != null)
+		{
 			_drops.add(item);
+		}
 	}
 	
 	/**
-	 * Will return true if the event is already
-	 * started
+	 * Will return true if the event is already started
 	 * @return boolean
 	 */
 	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)
 	{
-		for(L2PcInstance p : _holder.getAllPlayers())
+		for (L2PcInstance p : _holder.getAllPlayers())
 		{
 			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()
 	{
 		try
 		{
-			synchronized(this)
+			synchronized (this)
 			{
 				_isStarted = false;
 				
-				if(_task != null)
+				if (_task != null)
+				{
 					_task.cancel(true);
+				}
 				
 				_abnormalEnd = true;
 				
 				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
-	{		
+	{
 		// In event used skills
-		private L2Skill _freeze, _transformationRed, _transformationBlue;
+		private final L2Skill _freeze, _transformationRed, _transformationBlue;
 		// Common and unparametizer packet
 		private final ExCubeGameCloseUI _closeUserInterface = new ExCubeGameCloseUI();
 		
@@ -298,11 +333,9 @@ public final class BlockCheckerEngine
 			_transformationRed = SkillTable.getInstance().getInfo(6035, 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()
 		{
@@ -312,13 +345,16 @@ public final class BlockCheckerEngine
 			// Initialize packets avoiding create a new one per player
 			_redPoints = _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;
 			
-			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
 				boolean isRed = _holder.getRedPlayers().contains(player);
 				
@@ -336,29 +372,35 @@ public final class BlockCheckerEngine
 				int y = _arenaCoordinates[_arena][tc + 1];
 				player.teleToLocation(x, y, _zCoord);
 				// Set the player team
-				if(isRed)
+				if (isRed)
 				{
-					_redTeamPoints.put(player,0);
+					_redTeamPoints.put(player, 0);
 					player.setTeam(2);
 				}
 				else
 				{
-					_blueTeamPoints.put(player,0);
+					_blueTeamPoints.put(player, 0);
 					player.setTeam(1);
 				}
 				player.stopAllEffects();
 				
-				if(player.getPet() != null)
+				if (player.getPet() != null)
+				{
 					player.getPet().unSummon(player);
+				}
 				
 				// Give the player start up effects
 				// Freeze
 				_freeze.getEffects(player, player);
 				// Transformation
-				if(_holder.getPlayerTeam(player) == 0)
+				if (_holder.getPlayerTeam(player) == 0)
+				{
 					_transformationRed.getEffects(player, player);
+				}
 				else
+				{
 					_transformationBlue.getEffects(player, player);
+				}
 				// Set the current player arena
 				player.setBlockCheckerArena((byte) _arena);
 				player.setInsideZone(L2Character.ZONE_PVP, true);
@@ -367,16 +409,16 @@ public final class BlockCheckerEngine
 				player.sendPacket(_closeUserInterface);
 				// ExBasicActionList
 				final ExBasicActionList actionList = ExBasicActionList.getStaticPacket(player);
-				player.sendPacket(actionList);	
+				player.sendPacket(actionList);
 				broadcastRelationChanged(player);
 			}
 		}
-				
+		
 		@Override
 		public void run()
 		{
 			// 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...");
 				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
 	{
@@ -409,9 +450,12 @@ public final class BlockCheckerEngine
 		@Override
 		public void run()
 		{
-			if(!_isStarted) return;
+			if (!_isStarted)
+			{
+				return;
+			}
 			
-			switch(_round)
+			switch (_round)
 			{
 				case 1:
 					// Schedule second spawn round
@@ -435,41 +479,47 @@ public final class BlockCheckerEngine
 			try
 			{
 				// Creates 50 new blocks
-				for(int i = 0; i < _numOfBoxes; i++)
+				for (int i = 0; i < _numOfBoxes; i++)
 				{
 					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.setAmount(1);
 					spawn.setHeading(1);
 					spawn.setRespawnDelay(1);
 					SpawnTable.getInstance().addNewSpawn(spawn, false);
 					spawn.init();
-					L2BlockInstance block = (L2BlockInstance)spawn.getLastSpawn();
+					L2BlockInstance block = (L2BlockInstance) spawn.getLastSpawn();
 					// 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);
 					_spawns.add(spawn);
 					random++;
 				}
 			}
-			catch(Exception e)
+			catch (Exception e)
 			{
 				_log.warning(getClass().getSimpleName() + ": " + e.getMessage());
 			}
 			
 			// Spawn the block carrying girl
-			if(_round == 1 || _round == 2)
+			if ((_round == 1) || (_round == 2))
 			{
 				L2NpcTemplate girl = NpcTable.getInstance().getTemplate(18676);
 				try
 				{
 					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.setAmount(1);
 					girlSpawn.setHeading(1);
@@ -479,7 +529,7 @@ public final class BlockCheckerEngine
 					// Schedule his deletion after 9 secs of spawn
 					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(getClass().getSimpleName() + ": " + e.getMessage());
@@ -489,7 +539,7 @@ public final class BlockCheckerEngine
 			_redPoints += _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());
 			getHolder().broadCastPacketToTeam(changePoints);
 		}
@@ -497,7 +547,7 @@ public final class BlockCheckerEngine
 	
 	private class CarryingGirlUnspawn implements Runnable
 	{
-		private L2Spawn _spawn;
+		private final L2Spawn _spawn;
 		
 		protected CarryingGirlUnspawn(L2Spawn spawn)
 		{
@@ -507,7 +557,7 @@ public final class BlockCheckerEngine
 		@Override
 		public void run()
 		{
-			if(_spawn == null)
+			if (_spawn == null)
 			{
 				_log.warning("HBCE: Block Carrying Girl is null");
 				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
-	{		
+	{
 		// Garbage collector and arena free setter
 		private void clearMe()
 		{
@@ -547,7 +587,7 @@ public final class BlockCheckerEngine
 			_redTeamPoints.clear();
 			HandysBlockCheckerManager.getInstance().setArenaFree(_arena);
 			
-			for(L2Spawn spawn : _spawns)
+			for (L2Spawn spawn : _spawns)
 			{
 				spawn.stopRespawn();
 				spawn.getLastSpawn().deleteMe();
@@ -556,34 +596,39 @@ public final class BlockCheckerEngine
 			}
 			_spawns.clear();
 			
-			for(L2ItemInstance item : _drops)
+			for (L2ItemInstance item : _drops)
 			{
 				// npe
-				if(item == null)
+				if (item == null)
+				{
 					continue;
+				}
 				
 				// a player has it, it will be deleted later
-				if(!item.isVisible() || item.getOwnerId() != 0)
+				if (!item.isVisible() || (item.getOwnerId() != 0))
+				{
 					continue;
+				}
 				
 				item.decayMe();
 				L2World.getInstance().removeObject(item);
 			}
 			_drops.clear();
 		}
-
+		
 		/**
-		 * Reward players after event.
-		 * Tie - No Reward
+		 * Reward players after event. Tie - No Reward
 		 */
 		private void rewardPlayers()
 		{
-			if(_redPoints == _bluePoints)
+			if (_redPoints == _bluePoints)
+			{
 				return;
+			}
 			
 			_isRedWinner = _redPoints > _bluePoints ? true : false;
 			
-			if(_isRedWinner)
+			if (_isRedWinner)
 			{
 				rewardAsWinner(true);
 				rewardAsLooser(false);
@@ -591,7 +636,7 @@ public final class BlockCheckerEngine
 				msg.addString("Red Team");
 				_holder.broadCastPacketToTeam(msg);
 			}
-			else if(_bluePoints > _redPoints)
+			else if (_bluePoints > _redPoints)
 			{
 				rewardAsWinner(false);
 				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
 		 */
 		private void rewardAsWinner(boolean isRed)
 		{
-			FastMap<L2PcInstance, Integer> tempPoints = isRed? _redTeamPoints : _blueTeamPoints;
+			FastMap<L2PcInstance, Integer> tempPoints = isRed ? _redTeamPoints : _blueTeamPoints;
 			
 			// 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;
+				}
 				
-				if(points.getValue() >= 10)
+				if (points.getValue() >= 10)
+				{
 					points.getKey().addItem("Block Checker", 13067, 2, points.getKey(), true);
+				}
 				else
+				{
 					tempPoints.remove(points.getKey());
+				}
 			}
 			
 			int first = 0, second = 0;
 			L2PcInstance winner1 = null, winner2 = null;
-			for(Entry<L2PcInstance, Integer> entry : tempPoints.entrySet())
+			for (Entry<L2PcInstance, Integer> entry : tempPoints.entrySet())
 			{
 				L2PcInstance pc = entry.getKey();
 				int pcPoints = entry.getValue();
-				if(pcPoints > first)
+				if (pcPoints > first)
 				{
 					// Move old data
 					second = first;
@@ -643,48 +692,53 @@ public final class BlockCheckerEngine
 					first = pcPoints;
 					winner1 = pc;
 				}
-				else if(pcPoints > second)
+				else if (pcPoints > second)
 				{
 					second = pcPoints;
 					winner2 = pc;
 				}
 			}
-			if(winner1 != null)
+			if (winner1 != null)
+			{
 				winner1.addItem("Block Checker", 13067, 8, winner1, true);
-			if(winner2 != null)
+			}
+			if (winner2 != null)
+			{
 				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
 		 */
 		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();
-				if(player != null && entry.getValue() >= 10)
+				if ((player != null) && (entry.getValue() >= 10))
+				{
 					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()
 		{
 			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();
 				// Remove team aura
@@ -693,12 +747,12 @@ public final class BlockCheckerEngine
 				player.setBlockCheckerArena(DEFAULT_ARENA);
 				// Remove the event items
 				PcInventory inv = player.getInventory();
-				if(inv.getItemByItemId(13787) != null)
+				if (inv.getItemByItemId(13787) != null)
 				{
 					long count = inv.getInventoryItemCount(13787, 0);
 					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);
 					inv.destroyItemByItemId("Handys Block Checker", 13788, count, player, player);
@@ -712,12 +766,14 @@ public final class BlockCheckerEngine
 				player.broadcastUserInfo();
 			}
 		}
-				
+		
 		@Override
 		public void run()
 		{
-			if(!_abnormalEnd)
+			if (!_abnormalEnd)
+			{
 				rewardPlayers();
+			}
 			setPlayersBack();
 			clearMe();
 			_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 int _castleId = 0;
-	private List<L2DoorInstance> _doors = new ArrayList<>();
+	private final List<L2DoorInstance> _doors = new ArrayList<>();
 	private String _name = "";
 	private int _ownerId = 0;
 	private Siege _siege = null;
@@ -93,10 +93,10 @@ public class Castle
 	private L2CastleZone _castleZone = null;
 	private L2ResidenceTeleportZone _teleZone;
 	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;
 	
 	/** Castle Functions */
@@ -108,11 +108,11 @@ public class Castle
 	
 	public class CastleFunction
 	{
-		private int _type;
+		private final int _type;
 		private int _lvl;
 		protected int _fee;
 		protected int _tempFee;
-		private long _rate;
+		private final long _rate;
 		private long _endDate;
 		protected boolean _inDebt;
 		public boolean _cwh;
@@ -171,12 +171,18 @@ public class Castle
 		private void initializeTask(boolean cwh)
 		{
 			if (getOwnerId() <= 0)
+			{
 				return;
+			}
 			long currentTime = System.currentTimeMillis();
 			if (_endDate > currentTime)
+			{
 				ThreadPoolManager.getInstance().scheduleGeneral(new FunctionTask(cwh), _endDate - currentTime);
+			}
 			else
+			{
 				ThreadPoolManager.getInstance().scheduleGeneral(new FunctionTask(cwh), 0);
+			}
 		}
 		
 		private class FunctionTask implements Runnable
@@ -192,12 +198,16 @@ public class Castle
 				try
 				{
 					if (getOwnerId() <= 0)
+					{
 						return;
-					if (ClanTable.getInstance().getClan(getOwnerId()).getWarehouse().getAdena() >= _fee || !_cwh)
+					}
+					if ((ClanTable.getInstance().getClan(getOwnerId()).getWarehouse().getAdena() >= _fee) || !_cwh)
 					{
 						int fee = _fee;
 						if (getEndTime() == -1)
+						{
 							fee = _tempFee;
+						}
 						
 						setEndTime(System.currentTimeMillis() + getRate());
 						dbSave();
@@ -205,12 +215,16 @@ public class Castle
 						{
 							ClanTable.getInstance().getClan(getOwnerId()).getWarehouse().destroyItemByItemId("CS_function_fee", PcInventory.ADENA_ID, fee, null, null);
 							if (Config.DEBUG)
+							{
 								_log.warning("deducted " + fee + " adena from " + getName() + " owner's cwh for function id : " + getType());
+							}
 						}
 						ThreadPoolManager.getInstance().scheduleGeneral(new FunctionTask(true), getRate());
 					}
 					else
+					{
 						removeFunction(getType());
+					}
 				}
 				catch (Exception e)
 				{
@@ -274,21 +288,27 @@ public class Castle
 	public CastleFunction getFunction(int type)
 	{
 		if (_function.containsKey(type))
+		{
 			return _function.get(type);
+		}
 		return null;
 	}
 	
 	public synchronized void engrave(L2Clan clan, L2Object target)
 	{
 		if (!_artefacts.contains(target))
+		{
 			return;
+		}
 		_engrave.put(target.getObjectId(), clan.getClanId());
 		if (_engrave.size() == _artefacts.size())
 		{
 			for (L2ArtefactInstance art : _artefacts)
 			{
 				if (_engrave.get(art.getObjectId()) != clan.getClanId())
+				{
 					return;
+				}
 			}
 			_engrave.clear();
 			setOwner(clan);
@@ -315,7 +335,9 @@ public class Castle
 			{
 				long runeTax = (long) (amount * rune.getTaxRate());
 				if (rune.getOwnerId() > 0)
+				{
 					rune.addToTreasury(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
 				if (aden.getOwnerId() > 0)
+				{
 					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
 			}
 		}
@@ -343,21 +367,29 @@ public class Castle
 	public boolean addToTreasuryNoTax(long amount)
 	{
 		if (getOwnerId() <= 0)
+		{
 			return false;
+		}
 		
 		if (amount < 0)
 		{
 			amount *= -1;
 			if (_treasury < amount)
+			{
 				return false;
+			}
 			_treasury -= amount;
 		}
 		else
 		{
-			if (_treasury + amount > PcInventory.MAX_ADENA) // TODO is this valid after gracia final?
+			if ((_treasury + amount) > PcInventory.MAX_ADENA)
+			{
 				_treasury = PcInventory.MAX_ADENA;
+			}
 			else
+			{
 				_treasury += amount;
+			}
 		}
 		
 		try (Connection con = L2DatabaseFactory.getInstance().getConnection();
@@ -470,15 +502,21 @@ public class Castle
 	public void openCloseDoor(L2PcInstance activeChar, int doorId, boolean open)
 	{
 		if (activeChar.getClanId() != getOwnerId())
+		{
 			return;
+		}
 		
 		L2DoorInstance door = getDoor(doorId);
 		if (door != null)
 		{
 			if (open)
+			{
 				door.openMe();
+			}
 			else
+			{
 				door.closeMe();
+			}
 		}
 	}
 	
@@ -497,7 +535,7 @@ public class Castle
 	public void setOwner(L2Clan clan)
 	{
 		// 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
 			if (oldOwner != null)
@@ -516,7 +554,9 @@ public class Castle
 					if (oldleader != null)
 					{
 						if (oldleader.getMountType() == 2)
+						{
 							oldleader.dismount();
+						}
 					}
 				}
 				catch (Exception e)
@@ -536,12 +576,16 @@ public class Castle
 		setShowNpcCrest(false);
 		
 		// if clan have fortress, remove it
-		if ((clan != null) && clan.getFortId() > 0)
+		if ((clan != null) && (clan.getFortId() > 0))
+		{
 			FortManager.getInstance().getFortByOwner(clan).removeOwner(true);
+		}
 		
-		if (getSiege().getIsInProgress()) // If siege in progress
+		if (getSiege().getIsInProgress())
+		{
 			getSiege().midVictory(); // Mid victory phase of siege
-			
+		}
+		
 		TerritoryWarManager.getInstance().getTerritory(_castleId).setOwnerClan(clan);
 		
 		if (clan != null)
@@ -574,7 +618,9 @@ public class Castle
 		
 		updateOwnerInDB(null);
 		if (getSiege().getIsInProgress())
+		{
 			getSiege().midVictory();
+		}
 		
 		for (Integer fc : _function.keySet())
 		{
@@ -599,7 +645,7 @@ public class Castle
 				maxTax = 15;
 		}
 		
-		if (taxPercent < 0 || taxPercent > maxTax)
+		if ((taxPercent < 0) || (taxPercent > maxTax))
 		{
 			activeChar.sendMessage("Tax value must be between 0 and " + maxTax + ".");
 			return;
@@ -648,13 +694,19 @@ public class Castle
 			{
 				door.doRevive();
 				if (isDoorWeak)
+				{
 					door.setCurrentHp(door.getMaxHp() / 2);
+				}
 				else
+				{
 					door.setCurrentHp(door.getMaxHp());
+				}
 			}
 			
 			if (door.getOpen())
+			{
 				door.closeMe();
+			}
 		}
 		loadDoorUpgrade(); // Check for any upgrade the doors may have
 	}
@@ -664,7 +716,9 @@ public class Castle
 	{
 		L2DoorInstance door = getDoor(doorId);
 		if (door == null)
+		{
 			return;
+		}
 		
 		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)
 	{
 		if (player == null)
+		{
 			return false;
+		}
 		if (Config.DEBUG)
+		{
 			_log.warning("Called Castle.updateFunctions(int type, int lvl, int lease, long rate, boolean addNew) Owner : " + getOwnerId());
+		}
 		if (lease > 0)
+		{
 			if (!player.destroyItemByItemId("Consume", PcInventory.ADENA_ID, lease, null, true))
+			{
 				return false;
+			}
+		}
 		if (addNew)
 		{
 			_function.put(type, new CastleFunction(type, lvl, lease, 0, rate, 0, false));
 		}
 		else
 		{
-			if (lvl == 0 && lease == 0)
+			if ((lvl == 0) && (lease == 0))
+			{
 				removeFunction(type);
+			}
 			else
 			{
 				int diffLease = lease - _function.get(type).getLease();
 				if (Config.DEBUG)
+				{
 					_log.warning("Called Castle.updateFunctions diffLease : " + diffLease);
+				}
 				if (diffLease > 0)
 				{
 					_function.remove(type);
@@ -801,7 +867,7 @@ public class Castle
 		}
 		return true;
 	}
-
+	
 	public void activateInstance()
 	{
 		loadDoor();
@@ -812,12 +878,16 @@ public class Castle
 	{
 		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);
+			}
 		}
 		
 		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
@@ -827,9 +897,11 @@ public class Castle
 		{
 			StringBuilder doorIds = new StringBuilder(100);
 			for (L2DoorInstance door : getDoors())
+			{
 				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();
 			
 			while (rs.next())
@@ -851,9 +923,11 @@ public class Castle
 		{
 			StringBuilder doorIds = new StringBuilder(100);
 			for (L2DoorInstance door : getDoors())
+			{
 				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.close();
 		}
@@ -884,7 +958,9 @@ public class Castle
 	private void updateOwnerInDB(L2Clan clan)
 	{
 		if (clan != null)
+		{
 			_ownerId = clan.getClanId(); // Update owner id property
+		}
 		else
 		{
 			_ownerId = 0; // Remove owner
@@ -929,12 +1005,16 @@ public class Castle
 	public final L2DoorInstance getDoor(int doorId)
 	{
 		if (doorId <= 0)
+		{
 			return null;
+		}
 		
 		for (L2DoorInstance door : getDoors())
 		{
 			if (door.getDoorId() == doorId)
+			{
 				return door;
+			}
 		}
 		return null;
 	}
@@ -957,10 +1037,12 @@ public class Castle
 	public final Siege getSiege()
 	{
 		if (_siege == null)
+		{
 			_siege = new Siege(new Castle[]
 			{
 				this
 			});
+		}
 		return _siege;
 	}
 	
@@ -982,7 +1064,9 @@ public class Castle
 	public Calendar getTimeRegistrationOverDate()
 	{
 		if (_siegeTimeRegistrationEndDate == null)
+		{
 			_siegeTimeRegistrationEndDate = Calendar.getInstance();
+		}
 		return _siegeTimeRegistrationEndDate;
 	}
 	
@@ -1028,17 +1112,25 @@ public class Castle
 	public void setSeedProduction(List<SeedProduction> seed, int period)
 	{
 		if (period == CastleManorManager.PERIOD_CURRENT)
+		{
 			_production = seed;
+		}
 		else
+		{
 			_productionNext = seed;
+		}
 	}
 	
 	public void setCropProcure(List<CropProcure> crop, int period)
 	{
 		if (period == CastleManorManager.PERIOD_CURRENT)
+		{
 			_procure = crop;
+		}
 		else
+		{
 			_procureNext = crop;
+		}
 	}
 	
 	public SeedProduction getSeed(int seedId, int period)
@@ -1285,7 +1377,7 @@ public class Castle
 			List<CropProcure> proc = null;
 			proc = getCropProcure(period);
 			
-			if (proc != null && proc.size() > 0)
+			if ((proc != null) && (proc.size() > 0))
 			{
 				int count = 0;
 				StringBuilder query = new StringBuilder();
@@ -1372,10 +1464,14 @@ public class Castle
 				_formerOwner.takeReputationScore(Config.LOOSE_CASTLE_POINTS, true);
 				L2Clan owner = ClanTable.getInstance().getClan(getOwnerId());
 				if (owner != null)
+				{
 					owner.addReputationScore(Math.min(Config.TAKE_CASTLE_POINTS, maxreward), true);
+				}
 			}
 			else
+			{
 				_formerOwner.addReputationScore(Config.CASTLE_DEFENDED_POINTS, true);
+			}
 		}
 		else
 		{
@@ -1415,7 +1511,7 @@ public class Castle
 			player.addSkill(sk, false);
 		}
 		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())
 			{
@@ -1470,7 +1566,9 @@ public class Castle
 	public void registerArtefact(L2ArtefactInstance artefact)
 	{
 		if (Config.DEBUG)
+		{
 			_log.info("ArtefactId: " + artefact.getObjectId() + " is registered to " + getName() + " castle.");
+		}
 		_artefacts.add(artefact);
 	}
 	
@@ -1518,6 +1616,6 @@ public class Castle
 	@Override
 	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());
 	
-	private int _clanHallId;
+	private final int _clanHallId;
 	private ArrayList<L2DoorInstance> _doors;
-	private String _name;
+	private final String _name;
 	private int _ownerId;
-	private String _desc;
-	private String _location;
+	private final String _desc;
+	private final String _location;
 	private L2ClanHallZone _zone;
 	protected final int _chRate = 604800000;
 	protected boolean _isFree = true;
-	private Map<Integer, ClanHallFunction> _functions;
+	private final Map<Integer, ClanHallFunction> _functions;
 	
 	/** Clan Hall Functions */
 	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_EXP = 5;
 	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
 	{
-		private int _type;
+		private final int _type;
 		private int _lvl;
 		protected int _fee;
 		protected int _tempFee;
-		private long _rate;
+		private final long _rate;
 		private long _endDate;
 		protected boolean _inDebt;
 		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)
 		{
 			if (_isFree)
+			{
 				return;
+			}
 			long currentTime = System.currentTimeMillis();
 			if (_endDate > currentTime)
+			{
 				ThreadPoolManager.getInstance().scheduleGeneral(new FunctionTask(cwh), _endDate - currentTime);
+			}
 			else
+			{
 				ThreadPoolManager.getInstance().scheduleGeneral(new FunctionTask(cwh), 0);
+			}
 		}
 		
 		private class FunctionTask implements Runnable
@@ -147,12 +153,16 @@ public abstract class ClanHall
 				try
 				{
 					if (_isFree)
+					{
 						return;
-					if (ClanTable.getInstance().getClan(getOwnerId()).getWarehouse().getAdena() >= _fee || !_cwh)
+					}
+					if ((ClanTable.getInstance().getClan(getOwnerId()).getWarehouse().getAdena() >= _fee) || !_cwh)
 					{
 						int fee = _fee;
 						if (getEndTime() == -1)
+						{
 							fee = _tempFee;
+						}
 						
 						setEndTime(System.currentTimeMillis() + getRate());
 						dbSave();
@@ -160,12 +170,16 @@ public abstract class ClanHall
 						{
 							ClanTable.getInstance().getClan(getOwnerId()).getWarehouse().destroyItemByItemId("CH_function_fee", PcInventory.ADENA_ID, fee, null, null);
 							if (Config.DEBUG)
+							{
 								_log.warning("deducted " + fee + " adena from " + getName() + " owner's cwh for function id : " + getType());
+							}
 						}
 						ThreadPoolManager.getInstance().scheduleGeneral(new FunctionTask(true), getRate());
 					}
 					else
+					{
 						removeFunction(getType());
+					}
 				}
 				catch (Exception e)
 				{
@@ -190,8 +204,7 @@ public abstract class ClanHall
 			}
 			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");
 		_ownerId = set.getInteger("ownerId");
 		if (Config.DEBUG)
+		{
 			_log.warning("Init Owner : " + _ownerId);
+		}
 		_desc = set.getString("desc");
 		_location = set.getString("location");
 		_functions = new FastMap<>();
 		
-		if(_ownerId > 0)
+		if (_ownerId > 0)
 		{
 			L2Clan clan = ClanTable.getInstance().getClan(_ownerId);
-			if(clan != null)
+			if (clan != null)
+			{
 				clan.setHideoutId(getId());
+			}
 			else
+			{
 				free();
+			}
 		}
 	}
 	
@@ -263,34 +282,42 @@ public abstract class ClanHall
 	public final ArrayList<L2DoorInstance> getDoors()
 	{
 		if (_doors == null)
+		{
 			_doors = new ArrayList<>();
+		}
 		return _doors;
 	}
 	
 	/**
-	 * @param doorId 
+	 * @param doorId
 	 * @return Door
 	 */
 	public final L2DoorInstance getDoor(int doorId)
 	{
 		if (doorId <= 0)
+		{
 			return null;
+		}
 		for (L2DoorInstance door : getDoors())
 		{
 			if (door.getDoorId() == doorId)
+			{
 				return door;
+			}
 		}
 		return null;
 	}
 	
 	/**
-	 * @param type 
+	 * @param type
 	 * @return function with id
 	 */
 	public ClanHallFunction getFunction(int type)
 	{
 		if (_functions.get(type) != null)
+		{
 			return _functions.get(type);
+		}
 		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
 	 */
 	public boolean checkIfInZone(int x, int y, int z)
@@ -328,20 +355,24 @@ public abstract class ClanHall
 		_ownerId = 0;
 		_isFree = true;
 		for (Map.Entry<Integer, ClanHallFunction> fc : _functions.entrySet())
+		{
 			removeFunction(fc.getKey());
+		}
 		_functions.clear();
 		updateDb();
 	}
 	
 	/**
 	 * Set owner if clan hall is free
-	 * @param clan 
+	 * @param clan
 	 */
 	public void setOwner(L2Clan clan)
 	{
 		// Verify that this ClanHall is Free and Clan isn't null
-		if (_ownerId > 0 || clan == null)
+		if ((_ownerId > 0) || (clan == null))
+		{
 			return;
+		}
 		_ownerId = clan.getClanId();
 		_isFree = false;
 		clan.setHideoutId(getId());
@@ -349,17 +380,19 @@ public abstract class ClanHall
 		clan.broadcastToOnlineMembers(new PledgeShowInfoUpdate(clan));
 		updateDb();
 	}
-		
+	
 	/**
 	 * Open or Close Door
-	 * @param activeChar 
-	 * @param doorId 
+	 * @param activeChar
+	 * @param doorId
 	 * @param 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);
+		}
 	}
 	
 	public void openCloseDoor(int doorId, boolean open)
@@ -372,16 +405,22 @@ public abstract class ClanHall
 		if (door != null)
 		{
 			if (open)
+			{
 				door.openMe();
+			}
 			else
+			{
 				door.closeMe();
+			}
 		}
 	}
 	
 	public void openCloseDoors(L2PcInstance activeChar, boolean open)
 	{
-		if (activeChar != null && activeChar.getClanId() == getOwnerId())
+		if ((activeChar != null) && (activeChar.getClanId() == getOwnerId()))
+		{
 			openCloseDoors(open);
+		}
 	}
 	
 	public void openCloseDoors(boolean open)
@@ -391,9 +430,13 @@ public abstract class ClanHall
 			if (door != null)
 			{
 				if (open)
+				{
 					door.openMe();
+				}
 				else
+				{
 					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)
 	{
 		if (player == null)
+		{
 			return false;
+		}
 		if (Config.DEBUG)
+		{
 			_log.warning("Called ClanHall.updateFunctions(int type, int lvl, int lease, long rate, boolean addNew) Owner : " + getOwnerId());
+		}
 		if (lease > 0)
 		{
 			if (!player.destroyItemByItemId("Consume", PcInventory.ADENA_ID, lease, null, true))
+			{
 				return false;
+			}
 		}
 		if (addNew)
+		{
 			_functions.put(type, new ClanHallFunction(type, lvl, lease, 0, rate, 0, false));
+		}
 		else
 		{
-			if (lvl == 0 && lease == 0)
+			if ((lvl == 0) && (lease == 0))
+			{
 				removeFunction(type);
+			}
 			else
 			{
 				int diffLease = lease - _functions.get(type).getLease();
 				if (Config.DEBUG)
+				{
 					_log.warning("Called ClanHall.updateFunctions diffLease : " + diffLease);
+				}
 				if (diffLease > 0)
 				{
 					_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())
 		{
-			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);
-			rs = statement.executeQuery();
+			ResultSet rs = statement.executeQuery();
 			
 			while (rs.next())
 			{
@@ -88,9 +86,8 @@ public class Couple
 		
 		try (Connection con = L2DatabaseFactory.getInstance().getConnection())
 		{
-			PreparedStatement statement;
 			_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(2, _player1Id);
 			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 FastList<Byte> _completedRooms = new FastList<>();
 	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;
 	
 	private Timer teleporterTimer;
@@ -72,9 +72,13 @@ public class DimensionalRift
 			{
 				QuestState qs = p.getQuestState(riftQuest.getName());
 				if (qs == null)
+				{
 					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]);
 		}
@@ -113,14 +117,17 @@ public class DimensionalRift
 		}
 		
 		teleporterTimer = new Timer();
-		teleporterTimerTask = new TimerTask() {
+		teleporterTimerTask = new TimerTask()
+		{
 			@Override
 			public void run()
 			{
 				if (_choosenRoom > -1)
+				{
 					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++;
 					
@@ -128,16 +135,24 @@ public class DimensionalRift
 					_choosenRoom = -1;
 					
 					for (L2PcInstance p : _party.getMembers())
+					{
 						if (!revivedInWaitingRoom.contains(p))
+						{
 							teleportToNextRoom(p);
+						}
+					}
 					createTeleporterTimer(true);
 					createSpawnTimer(_choosenRoom);
 				}
 				else
 				{
 					for (L2PcInstance p : _party.getMembers())
+					{
 						if (!revivedInWaitingRoom.contains(p))
+						{
 							teleportToWaitingRoom(p);
+						}
+					}
 					killRift();
 					cancel();
 				}
@@ -147,21 +162,27 @@ public class DimensionalRift
 		if (reasonTP)
 		{
 			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
 				public void run()
 				{
 					for (L2PcInstance p : _party.getMembers())
+					{
 						if (!revivedInWaitingRoom.contains(p))
+						{
 							p.sendPacket(new Earthquake(p.getX(), p.getY(), p.getZ(), 65, 9));
+						}
+					}
 				}
-			}
-			, jumpTime - 7000);
+			}, jumpTime - 7000);
 		}
 		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)
@@ -179,7 +200,8 @@ public class DimensionalRift
 		}
 		
 		spawnTimer = new Timer();
-		spawnTimerTask = new TimerTask() {
+		spawnTimerTask = new TimerTask()
+		{
 			@Override
 			public void run()
 			{
@@ -198,15 +220,21 @@ public class DimensionalRift
 	public void partyMemberExited(L2PcInstance player)
 	{
 		if (deadPlayers.contains(player))
+		{
 			deadPlayers.remove(player);
+		}
 		
 		if (revivedInWaitingRoom.contains(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())
+			{
 				teleportToWaitingRoom(p);
+			}
 			killRift();
 		}
 	}
@@ -214,7 +242,9 @@ public class DimensionalRift
 	public void manualTeleport(L2PcInstance player, L2Npc npc)
 	{
 		if (!player.isInParty() || !player.getParty().isInDimensionalRift())
+		{
 			return;
+		}
 		
 		if (player.getObjectId() != player.getParty().getLeaderObjectId())
 		{
@@ -234,7 +264,9 @@ public class DimensionalRift
 		_choosenRoom = -1;
 		
 		for (L2PcInstance p : _party.getMembers())
+		{
 			teleportToNextRoom(p);
+		}
 		
 		DimensionalRiftManager.getInstance().getRoom(_type, _choosenRoom).setPartyInside(true);
 		
@@ -245,7 +277,9 @@ public class DimensionalRift
 	public void manualExitRift(L2PcInstance player, L2Npc npc)
 	{
 		if (!player.isInParty() || !player.getParty().isInDimensionalRift())
+		{
 			return;
+		}
 		
 		if (player.getObjectId() != player.getParty().getLeaderObjectId())
 		{
@@ -254,7 +288,9 @@ public class DimensionalRift
 		}
 		
 		for (L2PcInstance p : player.getParty().getMembers())
+		{
 			teleportToWaitingRoom(p);
+		}
 		killRift();
 	}
 	
@@ -271,8 +307,10 @@ public class DimensionalRift
 				emptyRooms.removeAll(_completedRooms);
 				// If no room left, find any empty
 				if (emptyRooms.isEmpty())
+				{
 					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());
 		}
@@ -290,8 +328,10 @@ public class DimensionalRift
 		if (riftQuest != null)
 		{
 			QuestState qs = player.getQuestState(riftQuest.getName());
-			if (qs != null && qs.getInt("cond") == 1)
+			if ((qs != null) && (qs.getInt("cond") == 1))
+			{
 				qs.set("cond", "0");
+			}
 		}
 	}
 	
@@ -300,7 +340,9 @@ public class DimensionalRift
 		_completedRooms = null;
 		
 		if (_party != null)
+		{
 			_party.setDimensionalRift(null);
+		}
 		
 		_party = 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;
 		
 		if (isBossRoom)
+		{
 			return (long) (time * Config.RIFT_BOSS_ROOM_TIME_MUTIPLY);
+		}
 		return time;
 	}
 	
 	public void memberDead(L2PcInstance player)
 	{
 		if (!deadPlayers.contains(player))
+		{
 			deadPlayers.add(player);
+		}
 	}
 	
 	public void memberRessurected(L2PcInstance player)
 	{
 		if (deadPlayers.contains(player))
+		{
 			deadPlayers.remove(player);
+		}
 	}
 	
 	public void usedTeleport(L2PcInstance player)
 	{
 		if (!revivedInWaitingRoom.contains(player))
+		{
 			revivedInWaitingRoom.add(player);
+		}
 		
 		if (!deadPlayers.contains(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())
-				if (p != null && !revivedInWaitingRoom.contains(p))
+			{
+				if ((p != null) && !revivedInWaitingRoom.contains(p))
+				{
 					teleportToWaitingRoom(p);
+				}
+			}
 			killRift();
 		}
 	}
@@ -420,8 +476,10 @@ public class DimensionalRift
 	
 	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 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_INTERRUPTED = 4;
 	
-	private int _duelId;
+	private final int _duelId;
 	private L2PcInstance _playerA;
 	private L2PcInstance _playerB;
-	private boolean _partyDuel;
-	private Calendar _duelEndTime;
+	private final boolean _partyDuel;
+	private final Calendar _duelEndTime;
 	private int _surrenderRequest = 0;
 	private int _countdown = 4;
 	private boolean _finished = false;
@@ -78,9 +78,13 @@ public class Duel
 		
 		_duelEndTime = Calendar.getInstance();
 		if (_partyDuel)
+		{
 			_duelEndTime.add(Calendar.SECOND, 300);
+		}
 		else
+		{
 			_duelEndTime.add(Calendar.SECOND, 120);
+		}
 		
 		_playerConditions = new FastList<>();
 		
@@ -112,7 +116,9 @@ public class Duel
 		public PlayerCondition(L2PcInstance player, boolean partyDuel)
 		{
 			if (player == null)
+			{
 				return;
+			}
 			_player = player;
 			_hp = _player.getCurrentHp();
 			_mp = _player.getCurrentMp();
@@ -130,7 +136,9 @@ public class Duel
 		public void restoreCondition()
 		{
 			if (_player == null)
+			{
 				return;
+			}
 			_player.setCurrentHp(_hp);
 			_player.setCurrentMp(_mp);
 			_player.setCurrentCp(_cp);
@@ -142,15 +150,21 @@ public class Duel
 			if (_debuffs != null) // Debuff removal
 			{
 				for (L2Effect temp : _debuffs)
+				{
 					if (temp != null)
+					{
 						temp.exit();
+					}
+				}
 			}
 		}
 		
 		public void registerDebuff(L2Effect debuff)
 		{
 			if (_debuffs == null)
+			{
 				_debuffs = new FastList<>();
+			}
 			
 			_debuffs.add(debuff);
 		}
@@ -158,7 +172,9 @@ public class Duel
 		public void teleportBack()
 		{
 			if (_paDuel)
+			{
 				_player.teleToLocation(_x, _y, _z);
+			}
 		}
 		
 		public L2PcInstance getPlayer()
@@ -169,7 +185,7 @@ public class Duel
 	
 	public class ScheduleDuelTask implements Runnable
 	{
-		private Duel _duel;
+		private final Duel _duel;
 		
 		public ScheduleDuelTask(Duel duel)
 		{
@@ -196,7 +212,9 @@ public class Duel
 					ThreadPoolManager.getInstance().scheduleGeneral(new ScheduleEndDuelTask(_duel, status), 5000);
 				}
 				else
+				{
 					ThreadPoolManager.getInstance().scheduleGeneral(this, 1000);
+				}
 			}
 			catch (Exception e)
 			{
@@ -207,7 +225,7 @@ public class Duel
 	
 	public static class ScheduleStartDuelTask implements Runnable
 	{
-		private Duel _duel;
+		private final Duel _duel;
 		
 		public ScheduleStartDuelTask(Duel duel)
 		{
@@ -225,7 +243,7 @@ public class Duel
 				if (count == 4)
 				{
 					// 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
 					_duel.teleportPlayers(-83760, -238825, -3331);
 					
@@ -237,7 +255,9 @@ public class Duel
 					ThreadPoolManager.getInstance().scheduleGeneral(this, 1000);
 				}
 				else
+				{
 					_duel.startDuel();
+				}
 			}
 			catch (Exception e)
 			{
@@ -248,8 +268,8 @@ public class Duel
 	
 	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)
 		{
@@ -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()
 	{
@@ -311,7 +329,7 @@ public class Duel
 	
 	/**
 	 * 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
 	 */
 	public boolean isDuelistInPvp(boolean sendMessage)
@@ -321,7 +339,7 @@ public class Duel
 			// Party duels take place in arenas - should be no other players there
 			return false;
 		}
-		else if (_playerA.getPvpFlag() != 0 || _playerB.getPvpFlag() != 0)
+		else if ((_playerA.getPvpFlag() != 0) || (_playerB.getPvpFlag() != 0))
 		{
 			if (sendMessage)
 			{
@@ -336,14 +354,13 @@ public class Duel
 	
 	/**
 	 * Starts the duel
-	 *
 	 */
 	public void startDuel()
 	{
 		// Save player Conditions
 		savePlayerConditions();
 		
-		if (_playerA == null || _playerB == null || _playerA.isInDuel() || _playerB.isInDuel())
+		if ((_playerA == null) || (_playerB == null) || _playerA.isInDuel() || _playerB.isInDuel())
 		{
 			// clean up
 			_playerConditions.clear();
@@ -417,7 +434,6 @@ public class Duel
 	
 	/**
 	 * Save the current player condition: hp, mp, cp, location
-	 *
 	 */
 	public void savePlayerConditions()
 	{
@@ -473,7 +489,9 @@ public class Duel
 		
 		// if it is an abnormal DuelEnd do not restore hp, mp, cp
 		if (abnormalDuelEnd)
+		{
 			return;
+		}
 		
 		// restore player conditions
 		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)
 	{
-		//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)
+		{
 			return;
+		}
 		int offset = 0;
 		
 		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 = 0;
 		for (L2PcInstance temp : _playerB.getParty().getMembers())
 		{
-			temp.teleToLocation(x + offset - 180, y + 150, z);
+			temp.teleToLocation((x + offset) - 180, y + 150, z);
 			offset += 40;
 		}
 	}
 	
 	/**
 	 * Broadcast a packet to the challenger team
-	 * @param packet 
+	 * @param packet
 	 */
 	public void broadcastToTeam1(L2GameServerPacket packet)
 	{
 		if (_playerA == null)
+		{
 			return;
+		}
 		
-		if (_partyDuel && _playerA.getParty() != null)
+		if (_partyDuel && (_playerA.getParty() != null))
 		{
 			for (L2PcInstance temp : _playerA.getParty().getMembers())
+			{
 				temp.sendPacket(packet);
+			}
 		}
 		else
+		{
 			_playerA.sendPacket(packet);
+		}
 	}
 	
 	/**
 	 * Broadcast a packet to the challenged team
-	 * @param packet 
+	 * @param packet
 	 */
 	public void broadcastToTeam2(L2GameServerPacket packet)
 	{
 		if (_playerB == null)
+		{
 			return;
+		}
 		
-		if (_partyDuel && _playerB.getParty() != null)
+		if (_partyDuel && (_playerB.getParty() != null))
 		{
 			for (L2PcInstance temp : _playerB.getParty().getMembers())
+			{
 				temp.sendPacket(packet);
+			}
 		}
 		else
+		{
 			_playerB.sendPacket(packet);
+		}
 	}
 	
 	/**
@@ -605,12 +637,18 @@ public class Duel
 	 */
 	public L2PcInstance getWinner()
 	{
-		if (!getFinished() || _playerA == null || _playerB == null)
+		if (!getFinished() || (_playerA == null) || (_playerB == null))
+		{
 			return null;
+		}
 		if (_playerA.getDuelState() == DUELSTATE_WINNER)
+		{
 			return _playerA;
+		}
 		if (_playerB.getDuelState() == DUELSTATE_WINNER)
+		{
 			return _playerB;
+		}
 		return null;
 	}
 	
@@ -620,33 +658,44 @@ public class Duel
 	 */
 	public L2PcInstance getLooser()
 	{
-		if (!getFinished() || _playerA == null || _playerB == null)
+		if (!getFinished() || (_playerA == null) || (_playerB == null))
+		{
 			return null;
+		}
 		if (_playerA.getDuelState() == DUELSTATE_WINNER)
+		{
 			return _playerB;
+		}
 		else if (_playerB.getDuelState() == DUELSTATE_WINNER)
+		{
 			return _playerA;
+		}
 		return null;
 	}
 	
 	/**
 	 * Playback the bow animation for all loosers
-	 *
 	 */
 	public void playKneelAnimation()
 	{
 		L2PcInstance looser = getLooser();
 		
 		if (looser == null)
+		{
 			return;
+		}
 		
-		if (_partyDuel && looser.getParty() != null)
+		if (_partyDuel && (looser.getParty() != null))
 		{
 			for (L2PcInstance temp : looser.getParty().getMembers())
+			{
 				temp.broadcastPacket(new SocialAction(temp.getObjectId(), 7));
+			}
 		}
 		else
+		{
 			looser.broadcastPacket(new SocialAction(looser.getObjectId(), 7));
+		}
 	}
 	
 	/**
@@ -658,7 +707,9 @@ public class Duel
 		_countdown--;
 		
 		if (_countdown > 3)
+		{
 			return _countdown;
+		}
 		
 		// Broadcast countdown to duelists
 		SystemMessage sm = null;
@@ -668,7 +719,9 @@ public class Duel
 			sm.addNumber(_countdown);
 		}
 		else
+		{
 			sm = SystemMessage.getSystemMessage(SystemMessageId.LET_THE_DUEL_BEGIN);
+		}
 		
 		broadcastToTeam1(sm);
 		broadcastToTeam2(sm);
@@ -682,9 +735,9 @@ public class Duel
 	 */
 	public void endDuel(DuelResultEnum result)
 	{
-		if (_playerA == null || _playerB == null)
+		if ((_playerA == null) || (_playerB == null))
 		{
-			//clean up
+			// clean up
 			_playerConditions.clear();
 			_playerConditions = null;
 			DuelManager.getInstance().removeDuel(this);
@@ -700,9 +753,13 @@ public class Duel
 				restorePlayerConditions(false);
 				// send SystemMessage
 				if (_partyDuel)
+				{
 					sm = SystemMessage.getSystemMessage(SystemMessageId.C1_PARTY_HAS_WON_THE_DUEL);
+				}
 				else
+				{
 					sm = SystemMessage.getSystemMessage(SystemMessageId.C1_HAS_WON_THE_DUEL);
+				}
 				sm.addString(_playerA.getName());
 				
 				broadcastToTeam1(sm);
@@ -713,9 +770,13 @@ public class Duel
 				restorePlayerConditions(false);
 				// send SystemMessage
 				if (_partyDuel)
+				{
 					sm = SystemMessage.getSystemMessage(SystemMessageId.C1_PARTY_HAS_WON_THE_DUEL);
+				}
 				else
+				{
 					sm = SystemMessage.getSystemMessage(SystemMessageId.C1_HAS_WON_THE_DUEL);
+				}
 				sm.addString(_playerB.getName());
 				
 				broadcastToTeam1(sm);
@@ -725,7 +786,7 @@ public class Duel
 				stopFighting();
 				// dont restore hp, mp, cp
 				restorePlayerConditions(true);
-				//TODO: is there no other message for a canceled duel?
+				// TODO: is there no other message for a canceled duel?
 				// send SystemMessage
 				sm = SystemMessage.getSystemMessage(SystemMessageId.THE_DUEL_HAS_ENDED_IN_A_TIE);
 				
@@ -747,14 +808,18 @@ public class Duel
 		// Send end duel packet
 		ExDuelEnd duelEnd = null;
 		if (_partyDuel)
+		{
 			duelEnd = new ExDuelEnd(1);
+		}
 		else
+		{
 			duelEnd = new ExDuelEnd(0);
+		}
 		
 		broadcastToTeam1(duelEnd);
 		broadcastToTeam2(duelEnd);
 		
-		//clean up
+		// clean up
 		_playerConditions.clear();
 		_playerConditions = null;
 		DuelManager.getInstance().removeDuel(this);
@@ -767,14 +832,18 @@ public class Duel
 	public DuelResultEnum checkEndDuelCondition()
 	{
 		// one of the players might leave during duel
-		if (_playerA == null || _playerB == null)
+		if ((_playerA == null) || (_playerB == null))
+		{
 			return DuelResultEnum.Canceled;
+		}
 		
 		// got a duel surrender request?
 		if (_surrenderRequest != 0)
 		{
 			if (_surrenderRequest == 1)
+			{
 				return DuelResultEnum.Team1Surrender;
+			}
 			return DuelResultEnum.Team2Surrender;
 		}
 		// duel timed out
@@ -800,21 +869,28 @@ public class Duel
 		else if (!_partyDuel)
 		{
 			// 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;
+			}
 			
 			// Are the players too far apart?
 			if (!_playerA.isInsideRadius(_playerB, 1600, false, false))
+			{
 				return DuelResultEnum.Canceled;
+			}
 			
 			// Did one of the players engage in PvP combat?
 			if (isDuelistInPvp(true))
+			{
 				return DuelResultEnum.Canceled;
+			}
 			
 			// 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.Continue;
@@ -828,7 +904,9 @@ public class Duel
 	{
 		// already recived a surrender request
 		if (_surrenderRequest != 0)
+		{
 			return;
+		}
 		
 		// stop the fight
 		stopFighting();
@@ -904,7 +982,9 @@ public class Duel
 			{
 				L2PcInstance winner = _playerA;
 				if (_playerA.getParty().getMembers().contains(player))
+				{
 					winner = _playerB;
+				}
 				
 				for (L2PcInstance temp : winner.getParty().getMembers())
 				{
@@ -914,13 +994,19 @@ public class Duel
 		}
 		else
 		{
-			if (player != _playerA && player != _playerB)
+			if ((player != _playerA) && (player != _playerB))
+			{
 				_log.warning("Error in onPlayerDefeat(): player is not part of this 1vs1 duel");
+			}
 			
 			if (_playerA == player)
+			{
 				_playerB.setDuelState(DUELSTATE_WINNER);
+			}
 			else
+			{
 				_playerA.setDuelState(DUELSTATE_WINNER);
+			}
 		}
 	}
 	
@@ -932,11 +1018,13 @@ public class Duel
 	{
 		// if it isnt a party duel ignore this
 		if (!_partyDuel)
+		{
 			return;
+		}
 		
 		// this player is leaving his party during party duel
 		// 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;)
 			{
@@ -948,7 +1036,7 @@ public class Duel
 			_playerB = null;
 		}
 		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;)
 			{

+ 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());
 	
 	private int _fortId = 0;
-	private List<L2DoorInstance> _doors = new ArrayList<>();
+	private final List<L2DoorInstance> _doors = new ArrayList<>();
 	private L2StaticObjectInstance _flagPole = null;
 	private String _name = "";
 	private FortSiege _siege = null;
@@ -82,17 +82,17 @@ public class Fort
 	private int _castleId = 0;
 	private int _blood = 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
 	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 */
 	public static final int FUNC_TELEPORT = 1;
@@ -103,11 +103,11 @@ public class Fort
 	
 	public class FortFunction
 	{
-		private int _type;
+		private final int _type;
 		private int _lvl;
 		protected int _fee;
 		protected int _tempFee;
-		private long _rate;
+		private final long _rate;
 		private long _endDate;
 		protected boolean _inDebt;
 		public boolean _cwh;
@@ -166,12 +166,18 @@ public class Fort
 		private void initializeTask(boolean cwh)
 		{
 			if (getOwnerClan() == null)
+			{
 				return;
+			}
 			long currentTime = System.currentTimeMillis();
 			if (_endDate > currentTime)
+			{
 				ThreadPoolManager.getInstance().scheduleGeneral(new FunctionTask(cwh), _endDate - currentTime);
+			}
 			else
+			{
 				ThreadPoolManager.getInstance().scheduleGeneral(new FunctionTask(cwh), 0);
+			}
 		}
 		
 		private class FunctionTask implements Runnable
@@ -187,12 +193,16 @@ public class Fort
 				try
 				{
 					if (getOwnerClan() == null)
+					{
 						return;
-					if (getOwnerClan().getWarehouse().getAdena() >= _fee || !_cwh)
+					}
+					if ((getOwnerClan().getWarehouse().getAdena() >= _fee) || !_cwh)
 					{
 						int fee = _fee;
 						if (getEndTime() == -1)
+						{
 							fee = _tempFee;
+						}
 						
 						setEndTime(System.currentTimeMillis() + getRate());
 						dbSave();
@@ -200,12 +210,16 @@ public class Fort
 						{
 							getOwnerClan().getWarehouse().destroyItemByItemId("CS_function_fee", PcInventory.ADENA_ID, fee, null, null);
 							if (Config.DEBUG)
+							{
 								_log.warning("Deducted " + fee + " adena from " + getName() + " owner's cwh for function id : " + getType());
+							}
 						}
 						ThreadPoolManager.getInstance().scheduleGeneral(new FunctionTask(true), getRate());
 					}
 					else
+					{
 						removeFunction(getType());
+					}
 				}
 				catch (Throwable t)
 				{
@@ -260,11 +274,11 @@ public class Fort
 		}
 		initNpcs(); // load and spawn npcs (Always spawned)
 		initSiegeNpcs(); // load suspicious merchants (Despawned 10mins before siege)
-		//spawnSuspiciousMerchant();// spawn suspicious merchants
+		// spawnSuspiciousMerchant();// spawn suspicious merchants
 		initNpcCommanders(); // npc Commanders (not monsters) (Spawned during siege)
 		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();
 			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
 	 */
 	public FortFunction getFunction(int type)
 	{
 		if (_function.get(type) != null)
+		{
 			return _function.get(type);
+		}
 		return null;
 	}
 	
 	public static class ScheduleSpecialEnvoysDeSpawn implements Runnable
 	{
-		private Fort _fortInst;
+		private final Fort _fortInst;
 		
 		public ScheduleSpecialEnvoysDeSpawn(Fort pFort)
 		{
@@ -299,7 +315,9 @@ public class Fort
 			{
 				// if state not decided, change state to indenpendent
 				if (_fortInst.getFortState() == 0)
+				{
 					_fortInst.setFortState(1, 0);
+				}
 				_fortInst.despawnSpecialEnvoys();
 			}
 			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()
 	{
@@ -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
 	 */
 	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)
 	{
 		if (activeChar.getClan() != getOwnerClan())
+		{
 			return;
+		}
 		
 		L2DoorInstance door = getDoor(doorId);
 		if (door != null)
 		{
 			if (open)
+			{
 				door.openMe();
+			}
 			else
+			{
 				door.closeMe();
+			}
 		}
 	}
 	
@@ -415,7 +440,7 @@ public class Fort
 	 * This method will set owner for Fort
 	 * @param clan
 	 * @param updateClansReputation
-	 * @return 
+	 * @return
 	 */
 	public boolean setOwner(L2Clan clan, boolean updateClansReputation)
 	{
@@ -425,7 +450,7 @@ public class Fort
 			return false;
 		}
 		final L2Clan oldowner = getOwnerClan();
-		if (oldowner != null && clan != oldowner)
+		if ((oldowner != null) && (clan != oldowner))
 		{
 			// Remove points from old owner
 			updateClansReputation(oldowner, true);
@@ -435,7 +460,9 @@ public class Fort
 				if (oldleader != null)
 				{
 					if (oldleader.getMountType() == 2)
+					{
 						oldleader.dismount();
+					}
 				}
 			}
 			catch (Exception e)
@@ -446,7 +473,7 @@ public class Fort
 		}
 		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)
 		{
 			getSiege().announceToPlayer(SystemMessage.getSystemMessage(SystemMessageId.NPCS_RECAPTURED_FORTRESS));
@@ -455,13 +482,17 @@ public class Fort
 		
 		// Give points to new owner
 		if (updateClansReputation)
+		{
 			updateClansReputation(clan, false);
+		}
 		
 		spawnSpecialEnvoys();
 		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.getFortId() > 0)
+		{
 			FortManager.getInstance().getFortByOwner(clan).removeOwner(true);
+		}
 		
 		setBloodOathReward(0);
 		setSupplyLvL(0);
@@ -469,8 +500,10 @@ public class Fort
 		updateOwnerInDB(); // Update in database
 		saveFortVariables();
 		
-		if (getSiege().getIsInProgress()) // If siege in progress
+		if (getSiege().getIsInProgress())
+		{
 			getSiege().endSiege();
+		}
 		
 		for (L2PcInstance member : clan.getOnlineMembers(0))
 		{
@@ -498,7 +531,9 @@ public class Fort
 			saveFortVariables();
 			removeAllFunctions();
 			if (updateDB)
+			{
 				updateOwnerInDB();
+			}
 		}
 	}
 	
@@ -516,13 +551,17 @@ public class Fort
 	{
 		_supplyLvL++;
 		if (_supplyLvL > Config.FS_MAX_SUPPLY_LEVEL)
+		{
 			_supplyLvL = Config.FS_MAX_SUPPLY_LEVEL;
+		}
 	}
 	
 	public void setSupplyLvL(int val)
 	{
 		if (val <= Config.FS_MAX_SUPPLY_LEVEL)
+		{
 			_supplyLvL = val;
+		}
 	}
 	
 	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)
 	{
 		L2StaticObjectInstance flagPole = getFlagPole();
 		if (flagPole != null)
+		{
 			flagPole.setMeshIndex(val ? 1 : 0);
+		}
 	}
 	
 	/**
-	 * Respawn all doors on fort grounds<BR><BR>
+	 * Respawn all doors on fort grounds<BR>
+	 * <BR>
 	 */
 	public void resetDoors()
 	{
 		for (L2DoorInstance door : _doors)
 		{
 			if (door.getOpen())
+			{
 				door.closeMe();
+			}
 			if (door.isDead())
+			{
 				door.doRevive();
+			}
 			if (door.getCurrentHp() < door.getMaxHp())
+			{
 				door.setCurrentHp(door.getMaxHp());
+			}
 		}
 		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)
 	{
 		L2DoorInstance door = getDoor(doorId);
-		if (door != null && door.getDoorId() == doorId)
+		if ((door != null) && (door.getDoorId() == doorId))
 		{
 			door.setCurrentHp(door.getMaxHp() + hp);
 			
@@ -625,19 +674,27 @@ public class Fort
 				int runCount = getOwnedTime() / (Config.FS_UPDATE_FRQ * 60);
 				long initial = System.currentTimeMillis() - _lastOwnedTime.getTimeInMillis();
 				while (initial > (Config.FS_UPDATE_FRQ * 60000L))
+				{
 					initial -= (Config.FS_UPDATE_FRQ * 60000L);
+				}
 				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
 					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
+					}
 				}
 				else
+				{
 					_FortUpdater[1] = ThreadPoolManager.getInstance().scheduleGeneral(new FortUpdater(this, clan, 0, UpdaterType.MAX_OWN_TIME), 60000); // Schedule owner tasks to remove owner
+				}
 			}
 			else
+			{
 				setOwnerClan(null);
+			}
 			
 		}
 		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
 	 */
 	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)
 	{
 		if (player == null)
+		{
 			return false;
+		}
 		if (Config.DEBUG)
+		{
 			_log.warning("Called Fort.updateFunctions(int type, int lvl, int lease, long rate, boolean addNew) Owner : " + getOwnerClan());
+		}
 		if (lease > 0)
+		{
 			if (!player.destroyItemByItemId("Consume", PcInventory.ADENA_ID, lease, null, true))
+			{
 				return false;
+			}
+		}
 		if (addNew)
 		{
 			_function.put(type, new FortFunction(type, lvl, lease, 0, rate, 0, false));
 		}
 		else
 		{
-			if (lvl == 0 && lease == 0)
+			if ((lvl == 0) && (lease == 0))
+			{
 				removeFunction(type);
+			}
 			else
 			{
 				int diffLease = lease - _function.get(type).getLease();
 				if (Config.DEBUG)
+				{
 					_log.warning("Called Fort.updateFunctions diffLease : " + diffLease);
+				}
 				if (diffLease > 0)
 				{
 					_function.remove(type);
@@ -749,18 +818,22 @@ public class Fort
 	{
 		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);
+			}
 		}
 		if (Config.DEBUG)
-			_log.info("Fort "+this+" loaded "+_doors.size()+" doors.");
+		{
+			_log.info("Fort " + this + " loaded " + _doors.size() + " doors.");
+		}
 	}
 	
 	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;
 				break;
@@ -837,7 +910,9 @@ public class Fort
 			_lastOwnedTime.setTimeInMillis(System.currentTimeMillis());
 		}
 		else
+		{
 			_lastOwnedTime.setTimeInMillis(0);
+		}
 		
 		try (Connection con = L2DatabaseFactory.getInstance().getConnection())
 		{
@@ -863,20 +938,30 @@ public class Fort
 				clan.broadcastToOnlineMembers(new PledgeShowInfoUpdate(clan));
 				clan.broadcastToOnlineMembers(new PlaySound(1, "Siege_Victory", 0, 0, 0, 0, 0));
 				if (_FortUpdater[0] != null)
+				{
 					_FortUpdater[0].cancel(false);
+				}
 				if (_FortUpdater[1] != null)
+				{
 					_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
 				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
+				}
 			}
 			else
 			{
 				if (_FortUpdater[0] != null)
+				{
 					_FortUpdater[0].cancel(false);
+				}
 				_FortUpdater[0] = null;
 				if (_FortUpdater[1] != null)
+				{
 					_FortUpdater[1].cancel(false);
+				}
 				_FortUpdater[1] = null;
 			}
 		}
@@ -905,12 +990,16 @@ public class Fort
 	public final L2DoorInstance getDoor(int doorId)
 	{
 		if (doorId <= 0)
+		{
 			return null;
+		}
 		
 		for (L2DoorInstance door : getDoors())
 		{
 			if (door.getDoorId() == doorId)
+			{
 				return door;
+			}
 		}
 		return null;
 	}
@@ -928,7 +1017,9 @@ public class Fort
 	public final FortSiege getSiege()
 	{
 		if (_siege == null)
+		{
 			_siege = new FortSiege(this);
+		}
 		return _siege;
 	}
 	
@@ -945,7 +1036,9 @@ public class Fort
 	public final int getOwnedTime()
 	{
 		if (_lastOwnedTime.getTimeInMillis() == 0)
+		{
 			return 0;
+		}
 		
 		return (int) ((System.currentTimeMillis() - _lastOwnedTime.getTimeInMillis()) / 1000);
 	}
@@ -953,15 +1046,19 @@ public class Fort
 	public final int getTimeTillRebelArmy()
 	{
 		if (_lastOwnedTime.getTimeInMillis() == 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()
 	{
 		if (_FortUpdater[0] == null)
+		{
 			return 0;
+		}
 		return _FortUpdater[0].getDelay(TimeUnit.SECONDS);
 	}
 	
@@ -975,16 +1072,20 @@ public class Fort
 		if (owner != null)
 		{
 			if (removePoints)
+			{
 				owner.takeReputationScore(Config.LOOSE_FORT_POINTS, true);
+			}
 			else
+			{
 				owner.addReputationScore(Config.TAKE_FORT_POINTS, true);
+			}
 		}
 	}
 	
 	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)
 		{
@@ -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()
 	{
@@ -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
 	 */
 	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()
 	{
@@ -1080,7 +1182,9 @@ public class Fort
 	public void spawnSuspiciousMerchant()
 	{
 		if (_isSuspiciousMerchantSpawned)
+		{
 			return;
+		}
 		_isSuspiciousMerchantSpawned = true;
 		
 		for (L2Spawn spawnDat : _siegeNpcs)
@@ -1093,7 +1197,9 @@ public class Fort
 	public void despawnSuspiciousMerchant()
 	{
 		if (!_isSuspiciousMerchantSpawned)
+		{
 			return;
+		}
 		_isSuspiciousMerchantSpawned = false;
 		
 		for (L2Spawn spawnDat : _siegeNpcs)
@@ -1252,8 +1358,7 @@ public class Fort
 				}
 				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();
@@ -1298,8 +1403,7 @@ public class Fort
 				}
 				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();
@@ -1319,19 +1423,23 @@ public class Fort
 	
 	public void giveResidentialSkills(L2PcInstance player)
 	{
-		if (_residentialSkills != null && !_residentialSkills.isEmpty())
+		if ((_residentialSkills != null) && !_residentialSkills.isEmpty())
 		{
 			for (L2Skill sk : _residentialSkills)
+			{
 				player.addSkill(sk, false);
+			}
 		}
 	}
 	
 	public void removeResidentialSkills(L2PcInstance player)
 	{
-		if (_residentialSkills != null && !_residentialSkills.isEmpty())
+		if ((_residentialSkills != null) && !_residentialSkills.isEmpty())
 		{
 			for (L2Skill sk : _residentialSkills)
+			{
 				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());
 	
 	private static FastList<FortSiegeListener> fortSiegeListeners = new FastList<FortSiegeListener>().shared();
-
+	
 	public static enum TeleportWhoType
 	{
-		All, Attacker, Owner,
+		All,
+		Attacker,
+		Owner,
 	}
 	
 	// SQL
@@ -75,16 +77,18 @@ public class FortSiege implements Siegable
 		public void run()
 		{
 			if (!getIsInProgress())
+			{
 				return;
+			}
 			
 			try
 			{
 				_siegeEnd = null;
-				FortSiege.this.endSiege();
+				endSiege();
 			}
 			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)
 		{
-			_fortInst = FortSiege.this._fort;
+			_fortInst = _fort;
 			_time = time;
 		}
 		
@@ -104,7 +108,9 @@ public class FortSiege implements Siegable
 		public void run()
 		{
 			if (getIsInProgress())
+			{
 				return;
+			}
 			
 			try
 			{
@@ -168,7 +174,9 @@ public class FortSiege implements Siegable
 					_fortInst.getSiege().startSiege();
 				}
 				else
+				{
 					_log.warning("Exception: ScheduleStartSiegeTask(): unknown siege time: " + String.valueOf(_time));
+				}
 			}
 			catch (Exception e)
 			{
@@ -183,15 +191,17 @@ public class FortSiege implements Siegable
 		public void run()
 		{
 			if (getIsInProgress())
+			{
 				return;
+			}
 			
 			try
 			{
-				FortSiege.this._fort.spawnSuspiciousMerchant();
+				_fort.spawnSuspiciousMerchant();
 			}
 			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()
 		{
 			if (!getIsInProgress())
+			{
 				return;
+			}
 			
 			try
 			{
 				_siegeRestore = null;
-				FortSiege.this.resetSiege();
+				resetSiege();
 				announceToPlayer(SystemMessage.getSystemMessage(SystemMessageId.BARRACKS_FUNCTION_RESTORED));
 			}
 			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
 	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
 	public void endSiege()
@@ -256,7 +269,9 @@ public class FortSiege implements Siegable
 			
 			int ownerId = -1;
 			if (getFort().getOwnerClan() != null)
+			{
 				ownerId = getFort().getOwnerClan().getClanId();
+			}
 			getFort().getZone().banishForeigners(ownerId);
 			getFort().getZone().setIsActive(false);
 			getFort().getZone().updateZoneStatusForCharactersInside();
@@ -284,8 +299,10 @@ public class FortSiege implements Siegable
 				_siegeRestore = null;
 			}
 			
-			if (getFort().getOwnerClan() != null && getFort().getFlagPole().getMeshIndex() == 0)
+			if ((getFort().getOwnerClan() != null) && (getFort().getFlagPole().getMeshIndex() == 0))
+			{
 				getFort().setVisibleFlag(true);
+			}
 			
 			_log.info("Siege of " + getFort().getName() + " fort finished.");
 			fireFortSiegeEventListeners(EventStage.END);
@@ -293,7 +310,8 @@ public class FortSiege implements Siegable
 	}
 	
 	/**
-	 * When siege starts<BR><BR>
+	 * When siege starts<BR>
+	 * <BR>
 	 */
 	@Override
 	public void startSiege()
@@ -312,7 +330,9 @@ public class FortSiege implements Siegable
 			_siegeStartTask = null;
 			
 			if (getAttackerClans().isEmpty())
+			{
 				return;
+			}
 			
 			_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
 	 */
 	public void announceToPlayer(SystemMessage sm)
@@ -355,7 +376,9 @@ public class FortSiege implements Siegable
 			for (L2PcInstance member : clan.getOnlineMembers(0))
 			{
 				if (member != null)
+				{
 					member.sendPacket(sm);
+				}
 			}
 		}
 		if (getFort().getOwnerClan() != null)
@@ -364,7 +387,9 @@ public class FortSiege implements Siegable
 			for (L2PcInstance member : clan.getOnlineMembers(0))
 			{
 				if (member != null)
+				{
 					member.sendPacket(sm);
+				}
 			}
 		}
 	}
@@ -384,7 +409,9 @@ public class FortSiege implements Siegable
 			for (L2PcInstance member : clan.getOnlineMembers(0))
 			{
 				if (member == null)
+				{
 					continue;
+				}
 				
 				if (clear)
 				{
@@ -412,7 +439,9 @@ public class FortSiege implements Siegable
 			for (L2PcInstance member : clan.getOnlineMembers(0))
 			{
 				if (member == null)
+				{
 					continue;
+				}
 				
 				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)
 	{
@@ -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
 	 */
 	public boolean checkIfInZone(int x, int y, int z)
@@ -473,8 +502,10 @@ public class FortSiege implements Siegable
 	@Override
 	public boolean checkIsDefender(L2Clan clan)
 	{
-		if (clan != null && getFort().getOwnerClan() == clan)
+		if ((clan != null) && (getFort().getOwnerClan() == clan))
+		{
 			return true;
+		}
 		
 		return false;
 	}
@@ -501,7 +532,9 @@ public class FortSiege implements Siegable
 			
 			// if siege is in progress, end siege
 			if (getIsInProgress())
+			{
 				endSiege();
+			}
 			
 			// if siege isn't in progress (1hr waiting time till siege starts), cancel waiting time
 			if (_siegeStartTask != null)
@@ -536,10 +569,14 @@ public class FortSiege implements Siegable
 			for (L2PcInstance player : clan.getOnlineMembers(0))
 			{
 				if (player == null)
+				{
 					continue;
+				}
 				
 				if (player.isInSiege())
+				{
 					players.add(player);
+				}
 			}
 		}
 		return players;
@@ -564,27 +601,33 @@ public class FortSiege implements Siegable
 		{
 			clan = ClanTable.getInstance().getClan(getFort().getOwnerClan().getClanId());
 			if (clan != getFort().getOwnerClan())
+			{
 				return null;
+			}
 			
 			for (L2PcInstance player : clan.getOnlineMembers(0))
 			{
 				if (player == null)
+				{
 					continue;
+				}
 				
 				if (player.isInSiege())
+				{
 					players.add(player);
+				}
 			}
 		}
 		return players;
 	}
 	
 	/**
-	 * Commander was killed 
+	 * Commander was killed
 	 * @param 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();
 			if (spawn != null)
@@ -611,7 +654,9 @@ public class FortSiege implements Siegable
 								break;
 						}
 						if (npcString != null)
+						{
 							instance.broadcastPacket(new NpcSay(instance.getObjectId(), 1, instance.getNpcId(), npcString));
+						}
 					}
 				}
 				_commanders.remove(spawn);
@@ -628,9 +673,11 @@ public class FortSiege implements Siegable
 					for (L2DoorInstance door : getFort().getDoors())
 					{
 						if (door.getIsShowHp())
+						{
 							continue;
+						}
 						
-						//TODO this also opens control room door at big fort
+						// TODO this also opens control room door at big fort
 						door.openMe();
 					}
 					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);
 				}
 				else
+				{
 					getFort().getSiege().announceToPlayer(SystemMessage.getSystemMessage(SystemMessageId.SEIZED_BARRACKS));
+				}
 			}
 			else
+			{
 				_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
 	 */
 	public void killedFlag(L2Npc flag)
 	{
 		if (flag == null)
+		{
 			return;
+		}
 		
 		for (L2SiegeClan clan : getAttackerClans())
 		{
 			if (clan.removeFlag(flag))
+			{
 				return;
+			}
 		}
 	}
 	
 	/**
-	 * Register clan as attacker<BR><BR>
+	 * Register clan as attacker<BR>
+	 * <BR>
 	 * @param player The L2PcInstance of the player trying to register
-	 * @param force 
-	 * @return 
+	 * @param force
+	 * @return
 	 */
 	public boolean registerAttacker(L2PcInstance player, boolean force)
 	{
 		if (player.getClan() == null)
+		{
 			return false;
+		}
 		
 		if (force || checkIfCanRegister(player))
 		{
@@ -683,7 +741,9 @@ public class FortSiege implements Siegable
 			if (getAttackerClans().size() == 1)
 			{
 				if (!force)
+				{
 					player.reduceAdena("siege", 250000, null, true);
+				}
 				startAutoTask(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 !
 	 * @param clanId The int of player's clan id
 	 */
@@ -713,9 +774,13 @@ public class FortSiege implements Siegable
 			if (getAttackerClans().isEmpty())
 			{
 				if (getIsInProgress())
+				{
 					endSiege();
+				}
 				else
+				{
 					saveFortSiege(); // Clear siege time in DB
+				}
 				
 				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
 	 */
 	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;
+		}
 		
 		removeSiegeClan(clan.getClanId());
 	}
@@ -748,8 +816,10 @@ public class FortSiege implements Siegable
 	 */
 	public void checkAutoTask()
 	{
-		if (_siegeStartTask != null) //safety check
+		if (_siegeStartTask != null)
+		{
 			return;
+		}
 		
 		final long delay = getFort().getSiegeDate().getTimeInMillis() - Calendar.getInstance().getTimeInMillis();
 		
@@ -765,8 +835,10 @@ public class FortSiege implements Siegable
 		{
 			loadSiegeClan();
 			if (getAttackerClans().isEmpty())
+			{
 				// no attackers - waiting for suspicious merchant spawn
 				ThreadPoolManager.getInstance().scheduleGeneral(new ScheduleSuspiciousMerchantSpawn(), delay);
+			}
 			else
 			{
 				// preparing start siege task
@@ -780,13 +852,19 @@ public class FortSiege implements Siegable
 					ThreadPoolManager.getInstance().executeTask(new ScheduleSuspiciousMerchantSpawn());
 					_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);
-				else if (delay > 60000) //more than 1 min
+				}
+				else if (delay > 60000)
+				{
 					_siegeStartTask = ThreadPoolManager.getInstance().scheduleGeneral(new FortSiege.ScheduleStartSiegeTask(60), delay - 60000);
+				}
 				else
+				{
 					// lower than 1 min, set to 1 min
 					_siegeStartTask = ThreadPoolManager.getInstance().scheduleGeneral(new FortSiege.ScheduleStartSiegeTask(60), 0);
+				}
 				
 				_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)
 	{
 		if (_siegeStartTask != null)
+		{
 			return;
+		}
 		
 		if (setTime)
+		{
 			setSiegeDateTime(false);
+		}
 		
 		if (getFort().getOwnerClan() != null)
+		{
 			getFort().getOwnerClan().broadcastToOnlineMembers(SystemMessage.getSystemMessage(SystemMessageId.A_FORTRESS_IS_UNDER_ATTACK));
+		}
 		
 		// Execute siege auto start
 		_siegeStartTask = ThreadPoolManager.getInstance().scheduleGeneral(new FortSiege.ScheduleStartSiegeTask(3600), 0);
@@ -814,8 +899,8 @@ public class FortSiege implements Siegable
 	
 	/**
 	 * Teleport players
-	 * @param teleportWho 
-	 * @param teleportWhere 
+	 * @param teleportWho
+	 * @param teleportWhere
 	 */
 	public void teleportPlayer(TeleportWhoType teleportWho, MapRegionManager.TeleportWhereType teleportWhere)
 	{
@@ -835,14 +920,17 @@ public class FortSiege implements Siegable
 		for (L2PcInstance player : players)
 		{
 			if (player.isGM() || player.isInJail())
+			{
 				continue;
+			}
 			
 			player.teleToLocation(teleportWhere);
 		}
 	}
 	
 	/**
-	 * Add clan as attacker<BR><BR>
+	 * Add clan as attacker<BR>
+	 * <BR>
 	 * @param clanId The int of clan's id
 	 */
 	private void addAttacker(int clanId)
@@ -857,7 +945,7 @@ public class FortSiege implements Siegable
 	public boolean checkIfCanRegister(L2PcInstance player)
 	{
 		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;
 			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;
 			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;
 			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;
 			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;
 			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);
 					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;
 					player.sendPacket(SystemMessageId.ALREADY_REQUESTED_SIEGE_BATTLE);
@@ -917,14 +1005,20 @@ public class FortSiege implements Siegable
 		for (FortSiege siege : FortSiegeManager.getInstance().getSieges())
 		{
 			if (siege == this)
+			{
 				continue;
+			}
 			
 			if (siege.getSiegeDate().get(Calendar.DAY_OF_WEEK) == getSiegeDate().get(Calendar.DAY_OF_WEEK))
 			{
 				if (siege.checkIsAttacker(clan))
+				{
 					return true;
+				}
 				if (siege.checkIsDefender(clan))
+				{
 					return true;
+				}
 			}
 		}
 		
@@ -935,9 +1029,13 @@ public class FortSiege implements Siegable
 	{
 		Calendar newDate = Calendar.getInstance();
 		if (merchant)
+		{
 			newDate.add(Calendar.MINUTE, FortSiegeManager.getInstance().getSuspiciousMerchantRespawnDelay());
+		}
 		else
+		{
 			newDate.add(Calendar.MINUTE, 60);
+		}
 		getFort().setSiegeDate(newDate);
 		saveSiegeDate();
 	}
@@ -967,7 +1065,7 @@ public class FortSiege implements Siegable
 	/** Remove commanders. */
 	private void removeCommanders()
 	{
-		if (_commanders != null && !_commanders.isEmpty())
+		if ((_commanders != null) && !_commanders.isEmpty())
 		{
 			// Remove all instance of commanders for this fort
 			for (L2Spawn spawn : _commanders)
@@ -976,7 +1074,9 @@ public class FortSiege implements Siegable
 				{
 					spawn.stopRespawn();
 					if (spawn.getLastSpawn() != null)
+					{
 						spawn.getLastSpawn().deleteMe();
+					}
 				}
 			}
 			_commanders.clear();
@@ -989,7 +1089,9 @@ public class FortSiege implements Siegable
 		for (L2SiegeClan sc : getAttackerClans())
 		{
 			if (sc != null)
+			{
 				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
 	 */
 	private void saveSiegeClan(L2Clan clan)
@@ -1045,7 +1148,7 @@ public class FortSiege implements Siegable
 	/** Spawn commanders. */
 	private void spawnCommanders()
 	{
-		//Set commanders array size if one does not exist
+		// Set commanders array size if one does not exist
 		try
 		{
 			_commanders.clear();
@@ -1083,20 +1186,27 @@ public class FortSiege implements Siegable
 	private void spawnFlag(int Id)
 	{
 		for (CombatFlag cf : FortSiegeManager.getInstance().getFlagList(Id))
+		{
 			cf.spawnMe();
+		}
 	}
 	
 	private void unSpawnFlags()
 	{
 		if (FortSiegeManager.getInstance().getFlagList(getFort().getFortId()) == null)
+		{
 			return;
+		}
 		
 		for (CombatFlag cf : FortSiegeManager.getInstance().getFlagList(getFort().getFortId()))
+		{
 			cf.unSpawnMe();
+		}
 	}
 	
 	/**
-	 * Spawn siege guard.<BR><BR>
+	 * Spawn siege guard.<BR>
+	 * <BR>
 	 */
 	private void spawnSiegeGuard()
 	{
@@ -1107,7 +1217,9 @@ public class FortSiege implements Siegable
 	public final L2SiegeClan getAttackerClan(L2Clan clan)
 	{
 		if (clan == null)
+		{
 			return null;
+		}
 		
 		return getAttackerClan(clan.getClanId());
 	}
@@ -1116,8 +1228,12 @@ public class FortSiege implements Siegable
 	public final L2SiegeClan getAttackerClan(int clanId)
 	{
 		for (L2SiegeClan sc : getAttackerClans())
-			if (sc != null && sc.getClanId() == clanId)
+		{
+			if ((sc != null) && (sc.getClanId() == clanId))
+			{
 				return sc;
+			}
+		}
 		
 		return null;
 	}
@@ -1151,7 +1267,9 @@ public class FortSiege implements Siegable
 		{
 			L2SiegeClan sc = getAttackerClan(clan);
 			if (sc != null)
+			{
 				return sc.getFlag();
+			}
 		}
 		
 		return null;
@@ -1160,7 +1278,9 @@ public class FortSiege implements Siegable
 	public final FortSiegeGuardManager getSiegeGuardManager()
 	{
 		if (_siegeGuardManager == null)
+		{
 			_siegeGuardManager = new FortSiegeGuardManager(getFort());
+		}
 		
 		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)
 				{
 					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);
@@ -337,7 +337,7 @@ public class Hero
 				{
 					String name = CharNameTable.getInstance().getNameById(charTwoId);
 					String cls = ClassListData.getInstance().getClass(charTwoClass).getClientCode();
-					if(name != null && cls != null)
+					if ((name != null) && (cls != null))
 					{
 						StatsSet fight = new StatsSet();
 						fight.set("oponent", name);
@@ -373,7 +373,7 @@ public class Hero
 				{
 					String name = CharNameTable.getInstance().getNameById(charOneId);
 					String cls = ClassListData.getInstance().getClass(charOneClass).getClientCode();
-					if(name != null && cls != null)
+					if ((name != null) && (cls != null))
 					{
 						StatsSet fight = new StatsSet();
 						fight.set("oponent", name);
@@ -457,8 +457,8 @@ public class Hero
 		{
 			List<StatsSet> _mainlist = _herodiary.get(charid);
 			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.replace("%heroname%", CharNameTable.getInstance().getNameById(charid));
@@ -546,7 +546,7 @@ public class Hero
 			List<StatsSet> _list = _herofights.get(charid);
 			
 			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)
 			{
 				FightReply.setHtml(htmContent);
@@ -719,7 +719,7 @@ public class Hero
 		updateHeroes(false);
 		
 		L2PcInstance player;
-		for(Integer charId : _heroes.keySet())
+		for (Integer charId : _heroes.keySet())
 		{
 			player = L2World.getInstance().getPlayer(charId);
 			if (player != null)
@@ -787,8 +787,8 @@ public class Hero
 	
 	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())
 		{
@@ -957,7 +957,9 @@ public class Hero
 	{
 		_heroMessage.put(player.getObjectId(), message);
 		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)
 	{
 		if (_heroMessage.get(charId) == null)
+		{
 			return;
+		}
 		
 		try (Connection con = L2DatabaseFactory.getInstance().getConnection())
 		{
@@ -1003,7 +1007,7 @@ public class Hero
 	 */
 	public void shutdown()
 	{
-		for (int charId: _heroMessage.keySet())
+		for (int charId : _heroMessage.keySet())
 		{
 			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;
 
 /**
- * @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
 {
@@ -59,7 +57,7 @@ public class L2Event
 	public static final List<L2PcInstance> _registeredPlayers = new FastList<>();
 	public static final Map<Integer, FastList<L2PcInstance>> _teams = new FastMap<>();
 	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<>();
 	
 	public enum EventState
@@ -70,19 +68,22 @@ public class L2Event
 	}
 	
 	/**
-	 * 
 	 * @param player
 	 * @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)
 	{
 		if (player == null)
+		{
 			return -1;
+		}
 		
 		for (Entry<Integer, FastList<L2PcInstance>> team : _teams.entrySet())
 		{
 			if (team.getValue().contains(player))
+			{
 				return team.getKey();
+			}
 		}
 		
 		return -1;
@@ -97,7 +98,9 @@ public class L2Event
 			for (L2PcInstance player : teamList)
 			{
 				if (player.getEventStatus() == null)
+				{
 					continue;
+				}
 				
 				tmp.put(player, player.getEventStatus().kills.size());
 			}
@@ -117,10 +120,10 @@ public class L2Event
 		toReturn.addAll(tmp.keySet());
 		return toReturn.subList(1, n);
 	}
-
+	
 	public static void showEventHtml(L2PcInstance player, String objectid)
-	{//TODO: work on this
-		
+	{// TODO: work on this
+	
 		if (eventState == EventState.STANDBY)
 		{
 			try
@@ -129,12 +132,18 @@ public class L2Event
 				NpcHtmlMessage html = new NpcHtmlMessage(5);
 				
 				if (_registeredPlayers.contains(player))
+				{
 					htmContent = HtmCache.getInstance().getHtm(player.getHtmlPrefix(), "data/html/mods/EventEngine/Participating.htm");
+				}
 				else
+				{
 					htmContent = HtmCache.getInstance().getHtm(player.getHtmlPrefix(), "data/html/mods/EventEngine/Participation.htm");
+				}
 				
 				if (htmContent != null)
+				{
 					html.setHtml(htmContent);
+				}
 				
 				html.replace("%objectId%", objectid); // Yeah, we need this.
 				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)
 	{
@@ -175,12 +183,12 @@ public class L2Event
 			spawn.getLastSpawn().setCurrentHp(999999999);
 			spawn.getLastSpawn().setTitle(_eventName);
 			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));
 			
-			//_npcs.add(spawn.getLastSpawn());
+			// _npcs.add(spawn.getLastSpawn());
 			
 		}
 		catch (Exception e)
@@ -192,30 +200,30 @@ public class L2Event
 	
 	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())
 		{
-			if (spawn.getLastSpawn() != null && spawn.getLastSpawn().isEventMob)
+			if ((spawn.getLastSpawn() != null) && spawn.getLastSpawn().isEventMob)
 			{
 				spawn.getLastSpawn().deleteMe();
 				spawn.stopRespawn();
 				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)
 	{
-		if (player == null || player.getEventStatus() == null)
+		if ((player == null) || (player.getEventStatus() == null))
+		{
 			return false;
+		}
 		
 		switch (eventState)
 		{
@@ -227,7 +235,9 @@ public class L2Event
 				for (FastList<L2PcInstance> teamList : _teams.values())
 				{
 					if (teamList.contains(player))
+					{
 						return true;
+					}
 				}
 		}
 		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)
 	{
@@ -248,28 +256,27 @@ public class L2Event
 			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);
+		}
 		else
 		{
 			player.sendMessage("You have reached the maximum allowed participants per IP.");
 			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)
 	{
 		
 		try
-		{			
+		{
 			if (isParticipant(player))
 			{
 				if (player.isDead())
@@ -293,14 +300,18 @@ public class L2Event
 			}
 			
 			if (player.getEventStatus() != null)
+			{
 				player.getEventStatus().restoreInits();
+			}
 			
 			player.setEventStatus(null);
 			
 			_registeredPlayers.remove(player);
 			int teamId = getPlayerTeamId(player);
 			if (_teams.containsKey(teamId))
+			{
 				_teams.get(teamId).remove(player);
+			}
 		}
 		catch (Exception e)
 		{
@@ -310,17 +321,16 @@ public class L2Event
 	
 	/**
 	 * The player's event status will be saved at _connectionLossData
-	 * @param player 
+	 * @param 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)
 	{
@@ -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.
 	 */
 	public static String startEventParticipation()
@@ -358,10 +367,12 @@ public class L2Event
 			// Just in case
 			unspawnEventNpcs();
 			_registeredPlayers.clear();
-			//_npcs.clear();
+			// _npcs.clear();
 			
 			if (NpcTable.getInstance().getTemplate(_npcId) == null)
+			{
 				return "Cannot start event, invalid npc id.";
+			}
 			
 			try (FileReader fr = new FileReader(Config.DATAPACK_ROOT + "/data/events/" + _eventName);
 				BufferedReader br = new BufferedReader(fr))
@@ -373,8 +384,10 @@ public class L2Event
 			List<L2PcInstance> temp = new FastList<>();
 			for (L2PcInstance player : L2World.getInstance().getAllPlayersArray())
 			{
-				if (!player.isOnline()) // Offline shops? 
+				if (!player.isOnline())
+				{
 					continue;
+				}
 				
 				if (!temp.contains(player))
 				{
@@ -384,9 +397,11 @@ public class L2Event
 				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))
+					{
 						temp.add(playertemp);
+					}
 				}
-			}	
+			}
 		}
 		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.
 	 */
 	public static String startEvent()
@@ -426,28 +438,34 @@ public class L2Event
 			
 			// Insert empty lists at _teams.
 			for (int i = 0; i < _teamsNumber; i++)
+			{
 				_teams.put(i + 1, new FastList<L2PcInstance>());
+			}
 			
 			int i = 0;
 			while (!_registeredPlayers.isEmpty())
 			{
-				//Get the player with the biggest level
+				// Get the player with the biggest level
 				int max = 0;
 				L2PcInstance biggestLvlPlayer = null;
 				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)
+				{
 					continue;
+				}
 				
 				_registeredPlayers.remove(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.
 	 */
 	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.";
 	}

+ 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;
 
 /**
- *
- * @author  Migi, DS
+ * @author Migi, DS
  */
 public class Message
 {
@@ -52,7 +51,7 @@ public class Message
 	private int _sendBySystem;
 	private boolean _deletedBySender;
 	private boolean _deletedByReceiver;
-	private long _reqAdena;
+	private final long _reqAdena;
 	private boolean _hasAttachments;
 	private Mail _attachments = null;
 	private ScheduledFuture<?> _unloadTask = null;
@@ -95,7 +94,7 @@ public class Message
 		_receiverId = receiverId;
 		_subject = subject;
 		_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;
 		_unread = true;
 		_deletedBySender = false;
@@ -111,9 +110,9 @@ public class Message
 		_messageId = IdFactory.getInstance().getNextId();
 		_senderId = -1;
 		_receiverId = receiverId;
-		_subject = subject; 
+		_subject = subject;
 		_content = content;
-		_expiration = System.currentTimeMillis() + EXPIRATION * 3600000;
+		_expiration = System.currentTimeMillis() + (EXPIRATION * 3600000);
 		_reqAdena = 0;
 		_hasAttachments = false;
 		_unread = true;
@@ -133,7 +132,7 @@ public class Message
 		_receiverId = msg.getSenderId();
 		_subject = "";
 		_content = "";
-		_expiration = System.currentTimeMillis() + EXPIRATION * 3600000;
+		_expiration = System.currentTimeMillis() + (EXPIRATION * 3600000);
 		_unread = true;
 		_deletedBySender = true;
 		_deletedByReceiver = false;
@@ -188,11 +187,15 @@ public class Message
 		if (_senderName == null)
 		{
 			if (_sendBySystem != 0)
+			{
 				return "****";
+			}
 			
 			_senderName = CharNameTable.getInstance().getNameById(_senderId);
 			if (_senderName == null)
+			{
 				_senderName = "";
+			}
 		}
 		return _senderName;
 	}
@@ -203,7 +206,9 @@ public class Message
 		{
 			_receiverName = CharNameTable.getInstance().getNameById(_receiverId);
 			if (_receiverName == null)
+			{
 				_receiverName = "";
+			}
 		}
 		return _receiverName;
 	}
@@ -230,7 +235,7 @@ public class Message
 	
 	public final int getExpirationSeconds()
 	{
-		return (int)(_expiration / 1000);
+		return (int) (_expiration / 1000);
 	}
 	
 	public final boolean isUnread()
@@ -258,9 +263,13 @@ public class Message
 		{
 			_deletedBySender = true;
 			if (_deletedByReceiver)
+			{
 				MailManager.getInstance().deleteMessageInDb(_messageId);
+			}
 			else
+			{
 				MailManager.getInstance().markAsDeletedBySenderInDb(_messageId);
+			}
 		}
 	}
 	
@@ -275,9 +284,13 @@ public class Message
 		{
 			_deletedByReceiver = true;
 			if (_deletedBySender)
+			{
 				MailManager.getInstance().deleteMessageInDb(_messageId);
+			}
 			else
+			{
 				MailManager.getInstance().markAsDeletedByReceiverInDb(_messageId);
+			}
 		}
 	}
 	
@@ -304,7 +317,9 @@ public class Message
 	public final synchronized Mail getAttachments()
 	{
 		if (!_hasAttachments)
+		{
 			return null;
+		}
 		
 		if (_attachments == null)
 		{
@@ -328,14 +343,18 @@ public class Message
 			_hasAttachments = false;
 			MailManager.getInstance().removeAttachmentsInDb(_messageId);
 			if (_unloadTask != null)
+			{
 				_unloadTask.cancel(false);
+			}
 		}
 	}
 	
 	public final synchronized Mail createAttachments()
 	{
-		if (_hasAttachments || _attachments != null)
+		if (_hasAttachments || (_attachments != null))
+		{
 			return null;
+		}
 		
 		_attachments = new Mail(_senderId, _messageId);
 		_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
 {
-	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)
 	{
-		if (activeChar != null && activeChar.isOnline())
+		if ((activeChar != null) && activeChar.isOnline())
 		{
 			if (activeChar.getRecomHave() == 0)
+			{
 				return 0;
+			}
 			
 			int _lvl = activeChar.getLevel() / 10;
 			int _exp = (Math.min(100, activeChar.getRecomHave()) - 1) / 10;
@@ -53,11 +155,15 @@ public final class RecoBonus
 		double _multiplier = 1;
 		
 		double bonus = getRecoBonus(activeChar);
-		if(bonus > 0)
+		if (bonus > 0)
+		{
 			_multiplier = (1 + (bonus / 100));
+		}
 		
-		if(_multiplier < 1)
+		if (_multiplier < 1)
+		{
 			_multiplier = 1;
+		}
 		
 		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
- *
  */
 public interface Siegable
 {
@@ -55,7 +54,9 @@ public interface Siegable
 	public Calendar getSiegeDate();
 	
 	public boolean giveFame();
+	
 	public int getFameFrequency();
+	
 	public int getFameAmount();
 	
 	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()
 		{
 			if (!getIsInProgress())
+			{
 				return;
+			}
 			
 			try
 			{
@@ -165,7 +167,9 @@ public class Siege implements Siegable
 		{
 			_scheduledStartSiegeTask.cancel(false);
 			if (getIsInProgress())
+			{
 				return;
+			}
 			
 			try
 			{
@@ -270,7 +274,9 @@ public class Siege implements Siegable
 					final int num = SiegeManager.getInstance().getBloodAllianceReward();
 					int count = getCastle().getBloodAlliance();
 					if (num > 0)
+					{
 						getCastle().setBloodAlliance(count + num);
+					}
 				}
 				else
 				{
@@ -280,7 +286,7 @@ public class Siege implements Siegable
 						if (member != null)
 						{
 							L2PcInstance player = member.getPlayerInstance();
-							if (player != null && player.isNoble())
+							if ((player != null) && player.isNoble())
 							{
 								Hero.getInstance().setCastleTaken(player.getObjectId(), getCastle().getCastleId());
 							}
@@ -308,7 +314,9 @@ public class Siege implements Siegable
 			removeFlameTower();
 			_siegeGuardManager.unspawnSiegeGuard(); // Remove all spawned siege guard from this castle
 			if (getCastle().getOwnerId() > 0)
+			{
 				_siegeGuardManager.removeMercs();
+			}
 			getCastle().spawnDoor(); // Respawn door to castle
 			getCastle().getZone().setIsActive(false);
 			getCastle().getZone().updateZoneStatusForCharactersInside();
@@ -320,19 +328,25 @@ public class Siege implements Siegable
 	private void removeDefender(L2SiegeClan sc)
 	{
 		if (sc != null)
+		{
 			getDefenderClans().remove(sc);
+		}
 	}
 	
 	private void removeAttacker(L2SiegeClan sc)
 	{
 		if (sc != null)
+		{
 			getAttackerClans().remove(sc);
+		}
 	}
 	
 	private void addDefender(L2SiegeClan sc, SiegeClanType type)
 	{
 		if (sc == null)
+		{
 			return;
+		}
 		sc.setType(type);
 		getDefenderClans().add(sc);
 	}
@@ -340,7 +354,9 @@ public class Siege implements Siegable
 	private void addAttacker(L2SiegeClan sc)
 	{
 		if (sc == null)
+		{
 			return;
+		}
 		sc.setType(SiegeClanType.ATTACKER);
 		getAttackerClans().add(sc);
 	}
@@ -354,11 +370,13 @@ public class Siege implements Siegable
 		if (getIsInProgress()) // Siege still in progress
 		{
 			if (getCastle().getOwnerId() > 0)
+			{
 				_siegeGuardManager.removeMercs(); // Remove all merc entry from db
-				
+			}
+			
 			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());
 				removeAttacker(sc_newowner);
@@ -381,7 +399,9 @@ public class Siege implements Siegable
 							if (sc != null)
 							{
 								if (ClanTable.getInstance().getClan(sc.getClanId()).getAllyId() != allyId)
+								{
 									allinsamealliance = false;
+								}
 							}
 						}
 						if (allinsamealliance)
@@ -448,16 +468,22 @@ public class Siege implements Siegable
 		if (!getIsInProgress())
 		{
 			if (!fireSiegeListeners(EventStage.START))
+			{
 				return;
+			}
 			_firstOwnerClanId = getCastle().getOwnerId();
 			
 			if (getAttackerClans().isEmpty())
 			{
 				SystemMessage sm;
 				if (getCastle().getOwnerId() <= 0)
+				{
 					sm = SystemMessage.getSystemMessage(SystemMessageId.SIEGE_OF_S1_HAS_BEEN_CANCELED_DUE_TO_LACK_OF_INTEREST);
+				}
 				else
+				{
 					sm = SystemMessage.getSystemMessage(SystemMessageId.S1_SIEGE_WAS_CANCELED_BECAUSE_NO_CLANS_PARTICIPATED);
+				}
 				sm.addCastleId(getCastle().getCastleId());
 				Announcements.getInstance().announceToAll(sm);
 				saveCastleSiege();
@@ -507,7 +533,9 @@ public class Siege implements Siegable
 			for (L2PcInstance member : clan.getOnlineMembers(0))
 			{
 				if (member != null)
+				{
 					member.sendPacket(message);
+				}
 			}
 		}
 		
@@ -519,7 +547,9 @@ public class Siege implements Siegable
 				for (L2PcInstance member : clan.getOnlineMembers(0))
 				{
 					if (member != null)
+					{
 						member.sendPacket(message);
+					}
 				}
 			}
 		}
@@ -531,13 +561,17 @@ public class Siege implements Siegable
 		for (L2SiegeClan siegeclan : getAttackerClans())
 		{
 			if (siegeclan == null)
+			{
 				continue;
+			}
 			
 			clan = ClanTable.getInstance().getClan(siegeclan.getClanId());
 			for (L2PcInstance member : clan.getOnlineMembers(0))
 			{
 				if (member == null)
+				{
 					continue;
+				}
 				
 				if (clear)
 				{
@@ -561,24 +595,32 @@ public class Siege implements Siegable
 				for (L2PcInstance player : member.getKnownList().getKnownPlayers().values())
 				{
 					if (player == null)
+					{
 						continue;
+					}
 					
 					player.sendPacket(new RelationChanged(member, member.getRelation(player), member.isAutoAttackable(player)));
 					if (member.getPet() != null)
+					{
 						player.sendPacket(new RelationChanged(member.getPet(), member.getRelation(player), member.isAutoAttackable(player)));
+					}
 				}
 			}
 		}
 		for (L2SiegeClan siegeclan : getDefenderClans())
 		{
 			if (siegeclan == null)
+			{
 				continue;
+			}
 			
 			clan = ClanTable.getInstance().getClan(siegeclan.getClanId());
 			for (L2PcInstance member : clan.getOnlineMembers(0))
 			{
 				if (member == null)
+				{
 					continue;
+				}
 				
 				if (clear)
 				{
@@ -603,10 +645,14 @@ public class Siege implements Siegable
 				for (L2PcInstance player : member.getKnownList().getKnownPlayers().values())
 				{
 					if (player == null)
+					{
 						continue;
+					}
 					player.sendPacket(new RelationChanged(member, member.getRelation(player), member.isAutoAttackable(player)));
 					if (member.getPet() != null)
+					{
 						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)
 	{
 		if (clanId <= 0)
+		{
 			return;
+		}
 		saveSiegeClan(ClanTable.getInstance().getClan(clanId), DEFENDER, true);
 		loadSiegeClan();
 	}
@@ -733,10 +781,14 @@ public class Siege implements Siegable
 			for (L2PcInstance player : clan.getOnlineMembers(0))
 			{
 				if (player == null)
+				{
 					continue;
+				}
 				
 				if (player.isInSiege())
+				{
 					players.add(player);
+				}
 			}
 		}
 		return players;
@@ -753,14 +805,20 @@ public class Siege implements Siegable
 		{
 			clan = ClanTable.getInstance().getClan(siegeclan.getClanId());
 			if (clan.getClanId() == getCastle().getOwnerId())
+			{
 				continue;
+			}
 			for (L2PcInstance player : clan.getOnlineMembers(0))
 			{
 				if (player == null)
+				{
 					continue;
+				}
 				
 				if (player.isInSiege())
+				{
 					players.add(player);
+				}
 			}
 		}
 		return players;
@@ -785,14 +843,20 @@ public class Siege implements Siegable
 		{
 			clan = ClanTable.getInstance().getClan(siegeclan.getClanId());
 			if (clan.getClanId() != getCastle().getOwnerId())
+			{
 				continue;
+			}
 			for (L2PcInstance player : clan.getOnlineMembers(0))
 			{
 				if (player == null)
+				{
 					continue;
+				}
 				
 				if (player.isInSiege())
+				{
 					players.add(player);
+				}
 			}
 		}
 		return players;
@@ -808,10 +872,14 @@ public class Siege implements Siegable
 		for (L2PcInstance player : getCastle().getZone().getPlayersInside())
 		{
 			if (player == null)
+			{
 				continue;
+			}
 			
 			if (!player.isInSiege())
+			{
 				players.add(player);
+			}
 		}
 		return players;
 	}
@@ -824,7 +892,9 @@ public class Siege implements Siegable
 	{
 		_controlTowerCount--;
 		if (_controlTowerCount < 0)
+		{
 			_controlTowerCount = 0;
+		}
 	}
 	
 	/**
@@ -834,11 +904,15 @@ public class Siege implements Siegable
 	public void killedFlag(L2Npc flag)
 	{
 		if (flag == null)
+		{
 			return;
+		}
 		for (L2SiegeClan clan : getAttackerClans())
 		{
 			if (clan.removeFlag(flag))
+			{
 				return;
+			}
 		}
 	}
 	
@@ -864,20 +938,26 @@ public class Siege implements Siegable
 	public void registerAttacker(L2PcInstance player, boolean force)
 	{
 		if (player.getClan() == null)
+		{
 			return;
+		}
 		int allyId = 0;
 		if (getCastle().getOwnerId() != 0)
+		{
 			allyId = ClanTable.getInstance().getClan(getCastle().getOwnerId()).getAllyId();
+		}
 		if (allyId != 0)
 		{
-			if (player.getClan().getAllyId() == allyId && !force)
+			if ((player.getClan().getAllyId() == allyId) && !force)
 			{
 				player.sendPacket(SystemMessageId.CANNOT_ATTACK_ALLIANCE_CASTLE);
 				return;
 			}
 		}
 		if (force || checkIfCanRegister(player, ATTACKER))
+		{
 			saveSiegeClan(player.getClan(), ATTACKER, false); // Save to database
+		}
 	}
 	
 	/**
@@ -893,9 +973,13 @@ public class Siege implements Siegable
 	public void registerDefender(L2PcInstance player, boolean force)
 	{
 		if (getCastle().getOwnerId() <= 0)
+		{
 			player.sendMessage("You cannot register as a defender because " + getCastle().getName() + " is owned by NPC.");
+		}
 		else if (force || checkIfCanRegister(player, DEFENDER_NOT_APPROWED))
+		{
 			saveSiegeClan(player.getClan(), DEFENDER_NOT_APPROWED, false); // Save to database
+		}
 	}
 	
 	/**
@@ -906,7 +990,9 @@ public class Siege implements Siegable
 	public void removeSiegeClan(int clanId)
 	{
 		if (clanId <= 0)
+		{
 			return;
+		}
 		
 		try (Connection con = L2DatabaseFactory.getInstance().getConnection();
 			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)
 	{
-		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;
+		}
 		removeSiegeClan(clan.getClanId());
 	}
 	
@@ -959,7 +1047,9 @@ public class Siege implements Siegable
 		
 		// Schedule siege auto start
 		if (_scheduledStartSiegeTask != null)
+		{
 			_scheduledStartSiegeTask.cancel(false);
+		}
 		_scheduledStartSiegeTask = ThreadPoolManager.getInstance().scheduleGeneral(new Siege.ScheduleStartSiegeTask(getCastle()), 1000);
 	}
 	
@@ -992,7 +1082,9 @@ public class Siege implements Siegable
 		for (L2PcInstance player : players)
 		{
 			if (player.isGM() || player.isInJail())
+			{
 				continue;
+			}
 			player.teleToLocation(teleportWhere);
 		}
 	}
@@ -1053,23 +1145,41 @@ public class Siege implements Siegable
 			player.sendPacket(sm);
 		}
 		else if (getIsInProgress())
+		{
 			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);
+		}
 		else if (player.getClan().getClanId() == getCastle().getOwnerId())
+		{
 			player.sendPacket(SystemMessageId.CLAN_THAT_OWNS_CASTLE_IS_AUTOMATICALLY_REGISTERED_DEFENDING);
+		}
 		else if (player.getClan().getCastleId() > 0)
+		{
 			player.sendPacket(SystemMessageId.CLAN_THAT_OWNS_CASTLE_CANNOT_PARTICIPATE_OTHER_SIEGE);
+		}
 		else if (SiegeManager.getInstance().checkIsRegistered(player.getClan(), getCastle().getCastleId()))
+		{
 			player.sendPacket(SystemMessageId.ALREADY_REQUESTED_SIEGE_BATTLE);
+		}
 		else if (checkIfAlreadyRegisteredForSameDay(player.getClan()))
+		{
 			player.sendPacket(SystemMessageId.APPLICATION_DENIED_BECAUSE_ALREADY_SUBMITTED_A_REQUEST_FOR_ANOTHER_SIEGE_BATTLE);
+		}
 		else if ((typeId == ATTACKER) && (getAttackerClans().size() >= SiegeManager.getInstance().getAttackerMaxClans()))
+		{
 			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);
+		}
 		else
+		{
 			return true;
+		}
 		
 		return false;
 	}
@@ -1083,15 +1193,23 @@ public class Siege implements Siegable
 		for (Siege siege : SiegeManager.getInstance().getSieges())
 		{
 			if (siege == this)
+			{
 				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))
+				{
 					return true;
+				}
 				if (siege.checkIsDefender(clan))
+				{
 					return true;
+				}
 				if (siege.checkIsDefenderWaiting(clan))
+				{
 					return true;
+				}
 			}
 		}
 		return false;
@@ -1122,7 +1240,9 @@ public class Siege implements Siegable
 		}
 		
 		if (corrected)
+		{
 			saveSiegeDate();
+		}
 	}
 	
 	/** 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)
 			if (getCastle().getOwnerId() > 0)
+			{
 				addDefender(getCastle().getOwnerId(), SiegeClanType.OWNER);
+			}
 			
 			statement.setInt(1, getCastle().getCastleId());
 			try (ResultSet rs = statement.executeQuery())
@@ -1148,11 +1270,17 @@ public class Siege implements Siegable
 				{
 					typeId = rs.getInt("type");
 					if (typeId == DEFENDER)
+					{
 						addDefender(rs.getInt("clan_id"));
+					}
 					else if (typeId == ATTACKER)
+					{
 						addAttacker(rs.getInt("clan_id"));
+					}
 					else if (typeId == DEFENDER_NOT_APPROWED)
+					{
 						addDefenderWaiting(rs.getInt("clan_id"));
+					}
 				}
 			}
 		}
@@ -1165,7 +1293,7 @@ public class Siege implements Siegable
 	/** Remove all control tower spawned. */
 	private void removeControlTower()
 	{
-		if (_controlTowers != null && !_controlTowers.isEmpty())
+		if ((_controlTowers != null) && !_controlTowers.isEmpty())
 		{
 			// Remove all instances of control tower for this castle
 			for (L2ControlTowerInstance ct : _controlTowers)
@@ -1190,7 +1318,7 @@ public class Siege implements Siegable
 	/** Remove all flame towers spawned. */
 	private void removeFlameTower()
 	{
-		if (_flameTowers != null && !_flameTowers.isEmpty())
+		if ((_flameTowers != null) && !_flameTowers.isEmpty())
 		{
 			// Remove all instances of control tower for this castle
 			for (L2FlameTowerInstance ct : _flameTowers)
@@ -1218,12 +1346,16 @@ public class Siege implements Siegable
 		for (L2SiegeClan sc : getAttackerClans())
 		{
 			if (sc != null)
+			{
 				sc.removeFlags();
+			}
 		}
 		for (L2SiegeClan sc : getDefenderClans())
 		{
 			if (sc != null)
+			{
 				sc.removeFlags();
+			}
 		}
 	}
 	
@@ -1233,7 +1365,9 @@ public class Siege implements Siegable
 		for (L2SiegeClan sc : getDefenderClans())
 		{
 			if (sc != null)
+			{
 				sc.removeFlags();
+			}
 		}
 	}
 	
@@ -1259,7 +1393,6 @@ public class Siege implements Siegable
 			_scheduledStartSiegeTask = ThreadPoolManager.getInstance().scheduleGeneral(new Siege.ScheduleStartSiegeTask(getCastle()), 1000);
 		}
 		
-		
 		try (Connection con = L2DatabaseFactory.getInstance().getConnection();
 			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)
 	{
 		if (clan.getCastleId() > 0)
+		{
 			return;
+		}
 		
 		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;
+				}
 			}
 			else
 			{
 				if (getAttackerClans().size() >= SiegeManager.getInstance().getAttackerMaxClans())
+				{
 					return;
+				}
 			}
 			
 			if (!isUpdateRegistration)
@@ -1321,7 +1460,7 @@ public class Siege implements Siegable
 				}
 			}
 			
-			if (typeId == DEFENDER || typeId == OWNER)
+			if ((typeId == DEFENDER) || (typeId == OWNER))
 			{
 				addDefender(clan.getClanId());
 			}
@@ -1345,18 +1484,24 @@ public class Siege implements Siegable
 	{
 		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);
+			}
 			// 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
-			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);
+			}
 			// set the next siege day to the next weekend
 			getCastle().getSiegeDate().add(Calendar.DAY_OF_MONTH, 7);
 		}
 		
 		if (!SevenSigns.getInstance().isDateInSealValidPeriod(getCastle().getSiegeDate()))
+		{
 			getCastle().getSiegeDate().add(Calendar.DAY_OF_MONTH, 7);
+		}
 		
 		SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.S1_ANNOUNCED_SIEGE_TIME);
 		sm.addCastleId(getCastle().getCastleId());
@@ -1373,7 +1518,9 @@ public class Siege implements Siegable
 	{
 		// Set control tower array size if one does not exist
 		if (_controlTowers == null)
+		{
 			_controlTowers = new ArrayList<>();
+		}
 		
 		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
 		if (_flameTowers == null)
+		{
 			_flameTowers = new ArrayList<>();
+		}
 		
 		for (SiegeSpawn _sp : SiegeManager.getInstance().getFlameTowerSpawnList(Id))
 		{
@@ -1420,8 +1569,10 @@ public class Siege implements Siegable
 			_flameTowerMaxCount++;
 			_flameTowers.add(ct);
 		}
-		if (_flameTowerCount == 0) // TODO: temp fix until flame towers are assigned in config
+		if (_flameTowerCount == 0)
+		{
 			_flameTowerCount = 1;
+		}
 	}
 	
 	/**
@@ -1443,7 +1594,9 @@ public class Siege implements Siegable
 			for (L2Spawn spawn : getSiegeGuardManager().getSiegeGuardSpawn())
 			{
 				if (spawn == null)
+				{
 					continue;
+				}
 				
 				closestCt = null;
 				distanceClosest = Integer.MAX_VALUE;
@@ -1455,7 +1608,9 @@ public class Siege implements Siegable
 				for (L2ControlTowerInstance ct : _controlTowers)
 				{
 					if (ct == null)
+					{
 						continue;
+					}
 					
 					distance = ct.getDistanceSq(x, y, z);
 					
@@ -1466,7 +1621,9 @@ public class Siege implements Siegable
 					}
 				}
 				if (closestCt != null)
+				{
 					closestCt.registerGuard(spawn);
+				}
 			}
 		}
 	}
@@ -1475,7 +1632,9 @@ public class Siege implements Siegable
 	public final L2SiegeClan getAttackerClan(L2Clan clan)
 	{
 		if (clan == null)
+		{
 			return null;
+		}
 		return getAttackerClan(clan.getClanId());
 	}
 	
@@ -1483,8 +1642,12 @@ public class Siege implements Siegable
 	public final L2SiegeClan getAttackerClan(int clanId)
 	{
 		for (L2SiegeClan sc : getAttackerClans())
-			if (sc != null && sc.getClanId() == clanId)
+		{
+			if ((sc != null) && (sc.getClanId() == clanId))
+			{
 				return sc;
+			}
+		}
 		return null;
 	}
 	
@@ -1492,7 +1655,9 @@ public class Siege implements Siegable
 	public final List<L2SiegeClan> getAttackerClans()
 	{
 		if (_isNormalSide)
+		{
 			return _attackerClans;
+		}
 		return _defenderClans;
 	}
 	
@@ -1503,8 +1668,10 @@ public class Siege implements Siegable
 	
 	public final Castle getCastle()
 	{
-		if (_castle == null || _castle.length <= 0)
+		if ((_castle == null) || (_castle.length <= 0))
+		{
 			return null;
+		}
 		return _castle[0];
 	}
 	
@@ -1512,7 +1679,9 @@ public class Siege implements Siegable
 	public final L2SiegeClan getDefenderClan(L2Clan clan)
 	{
 		if (clan == null)
+		{
 			return null;
+		}
 		return getDefenderClan(clan.getClanId());
 	}
 	
@@ -1520,8 +1689,12 @@ public class Siege implements Siegable
 	public final L2SiegeClan getDefenderClan(int clanId)
 	{
 		for (L2SiegeClan sc : getDefenderClans())
-			if (sc != null && sc.getClanId() == clanId)
+		{
+			if ((sc != null) && (sc.getClanId() == clanId))
+			{
 				return sc;
+			}
+		}
 		return null;
 	}
 	
@@ -1529,22 +1702,30 @@ public class Siege implements Siegable
 	public final List<L2SiegeClan> getDefenderClans()
 	{
 		if (_isNormalSide)
+		{
 			return _defenderClans;
+		}
 		return _attackerClans;
 	}
 	
 	public final L2SiegeClan getDefenderWaitingClan(L2Clan clan)
 	{
 		if (clan == null)
+		{
 			return null;
+		}
 		return getDefenderWaitingClan(clan.getClanId());
 	}
 	
 	public final L2SiegeClan getDefenderWaitingClan(int clanId)
 	{
 		for (L2SiegeClan sc : getDefenderWaitingClans())
-			if (sc != null && sc.getClanId() == clanId)
+		{
+			if ((sc != null) && (sc.getClanId() == clanId))
+			{
 				return sc;
+			}
+		}
 		return null;
 	}
 	
@@ -1583,7 +1764,9 @@ public class Siege implements Siegable
 	{
 		getCastle().setIsTimeRegistrationOver(true);
 		if (!automatic)
+		{
 			saveSiegeDate();
+		}
 	}
 	
 	@Override
@@ -1593,7 +1776,9 @@ public class Siege implements Siegable
 		{
 			L2SiegeClan sc = getAttackerClan(clan);
 			if (sc != null)
+			{
 				return sc.getFlag();
+			}
 		}
 		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());
 	/** html path **/
 	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];
 	/** The state of the TvTEvent<br> */
 	private static EventState _state = EventState.INACTIVE;
@@ -108,8 +108,8 @@ public class TvTEvent
 	/**
 	 * Starts the participation of the TvTEvent<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>
 	 */
 	public static boolean startParticipation()
@@ -154,7 +154,7 @@ public class TvTEvent
 		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;
 		for (L2PcInstance player : players.values())
@@ -174,8 +174,8 @@ public class TvTEvent
 	 * 2. Close doors specified in configs<br>
 	 * 3. Abort if not enought participants(return false)<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>
 	 */
 	public static boolean startFight()
@@ -184,12 +184,12 @@ public class TvTEvent
 		setState(EventState.STARTING);
 		
 		// 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[1].getParticipatedPlayers());
 		_teams[0].cleanMe();
 		_teams[1].cleanMe();
-
+		
 		L2PcInstance player;
 		Iterator<L2PcInstance> iter;
 		if (needParticipationFee())
@@ -199,11 +199,17 @@ public class TvTEvent
 			{
 				player = iter.next();
 				if (!hasParticipationFee(player))
+				{
 					iter.remove();
+				}
 			}
 		}
 		
-		int balance[] = { 0, 0 }, priority = 0, highestLevelPlayerId;
+		int balance[] =
+		{
+			0,
+			0
+		}, priority = 0, highestLevelPlayerId;
 		L2PcInstance highestLevelPlayer;
 		// XXX: allParticipants should be sorted by level instead of using highestLevelPcInstanceOf for every fetch
 		while (!allParticipants.isEmpty())
@@ -215,10 +221,13 @@ public class TvTEvent
 			_teams[priority].addPlayer(highestLevelPlayer);
 			balance[priority] += highestLevelPlayer.getLevel();
 			// Exiting if no more players
-			if (allParticipants.isEmpty()) break;
+			if (allParticipants.isEmpty())
+			{
+				break;
+			}
 			// The other team gets one player
 			// XXX: Code not dry
-			priority = 1-priority;
+			priority = 1 - priority;
 			highestLevelPlayerId = highestLevelPcInstanceOf(allParticipants);
 			highestLevelPlayer = allParticipants.get(highestLevelPlayerId);
 			allParticipants.remove(highestLevelPlayerId);
@@ -229,7 +238,7 @@ public class TvTEvent
 		}
 		
 		// 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
 			setState(EventState.INACTIVE);
@@ -249,14 +258,18 @@ public class TvTEvent
 			{
 				player = iter.next();
 				if (!payParticipationFee(player))
+				{
 					iter.remove();
+				}
 			}
 			iter = _teams[1].getParticipatedPlayers().values().iterator();
 			while (iter.hasNext())
 			{
 				player = iter.next();
 				if (!payParticipationFee(player))
+				{
 					iter.remove();
+				}
 			}
 		}
 		
@@ -267,7 +280,7 @@ public class TvTEvent
 				_TvTEventInstance = InstanceManager.getInstance().createDynamicInstance(Config.TVT_EVENT_INSTANCE_FILE);
 				InstanceManager.getInstance().getInstance(_TvTEventInstance).setAllowSummon(false);
 				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)
 			{
@@ -307,8 +320,8 @@ public class TvTEvent
 	 * 2. Wait till teams are not at a tie anymore<br>
 	 * 3. Set state EvcentState.REWARDING<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>
 	 */
 	public static String calculateRewards()
@@ -316,7 +329,7 @@ public class TvTEvent
 		if (_teams[0].getPoints() == _teams[1].getPoints())
 		{
 			// Check if one of the teams have no more players left
-			if (_teams[0].getParticipatedPlayerCount() == 0 || _teams[1].getParticipatedPlayerCount() == 0)
+			if ((_teams[0].getParticipatedPlayerCount() == 0) || (_teams[1].getParticipatedPlayerCount() == 0))
 			{
 				// set state to rewarding
 				setState(EventState.REWARDING);
@@ -398,7 +411,7 @@ public class TvTEvent
 			NpcHtmlMessage npcHtmlMessage = new NpcHtmlMessage(0);
 			
 			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(npcHtmlMessage);
 		}
@@ -417,7 +430,7 @@ public class TvTEvent
 	{
 		// Set state INACTIVATING
 		setState(EventState.INACTIVATING);
-		//Unspawn event npc
+		// Unspawn event npc
 		unSpawnNpc();
 		// Opens all doors specified in configs for tvt
 		openDoors(Config.TVT_DOORS_IDS_TO_CLOSE);
@@ -448,8 +461,8 @@ public class TvTEvent
 	/**
 	 * Adds a player to a TvTEvent team<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>
 	 * @return boolean: true if success, otherwise false<br>
 	 */
@@ -479,8 +492,8 @@ public class TvTEvent
 	/**
 	 * Removes a TvTEvent player from it's team<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
 	 * @return boolean: true if success, otherwise false
 	 */
@@ -502,7 +515,7 @@ public class TvTEvent
 	
 	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)
@@ -520,8 +533,10 @@ public class TvTEvent
 		int itemId = Config.TVT_EVENT_PARTICIPATION_FEE[0];
 		int itemNum = Config.TVT_EVENT_PARTICIPATION_FEE[1];
 		
-		if (itemId == 0 || itemNum == 0)
+		if ((itemId == 0) || (itemNum == 0))
+		{
 			return "-";
+		}
 		
 		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>
 	 * 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>
 	 */
 	public static void sysMsgToAllParticipants(String message)
@@ -554,7 +569,7 @@ public class TvTEvent
 	
 	/**
 	 * Close doors specified in configs
-	 * @param doors 
+	 * @param doors
 	 */
 	private static void closeDoors(List<Integer> doors)
 	{
@@ -571,7 +586,7 @@ public class TvTEvent
 	
 	/**
 	 * Open doors specified in configs
-	 * @param doors 
+	 * @param 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>
 	 */
 	public static void onLogin(L2PcInstance playerInstance)
 	{
-		if (playerInstance == null || (!isStarting() && !isStarted()))
+		if ((playerInstance == null) || (!isStarting() && !isStarted()))
 		{
 			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>
 	 */
 	public static void onLogout(L2PcInstance playerInstance)
 	{
-		if (playerInstance != null && (isStarting() || isStarted() || isParticipating()))
+		if ((playerInstance != null) && (isStarting() || isStarted() || isParticipating()))
 		{
 			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>
-	 * 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 playerInstance as L2PcInstance<br>
 	 */
 	public static synchronized void onBypass(String command, L2PcInstance playerInstance)
 	{
-		if (playerInstance == null || !isParticipating())
+		if ((playerInstance == null) || !isParticipating())
+		{
 			return;
+		}
 		
 		final String htmContent;
 		
@@ -660,25 +677,31 @@ public class TvTEvent
 			
 			if (playerInstance.isCursedWeaponEquipped())
 			{
-				htmContent = HtmCache.getInstance().getHtm(playerInstance.getHtmlPrefix(), htmlPath+"CursedWeaponEquipped.htm");
+				htmContent = HtmCache.getInstance().getHtm(playerInstance.getHtmlPrefix(), htmlPath + "CursedWeaponEquipped.htm");
 				if (htmContent != null)
+				{
 					npcHtmlMessage.setHtml(htmContent);
+				}
 			}
 			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)
+				{
 					npcHtmlMessage.setHtml(htmContent);
+				}
 			}
 			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)
+				{
 					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)
 				{
 					npcHtmlMessage.setHtml(htmContent);
@@ -686,19 +709,18 @@ public class TvTEvent
 					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)
 				{
 					npcHtmlMessage.setHtml(htmContent);
 					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)
 				{
 					npcHtmlMessage.setHtml(htmContent);
@@ -707,7 +729,7 @@ public class TvTEvent
 			}
 			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)
 				{
 					npcHtmlMessage.setHtml(htmContent);
@@ -715,9 +737,13 @@ public class TvTEvent
 				}
 			}
 			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
+			{
 				return;
+			}
 			
 			playerInstance.sendPacket(npcHtmlMessage);
 		}
@@ -725,25 +751,27 @@ public class TvTEvent
 		{
 			removeParticipant(playerInstance.getObjectId());
 			if (Config.TVT_EVENT_MAX_PARTICIPANTS_PER_IP > 0)
+			{
 				AntiFeedManager.getInstance().removePlayer(AntiFeedManager.TVT_ID, playerInstance);
+			}
 			
 			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);
 		}
 	}
 	
 	/**
-	 * Called on every onAction in L2PcIstance<br><br>
-	 *
+	 * Called on every onAction in L2PcIstance<br>
+	 * <br>
 	 * @param playerInstance
 	 * @param targetedPlayerObjectId
 	 * @return boolean: true if player is allowed to target, otherwise false
 	 */
 	public static boolean onAction(L2PcInstance playerInstance, int targetedPlayerObjectId)
 	{
-		if (playerInstance == null || !isStarted())
+		if ((playerInstance == null) || !isStarted())
 		{
 			return true;
 		}
@@ -756,12 +784,12 @@ public class TvTEvent
 		byte playerTeamId = getParticipantTeamId(playerInstance.getObjectId());
 		byte targetedPlayerTeamId = getParticipantTeamId(targetedPlayerObjectId);
 		
-		if ((playerTeamId != -1 && targetedPlayerTeamId == -1) || (playerTeamId == -1 && targetedPlayerTeamId != -1))
+		if (((playerTeamId != -1) && (targetedPlayerTeamId == -1)) || ((playerTeamId == -1) && (targetedPlayerTeamId != -1)))
 		{
 			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;
 		}
@@ -770,18 +798,22 @@ public class TvTEvent
 	}
 	
 	/**
-	 * Called on every scroll use<br><br>
-	 *
+	 * Called on every scroll use<br>
+	 * <br>
 	 * @param playerObjectId
 	 * @return boolean: true if player is allowed to use scroll, otherwise false
 	 */
 	public static boolean onScrollUse(int playerObjectId)
 	{
 		if (!isStarted())
+		{
 			return true;
+		}
 		
 		if (isPlayerParticipant(playerObjectId) && !Config.TVT_EVENT_SCROLL_ALLOWED)
+		{
 			return false;
+		}
 		
 		return true;
 	}
@@ -794,10 +826,14 @@ public class TvTEvent
 	public static boolean onPotionUse(int playerObjectId)
 	{
 		if (!isStarted())
+		{
 			return true;
+		}
 		
 		if (isPlayerParticipant(playerObjectId) && !Config.TVT_EVENT_POTIONS_ALLOWED)
+		{
 			return false;
+		}
 		
 		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 killedPlayerInstance as L2PcInstance<br>
 	 */
 	public static void onKill(L2Character killerCharacter, L2PcInstance killedPlayerInstance)
 	{
-		if (killedPlayerInstance == null || !isStarted())
+		if ((killedPlayerInstance == null) || !isStarted())
 		{
 			return;
 		}
@@ -871,7 +907,7 @@ public class TvTEvent
 		
 		L2PcInstance killerPlayerInstance = null;
 		
-		if (killerCharacter instanceof L2PetInstance || killerCharacter instanceof L2ServitorInstance)
+		if ((killerCharacter instanceof L2PetInstance) || (killerCharacter instanceof L2ServitorInstance))
 		{
 			killerPlayerInstance = ((L2Summon) killerCharacter).getOwner();
 			
@@ -891,7 +927,7 @@ public class TvTEvent
 		
 		byte killerTeamId = getParticipantTeamId(killerPlayerInstance.getObjectId());
 		
-		if (killerTeamId != -1 && killedTeamId != -1 && killerTeamId != killedTeamId)
+		if ((killerTeamId != -1) && (killedTeamId != -1) && (killerTeamId != killedTeamId))
 		{
 			TvTEventTeam killerTeam = _teams[killerTeamId];
 			
@@ -906,7 +942,7 @@ public class TvTEvent
 					playerInstance.sendPacket(cs);
 				}
 			}
-			fireTvtKillListeners(killerPlayerInstance,killedPlayerInstance,killerTeam);
+			fireTvtKillListeners(killerPlayerInstance, killedPlayerInstance, killerTeam);
 		}
 	}
 	
@@ -916,45 +952,53 @@ public class TvTEvent
 	 */
 	public static void onTeleported(L2PcInstance playerInstance)
 	{
-		if (!isStarted() || playerInstance == null || !isPlayerParticipant(playerInstance.getObjectId()))
+		if (!isStarted() || (playerInstance == null) || !isPlayerParticipant(playerInstance.getObjectId()))
+		{
 			return;
+		}
 		
 		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())
 				{
 					L2Skill skill = SkillTable.getInstance().getInfo(i, Config.TVT_EVENT_MAGE_BUFFS.get(i));
 					if (skill != null)
+					{
 						skill.getEffects(playerInstance, playerInstance);
+					}
 				}
 			}
 		}
 		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())
 				{
 					L2Skill skill = SkillTable.getInstance().getInfo(i, Config.TVT_EVENT_FIGHTER_BUFFS.get(i));
 					if (skill != null)
+					{
 						skill.getEffects(playerInstance, playerInstance);
+					}
 				}
 			}
 		}
 	}
 	
 	/**
-	 * @param source 
-	 * @param target 
-	 * @param skill 
+	 * @param source
+	 * @param target
+	 * @param skill
 	 * @return true if player valid for skill
 	 */
 	public static final boolean checkForTvTSkill(L2PcInstance source, L2PcInstance target, L2Skill skill)
 	{
 		if (!isStarted())
+		{
 			return true;
+		}
 		// TvT is started
 		final int sourcePlayerId = source.getObjectId();
 		final int targetPlayerId = target.getObjectId();
@@ -963,22 +1007,28 @@ public class TvTEvent
 		
 		// both players not participating
 		if (!isSourceParticipant && !isTargetParticipant)
+		{
 			return true;
+		}
 		// one player not participating
 		if (!(isSourceParticipant && isTargetParticipant))
+		{
 			return false;
+		}
 		// players in the different teams ?
 		if (getParticipantTeamId(sourcePlayerId) != getParticipantTeamId(targetPlayerId))
 		{
 			if (!skill.isOffensive())
+			{
 				return false;
+			}
 		}
 		return true;
 	}
 	
 	/**
-	 * Sets the TvTEvent state<br><br>
-	 *
+	 * Sets the TvTEvent state<br>
+	 * <br>
 	 * @param state as EventState<br>
 	 */
 	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>
 	 */
 	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>
 	 */
 	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>
 	 */
 	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>
 	 */
 	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>
 	 */
 	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>
 	 */
 	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>
 	 */
 	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>
 	 */
 	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>
 	 */
 	public static int[] getTeamsPlayerCounts()
@@ -1191,14 +1241,13 @@ public class TvTEvent
 	
 	/**
 	 * 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>
 	 */
 	public static int[] getTeamsPoints()
 	{
 		return new int[]
 		{
-			_teams[0].getPoints(), 
+			_teams[0].getPoints(),
 			_teams[1].getPoints()
 		};
 	}
@@ -1217,7 +1266,7 @@ public class TvTEvent
 	 */
 	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();
 			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
 {
 	/** The name of the team<br> */
-	private String _name;
+	private final String _name;
 	/** The team spot coordinated<br> */
 	private int[] _coordinates = new int[3];
 	/** The points of the team<br> */
@@ -35,8 +35,8 @@ public class TvTEventTeam
 	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 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>
 	 * @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>
 	 */
 	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>
 	 */
 	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>
 	 */
 	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>
 	 */
 	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>
 	 */
 	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>
 	 * 3. Revive and full heal 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()
 	 */
 	@Override
 	public void run()
 	{
 		if (_playerInstance == null)
+		{
 			return;
+		}
 		
 		L2Summon summon = _playerInstance.getPet();
 		
 		if (summon != null)
+		{
 			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();
+		}
 		
 		if (_playerInstance.isInDuel())
+		{
 			_playerInstance.setDuelState(Duel.DUELSTATE_INTERRUPTED);
+		}
 		
 		int TvTInstance = TvTEvent.getTvTEventInstance();
 		if (TvTInstance != 0)
@@ -94,12 +101,16 @@ public class TvTEventTeleporter implements Runnable
 		
 		_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)
+		{
 			_playerInstance.setTeam(TvTEvent.getParticipantTeamId(_playerInstance.getObjectId()) + 1);
+		}
 		else
+		{
 			_playerInstance.setTeam(0);
+		}
 		
 		_playerInstance.setCurrentCp(_playerInstance.getMaxCp());
 		_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.ThreadPoolManager;
 
-
 /**
  * @author FBIagent
  */
@@ -42,7 +41,7 @@ public class TvTManager
 		{
 			TvTEvent.init();
 			
-			this.scheduleEventStart();
+			scheduleEventStart();
 			_log.info("TvTEventEngine[TvTManager.TvTManager()]: Started.");
 		}
 		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>
 	 */
 	public static TvTManager getInstance()
@@ -85,7 +84,7 @@ public class TvTManager
 					testStartTime.add(Calendar.DAY_OF_MONTH, 1);
 				}
 				// 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;
 				}
@@ -112,15 +111,14 @@ public class TvTManager
 			Announcements.getInstance().announceToAll("TvT Event: Event was cancelled.");
 			_log.warning("TvTEventEngine[TvTManager.run()]: Error spawning event npc for participation.");
 			
-			this.scheduleEventStart();
+			scheduleEventStart();
 		}
 		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
-			_task.setStartTime(System.currentTimeMillis() + 60000L * Config.TVT_EVENT_PARTICIPATION_TIME);
+			_task.setStartTime(System.currentTimeMillis() + (60000L * Config.TVT_EVENT_PARTICIPATION_TIME));
 			ThreadPoolManager.getInstance().executeTask(_task);
 		}
 	}
@@ -135,13 +133,12 @@ public class TvTManager
 			Announcements.getInstance().announceToAll("TvT Event: Event cancelled due to lack of Participation.");
 			_log.info("TvTEventEngine[TvTManager.run()]: Lack of registration, abort event.");
 			
-			this.scheduleEventStart();
+			scheduleEventStart();
 		}
 		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);
 		}
 	}
@@ -152,11 +149,10 @@ public class TvTManager
 	public void endEvent()
 	{
 		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();
 		
-		this.scheduleEventStart();
+		scheduleEventStart();
 	}
 	
 	public void skipDelay()
@@ -196,7 +192,7 @@ public class TvTManager
 			
 			if (delay > 0)
 			{
-				this.announce(delay);
+				announce(delay);
 			}
 			
 			int nextMsg = 0;
@@ -237,15 +233,15 @@ public class TvTManager
 				// start
 				if (TvTEvent.isInactive())
 				{
-					TvTManager.this.startReg();
+					startReg();
 				}
 				else if (TvTEvent.isParticipating())
 				{
-					TvTManager.this.startEvent();
+					startEvent();
 				}
 				else
 				{
-					TvTManager.this.endEvent();
+					endEvent();
 				}
 			}
 			
@@ -257,7 +253,7 @@ public class TvTManager
 		
 		private void announce(long time)
 		{
-			if (time >= 3600 && time % 3600 == 0)
+			if ((time >= 3600) && ((time % 3600) == 0))
 			{
 				if (TvTEvent.isParticipating())
 				{