Jelajahi Sumber

Full source format

Zoey76 6 tahun lalu
induk
melakukan
b4cfd6aa5d
100 mengubah file dengan 2401 tambahan dan 5138 penghapusan
  1. 16 34
      src/main/java/com/l2jserver/gameserver/FortUpdater.java
  2. 22 46
      src/main/java/com/l2jserver/gameserver/GameTimeController.java
  3. 76 160
      src/main/java/com/l2jserver/gameserver/GeoData.java
  4. 1 2
      src/main/java/com/l2jserver/gameserver/InstanceListManager.java
  5. 19 41
      src/main/java/com/l2jserver/gameserver/ItemsAutoDestroy.java
  6. 22 47
      src/main/java/com/l2jserver/gameserver/MonsterRace.java
  7. 114 251
      src/main/java/com/l2jserver/gameserver/RecipeController.java
  8. 85 185
      src/main/java/com/l2jserver/gameserver/ThreadPoolManager.java
  9. 96 200
      src/main/java/com/l2jserver/gameserver/ai/AbstractAI.java
  10. 1 2
      src/main/java/com/l2jserver/gameserver/ai/Ctrl.java
  11. 1 2
      src/main/java/com/l2jserver/gameserver/ai/CtrlEvent.java
  12. 1 2
      src/main/java/com/l2jserver/gameserver/ai/CtrlIntention.java
  13. 10 20
      src/main/java/com/l2jserver/gameserver/ai/L2AirShipAI.java
  14. 165 352
      src/main/java/com/l2jserver/gameserver/ai/L2AttackableAI.java
  15. 11 22
      src/main/java/com/l2jserver/gameserver/ai/L2BoatAI.java
  16. 138 286
      src/main/java/com/l2jserver/gameserver/ai/L2CharacterAI.java
  17. 81 167
      src/main/java/com/l2jserver/gameserver/ai/L2ControllableMobAI.java
  18. 30 60
      src/main/java/com/l2jserver/gameserver/ai/L2DoorAI.java
  19. 134 283
      src/main/java/com/l2jserver/gameserver/ai/L2FortSiegeGuardAI.java
  20. 13 26
      src/main/java/com/l2jserver/gameserver/ai/L2PlayableAI.java
  21. 53 113
      src/main/java/com/l2jserver/gameserver/ai/L2PlayerAI.java
  22. 125 261
      src/main/java/com/l2jserver/gameserver/ai/L2SiegeGuardAI.java
  23. 5 10
      src/main/java/com/l2jserver/gameserver/ai/L2SpecialSiegeGuardAI.java
  24. 49 102
      src/main/java/com/l2jserver/gameserver/ai/L2SummonAI.java
  25. 20 40
      src/main/java/com/l2jserver/gameserver/ai/L2VehicleAI.java
  26. 28 56
      src/main/java/com/l2jserver/gameserver/ai/NextAction.java
  27. 33 70
      src/main/java/com/l2jserver/gameserver/cache/HtmCache.java
  28. 10 20
      src/main/java/com/l2jserver/gameserver/cache/WarehouseCacheManager.java
  29. 5 10
      src/main/java/com/l2jserver/gameserver/communitybbs/Manager/BaseBBSManager.java
  30. 1 2
      src/main/java/com/l2jserver/gameserver/dao/FriendDAO.java
  31. 1 2
      src/main/java/com/l2jserver/gameserver/dao/HennaDAO.java
  32. 1 2
      src/main/java/com/l2jserver/gameserver/dao/ItemDAO.java
  33. 1 2
      src/main/java/com/l2jserver/gameserver/dao/ItemReuseDAO.java
  34. 1 2
      src/main/java/com/l2jserver/gameserver/dao/PetDAO.java
  35. 1 2
      src/main/java/com/l2jserver/gameserver/dao/PetSkillSaveDAO.java
  36. 1 2
      src/main/java/com/l2jserver/gameserver/dao/PlayerDAO.java
  37. 1 2
      src/main/java/com/l2jserver/gameserver/dao/PlayerSkillSaveDAO.java
  38. 1 2
      src/main/java/com/l2jserver/gameserver/dao/PremiumItemDAO.java
  39. 1 2
      src/main/java/com/l2jserver/gameserver/dao/RecipeBookDAO.java
  40. 1 2
      src/main/java/com/l2jserver/gameserver/dao/RecipeShopListDAO.java
  41. 1 2
      src/main/java/com/l2jserver/gameserver/dao/RecommendationBonusDAO.java
  42. 1 2
      src/main/java/com/l2jserver/gameserver/dao/ServitorSkillSaveDAO.java
  43. 1 2
      src/main/java/com/l2jserver/gameserver/dao/ShortcutDAO.java
  44. 1 2
      src/main/java/com/l2jserver/gameserver/dao/SkillDAO.java
  45. 1 2
      src/main/java/com/l2jserver/gameserver/dao/SubclassDAO.java
  46. 1 2
      src/main/java/com/l2jserver/gameserver/dao/TeleportBookmarkDAO.java
  47. 8 16
      src/main/java/com/l2jserver/gameserver/dao/factory/impl/DAOFactory.java
  48. 11 24
      src/main/java/com/l2jserver/gameserver/data/json/ExperienceData.java
  49. 29 58
      src/main/java/com/l2jserver/gameserver/data/sql/impl/SummonEffectsTable.java
  50. 29 58
      src/main/java/com/l2jserver/gameserver/data/xml/impl/ArmorSetsData.java
  51. 16 32
      src/main/java/com/l2jserver/gameserver/data/xml/impl/CategoryData.java
  52. 13 26
      src/main/java/com/l2jserver/gameserver/data/xml/impl/ClassListData.java
  53. 31 62
      src/main/java/com/l2jserver/gameserver/data/xml/impl/EnchantSkillGroupsData.java
  54. 24 48
      src/main/java/com/l2jserver/gameserver/data/xml/impl/FishData.java
  55. 16 32
      src/main/java/com/l2jserver/gameserver/data/xml/impl/FishingMonstersData.java
  56. 160 352
      src/main/java/com/l2jserver/gameserver/datatables/AugmentationData.java
  57. 13 26
      src/main/java/com/l2jserver/gameserver/datatables/EventDroplist.java
  58. 40 81
      src/main/java/com/l2jserver/gameserver/datatables/MerchantPriceConfigTable.java
  59. 15 31
      src/main/java/com/l2jserver/gameserver/datatables/NpcPersonalAIData.java
  60. 21 42
      src/main/java/com/l2jserver/gameserver/datatables/SkillData.java
  61. 167 343
      src/main/java/com/l2jserver/gameserver/engines/DocumentBase.java
  62. 18 36
      src/main/java/com/l2jserver/gameserver/engines/DocumentEngine.java
  63. 28 62
      src/main/java/com/l2jserver/gameserver/engines/items/DocumentItem.java
  64. 1 2
      src/main/java/com/l2jserver/gameserver/engines/items/Item.java
  65. 304 747
      src/main/java/com/l2jserver/gameserver/engines/skills/DocumentSkill.java
  66. 1 2
      src/main/java/com/l2jserver/gameserver/enums/AISkillScope.java
  67. 1 2
      src/main/java/com/l2jserver/gameserver/enums/AIType.java
  68. 1 2
      src/main/java/com/l2jserver/gameserver/enums/AuctionItemType.java
  69. 4 8
      src/main/java/com/l2jserver/gameserver/enums/CategoryType.java
  70. 1 2
      src/main/java/com/l2jserver/gameserver/enums/DispelCategory.java
  71. 1 2
      src/main/java/com/l2jserver/gameserver/enums/DuelResult.java
  72. 1 2
      src/main/java/com/l2jserver/gameserver/enums/DuelState.java
  73. 1 2
      src/main/java/com/l2jserver/gameserver/enums/EffectCalculationType.java
  74. 1 2
      src/main/java/com/l2jserver/gameserver/enums/EventState.java
  75. 1 2
      src/main/java/com/l2jserver/gameserver/enums/FortTeleportWhoType.java
  76. 1 2
      src/main/java/com/l2jserver/gameserver/enums/HtmlActionScope.java
  77. 4 8
      src/main/java/com/l2jserver/gameserver/enums/IllegalActionPunishmentType.java
  78. 1 2
      src/main/java/com/l2jserver/gameserver/enums/InstanceReenterType.java
  79. 1 2
      src/main/java/com/l2jserver/gameserver/enums/InstanceRemoveBuffType.java
  80. 12 26
      src/main/java/com/l2jserver/gameserver/enums/InstanceType.java
  81. 1 2
      src/main/java/com/l2jserver/gameserver/enums/ItemLocation.java
  82. 1 2
      src/main/java/com/l2jserver/gameserver/enums/MacroType.java
  83. 1 2
      src/main/java/com/l2jserver/gameserver/enums/ManorMode.java
  84. 5 12
      src/main/java/com/l2jserver/gameserver/enums/MountType.java
  85. 7 14
      src/main/java/com/l2jserver/gameserver/enums/PartyDistributionType.java
  86. 1 2
      src/main/java/com/l2jserver/gameserver/enums/PetitionState.java
  87. 1 2
      src/main/java/com/l2jserver/gameserver/enums/PetitionType.java
  88. 3 6
      src/main/java/com/l2jserver/gameserver/enums/PlayerAction.java
  89. 6 12
      src/main/java/com/l2jserver/gameserver/enums/PrivateStoreType.java
  90. 1 2
      src/main/java/com/l2jserver/gameserver/enums/QuestType.java
  91. 1 2
      src/main/java/com/l2jserver/gameserver/enums/Race.java
  92. 1 2
      src/main/java/com/l2jserver/gameserver/enums/Sex.java
  93. 1 2
      src/main/java/com/l2jserver/gameserver/enums/ShortcutType.java
  94. 3 6
      src/main/java/com/l2jserver/gameserver/enums/ShotType.java
  95. 1 2
      src/main/java/com/l2jserver/gameserver/enums/SiegeTeleportWhoType.java
  96. 1 2
      src/main/java/com/l2jserver/gameserver/enums/StartPosType.java
  97. 4 8
      src/main/java/com/l2jserver/gameserver/enums/StatFunction.java
  98. 1 2
      src/main/java/com/l2jserver/gameserver/enums/StatType.java
  99. 3 6
      src/main/java/com/l2jserver/gameserver/enums/Team.java
  100. 1 2
      src/main/java/com/l2jserver/gameserver/enums/TrapAction.java

+ 16 - 34
src/main/java/com/l2jserver/gameserver/FortUpdater.java

@@ -31,22 +31,19 @@ import com.l2jserver.gameserver.model.itemcontainer.Inventory;
  * @author Vice
  * @since 2008
  */
-public class FortUpdater implements Runnable
-{
+public class FortUpdater implements Runnable {
 	private static final Logger LOG = LoggerFactory.getLogger(FortUpdater.class);
 	private final L2Clan _clan;
 	private final Fort _fort;
 	private int _runCount;
 	private final UpdaterType _updaterType;
 	
-	public enum UpdaterType
-	{
+	public enum UpdaterType {
 		MAX_OWN_TIME, // gives fort back to NPC clan
 		PERIODIC_UPDATE // raise blood oath/supply level
 	}
 	
-	public FortUpdater(Fort fort, L2Clan clan, int runCount, UpdaterType ut)
-	{
+	public FortUpdater(Fort fort, L2Clan clan, int runCount, UpdaterType ut) {
 		_fort = fort;
 		_clan = clan;
 		_runCount = runCount;
@@ -54,61 +51,46 @@ public class FortUpdater implements Runnable
 	}
 	
 	@Override
-	public void run()
-	{
-		try
-		{
-			switch (_updaterType)
-			{
-				case PERIODIC_UPDATE:
-				{
+	public void run() {
+		try {
+			switch (_updaterType) {
+				case PERIODIC_UPDATE: {
 					_runCount++;
-					if ((_fort.getOwnerClan() == null) || (_fort.getOwnerClan() != _clan))
-					{
+					if ((_fort.getOwnerClan() == null) || (_fort.getOwnerClan() != _clan)) {
 						return;
 					}
 					
 					_fort.getOwnerClan().increaseBloodOathCount();
 					
-					if (_fort.getFortState() == 2)
-					{
-						if (_clan.getWarehouse().getAdena() >= Config.FS_FEE_FOR_CASTLE)
-						{
+					if (_fort.getFortState() == 2) {
+						if (_clan.getWarehouse().getAdena() >= Config.FS_FEE_FOR_CASTLE) {
 							_clan.getWarehouse().destroyItemByItemId("FS_fee_for_Castle", Inventory.ADENA_ID, Config.FS_FEE_FOR_CASTLE, null, null);
 							_fort.getContractedCastle().addToTreasuryNoTax(Config.FS_FEE_FOR_CASTLE);
 							_fort.raiseSupplyLvL();
-						}
-						else
-						{
+						} else {
 							_fort.setFortState(1, 0);
 						}
 					}
 					_fort.saveFortVariables();
 					break;
 				}
-				case MAX_OWN_TIME:
-				{
-					if ((_fort.getOwnerClan() == null) || (_fort.getOwnerClan() != _clan))
-					{
+				case MAX_OWN_TIME: {
+					if ((_fort.getOwnerClan() == null) || (_fort.getOwnerClan() != _clan)) {
 						return;
 					}
-					if (_fort.getOwnedTime() > (Config.FS_MAX_OWN_TIME * 3600))
-					{
+					if (_fort.getOwnedTime() > (Config.FS_MAX_OWN_TIME * 3600)) {
 						_fort.removeOwner(true);
 						_fort.setFortState(0, 0);
 					}
 					break;
 				}
 			}
-		}
-		catch (Exception e)
-		{
+		} catch (Exception e) {
 			LOG.error("There has been a problem updating forts!", e);
 		}
 	}
 	
-	public int getRunCount()
-	{
+	public int getRunCount() {
 		return _runCount;
 	}
 }

+ 22 - 46
src/main/java/com/l2jserver/gameserver/GameTimeController.java

@@ -32,8 +32,7 @@ import com.l2jserver.gameserver.model.actor.L2Character;
  * Game Time controller class.
  * @author Forsaiken
  */
-public final class GameTimeController extends Thread
-{
+public final class GameTimeController extends Thread {
 	private static final Logger LOG = LoggerFactory.getLogger(GameTimeController.class);
 	
 	public static final int TICKS_PER_SECOND = 10; // not able to change this without checking through code
@@ -50,8 +49,7 @@ public final class GameTimeController extends Thread
 	private final Set<L2Character> _movingObjects = ConcurrentHashMap.newKeySet();
 	private final long _referenceTime;
 	
-	private GameTimeController()
-	{
+	private GameTimeController() {
 		super("GameTimeController");
 		super.setDaemon(true);
 		super.setPriority(MAX_PRIORITY);
@@ -66,28 +64,23 @@ public final class GameTimeController extends Thread
 		super.start();
 	}
 	
-	public static final void init()
-	{
+	public static final void init() {
 		_instance = new GameTimeController();
 	}
 	
-	public final int getGameTime()
-	{
+	public final int getGameTime() {
 		return (getGameTicks() % TICKS_PER_IG_DAY) / MILLIS_IN_TICK;
 	}
 	
-	public final int getGameHour()
-	{
+	public final int getGameHour() {
 		return getGameTime() / 60;
 	}
 	
-	public final int getGameMinute()
-	{
+	public final int getGameMinute() {
 		return getGameTime() % 60;
 	}
 	
-	public final boolean isNight()
-	{
+	public final boolean isNight() {
 		return getGameHour() < 6;
 	}
 	
@@ -95,8 +88,7 @@ public final class GameTimeController extends Thread
 	 * The true GameTime tick. Directly taken from current time. This represents the tick of the time.
 	 * @return
 	 */
-	public final int getGameTicks()
-	{
+	public final int getGameTicks() {
 		return (int) ((System.currentTimeMillis() - _referenceTime) / MILLIS_IN_TICK);
 	}
 	
@@ -104,10 +96,8 @@ public final class GameTimeController extends Thread
 	 * Add a L2Character to movingObjects of GameTimeController.
 	 * @param cha The L2Character to add to movingObjects of GameTimeController
 	 */
-	public final void registerMovingObject(final L2Character cha)
-	{
-		if (cha == null)
-		{
+	public final void registerMovingObject(final L2Character cha) {
+		if (cha == null) {
 			return;
 		}
 		
@@ -125,58 +115,45 @@ public final class GameTimeController extends Thread
 	 * <li>Create a task to update the _knownObject and _knowPlayers of each L2Character that finished its movement and of their already known L2Object then notify AI with EVT_ARRIVED</li>
 	 * </ul>
 	 */
-	private final void moveObjects()
-	{
+	private final void moveObjects() {
 		_movingObjects.removeIf(L2Character::updatePosition);
 	}
 	
-	public final void stopTimer()
-	{
+	public final void stopTimer() {
 		super.interrupt();
 		LOG.info("Stopping {}", getClass().getSimpleName());
 	}
 	
 	@Override
-	public final void run()
-	{
+	public final void run() {
 		LOG.debug("{}: Started.", getClass().getSimpleName());
 		
 		long nextTickTime, sleepTime;
 		boolean isNight = isNight();
 		
-		if (isNight)
-		{
+		if (isNight) {
 			ThreadPoolManager.getInstance().executeAi(() -> DayNightSpawnManager.getInstance().notifyChangeMode());
 		}
 		
-		while (true)
-		{
+		while (true) {
 			nextTickTime = ((System.currentTimeMillis() / MILLIS_IN_TICK) * MILLIS_IN_TICK) + 100;
 			
-			try
-			{
+			try {
 				moveObjects();
-			}
-			catch (final Throwable e)
-			{
+			} catch (final Throwable e) {
 				LOG.warn("Unable to move objects!", e);
 			}
 			
 			sleepTime = nextTickTime - System.currentTimeMillis();
-			if (sleepTime > 0)
-			{
-				try
-				{
+			if (sleepTime > 0) {
+				try {
 					Thread.sleep(sleepTime);
-				}
-				catch (final InterruptedException e)
-				{
+				} catch (final InterruptedException e) {
 					
 				}
 			}
 			
-			if (isNight() != isNight)
-			{
+			if (isNight() != isNight) {
 				isNight = !isNight;
 				
 				ThreadPoolManager.getInstance().executeAi(() -> DayNightSpawnManager.getInstance().notifyChangeMode());
@@ -184,8 +161,7 @@ public final class GameTimeController extends Thread
 		}
 	}
 	
-	public static final GameTimeController getInstance()
-	{
+	public static final GameTimeController getInstance() {
 		return _instance;
 	}
 }

+ 76 - 160
src/main/java/com/l2jserver/gameserver/GeoData.java

@@ -40,8 +40,7 @@ import com.l2jserver.geodriver.GeoDriver;
  * Geodata.
  * @author -Nemesiss-, HorridoJoho
  */
-public class GeoData
-{
+public class GeoData {
 	private static final Logger LOG = LoggerFactory.getLogger(GeoData.class);
 	private static final String FILE_NAME_FORMAT = "%d_%d.l2j";
 	private static final int ELEVATED_SEE_OVER_DISTANCE = 2;
@@ -50,44 +49,31 @@ public class GeoData
 	
 	private final GeoDriver _driver = new GeoDriver();
 	
-	protected GeoData()
-	{
+	protected GeoData() {
 		int loadedRegions = 0;
-		try
-		{
-			for (int regionX = L2World.TILE_X_MIN; regionX <= L2World.TILE_X_MAX; regionX++)
-			{
-				for (int regionY = L2World.TILE_Y_MIN; regionY <= L2World.TILE_Y_MAX; regionY++)
-				{
+		try {
+			for (int regionX = L2World.TILE_X_MIN; regionX <= L2World.TILE_X_MAX; regionX++) {
+				for (int regionY = L2World.TILE_Y_MIN; regionY <= L2World.TILE_Y_MAX; regionY++) {
 					final Path geoFilePath = Config.GEODATA_PATH.resolve(String.format(FILE_NAME_FORMAT, regionX, regionY));
 					final Boolean loadFile = Config.GEODATA_REGIONS.get(regionX + "_" + regionY);
-					if (loadFile != null)
-					{
-						if (loadFile)
-						{
+					if (loadFile != null) {
+						if (loadFile) {
 							LOG.info("{}: Loading {}...", getClass().getSimpleName(), geoFilePath.getFileName());
 							_driver.loadRegion(geoFilePath, regionX, regionY);
 							loadedRegions++;
 						}
-					}
-					else if (Config.TRY_LOAD_UNSPECIFIED_REGIONS && Files.exists(geoFilePath))
-					{
-						try
-						{
+					} else if (Config.TRY_LOAD_UNSPECIFIED_REGIONS && Files.exists(geoFilePath)) {
+						try {
 							LOG.info("{}: Loading {}...", getClass().getSimpleName(), geoFilePath.getFileName());
 							_driver.loadRegion(geoFilePath, regionX, regionY);
 							loadedRegions++;
-						}
-						catch (Exception e)
-						{
+						} catch (Exception e) {
 							LOG.warn("{}: Failed to load {}!", getClass().getSimpleName(), geoFilePath.getFileName(), e);
 						}
 					}
 				}
 			}
-		}
-		catch (Exception e)
-		{
+		} catch (Exception e) {
 			LOG.error("{}: Failed to load geodata!", e);
 			System.exit(1);
 		}
@@ -95,39 +81,32 @@ public class GeoData
 		LOG.info("{}: Loaded {} regions.", getClass().getSimpleName(), loadedRegions);
 	}
 	
-	public boolean hasGeoPos(int geoX, int geoY)
-	{
+	public boolean hasGeoPos(int geoX, int geoY) {
 		return _driver.hasGeoPos(geoX, geoY);
 	}
 	
-	public boolean checkNearestNswe(int geoX, int geoY, int worldZ, int nswe)
-	{
+	public boolean checkNearestNswe(int geoX, int geoY, int worldZ, int nswe) {
 		return _driver.checkNearestNswe(geoX, geoY, worldZ, nswe);
 	}
 	
-	public boolean checkNearestNsweAntiCornerCut(int geoX, int geoY, int worldZ, int nswe)
-	{
+	public boolean checkNearestNsweAntiCornerCut(int geoX, int geoY, int worldZ, int nswe) {
 		boolean can = true;
-		if ((nswe & Cell.NSWE_NORTH_EAST) == Cell.NSWE_NORTH_EAST)
-		{
+		if ((nswe & Cell.NSWE_NORTH_EAST) == Cell.NSWE_NORTH_EAST) {
 			// can = canEnterNeighbors(prevX, prevY - 1, prevGeoZ, Direction.EAST) && canEnterNeighbors(prevX + 1, prevY, prevGeoZ, Direction.NORTH);
 			can = checkNearestNswe(geoX, geoY - 1, worldZ, Cell.NSWE_EAST) && checkNearestNswe(geoX + 1, geoY, worldZ, Cell.NSWE_NORTH);
 		}
 		
-		if (can && ((nswe & Cell.NSWE_NORTH_WEST) == Cell.NSWE_NORTH_WEST))
-		{
+		if (can && ((nswe & Cell.NSWE_NORTH_WEST) == Cell.NSWE_NORTH_WEST)) {
 			// can = canEnterNeighbors(prevX, prevY - 1, prevGeoZ, Direction.WEST) && canEnterNeighbors(prevX - 1, prevY, prevGeoZ, Direction.NORTH);
 			can = checkNearestNswe(geoX, geoY - 1, worldZ, Cell.NSWE_WEST) && checkNearestNswe(geoX, geoY - 1, worldZ, Cell.NSWE_NORTH);
 		}
 		
-		if (can && ((nswe & Cell.NSWE_SOUTH_EAST) == Cell.NSWE_SOUTH_EAST))
-		{
+		if (can && ((nswe & Cell.NSWE_SOUTH_EAST) == Cell.NSWE_SOUTH_EAST)) {
 			// can = canEnterNeighbors(prevX, prevY + 1, prevGeoZ, Direction.EAST) && canEnterNeighbors(prevX + 1, prevY, prevGeoZ, Direction.SOUTH);
 			can = checkNearestNswe(geoX, geoY + 1, worldZ, Cell.NSWE_EAST) && checkNearestNswe(geoX + 1, geoY, worldZ, Cell.NSWE_SOUTH);
 		}
 		
-		if (can && ((nswe & Cell.NSWE_SOUTH_WEST) == Cell.NSWE_SOUTH_WEST))
-		{
+		if (can && ((nswe & Cell.NSWE_SOUTH_WEST) == Cell.NSWE_SOUTH_WEST)) {
 			// can = canEnterNeighbors(prevX, prevY + 1, prevGeoZ, Direction.WEST) && canEnterNeighbors(prevX - 1, prevY, prevGeoZ, Direction.SOUTH);
 			can = checkNearestNswe(geoX, geoY + 1, worldZ, Cell.NSWE_WEST) && checkNearestNswe(geoX - 1, geoY, worldZ, Cell.NSWE_SOUTH);
 		}
@@ -135,38 +114,31 @@ public class GeoData
 		return can && checkNearestNswe(geoX, geoY, worldZ, nswe);
 	}
 	
-	public int getNearestZ(int geoX, int geoY, int worldZ)
-	{
+	public int getNearestZ(int geoX, int geoY, int worldZ) {
 		return _driver.getNearestZ(geoX, geoY, worldZ);
 	}
 	
-	public int getNextLowerZ(int geoX, int geoY, int worldZ)
-	{
+	public int getNextLowerZ(int geoX, int geoY, int worldZ) {
 		return _driver.getNextLowerZ(geoX, geoY, worldZ);
 	}
 	
-	public int getNextHigherZ(int geoX, int geoY, int worldZ)
-	{
+	public int getNextHigherZ(int geoX, int geoY, int worldZ) {
 		return _driver.getNextHigherZ(geoX, geoY, worldZ);
 	}
 	
-	public int getGeoX(int worldX)
-	{
+	public int getGeoX(int worldX) {
 		return _driver.getGeoX(worldX);
 	}
 	
-	public int getGeoY(int worldY)
-	{
+	public int getGeoY(int worldY) {
 		return _driver.getGeoY(worldY);
 	}
 	
-	public int getWorldX(int geoX)
-	{
+	public int getWorldX(int geoX) {
 		return _driver.getWorldX(geoX);
 	}
 	
-	public int getWorldY(int geoY)
-	{
+	public int getWorldY(int geoY) {
 		return _driver.getWorldY(geoY);
 	}
 	
@@ -179,8 +151,7 @@ public class GeoData
 	 * @param z the z coordinate
 	 * @return the height
 	 */
-	public int getHeight(int x, int y, int z)
-	{
+	public int getHeight(int x, int y, int z) {
 		return getNearestZ(getGeoX(x), getGeoY(y), z);
 	}
 	
@@ -191,13 +162,11 @@ public class GeoData
 	 * @param z the the z coordinate
 	 * @return the spawn height
 	 */
-	public int getSpawnHeight(int x, int y, int z)
-	{
+	public int getSpawnHeight(int x, int y, int z) {
 		final int geoX = getGeoX(x);
 		final int geoY = getGeoY(y);
 		
-		if (!hasGeoPos(geoX, geoY))
-		{
+		if (!hasGeoPos(geoX, geoY)) {
 			return z;
 		}
 		
@@ -210,8 +179,7 @@ public class GeoData
 	 * @param location the location
 	 * @return the spawn height
 	 */
-	public int getSpawnHeight(Location location)
-	{
+	public int getSpawnHeight(Location location) {
 		return getSpawnHeight(location.getX(), location.getY(), location.getZ());
 	}
 	
@@ -221,14 +189,11 @@ public class GeoData
 	 * @param target the target
 	 * @return {@code true} if the character can see the target (LOS), {@code false} otherwise
 	 */
-	public boolean canSeeTarget(L2Object cha, L2Object target)
-	{
-		if (target == null)
-		{
+	public boolean canSeeTarget(L2Object cha, L2Object target) {
+		if (target == null) {
 			return false;
 		}
-		if (target.isDoor())
-		{
+		if (target.isDoor()) {
 			return true;
 		}
 		return canSeeTarget(cha.getX(), cha.getY(), cha.getZ(), cha.getInstanceId(), target.getX(), target.getY(), target.getZ(), target.getInstanceId());
@@ -240,8 +205,7 @@ public class GeoData
 	 * @param worldPosition the world position
 	 * @return {@code true} if the character can see the target at the given world position, {@code false} otherwise
 	 */
-	public boolean canSeeTarget(L2Object cha, ILocational worldPosition)
-	{
+	public boolean canSeeTarget(L2Object cha, ILocational worldPosition) {
 		return canSeeTarget(cha.getX(), cha.getY(), cha.getZ(), cha.getInstanceId(), worldPosition.getX(), worldPosition.getY(), worldPosition.getZ());
 	}
 	
@@ -257,10 +221,8 @@ public class GeoData
 	 * @param tInstanceId the target's instanceId
 	 * @return
 	 */
-	public boolean canSeeTarget(int x, int y, int z, int instanceId, int tx, int ty, int tz, int tInstanceId)
-	{
-		if ((instanceId != tInstanceId))
-		{
+	public boolean canSeeTarget(int x, int y, int z, int instanceId, int tx, int ty, int tz, int tInstanceId) {
+		if ((instanceId != tInstanceId)) {
 			return false;
 		}
 		return canSeeTarget(x, y, z, instanceId, tx, ty, tz);
@@ -277,24 +239,19 @@ public class GeoData
 	 * @param tz the target's z coordinate
 	 * @return {@code true} if there is line of sight between the given coordinate sets, {@code false} otherwise
 	 */
-	public boolean canSeeTarget(int x, int y, int z, int instanceId, int tx, int ty, int tz)
-	{
-		if (DoorData.getInstance().checkIfDoorsBetween(x, y, z, tx, ty, tz, instanceId, true))
-		{
+	public boolean canSeeTarget(int x, int y, int z, int instanceId, int tx, int ty, int tz) {
+		if (DoorData.getInstance().checkIfDoorsBetween(x, y, z, tx, ty, tz, instanceId, true)) {
 			return false;
 		}
 		return canSeeTarget(x, y, z, tx, ty, tz);
 	}
 	
-	private int getLosGeoZ(int prevX, int prevY, int prevGeoZ, int curX, int curY, int nswe)
-	{
-		if ((((nswe & Cell.NSWE_NORTH) != 0) && ((nswe & Cell.NSWE_SOUTH) != 0)) || (((nswe & Cell.NSWE_WEST) != 0) && ((nswe & Cell.NSWE_EAST) != 0)))
-		{
+	private int getLosGeoZ(int prevX, int prevY, int prevGeoZ, int curX, int curY, int nswe) {
+		if ((((nswe & Cell.NSWE_NORTH) != 0) && ((nswe & Cell.NSWE_SOUTH) != 0)) || (((nswe & Cell.NSWE_WEST) != 0) && ((nswe & Cell.NSWE_EAST) != 0))) {
 			throw new RuntimeException("Multiple directions!");
 		}
 		
-		if (checkNearestNsweAntiCornerCut(prevX, prevY, prevGeoZ, nswe))
-		{
+		if (checkNearestNsweAntiCornerCut(prevX, prevY, prevGeoZ, nswe)) {
 			return getNearestZ(curX, curY, prevGeoZ);
 		}
 		return getNextHigherZ(curX, curY, prevGeoZ);
@@ -310,8 +267,7 @@ public class GeoData
 	 * @param tz the target's z coordinate
 	 * @return {@code true} if there is line of sight between the given coordinate sets, {@code false} otherwise
 	 */
-	public boolean canSeeTarget(int x, int y, int z, int tx, int ty, int tz)
-	{
+	public boolean canSeeTarget(int x, int y, int z, int tx, int ty, int tz) {
 		int geoX = getGeoX(x);
 		int geoY = getGeoY(y);
 		int tGeoX = getGeoX(tx);
@@ -321,18 +277,15 @@ public class GeoData
 		tz = getNearestZ(tGeoX, tGeoY, tz);
 		
 		// fastpath
-		if ((geoX == tGeoX) && (geoY == tGeoY))
-		{
-			if (hasGeoPos(tGeoX, tGeoY))
-			{
+		if ((geoX == tGeoX) && (geoY == tGeoY)) {
+			if (hasGeoPos(tGeoX, tGeoY)) {
 				return z == tz;
 			}
 			
 			return true;
 		}
 		
-		if (tz > z)
-		{
+		if (tz > z) {
 			int tmp = tx;
 			tx = x;
 			x = tmp;
@@ -362,13 +315,11 @@ public class GeoData
 		int prevZ = pointIter.z();
 		int prevGeoZ = prevZ;
 		int ptIndex = 0;
-		while (pointIter.next())
-		{
+		while (pointIter.next()) {
 			int curX = pointIter.x();
 			int curY = pointIter.y();
 			
-			if ((curX == prevX) && (curY == prevY))
-			{
+			if ((curX == prevX) && (curY == prevY)) {
 				continue;
 			}
 			
@@ -376,55 +327,40 @@ public class GeoData
 			int curGeoZ = prevGeoZ;
 			
 			// check if the position has geodata
-			if (hasGeoPos(curX, curY))
-			{
+			if (hasGeoPos(curX, curY)) {
 				int nswe = GeoUtils.computeNswe(prevX, prevY, curX, curY);
 				curGeoZ = getLosGeoZ(prevX, prevY, prevGeoZ, curX, curY, nswe);
 				int maxHeight;
-				if (ptIndex < ELEVATED_SEE_OVER_DISTANCE)
-				{
+				if (ptIndex < ELEVATED_SEE_OVER_DISTANCE) {
 					maxHeight = z + MAX_SEE_OVER_HEIGHT;
-				}
-				else
-				{
+				} else {
 					maxHeight = beeCurZ + MAX_SEE_OVER_HEIGHT;
 				}
 				
 				boolean canSeeThrough = false;
-				if (curGeoZ <= maxHeight)
-				{
-					if ((nswe & Cell.NSWE_NORTH_EAST) == Cell.NSWE_NORTH_EAST)
-					{
+				if (curGeoZ <= maxHeight) {
+					if ((nswe & Cell.NSWE_NORTH_EAST) == Cell.NSWE_NORTH_EAST) {
 						int northGeoZ = getLosGeoZ(prevX, prevY, prevGeoZ, prevX, prevY - 1, Cell.NSWE_EAST);
 						int eastGeoZ = getLosGeoZ(prevX, prevY, prevGeoZ, prevX + 1, prevY, Cell.NSWE_NORTH);
 						canSeeThrough = (northGeoZ <= maxHeight) && (eastGeoZ <= maxHeight) && (northGeoZ <= getNearestZ(prevX, prevY - 1, beeCurZ)) && (eastGeoZ <= getNearestZ(prevX + 1, prevY, beeCurZ));
-					}
-					else if ((nswe & Cell.NSWE_NORTH_WEST) == Cell.NSWE_NORTH_WEST)
-					{
+					} else if ((nswe & Cell.NSWE_NORTH_WEST) == Cell.NSWE_NORTH_WEST) {
 						int northGeoZ = getLosGeoZ(prevX, prevY, prevGeoZ, prevX, prevY - 1, Cell.NSWE_WEST);
 						int westGeoZ = getLosGeoZ(prevX, prevY, prevGeoZ, prevX - 1, prevY, Cell.NSWE_NORTH);
 						canSeeThrough = (northGeoZ <= maxHeight) && (westGeoZ <= maxHeight) && (northGeoZ <= getNearestZ(prevX, prevY - 1, beeCurZ)) && (westGeoZ <= getNearestZ(prevX - 1, prevY, beeCurZ));
-					}
-					else if ((nswe & Cell.NSWE_SOUTH_EAST) == Cell.NSWE_SOUTH_EAST)
-					{
+					} else if ((nswe & Cell.NSWE_SOUTH_EAST) == Cell.NSWE_SOUTH_EAST) {
 						int southGeoZ = getLosGeoZ(prevX, prevY, prevGeoZ, prevX, prevY + 1, Cell.NSWE_EAST);
 						int eastGeoZ = getLosGeoZ(prevX, prevY, prevGeoZ, prevX + 1, prevY, Cell.NSWE_SOUTH);
 						canSeeThrough = (southGeoZ <= maxHeight) && (eastGeoZ <= maxHeight) && (southGeoZ <= getNearestZ(prevX, prevY + 1, beeCurZ)) && (eastGeoZ <= getNearestZ(prevX + 1, prevY, beeCurZ));
-					}
-					else if ((nswe & Cell.NSWE_SOUTH_WEST) == Cell.NSWE_SOUTH_WEST)
-					{
+					} else if ((nswe & Cell.NSWE_SOUTH_WEST) == Cell.NSWE_SOUTH_WEST) {
 						int southGeoZ = getLosGeoZ(prevX, prevY, prevGeoZ, prevX, prevY + 1, Cell.NSWE_WEST);
 						int westGeoZ = getLosGeoZ(prevX, prevY, prevGeoZ, prevX - 1, prevY, Cell.NSWE_SOUTH);
 						canSeeThrough = (southGeoZ <= maxHeight) && (westGeoZ <= maxHeight) && (southGeoZ <= getNearestZ(prevX, prevY + 1, beeCurZ)) && (westGeoZ <= getNearestZ(prevX - 1, prevY, beeCurZ));
-					}
-					else
-					{
+					} else {
 						canSeeThrough = true;
 					}
 				}
 				
-				if (!canSeeThrough)
-				{
+				if (!canSeeThrough) {
 					return false;
 				}
 			}
@@ -444,8 +380,7 @@ public class GeoData
 	 * @param destination the destination
 	 * @return the destination if there is a path or the closes location
 	 */
-	public Location moveCheck(ILocational origin, ILocational destination)
-	{
+	public Location moveCheck(ILocational origin, ILocational destination) {
 		return moveCheck(origin.getX(), origin.getY(), origin.getZ(), destination.getX(), destination.getY(), destination.getZ(), origin.getInstanceId());
 	}
 	
@@ -460,8 +395,7 @@ public class GeoData
 	 * @param instanceId the instance id
 	 * @return the last Location (x,y,z) where player can walk - just before wall
 	 */
-	public Location moveCheck(int x, int y, int z, int tx, int ty, int tz, int instanceId)
-	{
+	public Location moveCheck(int x, int y, int z, int tx, int ty, int tz, int instanceId) {
 		int geoX = getGeoX(x);
 		int geoY = getGeoY(y);
 		z = getNearestZ(geoX, geoY, z);
@@ -469,8 +403,7 @@ public class GeoData
 		int tGeoY = getGeoY(ty);
 		tz = getNearestZ(tGeoX, tGeoY, tz);
 		
-		if (DoorData.getInstance().checkIfDoorsBetween(x, y, z, tx, ty, tz, instanceId, false))
-		{
+		if (DoorData.getInstance().checkIfDoorsBetween(x, y, z, tx, ty, tz, instanceId, false)) {
 			return new Location(x, y, getHeight(x, y, z));
 		}
 		
@@ -481,17 +414,14 @@ public class GeoData
 		int prevY = pointIter.y();
 		int prevZ = z;
 		
-		while (pointIter.next())
-		{
+		while (pointIter.next()) {
 			int curX = pointIter.x();
 			int curY = pointIter.y();
 			int curZ = getNearestZ(curX, curY, prevZ);
 			
-			if (hasGeoPos(prevX, prevY))
-			{
+			if (hasGeoPos(prevX, prevY)) {
 				int nswe = GeoUtils.computeNswe(prevX, prevY, curX, curY);
-				if (!checkNearestNsweAntiCornerCut(prevX, prevY, prevZ, nswe))
-				{
+				if (!checkNearestNsweAntiCornerCut(prevX, prevY, prevZ, nswe)) {
 					// can't move, return previous location
 					return new Location(getWorldX(prevX), getWorldY(prevY), prevZ);
 				}
@@ -502,8 +432,7 @@ public class GeoData
 			prevZ = curZ;
 		}
 		
-		if (hasGeoPos(prevX, prevY) && (prevZ != tz))
-		{
+		if (hasGeoPos(prevX, prevY) && (prevZ != tz)) {
 			// different floors, return start location
 			return new Location(x, y, z);
 		}
@@ -522,8 +451,7 @@ public class GeoData
 	 * @param instanceId the instance ID
 	 * @return {@code true} if the character at start coordinates can move to end coordinates, {@code false} otherwise
 	 */
-	public boolean canMove(int fromX, int fromY, int fromZ, int toX, int toY, int toZ, int instanceId)
-	{
+	public boolean canMove(int fromX, int fromY, int fromZ, int toX, int toY, int toZ, int instanceId) {
 		int geoX = getGeoX(fromX);
 		int geoY = getGeoY(fromY);
 		fromZ = getNearestZ(geoX, geoY, fromZ);
@@ -531,8 +459,7 @@ public class GeoData
 		int tGeoY = getGeoY(toY);
 		toZ = getNearestZ(tGeoX, tGeoY, toZ);
 		
-		if (DoorData.getInstance().checkIfDoorsBetween(fromX, fromY, fromZ, toX, toY, toZ, instanceId, false))
-		{
+		if (DoorData.getInstance().checkIfDoorsBetween(fromX, fromY, fromZ, toX, toY, toZ, instanceId, false)) {
 			return false;
 		}
 		
@@ -543,17 +470,14 @@ public class GeoData
 		int prevY = pointIter.y();
 		int prevZ = fromZ;
 		
-		while (pointIter.next())
-		{
+		while (pointIter.next()) {
 			int curX = pointIter.x();
 			int curY = pointIter.y();
 			int curZ = getNearestZ(curX, curY, prevZ);
 			
-			if (hasGeoPos(prevX, prevY))
-			{
+			if (hasGeoPos(prevX, prevY)) {
 				int nswe = GeoUtils.computeNswe(prevX, prevY, curX, curY);
-				if (!checkNearestNsweAntiCornerCut(prevX, prevY, prevZ, nswe))
-				{
+				if (!checkNearestNsweAntiCornerCut(prevX, prevY, prevZ, nswe)) {
 					return false;
 				}
 			}
@@ -563,8 +487,7 @@ public class GeoData
 			prevZ = curZ;
 		}
 		
-		if (hasGeoPos(prevX, prevY) && (prevZ != toZ))
-		{
+		if (hasGeoPos(prevX, prevY) && (prevZ != toZ)) {
 			// different floors
 			return false;
 		}
@@ -572,8 +495,7 @@ public class GeoData
 		return true;
 	}
 	
-	public int traceTerrainZ(int x, int y, int z, int tx, int ty)
-	{
+	public int traceTerrainZ(int x, int y, int z, int tx, int ty) {
 		int geoX = getGeoX(x);
 		int geoY = getGeoY(y);
 		z = getNearestZ(geoX, geoY, z);
@@ -585,8 +507,7 @@ public class GeoData
 		pointIter.next();
 		int prevZ = z;
 		
-		while (pointIter.next())
-		{
+		while (pointIter.next()) {
 			int curX = pointIter.x();
 			int curY = pointIter.y();
 			int curZ = getNearestZ(curX, curY, prevZ);
@@ -605,8 +526,7 @@ public class GeoData
 	 * @param toZ the Z coordinate to end checking at
 	 * @return {@code true} if the character at start coordinates can move to end coordinates, {@code false} otherwise
 	 */
-	public boolean canMove(ILocational from, int toX, int toY, int toZ)
-	{
+	public boolean canMove(ILocational from, int toX, int toY, int toZ) {
 		return canMove(from.getX(), from.getY(), from.getZ(), toX, toY, toZ, from.getInstanceId());
 	}
 	
@@ -616,8 +536,7 @@ public class GeoData
 	 * @param to the {@code ILocational} to end checking at
 	 * @return {@code true} if the character at start coordinates can move to end coordinates, {@code false} otherwise
 	 */
-	public boolean canMove(ILocational from, ILocational to)
-	{
+	public boolean canMove(ILocational from, ILocational to) {
 		return canMove(from, to.getX(), to.getY(), to.getZ());
 	}
 	
@@ -627,18 +546,15 @@ public class GeoData
 	 * @param y the Y coordinate
 	 * @return {@code true} if there is geodata for the given coordinates, {@code false} otherwise
 	 */
-	public boolean hasGeo(int x, int y)
-	{
+	public boolean hasGeo(int x, int y) {
 		return hasGeoPos(getGeoX(x), getGeoY(y));
 	}
 	
-	public static GeoData getInstance()
-	{
+	public static GeoData getInstance() {
 		return SingletonHolder._instance;
 	}
 	
-	private static class SingletonHolder
-	{
+	private static class SingletonHolder {
 		protected static final GeoData _instance = new GeoData();
 	}
 }

+ 1 - 2
src/main/java/com/l2jserver/gameserver/InstanceListManager.java

@@ -22,8 +22,7 @@ package com.l2jserver.gameserver;
  * Interface for managers of list of instances.
  * @author fordfrog
  */
-public interface InstanceListManager
-{
+public interface InstanceListManager {
 	/**
 	 * Loads instances with their data from persistent format.<br>
 	 * This method has no side effect as calling methods of another instance manager.

+ 19 - 41
src/main/java/com/l2jserver/gameserver/ItemsAutoDestroy.java

@@ -27,79 +27,58 @@ import com.l2jserver.gameserver.instancemanager.ItemsOnGroundManager;
 import com.l2jserver.gameserver.model.L2World;
 import com.l2jserver.gameserver.model.items.instance.L2ItemInstance;
 
-public final class ItemsAutoDestroy
-{
+public final class ItemsAutoDestroy {
 	private final Map<Integer, L2ItemInstance> _items = new ConcurrentHashMap<>();
 	
-	protected ItemsAutoDestroy()
-	{
+	protected ItemsAutoDestroy() {
 		ThreadPoolManager.getInstance().scheduleGeneralAtFixedRate(this::removeItems, 5000, 5000);
 	}
 	
-	public static ItemsAutoDestroy getInstance()
-	{
+	public static ItemsAutoDestroy getInstance() {
 		return SingletonHolder._instance;
 	}
 	
-	public synchronized void addItem(L2ItemInstance item)
-	{
+	public synchronized void addItem(L2ItemInstance item) {
 		item.setDropTime(System.currentTimeMillis());
 		_items.put(item.getObjectId(), item);
 	}
 	
-	public synchronized void removeItems()
-	{
+	public synchronized void removeItems() {
 		final long curtime = System.currentTimeMillis();
-		for (L2ItemInstance item : _items.values())
-		{
-			if (item == null)
-			{
+		for (L2ItemInstance item : _items.values()) {
+			if (item == null) {
 				continue;
 			}
 			
-			if ((item.getDropTime() == 0) || (item.getItemLocation() != ItemLocation.VOID))
-			{
+			if ((item.getDropTime() == 0) || (item.getItemLocation() != ItemLocation.VOID)) {
 				_items.remove(item.getObjectId());
-			}
-			else
-			{
-				if (item.getItem().getAutoDestroyTime() > 0)
-				{
-					if ((curtime - item.getDropTime()) > item.getItem().getAutoDestroyTime())
-					{
+			} else {
+				if (item.getItem().getAutoDestroyTime() > 0) {
+					if ((curtime - item.getDropTime()) > item.getItem().getAutoDestroyTime()) {
 						L2World.getInstance().removeVisibleObject(item, item.getWorldRegion());
 						L2World.getInstance().removeObject(item);
 						_items.remove(item.getObjectId());
-						if (Config.SAVE_DROPPED_ITEM)
-						{
+						if (Config.SAVE_DROPPED_ITEM) {
 							ItemsOnGroundManager.getInstance().removeObject(item);
 						}
 					}
-				}
-				else if (item.getItem().hasExImmediateEffect())
-				{
-					if ((curtime - item.getDropTime()) > Config.HERB_AUTO_DESTROY_TIME)
-					{
+				} else if (item.getItem().hasExImmediateEffect()) {
+					if ((curtime - item.getDropTime()) > Config.HERB_AUTO_DESTROY_TIME) {
 						L2World.getInstance().removeVisibleObject(item, item.getWorldRegion());
 						L2World.getInstance().removeObject(item);
 						_items.remove(item.getObjectId());
-						if (Config.SAVE_DROPPED_ITEM)
-						{
+						if (Config.SAVE_DROPPED_ITEM) {
 							ItemsOnGroundManager.getInstance().removeObject(item);
 						}
 					}
-				}
-				else
-				{
+				} else {
 					final long sleep = ((Config.AUTODESTROY_ITEM_AFTER == 0) ? 3600000 : Config.AUTODESTROY_ITEM_AFTER * 1000);
 					
-					if ((curtime - item.getDropTime()) > sleep)
-					{
+					if ((curtime - item.getDropTime()) > sleep) {
 						L2World.getInstance().removeVisibleObject(item, item.getWorldRegion());
 						L2World.getInstance().removeObject(item);
 						_items.remove(item.getObjectId());
-						if (Config.SAVE_DROPPED_ITEM)
-						{
+						if (Config.SAVE_DROPPED_ITEM) {
 							ItemsOnGroundManager.getInstance().removeObject(item);
 						}
 					}
@@ -108,8 +87,7 @@ public final class ItemsAutoDestroy
 		}
 	}
 	
-	private static class SingletonHolder
-	{
+	private static class SingletonHolder {
 		protected static final ItemsAutoDestroy _instance = new ItemsAutoDestroy();
 	}
 }

+ 22 - 47
src/main/java/com/l2jserver/gameserver/MonsterRace.java

@@ -28,91 +28,71 @@ import com.l2jserver.gameserver.model.actor.L2Npc;
 import com.l2jserver.gameserver.model.actor.templates.L2NpcTemplate;
 import com.l2jserver.util.Rnd;
 
-public class MonsterRace
-{
+public class MonsterRace {
 	protected static final Logger LOG = LoggerFactory.getLogger(MonsterRace.class);
 	
 	private final L2Npc[] _monsters;
 	private int[][] _speeds;
 	private final int[] _first, _second;
 	
-	protected MonsterRace()
-	{
+	protected MonsterRace() {
 		_monsters = new L2Npc[8];
 		_speeds = new int[8][20];
 		_first = new int[2];
 		_second = new int[2];
 	}
 	
-	public static MonsterRace getInstance()
-	{
+	public static MonsterRace getInstance() {
 		return SingletonHolder._instance;
 	}
 	
-	public void newRace()
-	{
+	public void newRace() {
 		int random = 0;
 		
-		for (int i = 0; i < 8; i++)
-		{
+		for (int i = 0; i < 8; i++) {
 			int id = 31003;
 			random = Rnd.get(24);
-			while (true)
-			{
-				for (int j = i - 1; j >= 0; j--)
-				{
-					if (_monsters[j].getTemplate().getId() == (id + random))
-					{
+			while (true) {
+				for (int j = i - 1; j >= 0; j--) {
+					if (_monsters[j].getTemplate().getId() == (id + random)) {
 						random = Rnd.get(24);
 						continue;
 					}
 				}
 				break;
 			}
-			try
-			{
+			try {
 				L2NpcTemplate template = NpcData.getInstance().getTemplate(id + random);
 				Constructor<?> constructor = Class.forName("com.l2jserver.gameserver.model.actor.instance." + template.getType() + "Instance").getConstructors()[0];
 				_monsters[i] = (L2Npc) constructor.newInstance(template);
-			}
-			catch (Exception e)
-			{
+			} catch (Exception e) {
 				LOG.warn("Unable to create monster!", e);
 			}
 		}
 		newSpeeds();
 	}
 	
-	public void newSpeeds()
-	{
+	public void newSpeeds() {
 		_speeds = new int[8][20];
 		int total = 0;
 		_first[1] = 0;
 		_second[1] = 0;
-		for (int i = 0; i < 8; i++)
-		{
+		for (int i = 0; i < 8; i++) {
 			total = 0;
-			for (int j = 0; j < 20; j++)
-			{
-				if (j == 19)
-				{
+			for (int j = 0; j < 20; j++) {
+				if (j == 19) {
 					_speeds[i][j] = 100;
-				}
-				else
-				{
+				} else {
 					_speeds[i][j] = Rnd.get(60) + 65;
 				}
 				total += _speeds[i][j];
 			}
-			if (total >= _first[1])
-			{
+			if (total >= _first[1]) {
 				_second[0] = _first[0];
 				_second[1] = _first[1];
 				_first[0] = 8 - i;
 				_first[1] = total;
-			}
-			else if (total >= _second[1])
-			{
+			} else if (total >= _second[1]) {
 				_second[0] = 8 - i;
 				_second[1] = total;
 			}
@@ -122,31 +102,26 @@ public class MonsterRace
 	/**
 	 * @return Returns the monsters.
 	 */
-	public L2Npc[] getMonsters()
-	{
+	public L2Npc[] getMonsters() {
 		return _monsters;
 	}
 	
 	/**
 	 * @return Returns the speeds.
 	 */
-	public int[][] getSpeeds()
-	{
+	public int[][] getSpeeds() {
 		return _speeds;
 	}
 	
-	public int getFirstPlace()
-	{
+	public int getFirstPlace() {
 		return _first[0];
 	}
 	
-	public int getSecondPlace()
-	{
+	public int getSecondPlace() {
 		return _second[0];
 	}
 	
-	private static class SingletonHolder
-	{
+	private static class SingletonHolder {
 		protected static final MonsterRace _instance = new MonsterRace();
 	}
 }

+ 114 - 251
src/main/java/com/l2jserver/gameserver/RecipeController.java

@@ -53,20 +53,16 @@ import com.l2jserver.gameserver.network.serverpackets.SystemMessage;
 import com.l2jserver.gameserver.util.Util;
 import com.l2jserver.util.Rnd;
 
-public class RecipeController
-{
+public class RecipeController {
 	protected static final Map<Integer, RecipeItemMaker> _activeMakers = new ConcurrentHashMap<>();
 	
-	protected RecipeController()
-	{
+	protected RecipeController() {
 		// Prevent external initialization.
 	}
 	
-	public void requestBookOpen(L2PcInstance player, boolean isDwarvenCraft)
-	{
+	public void requestBookOpen(L2PcInstance player, boolean isDwarvenCraft) {
 		// Check if player is trying to alter recipe book while engaged in manufacturing.
-		if (!_activeMakers.containsKey(player.getObjectId()))
-		{
+		if (!_activeMakers.containsKey(player.getObjectId())) {
 			RecipeBookItemList response = new RecipeBookItemList(isDwarvenCraft, player.getMaxMp());
 			response.addRecipes(isDwarvenCraft ? player.getDwarvenRecipeBook() : player.getCommonRecipeBook());
 			player.sendPacket(response);
@@ -75,77 +71,63 @@ public class RecipeController
 		player.sendPacket(SystemMessageId.CANT_ALTER_RECIPEBOOK_WHILE_CRAFTING);
 	}
 	
-	public void requestMakeItemAbort(L2PcInstance player)
-	{
+	public void requestMakeItemAbort(L2PcInstance player) {
 		_activeMakers.remove(player.getObjectId()); // TODO: anything else here?
 	}
 	
-	public void requestManufactureItem(L2PcInstance manufacturer, int recipeListId, L2PcInstance player)
-	{
+	public void requestManufactureItem(L2PcInstance manufacturer, int recipeListId, L2PcInstance player) {
 		final L2RecipeList recipeList = RecipeData.getInstance().getValidRecipeList(player, recipeListId);
-		if (recipeList == null)
-		{
+		if (recipeList == null) {
 			return;
 		}
 		
 		List<L2RecipeList> dwarfRecipes = Arrays.asList(manufacturer.getDwarvenRecipeBook());
 		List<L2RecipeList> commonRecipes = Arrays.asList(manufacturer.getCommonRecipeBook());
 		
-		if (!dwarfRecipes.contains(recipeList) && !commonRecipes.contains(recipeList))
-		{
+		if (!dwarfRecipes.contains(recipeList) && !commonRecipes.contains(recipeList)) {
 			Util.handleIllegalPlayerAction(player, "Warning!! Character " + player.getName() + " of account " + player.getAccountName() + " sent a false recipe id.", Config.DEFAULT_PUNISH);
 			return;
 		}
 		
 		// Check if manufacturer is under manufacturing store or private store.
-		if (Config.ALT_GAME_CREATION && _activeMakers.containsKey(manufacturer.getObjectId()))
-		{
+		if (Config.ALT_GAME_CREATION && _activeMakers.containsKey(manufacturer.getObjectId())) {
 			player.sendPacket(SystemMessageId.CLOSE_STORE_WINDOW_AND_TRY_AGAIN);
 			return;
 		}
 		
 		final RecipeItemMaker maker = new RecipeItemMaker(manufacturer, recipeList, player);
-		if (maker._isValid)
-		{
-			if (Config.ALT_GAME_CREATION)
-			{
+		if (maker._isValid) {
+			if (Config.ALT_GAME_CREATION) {
 				_activeMakers.put(manufacturer.getObjectId(), maker);
 				ThreadPoolManager.getInstance().scheduleGeneral(maker, 100);
-			}
-			else
-			{
+			} else {
 				maker.run();
 			}
 		}
 	}
 	
-	public void requestMakeItem(L2PcInstance player, int recipeListId)
-	{
+	public void requestMakeItem(L2PcInstance player, int recipeListId) {
 		// Check if player is trying to operate a private store or private workshop while engaged in combat.
-		if (player.isInCombat() || player.isInDuel())
-		{
+		if (player.isInCombat() || player.isInDuel()) {
 			player.sendPacket(SystemMessageId.CANT_OPERATE_PRIVATE_STORE_DURING_COMBAT);
 			return;
 		}
 		
 		final L2RecipeList recipeList = RecipeData.getInstance().getValidRecipeList(player, recipeListId);
-		if (recipeList == null)
-		{
+		if (recipeList == null) {
 			return;
 		}
 		
 		List<L2RecipeList> dwarfRecipes = Arrays.asList(player.getDwarvenRecipeBook());
 		List<L2RecipeList> commonRecipes = Arrays.asList(player.getCommonRecipeBook());
 		
-		if (!dwarfRecipes.contains(recipeList) && !commonRecipes.contains(recipeList))
-		{
+		if (!dwarfRecipes.contains(recipeList) && !commonRecipes.contains(recipeList)) {
 			Util.handleIllegalPlayerAction(player, "Warning!! Character " + player.getName() + " of account " + player.getAccountName() + " sent a false recipe id.", Config.DEFAULT_PUNISH);
 			return;
 		}
 		
 		// Check if player is busy (possible if alt game creation is enabled)
-		if (Config.ALT_GAME_CREATION && _activeMakers.containsKey(player.getObjectId()))
-		{
+		if (Config.ALT_GAME_CREATION && _activeMakers.containsKey(player.getObjectId())) {
 			SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.S2_S1);
 			sm.addItemName(recipeList.getItemId());
 			sm.addString("You are busy creating.");
@@ -154,22 +136,17 @@ public class RecipeController
 		}
 		
 		final RecipeItemMaker maker = new RecipeItemMaker(player, recipeList, player);
-		if (maker._isValid)
-		{
-			if (Config.ALT_GAME_CREATION)
-			{
+		if (maker._isValid) {
+			if (Config.ALT_GAME_CREATION) {
 				_activeMakers.put(player.getObjectId(), maker);
 				ThreadPoolManager.getInstance().scheduleGeneral(maker, 100);
-			}
-			else
-			{
+			} else {
 				maker.run();
 			}
 		}
 	}
 	
-	private static class RecipeItemMaker implements Runnable
-	{
+	private static class RecipeItemMaker implements Runnable {
 		private static final Logger _log = Logger.getLogger(RecipeItemMaker.class.getName());
 		protected boolean _isValid;
 		protected List<TempItem> _items = null;
@@ -187,8 +164,7 @@ public class RecipeController
 		protected int _totalItems;
 		protected int _delay;
 		
-		public RecipeItemMaker(L2PcInstance pPlayer, L2RecipeList pRecipeList, L2PcInstance pTarget)
-		{
+		public RecipeItemMaker(L2PcInstance pPlayer, L2RecipeList pRecipeList, L2PcInstance pTarget) {
 			_player = pPlayer;
 			_target = pTarget;
 			_recipeList = pRecipeList;
@@ -200,56 +176,48 @@ public class RecipeController
 			
 			_player.isInCraftMode(true);
 			
-			if (_player.isAlikeDead())
-			{
+			if (_player.isAlikeDead()) {
 				_player.sendPacket(ActionFailed.STATIC_PACKET);
 				abort();
 				return;
 			}
 			
-			if (_target.isAlikeDead())
-			{
+			if (_target.isAlikeDead()) {
 				_target.sendPacket(ActionFailed.STATIC_PACKET);
 				abort();
 				return;
 			}
 			
-			if (_target.isProcessingTransaction())
-			{
+			if (_target.isProcessingTransaction()) {
 				_target.sendPacket(ActionFailed.STATIC_PACKET);
 				abort();
 				return;
 			}
 			
-			if (_player.isProcessingTransaction())
-			{
+			if (_player.isProcessingTransaction()) {
 				_player.sendPacket(ActionFailed.STATIC_PACKET);
 				abort();
 				return;
 			}
 			
 			// validate recipe list
-			if (_recipeList.getRecipes().length == 0)
-			{
+			if (_recipeList.getRecipes().length == 0) {
 				_player.sendPacket(ActionFailed.STATIC_PACKET);
 				abort();
 				return;
 			}
 			
 			// validate skill level
-			if (_recipeList.getLevel() > _skillLevel)
-			{
+			if (_recipeList.getLevel() > _skillLevel) {
 				_player.sendPacket(ActionFailed.STATIC_PACKET);
 				abort();
 				return;
 			}
 			
 			// check that customer can afford to pay for creation services
-			if (_player != _target)
-			{
+			if (_player != _target) {
 				final L2ManufactureItem item = _player.getManufactureItems().get(_recipeList.getId());
-				if (item != null)
-				{
+				if (item != null) {
 					_price = item.getCost();
 					if (_target.getAdena() < _price) // check price
 					{
@@ -262,27 +230,23 @@ public class RecipeController
 			
 			// make temporary items
 			_items = listItems(false);
-			if (_items == null)
-			{
+			if (_items == null) {
 				abort();
 				return;
 			}
 			
-			for (TempItem i : _items)
-			{
+			for (TempItem i : _items) {
 				_totalItems += i.getQuantity();
 			}
 			
 			// initial statUse checks
-			if (!calculateStatUse(false, false))
-			{
+			if (!calculateStatUse(false, false)) {
 				abort();
 				return;
 			}
 			
 			// initial AltStatChange checks
-			if (Config.ALT_GAME_CREATION)
-			{
+			if (Config.ALT_GAME_CREATION) {
 				calculateAltStatChange();
 			}
 			
@@ -295,38 +259,30 @@ public class RecipeController
 		}
 		
 		@Override
-		public void run()
-		{
-			if (!Config.IS_CRAFTING_ENABLED)
-			{
+		public void run() {
+			if (!Config.IS_CRAFTING_ENABLED) {
 				_target.sendMessage("Item creation is currently disabled.");
 				abort();
 				return;
 			}
 			
-			if ((_player == null) || (_target == null))
-			{
+			if ((_player == null) || (_target == null)) {
 				_log.warning("player or target == null (disconnected?), aborting" + _target + _player);
 				abort();
 				return;
 			}
 			
-			if (!_player.isOnline() || !_target.isOnline())
-			{
+			if (!_player.isOnline() || !_target.isOnline()) {
 				_log.warning("player or target is not online, aborting " + _target + _player);
 				abort();
 				return;
 			}
 			
-			if (Config.ALT_GAME_CREATION && !_activeMakers.containsKey(_player.getObjectId()))
-			{
-				if (_target != _player)
-				{
+			if (Config.ALT_GAME_CREATION && !_activeMakers.containsKey(_player.getObjectId())) {
+				if (_target != _player) {
 					_target.sendMessage("Manufacture aborted");
 					_player.sendMessage("Manufacture aborted");
-				}
-				else
-				{
+				} else {
 					_player.sendMessage("Item creation aborted");
 				}
 				
@@ -334,11 +290,9 @@ public class RecipeController
 				return;
 			}
 			
-			if (Config.ALT_GAME_CREATION && !_items.isEmpty())
-			{
+			if (Config.ALT_GAME_CREATION && !_items.isEmpty()) {
 				
-				if (!calculateStatUse(true, true))
-				{
+				if (!calculateStatUse(true, true)) {
 					return; // check stat use
 				}
 				updateCurMp(); // update craft window mp bar
@@ -346,8 +300,7 @@ public class RecipeController
 				grabSomeItems(); // grab (equip) some more items with a nice msg to player
 				
 				// if still not empty, schedule another pass
-				if (!_items.isEmpty())
-				{
+				if (!_items.isEmpty()) {
 					_delay = (int) (Config.ALT_GAME_CREATION_SPEED * _player.getMReuseRate(_skill) * GameTimeController.TICKS_PER_SECOND * GameTimeController.MILLIS_IN_TICK);
 					
 					// FIXME: please fix this packet to show crafting animation (somebody)
@@ -356,35 +309,25 @@ public class RecipeController
 					
 					_player.sendPacket(new SetupGauge(0, _delay));
 					ThreadPoolManager.getInstance().scheduleGeneral(this, 100 + _delay);
-				}
-				else
-				{
+				} else {
 					// for alt mode, sleep delay msec before finishing
 					_player.sendPacket(new SetupGauge(0, _delay));
 					
-					try
-					{
+					try {
 						Thread.sleep(_delay);
-					}
-					catch (InterruptedException e)
-					{
-					}
-					finally
-					{
+					} catch (InterruptedException e) {
+					} finally {
 						finishCrafting();
 					}
 				}
 			} // for old craft mode just finish
-			else
-			{
+			else {
 				finishCrafting();
 			}
 		}
 		
-		private void finishCrafting()
-		{
-			if (!Config.ALT_GAME_CREATION)
-			{
+		private void finishCrafting() {
+			if (!Config.ALT_GAME_CREATION) {
 				calculateStatUse(false, true);
 			}
 			
@@ -394,8 +337,7 @@ public class RecipeController
 				// attempt to pay for item
 				L2ItemInstance adenatransfer = _target.transferItem("PayManufacture", _target.getInventory().getAdenaInstance().getObjectId(), _price, _player.getInventory(), _player);
 				
-				if (adenatransfer == null)
-				{
+				if (adenatransfer == null) {
 					_target.sendPacket(SystemMessageId.YOU_NOT_ENOUGH_ADENA);
 					abort();
 					return;
@@ -403,20 +345,14 @@ public class RecipeController
 			}
 			
 			_items = listItems(true); // this line actually takes materials from inventory
-			if (_items == null)
-			{
+			if (_items == null) {
 				// handle possible cheaters here
 				// (they click craft then try to get rid of items in order to get free craft)
-			}
-			else if (Rnd.get(100) < _recipeList.getSuccessRate())
-			{
+			} else if (Rnd.get(100) < _recipeList.getSuccessRate()) {
 				rewardPlayer(); // and immediately puts created item in its place
 				updateMakeInfo(true);
-			}
-			else
-			{
-				if (_target != _player)
-				{
+			} else {
+				if (_target != _player) {
 					SystemMessage msg = SystemMessage.getSystemMessage(SystemMessageId.CREATION_OF_S2_FOR_C1_AT_S3_ADENA_FAILED);
 					msg.addString(_target.getName());
 					msg.addItemName(_recipeList.getItemId());
@@ -428,9 +364,7 @@ public class RecipeController
 					msg.addItemName(_recipeList.getItemId());
 					msg.addLong(_price);
 					_target.sendPacket(msg);
-				}
-				else
-				{
+				} else {
 					_target.sendPacket(SystemMessageId.ITEM_MIXING_FAILED);
 				}
 				updateMakeInfo(false);
@@ -443,153 +377,111 @@ public class RecipeController
 			_target.sendPacket(new ItemList(_target, false));
 		}
 		
-		private void updateMakeInfo(boolean success)
-		{
-			if (_target == _player)
-			{
+		private void updateMakeInfo(boolean success) {
+			if (_target == _player) {
 				_target.sendPacket(new RecipeItemMakeInfo(_recipeList.getId(), _target, success));
-			}
-			else
-			{
+			} else {
 				_target.sendPacket(new RecipeShopItemInfo(_player, _recipeList.getId()));
 			}
 		}
 		
-		private void updateCurLoad()
-		{
+		private void updateCurLoad() {
 			StatusUpdate su = new StatusUpdate(_target);
 			su.addAttribute(StatusUpdate.CUR_LOAD, _target.getCurrentLoad());
 			_target.sendPacket(su);
 		}
 		
-		private void updateCurMp()
-		{
+		private void updateCurMp() {
 			StatusUpdate su = new StatusUpdate(_target);
 			su.addAttribute(StatusUpdate.CUR_MP, (int) _target.getCurrentMp());
 			_target.sendPacket(su);
 		}
 		
-		private void grabSomeItems()
-		{
+		private void grabSomeItems() {
 			int grabItems = _itemGrab;
-			while ((grabItems > 0) && !_items.isEmpty())
-			{
+			while ((grabItems > 0) && !_items.isEmpty()) {
 				TempItem item = _items.get(0);
 				
 				int count = item.getQuantity();
-				if (count >= grabItems)
-				{
+				if (count >= grabItems) {
 					count = grabItems;
 				}
 				
 				item.setQuantity(item.getQuantity() - count);
-				if (item.getQuantity() <= 0)
-				{
+				if (item.getQuantity() <= 0) {
 					_items.remove(0);
-				}
-				else
-				{
+				} else {
 					_items.set(0, item);
 				}
 				
 				grabItems -= count;
 				
-				if (_target == _player)
-				{
+				if (_target == _player) {
 					SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.S1_S2_EQUIPPED); // you equipped ...
 					sm.addLong(count);
 					sm.addItemName(item.getItemId());
 					_player.sendPacket(sm);
-				}
-				else
-				{
+				} else {
 					_target.sendMessage("Manufacturer " + _player.getName() + " used " + count + " " + item.getItemName());
 				}
 			}
 		}
 		
 		// AltStatChange parameters make their effect here
-		private void calculateAltStatChange()
-		{
+		private void calculateAltStatChange() {
 			_itemGrab = _skillLevel;
 			
-			for (L2RecipeStatInstance altStatChange : _recipeList.getAltStatChange())
-			{
-				if (altStatChange.getType() == StatType.XP)
-				{
+			for (L2RecipeStatInstance altStatChange : _recipeList.getAltStatChange()) {
+				if (altStatChange.getType() == StatType.XP) {
 					_exp = altStatChange.getValue();
-				}
-				else if (altStatChange.getType() == StatType.SP)
-				{
+				} else if (altStatChange.getType() == StatType.SP) {
 					_sp = altStatChange.getValue();
-				}
-				else if (altStatChange.getType() == StatType.GIM)
-				{
+				} else if (altStatChange.getType() == StatType.GIM) {
 					_itemGrab *= altStatChange.getValue();
 				}
 			}
 			// determine number of creation passes needed
 			_creationPasses = (_totalItems / _itemGrab) + ((_totalItems % _itemGrab) != 0 ? 1 : 0);
-			if (_creationPasses < 1)
-			{
+			if (_creationPasses < 1) {
 				_creationPasses = 1;
 			}
 		}
 		
 		// StatUse
-		private boolean calculateStatUse(boolean isWait, boolean isReduce)
-		{
+		private boolean calculateStatUse(boolean isWait, boolean isReduce) {
 			boolean ret = true;
-			for (L2RecipeStatInstance statUse : _recipeList.getStatUse())
-			{
+			for (L2RecipeStatInstance statUse : _recipeList.getStatUse()) {
 				double modifiedValue = statUse.getValue() / _creationPasses;
-				if (statUse.getType() == StatType.HP)
-				{
+				if (statUse.getType() == StatType.HP) {
 					// we do not want to kill the player, so its CurrentHP must be greater than the reduce value
-					if (_player.getCurrentHp() <= modifiedValue)
-					{
+					if (_player.getCurrentHp() <= modifiedValue) {
 						// rest (wait for HP)
-						if (Config.ALT_GAME_CREATION && isWait)
-						{
+						if (Config.ALT_GAME_CREATION && isWait) {
 							_player.sendPacket(new SetupGauge(0, _delay));
 							ThreadPoolManager.getInstance().scheduleGeneral(this, 100 + _delay);
-						}
-						else
-						{
+						} else {
 							_target.sendPacket(SystemMessageId.NOT_ENOUGH_HP);
 							abort();
 						}
 						ret = false;
-					}
-					else if (isReduce)
-					{
+					} else if (isReduce) {
 						_player.reduceCurrentHp(modifiedValue, _player, _skill);
 					}
-				}
-				else if (statUse.getType() == StatType.MP)
-				{
-					if (_player.getCurrentMp() < modifiedValue)
-					{
+				} else if (statUse.getType() == StatType.MP) {
+					if (_player.getCurrentMp() < modifiedValue) {
 						// rest (wait for MP)
-						if (Config.ALT_GAME_CREATION && isWait)
-						{
+						if (Config.ALT_GAME_CREATION && isWait) {
 							_player.sendPacket(new SetupGauge(0, _delay));
 							ThreadPoolManager.getInstance().scheduleGeneral(this, 100 + _delay);
-						}
-						else
-						{
+						} else {
 							_target.sendPacket(SystemMessageId.NOT_ENOUGH_MP);
 							abort();
 						}
 						ret = false;
-					}
-					else if (isReduce)
-					{
+					} else if (isReduce) {
 						_player.reduceCurrentMp(modifiedValue);
 					}
-				}
-				else
-				{
+				} else {
 					// there is an unknown StatUse value
 					_target.sendMessage("Recipe error!!!, please tell this to your GM.");
 					ret = false;
@@ -599,23 +491,19 @@ public class RecipeController
 			return ret;
 		}
 		
-		private List<TempItem> listItems(boolean remove)
-		{
+		private List<TempItem> listItems(boolean remove) {
 			L2RecipeInstance[] recipes = _recipeList.getRecipes();
 			Inventory inv = _target.getInventory();
 			List<TempItem> materials = new ArrayList<>();
 			SystemMessage sm;
 			
-			for (L2RecipeInstance recipe : recipes)
-			{
-				if (recipe.getQuantity() > 0)
-				{
+			for (L2RecipeInstance recipe : recipes) {
+				if (recipe.getQuantity() > 0) {
 					L2ItemInstance item = inv.getItemByItemId(recipe.getItemId());
 					long itemQuantityAmount = item == null ? 0 : item.getCount();
 					
 					// check materials
-					if (itemQuantityAmount < recipe.getQuantity())
-					{
+					if (itemQuantityAmount < recipe.getQuantity()) {
 						sm = SystemMessage.getSystemMessage(SystemMessageId.MISSING_S2_S1_TO_CREATE);
 						sm.addItemName(recipe.getItemId());
 						sm.addLong(recipe.getQuantity() - itemQuantityAmount);
@@ -630,21 +518,16 @@ public class RecipeController
 				}
 			}
 			
-			if (remove)
-			{
-				for (TempItem tmp : materials)
-				{
+			if (remove) {
+				for (TempItem tmp : materials) {
 					inv.destroyItemByItemId("Manufacture", tmp.getItemId(), tmp.getQuantity(), _target, _player);
 					
-					if (tmp.getQuantity() > 1)
-					{
+					if (tmp.getQuantity() > 1) {
 						sm = SystemMessage.getSystemMessage(SystemMessageId.S2_S1_DISAPPEARED);
 						sm.addItemName(tmp.getItemId());
 						sm.addLong(tmp.getQuantity());
 						_target.sendPacket(sm);
-					}
-					else
-					{
+					} else {
 						sm = SystemMessage.getSystemMessage(SystemMessageId.S1_DISAPPEARED);
 						sm.addItemName(tmp.getItemId());
 						_target.sendPacket(sm);
@@ -654,25 +537,21 @@ public class RecipeController
 			return materials;
 		}
 		
-		private void abort()
-		{
+		private void abort() {
 			updateMakeInfo(false);
 			_player.isInCraftMode(false);
 			_activeMakers.remove(_player.getObjectId());
 		}
 		
-		private void rewardPlayer()
-		{
+		private void rewardPlayer() {
 			int rareProdId = _recipeList.getRareItemId();
 			int itemId = _recipeList.getItemId();
 			int itemCount = _recipeList.getCount();
 			L2Item template = ItemTable.getInstance().getTemplate(itemId);
 			
 			// check that the current recipe has a rare production or not
-			if ((rareProdId != -1) && ((rareProdId == itemId) || Config.CRAFT_MASTERWORK))
-			{
-				if (Rnd.get(100) < _recipeList.getRarity())
-				{
+			if ((rareProdId != -1) && ((rareProdId == itemId) || Config.CRAFT_MASTERWORK)) {
+				if (Rnd.get(100) < _recipeList.getRarity()) {
 					itemId = rareProdId;
 					itemCount = _recipeList.getRareCount();
 				}
@@ -682,11 +561,9 @@ public class RecipeController
 			
 			// inform customer of earned item
 			SystemMessage sm = null;
-			if (_target != _player)
-			{
+			if (_target != _player) {
 				// inform manufacturer of earned profit
-				if (itemCount == 1)
-				{
+				if (itemCount == 1) {
 					sm = SystemMessage.getSystemMessage(SystemMessageId.S2_CREATED_FOR_C1_FOR_S3_ADENA);
 					sm.addString(_target.getName());
 					sm.addItemName(itemId);
@@ -698,9 +575,7 @@ public class RecipeController
 					sm.addItemName(itemId);
 					sm.addLong(_price);
 					_target.sendPacket(sm);
-				}
-				else
-				{
+				} else {
 					sm = SystemMessage.getSystemMessage(SystemMessageId.S2_S3_S_CREATED_FOR_C1_FOR_S4_ADENA);
 					sm.addString(_target.getName());
 					sm.addInt(itemCount);
@@ -717,49 +592,39 @@ public class RecipeController
 				}
 			}
 			
-			if (itemCount > 1)
-			{
+			if (itemCount > 1) {
 				sm = SystemMessage.getSystemMessage(SystemMessageId.EARNED_S2_S1_S);
 				sm.addItemName(itemId);
 				sm.addLong(itemCount);
 				_target.sendPacket(sm);
-			}
-			else
-			{
+			} else {
 				sm = SystemMessage.getSystemMessage(SystemMessageId.EARNED_ITEM_S1);
 				sm.addItemName(itemId);
 				_target.sendPacket(sm);
 			}
 			
-			if (Config.ALT_GAME_CREATION)
-			{
+			if (Config.ALT_GAME_CREATION) {
 				int recipeLevel = _recipeList.getLevel();
-				if (_exp < 0)
-				{
+				if (_exp < 0) {
 					_exp = template.getReferencePrice() * itemCount;
 					_exp /= recipeLevel;
 				}
-				if (_sp < 0)
-				{
+				if (_sp < 0) {
 					_sp = _exp / 10;
 				}
-				if (itemId == rareProdId)
-				{
+				if (itemId == rareProdId) {
 					_exp *= Config.ALT_GAME_CREATION_RARE_XPSP_RATE;
 					_sp *= Config.ALT_GAME_CREATION_RARE_XPSP_RATE;
 				}
 				
-				if (_exp < 0)
-				{
+				if (_exp < 0) {
 					_exp = 0;
 				}
-				if (_sp < 0)
-				{
+				if (_sp < 0) {
 					_sp = 0;
 				}
 				
-				for (int i = _skillLevel; i > recipeLevel; i--)
-				{
+				for (int i = _skillLevel; i > recipeLevel; i--) {
 					_exp /= 4;
 					_sp /= 4;
 				}
@@ -772,13 +637,11 @@ public class RecipeController
 		}
 	}
 	
-	public static RecipeController getInstance()
-	{
+	public static RecipeController getInstance() {
 		return SingletonHolder._instance;
 	}
 	
-	private static class SingletonHolder
-	{
+	private static class SingletonHolder {
 		protected static final RecipeController _instance = new RecipeController();
 	}
 }

+ 85 - 185
src/main/java/com/l2jserver/gameserver/ThreadPoolManager.java

@@ -68,32 +68,24 @@ import com.l2jserver.util.StringUtil;
  * </p>
  * @author -Wooden-
  */
-public class ThreadPoolManager
-{
+public class ThreadPoolManager {
 	protected static final Logger LOG = LoggerFactory.getLogger(ThreadPoolManager.class);
 	
-	private static final class RunnableWrapper implements Runnable
-	{
+	private static final class RunnableWrapper implements Runnable {
 		private final Runnable _r;
 		
-		public RunnableWrapper(final Runnable r)
-		{
+		public RunnableWrapper(final Runnable r) {
 			_r = r;
 		}
 		
 		@Override
-		public final void run()
-		{
-			try
-			{
+		public final void run() {
+			try {
 				_r.run();
-			}
-			catch (final Throwable e)
-			{
+			} catch (final Throwable e) {
 				final Thread t = Thread.currentThread();
 				final UncaughtExceptionHandler h = t.getUncaughtExceptionHandler();
-				if (h != null)
-				{
+				if (h != null) {
 					h.uncaughtException(t, e);
 				}
 			}
@@ -111,13 +103,11 @@ public class ThreadPoolManager
 	
 	private boolean _shutdown;
 	
-	public static ThreadPoolManager getInstance()
-	{
+	public static ThreadPoolManager getInstance() {
 		return SingletonHolder._instance;
 	}
 	
-	protected ThreadPoolManager()
-	{
+	protected ThreadPoolManager() {
 		_effectsScheduledThreadPool = new ScheduledThreadPoolExecutor(Config.THREAD_P_EFFECTS, new PriorityThreadFactory("EffectsSTPool", Thread.NORM_PRIORITY));
 		_generalScheduledThreadPool = new ScheduledThreadPoolExecutor(Config.THREAD_P_GENERAL, new PriorityThreadFactory("GeneralSTPool", Thread.NORM_PRIORITY));
 		_eventScheduledThreadPool = new ScheduledThreadPoolExecutor(Config.THREAD_E_EVENTS, new PriorityThreadFactory("EventSTPool", Thread.NORM_PRIORITY));
@@ -137,14 +127,10 @@ public class ThreadPoolManager
 	 * @param unit the time unit of the delay parameter
 	 * @return a ScheduledFuture representing pending completion of the task, and whose get() method will throw an exception upon cancellation
 	 */
-	public ScheduledFuture<?> scheduleEffect(Runnable task, long delay, TimeUnit unit)
-	{
-		try
-		{
+	public ScheduledFuture<?> scheduleEffect(Runnable task, long delay, TimeUnit unit) {
+		try {
 			return _effectsScheduledThreadPool.schedule(new RunnableWrapper(task), delay, unit);
-		}
-		catch (RejectedExecutionException e)
-		{
+		} catch (RejectedExecutionException e) {
 			return null;
 		}
 	}
@@ -155,8 +141,7 @@ public class ThreadPoolManager
 	 * @param delay the delay in milliseconds
 	 * @return a ScheduledFuture representing pending completion of the task, and whose get() method will throw an exception upon cancellation
 	 */
-	public ScheduledFuture<?> scheduleEffect(Runnable task, long delay)
-	{
+	public ScheduledFuture<?> scheduleEffect(Runnable task, long delay) {
 		return scheduleEffect(task, delay, TimeUnit.MILLISECONDS);
 	}
 	
@@ -168,14 +153,10 @@ public class ThreadPoolManager
 	 * @param unit the time unit of the initialDelay and period parameters
 	 * @return a ScheduledFuture representing pending completion of the task, and whose get() method will throw an exception upon cancellation
 	 */
-	public ScheduledFuture<?> scheduleEffectAtFixedRate(Runnable task, long initialDelay, long period, TimeUnit unit)
-	{
-		try
-		{
+	public ScheduledFuture<?> scheduleEffectAtFixedRate(Runnable task, long initialDelay, long period, TimeUnit unit) {
+		try {
 			return _effectsScheduledThreadPool.scheduleAtFixedRate(new RunnableWrapper(task), initialDelay, period, unit);
-		}
-		catch (RejectedExecutionException e)
-		{
+		} catch (RejectedExecutionException e) {
 			return null; /* shutdown, ignore */
 		}
 	}
@@ -187,8 +168,7 @@ public class ThreadPoolManager
 	 * @param period the period between executions in milliseconds
 	 * @return a ScheduledFuture representing pending completion of the task, and whose get() method will throw an exception upon cancellation
 	 */
-	public ScheduledFuture<?> scheduleEffectAtFixedRate(Runnable task, long initialDelay, long period)
-	{
+	public ScheduledFuture<?> scheduleEffectAtFixedRate(Runnable task, long initialDelay, long period) {
 		return scheduleEffectAtFixedRate(task, initialDelay, period, TimeUnit.MILLISECONDS);
 	}
 	
@@ -199,14 +179,10 @@ public class ThreadPoolManager
 	 * @param unit the time unit of the delay parameter
 	 * @return a ScheduledFuture representing pending completion of the task, and whose get() method will throw an exception upon cancellation
 	 */
-	public ScheduledFuture<?> scheduleGeneral(Runnable task, long delay, TimeUnit unit)
-	{
-		try
-		{
+	public ScheduledFuture<?> scheduleGeneral(Runnable task, long delay, TimeUnit unit) {
+		try {
 			return _generalScheduledThreadPool.schedule(new RunnableWrapper(task), delay, unit);
-		}
-		catch (RejectedExecutionException e)
-		{
+		} catch (RejectedExecutionException e) {
 			return null; /* shutdown, ignore */
 		}
 	}
@@ -217,8 +193,7 @@ public class ThreadPoolManager
 	 * @param delay the delay in milliseconds
 	 * @return a ScheduledFuture representing pending completion of the task, and whose get() method will throw an exception upon cancellation
 	 */
-	public ScheduledFuture<?> scheduleGeneral(Runnable task, long delay)
-	{
+	public ScheduledFuture<?> scheduleGeneral(Runnable task, long delay) {
 		return scheduleGeneral(task, delay, TimeUnit.MILLISECONDS);
 	}
 	
@@ -230,14 +205,10 @@ public class ThreadPoolManager
 	 * @param unit the time unit of the initialDelay and period parameters
 	 * @return a ScheduledFuture representing pending completion of the task, and whose get() method will throw an exception upon cancellation
 	 */
-	public ScheduledFuture<?> scheduleGeneralAtFixedRate(Runnable task, long initialDelay, long period, TimeUnit unit)
-	{
-		try
-		{
+	public ScheduledFuture<?> scheduleGeneralAtFixedRate(Runnable task, long initialDelay, long period, TimeUnit unit) {
+		try {
 			return _generalScheduledThreadPool.scheduleAtFixedRate(new RunnableWrapper(task), initialDelay, period, unit);
-		}
-		catch (RejectedExecutionException e)
-		{
+		} catch (RejectedExecutionException e) {
 			return null; /* shutdown, ignore */
 		}
 	}
@@ -249,14 +220,10 @@ public class ThreadPoolManager
 	 * @param unit the time unit of the delay parameter
 	 * @return a ScheduledFuture representing pending completion of the task, and whose get() method will throw an exception upon cancellation
 	 */
-	public ScheduledFuture<?> scheduleEvent(Runnable task, long delay, TimeUnit unit)
-	{
-		try
-		{
+	public ScheduledFuture<?> scheduleEvent(Runnable task, long delay, TimeUnit unit) {
+		try {
 			return _eventScheduledThreadPool.schedule(new RunnableWrapper(task), delay, unit);
-		}
-		catch (RejectedExecutionException e)
-		{
+		} catch (RejectedExecutionException e) {
 			return null; /* shutdown, ignore */
 		}
 	}
@@ -267,8 +234,7 @@ public class ThreadPoolManager
 	 * @param delay the delay in milliseconds
 	 * @return a ScheduledFuture representing pending completion of the task, and whose get() method will throw an exception upon cancellation
 	 */
-	public ScheduledFuture<?> scheduleEvent(Runnable task, long delay)
-	{
+	public ScheduledFuture<?> scheduleEvent(Runnable task, long delay) {
 		return scheduleEvent(task, delay, TimeUnit.MILLISECONDS);
 	}
 	
@@ -280,14 +246,10 @@ public class ThreadPoolManager
 	 * @param unit the time unit of the initialDelay and period parameters
 	 * @return a ScheduledFuture representing pending completion of the task, and whose get() method will throw an exception upon cancellation
 	 */
-	public ScheduledFuture<?> scheduleEventAtFixedRate(Runnable task, long initialDelay, long period, TimeUnit unit)
-	{
-		try
-		{
+	public ScheduledFuture<?> scheduleEventAtFixedRate(Runnable task, long initialDelay, long period, TimeUnit unit) {
+		try {
 			return _eventScheduledThreadPool.scheduleAtFixedRate(new RunnableWrapper(task), initialDelay, period, unit);
-		}
-		catch (RejectedExecutionException e)
-		{
+		} catch (RejectedExecutionException e) {
 			return null; /* shutdown, ignore */
 		}
 	}
@@ -299,8 +261,7 @@ public class ThreadPoolManager
 	 * @param period the period between executions in milliseconds
 	 * @return a ScheduledFuture representing pending completion of the task, and whose get() method will throw an exception upon cancellation
 	 */
-	public ScheduledFuture<?> scheduleGeneralAtFixedRate(Runnable task, long initialDelay, long period)
-	{
+	public ScheduledFuture<?> scheduleGeneralAtFixedRate(Runnable task, long initialDelay, long period) {
 		return scheduleGeneralAtFixedRate(task, initialDelay, period, TimeUnit.MILLISECONDS);
 	}
 	
@@ -311,14 +272,10 @@ public class ThreadPoolManager
 	 * @param unit the time unit of the delay parameter
 	 * @return a ScheduledFuture representing pending completion of the task, and whose get() method will throw an exception upon cancellation
 	 */
-	public ScheduledFuture<?> scheduleAi(Runnable task, long delay, TimeUnit unit)
-	{
-		try
-		{
+	public ScheduledFuture<?> scheduleAi(Runnable task, long delay, TimeUnit unit) {
+		try {
 			return _aiScheduledThreadPool.schedule(new RunnableWrapper(task), delay, unit);
-		}
-		catch (RejectedExecutionException e)
-		{
+		} catch (RejectedExecutionException e) {
 			return null; /* shutdown, ignore */
 		}
 	}
@@ -329,8 +286,7 @@ public class ThreadPoolManager
 	 * @param delay the delay in milliseconds
 	 * @return a ScheduledFuture representing pending completion of the task, and whose get() method will throw an exception upon cancellation
 	 */
-	public ScheduledFuture<?> scheduleAi(Runnable task, long delay)
-	{
+	public ScheduledFuture<?> scheduleAi(Runnable task, long delay) {
 		return scheduleAi(task, delay, TimeUnit.MILLISECONDS);
 	}
 	
@@ -342,14 +298,10 @@ public class ThreadPoolManager
 	 * @param unit the time unit of the initialDelay and period parameters
 	 * @return a ScheduledFuture representing pending completion of the task, and whose get() method will throw an exception upon cancellation
 	 */
-	public ScheduledFuture<?> scheduleAiAtFixedRate(Runnable task, long initialDelay, long period, TimeUnit unit)
-	{
-		try
-		{
+	public ScheduledFuture<?> scheduleAiAtFixedRate(Runnable task, long initialDelay, long period, TimeUnit unit) {
+		try {
 			return _aiScheduledThreadPool.scheduleAtFixedRate(new RunnableWrapper(task), initialDelay, period, unit);
-		}
-		catch (RejectedExecutionException e)
-		{
+		} catch (RejectedExecutionException e) {
 			return null; /* shutdown, ignore */
 		}
 	}
@@ -361,8 +313,7 @@ public class ThreadPoolManager
 	 * @param period the period between executions in milliseconds
 	 * @return a ScheduledFuture representing pending completion of the task, and whose get() method will throw an exception upon cancellation
 	 */
-	public ScheduledFuture<?> scheduleAiAtFixedRate(Runnable task, long initialDelay, long period)
-	{
+	public ScheduledFuture<?> scheduleAiAtFixedRate(Runnable task, long initialDelay, long period) {
 		return scheduleAiAtFixedRate(task, initialDelay, period, TimeUnit.MILLISECONDS);
 	}
 	
@@ -370,14 +321,10 @@ public class ThreadPoolManager
 	 * Executes a packet task sometime in future in another thread.
 	 * @param task the task to execute
 	 */
-	public void executePacket(Runnable task)
-	{
-		try
-		{
+	public void executePacket(Runnable task) {
+		try {
 			_generalPacketsThreadPool.execute(task);
-		}
-		catch (RejectedExecutionException e)
-		{
+		} catch (RejectedExecutionException e) {
 			/* shutdown, ignore */
 		}
 	}
@@ -386,14 +333,10 @@ public class ThreadPoolManager
 	 * Executes an IO packet task sometime in future in another thread.
 	 * @param task the task to execute
 	 */
-	public void executeIOPacket(Runnable task)
-	{
-		try
-		{
+	public void executeIOPacket(Runnable task) {
+		try {
 			_ioPacketsThreadPool.execute(task);
-		}
-		catch (RejectedExecutionException e)
-		{
+		} catch (RejectedExecutionException e) {
 			/* shutdown, ignore */
 		}
 	}
@@ -402,14 +345,10 @@ public class ThreadPoolManager
 	 * Executes a general task sometime in future in another thread.
 	 * @param task the task to execute
 	 */
-	public void executeGeneral(Runnable task)
-	{
-		try
-		{
+	public void executeGeneral(Runnable task) {
+		try {
 			_generalThreadPool.execute(new RunnableWrapper(task));
-		}
-		catch (RejectedExecutionException e)
-		{
+		} catch (RejectedExecutionException e) {
 			/* shutdown, ignore */
 		}
 	}
@@ -418,14 +357,10 @@ public class ThreadPoolManager
 	 * Executes an AI task sometime in future in another thread.
 	 * @param task the task to execute
 	 */
-	public void executeAi(Runnable task)
-	{
-		try
-		{
+	public void executeAi(Runnable task) {
+		try {
 			_aiScheduledThreadPool.execute(new RunnableWrapper(task));
-		}
-		catch (RejectedExecutionException e)
-		{
+		} catch (RejectedExecutionException e) {
 			/* shutdown, ignore */
 		}
 	}
@@ -434,22 +369,16 @@ public class ThreadPoolManager
 	 * Executes an Event task sometime in future in another thread.
 	 * @param task the task to execute
 	 */
-	public void executeEvent(Runnable task)
-	{
-		try
-		{
+	public void executeEvent(Runnable task) {
+		try {
 			_eventThreadPool.execute(new RunnableWrapper(task));
-		}
-		catch (RejectedExecutionException e)
-		{
+		} catch (RejectedExecutionException e) {
 			/* shutdown, ignore */
 		}
 	}
 	
-	public String[] getStats()
-	{
-		return new String[]
-		{
+	public String[] getStats() {
+		return new String[] {
 			"STP:",
 			" + Effects:",
 			" |- ActiveThreads:   " + _effectsScheduledThreadPool.getActiveCount(),
@@ -522,39 +451,33 @@ public class ThreadPoolManager
 		};
 	}
 	
-	private static class PriorityThreadFactory implements ThreadFactory
-	{
+	private static class PriorityThreadFactory implements ThreadFactory {
 		private final int _prio;
 		private final String _name;
 		private final AtomicInteger _threadNumber = new AtomicInteger(1);
 		private final ThreadGroup _group;
 		
-		public PriorityThreadFactory(String name, int prio)
-		{
+		public PriorityThreadFactory(String name, int prio) {
 			_prio = prio;
 			_name = name;
 			_group = new ThreadGroup(_name);
 		}
 		
 		@Override
-		public Thread newThread(Runnable r)
-		{
+		public Thread newThread(Runnable r) {
 			Thread t = new Thread(_group, r, _name + "-" + _threadNumber.getAndIncrement());
 			t.setPriority(_prio);
 			return t;
 		}
 		
-		public ThreadGroup getGroup()
-		{
+		public ThreadGroup getGroup() {
 			return _group;
 		}
 	}
 	
-	public void shutdown()
-	{
+	public void shutdown() {
 		_shutdown = true;
-		try
-		{
+		try {
 			_effectsScheduledThreadPool.awaitTermination(1, TimeUnit.SECONDS);
 			_generalScheduledThreadPool.awaitTermination(1, TimeUnit.SECONDS);
 			_generalPacketsThreadPool.awaitTermination(1, TimeUnit.SECONDS);
@@ -569,20 +492,16 @@ public class ThreadPoolManager
 			_eventThreadPool.shutdown();
 			LOG.info("All ThreadPools are now stopped");
 			
-		}
-		catch (InterruptedException e)
-		{
+		} catch (InterruptedException e) {
 			LOG.warn("There has been a problem shuting down the thread pool manager!", e);
 		}
 	}
 	
-	public boolean isShutdown()
-	{
+	public boolean isShutdown() {
 		return _shutdown;
 	}
 	
-	public void purge()
-	{
+	public void purge() {
 		_effectsScheduledThreadPool.purge();
 		_generalScheduledThreadPool.purge();
 		_aiScheduledThreadPool.purge();
@@ -593,27 +512,22 @@ public class ThreadPoolManager
 		_eventThreadPool.purge();
 	}
 	
-	public String getPacketStats()
-	{
+	public String getPacketStats() {
 		final StringBuilder sb = new StringBuilder(1000);
 		ThreadFactory tf = _generalPacketsThreadPool.getThreadFactory();
-		if (tf instanceof PriorityThreadFactory)
-		{
+		if (tf instanceof PriorityThreadFactory) {
 			PriorityThreadFactory ptf = (PriorityThreadFactory) tf;
 			int count = ptf.getGroup().activeCount();
 			Thread[] threads = new Thread[count + 2];
 			ptf.getGroup().enumerate(threads);
 			StringUtil.append(sb, "General Packet Thread Pool:" + Config.EOL + "Tasks in the queue: ", String.valueOf(_generalPacketsThreadPool.getQueue().size()), Config.EOL + "Showing threads stack trace:" + Config.EOL + "There should be ", String.valueOf(count), " Threads" + Config.EOL);
-			for (Thread t : threads)
-			{
-				if (t == null)
-				{
+			for (Thread t : threads) {
+				if (t == null) {
 					continue;
 				}
 				
 				StringUtil.append(sb, t.getName(), Config.EOL);
-				for (StackTraceElement ste : t.getStackTrace())
-				{
+				for (StackTraceElement ste : t.getStackTrace()) {
 					StringUtil.append(sb, ste.toString(), Config.EOL);
 				}
 			}
@@ -624,30 +538,25 @@ public class ThreadPoolManager
 		return sb.toString();
 	}
 	
-	public String getIOPacketStats()
-	{
+	public String getIOPacketStats() {
 		final StringBuilder sb = new StringBuilder(1000);
 		ThreadFactory tf = _ioPacketsThreadPool.getThreadFactory();
 		
-		if (tf instanceof PriorityThreadFactory)
-		{
+		if (tf instanceof PriorityThreadFactory) {
 			PriorityThreadFactory ptf = (PriorityThreadFactory) tf;
 			int count = ptf.getGroup().activeCount();
 			Thread[] threads = new Thread[count + 2];
 			ptf.getGroup().enumerate(threads);
 			StringUtil.append(sb, "I/O Packet Thread Pool:" + Config.EOL + "Tasks in the queue: ", String.valueOf(_ioPacketsThreadPool.getQueue().size()), Config.EOL + "Showing threads stack trace:" + Config.EOL + "There should be ", String.valueOf(count), " Threads" + Config.EOL);
 			
-			for (Thread t : threads)
-			{
-				if (t == null)
-				{
+			for (Thread t : threads) {
+				if (t == null) {
 					continue;
 				}
 				
 				StringUtil.append(sb, t.getName(), Config.EOL);
 				
-				for (StackTraceElement ste : t.getStackTrace())
-				{
+				for (StackTraceElement ste : t.getStackTrace()) {
 					StringUtil.append(sb, ste.toString(), Config.EOL);
 				}
 			}
@@ -658,30 +567,25 @@ public class ThreadPoolManager
 		return sb.toString();
 	}
 	
-	public String getGeneralStats()
-	{
+	public String getGeneralStats() {
 		final StringBuilder sb = new StringBuilder(1000);
 		ThreadFactory tf = _generalThreadPool.getThreadFactory();
 		
-		if (tf instanceof PriorityThreadFactory)
-		{
+		if (tf instanceof PriorityThreadFactory) {
 			PriorityThreadFactory ptf = (PriorityThreadFactory) tf;
 			int count = ptf.getGroup().activeCount();
 			Thread[] threads = new Thread[count + 2];
 			ptf.getGroup().enumerate(threads);
 			StringUtil.append(sb, "General Thread Pool:" + Config.EOL + "Tasks in the queue: ", String.valueOf(_generalThreadPool.getQueue().size()), Config.EOL + "Showing threads stack trace:" + Config.EOL + "There should be ", String.valueOf(count), " Threads" + Config.EOL);
 			
-			for (Thread t : threads)
-			{
-				if (t == null)
-				{
+			for (Thread t : threads) {
+				if (t == null) {
 					continue;
 				}
 				
 				StringUtil.append(sb, t.getName(), Config.EOL);
 				
-				for (StackTraceElement ste : t.getStackTrace())
-				{
+				for (StackTraceElement ste : t.getStackTrace()) {
 					StringUtil.append(sb, ste.toString(), Config.EOL);
 				}
 			}
@@ -692,8 +596,7 @@ public class ThreadPoolManager
 		return sb.toString();
 	}
 	
-	protected class PurgeTask implements Runnable
-	{
+	protected class PurgeTask implements Runnable {
 		private final ScheduledThreadPoolExecutor _effectsScheduled;
 		
 		private final ScheduledThreadPoolExecutor _generalScheduled;
@@ -703,8 +606,7 @@ public class ThreadPoolManager
 		private final ThreadPoolExecutor _eventScheduled;
 		
 		PurgeTask(ScheduledThreadPoolExecutor effectsScheduledThreadPool, ScheduledThreadPoolExecutor generalScheduledThreadPool, //
-			ScheduledThreadPoolExecutor aiScheduledThreadPool, ThreadPoolExecutor eventScheduledThreadPool)
-		{
+			ScheduledThreadPoolExecutor aiScheduledThreadPool, ThreadPoolExecutor eventScheduledThreadPool) {
 			_effectsScheduled = effectsScheduledThreadPool;
 			_generalScheduled = generalScheduledThreadPool;
 			_aiScheduled = aiScheduledThreadPool;
@@ -712,8 +614,7 @@ public class ThreadPoolManager
 		}
 		
 		@Override
-		public void run()
-		{
+		public void run() {
 			_effectsScheduled.purge();
 			_generalScheduled.purge();
 			_aiScheduled.purge();
@@ -721,8 +622,7 @@ public class ThreadPoolManager
 		}
 	}
 	
-	private static class SingletonHolder
-	{
+	private static class SingletonHolder {
 		protected static final ThreadPoolManager _instance = new ThreadPoolManager();
 	}
 }

+ 96 - 200
src/main/java/com/l2jserver/gameserver/ai/AbstractAI.java

@@ -50,8 +50,7 @@ import com.l2jserver.gameserver.taskmanager.AttackStanceTaskManager;
  * AbastractAI :<br>
  * <li>L2CharacterAI</li>
  */
-public abstract class AbstractAI implements Ctrl
-{
+public abstract class AbstractAI implements Ctrl {
 	protected static final Logger LOG = LoggerFactory.getLogger(AbstractAI.class);
 	
 	private NextAction _nextAction;
@@ -59,60 +58,47 @@ public abstract class AbstractAI implements Ctrl
 	/**
 	 * @return the _nextAction
 	 */
-	public NextAction getNextAction()
-	{
+	public NextAction getNextAction() {
 		return _nextAction;
 	}
 	
 	/**
 	 * @param nextAction the next action to set.
 	 */
-	public void setNextAction(NextAction nextAction)
-	{
+	public void setNextAction(NextAction nextAction) {
 		_nextAction = nextAction;
 	}
 	
-	private class FollowTask implements Runnable
-	{
+	private class FollowTask implements Runnable {
 		protected int _range = 70;
 		
-		public FollowTask()
-		{
+		public FollowTask() {
 		}
 		
-		public FollowTask(int range)
-		{
+		public FollowTask(int range) {
 			_range = range;
 		}
 		
 		@Override
-		public void run()
-		{
-			try
-			{
-				if (_followTask == null)
-				{
+		public void run() {
+			try {
+				if (_followTask == null) {
 					return;
 				}
 				
 				L2Character followTarget = _followTarget; // copy to prevent NPE
-				if (followTarget == null)
-				{
-					if (_actor instanceof L2Summon)
-					{
+				if (followTarget == null) {
+					if (_actor instanceof L2Summon) {
 						((L2Summon) _actor).setFollowStatus(false);
 					}
 					setIntention(AI_INTENTION_IDLE);
 					return;
 				}
 				
-				if (!_actor.isInsideRadius(followTarget, _range, true, false))
-				{
-					if (!_actor.isInsideRadius(followTarget, 3000, true, false))
-					{
+				if (!_actor.isInsideRadius(followTarget, _range, true, false)) {
+					if (!_actor.isInsideRadius(followTarget, 3000, true, false)) {
 						// if the target is too far (maybe also teleported)
-						if (_actor instanceof L2Summon)
-						{
+						if (_actor instanceof L2Summon) {
 							((L2Summon) _actor).setFollowStatus(false);
 						}
 						
@@ -122,9 +108,7 @@ public abstract class AbstractAI implements Ctrl
 					
 					moveToPawn(followTarget, _range);
 				}
-			}
-			catch (Exception e)
-			{
+			} catch (Exception e) {
 				LOG.warn("{}: There has been a problem running the follow task!", getClass().getSimpleName(), e);
 			}
 		}
@@ -167,8 +151,7 @@ public abstract class AbstractAI implements Ctrl
 	 * Constructor of AbstractAI.
 	 * @param creature the creature
 	 */
-	protected AbstractAI(L2Character creature)
-	{
+	protected AbstractAI(L2Character creature) {
 		_actor = creature;
 	}
 	
@@ -176,8 +159,7 @@ public abstract class AbstractAI implements Ctrl
 	 * @return the L2Character managed by this Accessor AI.
 	 */
 	@Override
-	public L2Character getActor()
-	{
+	public L2Character getActor() {
 		return _actor;
 	}
 	
@@ -185,26 +167,22 @@ public abstract class AbstractAI implements Ctrl
 	 * @return the current Intention.
 	 */
 	@Override
-	public CtrlIntention getIntention()
-	{
+	public CtrlIntention getIntention() {
 		return _intention;
 	}
 	
-	protected void setCastTarget(L2Character target)
-	{
+	protected void setCastTarget(L2Character target) {
 		_castTarget = target;
 	}
 	
 	/**
 	 * @return the current cast target.
 	 */
-	public L2Character getCastTarget()
-	{
+	public L2Character getCastTarget() {
 		return _castTarget;
 	}
 	
-	protected void setAttackTarget(L2Character target)
-	{
+	protected void setAttackTarget(L2Character target) {
 		_attackTarget = target;
 	}
 	
@@ -212,8 +190,7 @@ public abstract class AbstractAI implements Ctrl
 	 * @return current attack target.
 	 */
 	@Override
-	public L2Character getAttackTarget()
-	{
+	public L2Character getAttackTarget() {
 		return _attackTarget;
 	}
 	
@@ -227,8 +204,7 @@ public abstract class AbstractAI implements Ctrl
 	 * @param arg0 The first parameter of the Intention
 	 * @param arg1 The second parameter of the Intention
 	 */
-	synchronized void changeIntention(CtrlIntention intention, Object arg0, Object arg1)
-	{
+	synchronized void changeIntention(CtrlIntention intention, Object arg0, Object arg1) {
 		_intention = intention;
 		_intentionArg0 = arg0;
 		_intentionArg1 = arg1;
@@ -240,8 +216,7 @@ public abstract class AbstractAI implements Ctrl
 	 * @param intention The new Intention to set to the AI
 	 */
 	@Override
-	public final void setIntention(CtrlIntention intention)
-	{
+	public final void setIntention(CtrlIntention intention) {
 		setIntention(intention, null, null);
 	}
 	
@@ -252,23 +227,19 @@ public abstract class AbstractAI implements Ctrl
 	 * @param arg0 The first parameter of the Intention (optional target)
 	 */
 	@Override
-	public final void setIntention(CtrlIntention intention, Object arg0)
-	{
+	public final void setIntention(CtrlIntention intention, Object arg0) {
 		setIntention(intention, arg0, null);
 	}
 	
 	@Override
-	public final void setIntention(CtrlIntention intention, Object arg0, Object arg1)
-	{
+	public final void setIntention(CtrlIntention intention, Object arg0, Object arg1) {
 		// Stop the follow mode if necessary
-		if ((intention != AI_INTENTION_FOLLOW) && (intention != AI_INTENTION_ATTACK))
-		{
+		if ((intention != AI_INTENTION_FOLLOW) && (intention != AI_INTENTION_ATTACK)) {
 			stopFollow();
 		}
 		
 		// Launch the onIntention method of the L2CharacterAI corresponding to the new Intention
-		switch (intention)
-		{
+		switch (intention) {
 			case AI_INTENTION_IDLE:
 				onIntentionIdle();
 				break;
@@ -299,8 +270,7 @@ public abstract class AbstractAI implements Ctrl
 		}
 		
 		// If do move or follow intention drop next action.
-		if ((_nextAction != null) && _nextAction.getIntentions().contains(intention))
-		{
+		if ((_nextAction != null) && _nextAction.getIntentions().contains(intention)) {
 			_nextAction = null;
 		}
 	}
@@ -311,8 +281,7 @@ public abstract class AbstractAI implements Ctrl
 	 * @param evt The event whose the AI must be notified
 	 */
 	@Override
-	public final void notifyEvent(CtrlEvent evt)
-	{
+	public final void notifyEvent(CtrlEvent evt) {
 		notifyEvent(evt, null, null);
 	}
 	
@@ -322,8 +291,7 @@ public abstract class AbstractAI implements Ctrl
 	 * @param arg0 The first parameter of the Event (optional target)
 	 */
 	@Override
-	public final void notifyEvent(CtrlEvent evt, Object arg0)
-	{
+	public final void notifyEvent(CtrlEvent evt, Object arg0) {
 		notifyEvent(evt, arg0, null);
 	}
 	
@@ -332,15 +300,12 @@ public abstract class AbstractAI implements Ctrl
 	 * @param evt The event whose the AI must be notified
 	 */
 	@Override
-	public final void notifyEvent(CtrlEvent evt, Object... args)
-	{
-		if ((!_actor.isVisible() && !_actor.isTeleporting()) || !_actor.hasAI())
-		{
+	public final void notifyEvent(CtrlEvent evt, Object... args) {
+		if ((!_actor.isVisible() && !_actor.isTeleporting()) || !_actor.hasAI()) {
 			return;
 		}
 		
-		switch (evt)
-		{
+		switch (evt) {
 			case EVT_THINK:
 				onEvtThink();
 				break;
@@ -372,8 +337,7 @@ public abstract class AbstractAI implements Ctrl
 				onEvtEvaded((L2Character) args[0]);
 				break;
 			case EVT_READY_TO_ACT:
-				if (!_actor.isCastingNow() && !_actor.isCastingSimultaneouslyNow())
-				{
+				if (!_actor.isCastingNow() && !_actor.isCastingSimultaneouslyNow()) {
 					onEvtReadyToAct();
 				}
 				break;
@@ -382,15 +346,13 @@ public abstract class AbstractAI implements Ctrl
 				break;
 			case EVT_ARRIVED:
 				// happens e.g. from stopmove but we don't process it if we're casting
-				if (!_actor.isCastingNow() && !_actor.isCastingSimultaneouslyNow())
-				{
+				if (!_actor.isCastingNow() && !_actor.isCastingSimultaneouslyNow()) {
 					onEvtArrived();
 				}
 				break;
 			case EVT_ARRIVED_REVALIDATE:
 				// this is disregarded if the char is not moving any more
-				if (_actor.isMoving())
-				{
+				if (_actor.isMoving()) {
 					onEvtArrivedRevalidate();
 				}
 				break;
@@ -412,16 +374,14 @@ public abstract class AbstractAI implements Ctrl
 			case EVT_FINISH_CASTING:
 				onEvtFinishCasting();
 				break;
-			case EVT_AFRAID:
-			{
+			case EVT_AFRAID: {
 				onEvtAfraid((L2Character) args[0], (Boolean) args[1]);
 				break;
 			}
 		}
 		
 		// Do next action.
-		if ((_nextAction != null) && _nextAction.getEvents().contains(evt))
-		{
+		if ((_nextAction != null) && _nextAction.getEvents().contains(evt)) {
 			_nextAction.doAction();
 		}
 	}
@@ -489,10 +449,8 @@ public abstract class AbstractAI implements Ctrl
 	/**
 	 * Cancel action client side by sending Server->Client packet ActionFailed to the L2PcInstance actor. <FONT COLOR=#FF0000><B> <U>Caution</U> : Low level function, used by AI subclasses</B></FONT>
 	 */
-	protected void clientActionFailed()
-	{
-		if (_actor instanceof L2PcInstance)
-		{
+	protected void clientActionFailed() {
+		if (_actor instanceof L2PcInstance) {
 			_actor.sendPacket(ActionFailed.STATIC_PACKET);
 		}
 	}
@@ -503,34 +461,25 @@ public abstract class AbstractAI implements Ctrl
 	 * @param pawn
 	 * @param offset
 	 */
-	protected void moveToPawn(L2Object pawn, int offset)
-	{
+	protected void moveToPawn(L2Object pawn, int offset) {
 		// Check if actor can move
-		if (!_actor.isMovementDisabled())
-		{
-			if (offset < 10)
-			{
+		if (!_actor.isMovementDisabled()) {
+			if (offset < 10) {
 				offset = 10;
 			}
 			
 			// prevent possible extra calls to this function (there is none?),
 			// also don't send movetopawn packets too often
 			boolean sendPacket = true;
-			if (_clientMoving && (_target == pawn))
-			{
-				if (_clientMovingToPawnOffset == offset)
-				{
-					if (GameTimeController.getInstance().getGameTicks() < _moveToPawnTimeout)
-					{
+			if (_clientMoving && (_target == pawn)) {
+				if (_clientMovingToPawnOffset == offset) {
+					if (GameTimeController.getInstance().getGameTicks() < _moveToPawnTimeout) {
 						return;
 					}
 					sendPacket = false;
-				}
-				else if (_actor.isOnGeodataPath())
-				{
+				} else if (_actor.isOnGeodataPath()) {
 					// minimum time to calculate new route is 2 seconds
-					if (GameTimeController.getInstance().getGameTicks() < (_moveToPawnTimeout + 10))
-					{
+					if (GameTimeController.getInstance().getGameTicks() < (_moveToPawnTimeout + 10)) {
 						return;
 					}
 				}
@@ -543,40 +492,30 @@ public abstract class AbstractAI implements Ctrl
 			_moveToPawnTimeout = GameTimeController.getInstance().getGameTicks();
 			_moveToPawnTimeout += 1000 / GameTimeController.MILLIS_IN_TICK;
 			
-			if (pawn == null)
-			{
+			if (pawn == null) {
 				return;
 			}
 			
 			// Calculate movement data for a move to location action and add the actor to movingObjects of GameTimeController
 			_actor.moveToLocation(pawn.getX(), pawn.getY(), pawn.getZ(), offset);
 			
-			if (!_actor.isMoving())
-			{
+			if (!_actor.isMoving()) {
 				clientActionFailed();
 				return;
 			}
 			
 			// Send a Server->Client packet MoveToPawn/CharMoveToLocation to the actor and all L2PcInstance in its _knownPlayers
-			if (pawn instanceof L2Character)
-			{
-				if (_actor.isOnGeodataPath())
-				{
+			if (pawn instanceof L2Character) {
+				if (_actor.isOnGeodataPath()) {
 					_actor.broadcastPacket(new MoveToLocation(_actor));
 					_clientMovingToPawnOffset = 0;
-				}
-				else if (sendPacket)
-				{
+				} else if (sendPacket) {
 					_actor.broadcastPacket(new MoveToPawn(_actor, (L2Character) pawn, offset));
 				}
-			}
-			else
-			{
+			} else {
 				_actor.broadcastPacket(new MoveToLocation(_actor));
 			}
-		}
-		else
-		{
+		} else {
 			clientActionFailed();
 		}
 	}
@@ -588,11 +527,9 @@ public abstract class AbstractAI implements Ctrl
 	 * @param y
 	 * @param z
 	 */
-	protected void moveTo(int x, int y, int z)
-	{
+	protected void moveTo(int x, int y, int z) {
 		// Chek if actor can move
-		if (!_actor.isMovementDisabled())
-		{
+		if (!_actor.isMovementDisabled()) {
 			// Set AI movement data
 			_clientMoving = true;
 			_clientMovingToPawnOffset = 0;
@@ -603,9 +540,7 @@ public abstract class AbstractAI implements Ctrl
 			// Send a Server->Client packet CharMoveToLocation to the actor and all L2PcInstance in its _knownPlayers
 			_actor.broadcastPacket(new MoveToLocation(_actor));
 			
-		}
-		else
-		{
+		} else {
 			clientActionFailed();
 		}
 	}
@@ -615,25 +550,21 @@ public abstract class AbstractAI implements Ctrl
 	 * <FONT COLOR=#FF0000><B> <U>Caution</U> : Low level function, used by AI subclasses</B></FONT>
 	 * @param loc
 	 */
-	protected void clientStopMoving(Location loc)
-	{
+	protected void clientStopMoving(Location loc) {
 		// Stop movement of the L2Character
-		if (_actor.isMoving())
-		{
+		if (_actor.isMoving()) {
 			_actor.stopMove(loc);
 		}
 		
 		_clientMovingToPawnOffset = 0;
 		
-		if (_clientMoving || (loc != null))
-		{
+		if (_clientMoving || (loc != null)) {
 			_clientMoving = false;
 			
 			// Send a Server->Client packet StopMove to the actor and all L2PcInstance in its _knownPlayers
 			_actor.broadcastPacket(new StopMove(_actor));
 			
-			if (loc != null)
-			{
+			if (loc != null) {
 				// Send a Server->Client packet StopRotation to the actor and all L2PcInstance in its _knownPlayers
 				_actor.broadcastPacket(new StopRotation(_actor.getObjectId(), loc.getHeading(), 0));
 			}
@@ -643,8 +574,7 @@ public abstract class AbstractAI implements Ctrl
 	/**
 	 * Client has already arrived to target, no need to force StopMove packet.
 	 */
-	protected void clientStoppedMoving()
-	{
+	protected void clientStoppedMoving() {
 		if (_clientMovingToPawnOffset > 0) // movetoPawn needs to be stopped
 		{
 			_clientMovingToPawnOffset = 0;
@@ -653,18 +583,14 @@ public abstract class AbstractAI implements Ctrl
 		_clientMoving = false;
 	}
 	
-	public boolean isAutoAttacking()
-	{
+	public boolean isAutoAttacking() {
 		return _clientAutoAttacking;
 	}
 	
-	public void setAutoAttacking(boolean isAutoAttacking)
-	{
-		if (_actor instanceof L2Summon)
-		{
+	public void setAutoAttacking(boolean isAutoAttacking) {
+		if (_actor instanceof L2Summon) {
 			L2Summon summon = (L2Summon) _actor;
-			if (summon.getOwner() != null)
-			{
+			if (summon.getOwner() != null) {
 				summon.getOwner().getAI().setAutoAttacking(isAutoAttacking);
 			}
 			return;
@@ -676,21 +602,16 @@ public abstract class AbstractAI implements Ctrl
 	 * Start the actor Auto Attack client side by sending Server->Client packet AutoAttackStart <I>(broadcast)</I>.<br>
 	 * <FONT COLOR=#FF0000><B> <U>Caution</U> : Low level function, used by AI subclasses</B></FONT>
 	 */
-	public void clientStartAutoAttack()
-	{
-		if (_actor instanceof L2Summon)
-		{
+	public void clientStartAutoAttack() {
+		if (_actor instanceof L2Summon) {
 			L2Summon summon = (L2Summon) _actor;
-			if (summon.getOwner() != null)
-			{
+			if (summon.getOwner() != null) {
 				summon.getOwner().getAI().clientStartAutoAttack();
 			}
 			return;
 		}
-		if (!isAutoAttacking())
-		{
-			if (_actor.isPlayer() && _actor.hasSummon())
-			{
+		if (!isAutoAttacking()) {
+			if (_actor.isPlayer() && _actor.hasSummon()) {
 				_actor.getSummon().broadcastPacket(new AutoAttackStart(_actor.getSummon().getObjectId()));
 			}
 			// Send a Server->Client packet AutoAttackStart to the actor and all L2PcInstance in its _knownPlayers
@@ -704,26 +625,19 @@ public abstract class AbstractAI implements Ctrl
 	 * Stop the actor auto-attack client side by sending Server->Client packet AutoAttackStop <I>(broadcast)</I>.<br>
 	 * <FONT COLOR=#FF0000><B> <U>Caution</U> : Low level function, used by AI subclasses</B></FONT>
 	 */
-	public void clientStopAutoAttack()
-	{
-		if (_actor instanceof L2Summon)
-		{
+	public void clientStopAutoAttack() {
+		if (_actor instanceof L2Summon) {
 			L2Summon summon = (L2Summon) _actor;
-			if (summon.getOwner() != null)
-			{
+			if (summon.getOwner() != null) {
 				summon.getOwner().getAI().clientStopAutoAttack();
 			}
 			return;
 		}
-		if (_actor instanceof L2PcInstance)
-		{
-			if (!AttackStanceTaskManager.getInstance().hasAttackStanceTask(_actor) && isAutoAttacking())
-			{
+		if (_actor instanceof L2PcInstance) {
+			if (!AttackStanceTaskManager.getInstance().hasAttackStanceTask(_actor) && isAutoAttacking()) {
 				AttackStanceTaskManager.getInstance().addAttackStanceTask(_actor);
 			}
-		}
-		else if (isAutoAttacking())
-		{
+		} else if (isAutoAttacking()) {
 			_actor.broadcastPacket(new AutoAttackStop(_actor.getObjectId()));
 			setAutoAttacking(false);
 		}
@@ -733,8 +647,7 @@ public abstract class AbstractAI implements Ctrl
 	 * Kill the actor client side by sending Server->Client packet AutoAttackStop, StopMove/StopRotation, Die <I>(broadcast)</I>.<br>
 	 * <FONT COLOR=#FF0000><B> <U>Caution</U> : Low level function, used by AI subclasses</B></FONT>
 	 */
-	protected void clientNotifyDead()
-	{
+	protected void clientNotifyDead() {
 		// Send a Server->Client packet Die to the actor and all L2PcInstance in its _knownPlayers
 		Die msg = new Die(_actor);
 		_actor.broadcastPacket(msg);
@@ -754,19 +667,13 @@ public abstract class AbstractAI implements Ctrl
 	 * <FONT COLOR=#FF0000><B> <U>Caution</U> : Low level function, used by AI subclasses</B></FONT>
 	 * @param player The L2PcIstance to notify with state of this L2Character
 	 */
-	public void describeStateToPlayer(L2PcInstance player)
-	{
-		if (getActor().isVisibleFor(player))
-		{
-			if (_clientMoving)
-			{
-				if ((_clientMovingToPawnOffset != 0) && (_followTarget != null))
-				{
+	public void describeStateToPlayer(L2PcInstance player) {
+		if (getActor().isVisibleFor(player)) {
+			if (_clientMoving) {
+				if ((_clientMovingToPawnOffset != 0) && (_followTarget != null)) {
 					// Send a Server->Client packet MoveToPawn to the actor and all L2PcInstance in its _knownPlayers
 					player.sendPacket(new MoveToPawn(_actor, _followTarget, _clientMovingToPawnOffset));
-				}
-				else
-				{
+				} else {
 					// Send a Server->Client packet CharMoveToLocation to the actor and all L2PcInstance in its _knownPlayers
 					player.sendPacket(new MoveToLocation(_actor));
 				}
@@ -778,10 +685,8 @@ public abstract class AbstractAI implements Ctrl
 	 * Create and Launch an AI Follow Task to execute every 1s.
 	 * @param target The L2Character to follow
 	 */
-	public synchronized void startFollow(L2Character target)
-	{
-		if (_followTask != null)
-		{
+	public synchronized void startFollow(L2Character target) {
+		if (_followTask != null) {
 			_followTask.cancel(false);
 			_followTask = null;
 		}
@@ -796,10 +701,8 @@ public abstract class AbstractAI implements Ctrl
 	 * @param target The L2Character to follow
 	 * @param range
 	 */
-	public synchronized void startFollow(L2Character target, int range)
-	{
-		if (_followTask != null)
-		{
+	public synchronized void startFollow(L2Character target, int range) {
+		if (_followTask != null) {
 			_followTask.cancel(false);
 			_followTask = null;
 		}
@@ -811,10 +714,8 @@ public abstract class AbstractAI implements Ctrl
 	/**
 	 * Stop an AI Follow Task.
 	 */
-	public synchronized void stopFollow()
-	{
-		if (_followTask != null)
-		{
+	public synchronized void stopFollow() {
+		if (_followTask != null) {
 			// Stop the Follow Task
 			_followTask.cancel(false);
 			_followTask = null;
@@ -822,32 +723,27 @@ public abstract class AbstractAI implements Ctrl
 		_followTarget = null;
 	}
 	
-	protected L2Character getFollowTarget()
-	{
+	protected L2Character getFollowTarget() {
 		return _followTarget;
 	}
 	
-	protected L2Object getTarget()
-	{
+	protected L2Object getTarget() {
 		return _target;
 	}
 	
-	protected void setTarget(L2Object target)
-	{
+	protected void setTarget(L2Object target) {
 		_target = target;
 	}
 	
 	/**
 	 * Stop all Ai tasks and futures.
 	 */
-	public void stopAITask()
-	{
+	public void stopAITask() {
 		stopFollow();
 	}
 	
 	@Override
-	public String toString()
-	{
+	public String toString() {
 		return "Actor: " + _actor;
 	}
 }

+ 1 - 2
src/main/java/com/l2jserver/gameserver/ai/Ctrl.java

@@ -42,8 +42,7 @@ import com.l2jserver.gameserver.model.actor.L2Character;
  * and required network messages are sent to client's, i.e. if we have incoming event that character's movement was disabled, it causes changing if its behavior,<br>
  * and if client's state for the character is "moving" we send messages to clients to stop the avatar/mob.
  */
-public interface Ctrl
-{
+public interface Ctrl {
 	/**
 	 * Gets the actor.
 	 * @return the actor

+ 1 - 2
src/main/java/com/l2jserver/gameserver/ai/CtrlEvent.java

@@ -21,8 +21,7 @@ package com.l2jserver.gameserver.ai;
 /**
  * This class contains an enum of each possibles events that can happen on an AI character.
  */
-public enum CtrlEvent
-{
+public enum CtrlEvent {
 	/**
 	 * Something has changed, usually a previous step has being completed or maybe was completed, the AI must thing on next action.
 	 */

+ 1 - 2
src/main/java/com/l2jserver/gameserver/ai/CtrlIntention.java

@@ -21,8 +21,7 @@ package com.l2jserver.gameserver.ai;
 /**
  * Enumeration of generic intentions of an NPC/PC, an intention may require several steps to be completed.
  */
-public enum CtrlIntention
-{
+public enum CtrlIntention {
 	/** Do nothing, disconnect AI of NPC if no players around */
 	AI_INTENTION_IDLE,
 	/** Alerted state without goal : scan attackable targets, random walk, etc */

+ 10 - 20
src/main/java/com/l2jserver/gameserver/ai/L2AirShipAI.java

@@ -27,18 +27,14 @@ import com.l2jserver.gameserver.network.serverpackets.ExStopMoveAirShip;
 /**
  * @author DS
  */
-public class L2AirShipAI extends L2VehicleAI
-{
-	public L2AirShipAI(L2AirShipInstance creature)
-	{
+public class L2AirShipAI extends L2VehicleAI {
+	public L2AirShipAI(L2AirShipInstance creature) {
 		super(creature);
 	}
 	
 	@Override
-	protected void moveTo(int x, int y, int z)
-	{
-		if (!_actor.isMovementDisabled())
-		{
+	protected void moveTo(int x, int y, int z) {
+		if (!_actor.isMovementDisabled()) {
 			_clientMoving = true;
 			_actor.moveToLocation(x, y, z, 0);
 			_actor.broadcastPacket(new ExMoveToLocationAirShip(getActor()));
@@ -46,32 +42,26 @@ public class L2AirShipAI extends L2VehicleAI
 	}
 	
 	@Override
-	protected void clientStopMoving(Location loc)
-	{
-		if (_actor.isMoving())
-		{
+	protected void clientStopMoving(Location loc) {
+		if (_actor.isMoving()) {
 			_actor.stopMove(loc);
 		}
 		
-		if (_clientMoving || (loc != null))
-		{
+		if (_clientMoving || (loc != null)) {
 			_clientMoving = false;
 			_actor.broadcastPacket(new ExStopMoveAirShip(getActor()));
 		}
 	}
 	
 	@Override
-	public void describeStateToPlayer(L2PcInstance player)
-	{
-		if (_clientMoving)
-		{
+	public void describeStateToPlayer(L2PcInstance player) {
+		if (_clientMoving) {
 			player.sendPacket(new ExMoveToLocationAirShip(getActor()));
 		}
 	}
 	
 	@Override
-	public L2AirShipInstance getActor()
-	{
+	public L2AirShipInstance getActor() {
 		return (L2AirShipInstance) _actor;
 	}
 }

File diff ditekan karena terlalu besar
+ 165 - 352
src/main/java/com/l2jserver/gameserver/ai/L2AttackableAI.java


+ 11 - 22
src/main/java/com/l2jserver/gameserver/ai/L2BoatAI.java

@@ -28,20 +28,15 @@ import com.l2jserver.gameserver.network.serverpackets.VehicleStarted;
 /**
  * @author DS
  */
-public class L2BoatAI extends L2VehicleAI
-{
-	public L2BoatAI(L2BoatInstance creature)
-	{
+public class L2BoatAI extends L2VehicleAI {
+	public L2BoatAI(L2BoatInstance creature) {
 		super(creature);
 	}
 	
 	@Override
-	protected void moveTo(int x, int y, int z)
-	{
-		if (!_actor.isMovementDisabled())
-		{
-			if (!_clientMoving)
-			{
+	protected void moveTo(int x, int y, int z) {
+		if (!_actor.isMovementDisabled()) {
+			if (!_clientMoving) {
 				_actor.broadcastPacket(new VehicleStarted(getActor(), 1));
 			}
 			
@@ -52,15 +47,12 @@ public class L2BoatAI extends L2VehicleAI
 	}
 	
 	@Override
-	protected void clientStopMoving(Location loc)
-	{
-		if (_actor.isMoving())
-		{
+	protected void clientStopMoving(Location loc) {
+		if (_actor.isMoving()) {
 			_actor.stopMove(loc);
 		}
 		
-		if (_clientMoving || (loc != null))
-		{
+		if (_clientMoving || (loc != null)) {
 			_clientMoving = false;
 			_actor.broadcastPacket(new VehicleStarted(getActor(), 0));
 			_actor.broadcastPacket(new VehicleInfo(getActor()));
@@ -68,17 +60,14 @@ public class L2BoatAI extends L2VehicleAI
 	}
 	
 	@Override
-	public void describeStateToPlayer(L2PcInstance player)
-	{
-		if (_clientMoving)
-		{
+	public void describeStateToPlayer(L2PcInstance player) {
+		if (_clientMoving) {
 			player.sendPacket(new VehicleDeparture(getActor()));
 		}
 	}
 	
 	@Override
-	public L2BoatInstance getActor()
-	{
+	public L2BoatInstance getActor() {
 		return (L2BoatInstance) _actor;
 	}
 }

File diff ditekan karena terlalu besar
+ 138 - 286
src/main/java/com/l2jserver/gameserver/ai/L2CharacterAI.java


+ 81 - 167
src/main/java/com/l2jserver/gameserver/ai/L2ControllableMobAI.java

@@ -44,8 +44,7 @@ import com.l2jserver.util.Rnd;
  * AI for controllable mobs
  * @author littlecrow
  */
-public final class L2ControllableMobAI extends L2AttackableAI
-{
+public final class L2ControllableMobAI extends L2AttackableAI {
 	public static final int AI_IDLE = 1;
 	public static final int AI_NORMAL = 2;
 	public static final int AI_FORCEATTACK = 3;
@@ -61,18 +60,15 @@ public final class L2ControllableMobAI extends L2AttackableAI
 	private L2Character _forcedTarget;
 	private MobGroup _targetGroup;
 	
-	public L2ControllableMobAI(L2ControllableMobInstance creature)
-	{
+	public L2ControllableMobAI(L2ControllableMobInstance creature) {
 		super(creature);
 		setAlternateAI(AI_IDLE);
 	}
 	
-	protected void thinkFollow()
-	{
+	protected void thinkFollow() {
 		L2Attackable me = (L2Attackable) _actor;
 		
-		if (!Util.checkIfInRange(MobGroupTable.FOLLOW_RANGE, me, getForcedTarget(), true))
-		{
+		if (!Util.checkIfInRange(MobGroupTable.FOLLOW_RANGE, me, getForcedTarget(), true)) {
 			int signX = (Rnd.nextInt(2) == 0) ? -1 : 1;
 			int signY = (Rnd.nextInt(2) == 0) ? -1 : 1;
 			int randX = Rnd.nextInt(MobGroupTable.FOLLOW_RANGE);
@@ -83,22 +79,17 @@ public final class L2ControllableMobAI extends L2AttackableAI
 	}
 	
 	@Override
-	protected void onEvtThink()
-	{
-		if (isThinking())
-		{
+	protected void onEvtThink() {
+		if (isThinking()) {
 			return;
 		}
 		
 		setThinking(true);
 		
-		try
-		{
-			switch (getAlternateAI())
-			{
+		try {
+			switch (getAlternateAI()) {
 				case AI_IDLE:
-					if (getIntention() != CtrlIntention.AI_INTENTION_ACTIVE)
-					{
+					if (getIntention() != CtrlIntention.AI_INTENTION_ACTIVE) {
 						setIntention(CtrlIntention.AI_INTENTION_ACTIVE);
 					}
 					break;
@@ -115,49 +106,38 @@ public final class L2ControllableMobAI extends L2AttackableAI
 					thinkAttackGroup();
 					break;
 				default:
-					if (getIntention() == AI_INTENTION_ACTIVE)
-					{
+					if (getIntention() == AI_INTENTION_ACTIVE) {
 						thinkActive();
-					}
-					else if (getIntention() == AI_INTENTION_ATTACK)
-					{
+					} else if (getIntention() == AI_INTENTION_ATTACK) {
 						thinkAttack();
 					}
 					break;
 			}
-		}
-		finally
-		{
+		} finally {
 			setThinking(false);
 		}
 	}
 	
 	@Override
-	protected void thinkCast()
-	{
+	protected void thinkCast() {
 		L2Attackable npc = (L2Attackable) _actor;
-		if ((getAttackTarget() == null) || getAttackTarget().isAlikeDead())
-		{
+		if ((getAttackTarget() == null) || getAttackTarget().isAlikeDead()) {
 			setAttackTarget(findNextRndTarget());
 			clientStopMoving(null);
 		}
 		
-		if (getAttackTarget() == null)
-		{
+		if (getAttackTarget() == null) {
 			return;
 		}
 		
 		npc.setTarget(getAttackTarget());
 		
-		if (!_actor.isMuted())
-		{
+		if (!_actor.isMuted()) {
 			int max_range = 0;
 			// check distant skills
 			
-			for (Skill sk : _actor.getAllSkills())
-			{
-				if (Util.checkIfInRange(sk.getCastRange(), _actor, getAttackTarget(), true) && !_actor.isSkillDisabled(sk) && (_actor.getCurrentMp() > _actor.getStat().getMpConsume2(sk)))
-				{
+			for (Skill sk : _actor.getAllSkills()) {
+				if (Util.checkIfInRange(sk.getCastRange(), _actor, getAttackTarget(), true) && !_actor.isSkillDisabled(sk) && (_actor.getCurrentMp() > _actor.getStat().getMpConsume2(sk))) {
 					_actor.doCast(sk);
 					return;
 				}
@@ -165,8 +145,7 @@ public final class L2ControllableMobAI extends L2AttackableAI
 				max_range = Math.max(max_range, sk.getCastRange());
 			}
 			
-			if (!isNotMoving())
-			{
+			if (!isNotMoving()) {
 				moveToPawn(getAttackTarget(), max_range);
 			}
 			
@@ -174,18 +153,15 @@ public final class L2ControllableMobAI extends L2AttackableAI
 		}
 	}
 	
-	protected void thinkAttackGroup()
-	{
+	protected void thinkAttackGroup() {
 		L2Character target = getForcedTarget();
-		if ((target == null) || target.isAlikeDead())
-		{
+		if ((target == null) || target.isAlikeDead()) {
 			// try to get next group target
 			setForcedTarget(findNextGroupTarget());
 			clientStopMoving(null);
 		}
 		
-		if (target == null)
-		{
+		if (target == null) {
 			return;
 		}
 		
@@ -199,15 +175,12 @@ public final class L2ControllableMobAI extends L2AttackableAI
 		int range = _actor.getPhysicalAttackRange() + _actor.getTemplate().getCollisionRadius() + target.getTemplate().getCollisionRadius();
 		int max_range = range;
 		
-		if (!_actor.isMuted() && (dist2 > ((range + 20) * (range + 20))))
-		{
+		if (!_actor.isMuted() && (dist2 > ((range + 20) * (range + 20)))) {
 			// check distant skills
-			for (Skill sk : _actor.getAllSkills())
-			{
+			for (Skill sk : _actor.getAllSkills()) {
 				int castRange = sk.getCastRange();
 				
-				if (((castRange * castRange) >= dist2) && !_actor.isSkillDisabled(sk) && (_actor.getCurrentMp() > _actor.getStat().getMpConsume2(sk)))
-				{
+				if (((castRange * castRange) >= dist2) && !_actor.isSkillDisabled(sk) && (_actor.getCurrentMp() > _actor.getStat().getMpConsume2(sk))) {
 					_actor.doCast(sk);
 					return;
 				}
@@ -215,8 +188,7 @@ public final class L2ControllableMobAI extends L2AttackableAI
 				max_range = Math.max(max_range, castRange);
 			}
 			
-			if (!isNotMoving())
-			{
+			if (!isNotMoving()) {
 				moveToPawn(target, range);
 			}
 			
@@ -225,10 +197,8 @@ public final class L2ControllableMobAI extends L2AttackableAI
 		_actor.doAttack(target);
 	}
 	
-	protected void thinkForceAttack()
-	{
-		if ((getForcedTarget() == null) || getForcedTarget().isAlikeDead())
-		{
+	protected void thinkForceAttack() {
+		if ((getForcedTarget() == null) || getForcedTarget().isAlikeDead()) {
 			clientStopMoving(null);
 			setIntention(AI_INTENTION_ACTIVE);
 			setAlternateAI(AI_IDLE);
@@ -239,15 +209,12 @@ public final class L2ControllableMobAI extends L2AttackableAI
 		int range = _actor.getPhysicalAttackRange() + _actor.getTemplate().getCollisionRadius() + getForcedTarget().getTemplate().getCollisionRadius();
 		int max_range = range;
 		
-		if (!_actor.isMuted() && (dist2 > ((range + 20) * (range + 20))))
-		{
+		if (!_actor.isMuted() && (dist2 > ((range + 20) * (range + 20)))) {
 			// check distant skills
-			for (Skill sk : _actor.getAllSkills())
-			{
+			for (Skill sk : _actor.getAllSkills()) {
 				int castRange = sk.getCastRange();
 				
-				if (((castRange * castRange) >= dist2) && !_actor.isSkillDisabled(sk) && (_actor.getCurrentMp() > _actor.getStat().getMpConsume2(sk)))
-				{
+				if (((castRange * castRange) >= dist2) && !_actor.isSkillDisabled(sk) && (_actor.getCurrentMp() > _actor.getStat().getMpConsume2(sk))) {
 					_actor.doCast(sk);
 					return;
 				}
@@ -255,8 +222,7 @@ public final class L2ControllableMobAI extends L2AttackableAI
 				max_range = Math.max(max_range, castRange);
 			}
 			
-			if (!isNotMoving())
-			{
+			if (!isNotMoving()) {
 				moveToPawn(getForcedTarget(), _actor.getPhysicalAttackRange()/* range */);
 			}
 			
@@ -267,41 +233,31 @@ public final class L2ControllableMobAI extends L2AttackableAI
 	}
 	
 	@Override
-	protected void thinkAttack()
-	{
-		if ((getAttackTarget() == null) || getAttackTarget().isAlikeDead())
-		{
-			if (getAttackTarget() != null)
-			{
+	protected void thinkAttack() {
+		if ((getAttackTarget() == null) || getAttackTarget().isAlikeDead()) {
+			if (getAttackTarget() != null) {
 				// stop hating
 				L2Attackable npc = (L2Attackable) _actor;
 				npc.stopHating(getAttackTarget());
 			}
 			
 			setIntention(AI_INTENTION_ACTIVE);
-		}
-		else
-		{
+		} else {
 			// notify aggression
-			if (((L2Npc) _actor).getTemplate().getClans() != null)
-			{
+			if (((L2Npc) _actor).getTemplate().getClans() != null) {
 				Collection<L2Object> objs = _actor.getKnownList().getKnownObjects().values();
-				for (L2Object obj : objs)
-				{
-					if (!(obj instanceof L2Npc))
-					{
+				for (L2Object obj : objs) {
+					if (!(obj instanceof L2Npc)) {
 						continue;
 					}
 					
 					L2Npc npc = (L2Npc) obj;
 					
-					if (!npc.isInMyClan((L2Npc) _actor))
-					{
+					if (!npc.isInMyClan((L2Npc) _actor)) {
 						continue;
 					}
 					
-					if (_actor.isInsideRadius(npc, npc.getTemplate().getClanHelpRange(), false, true) && (Math.abs(getAttackTarget().getZ() - npc.getZ()) < 200))
-					{
+					if (_actor.isInsideRadius(npc, npc.getTemplate().getClanHelpRange(), false, true) && (Math.abs(getAttackTarget().getZ() - npc.getZ()) < 200)) {
 						npc.getAI().notifyEvent(CtrlEvent.EVT_AGGRESSION, getAttackTarget(), 1);
 					}
 				}
@@ -312,15 +268,12 @@ public final class L2ControllableMobAI extends L2AttackableAI
 			int range = _actor.getPhysicalAttackRange() + _actor.getTemplate().getCollisionRadius() + getAttackTarget().getTemplate().getCollisionRadius();
 			int max_range = range;
 			
-			if (!_actor.isMuted() && (dist2 > ((range + 20) * (range + 20))))
-			{
+			if (!_actor.isMuted() && (dist2 > ((range + 20) * (range + 20)))) {
 				// check distant skills
-				for (Skill sk : _actor.getAllSkills())
-				{
+				for (Skill sk : _actor.getAllSkills()) {
 					int castRange = sk.getCastRange();
 					
-					if (((castRange * castRange) >= dist2) && !_actor.isSkillDisabled(sk) && (_actor.getCurrentMp() > _actor.getStat().getMpConsume2(sk)))
-					{
+					if (((castRange * castRange) >= dist2) && !_actor.isSkillDisabled(sk) && (_actor.getCurrentMp() > _actor.getStat().getMpConsume2(sk))) {
 						_actor.doCast(sk);
 						return;
 					}
@@ -335,34 +288,26 @@ public final class L2ControllableMobAI extends L2AttackableAI
 			// Force mobs to attack anybody if confused.
 			L2Character hated;
 			
-			if (_actor.isConfused())
-			{
+			if (_actor.isConfused()) {
 				hated = findNextRndTarget();
-			}
-			else
-			{
+			} else {
 				hated = getAttackTarget();
 			}
 			
-			if (hated == null)
-			{
+			if (hated == null) {
 				setIntention(AI_INTENTION_ACTIVE);
 				return;
 			}
 			
-			if (hated != getAttackTarget())
-			{
+			if (hated != getAttackTarget()) {
 				setAttackTarget(hated);
 			}
 			
-			if (!_actor.isMuted() && (Rnd.nextInt(5) == 3))
-			{
-				for (Skill sk : _actor.getAllSkills())
-				{
+			if (!_actor.isMuted() && (Rnd.nextInt(5) == 3)) {
+				for (Skill sk : _actor.getAllSkills()) {
 					int castRange = sk.getCastRange();
 					
-					if (((castRange * castRange) >= dist2) && !_actor.isSkillDisabled(sk) && (_actor.getCurrentMp() < _actor.getStat().getMpConsume2(sk)))
-					{
+					if (((castRange * castRange) >= dist2) && !_actor.isSkillDisabled(sk) && (_actor.getCurrentMp() < _actor.getStat().getMpConsume2(sk))) {
 						_actor.doCast(sk);
 						return;
 					}
@@ -374,162 +319,131 @@ public final class L2ControllableMobAI extends L2AttackableAI
 	}
 	
 	@Override
-	protected void thinkActive()
-	{
+	protected void thinkActive() {
 		setAttackTarget(findNextRndTarget());
 		L2Character hated;
 		
-		if (_actor.isConfused())
-		{
+		if (_actor.isConfused()) {
 			hated = findNextRndTarget();
-		}
-		else
-		{
+		} else {
 			hated = getAttackTarget();
 		}
 		
-		if (hated != null)
-		{
+		if (hated != null) {
 			_actor.setRunning();
 			setIntention(CtrlIntention.AI_INTENTION_ATTACK, hated);
 		}
 	}
 	
-	private boolean checkAutoAttackCondition(L2Character target)
-	{
-		if ((target == null) || (target instanceof L2NpcInstance) || (target instanceof L2DoorInstance))
-		{
+	private boolean checkAutoAttackCondition(L2Character target) {
+		if ((target == null) || (target instanceof L2NpcInstance) || (target instanceof L2DoorInstance)) {
 			return false;
 		}
 		
 		// TODO(Zoey76)[#112]: This check must change if summon fall in L2Npc hierarchy.
-		if (target.isNpc())
-		{
+		if (target.isNpc()) {
 			return false;
 		}
 		
 		// Check if the target isn't invulnerable
-		if (target.isInvul() || target.isAlikeDead())
-		{
+		if (target.isInvul() || target.isAlikeDead()) {
 			return false;
 		}
 		
 		// Spawn protection (only against mobs)
-		if (target.isPlayer() && ((L2PcInstance) target).isSpawnProtected())
-		{
+		if (target.isPlayer() && ((L2PcInstance) target).isSpawnProtected()) {
 			return false;
 		}
 		
 		final L2Attackable me = getActiveChar();
-		if (!me.isInsideRadius(target, me.getAggroRange(), false, false) || (Math.abs(_actor.getZ() - target.getZ()) > 100))
-		{
+		if (!me.isInsideRadius(target, me.getAggroRange(), false, false) || (Math.abs(_actor.getZ() - target.getZ()) > 100)) {
 			return false;
 		}
 		
 		// Check if the target is a L2Playable
-		if (target.isPlayable())
-		{
+		if (target.isPlayable()) {
 			// Check if the target isn't in silent move mode
-			if (((L2Playable) target).isSilentMovingAffected())
-			{
+			if (((L2Playable) target).isSilentMovingAffected()) {
 				return false;
 			}
 		}
 		return me.isAggressive();
 	}
 	
-	private L2Character findNextRndTarget()
-	{
+	private L2Character findNextRndTarget() {
 		final List<L2Character> potentialTarget = _actor.getKnownList().getKnownCharactersInRadius(getActiveChar().getAggroRange()).stream().filter(this::checkAutoAttackCondition).collect(Collectors.toList());
-		if (potentialTarget.isEmpty())
-		{
+		if (potentialTarget.isEmpty()) {
 			return null;
 		}
 		return potentialTarget.get(Rnd.nextInt(potentialTarget.size()));
 	}
 	
-	private L2ControllableMobInstance findNextGroupTarget()
-	{
+	private L2ControllableMobInstance findNextGroupTarget() {
 		return getGroupTarget().getRandomMob();
 	}
 	
-	public int getAlternateAI()
-	{
+	public int getAlternateAI() {
 		return _alternateAI;
 	}
 	
-	public void setAlternateAI(int _alternateai)
-	{
+	public void setAlternateAI(int _alternateai) {
 		_alternateAI = _alternateai;
 	}
 	
-	public void forceAttack(L2Character target)
-	{
+	public void forceAttack(L2Character target) {
 		setAlternateAI(AI_FORCEATTACK);
 		setForcedTarget(target);
 	}
 	
-	public void forceAttackGroup(MobGroup group)
-	{
+	public void forceAttackGroup(MobGroup group) {
 		setForcedTarget(null);
 		setGroupTarget(group);
 		setAlternateAI(AI_ATTACK_GROUP);
 	}
 	
-	public void stop()
-	{
+	public void stop() {
 		setAlternateAI(AI_IDLE);
 		clientStopMoving(null);
 	}
 	
-	public void move(int x, int y, int z)
-	{
+	public void move(int x, int y, int z) {
 		moveTo(x, y, z);
 	}
 	
-	public void follow(L2Character target)
-	{
+	public void follow(L2Character target) {
 		setAlternateAI(AI_FOLLOW);
 		setForcedTarget(target);
 	}
 	
-	public boolean isThinking()
-	{
+	public boolean isThinking() {
 		return _isThinking;
 	}
 	
-	public boolean isNotMoving()
-	{
+	public boolean isNotMoving() {
 		return _isNotMoving;
 	}
 	
-	public void setNotMoving(boolean isNotMoving)
-	{
+	public void setNotMoving(boolean isNotMoving) {
 		_isNotMoving = isNotMoving;
 	}
 	
-	public void setThinking(boolean isThinking)
-	{
+	public void setThinking(boolean isThinking) {
 		_isThinking = isThinking;
 	}
 	
-	private L2Character getForcedTarget()
-	{
+	private L2Character getForcedTarget() {
 		return _forcedTarget;
 	}
 	
-	private MobGroup getGroupTarget()
-	{
+	private MobGroup getGroupTarget() {
 		return _targetGroup;
 	}
 	
-	private void setForcedTarget(L2Character forcedTarget)
-	{
+	private void setForcedTarget(L2Character forcedTarget) {
 		_forcedTarget = forcedTarget;
 	}
 	
-	private void setGroupTarget(MobGroup targetGroup)
-	{
+	private void setGroupTarget(MobGroup targetGroup) {
 		_targetGroup = targetGroup;
 	}
 }

+ 30 - 60
src/main/java/com/l2jserver/gameserver/ai/L2DoorAI.java

@@ -29,147 +29,117 @@ import com.l2jserver.gameserver.model.skills.Skill;
 /**
  * @author mkizub
  */
-public class L2DoorAI extends L2CharacterAI
-{
-	public L2DoorAI(L2DoorInstance creature)
-	{
+public class L2DoorAI extends L2CharacterAI {
+	public L2DoorAI(L2DoorInstance creature) {
 		super(creature);
 	}
 	
 	@Override
-	protected void onIntentionIdle()
-	{
+	protected void onIntentionIdle() {
 	}
 	
 	@Override
-	protected void onIntentionActive()
-	{
+	protected void onIntentionActive() {
 	}
 	
 	@Override
-	protected void onIntentionRest()
-	{
+	protected void onIntentionRest() {
 	}
 	
 	@Override
-	protected void onIntentionAttack(L2Character target)
-	{
+	protected void onIntentionAttack(L2Character target) {
 	}
 	
 	@Override
-	protected void onIntentionCast(Skill skill, L2Object target)
-	{
+	protected void onIntentionCast(Skill skill, L2Object target) {
 	}
 	
 	@Override
-	protected void onIntentionMoveTo(Location destination)
-	{
+	protected void onIntentionMoveTo(Location destination) {
 	}
 	
 	@Override
-	protected void onIntentionFollow(L2Character target)
-	{
+	protected void onIntentionFollow(L2Character target) {
 	}
 	
 	@Override
-	protected void onIntentionPickUp(L2Object item)
-	{
+	protected void onIntentionPickUp(L2Object item) {
 	}
 	
 	@Override
-	protected void onIntentionInteract(L2Object object)
-	{
+	protected void onIntentionInteract(L2Object object) {
 	}
 	
 	@Override
-	protected void onEvtThink()
-	{
+	protected void onEvtThink() {
 	}
 	
 	@Override
-	protected void onEvtAttacked(L2Character attacker)
-	{
+	protected void onEvtAttacked(L2Character attacker) {
 		ThreadPoolManager.getInstance().executeGeneral(new onEventAttackedDoorTask((L2DoorInstance) _actor, attacker));
 	}
 	
 	@Override
-	protected void onEvtAggression(L2Character target, long aggro)
-	{
+	protected void onEvtAggression(L2Character target, long aggro) {
 	}
 	
 	@Override
-	protected void onEvtStunned(L2Character attacker)
-	{
+	protected void onEvtStunned(L2Character attacker) {
 	}
 	
 	@Override
-	protected void onEvtSleeping(L2Character attacker)
-	{
+	protected void onEvtSleeping(L2Character attacker) {
 	}
 	
 	@Override
-	protected void onEvtRooted(L2Character attacker)
-	{
+	protected void onEvtRooted(L2Character attacker) {
 	}
 	
 	@Override
-	protected void onEvtReadyToAct()
-	{
+	protected void onEvtReadyToAct() {
 	}
 	
 	@Override
-	protected void onEvtUserCmd(Object arg0, Object arg1)
-	{
+	protected void onEvtUserCmd(Object arg0, Object arg1) {
 	}
 	
 	@Override
-	protected void onEvtArrived()
-	{
+	protected void onEvtArrived() {
 	}
 	
 	@Override
-	protected void onEvtArrivedRevalidate()
-	{
+	protected void onEvtArrivedRevalidate() {
 	}
 	
 	@Override
-	protected void onEvtArrivedBlocked(Location blocked_at_loc)
-	{
+	protected void onEvtArrivedBlocked(Location blocked_at_loc) {
 	}
 	
 	@Override
-	protected void onEvtForgetObject(L2Object object)
-	{
+	protected void onEvtForgetObject(L2Object object) {
 	}
 	
 	@Override
-	protected void onEvtCancel()
-	{
+	protected void onEvtCancel() {
 	}
 	
 	@Override
-	protected void onEvtDead()
-	{
+	protected void onEvtDead() {
 	}
 	
-	private class onEventAttackedDoorTask implements Runnable
-	{
+	private class onEventAttackedDoorTask implements Runnable {
 		private final L2DoorInstance _door;
 		private final L2Character _attacker;
 		
-		public onEventAttackedDoorTask(L2DoorInstance door, L2Character attacker)
-		{
+		public onEventAttackedDoorTask(L2DoorInstance door, L2Character attacker) {
 			_door = door;
 			_attacker = attacker;
 		}
 		
 		@Override
-		public void run()
-		{
-			for (L2DefenderInstance guard : _door.getKnownDefenders())
-			{
-				if (_actor.isInsideRadius(guard, guard.getTemplate().getClanHelpRange(), false, true) && (Math.abs(_attacker.getZ() - guard.getZ()) < 200))
-				{
+		public void run() {
+			for (L2DefenderInstance guard : _door.getKnownDefenders()) {
+				if (_actor.isInsideRadius(guard, guard.getTemplate().getClanHelpRange(), false, true) && (Math.abs(_attacker.getZ() - guard.getZ()) < 200)) {
 					guard.getAI().notifyEvent(CtrlEvent.EVT_AGGRESSION, _attacker, 15);
 				}
 			}

+ 134 - 283
src/main/java/com/l2jserver/gameserver/ai/L2FortSiegeGuardAI.java

@@ -47,8 +47,7 @@ import com.l2jserver.util.Rnd;
 /**
  * This class manages AI of L2Attackable.
  */
-public class L2FortSiegeGuardAI extends L2CharacterAI implements Runnable
-{
+public class L2FortSiegeGuardAI extends L2CharacterAI implements Runnable {
 	private static final int MAX_ATTACK_TIMEOUT = 300; // int ticks, i.e. 30 seconds
 	
 	/** The L2Attackable AI task executed every 1s (call onEvtThink method) */
@@ -72,8 +71,7 @@ public class L2FortSiegeGuardAI extends L2CharacterAI implements Runnable
 	 * Constructor of L2AttackableAI.
 	 * @param creature the creature
 	 */
-	public L2FortSiegeGuardAI(L2DefenderInstance creature)
-	{
+	public L2FortSiegeGuardAI(L2DefenderInstance creature) {
 		super(creature);
 		_selfAnalysis.init();
 		_attackTimeout = Integer.MAX_VALUE;
@@ -82,8 +80,7 @@ public class L2FortSiegeGuardAI extends L2CharacterAI implements Runnable
 	}
 	
 	@Override
-	public void run()
-	{
+	public void run() {
 		// Launch actions corresponding to the Event Think
 		onEvtThink();
 	}
@@ -122,56 +119,43 @@ public class L2FortSiegeGuardAI extends L2CharacterAI implements Runnable
 	 * @param target The targeted L2Object
 	 * @return True if the target is autoattackable (depends on the actor type).
 	 */
-	private boolean autoAttackCondition(L2Character target)
-	{
+	private boolean autoAttackCondition(L2Character target) {
 		// Check if the target isn't another guard, folk or a door
-		if ((target == null) || (target instanceof L2DefenderInstance) || (target instanceof L2NpcInstance) || (target instanceof L2DoorInstance) || target.isAlikeDead() || (target instanceof L2FortCommanderInstance) || (target instanceof L2Playable))
-		{
+		if ((target == null) || (target instanceof L2DefenderInstance) || (target instanceof L2NpcInstance) || (target instanceof L2DoorInstance) || target.isAlikeDead() || (target instanceof L2FortCommanderInstance) || (target instanceof L2Playable)) {
 			L2PcInstance player = null;
-			if (target instanceof L2PcInstance)
-			{
+			if (target instanceof L2PcInstance) {
 				player = ((L2PcInstance) target);
-			}
-			else if (target instanceof L2Summon)
-			{
+			} else if (target instanceof L2Summon) {
 				player = ((L2Summon) target).getOwner();
 			}
-			if ((player == null) || ((player.getClan() != null) && (player.getClan().getFortId() == ((L2Npc) _actor).getFort().getResidenceId())))
-			{
+			if ((player == null) || ((player.getClan() != null) && (player.getClan().getFortId() == ((L2Npc) _actor).getFort().getResidenceId()))) {
 				return false;
 			}
 		}
 		
 		// Check if the target isn't invulnerable
-		if ((target != null) && target.isInvul())
-		{
+		if ((target != null) && target.isInvul()) {
 			// However EffectInvincible requires to check GMs specially
-			if (target.isPlayer() && target.isGM())
-			{
+			if (target.isPlayer() && target.isGM()) {
 				return false;
 			}
-			if (target.isSummon() && ((L2Summon) target).getOwner().isGM())
-			{
+			if (target.isSummon() && ((L2Summon) target).getOwner().isGM()) {
 				return false;
 			}
 		}
 		
 		// Get the owner if the target is a summon
-		if (target instanceof L2Summon)
-		{
+		if (target instanceof L2Summon) {
 			L2PcInstance owner = ((L2Summon) target).getOwner();
-			if (_actor.isInsideRadius(owner, 1000, true, false))
-			{
+			if (_actor.isInsideRadius(owner, 1000, true, false)) {
 				target = owner;
 			}
 		}
 		
 		// Check if the target is a L2PcInstance
-		if (target instanceof L2Playable)
-		{
+		if (target instanceof L2Playable) {
 			// Check if the target isn't in silent move mode AND too far (>100)
-			if (((L2Playable) target).isSilentMovingAffected() && !_actor.isInsideRadius(target, 250, false, false))
-			{
+			if (((L2Playable) target).isSilentMovingAffected() && !_actor.isInsideRadius(target, 250, false, false)) {
 				return false;
 			}
 		}
@@ -188,36 +172,29 @@ public class L2FortSiegeGuardAI extends L2CharacterAI implements Runnable
 	 * @param arg1 The second parameter of the Intention
 	 */
 	@Override
-	synchronized void changeIntention(CtrlIntention intention, Object arg0, Object arg1)
-	{
+	synchronized void changeIntention(CtrlIntention intention, Object arg0, Object arg1) {
 		LOG.debug("{}: changeIntention({}, {}, {})", getClass().getSimpleName(), intention, arg0, arg1);
 		
 		if (intention == AI_INTENTION_IDLE /* || intention == AI_INTENTION_ACTIVE */) // active becomes idle if only a summon is present
 		{
 			// Check if actor is not dead
-			if (!_actor.isAlikeDead())
-			{
+			if (!_actor.isAlikeDead()) {
 				L2Attackable npc = (L2Attackable) _actor;
 				
 				// If its _knownPlayer isn't empty set the Intention to AI_INTENTION_ACTIVE
-				if (!npc.getKnownList().getKnownPlayers().isEmpty())
-				{
+				if (!npc.getKnownList().getKnownPlayers().isEmpty()) {
 					intention = AI_INTENTION_ACTIVE;
-				}
-				else
-				{
+				} else {
 					intention = AI_INTENTION_IDLE;
 				}
 			}
 			
-			if (intention == AI_INTENTION_IDLE)
-			{
+			if (intention == AI_INTENTION_IDLE) {
 				// Set the Intention of this L2AttackableAI to AI_INTENTION_IDLE
 				super.changeIntention(AI_INTENTION_IDLE, null, null);
 				
 				// Stop AI task and detach AI from NPC
-				if (_aiTask != null)
-				{
+				if (_aiTask != null) {
 					_aiTask.cancel(true);
 					_aiTask = null;
 				}
@@ -233,8 +210,7 @@ public class L2FortSiegeGuardAI extends L2CharacterAI implements Runnable
 		super.changeIntention(intention, arg0, arg1);
 		
 		// If not idle - create an AI task (schedule onEvtThink repeatedly)
-		if (_aiTask == null)
-		{
+		if (_aiTask == null) {
 			_aiTask = ThreadPoolManager.getInstance().scheduleAiAtFixedRate(this, 1000, 1000);
 		}
 	}
@@ -244,8 +220,7 @@ public class L2FortSiegeGuardAI extends L2CharacterAI implements Runnable
 	 * @param target The L2Character to attack
 	 */
 	@Override
-	protected void onIntentionAttack(L2Character target)
-	{
+	protected void onIntentionAttack(L2Character target) {
 		// Calculate the attack timeout
 		_attackTimeout = MAX_ATTACK_TIMEOUT + GameTimeController.getInstance().getGameTicks();
 		
@@ -263,31 +238,23 @@ public class L2FortSiegeGuardAI extends L2CharacterAI implements Runnable
 	 * <li>If the actor can't attack, order to it to return to its home location</li>
 	 * </ul>
 	 */
-	private void thinkActive()
-	{
+	private void thinkActive() {
 		L2Attackable npc = (L2Attackable) _actor;
 		
 		// Update every 1s the _globalAggro counter to come close to 0
-		if (_globalAggro != 0)
-		{
-			if (_globalAggro < 0)
-			{
+		if (_globalAggro != 0) {
+			if (_globalAggro < 0) {
 				_globalAggro++;
-			}
-			else
-			{
+			} else {
 				_globalAggro--;
 			}
 		}
 		
 		// Add all autoAttackable L2Character in L2Attackable Aggro Range to its _aggroList with 0 damage and 1 hate
 		// A L2Attackable isn't aggressive during 10s after its spawn because _globalAggro is set to -10
-		if (_globalAggro >= 0)
-		{
-			for (L2Character target : npc.getKnownList().getKnownCharactersInRadius(_attackRange))
-			{
-				if (target == null)
-				{
+		if (_globalAggro >= 0) {
+			for (L2Character target : npc.getKnownList().getKnownCharactersInRadius(_attackRange)) {
+				if (target == null) {
 					continue;
 				}
 				if (autoAttackCondition(target)) // check aggression
@@ -296,8 +263,7 @@ public class L2FortSiegeGuardAI extends L2CharacterAI implements Runnable
 					long hating = npc.getHating(target);
 					
 					// Add the attacker to the L2Attackable _aggroList with 0 damage and 1 hate
-					if (hating == 0)
-					{
+					if (hating == 0) {
 						npc.addDamageHate(target, 0, 1);
 					}
 				}
@@ -305,26 +271,20 @@ public class L2FortSiegeGuardAI extends L2CharacterAI implements Runnable
 			
 			// Chose a target from its aggroList
 			L2Character hated;
-			if (_actor.isConfused())
-			{
+			if (_actor.isConfused()) {
 				hated = getAttackTarget(); // Force mobs to attack anybody if confused
-			}
-			else
-			{
+			} else {
 				hated = npc.getMostHated();
 				// _mostHatedAnalysis.Update(hated);
 			}
 			
 			// Order to the L2Attackable to attack the target
-			if (hated != null)
-			{
+			if (hated != null) {
 				// Get the hate level of the L2Attackable against this L2Character target contained in _aggroList
 				long aggro = npc.getHating(hated);
-				if ((aggro + _globalAggro) > 0)
-				{
+				if ((aggro + _globalAggro) > 0) {
 					// Set the L2Character movement type to run and send Server->Client packet ChangeMoveType to all others L2PcInstance
-					if (!_actor.isRunning())
-					{
+					if (!_actor.isRunning()) {
 						_actor.setRunning();
 					}
 					
@@ -337,14 +297,10 @@ public class L2FortSiegeGuardAI extends L2CharacterAI implements Runnable
 			
 		}
 		// Order to the L2SiegeGuardInstance to return to its home location because there's no target to attack
-		if (_actor.getWalkSpeed() >= 0)
-		{
-			if (_actor instanceof L2DefenderInstance)
-			{
+		if (_actor.getWalkSpeed() >= 0) {
+			if (_actor instanceof L2DefenderInstance) {
 				((L2DefenderInstance) _actor).returnHome();
-			}
-			else
-			{
+			} else {
 				((L2FortCommanderInstance) _actor).returnHome();
 			}
 		}
@@ -361,15 +317,12 @@ public class L2FortSiegeGuardAI extends L2CharacterAI implements Runnable
 	 * </ul>
 	 * TODO: Manage casting rules to healer mobs (like Ant Nurses)
 	 */
-	private void thinkAttack()
-	{
+	private void thinkAttack() {
 		LOG.debug("{}: thinkAttack(); timeout={}", getClass().getSimpleName(), (_attackTimeout - GameTimeController.getInstance().getGameTicks()));
 		
-		if (_attackTimeout < GameTimeController.getInstance().getGameTicks())
-		{
+		if (_attackTimeout < GameTimeController.getInstance().getGameTicks()) {
 			// Check if the actor is running
-			if (_actor.isRunning())
-			{
+			if (_actor.isRunning()) {
 				// Set the actor movement type to walk and send Server->Client packet ChangeMoveType to all others L2PcInstance
 				_actor.setWalking();
 				
@@ -380,11 +333,9 @@ public class L2FortSiegeGuardAI extends L2CharacterAI implements Runnable
 		
 		L2Character attackTarget = getAttackTarget();
 		// Check if target is dead or if timeout is expired to stop this attack
-		if ((attackTarget == null) || attackTarget.isAlikeDead() || (_attackTimeout < GameTimeController.getInstance().getGameTicks()))
-		{
+		if ((attackTarget == null) || attackTarget.isAlikeDead() || (_attackTimeout < GameTimeController.getInstance().getGameTicks())) {
 			// Stop hating this target after the attack timeout or if target is dead
-			if (attackTarget != null)
-			{
+			if (attackTarget != null) {
 				L2Attackable npc = (L2Attackable) _actor;
 				npc.stopHating(attackTarget);
 			}
@@ -404,58 +355,44 @@ public class L2FortSiegeGuardAI extends L2CharacterAI implements Runnable
 		attackPrepare();
 	}
 	
-	private final void factionNotifyAndSupport()
-	{
+	private final void factionNotifyAndSupport() {
 		L2Character target = getAttackTarget();
 		// Call all L2Object of its Faction inside the Faction Range
-		if ((((L2Npc) _actor).getTemplate().getClans() == null) || (target == null))
-		{
+		if ((((L2Npc) _actor).getTemplate().getClans() == null) || (target == null)) {
 			return;
 		}
 		
-		if (target.isInvul())
-		{
+		if (target.isInvul()) {
 			return; // speeding it up for siege guards
 		}
 		
 		// Go through all L2Character that belong to its faction
 		// for (L2Character cha : _actor.getKnownList().getKnownCharactersInRadius(((L2NpcInstance) _actor).getFactionRange()+_actor.getTemplate().collisionRadius))
-		for (L2Character cha : _actor.getKnownList().getKnownCharactersInRadius(1000))
-		{
-			if (cha == null)
-			{
+		for (L2Character cha : _actor.getKnownList().getKnownCharactersInRadius(1000)) {
+			if (cha == null) {
 				continue;
 			}
 			
-			if (!(cha instanceof L2Npc))
-			{
-				if (_selfAnalysis.hasHealOrResurrect && (cha instanceof L2PcInstance) && ((L2Npc) _actor).getFort().getSiege().checkIsDefender(((L2PcInstance) cha).getClan()))
-				{
+			if (!(cha instanceof L2Npc)) {
+				if (_selfAnalysis.hasHealOrResurrect && (cha instanceof L2PcInstance) && ((L2Npc) _actor).getFort().getSiege().checkIsDefender(((L2PcInstance) cha).getClan())) {
 					// heal friends
-					if (!_actor.isAttackingDisabled() && (cha.getCurrentHp() < (cha.getMaxHp() * 0.6)) && (_actor.getCurrentHp() > (_actor.getMaxHp() / 2)) && (_actor.getCurrentMp() > (_actor.getMaxMp() / 2)) && cha.isInCombat())
-					{
-						for (Skill sk : _selfAnalysis.healSkills)
-						{
-							if (_actor.getCurrentMp() < sk.getMpConsume2())
-							{
+					if (!_actor.isAttackingDisabled() && (cha.getCurrentHp() < (cha.getMaxHp() * 0.6)) && (_actor.getCurrentHp() > (_actor.getMaxHp() / 2)) && (_actor.getCurrentMp() > (_actor.getMaxMp() / 2)) && cha.isInCombat()) {
+						for (Skill sk : _selfAnalysis.healSkills) {
+							if (_actor.getCurrentMp() < sk.getMpConsume2()) {
 								continue;
 							}
-							if (_actor.isSkillDisabled(sk))
-							{
+							if (_actor.isSkillDisabled(sk)) {
 								continue;
 							}
-							if (!Util.checkIfInRange(sk.getCastRange(), _actor, cha, true))
-							{
+							if (!Util.checkIfInRange(sk.getCastRange(), _actor, cha, true)) {
 								continue;
 							}
 							
 							int chance = 5;
-							if (chance >= Rnd.get(100))
-							{
+							if (chance >= Rnd.get(100)) {
 								continue;
 							}
-							if (!GeoData.getInstance().canSeeTarget(_actor, cha))
-							{
+							if (!GeoData.getInstance().canSeeTarget(_actor, cha)) {
 								break;
 							}
 							
@@ -473,8 +410,7 @@ public class L2FortSiegeGuardAI extends L2CharacterAI implements Runnable
 			
 			L2Npc npc = (L2Npc) cha;
 			
-			if (!npc.isInMyClan((L2Npc) _actor))
-			{
+			if (!npc.isInMyClan((L2Npc) _actor)) {
 				continue;
 			}
 			
@@ -484,37 +420,29 @@ public class L2FortSiegeGuardAI extends L2CharacterAI implements Runnable
 				// && _actor.getAttackByList().contains(getAttackTarget())
 					&& ((npc.getAI()._intention == CtrlIntention.AI_INTENTION_IDLE) || (npc.getAI()._intention == CtrlIntention.AI_INTENTION_ACTIVE))
 					// limiting aggro for siege guards
-					&& target.isInsideRadius(npc, 1500, true, false) && GeoData.getInstance().canSeeTarget(npc, target))
-				{
+					&& target.isInsideRadius(npc, 1500, true, false) && GeoData.getInstance().canSeeTarget(npc, target)) {
 					// Notify the L2Object AI with EVT_AGGRESSION
 					npc.getAI().notifyEvent(CtrlEvent.EVT_AGGRESSION, getAttackTarget(), 1);
 					return;
 				}
 				// heal friends
-				if (_selfAnalysis.hasHealOrResurrect && !_actor.isAttackingDisabled() && (npc.getCurrentHp() < (npc.getMaxHp() * 0.6)) && (_actor.getCurrentHp() > (_actor.getMaxHp() / 2)) && (_actor.getCurrentMp() > (_actor.getMaxMp() / 2)) && npc.isInCombat())
-				{
-					for (Skill sk : _selfAnalysis.healSkills)
-					{
-						if (_actor.getCurrentMp() < sk.getMpConsume2())
-						{
+				if (_selfAnalysis.hasHealOrResurrect && !_actor.isAttackingDisabled() && (npc.getCurrentHp() < (npc.getMaxHp() * 0.6)) && (_actor.getCurrentHp() > (_actor.getMaxHp() / 2)) && (_actor.getCurrentMp() > (_actor.getMaxMp() / 2)) && npc.isInCombat()) {
+					for (Skill sk : _selfAnalysis.healSkills) {
+						if (_actor.getCurrentMp() < sk.getMpConsume2()) {
 							continue;
 						}
-						if (_actor.isSkillDisabled(sk))
-						{
+						if (_actor.isSkillDisabled(sk)) {
 							continue;
 						}
-						if (!Util.checkIfInRange(sk.getCastRange(), _actor, npc, true))
-						{
+						if (!Util.checkIfInRange(sk.getCastRange(), _actor, npc, true)) {
 							continue;
 						}
 						
 						int chance = 4;
-						if (chance >= Rnd.get(100))
-						{
+						if (chance >= Rnd.get(100)) {
 							continue;
 						}
-						if (!GeoData.getInstance().canSeeTarget(_actor, npc))
-						{
+						if (!GeoData.getInstance().canSeeTarget(_actor, npc)) {
 							break;
 						}
 						
@@ -530,36 +458,28 @@ public class L2FortSiegeGuardAI extends L2CharacterAI implements Runnable
 		}
 	}
 	
-	private void attackPrepare()
-	{
+	private void attackPrepare() {
 		// Get all information needed to choose between physical or magical attack
 		Collection<Skill> skills = null;
 		double dist_2 = 0;
 		int range = 0;
 		L2DefenderInstance sGuard;
-		if (_actor instanceof L2FortCommanderInstance)
-		{
+		if (_actor instanceof L2FortCommanderInstance) {
 			sGuard = (L2FortCommanderInstance) _actor;
-		}
-		else
-		{
+		} else {
 			sGuard = (L2DefenderInstance) _actor;
 		}
 		L2Character attackTarget = getAttackTarget();
 		
-		try
-		{
+		try {
 			_actor.setTarget(attackTarget);
 			skills = _actor.getAllSkills();
 			dist_2 = _actor.calculateDistance(attackTarget, false, true);
 			range = _actor.getPhysicalAttackRange() + _actor.getTemplate().getCollisionRadius() + attackTarget.getTemplate().getCollisionRadius();
-			if (attackTarget.isMoving())
-			{
+			if (attackTarget.isMoving()) {
 				range += 50;
 			}
-		}
-		catch (NullPointerException e)
-		{
+		} catch (NullPointerException e) {
 			LOG.warn("{}: Attack target is NULL.", getClass().getSimpleName());
 			_actor.setTarget(null);
 			setIntention(AI_INTENTION_IDLE, null, null);
@@ -567,8 +487,7 @@ public class L2FortSiegeGuardAI extends L2CharacterAI implements Runnable
 		}
 		
 		// never attack defenders
-		if ((attackTarget instanceof L2PcInstance) && sGuard.getFort().getSiege().checkIsDefender(((L2PcInstance) attackTarget).getClan()))
-		{
+		if ((attackTarget instanceof L2PcInstance) && sGuard.getFort().getSiege().checkIsDefender(((L2PcInstance) attackTarget).getClan())) {
 			// Cancel the target
 			sGuard.stopHating(attackTarget);
 			_actor.setTarget(null);
@@ -576,8 +495,7 @@ public class L2FortSiegeGuardAI extends L2CharacterAI implements Runnable
 			return;
 		}
 		
-		if (!GeoData.getInstance().canSeeTarget(_actor, attackTarget))
-		{
+		if (!GeoData.getInstance().canSeeTarget(_actor, attackTarget)) {
 			// Siege guards differ from normal mobs currently:
 			// If target cannot seen, don't attack any more
 			sGuard.stopHating(attackTarget);
@@ -587,33 +505,26 @@ public class L2FortSiegeGuardAI extends L2CharacterAI implements Runnable
 		}
 		
 		// Check if the actor isn't muted and if it is far from target
-		if (!_actor.isMuted() && (dist_2 > (range * range)))
-		{
+		if (!_actor.isMuted() && (dist_2 > (range * range))) {
 			// check for long ranged skills and heal/buff skills
-			for (Skill sk : skills)
-			{
+			for (Skill sk : skills) {
 				int castRange = sk.getCastRange();
 				
-				if ((dist_2 <= (castRange * castRange)) && (castRange > 70) && !_actor.isSkillDisabled(sk) && (_actor.getCurrentMp() >= _actor.getStat().getMpConsume2(sk)) && !sk.isPassive())
-				{
+				if ((dist_2 <= (castRange * castRange)) && (castRange > 70) && !_actor.isSkillDisabled(sk) && (_actor.getCurrentMp() >= _actor.getStat().getMpConsume2(sk)) && !sk.isPassive()) {
 					
 					L2Object OldTarget = _actor.getTarget();
-					if ((sk.isContinuous() && !sk.isDebuff()) || (sk.hasEffectType(L2EffectType.HP)))
-					{
+					if ((sk.isContinuous() && !sk.isDebuff()) || (sk.hasEffectType(L2EffectType.HP))) {
 						boolean useSkillSelf = true;
-						if ((sk.hasEffectType(L2EffectType.HP)) && (_actor.getCurrentHp() > (int) (_actor.getMaxHp() / 1.5)))
-						{
+						if ((sk.hasEffectType(L2EffectType.HP)) && (_actor.getCurrentHp() > (int) (_actor.getMaxHp() / 1.5))) {
 							useSkillSelf = false;
 							break;
 						}
 						
-						if ((sk.isContinuous() && !sk.isDebuff()) && _actor.isAffectedBySkill(sk.getId()))
-						{
+						if ((sk.isContinuous() && !sk.isDebuff()) && _actor.isAffectedBySkill(sk.getId())) {
 							useSkillSelf = false;
 						}
 						
-						if (useSkillSelf)
-						{
+						if (useSkillSelf) {
 							_actor.setTarget(_actor);
 						}
 					}
@@ -626,15 +537,12 @@ public class L2FortSiegeGuardAI extends L2CharacterAI implements Runnable
 			}
 			
 			// Check if the L2SiegeGuardInstance is attacking, knows the target and can't run
-			if (!(_actor.isAttackingNow()) && (_actor.getRunSpeed() == 0) && (_actor.getKnownList().knowsObject(attackTarget)))
-			{
+			if (!(_actor.isAttackingNow()) && (_actor.getRunSpeed() == 0) && (_actor.getKnownList().knowsObject(attackTarget))) {
 				// Cancel the target
 				_actor.getKnownList().removeKnownObject(attackTarget);
 				_actor.setTarget(null);
 				setIntention(AI_INTENTION_IDLE, null, null);
-			}
-			else
-			{
+			} else {
 				double dx = _actor.getX() - attackTarget.getX();
 				double dy = _actor.getY() - attackTarget.getY();
 				double dz = _actor.getZ() - attackTarget.getZ();
@@ -643,34 +551,27 @@ public class L2FortSiegeGuardAI extends L2CharacterAI implements Runnable
 				
 				// Check if the L2SiegeGuardInstance isn't too far from it's home location
 				if ((((dx * dx) + (dy * dy)) > 10000) && (((homeX * homeX) + (homeY * homeY)) > 3240000) // 1800 * 1800
-					&& (_actor.getKnownList().knowsObject(attackTarget)))
-				{
+					&& (_actor.getKnownList().knowsObject(attackTarget))) {
 					// Cancel the target
 					_actor.getKnownList().removeKnownObject(attackTarget);
 					_actor.setTarget(null);
 					setIntention(AI_INTENTION_IDLE, null, null);
-				}
-				else
+				} else
 				// Move the actor to Pawn server side AND client side by sending Server->Client packet MoveToPawn (broadcast)
 				{
 					// Temporary hack for preventing guards jumping off towers,
 					// before replacing this with effective geodata checks and AI modification
 					if ((dz * dz) < (170 * 170)) // normally 130 if guard z coordinates correct
 					{
-						if (_selfAnalysis.isMage)
-						{
+						if (_selfAnalysis.isMage) {
 							range = _selfAnalysis.maxCastRange - 50;
 						}
-						if (_actor.getWalkSpeed() <= 0)
-						{
+						if (_actor.getWalkSpeed() <= 0) {
 							return;
 						}
-						if (attackTarget.isMoving())
-						{
+						if (attackTarget.isMoving()) {
 							moveToPawn(attackTarget, range - 70);
-						}
-						else
-						{
+						} else {
 							moveToPawn(attackTarget, range);
 						}
 					}
@@ -681,84 +582,65 @@ public class L2FortSiegeGuardAI extends L2CharacterAI implements Runnable
 			
 		}
 		// Else, if the actor is muted and far from target, just "move to pawn"
-		else if (_actor.isMuted() && (dist_2 > (range * range)))
-		{
+		else if (_actor.isMuted() && (dist_2 > (range * range))) {
 			// Temporary hack for preventing guards jumping off towers,
 			// before replacing this with effective geodata checks and AI modification
 			double dz = _actor.getZ() - attackTarget.getZ();
 			if ((dz * dz) < (170 * 170)) // normally 130 if guard z coordinates correct
 			{
-				if (_selfAnalysis.isMage)
-				{
+				if (_selfAnalysis.isMage) {
 					range = _selfAnalysis.maxCastRange - 50;
 				}
-				if (_actor.getWalkSpeed() <= 0)
-				{
+				if (_actor.getWalkSpeed() <= 0) {
 					return;
 				}
-				if (attackTarget.isMoving())
-				{
+				if (attackTarget.isMoving()) {
 					moveToPawn(attackTarget, range - 70);
-				}
-				else
-				{
+				} else {
 					moveToPawn(attackTarget, range);
 				}
 			}
 			return;
 		}
 		// Else, if this is close enough to attack
-		else if (dist_2 <= (range * range))
-		{
+		else if (dist_2 <= (range * range)) {
 			// Force mobs to attack anybody if confused
 			L2Character hated = null;
-			if (_actor.isConfused())
-			{
+			if (_actor.isConfused()) {
 				hated = attackTarget;
-			}
-			else
-			{
+			} else {
 				hated = ((L2Attackable) _actor).getMostHated();
 			}
 			
-			if (hated == null)
-			{
+			if (hated == null) {
 				setIntention(AI_INTENTION_ACTIVE, null, null);
 				return;
 			}
-			if (hated != attackTarget)
-			{
+			if (hated != attackTarget) {
 				attackTarget = hated;
 			}
 			
 			_attackTimeout = MAX_ATTACK_TIMEOUT + GameTimeController.getInstance().getGameTicks();
 			
 			// check for close combat skills && heal/buff skills
-			if (!_actor.isMuted() && (Rnd.nextInt(100) <= 5))
-			{
-				for (Skill sk : skills)
-				{
+			if (!_actor.isMuted() && (Rnd.nextInt(100) <= 5)) {
+				for (Skill sk : skills) {
 					int castRange = sk.getCastRange();
 					
-					if (((castRange * castRange) >= dist_2) && !sk.isPassive() && (_actor.getCurrentMp() >= _actor.getStat().getMpConsume2(sk)) && !_actor.isSkillDisabled(sk))
-					{
+					if (((castRange * castRange) >= dist_2) && !sk.isPassive() && (_actor.getCurrentMp() >= _actor.getStat().getMpConsume2(sk)) && !_actor.isSkillDisabled(sk)) {
 						L2Object OldTarget = _actor.getTarget();
-						if ((sk.isContinuous() && !sk.isDebuff()) || (sk.hasEffectType(L2EffectType.HP)))
-						{
+						if ((sk.isContinuous() && !sk.isDebuff()) || (sk.hasEffectType(L2EffectType.HP))) {
 							boolean useSkillSelf = true;
-							if ((sk.hasEffectType(L2EffectType.HP)) && (_actor.getCurrentHp() > (int) (_actor.getMaxHp() / 1.5)))
-							{
+							if ((sk.hasEffectType(L2EffectType.HP)) && (_actor.getCurrentHp() > (int) (_actor.getMaxHp() / 1.5))) {
 								useSkillSelf = false;
 								break;
 							}
 							
-							if ((sk.isContinuous() && !sk.isDebuff()) && _actor.isAffectedBySkill(sk.getId()))
-							{
+							if ((sk.isContinuous() && !sk.isDebuff()) && _actor.isAffectedBySkill(sk.getId())) {
 								useSkillSelf = false;
 							}
 							
-							if (useSkillSelf)
-							{
+							if (useSkillSelf) {
 								_actor.setTarget(_actor);
 							}
 						}
@@ -779,34 +661,26 @@ public class L2FortSiegeGuardAI extends L2CharacterAI implements Runnable
 	 * Manage AI thinking actions of a L2Attackable.
 	 */
 	@Override
-	protected void onEvtThink()
-	{
+	protected void onEvtThink() {
 		// if(getIntention() != AI_INTENTION_IDLE && (!_actor.isVisible() || !_actor.hasAI() || !_actor.isKnownPlayers()))
 		// setIntention(AI_INTENTION_IDLE);
 		
 		// Check if the actor can't use skills and if a thinking action isn't already in progress
-		if (_thinking || _actor.isCastingNow() || _actor.isAllSkillsDisabled())
-		{
+		if (_thinking || _actor.isCastingNow() || _actor.isAllSkillsDisabled()) {
 			return;
 		}
 		
 		// Start thinking action
 		_thinking = true;
 		
-		try
-		{
+		try {
 			// Manage AI thinks of a L2Attackable
-			if (getIntention() == AI_INTENTION_ACTIVE)
-			{
+			if (getIntention() == AI_INTENTION_ACTIVE) {
 				thinkActive();
-			}
-			else if (getIntention() == AI_INTENTION_ATTACK)
-			{
+			} else if (getIntention() == AI_INTENTION_ATTACK) {
 				thinkAttack();
 			}
-		}
-		finally
-		{
+		} finally {
 			// Stop thinking action
 			_thinking = false;
 		}
@@ -823,14 +697,12 @@ public class L2FortSiegeGuardAI extends L2CharacterAI implements Runnable
 	 * @param attacker The L2Character that attacks the actor
 	 */
 	@Override
-	protected void onEvtAttacked(L2Character attacker)
-	{
+	protected void onEvtAttacked(L2Character attacker) {
 		// Calculate the attack timeout
 		_attackTimeout = MAX_ATTACK_TIMEOUT + GameTimeController.getInstance().getGameTicks();
 		
 		// Set the _globalAggro to 0 to permit attack even just after spawn
-		if (_globalAggro < 0)
-		{
+		if (_globalAggro < 0) {
 			_globalAggro = 0;
 		}
 		
@@ -838,14 +710,12 @@ public class L2FortSiegeGuardAI extends L2CharacterAI implements Runnable
 		((L2Attackable) _actor).addDamageHate(attacker, 0, 1);
 		
 		// Set the L2Character movement type to run and send Server->Client packet ChangeMoveType to all others L2PcInstance
-		if (!_actor.isRunning())
-		{
+		if (!_actor.isRunning()) {
 			_actor.setRunning();
 		}
 		
 		// Set the Intention to AI_INTENTION_ATTACK
-		if (getIntention() != AI_INTENTION_ATTACK)
-		{
+		if (getIntention() != AI_INTENTION_ATTACK) {
 			setIntention(CtrlIntention.AI_INTENTION_ATTACK, attacker, null);
 		}
 		
@@ -862,26 +732,21 @@ public class L2FortSiegeGuardAI extends L2CharacterAI implements Runnable
 	 * @param aggro The value of hate to add to the actor against the target
 	 */
 	@Override
-	protected void onEvtAggression(L2Character target, long aggro)
-	{
-		if (_actor == null)
-		{
+	protected void onEvtAggression(L2Character target, long aggro) {
+		if (_actor == null) {
 			return;
 		}
 		L2Attackable me = (L2Attackable) _actor;
 		
-		if (target != null)
-		{
+		if (target != null) {
 			// Add the target to the actor _aggroList or update hate if already present
 			me.addDamageHate(target, 0, aggro);
 			
 			// Get the hate of the actor against the target
 			aggro = me.getHating(target);
 			
-			if (aggro <= 0)
-			{
-				if (me.getMostHated() == null)
-				{
+			if (aggro <= 0) {
+				if (me.getMostHated() == null) {
 					_globalAggro = -25;
 					me.clearAggroList();
 					setIntention(AI_INTENTION_IDLE, null, null);
@@ -890,56 +755,44 @@ public class L2FortSiegeGuardAI extends L2CharacterAI implements Runnable
 			}
 			
 			// Set the actor AI Intention to AI_INTENTION_ATTACK
-			if (getIntention() != CtrlIntention.AI_INTENTION_ATTACK)
-			{
+			if (getIntention() != CtrlIntention.AI_INTENTION_ATTACK) {
 				// Set the L2Character movement type to run and send Server->Client packet ChangeMoveType to all others L2PcInstance
-				if (!_actor.isRunning())
-				{
+				if (!_actor.isRunning()) {
 					_actor.setRunning();
 				}
 				
 				L2DefenderInstance sGuard;
-				if (_actor instanceof L2FortCommanderInstance)
-				{
+				if (_actor instanceof L2FortCommanderInstance) {
 					sGuard = (L2FortCommanderInstance) _actor;
-				}
-				else
-				{
+				} else {
 					sGuard = (L2DefenderInstance) _actor;
 				}
 				double homeX = target.getX() - sGuard.getSpawn().getX();
 				double homeY = target.getY() - sGuard.getSpawn().getY();
 				
 				// Check if the L2SiegeGuardInstance is not too far from its home location
-				if (((homeX * homeX) + (homeY * homeY)) < 3240000)
-				{
+				if (((homeX * homeX) + (homeY * homeY)) < 3240000) {
 					setIntention(CtrlIntention.AI_INTENTION_ATTACK, target, null);
 				}
 			}
-		}
-		else
-		{
+		} else {
 			// currently only for setting lower general aggro
-			if (aggro >= 0)
-			{
+			if (aggro >= 0) {
 				return;
 			}
 			
 			L2Character mostHated = me.getMostHated();
-			if (mostHated == null)
-			{
+			if (mostHated == null) {
 				_globalAggro = -25;
 				return;
 			}
 			
-			for (L2Character aggroed : me.getAggroList().keySet())
-			{
+			for (L2Character aggroed : me.getAggroList().keySet()) {
 				me.addDamageHate(aggroed, 0, aggro);
 			}
 			
 			aggro = me.getHating(mostHated);
-			if (aggro <= 0)
-			{
+			if (aggro <= 0) {
 				_globalAggro = -25;
 				me.clearAggroList();
 				setIntention(AI_INTENTION_IDLE, null, null);
@@ -948,10 +801,8 @@ public class L2FortSiegeGuardAI extends L2CharacterAI implements Runnable
 	}
 	
 	@Override
-	public void stopAITask()
-	{
-		if (_aiTask != null)
-		{
+	public void stopAITask() {
+		if (_aiTask != null) {
 			_aiTask.cancel(false);
 			_aiTask = null;
 		}

+ 13 - 26
src/main/java/com/l2jserver/gameserver/ai/L2PlayableAI.java

@@ -29,23 +29,18 @@ import com.l2jserver.gameserver.network.SystemMessageId;
  * This class manages AI of L2Playable.
  * @author JIV
  */
-public abstract class L2PlayableAI extends L2CharacterAI
-{
+public abstract class L2PlayableAI extends L2CharacterAI {
 	/**
 	 * @param creature the creature
 	 */
-	public L2PlayableAI(L2Playable creature)
-	{
+	public L2PlayableAI(L2Playable creature) {
 		super(creature);
 	}
 	
 	@Override
-	protected void onIntentionAttack(L2Character target)
-	{
-		if (target instanceof L2Playable)
-		{
-			if (target.getActingPlayer().isProtectionBlessingAffected() && ((_actor.getActingPlayer().getLevel() - target.getActingPlayer().getLevel()) >= 10) && (_actor.getActingPlayer().getKarma() > 0) && !(target.isInsideZone(ZoneId.PVP)))
-			{
+	protected void onIntentionAttack(L2Character target) {
+		if (target instanceof L2Playable) {
+			if (target.getActingPlayer().isProtectionBlessingAffected() && ((_actor.getActingPlayer().getLevel() - target.getActingPlayer().getLevel()) >= 10) && (_actor.getActingPlayer().getKarma() > 0) && !(target.isInsideZone(ZoneId.PVP))) {
 				// If attacker have karma and have level >= 10 than his target and target have
 				// Newbie Protection Buff,
 				_actor.getActingPlayer().sendPacket(SystemMessageId.TARGET_IS_INCORRECT);
@@ -53,8 +48,7 @@ public abstract class L2PlayableAI extends L2CharacterAI
 				return;
 			}
 			
-			if (_actor.getActingPlayer().isProtectionBlessingAffected() && ((target.getActingPlayer().getLevel() - _actor.getActingPlayer().getLevel()) >= 10) && (target.getActingPlayer().getKarma() > 0) && !(target.isInsideZone(ZoneId.PVP)))
-			{
+			if (_actor.getActingPlayer().isProtectionBlessingAffected() && ((target.getActingPlayer().getLevel() - _actor.getActingPlayer().getLevel()) >= 10) && (target.getActingPlayer().getKarma() > 0) && !(target.isInsideZone(ZoneId.PVP))) {
 				// If target have karma and have level >= 10 than his target and actor have
 				// Newbie Protection Buff,
 				_actor.getActingPlayer().sendPacket(SystemMessageId.TARGET_IS_INCORRECT);
@@ -62,15 +56,13 @@ public abstract class L2PlayableAI extends L2CharacterAI
 				return;
 			}
 			
-			if (target.getActingPlayer().isCursedWeaponEquipped() && (_actor.getActingPlayer().getLevel() <= 20))
-			{
+			if (target.getActingPlayer().isCursedWeaponEquipped() && (_actor.getActingPlayer().getLevel() <= 20)) {
 				_actor.getActingPlayer().sendPacket(SystemMessageId.TARGET_IS_INCORRECT);
 				clientActionFailed();
 				return;
 			}
 			
-			if (_actor.getActingPlayer().isCursedWeaponEquipped() && (target.getActingPlayer().getLevel() <= 20))
-			{
+			if (_actor.getActingPlayer().isCursedWeaponEquipped() && (target.getActingPlayer().getLevel() <= 20)) {
 				_actor.getActingPlayer().sendPacket(SystemMessageId.TARGET_IS_INCORRECT);
 				clientActionFailed();
 				return;
@@ -81,12 +73,9 @@ public abstract class L2PlayableAI extends L2CharacterAI
 	}
 	
 	@Override
-	protected void onIntentionCast(Skill skill, L2Object target)
-	{
-		if ((target instanceof L2Playable) && skill.isBad())
-		{
-			if (target.getActingPlayer().isProtectionBlessingAffected() && ((_actor.getActingPlayer().getLevel() - target.getActingPlayer().getLevel()) >= 10) && (_actor.getActingPlayer().getKarma() > 0) && !target.isInsideZone(ZoneId.PVP))
-			{
+	protected void onIntentionCast(Skill skill, L2Object target) {
+		if ((target instanceof L2Playable) && skill.isBad()) {
+			if (target.getActingPlayer().isProtectionBlessingAffected() && ((_actor.getActingPlayer().getLevel() - target.getActingPlayer().getLevel()) >= 10) && (_actor.getActingPlayer().getKarma() > 0) && !target.isInsideZone(ZoneId.PVP)) {
 				// If attacker have karma and have level >= 10 than his target and target have
 				// Newbie Protection Buff,
 				_actor.getActingPlayer().sendPacket(SystemMessageId.TARGET_IS_INCORRECT);
@@ -95,8 +84,7 @@ public abstract class L2PlayableAI extends L2CharacterAI
 				return;
 			}
 			
-			if (_actor.getActingPlayer().isProtectionBlessingAffected() && ((target.getActingPlayer().getLevel() - _actor.getActingPlayer().getLevel()) >= 10) && (target.getActingPlayer().getKarma() > 0) && !target.isInsideZone(ZoneId.PVP))
-			{
+			if (_actor.getActingPlayer().isProtectionBlessingAffected() && ((target.getActingPlayer().getLevel() - _actor.getActingPlayer().getLevel()) >= 10) && (target.getActingPlayer().getKarma() > 0) && !target.isInsideZone(ZoneId.PVP)) {
 				// If target have karma and have level >= 10 than his target and actor have
 				// Newbie Protection Buff,
 				_actor.getActingPlayer().sendPacket(SystemMessageId.TARGET_IS_INCORRECT);
@@ -105,8 +93,7 @@ public abstract class L2PlayableAI extends L2CharacterAI
 				return;
 			}
 			
-			if (target.getActingPlayer().isCursedWeaponEquipped() && ((_actor.getActingPlayer().getLevel() <= 20) || (target.getActingPlayer().getLevel() <= 20)))
-			{
+			if (target.getActingPlayer().isCursedWeaponEquipped() && ((_actor.getActingPlayer().getLevel() <= 20) || (target.getActingPlayer().getLevel() <= 20))) {
 				_actor.getActingPlayer().sendPacket(SystemMessageId.TARGET_IS_INCORRECT);
 				clientActionFailed();
 				_actor.setIsCastingNow(false);

+ 53 - 113
src/main/java/com/l2jserver/gameserver/ai/L2PlayerAI.java

@@ -37,25 +37,21 @@ import com.l2jserver.gameserver.model.skills.targets.L2TargetType;
 import com.l2jserver.gameserver.network.SystemMessageId;
 import com.l2jserver.gameserver.network.serverpackets.SystemMessage;
 
-public class L2PlayerAI extends L2PlayableAI
-{
+public class L2PlayerAI extends L2PlayableAI {
 	private boolean _thinking; // to prevent recursive thinking
 	
 	private IntentionCommand _nextIntention = null;
 	
-	public L2PlayerAI(L2PcInstance creature)
-	{
+	public L2PlayerAI(L2PcInstance creature) {
 		super(creature);
 	}
 	
-	void saveNextIntention(CtrlIntention intention, Object arg0, Object arg1)
-	{
+	void saveNextIntention(CtrlIntention intention, Object arg0, Object arg1) {
 		_nextIntention = new IntentionCommand(intention, arg0, arg1);
 	}
 	
 	@Override
-	public IntentionCommand getNextIntention()
-	{
+	public IntentionCommand getNextIntention() {
 		return _nextIntention;
 	}
 	
@@ -66,19 +62,16 @@ public class L2PlayerAI extends L2PlayableAI
 	 * @param arg1 The second parameter of the Intention
 	 */
 	@Override
-	protected synchronized void changeIntention(CtrlIntention intention, Object arg0, Object arg1)
-	{
+	protected synchronized void changeIntention(CtrlIntention intention, Object arg0, Object arg1) {
 		// Forget next if it's not cast or it's cast and skill is toggle.
-		if ((intention != AI_INTENTION_CAST) || ((arg0 != null) && !((Skill) arg0).isToggle()))
-		{
+		if ((intention != AI_INTENTION_CAST) || ((arg0 != null) && !((Skill) arg0).isToggle())) {
 			_nextIntention = null;
 			super.changeIntention(intention, arg0, arg1);
 			return;
 		}
 		
 		// do nothing if next intention is same as current one.
-		if ((intention == _intention) && (arg0 == _intentionArg0) && (arg1 == _intentionArg1))
-		{
+		if ((intention == _intention) && (arg0 == _intentionArg0) && (arg1 == _intentionArg1)) {
 			super.changeIntention(intention, arg0, arg1);
 			return;
 		}
@@ -96,11 +89,9 @@ public class L2PlayerAI extends L2PlayableAI
 	 * </ul>
 	 */
 	@Override
-	protected void onEvtReadyToAct()
-	{
+	protected void onEvtReadyToAct() {
 		// Launch actions corresponding to the Event Think
-		if (_nextIntention != null)
-		{
+		if (_nextIntention != null) {
 			setIntention(_nextIntention._crtlIntention, _nextIntention._arg0, _nextIntention._arg1);
 			_nextIntention = null;
 		}
@@ -116,8 +107,7 @@ public class L2PlayerAI extends L2PlayableAI
 	 * </ul>
 	 */
 	@Override
-	protected void onEvtCancel()
-	{
+	protected void onEvtCancel() {
 		_nextIntention = null;
 		super.onEvtCancel();
 	}
@@ -128,26 +118,19 @@ public class L2PlayerAI extends L2PlayableAI
 	 * Check if actual intention is set to CAST and, if so, retrieves latest intention before the actual CAST and set it as the current intention for the player.
 	 */
 	@Override
-	protected void onEvtFinishCasting()
-	{
-		if (getIntention() == AI_INTENTION_CAST)
-		{
+	protected void onEvtFinishCasting() {
+		if (getIntention() == AI_INTENTION_CAST) {
 			// run interrupted or next intention
 			
 			IntentionCommand nextIntention = _nextIntention;
-			if (nextIntention != null)
-			{
+			if (nextIntention != null) {
 				if (nextIntention._crtlIntention != AI_INTENTION_CAST) // previous state shouldn't be casting
 				{
 					setIntention(nextIntention._crtlIntention, nextIntention._arg0, nextIntention._arg1);
-				}
-				else
-				{
+				} else {
 					setIntention(AI_INTENTION_IDLE);
 				}
-			}
-			else
-			{
+			} else {
 				// set intention to idle if skill doesn't change intention.
 				setIntention(AI_INTENTION_IDLE);
 			}
@@ -155,14 +138,11 @@ public class L2PlayerAI extends L2PlayableAI
 	}
 	
 	@Override
-	protected void onIntentionRest()
-	{
-		if (getIntention() != AI_INTENTION_REST)
-		{
+	protected void onIntentionRest() {
+		if (getIntention() != AI_INTENTION_REST) {
 			changeIntention(AI_INTENTION_REST, null, null);
 			setTarget(null);
-			if (getAttackTarget() != null)
-			{
+			if (getAttackTarget() != null) {
 				setAttackTarget(null);
 			}
 			clientStopMoving(null);
@@ -170,8 +150,7 @@ public class L2PlayerAI extends L2PlayableAI
 	}
 	
 	@Override
-	protected void onIntentionActive()
-	{
+	protected void onIntentionActive() {
 		setIntention(AI_INTENTION_IDLE);
 	}
 	
@@ -185,22 +164,18 @@ public class L2PlayerAI extends L2PlayableAI
 	 * </ul>
 	 */
 	@Override
-	protected void onIntentionMoveTo(Location loc)
-	{
-		if (getIntention() == AI_INTENTION_REST)
-		{
+	protected void onIntentionMoveTo(Location loc) {
+		if (getIntention() == AI_INTENTION_REST) {
 			// Cancel action client side by sending Server->Client packet ActionFailed to the L2PcInstance actor
 			clientActionFailed();
 			return;
 		}
-		if (_actor.getActingPlayer().getDuelState() == DuelState.DEAD)
-		{
+		if (_actor.getActingPlayer().getDuelState() == DuelState.DEAD) {
 			clientActionFailed();
 			_actor.getActingPlayer().sendPacket(SystemMessage.getSystemMessage(SystemMessageId.CANNOT_MOVE_FROZEN));
 			return;
 		}
-		if (_actor.isAllSkillsDisabled() || _actor.isCastingNow() || _actor.isAttackingNow())
-		{
+		if (_actor.isAllSkillsDisabled() || _actor.isCastingNow() || _actor.isAttackingNow()) {
 			clientActionFailed();
 			saveNextIntention(AI_INTENTION_MOVE_TO, loc, null);
 			return;
@@ -220,29 +195,24 @@ public class L2PlayerAI extends L2PlayableAI
 	}
 	
 	@Override
-	protected void clientNotifyDead()
-	{
+	protected void clientNotifyDead() {
 		_clientMovingToPawnOffset = 0;
 		_clientMoving = false;
 		
 		super.clientNotifyDead();
 	}
 	
-	private void thinkAttack()
-	{
+	private void thinkAttack() {
 		L2Character target = getAttackTarget();
-		if (target == null)
-		{
+		if (target == null) {
 			return;
 		}
-		if (checkTargetLostOrDead(target))
-		{
+		if (checkTargetLostOrDead(target)) {
 			// Notify the target
 			setAttackTarget(null);
 			return;
 		}
-		if (maybeMoveToPawn(target, _actor.getPhysicalAttackRange()))
-		{
+		if (maybeMoveToPawn(target, _actor.getPhysicalAttackRange())) {
 			return;
 		}
 		
@@ -250,115 +220,85 @@ public class L2PlayerAI extends L2PlayableAI
 		_actor.doAttack(target);
 	}
 	
-	private void thinkCast()
-	{
+	private void thinkCast() {
 		L2Character target = getCastTarget();
-		if ((_skill.getTargetType() == L2TargetType.GROUND) && (_actor instanceof L2PcInstance))
-		{
-			if (maybeMoveToPosition(((L2PcInstance) _actor).getCurrentSkillWorldPosition(), _actor.getMagicalAttackRange(_skill)))
-			{
+		if ((_skill.getTargetType() == L2TargetType.GROUND) && (_actor instanceof L2PcInstance)) {
+			if (maybeMoveToPosition(((L2PcInstance) _actor).getCurrentSkillWorldPosition(), _actor.getMagicalAttackRange(_skill))) {
 				_actor.setIsCastingNow(false);
 				return;
 			}
-		}
-		else
-		{
-			if (checkTargetLost(target))
-			{
-				if (_skill.isBad() && (getAttackTarget() != null))
-				{
+		} else {
+			if (checkTargetLost(target)) {
+				if (_skill.isBad() && (getAttackTarget() != null)) {
 					// Notify the target
 					setCastTarget(null);
 				}
 				_actor.setIsCastingNow(false);
 				return;
 			}
-			if ((target != null) && maybeMoveToPawn(target, _actor.getMagicalAttackRange(_skill)))
-			{
+			if ((target != null) && maybeMoveToPawn(target, _actor.getMagicalAttackRange(_skill))) {
 				_actor.setIsCastingNow(false);
 				return;
 			}
 		}
 		
-		if ((_skill.getHitTime() > 50) && !_skill.isSimultaneousCast())
-		{
+		if ((_skill.getHitTime() > 50) && !_skill.isSimultaneousCast()) {
 			clientStopMoving(null);
 		}
 		
 		_actor.doCast(_skill);
 	}
 	
-	private void thinkPickUp()
-	{
-		if (_actor.isAllSkillsDisabled() || _actor.isCastingNow())
-		{
+	private void thinkPickUp() {
+		if (_actor.isAllSkillsDisabled() || _actor.isCastingNow()) {
 			return;
 		}
 		L2Object target = getTarget();
-		if (checkTargetLost(target))
-		{
+		if (checkTargetLost(target)) {
 			return;
 		}
-		if (maybeMoveToPawn(target, 36))
-		{
+		if (maybeMoveToPawn(target, 36)) {
 			return;
 		}
 		setIntention(AI_INTENTION_IDLE);
 		_actor.getActingPlayer().doPickupItem(target);
 	}
 	
-	private void thinkInteract()
-	{
-		if (_actor.isAllSkillsDisabled() || _actor.isCastingNow())
-		{
+	private void thinkInteract() {
+		if (_actor.isAllSkillsDisabled() || _actor.isCastingNow()) {
 			return;
 		}
 		L2Object target = getTarget();
-		if (checkTargetLost(target))
-		{
+		if (checkTargetLost(target)) {
 			return;
 		}
-		if (maybeMoveToPawn(target, 36))
-		{
+		if (maybeMoveToPawn(target, 36)) {
 			return;
 		}
-		if (!(target instanceof L2StaticObjectInstance))
-		{
+		if (!(target instanceof L2StaticObjectInstance)) {
 			_actor.getActingPlayer().doInteract((L2Character) target);
 		}
 		setIntention(AI_INTENTION_IDLE);
 	}
 	
 	@Override
-	protected void onEvtThink()
-	{
-		if (_thinking && (getIntention() != AI_INTENTION_CAST))
-		{
+	protected void onEvtThink() {
+		if (_thinking && (getIntention() != AI_INTENTION_CAST)) {
 			return;
 		}
 		
 		_thinking = true;
-		try
-		{
-			if (getIntention() == AI_INTENTION_ATTACK)
-			{
+		try {
+			if (getIntention() == AI_INTENTION_ATTACK) {
 				thinkAttack();
-			}
-			else if (getIntention() == AI_INTENTION_CAST)
-			{
+			} else if (getIntention() == AI_INTENTION_CAST) {
 				thinkCast();
-			}
-			else if (getIntention() == AI_INTENTION_PICK_UP)
-			{
+			} else if (getIntention() == AI_INTENTION_PICK_UP) {
 				thinkPickUp();
-			}
-			else if (getIntention() == AI_INTENTION_INTERACT)
-			{
+			} else if (getIntention() == AI_INTENTION_INTERACT) {
 				thinkInteract();
 			}
-		}
-		finally
-		{
+		} finally {
 			_thinking = false;
 		}
 	}

+ 125 - 261
src/main/java/com/l2jserver/gameserver/ai/L2SiegeGuardAI.java

@@ -46,8 +46,7 @@ import com.l2jserver.util.Rnd;
 /**
  * This class manages AI of L2Attackable.
  */
-public class L2SiegeGuardAI extends L2CharacterAI implements Runnable
-{
+public class L2SiegeGuardAI extends L2CharacterAI implements Runnable {
 	private static final int MAX_ATTACK_TIMEOUT = 300; // int ticks, i.e. 30 seconds
 	
 	/** The L2Attackable AI task executed every 1s (call onEvtThink method) */
@@ -72,8 +71,7 @@ public class L2SiegeGuardAI extends L2CharacterAI implements Runnable
 	 * Constructor of L2AttackableAI.
 	 * @param creature the creature
 	 */
-	public L2SiegeGuardAI(L2DefenderInstance creature)
-	{
+	public L2SiegeGuardAI(L2DefenderInstance creature) {
 		super(creature);
 		_selfAnalysis.init();
 		_attackTimeout = Integer.MAX_VALUE;
@@ -82,8 +80,7 @@ public class L2SiegeGuardAI extends L2CharacterAI implements Runnable
 	}
 	
 	@Override
-	public void run()
-	{
+	public void run() {
 		// Launch actions corresponding to the Event Think
 		onEvtThink();
 		
@@ -123,44 +120,35 @@ public class L2SiegeGuardAI extends L2CharacterAI implements Runnable
 	 * @param target The targeted L2Object
 	 * @return True if the target is autoattackable (depends on the actor type).
 	 */
-	protected boolean autoAttackCondition(L2Character target)
-	{
+	protected boolean autoAttackCondition(L2Character target) {
 		// Check if the target isn't another guard, folk or a door
-		if ((target == null) || (target instanceof L2DefenderInstance) || (target instanceof L2NpcInstance) || (target instanceof L2DoorInstance) || target.isAlikeDead())
-		{
+		if ((target == null) || (target instanceof L2DefenderInstance) || (target instanceof L2NpcInstance) || (target instanceof L2DoorInstance) || target.isAlikeDead()) {
 			return false;
 		}
 		
 		// Check if the target isn't invulnerable
-		if (target.isInvul())
-		{
+		if (target.isInvul()) {
 			// However EffectInvincible requires to check GMs specially
-			if (target.isPlayer() && target.isGM())
-			{
+			if (target.isPlayer() && target.isGM()) {
 				return false;
 			}
-			if (target.isSummon() && ((L2Summon) target).getOwner().isGM())
-			{
+			if (target.isSummon() && ((L2Summon) target).getOwner().isGM()) {
 				return false;
 			}
 		}
 		
 		// Get the owner if the target is a summon
-		if (target instanceof L2Summon)
-		{
+		if (target instanceof L2Summon) {
 			L2PcInstance owner = ((L2Summon) target).getOwner();
-			if (_actor.isInsideRadius(owner, 1000, true, false))
-			{
+			if (_actor.isInsideRadius(owner, 1000, true, false)) {
 				target = owner;
 			}
 		}
 		
 		// Check if the target is a L2PcInstance
-		if (target instanceof L2Playable)
-		{
+		if (target instanceof L2Playable) {
 			// Check if the target isn't in silent move mode AND too far (>100)
-			if (((L2Playable) target).isSilentMovingAffected() && !_actor.isInsideRadius(target, 250, false, false))
-			{
+			if (((L2Playable) target).isSilentMovingAffected() && !_actor.isInsideRadius(target, 250, false, false)) {
 				return false;
 			}
 		}
@@ -177,36 +165,29 @@ public class L2SiegeGuardAI extends L2CharacterAI implements Runnable
 	 * @param arg1 The second parameter of the Intention
 	 */
 	@Override
-	synchronized void changeIntention(CtrlIntention intention, Object arg0, Object arg1)
-	{
+	synchronized void changeIntention(CtrlIntention intention, Object arg0, Object arg1) {
 		LOG.debug("{}: changeIntention({}, {}, {})", getClass().getSimpleName(), intention, arg0, arg1);
 		
 		if (intention == AI_INTENTION_IDLE /* || intention == AI_INTENTION_ACTIVE */) // active becomes idle if only a summon is present
 		{
 			// Check if actor is not dead
-			if (!_actor.isAlikeDead())
-			{
+			if (!_actor.isAlikeDead()) {
 				L2Attackable npc = (L2Attackable) _actor;
 				
 				// If its _knownPlayer isn't empty set the Intention to AI_INTENTION_ACTIVE
-				if (!npc.getKnownList().getKnownPlayers().isEmpty())
-				{
+				if (!npc.getKnownList().getKnownPlayers().isEmpty()) {
 					intention = AI_INTENTION_ACTIVE;
-				}
-				else
-				{
+				} else {
 					intention = AI_INTENTION_IDLE;
 				}
 			}
 			
-			if (intention == AI_INTENTION_IDLE)
-			{
+			if (intention == AI_INTENTION_IDLE) {
 				// Set the Intention of this L2AttackableAI to AI_INTENTION_IDLE
 				super.changeIntention(AI_INTENTION_IDLE, null, null);
 				
 				// Stop AI task and detach AI from NPC
-				if (_aiTask != null)
-				{
+				if (_aiTask != null) {
 					_aiTask.cancel(true);
 					_aiTask = null;
 				}
@@ -222,8 +203,7 @@ public class L2SiegeGuardAI extends L2CharacterAI implements Runnable
 		super.changeIntention(intention, arg0, arg1);
 		
 		// If not idle - create an AI task (schedule onEvtThink repeatedly)
-		if (_aiTask == null)
-		{
+		if (_aiTask == null) {
 			_aiTask = ThreadPoolManager.getInstance().scheduleAiAtFixedRate(this, 1000, 1000);
 		}
 	}
@@ -233,8 +213,7 @@ public class L2SiegeGuardAI extends L2CharacterAI implements Runnable
 	 * @param target The L2Character to attack
 	 */
 	@Override
-	protected void onIntentionAttack(L2Character target)
-	{
+	protected void onIntentionAttack(L2Character target) {
 		// Calculate the attack timeout
 		_attackTimeout = MAX_ATTACK_TIMEOUT + GameTimeController.getInstance().getGameTicks();
 		
@@ -252,31 +231,23 @@ public class L2SiegeGuardAI extends L2CharacterAI implements Runnable
 	 * <li>If the actor can't attack, order to it to return to its home location</li>
 	 * </ul>
 	 */
-	private void thinkActive()
-	{
+	private void thinkActive() {
 		L2Attackable npc = (L2Attackable) _actor;
 		
 		// Update every 1s the _globalAggro counter to come close to 0
-		if (_globalAggro != 0)
-		{
-			if (_globalAggro < 0)
-			{
+		if (_globalAggro != 0) {
+			if (_globalAggro < 0) {
 				_globalAggro++;
-			}
-			else
-			{
+			} else {
 				_globalAggro--;
 			}
 		}
 		
 		// Add all autoAttackable L2Character in L2Attackable Aggro Range to its _aggroList with 0 damage and 1 hate
 		// A L2Attackable isn't aggressive during 10s after its spawn because _globalAggro is set to -10
-		if (_globalAggro >= 0)
-		{
-			for (L2Character target : npc.getKnownList().getKnownCharactersInRadius(_attackRange))
-			{
-				if (target == null)
-				{
+		if (_globalAggro >= 0) {
+			for (L2Character target : npc.getKnownList().getKnownCharactersInRadius(_attackRange)) {
+				if (target == null) {
 					continue;
 				}
 				if (autoAttackCondition(target)) // check aggression
@@ -285,8 +256,7 @@ public class L2SiegeGuardAI extends L2CharacterAI implements Runnable
 					long hating = npc.getHating(target);
 					
 					// Add the attacker to the L2Attackable _aggroList with 0 damage and 1 hate
-					if (hating == 0)
-					{
+					if (hating == 0) {
 						npc.addDamageHate(target, 0, 1);
 					}
 				}
@@ -294,27 +264,21 @@ public class L2SiegeGuardAI extends L2CharacterAI implements Runnable
 			
 			// Chose a target from its aggroList
 			L2Character hated;
-			if (_actor.isConfused())
-			{
+			if (_actor.isConfused()) {
 				hated = getAttackTarget(); // Force mobs to attack anybody if confused
-			}
-			else
-			{
+			} else {
 				hated = npc.getMostHated();
 				// _mostHatedAnalysis.Update(hated);
 			}
 			
 			// Order to the L2Attackable to attack the target
-			if (hated != null)
-			{
+			if (hated != null) {
 				// Get the hate level of the L2Attackable against this L2Character target contained in _aggroList
 				long aggro = npc.getHating(hated);
 				
-				if ((aggro + _globalAggro) > 0)
-				{
+				if ((aggro + _globalAggro) > 0) {
 					// Set the L2Character movement type to run and send Server->Client packet ChangeMoveType to all others L2PcInstance
-					if (!_actor.isRunning())
-					{
+					if (!_actor.isRunning()) {
 						_actor.setRunning();
 					}
 					
@@ -341,15 +305,12 @@ public class L2SiegeGuardAI extends L2CharacterAI implements Runnable
 	 * </ul>
 	 * TODO: Manage casting rules to healer mobs (like Ant Nurses)
 	 */
-	private void thinkAttack()
-	{
+	private void thinkAttack() {
 		LOG.debug("{}: thinkAttack(); timeout={}", getClass().getSimpleName(), (_attackTimeout - GameTimeController.getInstance().getGameTicks()));
 		
-		if (_attackTimeout < GameTimeController.getInstance().getGameTicks())
-		{
+		if (_attackTimeout < GameTimeController.getInstance().getGameTicks()) {
 			// Check if the actor is running
-			if (_actor.isRunning())
-			{
+			if (_actor.isRunning()) {
 				// Set the actor movement type to walk and send Server->Client packet ChangeMoveType to all others L2PcInstance
 				_actor.setWalking();
 				
@@ -360,11 +321,9 @@ public class L2SiegeGuardAI extends L2CharacterAI implements Runnable
 		
 		L2Character attackTarget = getAttackTarget();
 		// Check if target is dead or if timeout is expired to stop this attack
-		if ((attackTarget == null) || attackTarget.isAlikeDead() || (_attackTimeout < GameTimeController.getInstance().getGameTicks()))
-		{
+		if ((attackTarget == null) || attackTarget.isAlikeDead() || (_attackTimeout < GameTimeController.getInstance().getGameTicks())) {
 			// Stop hating this target after the attack timeout or if target is dead
-			if (attackTarget != null)
-			{
+			if (attackTarget != null) {
 				L2Attackable npc = (L2Attackable) _actor;
 				npc.stopHating(attackTarget);
 			}
@@ -384,58 +343,44 @@ public class L2SiegeGuardAI extends L2CharacterAI implements Runnable
 		attackPrepare();
 	}
 	
-	private final void factionNotifyAndSupport()
-	{
+	private final void factionNotifyAndSupport() {
 		L2Character target = getAttackTarget();
 		// Call all L2Object of its Faction inside the Faction Range
-		if ((((L2Npc) _actor).getTemplate().getClans() == null) || (target == null))
-		{
+		if ((((L2Npc) _actor).getTemplate().getClans() == null) || (target == null)) {
 			return;
 		}
 		
-		if (target.isInvul())
-		{
+		if (target.isInvul()) {
 			return; // speeding it up for siege guards
 		}
 		
 		// Go through all L2Character that belong to its faction
 		// for (L2Character cha : _actor.getKnownList().getKnownCharactersInRadius(((L2NpcInstance) _actor).getFactionRange()+_actor.getTemplate().collisionRadius))
-		for (L2Character cha : _actor.getKnownList().getKnownCharactersInRadius(1000))
-		{
-			if (cha == null)
-			{
+		for (L2Character cha : _actor.getKnownList().getKnownCharactersInRadius(1000)) {
+			if (cha == null) {
 				continue;
 			}
 			
-			if (!(cha instanceof L2Npc))
-			{
-				if (_selfAnalysis.hasHealOrResurrect && (cha instanceof L2PcInstance) && (((L2Npc) _actor).getCastle().getSiege().checkIsDefender(((L2PcInstance) cha).getClan())))
-				{
+			if (!(cha instanceof L2Npc)) {
+				if (_selfAnalysis.hasHealOrResurrect && (cha instanceof L2PcInstance) && (((L2Npc) _actor).getCastle().getSiege().checkIsDefender(((L2PcInstance) cha).getClan()))) {
 					// heal friends
-					if (!_actor.isAttackingDisabled() && (cha.getCurrentHp() < (cha.getMaxHp() * 0.6)) && (_actor.getCurrentHp() > (_actor.getMaxHp() / 2)) && (_actor.getCurrentMp() > (_actor.getMaxMp() / 2)) && cha.isInCombat())
-					{
-						for (Skill sk : _selfAnalysis.healSkills)
-						{
-							if (_actor.getCurrentMp() < sk.getMpConsume2())
-							{
+					if (!_actor.isAttackingDisabled() && (cha.getCurrentHp() < (cha.getMaxHp() * 0.6)) && (_actor.getCurrentHp() > (_actor.getMaxHp() / 2)) && (_actor.getCurrentMp() > (_actor.getMaxMp() / 2)) && cha.isInCombat()) {
+						for (Skill sk : _selfAnalysis.healSkills) {
+							if (_actor.getCurrentMp() < sk.getMpConsume2()) {
 								continue;
 							}
-							if (_actor.isSkillDisabled(sk))
-							{
+							if (_actor.isSkillDisabled(sk)) {
 								continue;
 							}
-							if (!Util.checkIfInRange(sk.getCastRange(), _actor, cha, true))
-							{
+							if (!Util.checkIfInRange(sk.getCastRange(), _actor, cha, true)) {
 								continue;
 							}
 							
 							int chance = 5;
-							if (chance >= Rnd.get(100))
-							{
+							if (chance >= Rnd.get(100)) {
 								continue;
 							}
-							if (!GeoData.getInstance().canSeeTarget(_actor, cha))
-							{
+							if (!GeoData.getInstance().canSeeTarget(_actor, cha)) {
 								break;
 							}
 							
@@ -453,8 +398,7 @@ public class L2SiegeGuardAI extends L2CharacterAI implements Runnable
 			
 			L2Npc npc = (L2Npc) cha;
 			
-			if (!npc.isInMyClan((L2Npc) _actor))
-			{
+			if (!npc.isInMyClan((L2Npc) _actor)) {
 				continue;
 			}
 			
@@ -464,37 +408,29 @@ public class L2SiegeGuardAI extends L2CharacterAI implements Runnable
 				// && _actor.getAttackByList().contains(getAttackTarget())
 					&& ((npc.getAI()._intention == CtrlIntention.AI_INTENTION_IDLE) || (npc.getAI()._intention == CtrlIntention.AI_INTENTION_ACTIVE))
 					// limiting aggro for siege guards
-					&& target.isInsideRadius(npc, 1500, true, false) && GeoData.getInstance().canSeeTarget(npc, target))
-				{
+					&& target.isInsideRadius(npc, 1500, true, false) && GeoData.getInstance().canSeeTarget(npc, target)) {
 					// Notify the L2Object AI with EVT_AGGRESSION
 					npc.getAI().notifyEvent(CtrlEvent.EVT_AGGRESSION, getAttackTarget(), 1);
 					return;
 				}
 				// heal friends
-				if (_selfAnalysis.hasHealOrResurrect && !_actor.isAttackingDisabled() && (npc.getCurrentHp() < (npc.getMaxHp() * 0.6)) && (_actor.getCurrentHp() > (_actor.getMaxHp() / 2)) && (_actor.getCurrentMp() > (_actor.getMaxMp() / 2)) && npc.isInCombat())
-				{
-					for (Skill sk : _selfAnalysis.healSkills)
-					{
-						if (_actor.getCurrentMp() < sk.getMpConsume2())
-						{
+				if (_selfAnalysis.hasHealOrResurrect && !_actor.isAttackingDisabled() && (npc.getCurrentHp() < (npc.getMaxHp() * 0.6)) && (_actor.getCurrentHp() > (_actor.getMaxHp() / 2)) && (_actor.getCurrentMp() > (_actor.getMaxMp() / 2)) && npc.isInCombat()) {
+					for (Skill sk : _selfAnalysis.healSkills) {
+						if (_actor.getCurrentMp() < sk.getMpConsume2()) {
 							continue;
 						}
-						if (_actor.isSkillDisabled(sk))
-						{
+						if (_actor.isSkillDisabled(sk)) {
 							continue;
 						}
-						if (!Util.checkIfInRange(sk.getCastRange(), _actor, npc, true))
-						{
+						if (!Util.checkIfInRange(sk.getCastRange(), _actor, npc, true)) {
 							continue;
 						}
 						
 						int chance = 4;
-						if (chance >= Rnd.get(100))
-						{
+						if (chance >= Rnd.get(100)) {
 							continue;
 						}
-						if (!GeoData.getInstance().canSeeTarget(_actor, npc))
-						{
+						if (!GeoData.getInstance().canSeeTarget(_actor, npc)) {
 							break;
 						}
 						
@@ -510,8 +446,7 @@ public class L2SiegeGuardAI extends L2CharacterAI implements Runnable
 		}
 	}
 	
-	private void attackPrepare()
-	{
+	private void attackPrepare() {
 		// Get all information needed to choose between physical or magical attack
 		Collection<Skill> skills = null;
 		double dist_2 = 0;
@@ -519,29 +454,23 @@ public class L2SiegeGuardAI extends L2CharacterAI implements Runnable
 		L2DefenderInstance sGuard = (L2DefenderInstance) _actor;
 		L2Character attackTarget = getAttackTarget();
 		
-		try
-		{
+		try {
 			_actor.setTarget(attackTarget);
 			skills = _actor.getAllSkills();
 			dist_2 = _actor.calculateDistance(attackTarget, false, true);
 			range = _actor.getPhysicalAttackRange() + _actor.getTemplate().getCollisionRadius() + attackTarget.getTemplate().getCollisionRadius();
-			if (attackTarget.isMoving())
-			{
+			if (attackTarget.isMoving()) {
 				range += 50;
 			}
-		}
-		catch (NullPointerException e)
-		{
+		} catch (NullPointerException e) {
 			_actor.setTarget(null);
 			setIntention(AI_INTENTION_IDLE, null, null);
 			return;
 		}
 		
 		// never attack defenders
-		if (attackTarget instanceof L2PcInstance)
-		{
-			if ((sGuard.getConquerableHall() == null) && sGuard.getCastle().getSiege().checkIsDefender(((L2PcInstance) attackTarget).getClan()))
-			{
+		if (attackTarget instanceof L2PcInstance) {
+			if ((sGuard.getConquerableHall() == null) && sGuard.getCastle().getSiege().checkIsDefender(((L2PcInstance) attackTarget).getClan())) {
 				// Cancel the target
 				sGuard.stopHating(attackTarget);
 				_actor.setTarget(null);
@@ -550,8 +479,7 @@ public class L2SiegeGuardAI extends L2CharacterAI implements Runnable
 			}
 		}
 		
-		if (!GeoData.getInstance().canSeeTarget(_actor, attackTarget))
-		{
+		if (!GeoData.getInstance().canSeeTarget(_actor, attackTarget)) {
 			// Siege guards differ from normal mobs currently:
 			// If target cannot seen, don't attack any more
 			sGuard.stopHating(attackTarget);
@@ -561,33 +489,26 @@ public class L2SiegeGuardAI extends L2CharacterAI implements Runnable
 		}
 		
 		// Check if the actor isn't muted and if it is far from target
-		if (!_actor.isMuted() && (dist_2 > (range * range)))
-		{
+		if (!_actor.isMuted() && (dist_2 > (range * range))) {
 			// check for long ranged skills and heal/buff skills
-			for (Skill sk : skills)
-			{
+			for (Skill sk : skills) {
 				int castRange = sk.getCastRange();
 				
-				if ((dist_2 <= (castRange * castRange)) && (castRange > 70) && !_actor.isSkillDisabled(sk) && (_actor.getCurrentMp() >= _actor.getStat().getMpConsume2(sk)) && !sk.isPassive())
-				{
+				if ((dist_2 <= (castRange * castRange)) && (castRange > 70) && !_actor.isSkillDisabled(sk) && (_actor.getCurrentMp() >= _actor.getStat().getMpConsume2(sk)) && !sk.isPassive()) {
 					
 					L2Object OldTarget = _actor.getTarget();
-					if ((sk.isContinuous() && !sk.isDebuff()) || (sk.hasEffectType(L2EffectType.HP)))
-					{
+					if ((sk.isContinuous() && !sk.isDebuff()) || (sk.hasEffectType(L2EffectType.HP))) {
 						boolean useSkillSelf = true;
-						if ((sk.hasEffectType(L2EffectType.HP)) && (_actor.getCurrentHp() > (int) (_actor.getMaxHp() / 1.5)))
-						{
+						if ((sk.hasEffectType(L2EffectType.HP)) && (_actor.getCurrentHp() > (int) (_actor.getMaxHp() / 1.5))) {
 							useSkillSelf = false;
 							break;
 						}
 						
-						if ((sk.isContinuous() && !sk.isDebuff()) && _actor.isAffectedBySkill(sk.getId()))
-						{
+						if ((sk.isContinuous() && !sk.isDebuff()) && _actor.isAffectedBySkill(sk.getId())) {
 							useSkillSelf = false;
 						}
 						
-						if (useSkillSelf)
-						{
+						if (useSkillSelf) {
 							_actor.setTarget(_actor);
 						}
 					}
@@ -600,15 +521,12 @@ public class L2SiegeGuardAI extends L2CharacterAI implements Runnable
 			}
 			
 			// Check if the L2SiegeGuardInstance is attacking, knows the target and can't run
-			if (!(_actor.isAttackingNow()) && (_actor.getRunSpeed() == 0) && (_actor.getKnownList().knowsObject(attackTarget)))
-			{
+			if (!(_actor.isAttackingNow()) && (_actor.getRunSpeed() == 0) && (_actor.getKnownList().knowsObject(attackTarget))) {
 				// Cancel the target
 				_actor.getKnownList().removeKnownObject(attackTarget);
 				_actor.setTarget(null);
 				setIntention(AI_INTENTION_IDLE, null, null);
-			}
-			else
-			{
+			} else {
 				double dx = _actor.getX() - attackTarget.getX();
 				double dy = _actor.getY() - attackTarget.getY();
 				double dz = _actor.getZ() - attackTarget.getZ();
@@ -617,34 +535,27 @@ public class L2SiegeGuardAI extends L2CharacterAI implements Runnable
 				
 				// Check if the L2SiegeGuardInstance isn't too far from it's home location
 				if ((((dx * dx) + (dy * dy)) > 10000) && (((homeX * homeX) + (homeY * homeY)) > 3240000) // 1800 * 1800
-					&& (_actor.getKnownList().knowsObject(attackTarget)))
-				{
+					&& (_actor.getKnownList().knowsObject(attackTarget))) {
 					// Cancel the target
 					_actor.getKnownList().removeKnownObject(attackTarget);
 					_actor.setTarget(null);
 					setIntention(AI_INTENTION_IDLE, null, null);
-				}
-				else
+				} else
 				// Move the actor to Pawn server side AND client side by sending Server->Client packet MoveToPawn (broadcast)
 				{
 					// Temporary hack for preventing guards jumping off towers,
 					// before replacing this with effective geodata checks and AI modification
 					if ((dz * dz) < (170 * 170)) // normally 130 if guard z coordinates correct
 					{
-						if (_selfAnalysis.isHealer)
-						{
+						if (_selfAnalysis.isHealer) {
 							return;
 						}
-						if (_selfAnalysis.isMage)
-						{
+						if (_selfAnalysis.isMage) {
 							range = _selfAnalysis.maxCastRange - 50;
 						}
-						if (attackTarget.isMoving())
-						{
+						if (attackTarget.isMoving()) {
 							moveToPawn(attackTarget, range - 70);
-						}
-						else
-						{
+						} else {
 							moveToPawn(attackTarget, range);
 						}
 					}
@@ -655,80 +566,62 @@ public class L2SiegeGuardAI extends L2CharacterAI implements Runnable
 			
 		}
 		// Else, if the actor is muted and far from target, just "move to pawn"
-		else if (_actor.isMuted() && (dist_2 > (range * range)) && !_selfAnalysis.isHealer)
-		{
+		else if (_actor.isMuted() && (dist_2 > (range * range)) && !_selfAnalysis.isHealer) {
 			// Temporary hack for preventing guards jumping off towers,
 			// before replacing this with effective geodata checks and AI modification
 			double dz = _actor.getZ() - attackTarget.getZ();
 			if ((dz * dz) < (170 * 170)) // normally 130 if guard z coordinates correct
 			{
-				if (_selfAnalysis.isMage)
-				{
+				if (_selfAnalysis.isMage) {
 					range = _selfAnalysis.maxCastRange - 50;
 				}
-				if (attackTarget.isMoving())
-				{
+				if (attackTarget.isMoving()) {
 					moveToPawn(attackTarget, range - 70);
-				}
-				else
-				{
+				} else {
 					moveToPawn(attackTarget, range);
 				}
 			}
 			return;
 		}
 		// Else, if this is close enough to attack
-		else if (dist_2 <= (range * range))
-		{
+		else if (dist_2 <= (range * range)) {
 			// Force mobs to attack anybody if confused
 			L2Character hated = null;
-			if (_actor.isConfused())
-			{
+			if (_actor.isConfused()) {
 				hated = attackTarget;
-			}
-			else
-			{
+			} else {
 				hated = ((L2Attackable) _actor).getMostHated();
 			}
 			
-			if (hated == null)
-			{
+			if (hated == null) {
 				setIntention(AI_INTENTION_ACTIVE, null, null);
 				return;
 			}
-			if (hated != attackTarget)
-			{
+			if (hated != attackTarget) {
 				attackTarget = hated;
 			}
 			
 			_attackTimeout = MAX_ATTACK_TIMEOUT + GameTimeController.getInstance().getGameTicks();
 			
 			// check for close combat skills && heal/buff skills
-			if (!_actor.isMuted() && (Rnd.nextInt(100) <= 5))
-			{
-				for (Skill sk : skills)
-				{
+			if (!_actor.isMuted() && (Rnd.nextInt(100) <= 5)) {
+				for (Skill sk : skills) {
 					int castRange = sk.getCastRange();
 					
-					if (((castRange * castRange) >= dist_2) && !sk.isPassive() && (_actor.getCurrentMp() >= _actor.getStat().getMpConsume2(sk)) && !_actor.isSkillDisabled(sk))
-					{
+					if (((castRange * castRange) >= dist_2) && !sk.isPassive() && (_actor.getCurrentMp() >= _actor.getStat().getMpConsume2(sk)) && !_actor.isSkillDisabled(sk)) {
 						L2Object OldTarget = _actor.getTarget();
-						if ((sk.isContinuous() && !sk.isDebuff()) || (sk.hasEffectType(L2EffectType.HP)))
-						{
+						if ((sk.isContinuous() && !sk.isDebuff()) || (sk.hasEffectType(L2EffectType.HP))) {
 							boolean useSkillSelf = true;
-							if ((sk.hasEffectType(L2EffectType.HP)) && (_actor.getCurrentHp() > (int) (_actor.getMaxHp() / 1.5)))
-							{
+							if ((sk.hasEffectType(L2EffectType.HP)) && (_actor.getCurrentHp() > (int) (_actor.getMaxHp() / 1.5))) {
 								useSkillSelf = false;
 								break;
 							}
 							
-							if ((sk.isContinuous() && !sk.isDebuff()) && _actor.isAffectedBySkill(sk.getId()))
-							{
+							if ((sk.isContinuous() && !sk.isDebuff()) && _actor.isAffectedBySkill(sk.getId())) {
 								useSkillSelf = false;
 							}
 							
-							if (useSkillSelf)
-							{
+							if (useSkillSelf) {
 								_actor.setTarget(_actor);
 							}
 						}
@@ -741,8 +634,7 @@ public class L2SiegeGuardAI extends L2CharacterAI implements Runnable
 				}
 			}
 			// Finally, do the physical attack itself
-			if (!_selfAnalysis.isHealer)
-			{
+			if (!_selfAnalysis.isHealer) {
 				_actor.doAttack(attackTarget);
 			}
 		}
@@ -752,34 +644,26 @@ public class L2SiegeGuardAI extends L2CharacterAI implements Runnable
 	 * Manage AI thinking actions of a L2Attackable.
 	 */
 	@Override
-	protected void onEvtThink()
-	{
+	protected void onEvtThink() {
 		// if(getIntention() != AI_INTENTION_IDLE && (!_actor.isVisible() || !_actor.hasAI() || !_actor.isKnownPlayers()))
 		// setIntention(AI_INTENTION_IDLE);
 		
 		// Check if the thinking action is already in progress
-		if (_thinking || _actor.isCastingNow() || _actor.isAllSkillsDisabled())
-		{
+		if (_thinking || _actor.isCastingNow() || _actor.isAllSkillsDisabled()) {
 			return;
 		}
 		
 		// Start thinking action
 		_thinking = true;
 		
-		try
-		{
+		try {
 			// Manage AI thinks of a L2Attackable
-			if (getIntention() == AI_INTENTION_ACTIVE)
-			{
+			if (getIntention() == AI_INTENTION_ACTIVE) {
 				thinkActive();
-			}
-			else if (getIntention() == AI_INTENTION_ATTACK)
-			{
+			} else if (getIntention() == AI_INTENTION_ATTACK) {
 				thinkAttack();
 			}
-		}
-		finally
-		{
+		} finally {
 			// Stop thinking action
 			_thinking = false;
 		}
@@ -796,14 +680,12 @@ public class L2SiegeGuardAI extends L2CharacterAI implements Runnable
 	 * @param attacker The L2Character that attacks the actor
 	 */
 	@Override
-	protected void onEvtAttacked(L2Character attacker)
-	{
+	protected void onEvtAttacked(L2Character attacker) {
 		// Calculate the attack timeout
 		_attackTimeout = MAX_ATTACK_TIMEOUT + GameTimeController.getInstance().getGameTicks();
 		
 		// Set the _globalAggro to 0 to permit attack even just after spawn
-		if (_globalAggro < 0)
-		{
+		if (_globalAggro < 0) {
 			_globalAggro = 0;
 		}
 		
@@ -811,14 +693,12 @@ public class L2SiegeGuardAI extends L2CharacterAI implements Runnable
 		((L2Attackable) _actor).addDamageHate(attacker, 0, 1);
 		
 		// Set the L2Character movement type to run and send Server->Client packet ChangeMoveType to all others L2PcInstance
-		if (!_actor.isRunning())
-		{
+		if (!_actor.isRunning()) {
 			_actor.setRunning();
 		}
 		
 		// Set the Intention to AI_INTENTION_ATTACK
-		if (getIntention() != AI_INTENTION_ATTACK)
-		{
+		if (getIntention() != AI_INTENTION_ATTACK) {
 			setIntention(CtrlIntention.AI_INTENTION_ATTACK, attacker, null);
 		}
 		
@@ -835,26 +715,21 @@ public class L2SiegeGuardAI extends L2CharacterAI implements Runnable
 	 * @param aggro The value of hate to add to the actor against the target
 	 */
 	@Override
-	protected void onEvtAggression(L2Character target, long aggro)
-	{
-		if (_actor == null)
-		{
+	protected void onEvtAggression(L2Character target, long aggro) {
+		if (_actor == null) {
 			return;
 		}
 		L2Attackable me = (L2Attackable) _actor;
 		
-		if (target != null)
-		{
+		if (target != null) {
 			// Add the target to the actor _aggroList or update hate if already present
 			me.addDamageHate(target, 0, aggro);
 			
 			// Get the hate of the actor against the target
 			aggro = me.getHating(target);
 			
-			if (aggro <= 0)
-			{
-				if (me.getMostHated() == null)
-				{
+			if (aggro <= 0) {
+				if (me.getMostHated() == null) {
 					_globalAggro = -25;
 					me.clearAggroList();
 					setIntention(AI_INTENTION_IDLE, null, null);
@@ -863,11 +738,9 @@ public class L2SiegeGuardAI extends L2CharacterAI implements Runnable
 			}
 			
 			// Set the actor AI Intention to AI_INTENTION_ATTACK
-			if (getIntention() != CtrlIntention.AI_INTENTION_ATTACK)
-			{
+			if (getIntention() != CtrlIntention.AI_INTENTION_ATTACK) {
 				// Set the L2Character movement type to run and send Server->Client packet ChangeMoveType to all others L2PcInstance
-				if (!_actor.isRunning())
-				{
+				if (!_actor.isRunning()) {
 					_actor.setRunning();
 				}
 				
@@ -876,35 +749,28 @@ public class L2SiegeGuardAI extends L2CharacterAI implements Runnable
 				double homeY = target.getY() - sGuard.getSpawn().getY();
 				
 				// Check if the L2SiegeGuardInstance is not too far from its home location
-				if (((homeX * homeX) + (homeY * homeY)) < 3240000)
-				{
+				if (((homeX * homeX) + (homeY * homeY)) < 3240000) {
 					setIntention(CtrlIntention.AI_INTENTION_ATTACK, target, null);
 				}
 			}
-		}
-		else
-		{
+		} else {
 			// currently only for setting lower general aggro
-			if (aggro >= 0)
-			{
+			if (aggro >= 0) {
 				return;
 			}
 			
 			L2Character mostHated = me.getMostHated();
-			if (mostHated == null)
-			{
+			if (mostHated == null) {
 				_globalAggro = -25;
 				return;
 			}
 			
-			for (L2Character aggroed : me.getAggroList().keySet())
-			{
+			for (L2Character aggroed : me.getAggroList().keySet()) {
 				me.addDamageHate(aggroed, 0, aggro);
 			}
 			
 			aggro = me.getHating(mostHated);
-			if (aggro <= 0)
-			{
+			if (aggro <= 0) {
 				_globalAggro = -25;
 				me.clearAggroList();
 				setIntention(AI_INTENTION_IDLE, null, null);
@@ -913,10 +779,8 @@ public class L2SiegeGuardAI extends L2CharacterAI implements Runnable
 	}
 	
 	@Override
-	public void stopAITask()
-	{
-		if (_aiTask != null)
-		{
+	public void stopAITask() {
+		if (_aiTask != null) {
 			_aiTask.cancel(false);
 			_aiTask = null;
 		}

+ 5 - 10
src/main/java/com/l2jserver/gameserver/ai/L2SpecialSiegeGuardAI.java

@@ -27,28 +27,23 @@ import com.l2jserver.gameserver.model.actor.instance.L2DefenderInstance;
 /**
  * @author BiggBoss
  */
-public final class L2SpecialSiegeGuardAI extends L2SiegeGuardAI
-{
+public final class L2SpecialSiegeGuardAI extends L2SiegeGuardAI {
 	private final List<Integer> _allied = new ArrayList<>();
 	
 	/**
 	 * @param creature
 	 */
-	public L2SpecialSiegeGuardAI(L2DefenderInstance creature)
-	{
+	public L2SpecialSiegeGuardAI(L2DefenderInstance creature) {
 		super(creature);
 	}
 	
-	public List<Integer> getAlly()
-	{
+	public List<Integer> getAlly() {
 		return _allied;
 	}
 	
 	@Override
-	protected boolean autoAttackCondition(L2Character target)
-	{
-		if (_allied.contains(target.getObjectId()))
-		{
+	protected boolean autoAttackCondition(L2Character target) {
+		if (_allied.contains(target.getObjectId())) {
 			return false;
 		}
 		

+ 49 - 102
src/main/java/com/l2jserver/gameserver/ai/L2SummonAI.java

@@ -34,8 +34,7 @@ import com.l2jserver.gameserver.model.skills.Skill;
 import com.l2jserver.gameserver.pathfinding.PathFinding;
 import com.l2jserver.util.Rnd;
 
-public class L2SummonAI extends L2PlayableAI implements Runnable
-{
+public class L2SummonAI extends L2PlayableAI implements Runnable {
 	private static final int AVOID_RADIUS = 70;
 	
 	private volatile boolean _thinking; // to prevent recursive thinking
@@ -45,16 +44,13 @@ public class L2SummonAI extends L2PlayableAI implements Runnable
 	private volatile boolean _startAvoid = false;
 	private Future<?> _avoidTask = null;
 	
-	public L2SummonAI(L2Summon creature)
-	{
+	public L2SummonAI(L2Summon creature) {
 		super(creature);
 	}
 	
 	@Override
-	protected void onIntentionAttack(L2Character target)
-	{
-		if ((Config.PATHFINDING > 0) && (PathFinding.getInstance().findPath(_actor.getX(), _actor.getY(), _actor.getZ(), target.getX(), target.getY(), target.getZ(), _actor.getInstanceId(), true) == null))
-		{
+	protected void onIntentionAttack(L2Character target) {
+		if ((Config.PATHFINDING > 0) && (PathFinding.getInstance().findPath(_actor.getX(), _actor.getY(), _actor.getZ(), target.getX(), target.getY(), target.getZ(), _actor.getInstanceId(), true) == null)) {
 			return;
 		}
 		
@@ -62,32 +58,25 @@ public class L2SummonAI extends L2PlayableAI implements Runnable
 	}
 	
 	@Override
-	protected void onIntentionIdle()
-	{
+	protected void onIntentionIdle() {
 		stopFollow();
 		_startFollow = false;
 		onIntentionActive();
 	}
 	
 	@Override
-	protected void onIntentionActive()
-	{
+	protected void onIntentionActive() {
 		L2Summon summon = (L2Summon) _actor;
-		if (_startFollow)
-		{
+		if (_startFollow) {
 			setIntention(AI_INTENTION_FOLLOW, summon.getOwner());
-		}
-		else
-		{
+		} else {
 			super.onIntentionActive();
 		}
 	}
 	
 	@Override
-	synchronized void changeIntention(CtrlIntention intention, Object arg0, Object arg1)
-	{
-		switch (intention)
-		{
+	synchronized void changeIntention(CtrlIntention intention, Object arg0, Object arg1) {
+		switch (intention) {
 			case AI_INTENTION_ACTIVE:
 			case AI_INTENTION_FOLLOW:
 				startAvoidTask();
@@ -99,32 +88,26 @@ public class L2SummonAI extends L2PlayableAI implements Runnable
 		super.changeIntention(intention, arg0, arg1);
 	}
 	
-	private void thinkAttack()
-	{
-		if (checkTargetLostOrDead(getAttackTarget()))
-		{
+	private void thinkAttack() {
+		if (checkTargetLostOrDead(getAttackTarget())) {
 			setAttackTarget(null);
 			return;
 		}
-		if (maybeMoveToPawn(getAttackTarget(), _actor.getPhysicalAttackRange()))
-		{
+		if (maybeMoveToPawn(getAttackTarget(), _actor.getPhysicalAttackRange())) {
 			return;
 		}
 		clientStopMoving(null);
 		_actor.doAttack(getAttackTarget());
 	}
 	
-	private void thinkCast()
-	{
+	private void thinkCast() {
 		L2Summon summon = (L2Summon) _actor;
-		if (checkTargetLost(getCastTarget()))
-		{
+		if (checkTargetLost(getCastTarget())) {
 			setCastTarget(null);
 			return;
 		}
 		boolean val = _startFollow;
-		if (maybeMoveToPawn(getCastTarget(), _actor.getMagicalAttackRange(_skill)))
-		{
+		if (maybeMoveToPawn(getCastTarget(), _actor.getMagicalAttackRange(_skill))) {
 			return;
 		}
 		clientStopMoving(null);
@@ -134,45 +117,35 @@ public class L2SummonAI extends L2PlayableAI implements Runnable
 		_actor.doCast(_skill);
 	}
 	
-	private void thinkPickUp()
-	{
-		if (checkTargetLost(getTarget()))
-		{
+	private void thinkPickUp() {
+		if (checkTargetLost(getTarget())) {
 			return;
 		}
-		if (maybeMoveToPawn(getTarget(), 36))
-		{
+		if (maybeMoveToPawn(getTarget(), 36)) {
 			return;
 		}
 		setIntention(AI_INTENTION_IDLE);
 		((L2Summon) _actor).doPickupItem(getTarget());
 	}
 	
-	private void thinkInteract()
-	{
-		if (checkTargetLost(getTarget()))
-		{
+	private void thinkInteract() {
+		if (checkTargetLost(getTarget())) {
 			return;
 		}
-		if (maybeMoveToPawn(getTarget(), 36))
-		{
+		if (maybeMoveToPawn(getTarget(), 36)) {
 			return;
 		}
 		setIntention(AI_INTENTION_IDLE);
 	}
 	
 	@Override
-	protected void onEvtThink()
-	{
-		if (_thinking || _actor.isCastingNow() || _actor.isAllSkillsDisabled())
-		{
+	protected void onEvtThink() {
+		if (_thinking || _actor.isCastingNow() || _actor.isAllSkillsDisabled()) {
 			return;
 		}
 		_thinking = true;
-		try
-		{
-			switch (getIntention())
-			{
+		try {
+			switch (getIntention()) {
 				case AI_INTENTION_ATTACK:
 					thinkAttack();
 					break;
@@ -186,80 +159,64 @@ public class L2SummonAI extends L2PlayableAI implements Runnable
 					thinkInteract();
 					break;
 			}
-		}
-		finally
-		{
+		} finally {
 			_thinking = false;
 		}
 	}
 	
 	@Override
-	protected void onEvtFinishCasting()
-	{
-		if (_lastAttack == null)
-		{
+	protected void onEvtFinishCasting() {
+		if (_lastAttack == null) {
 			((L2Summon) _actor).setFollowStatus(_startFollow);
-		}
-		else
-		{
+		} else {
 			setIntention(CtrlIntention.AI_INTENTION_ATTACK, _lastAttack);
 			_lastAttack = null;
 		}
 	}
 	
 	@Override
-	protected void onEvtAttacked(L2Character attacker)
-	{
+	protected void onEvtAttacked(L2Character attacker) {
 		super.onEvtAttacked(attacker);
 		
 		avoidAttack(attacker);
 	}
 	
 	@Override
-	protected void onEvtEvaded(L2Character attacker)
-	{
+	protected void onEvtEvaded(L2Character attacker) {
 		super.onEvtEvaded(attacker);
 		
 		avoidAttack(attacker);
 	}
 	
-	private void avoidAttack(L2Character attacker)
-	{
+	private void avoidAttack(L2Character attacker) {
 		// trying to avoid if summon near owner
-		if ((((L2Summon) _actor).getOwner() != null) && (((L2Summon) _actor).getOwner() != attacker) && ((L2Summon) _actor).getOwner().isInsideRadius(_actor, 2 * AVOID_RADIUS, true, false))
-		{
+		if ((((L2Summon) _actor).getOwner() != null) && (((L2Summon) _actor).getOwner() != attacker) && ((L2Summon) _actor).getOwner().isInsideRadius(_actor, 2 * AVOID_RADIUS, true, false)) {
 			_startAvoid = true;
 		}
 	}
 	
 	@Override
-	public void run()
-	{
-		if (_startAvoid)
-		{
+	public void run() {
+		if (_startAvoid) {
 			_startAvoid = false;
 			
-			if (!_clientMoving && !_actor.isDead() && !_actor.isMovementDisabled())
-			{
+			if (!_clientMoving && !_actor.isDead() && !_actor.isMovementDisabled()) {
 				final int ownerX = ((L2Summon) _actor).getOwner().getX();
 				final int ownerY = ((L2Summon) _actor).getOwner().getY();
 				final double angle = Math.toRadians(Rnd.get(-90, 90)) + Math.atan2(ownerY - _actor.getY(), ownerX - _actor.getX());
 				
 				final int targetX = ownerX + (int) (AVOID_RADIUS * Math.cos(angle));
 				final int targetY = ownerY + (int) (AVOID_RADIUS * Math.sin(angle));
-				if (GeoData.getInstance().canMove(_actor.getX(), _actor.getY(), _actor.getZ(), targetX, targetY, _actor.getZ(), _actor.getInstanceId()))
-				{
+				if (GeoData.getInstance().canMove(_actor.getX(), _actor.getY(), _actor.getZ(), targetX, targetY, _actor.getZ(), _actor.getInstanceId())) {
 					moveTo(targetX, targetY, _actor.getZ());
 				}
 			}
 		}
 	}
 	
-	public void notifyFollowStatusChange()
-	{
+	public void notifyFollowStatusChange() {
 		_startFollow = !_startFollow;
-		switch (getIntention())
-		{
+		switch (getIntention()) {
 			case AI_INTENTION_ACTIVE:
 			case AI_INTENTION_FOLLOW:
 			case AI_INTENTION_IDLE:
@@ -269,45 +226,35 @@ public class L2SummonAI extends L2PlayableAI implements Runnable
 		}
 	}
 	
-	public void setStartFollowController(boolean val)
-	{
+	public void setStartFollowController(boolean val) {
 		_startFollow = val;
 	}
 	
 	@Override
-	protected void onIntentionCast(Skill skill, L2Object target)
-	{
-		if (getIntention() == AI_INTENTION_ATTACK)
-		{
+	protected void onIntentionCast(Skill skill, L2Object target) {
+		if (getIntention() == AI_INTENTION_ATTACK) {
 			_lastAttack = getAttackTarget();
-		}
-		else
-		{
+		} else {
 			_lastAttack = null;
 		}
 		super.onIntentionCast(skill, target);
 	}
 	
-	private void startAvoidTask()
-	{
-		if (_avoidTask == null)
-		{
+	private void startAvoidTask() {
+		if (_avoidTask == null) {
 			_avoidTask = ThreadPoolManager.getInstance().scheduleAiAtFixedRate(this, 100, 100);
 		}
 	}
 	
-	private void stopAvoidTask()
-	{
-		if (_avoidTask != null)
-		{
+	private void stopAvoidTask() {
+		if (_avoidTask != null) {
 			_avoidTask.cancel(false);
 			_avoidTask = null;
 		}
 	}
 	
 	@Override
-	public void stopAITask()
-	{
+	public void stopAITask() {
 		stopAvoidTask();
 		super.stopAITask();
 	}

+ 20 - 40
src/main/java/com/l2jserver/gameserver/ai/L2VehicleAI.java

@@ -26,104 +26,84 @@ import com.l2jserver.gameserver.model.skills.Skill;
 /**
  * @author DS
  */
-public abstract class L2VehicleAI extends L2CharacterAI
-{
+public abstract class L2VehicleAI extends L2CharacterAI {
 	/**
 	 * Simple AI for vehicles
 	 * @param creature
 	 */
-	public L2VehicleAI(L2Vehicle creature)
-	{
+	public L2VehicleAI(L2Vehicle creature) {
 		super(creature);
 	}
 	
 	@Override
-	protected void onIntentionAttack(L2Character target)
-	{
+	protected void onIntentionAttack(L2Character target) {
 	}
 	
 	@Override
-	protected void onIntentionCast(Skill skill, L2Object target)
-	{
+	protected void onIntentionCast(Skill skill, L2Object target) {
 	}
 	
 	@Override
-	protected void onIntentionFollow(L2Character target)
-	{
+	protected void onIntentionFollow(L2Character target) {
 	}
 	
 	@Override
-	protected void onIntentionPickUp(L2Object item)
-	{
+	protected void onIntentionPickUp(L2Object item) {
 	}
 	
 	@Override
-	protected void onIntentionInteract(L2Object object)
-	{
+	protected void onIntentionInteract(L2Object object) {
 	}
 	
 	@Override
-	protected void onEvtAttacked(L2Character attacker)
-	{
+	protected void onEvtAttacked(L2Character attacker) {
 	}
 	
 	@Override
-	protected void onEvtAggression(L2Character target, long aggro)
-	{
+	protected void onEvtAggression(L2Character target, long aggro) {
 	}
 	
 	@Override
-	protected void onEvtStunned(L2Character attacker)
-	{
+	protected void onEvtStunned(L2Character attacker) {
 	}
 	
 	@Override
-	protected void onEvtSleeping(L2Character attacker)
-	{
+	protected void onEvtSleeping(L2Character attacker) {
 	}
 	
 	@Override
-	protected void onEvtRooted(L2Character attacker)
-	{
+	protected void onEvtRooted(L2Character attacker) {
 	}
 	
 	@Override
-	protected void onEvtForgetObject(L2Object object)
-	{
+	protected void onEvtForgetObject(L2Object object) {
 	}
 	
 	@Override
-	protected void onEvtCancel()
-	{
+	protected void onEvtCancel() {
 	}
 	
 	@Override
-	protected void onEvtDead()
-	{
+	protected void onEvtDead() {
 	}
 	
 	@Override
-	protected void onEvtFakeDeath()
-	{
+	protected void onEvtFakeDeath() {
 	}
 	
 	@Override
-	protected void onEvtFinishCasting()
-	{
+	protected void onEvtFinishCasting() {
 	}
 	
 	@Override
-	protected void clientActionFailed()
-	{
+	protected void clientActionFailed() {
 	}
 	
 	@Override
-	protected void moveToPawn(L2Object pawn, int offset)
-	{
+	protected void moveToPawn(L2Object pawn, int offset) {
 	}
 	
 	@Override
-	protected void clientStoppedMoving()
-	{
+	protected void clientStoppedMoving() {
 	}
 }

+ 28 - 56
src/main/java/com/l2jserver/gameserver/ai/NextAction.java

@@ -26,10 +26,8 @@ import java.util.List;
  * Has 2 array list for "work" and "break".
  * @author Yaroslav
  */
-public class NextAction
-{
-	public interface NextActionCallback
-	{
+public class NextAction {
+	public interface NextActionCallback {
 		public void doWork();
 	}
 	
@@ -43,8 +41,7 @@ public class NextAction
 	 * @param intentions
 	 * @param callback
 	 */
-	public NextAction(List<CtrlEvent> events, List<CtrlIntention> intentions, NextActionCallback callback)
-	{
+	public NextAction(List<CtrlEvent> events, List<CtrlIntention> intentions, NextActionCallback callback) {
 		_events = events;
 		_intentions = intentions;
 		setCallback(callback);
@@ -56,25 +53,20 @@ public class NextAction
 	 * @param intention
 	 * @param callback
 	 */
-	public NextAction(CtrlEvent event, CtrlIntention intention, NextActionCallback callback)
-	{
-		if (_events == null)
-		{
+	public NextAction(CtrlEvent event, CtrlIntention intention, NextActionCallback callback) {
+		if (_events == null) {
 			_events = new ArrayList<>();
 		}
 		
-		if (_intentions == null)
-		{
+		if (_intentions == null) {
 			_intentions = new ArrayList<>();
 		}
 		
-		if (event != null)
-		{
+		if (event != null) {
 			_events.add(event);
 		}
 		
-		if (intention != null)
-		{
+		if (intention != null) {
 			_intentions.add(intention);
 		}
 		setCallback(callback);
@@ -83,10 +75,8 @@ public class NextAction
 	/**
 	 * Do action.
 	 */
-	public void doAction()
-	{
-		if (_callback != null)
-		{
+	public void doAction() {
+		if (_callback != null) {
 			_callback.doWork();
 		}
 	}
@@ -94,11 +84,9 @@ public class NextAction
 	/**
 	 * @return the _event
 	 */
-	public List<CtrlEvent> getEvents()
-	{
+	public List<CtrlEvent> getEvents() {
 		// If null return empty list.
-		if (_events == null)
-		{
+		if (_events == null) {
 			_events = new ArrayList<>();
 		}
 		return _events;
@@ -107,23 +95,19 @@ public class NextAction
 	/**
 	 * @param event the event to set.
 	 */
-	public void setEvents(ArrayList<CtrlEvent> event)
-	{
+	public void setEvents(ArrayList<CtrlEvent> event) {
 		_events = event;
 	}
 	
 	/**
 	 * @param event
 	 */
-	public void addEvent(CtrlEvent event)
-	{
-		if (_events == null)
-		{
+	public void addEvent(CtrlEvent event) {
+		if (_events == null) {
 			_events = new ArrayList<>();
 		}
 		
-		if (event != null)
-		{
+		if (event != null) {
 			_events.add(event);
 		}
 	}
@@ -131,10 +115,8 @@ public class NextAction
 	/**
 	 * @param event
 	 */
-	public void removeEvent(CtrlEvent event)
-	{
-		if (_events == null)
-		{
+	public void removeEvent(CtrlEvent event) {
+		if (_events == null) {
 			return;
 		}
 		_events.remove(event);
@@ -143,27 +125,23 @@ public class NextAction
 	/**
 	 * @return the _callback
 	 */
-	public NextActionCallback getCallback()
-	{
+	public NextActionCallback getCallback() {
 		return _callback;
 	}
 	
 	/**
 	 * @param callback the callback to set.
 	 */
-	public void setCallback(NextActionCallback callback)
-	{
+	public void setCallback(NextActionCallback callback) {
 		_callback = callback;
 	}
 	
 	/**
 	 * @return the _intentions
 	 */
-	public List<CtrlIntention> getIntentions()
-	{
+	public List<CtrlIntention> getIntentions() {
 		// If null return empty list.
-		if (_intentions == null)
-		{
+		if (_intentions == null) {
 			_intentions = new ArrayList<>();
 		}
 		return _intentions;
@@ -172,23 +150,19 @@ public class NextAction
 	/**
 	 * @param intentions the intention to set.
 	 */
-	public void setIntentions(ArrayList<CtrlIntention> intentions)
-	{
+	public void setIntentions(ArrayList<CtrlIntention> intentions) {
 		_intentions = intentions;
 	}
 	
 	/**
 	 * @param intention
 	 */
-	public void addIntention(CtrlIntention intention)
-	{
-		if (_intentions == null)
-		{
+	public void addIntention(CtrlIntention intention) {
+		if (_intentions == null) {
 			_intentions = new ArrayList<>();
 		}
 		
-		if (intention != null)
-		{
+		if (intention != null) {
 			_intentions.add(intention);
 		}
 	}
@@ -196,10 +170,8 @@ public class NextAction
 	/**
 	 * @param intention
 	 */
-	public void removeIntention(CtrlIntention intention)
-	{
-		if (_intentions == null)
-		{
+	public void removeIntention(CtrlIntention intention) {
+		if (_intentions == null) {
 			return;
 		}
 		_intentions.remove(intention);

+ 33 - 70
src/main/java/com/l2jserver/gameserver/cache/HtmCache.java

@@ -35,8 +35,7 @@ import com.l2jserver.util.file.filter.HTMLFilter;
 /**
  * @author Layane
  */
-public class HtmCache
-{
+public class HtmCache {
 	private static final Logger LOG = LoggerFactory.getLogger(HtmCache.class);
 	
 	private static final HTMLFilter HTML_FILTER = new HTMLFilter();
@@ -46,26 +45,20 @@ public class HtmCache
 	private int _loadedFiles;
 	private long _bytesBuffLen;
 	
-	protected HtmCache()
-	{
+	protected HtmCache() {
 		reload();
 	}
 	
-	public void reload()
-	{
+	public void reload() {
 		reload(Config.DATAPACK_ROOT);
 	}
 	
-	public void reload(File f)
-	{
-		if (!Config.LAZY_CACHE)
-		{
+	public void reload(File f) {
+		if (!Config.LAZY_CACHE) {
 			LOG.info("Html cache start...");
 			parseDir(f);
 			LOG.info("Cache[HTML]: " + String.format("%.3f", getMemoryUsage()) + " megabytes on " + getLoadedFiles() + " files loaded");
-		}
-		else
-		{
+		} else {
 			_cache.clear();
 			_loadedFiles = 0;
 			_bytesBuffLen = 0;
@@ -73,53 +66,41 @@ public class HtmCache
 		}
 	}
 	
-	public void reloadPath(File f)
-	{
+	public void reloadPath(File f) {
 		parseDir(f);
 		LOG.info("Cache[HTML]: Reloaded specified path.");
 	}
 	
-	public double getMemoryUsage()
-	{
+	public double getMemoryUsage() {
 		return ((float) _bytesBuffLen / 1048576);
 	}
 	
-	public int getLoadedFiles()
-	{
+	public int getLoadedFiles() {
 		return _loadedFiles;
 	}
 	
-	private void parseDir(File dir)
-	{
+	private void parseDir(File dir) {
 		final File[] files = dir.listFiles();
-		if (files != null)
-		{
-			for (File file : files)
-			{
-				if (!file.isDirectory())
-				{
+		if (files != null) {
+			for (File file : files) {
+				if (!file.isDirectory()) {
 					loadFile(file);
-				}
-				else
-				{
+				} else {
 					parseDir(file);
 				}
 			}
 		}
 	}
 	
-	public String loadFile(File file)
-	{
-		if (!HTML_FILTER.accept(file))
-		{
+	public String loadFile(File file) {
+		if (!HTML_FILTER.accept(file)) {
 			return null;
 		}
 		
 		final String relpath = Util.getRelativePath(Config.DATAPACK_ROOT, file);
 		String content = null;
 		try (FileInputStream fis = new FileInputStream(file);
-			BufferedInputStream bis = new BufferedInputStream(fis))
-		{
+			BufferedInputStream bis = new BufferedInputStream(fis)) {
 			final int bytes = bis.available();
 			byte[] raw = new byte[bytes];
 			
@@ -128,74 +109,59 @@ public class HtmCache
 			content = content.replaceAll("(?s)<!--.*?-->", ""); // Remove html comments
 			
 			String oldContent = _cache.put(relpath, content);
-			if (oldContent == null)
-			{
+			if (oldContent == null) {
 				_bytesBuffLen += bytes;
 				_loadedFiles++;
-			}
-			else
-			{
+			} else {
 				_bytesBuffLen = (_bytesBuffLen - oldContent.length()) + bytes;
 			}
-		}
-		catch (Exception e)
-		{
+		} catch (Exception e) {
 			LOG.warn("Problem with htm file {}!", file, e);
 		}
 		return content;
 	}
 	
-	public String getHtmForce(String prefix, String path)
-	{
+	public String getHtmForce(String prefix, String path) {
 		String content = getHtm(prefix, path);
-		if (content == null)
-		{
+		if (content == null) {
 			content = "<html><body>My text is missing:<br>" + path + "</body></html>";
 			LOG.warn("Cache[HTML]: Missing HTML page: " + path);
 		}
 		return content;
 	}
 	
-	public String getHtm(String prefix, String path)
-	{
+	public String getHtm(String prefix, String path) {
 		String newPath = null;
 		String content;
-		if ((prefix != null) && !prefix.isEmpty())
-		{
+		if ((prefix != null) && !prefix.isEmpty()) {
 			newPath = prefix + path;
 			content = getHtm(newPath);
-			if (content != null)
-			{
+			if (content != null) {
 				return content;
 			}
 		}
 		
 		content = getHtm(path);
-		if ((content != null) && (newPath != null))
-		{
+		if ((content != null) && (newPath != null)) {
 			_cache.put(newPath, content);
 		}
 		
 		return content;
 	}
 	
-	private String getHtm(String path)
-	{
-		if ((path == null) || path.isEmpty())
-		{
+	private String getHtm(String path) {
+		if ((path == null) || path.isEmpty()) {
 			return ""; // avoid possible NPE
 		}
 		
 		String content = _cache.get(path);
-		if (Config.LAZY_CACHE && (content == null))
-		{
+		if (Config.LAZY_CACHE && (content == null)) {
 			content = loadFile(new File(Config.DATAPACK_ROOT, path));
 		}
 		return content;
 	}
 	
-	public boolean contains(String path)
-	{
+	public boolean contains(String path) {
 		return _cache.containsKey(path);
 	}
 	
@@ -203,18 +169,15 @@ public class HtmCache
 	 * @param path The path to the HTM
 	 * @return {@code true} if the path targets a HTM or HTML file, {@code false} otherwise.
 	 */
-	public boolean isLoadable(String path)
-	{
+	public boolean isLoadable(String path) {
 		return HTML_FILTER.accept(new File(Config.DATAPACK_ROOT, path));
 	}
 	
-	public static HtmCache getInstance()
-	{
+	public static HtmCache getInstance() {
 		return SingletonHolder._instance;
 	}
 	
-	private static class SingletonHolder
-	{
+	private static class SingletonHolder {
 		protected static final HtmCache _instance = new HtmCache();
 	}
 }

+ 10 - 20
src/main/java/com/l2jserver/gameserver/cache/WarehouseCacheManager.java

@@ -28,36 +28,28 @@ import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
 /**
  * @author -Nemesiss-
  */
-public class WarehouseCacheManager
-{
+public class WarehouseCacheManager {
 	protected final Map<L2PcInstance, Long> _cachedWh = new ConcurrentHashMap<>();
 	protected final long _cacheTime = Config.WAREHOUSE_CACHE_TIME * 60000L;
 	
-	protected WarehouseCacheManager()
-	{
+	protected WarehouseCacheManager() {
 		ThreadPoolManager.getInstance().scheduleAiAtFixedRate(new CacheScheduler(), 120000, 60000);
 	}
 	
-	public void addCacheTask(L2PcInstance pc)
-	{
+	public void addCacheTask(L2PcInstance pc) {
 		_cachedWh.put(pc, System.currentTimeMillis());
 	}
 	
-	public void remCacheTask(L2PcInstance pc)
-	{
+	public void remCacheTask(L2PcInstance pc) {
 		_cachedWh.remove(pc);
 	}
 	
-	public class CacheScheduler implements Runnable
-	{
+	public class CacheScheduler implements Runnable {
 		@Override
-		public void run()
-		{
+		public void run() {
 			long cTime = System.currentTimeMillis();
-			for (L2PcInstance pc : _cachedWh.keySet())
-			{
-				if ((cTime - _cachedWh.get(pc)) > _cacheTime)
-				{
+			for (L2PcInstance pc : _cachedWh.keySet()) {
+				if ((cTime - _cachedWh.get(pc)) > _cacheTime) {
 					pc.clearWarehouse();
 					_cachedWh.remove(pc);
 				}
@@ -65,13 +57,11 @@ public class WarehouseCacheManager
 		}
 	}
 	
-	public static WarehouseCacheManager getInstance()
-	{
+	public static WarehouseCacheManager getInstance() {
 		return SingletonHolder._instance;
 	}
 	
-	private static class SingletonHolder
-	{
+	private static class SingletonHolder {
 		protected static final WarehouseCacheManager _instance = new WarehouseCacheManager();
 	}
 }

+ 5 - 10
src/main/java/com/l2jserver/gameserver/communitybbs/Manager/BaseBBSManager.java

@@ -24,8 +24,7 @@ import java.util.List;
 import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
 import com.l2jserver.gameserver.network.serverpackets.ShowBoard;
 
-public abstract class BaseBBSManager
-{
+public abstract class BaseBBSManager {
 	public abstract void parsecmd(String command, L2PcInstance activeChar);
 	
 	public abstract void parsewrite(String ar1, String ar2, String ar3, String ar4, String ar5, L2PcInstance activeChar);
@@ -34,10 +33,8 @@ public abstract class BaseBBSManager
 	 * @param html
 	 * @param acha
 	 */
-	protected void send1001(String html, L2PcInstance acha)
-	{
-		if (html.length() < 8192)
-		{
+	protected void send1001(String html, L2PcInstance acha) {
+		if (html.length() < 8192) {
 			acha.sendPacket(new ShowBoard(html, "1001"));
 		}
 	}
@@ -45,8 +42,7 @@ public abstract class BaseBBSManager
 	/**
 	 * @param acha
 	 */
-	protected void send1002(L2PcInstance acha)
-	{
+	protected void send1002(L2PcInstance acha) {
 		send1002(acha, " ", " ", "0");
 	}
 	
@@ -56,8 +52,7 @@ public abstract class BaseBBSManager
 	 * @param string2
 	 * @param string3
 	 */
-	protected void send1002(L2PcInstance activeChar, String string, String string2, String string3)
-	{
+	protected void send1002(L2PcInstance activeChar, String string, String string2, String string3) {
 		List<String> _arg = new ArrayList<>();
 		_arg.add("0");
 		_arg.add("0");

+ 1 - 2
src/main/java/com/l2jserver/gameserver/dao/FriendDAO.java

@@ -24,7 +24,6 @@ import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
  * Friend DAO interface.
  * @author Zoey76
  */
-public interface FriendDAO
-{
+public interface FriendDAO {
 	void load(L2PcInstance player);
 }

+ 1 - 2
src/main/java/com/l2jserver/gameserver/dao/HennaDAO.java

@@ -25,8 +25,7 @@ import com.l2jserver.gameserver.model.items.L2Henna;
  * Henna DAO interface.
  * @author Zoey76
  */
-public interface HennaDAO
-{
+public interface HennaDAO {
 	/**
 	 * Restores all hennas for the player.
 	 * @param player the player

+ 1 - 2
src/main/java/com/l2jserver/gameserver/dao/ItemDAO.java

@@ -24,8 +24,7 @@ import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
  * Item DAO interface.
  * @author Zoey76
  */
-public interface ItemDAO
-{
+public interface ItemDAO {
 	/**
 	 * Loads pet's inventory from database.
 	 * @param player the player

+ 1 - 2
src/main/java/com/l2jserver/gameserver/dao/ItemReuseDAO.java

@@ -24,8 +24,7 @@ import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
  * Item Reuse DAO interface.
  * @author Zoey76
  */
-public interface ItemReuseDAO
-{
+public interface ItemReuseDAO {
 	/**
 	 * Restores the item reuse for the given player.
 	 * @param player the player

+ 1 - 2
src/main/java/com/l2jserver/gameserver/dao/PetDAO.java

@@ -27,8 +27,7 @@ import com.l2jserver.gameserver.model.items.instance.L2ItemInstance;
  * Pet DAO interface.
  * @author Zoey76
  */
-public interface PetDAO
-{
+public interface PetDAO {
 	void updateFood(L2PcInstance player, int petId);
 	
 	/**

+ 1 - 2
src/main/java/com/l2jserver/gameserver/dao/PetSkillSaveDAO.java

@@ -24,8 +24,7 @@ import com.l2jserver.gameserver.model.actor.instance.L2PetInstance;
  * Pet Skill Save interface.
  * @author Zoey76
  */
-public interface PetSkillSaveDAO
-{
+public interface PetSkillSaveDAO {
 	/**
 	 * Stores the pet skills in the database.
 	 * @param pet the pets

+ 1 - 2
src/main/java/com/l2jserver/gameserver/dao/PlayerDAO.java

@@ -24,8 +24,7 @@ import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
  * Player DAO interface.
  * @author Zoey76
  */
-public interface PlayerDAO
-{
+public interface PlayerDAO {
 	void storeCharBase(L2PcInstance player);
 	
 	/**

+ 1 - 2
src/main/java/com/l2jserver/gameserver/dao/PlayerSkillSaveDAO.java

@@ -24,8 +24,7 @@ import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
  * Player Skill Save DAO interface.
  * @author Zoey76
  */
-public interface PlayerSkillSaveDAO
-{
+public interface PlayerSkillSaveDAO {
 	/**
 	 * Deletes the player skills from the database.
 	 * @param player the player

+ 1 - 2
src/main/java/com/l2jserver/gameserver/dao/PremiumItemDAO.java

@@ -24,8 +24,7 @@ import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
  * Premium Item DAO interface.
  * @author Zoey76
  */
-public interface PremiumItemDAO
-{
+public interface PremiumItemDAO {
 	void load(L2PcInstance player);
 	
 	void update(L2PcInstance player, int itemNum, long newcount);

+ 1 - 2
src/main/java/com/l2jserver/gameserver/dao/RecipeBookDAO.java

@@ -24,8 +24,7 @@ import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
  * Recipe Book DAO interface.
  * @author Zoey76
  */
-public interface RecipeBookDAO
-{
+public interface RecipeBookDAO {
 	void insert(L2PcInstance player, int recipeId, boolean isDwarf);
 	
 	/**

+ 1 - 2
src/main/java/com/l2jserver/gameserver/dao/RecipeShopListDAO.java

@@ -24,8 +24,7 @@ import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
  * Recipe Shop List DAO interface.
  * @author Zoey76
  */
-public interface RecipeShopListDAO
-{
+public interface RecipeShopListDAO {
 	void load(L2PcInstance player);
 	
 	void delete(L2PcInstance player);

+ 1 - 2
src/main/java/com/l2jserver/gameserver/dao/RecommendationBonusDAO.java

@@ -24,8 +24,7 @@ import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
  * Recommendation Bonus DAO interface.
  * @author Zoey76
  */
-public interface RecommendationBonusDAO
-{
+public interface RecommendationBonusDAO {
 	long load(L2PcInstance player);
 	
 	void insert(L2PcInstance player, long recoTaskEnd);

+ 1 - 2
src/main/java/com/l2jserver/gameserver/dao/ServitorSkillSaveDAO.java

@@ -24,8 +24,7 @@ import com.l2jserver.gameserver.model.actor.instance.L2ServitorInstance;
  * Servitor Skill Save DAO interface.
  * @author Zoey76
  */
-public interface ServitorSkillSaveDAO
-{
+public interface ServitorSkillSaveDAO {
 	/**
 	 * Stores the servitor skills in the database.
 	 * @param servitor the servitor

+ 1 - 2
src/main/java/com/l2jserver/gameserver/dao/ShortcutDAO.java

@@ -24,7 +24,6 @@ import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
  * Shortcut DAO interface.
  * @author Zoey76
  */
-public interface ShortcutDAO
-{
+public interface ShortcutDAO {
 	boolean delete(L2PcInstance player, int classIndex);
 }

+ 1 - 2
src/main/java/com/l2jserver/gameserver/dao/SkillDAO.java

@@ -27,8 +27,7 @@ import com.l2jserver.gameserver.model.skills.Skill;
  * Skill DAO interface.
  * @author Zoey76
  */
-public interface SkillDAO
-{
+public interface SkillDAO {
 	void insert(L2PcInstance player, int classIndex, Skill skill);
 	
 	void update(L2PcInstance player, int classIndex, Skill newSkill, Skill oldSkill);

+ 1 - 2
src/main/java/com/l2jserver/gameserver/dao/SubclassDAO.java

@@ -25,8 +25,7 @@ import com.l2jserver.gameserver.model.base.SubClass;
  * Subclass DAO interface.
  * @author Zoey76
  */
-public interface SubclassDAO
-{
+public interface SubclassDAO {
 	void update(L2PcInstance player);
 	
 	/**

+ 1 - 2
src/main/java/com/l2jserver/gameserver/dao/TeleportBookmarkDAO.java

@@ -24,8 +24,7 @@ import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
  * Teleport Bookmark DAO interface.
  * @author Zoey76
  */
-public interface TeleportBookmarkDAO
-{
+public interface TeleportBookmarkDAO {
 	void delete(L2PcInstance player, int id);
 	
 	void insert(L2PcInstance player, int id, int x, int y, int z, int icon, String tag, String name);

+ 8 - 16
src/main/java/com/l2jserver/gameserver/dao/factory/impl/DAOFactory.java

@@ -28,40 +28,32 @@ import com.l2jserver.gameserver.dao.factory.IDAOFactory;
  * DAO Factory implementation.
  * @author Zoey76
  */
-public class DAOFactory
-{
-	private DAOFactory()
-	{
+public class DAOFactory {
+	private DAOFactory() {
 		// Hide constructor.
 	}
 	
-	public static IDAOFactory getInstance()
-	{
+	public static IDAOFactory getInstance() {
 		return SingletonHolder.INSTANCE;
 	}
 	
-	private static class SingletonHolder
-	{
+	private static class SingletonHolder {
 		private static final Logger LOG = LoggerFactory.getLogger(DAOFactory.class);
 		
 		protected static final IDAOFactory INSTANCE;
 		
-		static
-		{
-			switch (Config.DATABASE_ENGINE)
-			{
+		static {
+			switch (Config.DATABASE_ENGINE) {
 				case "MSSQL":
 				case "OracleDB":
 				case "PostgreSQL":
 				case "H2":
-				case "HSQLDB":
-				{
+				case "HSQLDB": {
 					throw new UnsupportedOperationException(Config.DATABASE_ENGINE + " is not supported!");
 				}
 				default:
 				case "MariaDB":
-				case "MySQL":
-				{
+				case "MySQL": {
 					INSTANCE = MySQLDAOFactory.INSTANCE;
 					break;
 				}

+ 11 - 24
src/main/java/com/l2jserver/gameserver/data/json/ExperienceData.java

@@ -38,34 +38,25 @@ import com.l2jserver.gameserver.config.Config;
  * @author Zealar
  * @since 2.6.0.0
  */
-public final class ExperienceData
-{
+public final class ExperienceData {
 	private static final Logger LOG = LoggerFactory.getLogger(ExperienceData.class);
 	
 	private static final Gson GSON = new Gson();
-	private static final Type TYPE_MAP_INTEGER_LONG = new TypeToken<Map<Integer, Long>>()
-	{
+	private static final Type TYPE_MAP_INTEGER_LONG = new TypeToken<Map<Integer, Long>>() {
 	}.getType();
 	private final Map<Integer, Long> _expTable = new HashMap<>();
 	
-	ExperienceData()
-	{
+	ExperienceData() {
 		load();
 	}
 	
-	public void load()
-	{
+	public void load() {
 		_expTable.clear();
-		try (JsonReader reader = new JsonReader(new FileReader(new File(Config.DATAPACK_ROOT, "data/stats/expData.json"))))
-		{
+		try (JsonReader reader = new JsonReader(new FileReader(new File(Config.DATAPACK_ROOT, "data/stats/expData.json")))) {
 			_expTable.putAll(GSON.fromJson(reader, TYPE_MAP_INTEGER_LONG));
-		}
-		catch (FileNotFoundException fnfe)
-		{
+		} catch (FileNotFoundException fnfe) {
 			LOG.warn("data/stats/expData.json not found!");
-		}
-		catch (IOException ioe)
-		{
+		} catch (IOException ioe) {
 			LOG.warn("Failed to load expData.json for: ", ioe);
 		}
 	}
@@ -75,13 +66,11 @@ public final class ExperienceData
 	 * @param level the level required.
 	 * @return the experience points required to reach the given level.
 	 */
-	public long getExpForLevel(int level)
-	{
+	public long getExpForLevel(int level) {
 		return _expTable.get(level);
 	}
 	
-	public float getPercentFromCurrentLevel(long exp, int level)
-	{
+	public float getPercentFromCurrentLevel(long exp, int level) {
 		long expPerLevel = getExpForLevel(level);
 		long expPerLevel2 = getExpForLevel(level + 1);
 		return (float) (exp - expPerLevel) / (expPerLevel2 - expPerLevel);
@@ -91,13 +80,11 @@ public final class ExperienceData
 	 * Gets the single instance of ExperienceTable.
 	 * @return single instance of ExperienceTable
 	 */
-	public static ExperienceData getInstance()
-	{
+	public static ExperienceData getInstance() {
 		return SingletonHolder._instance;
 	}
 	
-	private static class SingletonHolder
-	{
+	private static class SingletonHolder {
 		static final ExperienceData _instance = new ExperienceData();
 	}
 }

+ 29 - 58
src/main/java/com/l2jserver/gameserver/data/sql/impl/SummonEffectsTable.java

@@ -32,8 +32,7 @@ import com.l2jserver.gameserver.model.skills.Skill;
 /**
  * @author Nyaran
  */
-public class SummonEffectsTable
-{
+public class SummonEffectsTable {
 	/** Servitors **/
 	// Map tree
 	// -> key: charObjectId, value: classIndex Map
@@ -44,138 +43,110 @@ public class SummonEffectsTable
 	// key: petItemObjectId, value: Effects list
 	private final Map<Integer, Map<Integer, SummonEffect>> _petEffects = new HashMap<>();
 	
-	private Map<Integer, Map<Integer, SummonEffect>> getServitorEffects(L2PcInstance owner)
-	{
+	private Map<Integer, Map<Integer, SummonEffect>> getServitorEffects(L2PcInstance owner) {
 		final Map<Integer, Map<Integer, Map<Integer, SummonEffect>>> servitorMap = _servitorEffects.get(owner.getObjectId());
-		if (servitorMap == null)
-		{
+		if (servitorMap == null) {
 			return null;
 		}
 		return servitorMap.get(owner.getClassIndex());
 	}
 	
-	private Map<Integer, SummonEffect> getServitorEffects(L2PcInstance owner, int referenceSkill)
-	{
+	private Map<Integer, SummonEffect> getServitorEffects(L2PcInstance owner, int referenceSkill) {
 		return containsOwner(owner) ? getServitorEffects(owner).get(referenceSkill) : null;
 	}
 	
-	private boolean containsOwner(L2PcInstance owner)
-	{
+	private boolean containsOwner(L2PcInstance owner) {
 		return _servitorEffects.getOrDefault(owner.getObjectId(), Collections.emptyMap()).containsKey(owner.getClassIndex());
 	}
 	
-	private void removeEffects(Map<Integer, SummonEffect> map, int skillId)
-	{
-		if (map != null)
-		{
+	private void removeEffects(Map<Integer, SummonEffect> map, int skillId) {
+		if (map != null) {
 			map.remove(skillId);
 		}
 	}
 	
-	private void applyEffects(L2Summon summon, Map<Integer, SummonEffect> map)
-	{
-		if (map == null)
-		{
+	private void applyEffects(L2Summon summon, Map<Integer, SummonEffect> map) {
+		if (map == null) {
 			return;
 		}
-		for (SummonEffect se : map.values())
-		{
-			if (se != null)
-			{
+		for (SummonEffect se : map.values()) {
+			if (se != null) {
 				se.getSkill().applyEffects(summon, summon, false, se.getEffectCurTime());
 			}
 		}
 	}
 	
-	public boolean containsSkill(L2PcInstance owner, int referenceSkill)
-	{
+	public boolean containsSkill(L2PcInstance owner, int referenceSkill) {
 		return containsOwner(owner) && getServitorEffects(owner).containsKey(referenceSkill);
 	}
 	
-	public void clearServitorEffects(L2PcInstance owner, int referenceSkill)
-	{
-		if (containsOwner(owner))
-		{
+	public void clearServitorEffects(L2PcInstance owner, int referenceSkill) {
+		if (containsOwner(owner)) {
 			getServitorEffects(owner).getOrDefault(referenceSkill, Collections.emptyMap()).clear();
 		}
 	}
 	
-	public void addServitorEffect(L2PcInstance owner, int referenceSkill, Skill skill, int effectCurTime)
-	{
+	public void addServitorEffect(L2PcInstance owner, int referenceSkill, Skill skill, int effectCurTime) {
 		_servitorEffects.putIfAbsent(owner.getObjectId(), new HashMap<Integer, Map<Integer, Map<Integer, SummonEffect>>>());
 		_servitorEffects.get(owner.getObjectId()).putIfAbsent(owner.getClassIndex(), new HashMap<Integer, Map<Integer, SummonEffect>>());
 		getServitorEffects(owner).putIfAbsent(referenceSkill, new ConcurrentHashMap<Integer, SummonEffect>());
 		getServitorEffects(owner).get(referenceSkill).put(skill.getId(), new SummonEffect(skill, effectCurTime));
 	}
 	
-	public void removeServitorEffects(L2PcInstance owner, int referenceSkill, int skillId)
-	{
+	public void removeServitorEffects(L2PcInstance owner, int referenceSkill, int skillId) {
 		removeEffects(getServitorEffects(owner, referenceSkill), skillId);
 	}
 	
-	public void applyServitorEffects(L2ServitorInstance servitor, L2PcInstance owner, int referenceSkill)
-	{
+	public void applyServitorEffects(L2ServitorInstance servitor, L2PcInstance owner, int referenceSkill) {
 		applyEffects(servitor, getServitorEffects(owner, referenceSkill));
 	}
 	
-	public void addPetEffect(int controlObjectId, Skill skill, int effectCurTime)
-	{
+	public void addPetEffect(int controlObjectId, Skill skill, int effectCurTime) {
 		_petEffects.computeIfAbsent(controlObjectId, k -> new ConcurrentHashMap<>()).put(skill.getId(), new SummonEffect(skill, effectCurTime));
 	}
 	
-	public boolean containsPetId(int controlObjectId)
-	{
+	public boolean containsPetId(int controlObjectId) {
 		return _petEffects.containsKey(controlObjectId);
 	}
 	
-	public void applyPetEffects(L2PetInstance l2PetInstance, int controlObjectId)
-	{
+	public void applyPetEffects(L2PetInstance l2PetInstance, int controlObjectId) {
 		applyEffects(l2PetInstance, _petEffects.get(controlObjectId));
 	}
 	
-	public void clearPetEffects(int controlObjectId)
-	{
+	public void clearPetEffects(int controlObjectId) {
 		final Map<Integer, SummonEffect> effects = _petEffects.get(controlObjectId);
-		if (effects != null)
-		{
+		if (effects != null) {
 			effects.clear();
 		}
 	}
 	
-	public void removePetEffects(int controlObjectId, int skillId)
-	{
+	public void removePetEffects(int controlObjectId, int skillId) {
 		removeEffects(_petEffects.get(controlObjectId), skillId);
 	}
 	
-	private class SummonEffect
-	{
+	private class SummonEffect {
 		Skill _skill;
 		int _effectCurTime;
 		
-		public SummonEffect(Skill skill, int effectCurTime)
-		{
+		public SummonEffect(Skill skill, int effectCurTime) {
 			_skill = skill;
 			_effectCurTime = effectCurTime;
 		}
 		
-		public Skill getSkill()
-		{
+		public Skill getSkill() {
 			return _skill;
 		}
 		
-		public int getEffectCurTime()
-		{
+		public int getEffectCurTime() {
 			return _effectCurTime;
 		}
 	}
 	
-	public static SummonEffectsTable getInstance()
-	{
+	public static SummonEffectsTable getInstance() {
 		return SingletonHolder.INSTANCE;
 	}
 	
-	private static class SingletonHolder
-	{
+	private static class SingletonHolder {
 		protected static final SummonEffectsTable INSTANCE = new SummonEffectsTable();
 	}
 }

+ 29 - 58
src/main/java/com/l2jserver/gameserver/data/xml/impl/ArmorSetsData.java

@@ -33,121 +33,96 @@ import com.l2jserver.gameserver.util.IXmlReader;
  * Loads armor set bonuses.
  * @author godson, Luno, UnAfraid
  */
-public final class ArmorSetsData implements IXmlReader
-{
+public final class ArmorSetsData implements IXmlReader {
 	private final Map<Integer, L2ArmorSet> _armorSets = new HashMap<>();
 	
 	/**
 	 * Instantiates a new armor sets data.
 	 */
-	protected ArmorSetsData()
-	{
+	protected ArmorSetsData() {
 		load();
 	}
 	
 	@Override
-	public void load()
-	{
+	public void load() {
 		_armorSets.clear();
 		parseDatapackDirectory("data/stats/armorsets", false);
 		LOG.info("{}: Loaded {} Armor sets.", getClass().getSimpleName(), _armorSets.size());
 	}
 	
 	@Override
-	public void parseDocument(Document doc)
-	{
-		for (Node n = doc.getFirstChild(); n != null; n = n.getNextSibling())
-		{
-			if ("list".equalsIgnoreCase(n.getNodeName()))
-			{
-				for (Node d = n.getFirstChild(); d != null; d = d.getNextSibling())
-				{
-					if ("set".equalsIgnoreCase(d.getNodeName()))
-					{
+	public void parseDocument(Document doc) {
+		for (Node n = doc.getFirstChild(); n != null; n = n.getNextSibling()) {
+			if ("list".equalsIgnoreCase(n.getNodeName())) {
+				for (Node d = n.getFirstChild(); d != null; d = d.getNextSibling()) {
+					if ("set".equalsIgnoreCase(d.getNodeName())) {
 						final L2ArmorSet set = new L2ArmorSet();
-						for (Node a = d.getFirstChild(); a != null; a = a.getNextSibling())
-						{
+						for (Node a = d.getFirstChild(); a != null; a = a.getNextSibling()) {
 							final NamedNodeMap attrs = a.getAttributes();
-							switch (a.getNodeName())
-							{
-								case "chest":
-								{
+							switch (a.getNodeName()) {
+								case "chest": {
 									set.addChest(parseInteger(attrs, "id"));
 									break;
 								}
-								case "feet":
-								{
+								case "feet": {
 									set.addFeet(parseInteger(attrs, "id"));
 									break;
 								}
-								case "gloves":
-								{
+								case "gloves": {
 									set.addGloves(parseInteger(attrs, "id"));
 									break;
 								}
-								case "head":
-								{
+								case "head": {
 									set.addHead(parseInteger(attrs, "id"));
 									break;
 								}
-								case "legs":
-								{
+								case "legs": {
 									set.addLegs(parseInteger(attrs, "id"));
 									break;
 								}
-								case "shield":
-								{
+								case "shield": {
 									set.addShield(parseInteger(attrs, "id"));
 									break;
 								}
-								case "skill":
-								{
+								case "skill": {
 									int skillId = parseInteger(attrs, "id");
 									int skillLevel = parseInteger(attrs, "level");
 									set.addSkill(new SkillHolder(skillId, skillLevel));
 									break;
 								}
-								case "shield_skill":
-								{
+								case "shield_skill": {
 									int skillId = parseInteger(attrs, "id");
 									int skillLevel = parseInteger(attrs, "level");
 									set.addShieldSkill(new SkillHolder(skillId, skillLevel));
 									break;
 								}
-								case "enchant6skill":
-								{
+								case "enchant6skill": {
 									int skillId = parseInteger(attrs, "id");
 									int skillLevel = parseInteger(attrs, "level");
 									set.addEnchant6Skill(new SkillHolder(skillId, skillLevel));
 									break;
 								}
-								case "con":
-								{
+								case "con": {
 									set.addCon(parseInteger(attrs, "val"));
 									break;
 								}
-								case "dex":
-								{
+								case "dex": {
 									set.addDex(parseInteger(attrs, "val"));
 									break;
 								}
-								case "str":
-								{
+								case "str": {
 									set.addStr(parseInteger(attrs, "val"));
 									break;
 								}
-								case "men":
-								{
+								case "men": {
 									set.addMen(parseInteger(attrs, "val"));
 									break;
 								}
-								case "wit":
-								{
+								case "wit": {
 									set.addWit(parseInteger(attrs, "val"));
 									break;
 								}
-								case "int":
-								{
+								case "int": {
 									set.addInt(parseInteger(attrs, "val"));
 									break;
 								}
@@ -165,8 +140,7 @@ public final class ArmorSetsData implements IXmlReader
 	 * @param chestId the chest Id to verify.
 	 * @return {@code true} if the chest Id belongs to a registered armor set, {@code false} otherwise.
 	 */
-	public boolean isArmorSet(int chestId)
-	{
+	public boolean isArmorSet(int chestId) {
 		return _armorSets.containsKey(chestId);
 	}
 	
@@ -175,8 +149,7 @@ public final class ArmorSetsData implements IXmlReader
 	 * @param chestId the chest Id identifying the armor set.
 	 * @return the armor set associated to the give chest Id.
 	 */
-	public L2ArmorSet getSet(int chestId)
-	{
+	public L2ArmorSet getSet(int chestId) {
 		return _armorSets.get(chestId);
 	}
 	
@@ -184,13 +157,11 @@ public final class ArmorSetsData implements IXmlReader
 	 * Gets the single instance of ArmorSetsData.
 	 * @return single instance of ArmorSetsData
 	 */
-	public static ArmorSetsData getInstance()
-	{
+	public static ArmorSetsData getInstance() {
 		return SingletonHolder._instance;
 	}
 	
-	private static class SingletonHolder
-	{
+	private static class SingletonHolder {
 		protected static final ArmorSetsData _instance = new ArmorSetsData();
 	}
 }

+ 16 - 32
src/main/java/com/l2jserver/gameserver/data/xml/impl/CategoryData.java

@@ -34,47 +34,36 @@ import com.l2jserver.gameserver.util.IXmlReader;
  * Loads the category data with Class or NPC IDs.
  * @author NosBit, xban1x
  */
-public final class CategoryData implements IXmlReader
-{
+public final class CategoryData implements IXmlReader {
 	private final Map<CategoryType, Set<Integer>> _categories = new HashMap<>();
 	
-	protected CategoryData()
-	{
+	protected CategoryData() {
 		load();
 	}
 	
 	@Override
-	public void load()
-	{
+	public void load() {
 		_categories.clear();
 		parseDatapackFile("data/categoryData.xml");
 		LOG.info("{}: Loaded {} Categories.", getClass().getSimpleName(), _categories.size());
 	}
 	
 	@Override
-	public void parseDocument(Document doc)
-	{
-		for (Node node = doc.getFirstChild(); node != null; node = node.getNextSibling())
-		{
-			if ("list".equalsIgnoreCase(node.getNodeName()))
-			{
-				for (Node list_node = node.getFirstChild(); list_node != null; list_node = list_node.getNextSibling())
-				{
-					if ("category".equalsIgnoreCase(list_node.getNodeName()))
-					{
+	public void parseDocument(Document doc) {
+		for (Node node = doc.getFirstChild(); node != null; node = node.getNextSibling()) {
+			if ("list".equalsIgnoreCase(node.getNodeName())) {
+				for (Node list_node = node.getFirstChild(); list_node != null; list_node = list_node.getNextSibling()) {
+					if ("category".equalsIgnoreCase(list_node.getNodeName())) {
 						final NamedNodeMap attrs = list_node.getAttributes();
 						final CategoryType categoryType = CategoryType.findByName(attrs.getNamedItem("name").getNodeValue());
-						if (categoryType == null)
-						{
+						if (categoryType == null) {
 							LOG.warn("{}: Can't find category by name :{}", getClass().getSimpleName(), attrs.getNamedItem("name").getNodeValue());
 							continue;
 						}
 						
 						final Set<Integer> ids = new HashSet<>();
-						for (Node category_node = list_node.getFirstChild(); category_node != null; category_node = category_node.getNextSibling())
-						{
-							if ("id".equalsIgnoreCase(category_node.getNodeName()))
-							{
+						for (Node category_node = list_node.getFirstChild(); category_node != null; category_node = category_node.getNextSibling()) {
+							if ("id".equalsIgnoreCase(category_node.getNodeName())) {
 								ids.add(Integer.parseInt(category_node.getTextContent()));
 							}
 						}
@@ -91,11 +80,9 @@ public final class CategoryData implements IXmlReader
 	 * @param id The id to be checked
 	 * @return {@code true} if id is in category, {@code false} if id is not in category or category was not found
 	 */
-	public boolean isInCategory(CategoryType type, int id)
-	{
+	public boolean isInCategory(CategoryType type, int id) {
 		final Set<Integer> category = getCategoryByType(type);
-		if (category == null)
-		{
+		if (category == null) {
 			LOG.warn("{}: Can't find category type: {}", getClass().getSimpleName(), type);
 			return false;
 		}
@@ -107,18 +94,15 @@ public final class CategoryData implements IXmlReader
 	 * @param type The category type
 	 * @return A {@code Set} containing all the IDs in category if category is found, {@code null} if category was not found
 	 */
-	public Set<Integer> getCategoryByType(CategoryType type)
-	{
+	public Set<Integer> getCategoryByType(CategoryType type) {
 		return _categories.get(type);
 	}
 	
-	public static CategoryData getInstance()
-	{
+	public static CategoryData getInstance() {
 		return SingletonHolder._instance;
 	}
 	
-	private static class SingletonHolder
-	{
+	private static class SingletonHolder {
 		protected static final CategoryData _instance = new CategoryData();
 	}
 }

+ 13 - 26
src/main/java/com/l2jserver/gameserver/data/xml/impl/ClassListData.java

@@ -33,38 +33,30 @@ import com.l2jserver.gameserver.util.IXmlReader;
  * Loads the the list of classes and it's info.
  * @author Zoey76
  */
-public final class ClassListData implements IXmlReader
-{
+public final class ClassListData implements IXmlReader {
 	private final Map<ClassId, ClassInfo> _classData = new HashMap<>();
 	
 	/**
 	 * Instantiates a new class list data.
 	 */
-	protected ClassListData()
-	{
+	protected ClassListData() {
 		load();
 	}
 	
 	@Override
-	public void load()
-	{
+	public void load() {
 		_classData.clear();
 		parseDatapackFile("data/stats/chars/classList.xml");
 		LOG.info("{}: Loaded {} Class data.", getClass().getSimpleName(), _classData.size());
 	}
 	
 	@Override
-	public void parseDocument(Document doc)
-	{
-		for (Node n = doc.getFirstChild(); n != null; n = n.getNextSibling())
-		{
-			if ("list".equals(n.getNodeName()))
-			{
-				for (Node d = n.getFirstChild(); d != null; d = d.getNextSibling())
-				{
+	public void parseDocument(Document doc) {
+		for (Node n = doc.getFirstChild(); n != null; n = n.getNextSibling()) {
+			if ("list".equals(n.getNodeName())) {
+				for (Node d = n.getFirstChild(); d != null; d = d.getNextSibling()) {
 					final NamedNodeMap attrs = d.getAttributes();
-					if ("class".equals(d.getNodeName()))
-					{
+					if ("class".equals(d.getNodeName())) {
 						Node attr = attrs.getNamedItem("classId");
 						final ClassId classId = ClassId.getClassId(parseInteger(attr));
 						attr = attrs.getNamedItem("name");
@@ -82,8 +74,7 @@ public final class ClassListData implements IXmlReader
 	 * Gets the class list.
 	 * @return the complete class list
 	 */
-	public Map<ClassId, ClassInfo> getClassList()
-	{
+	public Map<ClassId, ClassInfo> getClassList() {
 		return _classData;
 	}
 	
@@ -92,8 +83,7 @@ public final class ClassListData implements IXmlReader
 	 * @param classId the class ID
 	 * @return the class info related to the given {@code classId}
 	 */
-	public ClassInfo getClass(ClassId classId)
-	{
+	public ClassInfo getClass(ClassId classId) {
 		return _classData.get(classId);
 	}
 	
@@ -102,8 +92,7 @@ public final class ClassListData implements IXmlReader
 	 * @param classId the class Id as integer
 	 * @return the class info related to the given {@code classId}
 	 */
-	public ClassInfo getClass(int classId)
-	{
+	public ClassInfo getClass(int classId) {
 		final ClassId id = ClassId.getClassId(classId);
 		return (id != null) ? _classData.get(id) : null;
 	}
@@ -112,13 +101,11 @@ public final class ClassListData implements IXmlReader
 	 * Gets the single instance of ClassListData.
 	 * @return single instance of ClassListData
 	 */
-	public static ClassListData getInstance()
-	{
+	public static ClassListData getInstance() {
 		return SingletonHolder._instance;
 	}
 	
-	private static class SingletonHolder
-	{
+	private static class SingletonHolder {
 		protected static final ClassListData _instance = new ClassListData();
 	}
 }

+ 31 - 62
src/main/java/com/l2jserver/gameserver/data/xml/impl/EnchantSkillGroupsData.java

@@ -38,8 +38,7 @@ import com.l2jserver.gameserver.util.IXmlReader;
  * This class holds the Enchant Groups information.
  * @author Micr0
  */
-public class EnchantSkillGroupsData implements IXmlReader
-{
+public class EnchantSkillGroupsData implements IXmlReader {
 	public static final int NORMAL_ENCHANT_COST_MULTIPLIER = Config.NORMAL_ENCHANT_COST_MULTIPLIER;
 	public static final int SAFE_ENCHANT_COST_MULTIPLIER = Config.SAFE_ENCHANT_COST_MULTIPLIER;
 	
@@ -54,54 +53,42 @@ public class EnchantSkillGroupsData implements IXmlReader
 	/**
 	 * Instantiates a new enchant groups table.
 	 */
-	protected EnchantSkillGroupsData()
-	{
+	protected EnchantSkillGroupsData() {
 		load();
 	}
 	
 	@Override
-	public void load()
-	{
+	public void load() {
 		_enchantSkillGroups.clear();
 		_enchantSkillTrees.clear();
 		parseDatapackFile("data/enchantSkillGroups.xml");
 		int routes = 0;
-		for (L2EnchantSkillGroup group : _enchantSkillGroups.values())
-		{
+		for (L2EnchantSkillGroup group : _enchantSkillGroups.values()) {
 			routes += group.getEnchantGroupDetails().size();
 		}
 		LOG.info("{}: Loaded {} groups and {} routes.", getClass().getSimpleName(), _enchantSkillGroups.size(), routes);
 	}
 	
 	@Override
-	public void parseDocument(Document doc)
-	{
-		for (Node n = doc.getFirstChild(); n != null; n = n.getNextSibling())
-		{
-			if ("list".equalsIgnoreCase(n.getNodeName()))
-			{
-				for (Node d = n.getFirstChild(); d != null; d = d.getNextSibling())
-				{
-					if ("group".equalsIgnoreCase(d.getNodeName()))
-					{
+	public void parseDocument(Document doc) {
+		for (Node n = doc.getFirstChild(); n != null; n = n.getNextSibling()) {
+			if ("list".equalsIgnoreCase(n.getNodeName())) {
+				for (Node d = n.getFirstChild(); d != null; d = d.getNextSibling()) {
+					if ("group".equalsIgnoreCase(d.getNodeName())) {
 						NamedNodeMap attrs = d.getAttributes();
 						final int id = parseInteger(attrs, "id");
 						L2EnchantSkillGroup group = _enchantSkillGroups.get(id);
-						if (group == null)
-						{
+						if (group == null) {
 							group = new L2EnchantSkillGroup(id);
 							_enchantSkillGroups.put(id, group);
 						}
 						
-						for (Node b = d.getFirstChild(); b != null; b = b.getNextSibling())
-						{
-							if ("enchant".equalsIgnoreCase(b.getNodeName()))
-							{
+						for (Node b = d.getFirstChild(); b != null; b = b.getNextSibling()) {
+							if ("enchant".equalsIgnoreCase(b.getNodeName())) {
 								attrs = b.getAttributes();
 								StatsSet set = new StatsSet();
 								
-								for (int i = 0; i < attrs.getLength(); i++)
-								{
+								for (int i = 0; i < attrs.getLength(); i++) {
 									Node att = attrs.item(i);
 									set.set(att.getNodeName(), att.getNodeValue());
 								}
@@ -122,16 +109,13 @@ public class EnchantSkillGroupsData implements IXmlReader
 	 * @param group the group
 	 * @return the int
 	 */
-	public int addNewRouteForSkill(int skillId, int maxLvL, int route, int group)
-	{
+	public int addNewRouteForSkill(int skillId, int maxLvL, int route, int group) {
 		L2EnchantSkillLearn enchantableSkill = _enchantSkillTrees.get(skillId);
-		if (enchantableSkill == null)
-		{
+		if (enchantableSkill == null) {
 			enchantableSkill = new L2EnchantSkillLearn(skillId, maxLvL);
 			_enchantSkillTrees.put(skillId, enchantableSkill);
 		}
-		if (_enchantSkillGroups.containsKey(group))
-		{
+		if (_enchantSkillGroups.containsKey(group)) {
 			enchantableSkill.addNewEnchantRoute(route, group);
 			
 			return _enchantSkillGroups.get(group).getEnchantGroupDetails().size();
@@ -145,12 +129,10 @@ public class EnchantSkillGroupsData implements IXmlReader
 	 * @param skill the skill
 	 * @return the skill enchantment for skill
 	 */
-	public L2EnchantSkillLearn getSkillEnchantmentForSkill(Skill skill)
-	{
+	public L2EnchantSkillLearn getSkillEnchantmentForSkill(Skill skill) {
 		// there is enchantment for this skill and we have the required level of it
 		final L2EnchantSkillLearn esl = getSkillEnchantmentBySkillId(skill.getId());
-		if ((esl != null) && (skill.getLevel() >= esl.getBaseLevel()))
-		{
+		if ((esl != null) && (skill.getLevel() >= esl.getBaseLevel())) {
 			return esl;
 		}
 		return null;
@@ -161,8 +143,7 @@ public class EnchantSkillGroupsData implements IXmlReader
 	 * @param skillId the skill id
 	 * @return the skill enchantment by skill id
 	 */
-	public L2EnchantSkillLearn getSkillEnchantmentBySkillId(int skillId)
-	{
+	public L2EnchantSkillLearn getSkillEnchantmentBySkillId(int skillId) {
 		return _enchantSkillTrees.get(skillId);
 	}
 	
@@ -171,8 +152,7 @@ public class EnchantSkillGroupsData implements IXmlReader
 	 * @param id the id
 	 * @return the enchant skill group by id
 	 */
-	public L2EnchantSkillGroup getEnchantSkillGroupById(int id)
-	{
+	public L2EnchantSkillGroup getEnchantSkillGroupById(int id) {
 		return _enchantSkillGroups.get(id);
 	}
 	
@@ -181,14 +161,11 @@ public class EnchantSkillGroupsData implements IXmlReader
 	 * @param skill the skill
 	 * @return the enchant skill sp cost
 	 */
-	public int getEnchantSkillSpCost(Skill skill)
-	{
+	public int getEnchantSkillSpCost(Skill skill) {
 		final L2EnchantSkillLearn enchantSkillLearn = _enchantSkillTrees.get(skill.getId());
-		if (enchantSkillLearn != null)
-		{
+		if (enchantSkillLearn != null) {
 			final EnchantSkillHolder esh = enchantSkillLearn.getEnchantSkillHolder(skill.getLevel());
-			if (esh != null)
-			{
+			if (esh != null) {
 				return esh.getSpCost();
 			}
 		}
@@ -200,14 +177,11 @@ public class EnchantSkillGroupsData implements IXmlReader
 	 * @param skill the skill
 	 * @return the enchant skill Adena cost
 	 */
-	public int getEnchantSkillAdenaCost(Skill skill)
-	{
+	public int getEnchantSkillAdenaCost(Skill skill) {
 		final L2EnchantSkillLearn enchantSkillLearn = _enchantSkillTrees.get(skill.getId());
-		if (enchantSkillLearn != null)
-		{
+		if (enchantSkillLearn != null) {
 			final EnchantSkillHolder esh = enchantSkillLearn.getEnchantSkillHolder(skill.getLevel());
-			if (esh != null)
-			{
+			if (esh != null) {
 				return esh.getAdenaCost();
 			}
 		}
@@ -220,14 +194,11 @@ public class EnchantSkillGroupsData implements IXmlReader
 	 * @param skill the skill
 	 * @return the enchant skill rate
 	 */
-	public byte getEnchantSkillRate(L2PcInstance player, Skill skill)
-	{
+	public byte getEnchantSkillRate(L2PcInstance player, Skill skill) {
 		final L2EnchantSkillLearn enchantSkillLearn = _enchantSkillTrees.get(skill.getId());
-		if (enchantSkillLearn != null)
-		{
+		if (enchantSkillLearn != null) {
 			final EnchantSkillHolder esh = enchantSkillLearn.getEnchantSkillHolder(skill.getLevel());
-			if (esh != null)
-			{
+			if (esh != null) {
 				return esh.getRate(player);
 			}
 		}
@@ -238,13 +209,11 @@ public class EnchantSkillGroupsData implements IXmlReader
 	 * Gets the single instance of EnchantGroupsData.
 	 * @return single instance of EnchantGroupsData
 	 */
-	public static EnchantSkillGroupsData getInstance()
-	{
+	public static EnchantSkillGroupsData getInstance() {
 		return SingletonHolder._instance;
 	}
 	
-	private static class SingletonHolder
-	{
+	private static class SingletonHolder {
 		protected static final EnchantSkillGroupsData _instance = new EnchantSkillGroupsData();
 	}
 }

+ 24 - 48
src/main/java/com/l2jserver/gameserver/data/xml/impl/FishData.java

@@ -35,8 +35,7 @@ import com.l2jserver.gameserver.util.IXmlReader;
  * This class holds the Fish information.
  * @author nonom
  */
-public final class FishData implements IXmlReader
-{
+public final class FishData implements IXmlReader {
 	private final Map<Integer, L2Fish> _fishNormal = new HashMap<>();
 	private final Map<Integer, L2Fish> _fishEasy = new HashMap<>();
 	private final Map<Integer, L2Fish> _fishHard = new HashMap<>();
@@ -44,14 +43,12 @@ public final class FishData implements IXmlReader
 	/**
 	 * Instantiates a new fish data.
 	 */
-	protected FishData()
-	{
+	protected FishData() {
 		load();
 	}
 	
 	@Override
-	public void load()
-	{
+	public void load() {
 		_fishEasy.clear();
 		_fishNormal.clear();
 		_fishHard.clear();
@@ -60,40 +57,30 @@ public final class FishData implements IXmlReader
 	}
 	
 	@Override
-	public void parseDocument(Document doc)
-	{
-		for (Node n = doc.getFirstChild(); n != null; n = n.getNextSibling())
-		{
-			if ("list".equalsIgnoreCase(n.getNodeName()))
-			{
-				for (Node d = n.getFirstChild(); d != null; d = d.getNextSibling())
-				{
-					if ("fish".equalsIgnoreCase(d.getNodeName()))
-					{
+	public void parseDocument(Document doc) {
+		for (Node n = doc.getFirstChild(); n != null; n = n.getNextSibling()) {
+			if ("list".equalsIgnoreCase(n.getNodeName())) {
+				for (Node d = n.getFirstChild(); d != null; d = d.getNextSibling()) {
+					if ("fish".equalsIgnoreCase(d.getNodeName())) {
 						final NamedNodeMap attrs = d.getAttributes();
 						
 						final StatsSet set = new StatsSet();
-						for (int i = 0; i < attrs.getLength(); i++)
-						{
+						for (int i = 0; i < attrs.getLength(); i++) {
 							final Node att = attrs.item(i);
 							set.set(att.getNodeName(), att.getNodeValue());
 						}
 						
 						final L2Fish fish = new L2Fish(set);
-						switch (fish.getFishGrade())
-						{
-							case 0:
-							{
+						switch (fish.getFishGrade()) {
+							case 0: {
 								_fishEasy.put(fish.getFishId(), fish);
 								break;
 							}
-							case 1:
-							{
+							case 1: {
 								_fishNormal.put(fish.getFishId(), fish);
 								break;
 							}
-							case 2:
-							{
+							case 2: {
 								_fishHard.put(fish.getFishId(), fish);
 								break;
 							}
@@ -111,45 +98,36 @@ public final class FishData implements IXmlReader
 	 * @param grade the fish Grade
 	 * @return List of Fish that can be fished
 	 */
-	public List<L2Fish> getFish(int level, int group, int grade)
-	{
+	public List<L2Fish> getFish(int level, int group, int grade) {
 		final ArrayList<L2Fish> result = new ArrayList<>();
 		Map<Integer, L2Fish> fish = null;
-		switch (grade)
-		{
-			case 0:
-			{
+		switch (grade) {
+			case 0: {
 				fish = _fishEasy;
 				break;
 			}
-			case 1:
-			{
+			case 1: {
 				fish = _fishNormal;
 				break;
 			}
-			case 2:
-			{
+			case 2: {
 				fish = _fishHard;
 				break;
 			}
-			default:
-			{
+			default: {
 				LOG.warn("{}: Unmanaged fish grade!", getClass().getSimpleName());
 				return result;
 			}
 		}
 		
-		for (L2Fish f : fish.values())
-		{
-			if ((f.getFishLevel() != level) || (f.getFishGroup() != group))
-			{
+		for (L2Fish f : fish.values()) {
+			if ((f.getFishLevel() != level) || (f.getFishGroup() != group)) {
 				continue;
 			}
 			result.add(f);
 		}
 		
-		if (result.isEmpty())
-		{
+		if (result.isEmpty()) {
 			LOG.warn("{}: Cannot find any fish for level: {} group: {} and grade: {}!", getClass().getSimpleName(), level, group, grade);
 		}
 		return result;
@@ -159,13 +137,11 @@ public final class FishData implements IXmlReader
 	 * Gets the single instance of FishData.
 	 * @return single instance of FishData
 	 */
-	public static FishData getInstance()
-	{
+	public static FishData getInstance() {
 		return SingletonHolder._instance;
 	}
 	
-	private static class SingletonHolder
-	{
+	private static class SingletonHolder {
 		protected static final FishData _instance = new FishData();
 	}
 }

+ 16 - 32
src/main/java/com/l2jserver/gameserver/data/xml/impl/FishingMonstersData.java

@@ -33,42 +33,33 @@ import com.l2jserver.gameserver.util.IXmlReader;
  * This class holds the Fishing Monsters information.
  * @author nonom
  */
-public final class FishingMonstersData implements IXmlReader
-{
+public final class FishingMonstersData implements IXmlReader {
 	private final Map<Integer, L2FishingMonster> _fishingMonstersData = new HashMap<>();
 	
 	/**
 	 * Instantiates a new fishing monsters data.
 	 */
-	protected FishingMonstersData()
-	{
+	protected FishingMonstersData() {
 		load();
 	}
 	
 	@Override
-	public void load()
-	{
+	public void load() {
 		_fishingMonstersData.clear();
 		parseDatapackFile("data/stats/fishing/fishingMonsters.xml");
 		LOG.info("{}: Loaded {} Fishing Monsters.", getClass().getSimpleName(), _fishingMonstersData.size());
 	}
 	
 	@Override
-	public void parseDocument(Document doc)
-	{
-		for (Node n = doc.getFirstChild(); n != null; n = n.getNextSibling())
-		{
-			if ("list".equalsIgnoreCase(n.getNodeName()))
-			{
-				for (Node d = n.getFirstChild(); d != null; d = d.getNextSibling())
-				{
-					if ("fishingMonster".equalsIgnoreCase(d.getNodeName()))
-					{
+	public void parseDocument(Document doc) {
+		for (Node n = doc.getFirstChild(); n != null; n = n.getNextSibling()) {
+			if ("list".equalsIgnoreCase(n.getNodeName())) {
+				for (Node d = n.getFirstChild(); d != null; d = d.getNextSibling()) {
+					if ("fishingMonster".equalsIgnoreCase(d.getNodeName())) {
 						
 						final NamedNodeMap attrs = d.getAttributes();
 						final StatsSet set = new StatsSet();
-						for (int i = 0; i < attrs.getLength(); i++)
-						{
+						for (int i = 0; i < attrs.getLength(); i++) {
 							final Node att = attrs.item(i);
 							set.set(att.getNodeName(), att.getNodeValue());
 						}
@@ -86,12 +77,9 @@ public final class FishingMonstersData implements IXmlReader
 	 * @param lvl the fisherman level
 	 * @return a fishing monster given the fisherman level
 	 */
-	public L2FishingMonster getFishingMonster(int lvl)
-	{
-		for (L2FishingMonster fishingMonster : _fishingMonstersData.values())
-		{
-			if ((lvl >= fishingMonster.getUserMinLevel()) && (lvl <= fishingMonster.getUserMaxLevel()))
-			{
+	public L2FishingMonster getFishingMonster(int lvl) {
+		for (L2FishingMonster fishingMonster : _fishingMonstersData.values()) {
+			if ((lvl >= fishingMonster.getUserMinLevel()) && (lvl <= fishingMonster.getUserMaxLevel())) {
 				return fishingMonster;
 			}
 		}
@@ -103,10 +91,8 @@ public final class FishingMonstersData implements IXmlReader
 	 * @param id the fishing monster Id
 	 * @return the fishing monster by Id
 	 */
-	public L2FishingMonster getFishingMonsterById(int id)
-	{
-		if (_fishingMonstersData.containsKey(id))
-		{
+	public L2FishingMonster getFishingMonsterById(int id) {
+		if (_fishingMonstersData.containsKey(id)) {
 			return _fishingMonstersData.get(id);
 		}
 		return null;
@@ -116,13 +102,11 @@ public final class FishingMonstersData implements IXmlReader
 	 * Gets the single instance of FishingMonsterData.
 	 * @return single instance of FishingMonsterData
 	 */
-	public static FishingMonstersData getInstance()
-	{
+	public static FishingMonstersData getInstance() {
 		return SingletonHolder._instance;
 	}
 	
-	private static class SingletonHolder
-	{
+	private static class SingletonHolder {
 		protected static final FishingMonstersData _instance = new FishingMonstersData();
 	}
 }

+ 160 - 352
src/main/java/com/l2jserver/gameserver/datatables/AugmentationData.java

@@ -46,8 +46,7 @@ import com.l2jserver.util.Rnd;
  * Loads augmentation bonuses and skills.
  * @author durgus, Gigiikun, Sandro, UnAfraid
  */
-public class AugmentationData
-{
+public class AugmentationData {
 	// TODO(Zoey76): Implement using IXmlReader.
 	private static final Logger LOGGER = Logger.getLogger(AugmentationData.class.getName());
 	
@@ -92,32 +91,25 @@ public class AugmentationData
 	
 	private final Map<Integer, SkillHolder> _allSkills = new HashMap<>();
 	
-	protected AugmentationData()
-	{
-		for (int i = 0; i < 10; i++)
-		{
+	protected AugmentationData() {
+		for (int i = 0; i < 10; i++) {
 			_blueSkills.add(new ArrayList<Integer>());
 			_purpleSkills.add(new ArrayList<Integer>());
 			_redSkills.add(new ArrayList<Integer>());
 		}
 		
 		load();
-		if (!Config.RETAIL_LIKE_AUGMENTATION)
-		{
-			for (int i = 0; i < 10; i++)
-			{
+		if (!Config.RETAIL_LIKE_AUGMENTATION) {
+			for (int i = 0; i < 10; i++) {
 				LOGGER.info(getClass().getSimpleName() + ": Loaded: " + _blueSkills.get(i).size() + " blue, " + _purpleSkills.get(i).size() + " purple and " + _redSkills.get(i).size() + " red skills for lifeStoneLevel " + i);
 			}
-		}
-		else
-		{
+		} else {
 			LOGGER.log(Level.INFO, getClass().getSimpleName() + ": Loaded: " + _augmentationChances.size() + " augmentations.");
 			LOGGER.log(Level.INFO, getClass().getSimpleName() + ": Loaded: " + _augmentationChancesAcc.size() + " accessory augmentations.");
 		}
 	}
 	
-	public class AugmentationChance
-	{
+	public class AugmentationChance {
 		private final String _WeaponType;
 		private final int _StoneId;
 		private final int _VariationId;
@@ -125,8 +117,7 @@ public class AugmentationData
 		private final int _AugmentId;
 		private final float _AugmentChance;
 		
-		public AugmentationChance(String WeaponType, int StoneId, int VariationId, int CategoryChance, int AugmentId, float AugmentChance)
-		{
+		public AugmentationChance(String WeaponType, int StoneId, int VariationId, int CategoryChance, int AugmentId, float AugmentChance) {
 			_WeaponType = WeaponType;
 			_StoneId = StoneId;
 			_VariationId = VariationId;
@@ -135,39 +126,32 @@ public class AugmentationData
 			_AugmentChance = AugmentChance;
 		}
 		
-		public String getWeaponType()
-		{
+		public String getWeaponType() {
 			return _WeaponType;
 		}
 		
-		public int getStoneId()
-		{
+		public int getStoneId() {
 			return _StoneId;
 		}
 		
-		public int getVariationId()
-		{
+		public int getVariationId() {
 			return _VariationId;
 		}
 		
-		public int getCategoryChance()
-		{
+		public int getCategoryChance() {
 			return _CategoryChance;
 		}
 		
-		public int getAugmentId()
-		{
+		public int getAugmentId() {
 			return _AugmentId;
 		}
 		
-		public float getAugmentChance()
-		{
+		public float getAugmentChance() {
 			return _AugmentChance;
 		}
 	}
 	
-	public class augmentationChanceAcc
-	{
+	public class augmentationChanceAcc {
 		private final String _WeaponType;
 		private final int _StoneId;
 		private final int _VariationId;
@@ -175,8 +159,7 @@ public class AugmentationData
 		private final int _AugmentId;
 		private final float _AugmentChance;
 		
-		public augmentationChanceAcc(String WeaponType, int StoneId, int VariationId, int CategoryChance, int AugmentId, float AugmentChance)
-		{
+		public augmentationChanceAcc(String WeaponType, int StoneId, int VariationId, int CategoryChance, int AugmentId, float AugmentChance) {
 			_WeaponType = WeaponType;
 			_StoneId = StoneId;
 			_VariationId = VariationId;
@@ -185,39 +168,32 @@ public class AugmentationData
 			_AugmentChance = AugmentChance;
 		}
 		
-		public String getWeaponType()
-		{
+		public String getWeaponType() {
 			return _WeaponType;
 		}
 		
-		public int getStoneId()
-		{
+		public int getStoneId() {
 			return _StoneId;
 		}
 		
-		public int getVariationId()
-		{
+		public int getVariationId() {
 			return _VariationId;
 		}
 		
-		public int getCategoryChance()
-		{
+		public int getCategoryChance() {
 			return _CategoryChance;
 		}
 		
-		public int getAugmentId()
-		{
+		public int getAugmentId() {
 			return _AugmentId;
 		}
 		
-		public float getAugmentChance()
-		{
+		public float getAugmentChance() {
 			return _AugmentChance;
 		}
 	}
 	
-	private final void load()
-	{
+	private final void load() {
 		// Load stats
 		DocumentBuilderFactory factory2 = DocumentBuilderFactory.newInstance();
 		factory2.setValidating(false);
@@ -227,77 +203,56 @@ public class AugmentationData
 		// Note: the skillmap data is only used when generating new augmentations
 		// the client expects a different id in order to display the skill in the
 		// items description...
-		if (!Config.RETAIL_LIKE_AUGMENTATION)
-		{
-			try
-			{
+		if (!Config.RETAIL_LIKE_AUGMENTATION) {
+			try {
 				int badAugmantData = 0;
 				DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
 				factory.setValidating(false);
 				factory.setIgnoringComments(true);
 				
 				File file = new File(Config.DATAPACK_ROOT + "/data/stats/augmentation/augmentation_skillmap.xml");
-				if (!file.exists())
-				{
+				if (!file.exists()) {
 					LOGGER.log(Level.WARNING, getClass().getSimpleName() + ": ERROR The augmentation skillmap file is missing.");
 					return;
 				}
 				
 				Document doc = factory.newDocumentBuilder().parse(file);
 				
-				for (Node n = doc.getFirstChild(); n != null; n = n.getNextSibling())
-				{
-					if ("list".equalsIgnoreCase(n.getNodeName()))
-					{
-						for (Node d = n.getFirstChild(); d != null; d = d.getNextSibling())
-						{
-							if ("augmentation".equalsIgnoreCase(d.getNodeName()))
-							{
+				for (Node n = doc.getFirstChild(); n != null; n = n.getNextSibling()) {
+					if ("list".equalsIgnoreCase(n.getNodeName())) {
+						for (Node d = n.getFirstChild(); d != null; d = d.getNextSibling()) {
+							if ("augmentation".equalsIgnoreCase(d.getNodeName())) {
 								NamedNodeMap attrs = d.getAttributes();
 								int skillId = 0, augmentationId = Integer.parseInt(attrs.getNamedItem("id").getNodeValue());
 								int skillLvL = 0;
 								String type = "blue";
 								
-								for (Node cd = d.getFirstChild(); cd != null; cd = cd.getNextSibling())
-								{
-									if ("skillId".equalsIgnoreCase(cd.getNodeName()))
-									{
+								for (Node cd = d.getFirstChild(); cd != null; cd = cd.getNextSibling()) {
+									if ("skillId".equalsIgnoreCase(cd.getNodeName())) {
 										attrs = cd.getAttributes();
 										skillId = Integer.parseInt(attrs.getNamedItem("val").getNodeValue());
-									}
-									else if ("skillLevel".equalsIgnoreCase(cd.getNodeName()))
-									{
+									} else if ("skillLevel".equalsIgnoreCase(cd.getNodeName())) {
 										attrs = cd.getAttributes();
 										skillLvL = Integer.parseInt(attrs.getNamedItem("val").getNodeValue());
-									}
-									else if ("type".equalsIgnoreCase(cd.getNodeName()))
-									{
+									} else if ("type".equalsIgnoreCase(cd.getNodeName())) {
 										attrs = cd.getAttributes();
 										type = attrs.getNamedItem("val").getNodeValue();
 									}
 								}
-								if (skillId == 0)
-								{
+								if (skillId == 0) {
 									badAugmantData++;
 									continue;
-								}
-								else if (skillLvL == 0)
-								{
+								} else if (skillLvL == 0) {
 									badAugmantData++;
 									continue;
 								}
 								int k = (augmentationId - BLUE_START) / SKILLS_BLOCKSIZE;
 								
-								if (type.equalsIgnoreCase("blue"))
-								{
+								if (type.equalsIgnoreCase("blue")) {
 									_blueSkills.get(k).add(augmentationId);
-								}
-								else if (type.equalsIgnoreCase("purple"))
-								{
+								} else if (type.equalsIgnoreCase("purple")) {
 									_purpleSkills.get(k).add(augmentationId);
-								}
-								else
-								{
+								} else {
 									_redSkills.get(k).add(augmentationId);
 								}
 								
@@ -306,34 +261,25 @@ public class AugmentationData
 						}
 					}
 				}
-				if (badAugmantData != 0)
-				{
+				if (badAugmantData != 0) {
 					LOGGER.info(getClass().getSimpleName() + ": " + badAugmantData + " bad skill(s) were skipped.");
 				}
-			}
-			catch (Exception e)
-			{
+			} catch (Exception e) {
 				LOGGER.log(Level.WARNING, getClass().getSimpleName() + ": ERROR parsing augmentation_skillmap.xml.", e);
 				return;
 			}
-		}
-		else
-		{
+		} else {
 			DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
 			factory.setValidating(false);
 			factory.setIgnoringComments(true);
 			
 			File aFile = new File(Config.DATAPACK_ROOT + "/data/stats/augmentation/retailchances.xml");
-			if (aFile.exists())
-			{
+			if (aFile.exists()) {
 				Document aDoc = null;
 				
-				try
-				{
+				try {
 					aDoc = factory.newDocumentBuilder().parse(aFile);
-				}
-				catch (Exception e)
-				{
+				} catch (Exception e) {
 					e.printStackTrace();
 					return;
 				}
@@ -344,48 +290,36 @@ public class AugmentationData
 				int aAugmentId = 0;
 				float aAugmentChance = 0;
 				
-				for (Node l = aDoc.getFirstChild(); l != null; l = l.getNextSibling())
-				{
-					if (l.getNodeName().equals("list"))
-					{
+				for (Node l = aDoc.getFirstChild(); l != null; l = l.getNextSibling()) {
+					if (l.getNodeName().equals("list")) {
 						NamedNodeMap aNodeAttributes = null;
 						
-						for (Node n = l.getFirstChild(); n != null; n = n.getNextSibling())
-						{
-							if (n.getNodeName().equals("weapon"))
-							{
+						for (Node n = l.getFirstChild(); n != null; n = n.getNextSibling()) {
+							if (n.getNodeName().equals("weapon")) {
 								aNodeAttributes = n.getAttributes();
 								
 								aWeaponType = aNodeAttributes.getNamedItem("type").getNodeValue();
 								
-								for (Node c = n.getFirstChild(); c != null; c = c.getNextSibling())
-								{
-									if (c.getNodeName().equals("stone"))
-									{
+								for (Node c = n.getFirstChild(); c != null; c = c.getNextSibling()) {
+									if (c.getNodeName().equals("stone")) {
 										aNodeAttributes = c.getAttributes();
 										
 										aStoneId = Integer.parseInt(aNodeAttributes.getNamedItem("id").getNodeValue());
 										
-										for (Node v = c.getFirstChild(); v != null; v = v.getNextSibling())
-										{
-											if (v.getNodeName().equals("variation"))
-											{
+										for (Node v = c.getFirstChild(); v != null; v = v.getNextSibling()) {
+											if (v.getNodeName().equals("variation")) {
 												aNodeAttributes = v.getAttributes();
 												
 												aVariationId = Integer.parseInt(aNodeAttributes.getNamedItem("id").getNodeValue());
 												
-												for (Node j = v.getFirstChild(); j != null; j = j.getNextSibling())
-												{
-													if (j.getNodeName().equals("category"))
-													{
+												for (Node j = v.getFirstChild(); j != null; j = j.getNextSibling()) {
+													if (j.getNodeName().equals("category")) {
 														aNodeAttributes = j.getAttributes();
 														
 														aCategoryChance = Integer.parseInt(aNodeAttributes.getNamedItem("probability").getNodeValue());
 														
-														for (Node e = j.getFirstChild(); e != null; e = e.getNextSibling())
-														{
-															if (e.getNodeName().equals("augment"))
-															{
+														for (Node e = j.getFirstChild(); e != null; e = e.getNextSibling()) {
+															if (e.getNodeName().equals("augment")) {
 																aNodeAttributes = e.getAttributes();
 																
 																aAugmentId = Integer.parseInt(aNodeAttributes.getNamedItem("id").getNodeValue());
@@ -404,30 +338,23 @@ public class AugmentationData
 						}
 					}
 				}
-			}
-			else
-			{
+			} else {
 				LOGGER.log(Level.WARNING, getClass().getSimpleName() + ": ERROR The retailchances.xml data file is missing.");
 				return;
 			}
 		}
-		if (Config.RETAIL_LIKE_AUGMENTATION_ACCESSORY)
-		{
+		if (Config.RETAIL_LIKE_AUGMENTATION_ACCESSORY) {
 			DocumentBuilderFactory factory3 = DocumentBuilderFactory.newInstance();
 			factory3.setValidating(false);
 			factory3.setIgnoringComments(true);
 			
 			File aFile3 = new File(Config.DATAPACK_ROOT + "/data/stats/augmentation/retailchances_accessory.xml");
-			if (aFile3.exists())
-			{
+			if (aFile3.exists()) {
 				Document aDoc = null;
 				
-				try
-				{
+				try {
 					aDoc = factory3.newDocumentBuilder().parse(aFile3);
-				}
-				catch (Exception e)
-				{
+				} catch (Exception e) {
 					e.printStackTrace();
 					return;
 				}
@@ -438,47 +365,35 @@ public class AugmentationData
 				int aAugmentId = 0;
 				float aAugmentChance = 0;
 				
-				for (Node l = aDoc.getFirstChild(); l != null; l = l.getNextSibling())
-				{
-					if (l.getNodeName().equals("list"))
-					{
+				for (Node l = aDoc.getFirstChild(); l != null; l = l.getNextSibling()) {
+					if (l.getNodeName().equals("list")) {
 						NamedNodeMap aNodeAttributes = null;
-						for (Node n = l.getFirstChild(); n != null; n = n.getNextSibling())
-						{
-							if (n.getNodeName().equals("weapon"))
-							{
+						for (Node n = l.getFirstChild(); n != null; n = n.getNextSibling()) {
+							if (n.getNodeName().equals("weapon")) {
 								aNodeAttributes = n.getAttributes();
 								
 								aWeaponType = aNodeAttributes.getNamedItem("type").getNodeValue();
 								
-								for (Node c = n.getFirstChild(); c != null; c = c.getNextSibling())
-								{
-									if (c.getNodeName().equals("stone"))
-									{
+								for (Node c = n.getFirstChild(); c != null; c = c.getNextSibling()) {
+									if (c.getNodeName().equals("stone")) {
 										aNodeAttributes = c.getAttributes();
 										
 										aStoneId = Integer.parseInt(aNodeAttributes.getNamedItem("id").getNodeValue());
 										
-										for (Node v = c.getFirstChild(); v != null; v = v.getNextSibling())
-										{
-											if (v.getNodeName().equals("variation"))
-											{
+										for (Node v = c.getFirstChild(); v != null; v = v.getNextSibling()) {
+											if (v.getNodeName().equals("variation")) {
 												aNodeAttributes = v.getAttributes();
 												
 												aVariationId = Integer.parseInt(aNodeAttributes.getNamedItem("id").getNodeValue());
 												
-												for (Node j = v.getFirstChild(); j != null; j = j.getNextSibling())
-												{
-													if (j.getNodeName().equals("category"))
-													{
+												for (Node j = v.getFirstChild(); j != null; j = j.getNextSibling()) {
+													if (j.getNodeName().equals("category")) {
 														aNodeAttributes = j.getAttributes();
 														
 														aCategoryChance = Integer.parseInt(aNodeAttributes.getNamedItem("probability").getNodeValue());
 														
-														for (Node e = j.getFirstChild(); e != null; e = e.getNextSibling())
-														{
-															if (e.getNodeName().equals("augment"))
-															{
+														for (Node e = j.getFirstChild(); e != null; e = e.getNextSibling()) {
+															if (e.getNodeName().equals("augment")) {
 																aNodeAttributes = e.getAttributes();
 																
 																aAugmentId = Integer.parseInt(aNodeAttributes.getNamedItem("id").getNodeValue());
@@ -497,9 +412,7 @@ public class AugmentationData
 						}
 					}
 				}
-			}
-			else
-			{
+			} else {
 				LOGGER.log(Level.WARNING, getClass().getSimpleName() + ": ERROR The retailchances_accessory.xml data file is missing.");
 				return;
 			}
@@ -515,10 +428,8 @@ public class AugmentationData
 	 * @param targetItem
 	 * @return
 	 */
-	public L2Augmentation generateRandomAugmentation(int lifeStoneLevel, int lifeStoneGrade, int bodyPart, int lifeStoneId, L2ItemInstance targetItem)
-	{
-		switch (bodyPart)
-		{
+	public L2Augmentation generateRandomAugmentation(int lifeStoneLevel, int lifeStoneGrade, int bodyPart, int lifeStoneId, L2ItemInstance targetItem) {
+		switch (bodyPart) {
 			case L2Item.SLOT_LR_FINGER:
 			case L2Item.SLOT_LR_EAR:
 			case L2Item.SLOT_NECK:
@@ -528,43 +439,32 @@ public class AugmentationData
 		}
 	}
 	
-	private L2Augmentation generateRandomWeaponAugmentation(int lifeStoneLevel, int lifeStoneGrade, int lifeStoneId, L2ItemInstance item)
-	{
+	private L2Augmentation generateRandomWeaponAugmentation(int lifeStoneLevel, int lifeStoneGrade, int lifeStoneId, L2ItemInstance item) {
 		int stat12 = 0;
 		int stat34 = 0;
-		if (Config.RETAIL_LIKE_AUGMENTATION)
-		{
-			if (item.getItem().isMagicWeapon())
-			{
+		if (Config.RETAIL_LIKE_AUGMENTATION) {
+			if (item.getItem().isMagicWeapon()) {
 				List<AugmentationChance> _selectedChances12 = new ArrayList<>();
 				List<AugmentationChance> _selectedChances34 = new ArrayList<>();
-				for (AugmentationChance ac : _augmentationChances)
-				{
-					if (ac.getWeaponType().equals("mage") && (ac.getStoneId() == lifeStoneId))
-					{
-						if (ac.getVariationId() == 1)
-						{
+				for (AugmentationChance ac : _augmentationChances) {
+					if (ac.getWeaponType().equals("mage") && (ac.getStoneId() == lifeStoneId)) {
+						if (ac.getVariationId() == 1) {
 							_selectedChances12.add(ac);
-						}
-						else
-						{
+						} else {
 							_selectedChances34.add(ac);
 						}
 					}
 				}
 				int r = Rnd.get(10000);
 				float s = 10000;
-				for (AugmentationChance ac : _selectedChances12)
-				{
-					if (s > r)
-					{
+				for (AugmentationChance ac : _selectedChances12) {
+					if (s > r) {
 						s -= (ac.getAugmentChance() * 100);
 						stat12 = ac.getAugmentId();
 					}
 				}
 				int[] gradeChance = null;
-				switch (lifeStoneGrade)
-				{
+				switch (lifeStoneGrade) {
 					case AbstractRefinePacket.GRADE_NONE:
 						gradeChance = Config.RETAIL_LIKE_AUGMENTATION_NG_CHANCE;
 						break;
@@ -582,27 +482,18 @@ public class AugmentationData
 				}
 				
 				int c = Rnd.get(100);
-				if (c < gradeChance[0])
-				{
+				if (c < gradeChance[0]) {
 					c = 55;
-				}
-				else if (c < (gradeChance[0] + gradeChance[1]))
-				{
+				} else if (c < (gradeChance[0] + gradeChance[1])) {
 					c = 35;
-				}
-				else if (c < (gradeChance[0] + gradeChance[1] + gradeChance[2]))
-				{
+				} else if (c < (gradeChance[0] + gradeChance[1] + gradeChance[2])) {
 					c = 7;
-				}
-				else
-				{
+				} else {
 					c = 3;
 				}
 				List<AugmentationChance> _selectedChances34final = new ArrayList<>();
-				for (AugmentationChance ac : _selectedChances34)
-				{
-					if (ac.getCategoryChance() == c)
-					{
+				for (AugmentationChance ac : _selectedChances34) {
+					if (ac.getCategoryChance() == c) {
 						_selectedChances34final.add(ac);
 					}
 				}
@@ -610,46 +501,34 @@ public class AugmentationData
 				r = Rnd.get(10000);
 				s = 10000;
 				
-				for (AugmentationChance ac : _selectedChances34final)
-				{
-					if (s > r)
-					{
+				for (AugmentationChance ac : _selectedChances34final) {
+					if (s > r) {
 						s -= (ac.getAugmentChance() * 100);
 						stat34 = ac.getAugmentId();
 					}
 				}
-			}
-			else
-			{
+			} else {
 				List<AugmentationChance> _selectedChances12 = new ArrayList<>();
 				List<AugmentationChance> _selectedChances34 = new ArrayList<>();
-				for (AugmentationChance ac : _augmentationChances)
-				{
-					if (ac.getWeaponType().equals("warrior") && (ac.getStoneId() == lifeStoneId))
-					{
-						if (ac.getVariationId() == 1)
-						{
+				for (AugmentationChance ac : _augmentationChances) {
+					if (ac.getWeaponType().equals("warrior") && (ac.getStoneId() == lifeStoneId)) {
+						if (ac.getVariationId() == 1) {
 							_selectedChances12.add(ac);
-						}
-						else
-						{
+						} else {
 							_selectedChances34.add(ac);
 						}
 					}
 				}
 				int r = Rnd.get(10000);
 				float s = 10000;
-				for (AugmentationChance ac : _selectedChances12)
-				{
-					if (s > r)
-					{
+				for (AugmentationChance ac : _selectedChances12) {
+					if (s > r) {
 						s -= (ac.getAugmentChance() * 100);
 						stat12 = ac.getAugmentId();
 					}
 				}
 				int[] gradeChance = null;
-				switch (lifeStoneGrade)
-				{
+				switch (lifeStoneGrade) {
 					case AbstractRefinePacket.GRADE_NONE:
 						gradeChance = Config.RETAIL_LIKE_AUGMENTATION_NG_CHANCE;
 						break;
@@ -667,36 +546,25 @@ public class AugmentationData
 				}
 				
 				int c = Rnd.get(100);
-				if (c < gradeChance[0])
-				{
+				if (c < gradeChance[0]) {
 					c = 55;
-				}
-				else if (c < (gradeChance[0] + gradeChance[1]))
-				{
+				} else if (c < (gradeChance[0] + gradeChance[1])) {
 					c = 35;
-				}
-				else if (c < (gradeChance[0] + gradeChance[1] + gradeChance[2]))
-				{
+				} else if (c < (gradeChance[0] + gradeChance[1] + gradeChance[2])) {
 					c = 7;
-				}
-				else
-				{
+				} else {
 					c = 3;
 				}
 				List<AugmentationChance> _selectedChances34final = new ArrayList<>();
-				for (AugmentationChance ac : _selectedChances34)
-				{
-					if (ac.getCategoryChance() == c)
-					{
+				for (AugmentationChance ac : _selectedChances34) {
+					if (ac.getCategoryChance() == c) {
 						_selectedChances34final.add(ac);
 					}
 				}
 				r = Rnd.get(10000);
 				s = 10000;
-				for (AugmentationChance ac : _selectedChances34final)
-				{
-					if (s > r)
-					{
+				for (AugmentationChance ac : _selectedChances34final) {
+					if (s > r) {
 						s -= (ac.getAugmentChance() * 100);
 						stat34 = ac.getAugmentId();
 					}
@@ -710,57 +578,46 @@ public class AugmentationData
 		// life stone level is used for stat Id and skill level, but here the max level is 9
 		lifeStoneLevel = Math.min(lifeStoneLevel, 9);
 		
-		switch (lifeStoneGrade)
-		{
+		switch (lifeStoneGrade) {
 			case AbstractRefinePacket.GRADE_NONE:
-				if (Rnd.get(1, 100) <= Config.AUGMENTATION_NG_SKILL_CHANCE)
-				{
+				if (Rnd.get(1, 100) <= Config.AUGMENTATION_NG_SKILL_CHANCE) {
 					generateSkill = true;
 				}
-				if (Rnd.get(1, 100) <= Config.AUGMENTATION_NG_GLOW_CHANCE)
-				{
+				if (Rnd.get(1, 100) <= Config.AUGMENTATION_NG_GLOW_CHANCE) {
 					generateGlow = true;
 				}
 				break;
 			case AbstractRefinePacket.GRADE_MID:
-				if (Rnd.get(1, 100) <= Config.AUGMENTATION_MID_SKILL_CHANCE)
-				{
+				if (Rnd.get(1, 100) <= Config.AUGMENTATION_MID_SKILL_CHANCE) {
 					generateSkill = true;
 				}
-				if (Rnd.get(1, 100) <= Config.AUGMENTATION_MID_GLOW_CHANCE)
-				{
+				if (Rnd.get(1, 100) <= Config.AUGMENTATION_MID_GLOW_CHANCE) {
 					generateGlow = true;
 				}
 				break;
 			case AbstractRefinePacket.GRADE_HIGH:
-				if (Rnd.get(1, 100) <= Config.AUGMENTATION_HIGH_SKILL_CHANCE)
-				{
+				if (Rnd.get(1, 100) <= Config.AUGMENTATION_HIGH_SKILL_CHANCE) {
 					generateSkill = true;
 				}
-				if (Rnd.get(1, 100) <= Config.AUGMENTATION_HIGH_GLOW_CHANCE)
-				{
+				if (Rnd.get(1, 100) <= Config.AUGMENTATION_HIGH_GLOW_CHANCE) {
 					generateGlow = true;
 				}
 				break;
 			case AbstractRefinePacket.GRADE_TOP:
-				if (Rnd.get(1, 100) <= Config.AUGMENTATION_TOP_SKILL_CHANCE)
-				{
+				if (Rnd.get(1, 100) <= Config.AUGMENTATION_TOP_SKILL_CHANCE) {
 					generateSkill = true;
 				}
-				if (Rnd.get(1, 100) <= Config.AUGMENTATION_TOP_GLOW_CHANCE)
-				{
+				if (Rnd.get(1, 100) <= Config.AUGMENTATION_TOP_GLOW_CHANCE) {
 					generateGlow = true;
 				}
 				break;
 			case AbstractRefinePacket.GRADE_ACC:
-				if (Rnd.get(1, 100) <= Config.AUGMENTATION_ACC_SKILL_CHANCE)
-				{
+				if (Rnd.get(1, 100) <= Config.AUGMENTATION_ACC_SKILL_CHANCE) {
 					generateSkill = true;
 				}
 		}
 		
-		if (!generateSkill && (Rnd.get(1, 100) <= Config.AUGMENTATION_BASESTAT_CHANCE))
-		{
+		if (!generateSkill && (Rnd.get(1, 100) <= Config.AUGMENTATION_BASESTAT_CHANCE)) {
 			stat34 = Rnd.get(BASESTAT_STR, BASESTAT_MEN);
 		}
 		
@@ -770,38 +627,25 @@ public class AugmentationData
 		// what's known is: you can't have yellow with skill(or baseStatModifier)
 		// noGrade stone can not have glow, mid only with skill, high has a chance(custom), top allways glow
 		int resultColor = Rnd.get(0, 100);
-		if ((stat34 == 0) && !generateSkill)
-		{
-			if (resultColor <= ((15 * lifeStoneGrade) + 40))
-			{
+		if ((stat34 == 0) && !generateSkill) {
+			if (resultColor <= ((15 * lifeStoneGrade) + 40)) {
 				resultColor = 1;
-			}
-			else
-			{
+			} else {
 				resultColor = 0;
 			}
-		}
-		else
-		{
-			if ((resultColor <= ((10 * lifeStoneGrade) + 5)) || (stat34 != 0))
-			{
+		} else {
+			if ((resultColor <= ((10 * lifeStoneGrade) + 5)) || (stat34 != 0)) {
 				resultColor = 3;
-			}
-			else if (resultColor <= ((10 * lifeStoneGrade) + 10))
-			{
+			} else if (resultColor <= ((10 * lifeStoneGrade) + 10)) {
 				resultColor = 1;
-			}
-			else
-			{
+			} else {
 				resultColor = 2;
 			}
 		}
 		
 		// generate a skill if necessary
-		if (generateSkill)
-		{
-			switch (resultColor)
-			{
+		if (generateSkill) {
+			switch (resultColor) {
 				case 1: // blue skill
 					stat34 = _blueSkills.get(lifeStoneLevel).get(Rnd.get(0, _blueSkills.get(lifeStoneLevel).size() - 1));
 					break;
@@ -836,105 +680,75 @@ public class AugmentationData
 		
 		// is neither a skill nor basestat used for stat34? then generate a normal stat
 		int offset;
-		if (stat34 == 0)
-		{
+		if (stat34 == 0) {
 			int temp = Rnd.get(2, 3);
 			int colorOffset = (resultColor * (10 * STAT_SUBBLOCKSIZE)) + (temp * STAT_BLOCKSIZE) + 1;
 			offset = (lifeStoneLevel * STAT_SUBBLOCKSIZE) + colorOffset;
 			
 			stat34 = Rnd.get(offset, (offset + STAT_SUBBLOCKSIZE) - 1);
-			if (generateGlow && (lifeStoneGrade >= 2))
-			{
+			if (generateGlow && (lifeStoneGrade >= 2)) {
 				offset = (lifeStoneLevel * STAT_SUBBLOCKSIZE) + ((temp - 2) * STAT_BLOCKSIZE) + (lifeStoneGrade * (10 * STAT_SUBBLOCKSIZE)) + 1;
-			}
-			else
-			{
+			} else {
 				offset = (lifeStoneLevel * STAT_SUBBLOCKSIZE) + ((temp - 2) * STAT_BLOCKSIZE) + (Rnd.get(0, 1) * (10 * STAT_SUBBLOCKSIZE)) + 1;
 			}
-		}
-		else
-		{
-			if (!generateGlow)
-			{
+		} else {
+			if (!generateGlow) {
 				offset = (lifeStoneLevel * STAT_SUBBLOCKSIZE) + (Rnd.get(0, 1) * STAT_BLOCKSIZE) + 1;
-			}
-			else
-			{
+			} else {
 				offset = (lifeStoneLevel * STAT_SUBBLOCKSIZE) + (Rnd.get(0, 1) * STAT_BLOCKSIZE) + (((lifeStoneGrade + resultColor) / 2) * (10 * STAT_SUBBLOCKSIZE)) + 1;
 			}
 		}
 		stat12 = Rnd.get(offset, (offset + STAT_SUBBLOCKSIZE) - 1);
 		
-		if (Config.DEBUG)
-		{
+		if (Config.DEBUG) {
 			LOGGER.info(getClass().getSimpleName() + ": Augmentation success: stat12=" + stat12 + "; stat34=" + stat34 + "; resultColor=" + resultColor + "; level=" + lifeStoneLevel + "; grade=" + lifeStoneGrade);
 		}
 		return new L2Augmentation(((stat34 << 16) + stat12));
 	}
 	
-	private L2Augmentation generateRandomAccessoryAugmentation(int lifeStoneLevel, int bodyPart, int lifeStoneId)
-	{
+	private L2Augmentation generateRandomAccessoryAugmentation(int lifeStoneLevel, int bodyPart, int lifeStoneId) {
 		int stat12 = 0;
 		int stat34 = 0;
-		if (Config.RETAIL_LIKE_AUGMENTATION_ACCESSORY)
-		{
+		if (Config.RETAIL_LIKE_AUGMENTATION_ACCESSORY) {
 			List<augmentationChanceAcc> _selectedChances12 = new ArrayList<>();
 			List<augmentationChanceAcc> _selectedChances34 = new ArrayList<>();
-			for (augmentationChanceAcc ac : _augmentationChancesAcc)
-			{
-				if (ac.getWeaponType().equals("warrior") && (ac.getStoneId() == lifeStoneId))
-				{
-					if (ac.getVariationId() == 1)
-					{
+			for (augmentationChanceAcc ac : _augmentationChancesAcc) {
+				if (ac.getWeaponType().equals("warrior") && (ac.getStoneId() == lifeStoneId)) {
+					if (ac.getVariationId() == 1) {
 						_selectedChances12.add(ac);
-					}
-					else
-					{
+					} else {
 						_selectedChances34.add(ac);
 					}
 				}
 			}
 			int r = Rnd.get(10000);
 			float s = 10000;
-			for (augmentationChanceAcc ac : _selectedChances12)
-			{
-				if (s > r)
-				{
+			for (augmentationChanceAcc ac : _selectedChances12) {
+				if (s > r) {
 					s -= (ac.getAugmentChance() * 100);
 					stat12 = ac.getAugmentId();
 				}
 			}
 			int c = Rnd.get(100);
-			if (c < 55)
-			{
+			if (c < 55) {
 				c = 55;
-			}
-			else if (c < 90)
-			{
+			} else if (c < 90) {
 				c = 35;
-			}
-			else if (c < 99)
-			{
+			} else if (c < 99) {
 				c = 9;
-			}
-			else
-			{
+			} else {
 				c = 1;
 			}
 			List<augmentationChanceAcc> _selectedChances34final = new ArrayList<>();
-			for (augmentationChanceAcc ac : _selectedChances34)
-			{
-				if (ac.getCategoryChance() == c)
-				{
+			for (augmentationChanceAcc ac : _selectedChances34) {
+				if (ac.getCategoryChance() == c) {
 					_selectedChances34final.add(ac);
 				}
 			}
 			r = Rnd.get(10000);
 			s = 10000;
-			for (augmentationChanceAcc ac : _selectedChances34final)
-			{
-				if (s > r)
-				{
+			for (augmentationChanceAcc ac : _selectedChances34final) {
+				if (s > r) {
 					s -= (ac.getAugmentChance() * 100);
 					stat34 = ac.getAugmentId();
 				}
@@ -946,8 +760,7 @@ public class AugmentationData
 		int base = 0;
 		int skillsLength = 0;
 		
-		switch (bodyPart)
-		{
+		switch (bodyPart) {
 			case L2Item.SLOT_LR_FINGER:
 				base = ACC_RING_START + (ACC_RING_BLOCKSIZE * lifeStoneLevel);
 				skillsLength = ACC_RING_SKILLS;
@@ -969,15 +782,13 @@ public class AugmentationData
 		// first augmentation (stats only)
 		stat12 = Rnd.get(ACC_STAT_SUBBLOCKSIZE);
 		Options op = null;
-		if (Rnd.get(1, 100) <= Config.AUGMENTATION_ACC_SKILL_CHANCE)
-		{
+		if (Rnd.get(1, 100) <= Config.AUGMENTATION_ACC_SKILL_CHANCE) {
 			// second augmentation (skill)
 			stat34 = base + Rnd.get(skillsLength);
 			op = OptionData.getInstance().getOptions(stat34);
 		}
 		
-		if ((op == null) || (!op.hasActiveSkill() && !op.hasPassiveSkill() && !op.hasActivationSkills()))
-		{
+		if ((op == null) || (!op.hasActiveSkill() && !op.hasPassiveSkill() && !op.hasActivationSkills())) {
 			// second augmentation (stats)
 			// calculating any different from stat12 value inside sub-block
 			// starting from next and wrapping over using remainder
@@ -989,20 +800,17 @@ public class AugmentationData
 		// stat12 has stats only
 		stat12 = base + skillsLength + (ACC_STAT_SUBBLOCKSIZE * resultColor) + stat12;
 		
-		if (Config.DEBUG)
-		{
+		if (Config.DEBUG) {
 			LOGGER.info(getClass().getSimpleName() + ": Accessory augmentation success: stat12=" + stat12 + "; stat34=" + stat34 + "; level=" + lifeStoneLevel);
 		}
 		return new L2Augmentation(((stat34 << 16) + stat12));
 	}
 	
-	public static final AugmentationData getInstance()
-	{
+	public static final AugmentationData getInstance() {
 		return SingletonHolder._instance;
 	}
 	
-	private static class SingletonHolder
-	{
+	private static class SingletonHolder {
 		protected static final AugmentationData _instance = new AugmentationData();
 	}
 }

+ 13 - 26
src/main/java/com/l2jserver/gameserver/datatables/EventDroplist.java

@@ -31,20 +31,17 @@ import com.l2jserver.gameserver.script.EventDrop;
  * Those extra Items are defined in the table <b>allNpcDateDrops</b>.<br>
  * Each Special Event has a start and end date to stop to drop extra Items automatically.
  */
-public class EventDroplist
-{
+public class EventDroplist {
 	/**
 	 * The table containing all DataDrop object
 	 */
 	private static final List<DateDrop> ALL_NPC_DATE_DROPS = new ArrayList<>();
 	
-	public static class DateDrop
-	{
+	public static class DateDrop {
 		protected final DateRange _dateRange;
 		private final EventDrop _eventDrop;
 		
-		public DateDrop(DateRange dateRange, EventDrop eventDrop)
-		{
+		public DateDrop(DateRange dateRange, EventDrop eventDrop) {
 			_dateRange = dateRange;
 			_eventDrop = eventDrop;
 		}
@@ -52,16 +49,14 @@ public class EventDroplist
 		/**
 		 * @return the _eventDrop
 		 */
-		public EventDrop getEventDrop()
-		{
+		public EventDrop getEventDrop() {
 			return _eventDrop;
 		}
 		
 		/**
 		 * @return the _dateRange
 		 */
-		public DateRange getDateRange()
-		{
+		public DateRange getDateRange() {
 			return _dateRange;
 		}
 	}
@@ -73,8 +68,7 @@ public class EventDroplist
 	 * @param chance The chance to obtain this drop
 	 * @param dateRange The DateRange object to add to this DateDrop
 	 */
-	public void addGlobalDrop(int[] itemIdList, int[] count, int chance, DateRange dateRange)
-	{
+	public void addGlobalDrop(int[] itemIdList, int[] count, int chance, DateRange dateRange) {
 		ALL_NPC_DATE_DROPS.add(new DateDrop(dateRange, new EventDrop(itemIdList, count[0], count[1], chance)));
 	}
 	
@@ -85,8 +79,7 @@ public class EventDroplist
 	 * @param chance the drop chance
 	 * @param dateRange the event drop rate range
 	 */
-	public void addGlobalDrop(int itemId, long min, long max, int chance, DateRange dateRange)
-	{
+	public void addGlobalDrop(int itemId, long min, long max, int chance, DateRange dateRange) {
 		ALL_NPC_DATE_DROPS.add(new DateDrop(dateRange, new EventDrop(itemId, min, max, chance)));
 	}
 	
@@ -95,35 +88,29 @@ public class EventDroplist
 	 * @param dateRange the date range.
 	 * @param eventDrop the event drop.
 	 */
-	public void addGlobalDrop(DateRange dateRange, EventDrop eventDrop)
-	{
+	public void addGlobalDrop(DateRange dateRange, EventDrop eventDrop) {
 		ALL_NPC_DATE_DROPS.add(new DateDrop(dateRange, eventDrop));
 	}
 	
 	/**
 	 * @return all DateDrop of EventDroplist allNpcDateDrops within the date range.
 	 */
-	public List<DateDrop> getAllDrops()
-	{
+	public List<DateDrop> getAllDrops() {
 		final List<DateDrop> list = new ArrayList<>();
 		final Date currentDate = new Date();
-		for (DateDrop drop : ALL_NPC_DATE_DROPS)
-		{
-			if (drop._dateRange.isWithinRange(currentDate))
-			{
+		for (DateDrop drop : ALL_NPC_DATE_DROPS) {
+			if (drop._dateRange.isWithinRange(currentDate)) {
 				list.add(drop);
 			}
 		}
 		return list;
 	}
 	
-	public static EventDroplist getInstance()
-	{
+	public static EventDroplist getInstance() {
 		return SingletonHolder._instance;
 	}
 	
-	private static class SingletonHolder
-	{
+	private static class SingletonHolder {
 		protected static final EventDroplist _instance = new EventDroplist();
 	}
 }

+ 40 - 81
src/main/java/com/l2jserver/gameserver/datatables/MerchantPriceConfigTable.java

@@ -41,13 +41,11 @@ import com.l2jserver.gameserver.model.entity.Castle;
 /**
  * @author KenM
  */
-public class MerchantPriceConfigTable implements InstanceListManager
-{
+public class MerchantPriceConfigTable implements InstanceListManager {
 	// Zoey76: TODO: Implement using IXmlReader.
 	private static Logger LOGGER = Logger.getLogger(MerchantPriceConfigTable.class.getName());
 	
-	public static MerchantPriceConfigTable getInstance()
-	{
+	public static MerchantPriceConfigTable getInstance() {
 		return SingletonHolder._instance;
 	}
 	
@@ -56,65 +54,53 @@ public class MerchantPriceConfigTable implements InstanceListManager
 	private final Map<Integer, MerchantPriceConfig> _mpcs = new HashMap<>();
 	private MerchantPriceConfig _defaultMpc;
 	
-	public MerchantPriceConfig getMerchantPriceConfig(L2MerchantInstance npc)
-	{
-		for (MerchantPriceConfig mpc : _mpcs.values())
-		{
-			if ((npc.getWorldRegion() != null) && npc.getWorldRegion().containsZone(mpc.getZoneId()))
-			{
+	public MerchantPriceConfig getMerchantPriceConfig(L2MerchantInstance npc) {
+		for (MerchantPriceConfig mpc : _mpcs.values()) {
+			if ((npc.getWorldRegion() != null) && npc.getWorldRegion().containsZone(mpc.getZoneId())) {
 				return mpc;
 			}
 		}
 		return _defaultMpc;
 	}
 	
-	public MerchantPriceConfig getMerchantPriceConfig(int id)
-	{
+	public MerchantPriceConfig getMerchantPriceConfig(int id) {
 		return _mpcs.get(id);
 	}
 	
-	public void loadXML() throws SAXException, IOException, ParserConfigurationException
-	{
+	public void loadXML() throws SAXException, IOException, ParserConfigurationException {
 		DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
 		factory.setValidating(false);
 		factory.setIgnoringComments(true);
 		File file = new File(Config.DATAPACK_ROOT + "/data/" + MPCS_FILE);
-		if (file.exists())
-		{
+		if (file.exists()) {
 			int defaultPriceConfigId;
 			Document doc = factory.newDocumentBuilder().parse(file);
 			
 			Node n = doc.getDocumentElement();
 			Node dpcNode = n.getAttributes().getNamedItem("defaultPriceConfig");
-			if (dpcNode == null)
-			{
+			if (dpcNode == null) {
 				throw new IllegalStateException("merchantPriceConfig must define an 'defaultPriceConfig'");
 			}
 			defaultPriceConfigId = Integer.parseInt(dpcNode.getNodeValue());
 			
 			MerchantPriceConfig mpc;
-			for (n = n.getFirstChild(); n != null; n = n.getNextSibling())
-			{
+			for (n = n.getFirstChild(); n != null; n = n.getNextSibling()) {
 				mpc = parseMerchantPriceConfig(n);
-				if (mpc != null)
-				{
+				if (mpc != null) {
 					_mpcs.put(mpc.getId(), mpc);
 				}
 			}
 			
 			MerchantPriceConfig defaultMpc = this.getMerchantPriceConfig(defaultPriceConfigId);
-			if (defaultMpc == null)
-			{
+			if (defaultMpc == null) {
 				throw new IllegalStateException("'defaultPriceConfig' points to an non-loaded priceConfig");
 			}
 			_defaultMpc = defaultMpc;
 		}
 	}
 	
-	private MerchantPriceConfig parseMerchantPriceConfig(Node n)
-	{
-		if (n.getNodeName().equals("priceConfig"))
-		{
+	private MerchantPriceConfig parseMerchantPriceConfig(Node n) {
+		if (n.getNodeName().equals("priceConfig")) {
 			final int id;
 			final int baseTax;
 			int castleId = -1;
@@ -122,35 +108,30 @@ public class MerchantPriceConfigTable implements InstanceListManager
 			final String name;
 			
 			Node node = n.getAttributes().getNamedItem("id");
-			if (node == null)
-			{
+			if (node == null) {
 				throw new IllegalStateException("Must define the priceConfig 'id'");
 			}
 			id = Integer.parseInt(node.getNodeValue());
 			
 			node = n.getAttributes().getNamedItem("name");
-			if (node == null)
-			{
+			if (node == null) {
 				throw new IllegalStateException("Must define the priceConfig 'name'");
 			}
 			name = node.getNodeValue();
 			
 			node = n.getAttributes().getNamedItem("baseTax");
-			if (node == null)
-			{
+			if (node == null) {
 				throw new IllegalStateException("Must define the priceConfig 'baseTax'");
 			}
 			baseTax = Integer.parseInt(node.getNodeValue());
 			
 			node = n.getAttributes().getNamedItem("castleId");
-			if (node != null)
-			{
+			if (node != null) {
 				castleId = Integer.parseInt(node.getNodeValue());
 			}
 			
 			node = n.getAttributes().getNamedItem("zoneId");
-			if (node != null)
-			{
+			if (node != null) {
 				zoneId = Integer.parseInt(node.getNodeValue());
 			}
 			
@@ -160,38 +141,30 @@ public class MerchantPriceConfigTable implements InstanceListManager
 	}
 	
 	@Override
-	public void loadInstances()
-	{
-		try
-		{
+	public void loadInstances() {
+		try {
 			loadXML();
 			LOGGER.info(getClass().getSimpleName() + ": Loaded " + _mpcs.size() + " merchant price configs.");
-		}
-		catch (Exception e)
-		{
+		} catch (Exception e) {
 			LOGGER.log(Level.SEVERE, getClass().getSimpleName() + ": Failed loading MerchantPriceConfigTable. Reason: " + e.getMessage(), e);
 		}
 	}
 	
 	@Override
-	public void updateReferences()
-	{
-		for (final MerchantPriceConfig mpc : _mpcs.values())
-		{
+	public void updateReferences() {
+		for (final MerchantPriceConfig mpc : _mpcs.values()) {
 			mpc.updateReferences();
 		}
 	}
 	
 	@Override
-	public void activateInstances()
-	{
+	public void activateInstances() {
 	}
 	
 	/**
 	 * @author KenM
 	 */
-	public static final class MerchantPriceConfig
-	{
+	public static final class MerchantPriceConfig {
 		private final int _id;
 		private final String _name;
 		private final int _baseTax;
@@ -199,8 +172,7 @@ public class MerchantPriceConfigTable implements InstanceListManager
 		private Castle _castle;
 		private final int _zoneId;
 		
-		public MerchantPriceConfig(final int id, final String name, final int baseTax, final int castleId, final int zoneId)
-		{
+		public MerchantPriceConfig(final int id, final String name, final int baseTax, final int castleId, final int zoneId) {
 			_id = id;
 			_name = name;
 			_baseTax = baseTax;
@@ -211,82 +183,69 @@ public class MerchantPriceConfigTable implements InstanceListManager
 		/**
 		 * @return Returns the id.
 		 */
-		public int getId()
-		{
+		public int getId() {
 			return _id;
 		}
 		
 		/**
 		 * @return Returns the name.
 		 */
-		public String getName()
-		{
+		public String getName() {
 			return _name;
 		}
 		
 		/**
 		 * @return Returns the baseTax.
 		 */
-		public int getBaseTax()
-		{
+		public int getBaseTax() {
 			return _baseTax;
 		}
 		
 		/**
 		 * @return Returns the baseTax / 100.0.
 		 */
-		public double getBaseTaxRate()
-		{
+		public double getBaseTaxRate() {
 			return _baseTax / 100.0;
 		}
 		
 		/**
 		 * @return Returns the castle.
 		 */
-		public Castle getCastle()
-		{
+		public Castle getCastle() {
 			return _castle;
 		}
 		
 		/**
 		 * @return Returns the zoneId.
 		 */
-		public int getZoneId()
-		{
+		public int getZoneId() {
 			return _zoneId;
 		}
 		
-		public boolean hasCastle()
-		{
+		public boolean hasCastle() {
 			return getCastle() != null;
 		}
 		
-		public double getCastleTaxRate()
-		{
+		public double getCastleTaxRate() {
 			return hasCastle() ? getCastle().getTaxRate() : 0.0;
 		}
 		
-		public int getTotalTax()
-		{
+		public int getTotalTax() {
 			return hasCastle() ? (getCastle().getTaxPercent() + getBaseTax()) : getBaseTax();
 		}
 		
-		public double getTotalTaxRate()
-		{
+		public double getTotalTaxRate() {
 			return getTotalTax() / 100.0;
 		}
 		
-		public void updateReferences()
-		{
-			if (_castleId > 0)
-			{
+		public void updateReferences() {
+			if (_castleId > 0) {
 				_castle = CastleManager.getInstance().getCastleById(_castleId);
 			}
 		}
 	}
 	
-	private static class SingletonHolder
-	{
+	private static class SingletonHolder {
 		protected static final MerchantPriceConfigTable _instance = new MerchantPriceConfigTable();
 	}
 }

+ 15 - 31
src/main/java/com/l2jserver/gameserver/datatables/NpcPersonalAIData.java

@@ -30,15 +30,13 @@ import com.l2jserver.util.Rnd;
  * It can be either general parameters overridden for certain NPC instance instead of template parameters(aggro range, for example), or some optional parameters, handled by datapack scripts.
  * @author GKR
  */
-public class NpcPersonalAIData
-{
+public class NpcPersonalAIData {
 	private final Map<String, Map<String, Integer>> _AIData = new HashMap<>();
 	
 	/**
 	 * Instantiates a new table.
 	 */
-	protected NpcPersonalAIData()
-	{
+	protected NpcPersonalAIData() {
 	}
 	
 	/**
@@ -46,13 +44,10 @@ public class NpcPersonalAIData
 	 * @param spawnDat spawn to process
 	 * @param data Map of AI values
 	 */
-	public void storeData(L2Spawn spawnDat, Map<String, Integer> data)
-	{
-		if ((data != null) && !data.isEmpty())
-		{
+	public void storeData(L2Spawn spawnDat, Map<String, Integer> data) {
+		if ((data != null) && !data.isEmpty()) {
 			// check for spawn name. Since spawn name is key for AI Data, generate random name, if spawn name isn't specified
-			if (spawnDat.getName() == null)
-			{
+			if (spawnDat.getName() == null) {
 				spawnDat.setName(Long.toString(Rnd.nextLong()));
 			}
 			
@@ -66,8 +61,7 @@ public class NpcPersonalAIData
 	 * @param paramName parameter to check
 	 * @return value of given parameter for given spawn name
 	 */
-	public int getAIValue(String spawnName, String paramName)
-	{
+	public int getAIValue(String spawnName, String paramName) {
 		return hasAIValue(spawnName, paramName) ? _AIData.get(spawnName).get(paramName) : -1;
 	}
 	
@@ -77,8 +71,7 @@ public class NpcPersonalAIData
 	 * @param paramName parameter name to check
 	 * @return {@code true} if parameter paramName is set for spawn spawnName, {@code false} otherwise
 	 */
-	public boolean hasAIValue(String spawnName, String paramName)
-	{
+	public boolean hasAIValue(String spawnName, String paramName) {
 		return (spawnName != null) && _AIData.containsKey(spawnName) && _AIData.get(spawnName).containsKey(paramName);
 	}
 	
@@ -88,18 +81,13 @@ public class NpcPersonalAIData
 	 * @param spawn link to NPC's spawn
 	 * @param spawnName name of spawn
 	 */
-	public void initializeNpcParameters(L2Npc npc, L2Spawn spawn, String spawnName)
-	{
-		if (_AIData.containsKey(spawnName))
-		{
+	public void initializeNpcParameters(L2Npc npc, L2Spawn spawn, String spawnName) {
+		if (_AIData.containsKey(spawnName)) {
 			Map<String, Integer> map = _AIData.get(spawnName);
 			
-			try
-			{
-				for (String key : map.keySet())
-				{
-					switch (key)
-					{
+			try {
+				for (String key : map.keySet()) {
+					switch (key) {
 						case "disableRandomAnimation":
 							npc.setRandomAnimationEnabled((map.get(key) == 0));
 							break;
@@ -109,9 +97,7 @@ public class NpcPersonalAIData
 							break;
 					}
 				}
-			}
-			catch (Exception e)
-			{
+			} catch (Exception e) {
 				// Do nothing
 			}
 		}
@@ -121,13 +107,11 @@ public class NpcPersonalAIData
 	 * Gets the single instance of NpcTable.
 	 * @return single instance of NpcTable
 	 */
-	public static NpcPersonalAIData getInstance()
-	{
+	public static NpcPersonalAIData getInstance() {
 		return SingletonHolder._instance;
 	}
 	
-	private static class SingletonHolder
-	{
+	private static class SingletonHolder {
 		protected static final NpcPersonalAIData _instance = new NpcPersonalAIData();
 	}
 }

+ 21 - 42
src/main/java/com/l2jserver/gameserver/datatables/SkillData.java

@@ -33,28 +33,24 @@ import com.l2jserver.gameserver.model.skills.Skill;
 /**
  * Skill data.
  */
-public final class SkillData
-{
+public final class SkillData {
 	private static Logger LOGGER = Logger.getLogger(SkillData.class.getName());
 	
 	private final Map<Integer, Skill> _skills = new HashMap<>();
 	private final Map<Integer, Integer> _skillMaxLevel = new HashMap<>();
 	private final Set<Integer> _enchantable = new HashSet<>();
 	
-	protected SkillData()
-	{
+	protected SkillData() {
 		load();
 	}
 	
-	public void reload()
-	{
+	public void reload() {
 		load();
 		// Reload Skill Tree as well.
 		SkillTreesData.getInstance().load();
 	}
 	
-	private void load()
-	{
+	private void load() {
 		final Map<Integer, Skill> _temp = new HashMap<>();
 		DocumentEngine.getInstance().loadAllSkills(_temp);
 		
@@ -63,14 +59,11 @@ public final class SkillData
 		
 		_skillMaxLevel.clear();
 		_enchantable.clear();
-		for (Skill skill : _skills.values())
-		{
+		for (Skill skill : _skills.values()) {
 			final int skillId = skill.getId();
 			final int skillLvl = skill.getLevel();
-			if (skillLvl > 99)
-			{
-				if (!_enchantable.contains(skillId))
-				{
+			if (skillLvl > 99) {
+				if (!_enchantable.contains(skillId)) {
 					_enchantable.add(skillId);
 				}
 				continue;
@@ -78,8 +71,7 @@ public final class SkillData
 			
 			// only non-enchanted skills
 			final int maxLvl = getMaxLevel(skillId);
-			if (skillLvl > maxLvl)
-			{
+			if (skillLvl > maxLvl) {
 				_skillMaxLevel.put(skillId, skillLvl);
 			}
 		}
@@ -90,8 +82,7 @@ public final class SkillData
 	 * @param skill The L2Skill to be hashed
 	 * @return getSkillHashCode(skill.getId(), skill.getLevel())
 	 */
-	public static int getSkillHashCode(Skill skill)
-	{
+	public static int getSkillHashCode(Skill skill) {
 		return getSkillHashCode(skill.getId(), skill.getLevel());
 	}
 	
@@ -101,26 +92,21 @@ public final class SkillData
 	 * @param skillLevel The Skill Level
 	 * @return The Skill hash number
 	 */
-	public static int getSkillHashCode(int skillId, int skillLevel)
-	{
+	public static int getSkillHashCode(int skillId, int skillLevel) {
 		return (skillId * 1021) + skillLevel;
 	}
 	
-	public Skill getSkill(int skillId, int level)
-	{
+	public Skill getSkill(int skillId, int level) {
 		final Skill result = _skills.get(getSkillHashCode(skillId, level));
-		if (result != null)
-		{
+		if (result != null) {
 			return result;
 		}
 		
 		// skill/level not found, fix for transformation scripts
 		final int maxLvl = getMaxLevel(skillId);
 		// requested level too high
-		if ((maxLvl > 0) && (level > maxLvl))
-		{
-			if (Config.DEBUG)
-			{
+		if ((maxLvl > 0) && (level > maxLvl)) {
+			if (Config.DEBUG) {
 				LOGGER.log(Level.WARNING, getClass().getSimpleName() + ": call to unexisting skill level id: " + skillId + " requested level: " + level + " max level: " + maxLvl, new Throwable());
 			}
 			return _skills.get(getSkillHashCode(skillId, maxLvl));
@@ -130,8 +116,7 @@ public final class SkillData
 		return null;
 	}
 	
-	public int getMaxLevel(int skillId)
-	{
+	public int getMaxLevel(int skillId) {
 		final Integer maxLevel = _skillMaxLevel.get(skillId);
 		return maxLevel != null ? maxLevel : 0;
 	}
@@ -141,8 +126,7 @@ public final class SkillData
 	 * @param skillId the skill ID
 	 * @return {@code true} if the skill is enchantable, {@code false} otherwise
 	 */
-	public boolean isEnchantable(int skillId)
-	{
+	public boolean isEnchantable(int skillId) {
 		return _enchantable.contains(skillId);
 	}
 	
@@ -151,32 +135,27 @@ public final class SkillData
 	 * @param hasCastle
 	 * @return an array with siege skills. If addNoble == true, will add also Advanced headquarters.
 	 */
-	public Skill[] getSiegeSkills(boolean addNoble, boolean hasCastle)
-	{
+	public Skill[] getSiegeSkills(boolean addNoble, boolean hasCastle) {
 		Skill[] temp = new Skill[2 + (addNoble ? 1 : 0) + (hasCastle ? 2 : 0)];
 		int i = 0;
 		temp[i++] = _skills.get(SkillData.getSkillHashCode(246, 1));
 		temp[i++] = _skills.get(SkillData.getSkillHashCode(247, 1));
 		
-		if (addNoble)
-		{
+		if (addNoble) {
 			temp[i++] = _skills.get(SkillData.getSkillHashCode(326, 1));
 		}
-		if (hasCastle)
-		{
+		if (hasCastle) {
 			temp[i++] = _skills.get(SkillData.getSkillHashCode(844, 1));
 			temp[i++] = _skills.get(SkillData.getSkillHashCode(845, 1));
 		}
 		return temp;
 	}
 	
-	public static SkillData getInstance()
-	{
+	public static SkillData getInstance() {
 		return SingletonHolder._instance;
 	}
 	
-	private static class SingletonHolder
-	{
+	private static class SingletonHolder {
 		protected static final SkillData _instance = new SkillData();
 	}
 }

File diff ditekan karena terlalu besar
+ 167 - 343
src/main/java/com/l2jserver/gameserver/engines/DocumentBase.java


+ 18 - 36
src/main/java/com/l2jserver/gameserver/engines/DocumentEngine.java

@@ -35,55 +35,44 @@ import com.l2jserver.util.file.filter.XMLFilter;
 /**
  * @author mkizub
  */
-public class DocumentEngine
-{
+public class DocumentEngine {
 	private static final Logger _log = Logger.getLogger(DocumentEngine.class.getName());
 	
 	private final List<File> _itemFiles = new ArrayList<>();
 	private final List<File> _skillFiles = new ArrayList<>();
 	
-	public static DocumentEngine getInstance()
-	{
+	public static DocumentEngine getInstance() {
 		return SingletonHolder._instance;
 	}
 	
-	protected DocumentEngine()
-	{
+	protected DocumentEngine() {
 		hashFiles("data/stats/items", _itemFiles);
-		if (Config.CUSTOM_ITEMS_LOAD)
-		{
+		if (Config.CUSTOM_ITEMS_LOAD) {
 			hashFiles("data/stats/items/custom", _itemFiles);
 		}
 		hashFiles("data/stats/skills", _skillFiles);
-		if (Config.CUSTOM_SKILLS_LOAD)
-		{
+		if (Config.CUSTOM_SKILLS_LOAD) {
 			hashFiles("data/stats/skills/custom", _skillFiles);
 		}
 	}
 	
-	private void hashFiles(String dirname, List<File> hash)
-	{
+	private void hashFiles(String dirname, List<File> hash) {
 		File dir = new File(Config.DATAPACK_ROOT, dirname);
-		if (!dir.exists())
-		{
+		if (!dir.exists()) {
 			_log.warning("Dir " + dir.getAbsolutePath() + " not exists");
 			return;
 		}
 		
 		final File[] files = dir.listFiles(new XMLFilter());
-		if (files != null)
-		{
-			for (File f : files)
-			{
+		if (files != null) {
+			for (File f : files) {
 				hash.add(f);
 			}
 		}
 	}
 	
-	public List<Skill> loadSkills(File file)
-	{
-		if (file == null)
-		{
+	public List<Skill> loadSkills(File file) {
+		if (file == null) {
 			_log.warning("Skill file not found.");
 			return null;
 		}
@@ -92,18 +81,14 @@ public class DocumentEngine
 		return doc.getSkills();
 	}
 	
-	public void loadAllSkills(final Map<Integer, Skill> allSkills)
-	{
+	public void loadAllSkills(final Map<Integer, Skill> allSkills) {
 		int count = 0;
-		for (File file : _skillFiles)
-		{
+		for (File file : _skillFiles) {
 			List<Skill> s = loadSkills(file);
-			if (s == null)
-			{
+			if (s == null) {
 				continue;
 			}
-			for (Skill skill : s)
-			{
+			for (Skill skill : s) {
 				allSkills.put(SkillData.getSkillHashCode(skill), skill);
 				count++;
 			}
@@ -115,11 +100,9 @@ public class DocumentEngine
 	 * Return created items
 	 * @return List of {@link L2Item}
 	 */
-	public List<L2Item> loadItems()
-	{
+	public List<L2Item> loadItems() {
 		List<L2Item> list = new ArrayList<>();
-		for (File f : _itemFiles)
-		{
+		for (File f : _itemFiles) {
 			DocumentItem document = new DocumentItem(f);
 			document.parse();
 			list.addAll(document.getItemList());
@@ -127,8 +110,7 @@ public class DocumentEngine
 		return list;
 	}
 	
-	private static class SingletonHolder
-	{
+	private static class SingletonHolder {
 		protected static final DocumentEngine _instance = new DocumentEngine();
 	}
 }

+ 28 - 62
src/main/java/com/l2jserver/gameserver/engines/items/DocumentItem.java

@@ -36,58 +36,45 @@ import com.l2jserver.gameserver.model.items.L2Item;
 /**
  * @author mkizub, JIV
  */
-public final class DocumentItem extends DocumentBase
-{
+public final class DocumentItem extends DocumentBase {
 	private Item _currentItem = null;
 	private final List<L2Item> _itemsInFile = new ArrayList<>();
 	
 	/**
 	 * @param file
 	 */
-	public DocumentItem(File file)
-	{
+	public DocumentItem(File file) {
 		super(file);
 	}
 	
 	@Override
-	protected StatsSet getStatsSet()
-	{
+	protected StatsSet getStatsSet() {
 		return _currentItem.set;
 	}
 	
 	@Override
-	protected String getTableValue(String name)
-	{
+	protected String getTableValue(String name) {
 		return _tables.get(name)[_currentItem.currentLevel];
 	}
 	
 	@Override
-	protected String getTableValue(String name, int idx)
-	{
+	protected String getTableValue(String name, int idx) {
 		return _tables.get(name)[idx - 1];
 	}
 	
 	@Override
-	protected void parseDocument(Document doc)
-	{
-		for (Node n = doc.getFirstChild(); n != null; n = n.getNextSibling())
-		{
-			if ("list".equalsIgnoreCase(n.getNodeName()))
-			{
+	protected void parseDocument(Document doc) {
+		for (Node n = doc.getFirstChild(); n != null; n = n.getNextSibling()) {
+			if ("list".equalsIgnoreCase(n.getNodeName())) {
 				
-				for (Node d = n.getFirstChild(); d != null; d = d.getNextSibling())
-				{
-					if ("item".equalsIgnoreCase(d.getNodeName()))
-					{
-						try
-						{
+				for (Node d = n.getFirstChild(); d != null; d = d.getNextSibling()) {
+					if ("item".equalsIgnoreCase(d.getNodeName())) {
+						try {
 							_currentItem = new Item();
 							parseItem(d);
 							_itemsInFile.add(_currentItem.item);
 							resetTable();
-						}
-						catch (Exception e)
-						{
+						} catch (Exception e) {
 							_log.log(Level.WARNING, "Cannot create item " + _currentItem.id, e);
 						}
 					}
@@ -96,8 +83,7 @@ public final class DocumentItem extends DocumentBase
 		}
 	}
 	
-	protected void parseItem(Node n) throws InvocationTargetException
-	{
+	protected void parseItem(Node n) throws InvocationTargetException {
 		int itemId = Integer.parseInt(n.getAttributes().getNamedItem("id").getNodeValue());
 		String className = n.getAttributes().getNamedItem("type").getNodeValue();
 		String itemName = n.getAttributes().getNamedItem("name").getNodeValue();
@@ -110,45 +96,31 @@ public final class DocumentItem extends DocumentBase
 		_currentItem.set.set("name", itemName);
 		
 		Node first = n.getFirstChild();
-		for (n = first; n != null; n = n.getNextSibling())
-		{
-			if ("table".equalsIgnoreCase(n.getNodeName()))
-			{
-				if (_currentItem.item != null)
-				{
+		for (n = first; n != null; n = n.getNextSibling()) {
+			if ("table".equalsIgnoreCase(n.getNodeName())) {
+				if (_currentItem.item != null) {
 					throw new IllegalStateException("Item created but table node found! Item " + itemId);
 				}
 				parseTable(n);
-			}
-			else if ("set".equalsIgnoreCase(n.getNodeName()))
-			{
-				if (_currentItem.item != null)
-				{
+			} else if ("set".equalsIgnoreCase(n.getNodeName())) {
+				if (_currentItem.item != null) {
 					throw new IllegalStateException("Item created but set node found! Item " + itemId);
 				}
 				parseBeanSet(n, _currentItem.set, 1);
-			}
-			else if ("for".equalsIgnoreCase(n.getNodeName()))
-			{
+			} else if ("for".equalsIgnoreCase(n.getNodeName())) {
 				makeItem();
 				parseTemplate(n, _currentItem.item);
-			}
-			else if ("cond".equalsIgnoreCase(n.getNodeName()))
-			{
+			} else if ("cond".equalsIgnoreCase(n.getNodeName())) {
 				makeItem();
 				Condition condition = parseCondition(n.getFirstChild(), _currentItem.item);
 				Node msg = n.getAttributes().getNamedItem("msg");
 				Node msgId = n.getAttributes().getNamedItem("msgId");
-				if ((condition != null) && (msg != null))
-				{
+				if ((condition != null) && (msg != null)) {
 					condition.setMessage(msg.getNodeValue());
-				}
-				else if ((condition != null) && (msgId != null))
-				{
+				} else if ((condition != null) && (msgId != null)) {
 					condition.setMessageId(Integer.decode(getValue(msgId.getNodeValue(), null)));
 					Node addName = n.getAttributes().getNamedItem("addName");
-					if ((addName != null) && (Integer.decode(getValue(msgId.getNodeValue(), null)) > 0))
-					{
+					if ((addName != null) && (Integer.decode(getValue(msgId.getNodeValue(), null)) > 0)) {
 						condition.addName();
 					}
 				}
@@ -159,25 +131,19 @@ public final class DocumentItem extends DocumentBase
 		makeItem();
 	}
 	
-	private void makeItem() throws InvocationTargetException
-	{
-		if (_currentItem.item != null)
-		{
+	private void makeItem() throws InvocationTargetException {
+		if (_currentItem.item != null) {
 			return; // item is already created
 		}
-		try
-		{
+		try {
 			Constructor<?> c = Class.forName("com.l2jserver.gameserver.model.items.L2" + _currentItem.type).getConstructor(StatsSet.class);
 			_currentItem.item = (L2Item) c.newInstance(_currentItem.set);
-		}
-		catch (Exception e)
-		{
+		} catch (Exception e) {
 			throw new InvocationTargetException(e);
 		}
 	}
 	
-	public List<L2Item> getItemList()
-	{
+	public List<L2Item> getItemList() {
 		return _itemsInFile;
 	}
 }

+ 1 - 2
src/main/java/com/l2jserver/gameserver/engines/items/Item.java

@@ -21,8 +21,7 @@ package com.l2jserver.gameserver.engines.items;
 import com.l2jserver.gameserver.model.StatsSet;
 import com.l2jserver.gameserver.model.items.L2Item;
 
-public class Item
-{
+public class Item {
 	public int id;
 	public String type;
 	public String name;

File diff ditekan karena terlalu besar
+ 304 - 747
src/main/java/com/l2jserver/gameserver/engines/skills/DocumentSkill.java


+ 1 - 2
src/main/java/com/l2jserver/gameserver/enums/AISkillScope.java

@@ -21,8 +21,7 @@ package com.l2jserver.gameserver.enums;
 /**
  * @author Zoey76
  */
-public enum AISkillScope
-{
+public enum AISkillScope {
 	BUFF,
 	DEBUFF,
 	NEGATIVE,

+ 1 - 2
src/main/java/com/l2jserver/gameserver/enums/AIType.java

@@ -21,8 +21,7 @@ package com.l2jserver.gameserver.enums;
 /**
  * @author Zoey76
  */
-public enum AIType
-{
+public enum AIType {
 	FIGHTER,
 	ARCHER,
 	BALANCED,

+ 1 - 2
src/main/java/com/l2jserver/gameserver/enums/AuctionItemType.java

@@ -18,7 +18,6 @@
  */
 package com.l2jserver.gameserver.enums;
 
-public enum AuctionItemType
-{
+public enum AuctionItemType {
 	ClanHall
 }

+ 4 - 8
src/main/java/com/l2jserver/gameserver/enums/CategoryType.java

@@ -22,8 +22,7 @@ package com.l2jserver.gameserver.enums;
  * This class defines all category types.
  * @author xban1x
  */
-public enum CategoryType
-{
+public enum CategoryType {
 	FIGHTER_GROUP,
 	MAGE_GROUP,
 	WIZARD_GROUP,
@@ -154,12 +153,9 @@ public enum CategoryType
 	 * @param categoryName
 	 * @return A {@code CategoryType} if category was found, {@code null} if category was not found
 	 */
-	public static final CategoryType findByName(String categoryName)
-	{
-		for (CategoryType type : values())
-		{
-			if (type.name().equalsIgnoreCase(categoryName))
-			{
+	public static final CategoryType findByName(String categoryName) {
+		for (CategoryType type : values()) {
+			if (type.name().equalsIgnoreCase(categoryName)) {
 				return type;
 			}
 		}

+ 1 - 2
src/main/java/com/l2jserver/gameserver/enums/DispelCategory.java

@@ -21,8 +21,7 @@ package com.l2jserver.gameserver.enums;
 /**
  * @author Zealar
  */
-public enum DispelCategory
-{
+public enum DispelCategory {
 	ALL,
 	BUFF,
 	DEBUFF

+ 1 - 2
src/main/java/com/l2jserver/gameserver/enums/DuelResult.java

@@ -21,8 +21,7 @@ package com.l2jserver.gameserver.enums;
 /**
  * @author Zealar
  */
-public enum DuelResult
-{
+public enum DuelResult {
 	CONTINUE,
 	TEAM_1_WIN,
 	TEAM_2_WIN,

+ 1 - 2
src/main/java/com/l2jserver/gameserver/enums/DuelState.java

@@ -21,8 +21,7 @@ package com.l2jserver.gameserver.enums;
 /**
  * @author Zealar
  */
-public enum DuelState
-{
+public enum DuelState {
 	NO_DUEL,
 	DUELLING,
 	DEAD,

+ 1 - 2
src/main/java/com/l2jserver/gameserver/enums/EffectCalculationType.java

@@ -21,8 +21,7 @@ package com.l2jserver.gameserver.enums;
 /**
  * @author Zealar
  */
-public enum EffectCalculationType
-{
+public enum EffectCalculationType {
 	DIFF,
 	PER
 }

+ 1 - 2
src/main/java/com/l2jserver/gameserver/enums/EventState.java

@@ -21,8 +21,7 @@ package com.l2jserver.gameserver.enums;
 /**
  * @author UnAfraid
  */
-public enum EventState
-{
+public enum EventState {
 	STARTED,
 	FINISHED,
 }

+ 1 - 2
src/main/java/com/l2jserver/gameserver/enums/FortTeleportWhoType.java

@@ -18,8 +18,7 @@
  */
 package com.l2jserver.gameserver.enums;
 
-public enum FortTeleportWhoType
-{
+public enum FortTeleportWhoType {
 	All,
 	Attacker,
 	Owner,

+ 1 - 2
src/main/java/com/l2jserver/gameserver/enums/HtmlActionScope.java

@@ -21,8 +21,7 @@ package com.l2jserver.gameserver.enums;
 /**
  * @author HorridoJoho
  */
-public enum HtmlActionScope
-{
+public enum HtmlActionScope {
 	NPC_HTML,
 	NPC_ITEM_HTML,
 	NPC_QUEST_HTML,

+ 4 - 8
src/main/java/com/l2jserver/gameserver/enums/IllegalActionPunishmentType.java

@@ -22,20 +22,16 @@ package com.l2jserver.gameserver.enums;
  * Illegal Action Punishment Type.
  * @author xban1x
  */
-public enum IllegalActionPunishmentType
-{
+public enum IllegalActionPunishmentType {
 	NONE,
 	BROADCAST,
 	KICK,
 	KICKBAN,
 	JAIL;
 	
-	public static final IllegalActionPunishmentType findByName(String name)
-	{
-		for (IllegalActionPunishmentType type : values())
-		{
-			if (type.name().toLowerCase().equals(name.toLowerCase()))
-			{
+	public static final IllegalActionPunishmentType findByName(String name) {
+		for (IllegalActionPunishmentType type : values()) {
+			if (type.name().toLowerCase().equals(name.toLowerCase())) {
 				return type;
 			}
 		}

+ 1 - 2
src/main/java/com/l2jserver/gameserver/enums/InstanceReenterType.java

@@ -21,8 +21,7 @@ package com.l2jserver.gameserver.enums;
 /**
  * @author FallenAngel
  */
-public enum InstanceReenterType
-{
+public enum InstanceReenterType {
 	NONE,
 	ON_INSTANCE_ENTER,
 	ON_INSTANCE_FINISH,

+ 1 - 2
src/main/java/com/l2jserver/gameserver/enums/InstanceRemoveBuffType.java

@@ -21,8 +21,7 @@ package com.l2jserver.gameserver.enums;
 /**
  * @author St3eT
  */
-public enum InstanceRemoveBuffType
-{
+public enum InstanceRemoveBuffType {
 	NONE,
 	ALL,
 	WHITELIST,

+ 12 - 26
src/main/java/com/l2jserver/gameserver/enums/InstanceType.java

@@ -18,8 +18,7 @@
  */
 package com.l2jserver.gameserver.enums;
 
-public enum InstanceType
-{
+public enum InstanceType {
 	L2Object(null),
 	L2ItemInstance(L2Object),
 	L2Character(L2Object),
@@ -113,55 +112,42 @@ public enum InstanceType
 	private final long _maskL;
 	private final long _maskH;
 	
-	private InstanceType(InstanceType parent)
-	{
+	private InstanceType(InstanceType parent) {
 		_parent = parent;
 		
 		final int high = ordinal() - (Long.SIZE - 1);
-		if (high < 0)
-		{
+		if (high < 0) {
 			_typeL = 1L << ordinal();
 			_typeH = 0;
-		}
-		else
-		{
+		} else {
 			_typeL = 0;
 			_typeH = 1L << high;
 		}
 		
-		if ((_typeL < 0) || (_typeH < 0))
-		{
+		if ((_typeL < 0) || (_typeH < 0)) {
 			throw new Error("Too many instance types, failed to load " + name());
 		}
 		
-		if (parent != null)
-		{
+		if (parent != null) {
 			_maskL = _typeL | parent._maskL;
 			_maskH = _typeH | parent._maskH;
-		}
-		else
-		{
+		} else {
 			_maskL = _typeL;
 			_maskH = _typeH;
 		}
 	}
 	
-	public final InstanceType getParent()
-	{
+	public final InstanceType getParent() {
 		return _parent;
 	}
 	
-	public final boolean isType(InstanceType it)
-	{
+	public final boolean isType(InstanceType it) {
 		return ((_maskL & it._typeL) > 0) || ((_maskH & it._typeH) > 0);
 	}
 	
-	public final boolean isTypes(InstanceType... it)
-	{
-		for (InstanceType i : it)
-		{
-			if (isType(i))
-			{
+	public final boolean isTypes(InstanceType... it) {
+		for (InstanceType i : it) {
+			if (isType(i)) {
 				return true;
 			}
 		}

+ 1 - 2
src/main/java/com/l2jserver/gameserver/enums/ItemLocation.java

@@ -18,8 +18,7 @@
  */
 package com.l2jserver.gameserver.enums;
 
-public enum ItemLocation
-{
+public enum ItemLocation {
 	VOID,
 	INVENTORY,
 	PAPERDOLL,

+ 1 - 2
src/main/java/com/l2jserver/gameserver/enums/MacroType.java

@@ -22,8 +22,7 @@ package com.l2jserver.gameserver.enums;
  * Macro type enumerated.
  * @author Zoey76
  */
-public enum MacroType
-{
+public enum MacroType {
 	NONE,
 	SKILL,
 	ACTION,

+ 1 - 2
src/main/java/com/l2jserver/gameserver/enums/ManorMode.java

@@ -21,8 +21,7 @@ package com.l2jserver.gameserver.enums;
 /**
  * @author malyelfik
  */
-public enum ManorMode
-{
+public enum ManorMode {
 	DISABLED,
 	MODIFIABLE,
 	MAINTENANCE,

+ 5 - 12
src/main/java/com/l2jserver/gameserver/enums/MountType.java

@@ -23,25 +23,18 @@ import com.l2jserver.gameserver.data.xml.impl.CategoryData;
 /**
  * @author UnAfraid
  */
-public enum MountType
-{
+public enum MountType {
 	NONE,
 	STRIDER,
 	WYVERN,
 	WOLF;
 	
-	public static MountType findByNpcId(int npcId)
-	{
-		if (CategoryData.getInstance().isInCategory(CategoryType.STRIDER, npcId))
-		{
+	public static MountType findByNpcId(int npcId) {
+		if (CategoryData.getInstance().isInCategory(CategoryType.STRIDER, npcId)) {
 			return STRIDER;
-		}
-		else if (CategoryData.getInstance().isInCategory(CategoryType.WYVERN_GROUP, npcId))
-		{
+		} else if (CategoryData.getInstance().isInCategory(CategoryType.WYVERN_GROUP, npcId)) {
 			return WYVERN;
-		}
-		else if (CategoryData.getInstance().isInCategory(CategoryType.WOLF_GROUP, npcId))
-		{
+		} else if (CategoryData.getInstance().isInCategory(CategoryType.WOLF_GROUP, npcId)) {
 			return WOLF;
 		}
 		return NONE;

+ 7 - 14
src/main/java/com/l2jserver/gameserver/enums/PartyDistributionType.java

@@ -21,8 +21,7 @@ package com.l2jserver.gameserver.enums;
 /**
  * @author NosBit
  */
-public enum PartyDistributionType
-{
+public enum PartyDistributionType {
 	FINDERS_KEEPERS(0, 487),
 	RANDOM(1, 488),
 	RANDOM_INCLUDING_SPOIL(2, 798),
@@ -37,8 +36,7 @@ public enum PartyDistributionType
 	 * @param id the id used by packets.
 	 * @param sysStringId the sysstring id
 	 */
-	private PartyDistributionType(int id, int sysStringId)
-	{
+	private PartyDistributionType(int id, int sysStringId) {
 		_id = id;
 		_sysStringId = sysStringId;
 	}
@@ -47,8 +45,7 @@ public enum PartyDistributionType
 	 * Gets the id used by packets.
 	 * @return the id
 	 */
-	public int getId()
-	{
+	public int getId() {
 		return _id;
 	}
 	
@@ -56,8 +53,7 @@ public enum PartyDistributionType
 	 * Gets the sysstring id used by system messages.
 	 * @return the sysstring-e id
 	 */
-	public int getSysStringId()
-	{
+	public int getSysStringId() {
 		return _sysStringId;
 	}
 	
@@ -66,12 +62,9 @@ public enum PartyDistributionType
 	 * @param id the id
 	 * @return the {@code PartyDistributionType} if its found, {@code null} otherwise.
 	 */
-	public static PartyDistributionType findById(int id)
-	{
-		for (PartyDistributionType partyDistributionType : values())
-		{
-			if (partyDistributionType.getId() == id)
-			{
+	public static PartyDistributionType findById(int id) {
+		for (PartyDistributionType partyDistributionType : values()) {
+			if (partyDistributionType.getId() == id) {
 				return partyDistributionType;
 			}
 		}

+ 1 - 2
src/main/java/com/l2jserver/gameserver/enums/PetitionState.java

@@ -22,8 +22,7 @@ package com.l2jserver.gameserver.enums;
  * Enum with petition states.
  * @author xban1x
  */
-public enum PetitionState
-{
+public enum PetitionState {
 	PENDING,
 	RESPONDER_CANCEL,
 	RESPONDER_MISSING,

+ 1 - 2
src/main/java/com/l2jserver/gameserver/enums/PetitionType.java

@@ -22,8 +22,7 @@ package com.l2jserver.gameserver.enums;
  * Enum with petition types.
  * @author xban1x
  */
-public enum PetitionType
-{
+public enum PetitionType {
 	IMMOBILITY,
 	RECOVERY_RELATED,
 	BUG_REPORT,

+ 3 - 6
src/main/java/com/l2jserver/gameserver/enums/PlayerAction.java

@@ -21,20 +21,17 @@ package com.l2jserver.gameserver.enums;
 /**
  * @author UnAfraid
  */
-public enum PlayerAction
-{
+public enum PlayerAction {
 	ADMIN_COMMAND,
 	USER_ENGAGE;
 	
 	private final int _mask;
 	
-	private PlayerAction()
-	{
+	private PlayerAction() {
 		_mask = (1 << ordinal());
 	}
 	
-	public int getMask()
-	{
+	public int getMask() {
 		return _mask;
 	}
 }

+ 6 - 12
src/main/java/com/l2jserver/gameserver/enums/PrivateStoreType.java

@@ -21,8 +21,7 @@ package com.l2jserver.gameserver.enums;
 /**
  * @author NosBit
  */
-public enum PrivateStoreType
-{
+public enum PrivateStoreType {
 	NONE(0),
 	SELL(1),
 	SELL_MANAGE(2),
@@ -33,22 +32,17 @@ public enum PrivateStoreType
 	
 	private int _id;
 	
-	private PrivateStoreType(int id)
-	{
+	private PrivateStoreType(int id) {
 		_id = id;
 	}
 	
-	public int getId()
-	{
+	public int getId() {
 		return _id;
 	}
 	
-	public static PrivateStoreType findById(int id)
-	{
-		for (PrivateStoreType privateStoreType : values())
-		{
-			if (privateStoreType.getId() == id)
-			{
+	public static PrivateStoreType findById(int id) {
+		for (PrivateStoreType privateStoreType : values()) {
+			if (privateStoreType.getId() == id) {
 				return privateStoreType;
 			}
 		}

+ 1 - 2
src/main/java/com/l2jserver/gameserver/enums/QuestType.java

@@ -21,8 +21,7 @@ package com.l2jserver.gameserver.enums;
 /**
  * @author Luis Arias
  */
-public enum QuestType
-{
+public enum QuestType {
 	REPEATABLE,
 	ONE_TIME,
 	DAILY

+ 1 - 2
src/main/java/com/l2jserver/gameserver/enums/Race.java

@@ -22,8 +22,7 @@ package com.l2jserver.gameserver.enums;
  * Creature races enumerated.
  * @author Zealar
  */
-public enum Race
-{
+public enum Race {
 	HUMAN,
 	ELF,
 	DARK_ELF,

+ 1 - 2
src/main/java/com/l2jserver/gameserver/enums/Sex.java

@@ -18,8 +18,7 @@
  */
 package com.l2jserver.gameserver.enums;
 
-public enum Sex
-{
+public enum Sex {
 	MALE,
 	FEMALE,
 	ETC;

+ 1 - 2
src/main/java/com/l2jserver/gameserver/enums/ShortcutType.java

@@ -22,8 +22,7 @@ package com.l2jserver.gameserver.enums;
  * Shortcut type enumerated.
  * @author Zoey76
  */
-public enum ShortcutType
-{
+public enum ShortcutType {
 	NONE,
 	ITEM,
 	SKILL,

+ 3 - 6
src/main/java/com/l2jserver/gameserver/enums/ShotType.java

@@ -21,8 +21,7 @@ package com.l2jserver.gameserver.enums;
 /**
  * @author UnAfraid
  */
-public enum ShotType
-{
+public enum ShotType {
 	SOULSHOTS,
 	SPIRITSHOTS,
 	BLESSED_SPIRITSHOTS,
@@ -30,13 +29,11 @@ public enum ShotType
 	
 	private final int _mask;
 	
-	private ShotType()
-	{
+	private ShotType() {
 		_mask = (1 << ordinal());
 	}
 	
-	public int getMask()
-	{
+	public int getMask() {
 		return _mask;
 	}
 }

+ 1 - 2
src/main/java/com/l2jserver/gameserver/enums/SiegeTeleportWhoType.java

@@ -18,8 +18,7 @@
  */
 package com.l2jserver.gameserver.enums;
 
-public enum SiegeTeleportWhoType
-{
+public enum SiegeTeleportWhoType {
 	Attacker,
 	Owner,
 	NotOwner,

+ 1 - 2
src/main/java/com/l2jserver/gameserver/enums/StartPosType.java

@@ -21,8 +21,7 @@ package com.l2jserver.gameserver.enums;
 /**
  * @author Zealar
  */
-public enum StartPosType
-{
+public enum StartPosType {
 	FIXED,
 	RANDOM
 }

+ 4 - 8
src/main/java/com/l2jserver/gameserver/enums/StatFunction.java

@@ -21,8 +21,7 @@ package com.l2jserver.gameserver.enums;
 /**
  * @author Zealar
  */
-public enum StatFunction
-{
+public enum StatFunction {
 	ADD("Add", 30),
 	DIV("Div", 20),
 	ENCHANT("Enchant", 0),
@@ -35,19 +34,16 @@ public enum StatFunction
 	private String _name;
 	private int _order;
 	
-	StatFunction(String name, int order)
-	{
+	StatFunction(String name, int order) {
 		_name = name;
 		_order = order;
 	}
 	
-	public String getName()
-	{
+	public String getName() {
 		return _name;
 	}
 	
-	public int getOrder()
-	{
+	public int getOrder() {
 		return _order;
 	}
 }

+ 1 - 2
src/main/java/com/l2jserver/gameserver/enums/StatType.java

@@ -18,8 +18,7 @@
  */
 package com.l2jserver.gameserver.enums;
 
-public enum StatType
-{
+public enum StatType {
 	
 	HP,
 	MP,

+ 3 - 6
src/main/java/com/l2jserver/gameserver/enums/Team.java

@@ -21,21 +21,18 @@ package com.l2jserver.gameserver.enums;
 /**
  * @author NosBit
  */
-public enum Team
-{
+public enum Team {
 	NONE(0),
 	BLUE(1),
 	RED(2);
 	
 	private int _id;
 	
-	private Team(int id)
-	{
+	private Team(int id) {
 		_id = id;
 	}
 	
-	public int getId()
-	{
+	public int getId() {
 		return _id;
 	}
 }

+ 1 - 2
src/main/java/com/l2jserver/gameserver/enums/TrapAction.java

@@ -18,8 +18,7 @@
  */
 package com.l2jserver.gameserver.enums;
 
-public enum TrapAction
-{
+public enum TrapAction {
 	TRAP_TRIGGERED,
 	TRAP_DETECTED,
 	TRAP_DISARMED

Beberapa file tidak ditampilkan karena terlalu banyak file yang berubah dalam diff ini