Browse Source

BETA: Avoiding boxing/unboxing of int and boolean.
Continuing with [4451].

'''Note:''' valueOf(..) returns an object, this is useful when using List/Map (not Trove ones), if it's only required an int (or boolean) use parseInt(..) (or parseBoolean(..)).

Zoey76 13 years ago
parent
commit
d184eacd48

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

@@ -1559,7 +1559,7 @@ public final class Config
 							{
 								try
 								{
-									SKILL_REUSE_LIST.put(Integer.valueOf(skillSplit[0]), Integer.valueOf(skillSplit[1]));
+									SKILL_REUSE_LIST.put(Integer.parseInt(skillSplit[0]), Integer.parseInt(skillSplit[1]));
 								}
 								catch (NumberFormatException nfe)
 								{
@@ -2028,9 +2028,9 @@ public final class Config
 					ALT_LOTTERY_4_NUMBER_RATE = Float.parseFloat(General.getProperty("AltLottery4NumberRate","0.2"));
 					ALT_LOTTERY_3_NUMBER_RATE = Float.parseFloat(General.getProperty("AltLottery3NumberRate","0.2"));
 					ALT_LOTTERY_2_AND_1_NUMBER_PRIZE = Long.parseLong(General.getProperty("AltLottery2and1NumberPrize","200"));
-					ALT_ITEM_AUCTION_ENABLED = Boolean.valueOf(General.getProperty("AltItemAuctionEnabled", "True"));
-					ALT_ITEM_AUCTION_EXPIRED_AFTER = Integer.valueOf(General.getProperty("AltItemAuctionExpiredAfter", "14"));
-					ALT_ITEM_AUCTION_TIME_EXTENDS_ON_BID = 1000 * (long)Integer.valueOf(General.getProperty("AltItemAuctionTimeExtendsOnBid", "0"));
+					ALT_ITEM_AUCTION_ENABLED = Boolean.parseBoolean(General.getProperty("AltItemAuctionEnabled", "True"));
+					ALT_ITEM_AUCTION_EXPIRED_AFTER = Integer.parseInt(General.getProperty("AltItemAuctionExpiredAfter", "14"));
+					ALT_ITEM_AUCTION_TIME_EXTENDS_ON_BID = 1000 * (long)Integer.parseInt(General.getProperty("AltItemAuctionTimeExtendsOnBid", "0"));
 					FS_TIME_ATTACK = Integer.parseInt(General.getProperty("TimeOfAttack", "50"));
 					FS_TIME_COOLDOWN = Integer.parseInt(General.getProperty("TimeOfCoolDown", "5"));
 					FS_TIME_ENTRY = Integer.parseInt(General.getProperty("TimeOfEntry", "3"));
@@ -2064,23 +2064,23 @@ public final class Config
 					JAIL_IS_PVP = Boolean.parseBoolean(General.getProperty("JailIsPvp", "False"));
 					JAIL_DISABLE_CHAT = Boolean.parseBoolean(General.getProperty("JailDisableChat", "True"));
 					JAIL_DISABLE_TRANSACTION = Boolean.parseBoolean(General.getProperty("JailDisableTransaction", "False"));
-					CUSTOM_SPAWNLIST_TABLE = Boolean.valueOf(General.getProperty("CustomSpawnlistTable", "false"));
-					SAVE_GMSPAWN_ON_CUSTOM = Boolean.valueOf(General.getProperty("SaveGmSpawnOnCustom", "false"));
-					CUSTOM_NPC_TABLE = Boolean.valueOf(General.getProperty("CustomNpcTable", "false"));
-					CUSTOM_NPC_SKILLS_TABLE = Boolean.valueOf(General.getProperty("CustomNpcSkillsTable", "false"));
-					CUSTOM_ARMORSETS_TABLE = Boolean.valueOf(General.getProperty("CustomArmorSetsTable", "false"));
-					CUSTOM_TELEPORT_TABLE = Boolean.valueOf(General.getProperty("CustomTeleportTable", "false"));
-					CUSTOM_DROPLIST_TABLE = Boolean.valueOf(General.getProperty("CustomDroplistTable", "false"));
-					CUSTOM_MERCHANT_TABLES = Boolean.valueOf(General.getProperty("CustomMerchantTables", "false"));
-					CUSTOM_NPCBUFFER_TABLES = Boolean.valueOf(General.getProperty("CustomNpcBufferTables", "false"));
-					CUSTOM_SKILLS_LOAD = Boolean.valueOf(General.getProperty("CustomSkillsLoad", "false"));
-					CUSTOM_ITEMS_LOAD = Boolean.valueOf(General.getProperty("CustomItemsLoad", "false"));
-					CUSTOM_MULTISELL_LOAD = Boolean.valueOf(General.getProperty("CustomMultisellLoad", "false"));
+					CUSTOM_SPAWNLIST_TABLE = Boolean.parseBoolean(General.getProperty("CustomSpawnlistTable", "false"));
+					SAVE_GMSPAWN_ON_CUSTOM = Boolean.parseBoolean(General.getProperty("SaveGmSpawnOnCustom", "false"));
+					CUSTOM_NPC_TABLE = Boolean.parseBoolean(General.getProperty("CustomNpcTable", "false"));
+					CUSTOM_NPC_SKILLS_TABLE = Boolean.parseBoolean(General.getProperty("CustomNpcSkillsTable", "false"));
+					CUSTOM_ARMORSETS_TABLE = Boolean.parseBoolean(General.getProperty("CustomArmorSetsTable", "false"));
+					CUSTOM_TELEPORT_TABLE = Boolean.parseBoolean(General.getProperty("CustomTeleportTable", "false"));
+					CUSTOM_DROPLIST_TABLE = Boolean.parseBoolean(General.getProperty("CustomDroplistTable", "false"));
+					CUSTOM_MERCHANT_TABLES = Boolean.parseBoolean(General.getProperty("CustomMerchantTables", "false"));
+					CUSTOM_NPCBUFFER_TABLES = Boolean.parseBoolean(General.getProperty("CustomNpcBufferTables", "false"));
+					CUSTOM_SKILLS_LOAD = Boolean.parseBoolean(General.getProperty("CustomSkillsLoad", "false"));
+					CUSTOM_ITEMS_LOAD = Boolean.parseBoolean(General.getProperty("CustomItemsLoad", "false"));
+					CUSTOM_MULTISELL_LOAD = Boolean.parseBoolean(General.getProperty("CustomMultisellLoad", "false"));
 					ALT_BIRTHDAY_GIFT = Integer.parseInt(General.getProperty("AltBirthdayGift", "22187"));
 					ALT_BIRTHDAY_MAIL_SUBJECT = General.getProperty("AltBirthdayMailSubject", "Happy Birthday!");
 					ALT_BIRTHDAY_MAIL_TEXT = General.getProperty("AltBirthdayMailText", "Hello Adventurer!! Seeing as you're one year older now, I thought I would send you some birthday cheer :) Please find your birthday pack attached. May these gifts bring you joy and happiness on this very special day.\n\nSincerely, Alegria");
-					ENABLE_BLOCK_CHECKER_EVENT = Boolean.valueOf(General.getProperty("EnableBlockCheckerEvent", "false"));
-					MIN_BLOCK_CHECKER_TEAM_MEMBERS = Integer.valueOf(General.getProperty("BlockCheckerMinTeamMembers", "2"));
+					ENABLE_BLOCK_CHECKER_EVENT = Boolean.parseBoolean(General.getProperty("EnableBlockCheckerEvent", "false"));
+					MIN_BLOCK_CHECKER_TEAM_MEMBERS = Integer.parseInt(General.getProperty("BlockCheckerMinTeamMembers", "2"));
 					if(MIN_BLOCK_CHECKER_TEAM_MEMBERS < 1)
 						MIN_BLOCK_CHECKER_TEAM_MEMBERS = 1;
 					else if(MIN_BLOCK_CHECKER_TEAM_MEMBERS > 6)
@@ -2166,7 +2166,7 @@ public final class Config
 						
 						try
 						{
-							MINIONS_RESPAWN_TIME.put(Integer.valueOf(propSplit[0]), Integer.valueOf(propSplit[1]));
+							MINIONS_RESPAWN_TIME.put(Integer.parseInt(propSplit[0]), Integer.parseInt(propSplit[1]));
 						}
 						catch (NumberFormatException nfe)
 						{
@@ -2377,8 +2377,8 @@ public final class Config
 					L2JMOD_WEDDING_FORMALWEAR = Boolean.parseBoolean(L2JModSettings.getProperty("WeddingFormalWear", "True"));
 					L2JMOD_WEDDING_DIVORCE_COSTS = Integer.parseInt(L2JModSettings.getProperty("WeddingDivorceCosts", "20"));
 					
-					L2JMOD_ENABLE_WAREHOUSESORTING_CLAN = Boolean.valueOf(L2JModSettings.getProperty("EnableWarehouseSortingClan", "False"));
-					L2JMOD_ENABLE_WAREHOUSESORTING_PRIVATE = Boolean.valueOf(L2JModSettings.getProperty("EnableWarehouseSortingPrivate", "False"));
+					L2JMOD_ENABLE_WAREHOUSESORTING_CLAN = Boolean.parseBoolean(L2JModSettings.getProperty("EnableWarehouseSortingClan", "False"));
+					L2JMOD_ENABLE_WAREHOUSESORTING_PRIVATE = Boolean.parseBoolean(L2JModSettings.getProperty("EnableWarehouseSortingPrivate", "False"));
 					
 					if (TVT_EVENT_PARTICIPATION_NPC_ID == 0)
 					{

+ 3 - 3
L2J_Server_BETA/java/com/l2jserver/gameserver/cache/CrestCache.java

@@ -102,7 +102,7 @@ public class CrestCache
 					
 					if (file.getName().startsWith("Crest_Large_"))
 					{
-						crestId = Integer.valueOf(file.getName().substring(12, file.getName().length() - 4));
+						crestId = Integer.parseInt(file.getName().substring(12, file.getName().length() - 4));
 						if(Config.CLEAR_CREST_CACHE)
 						{
 							for(final L2Clan clan : clans)
@@ -121,7 +121,7 @@ public class CrestCache
 					}
 					else if (file.getName().startsWith("Crest_"))
 					{
-						crestId = Integer.valueOf(file.getName().substring(6, file.getName().length() - 4));
+						crestId = Integer.parseInt(file.getName().substring(6, file.getName().length() - 4));
 						if(Config.CLEAR_CREST_CACHE)
 						{
 							for(final L2Clan clan : clans)
@@ -140,7 +140,7 @@ public class CrestCache
 					}
 					else if (file.getName().startsWith("AllyCrest_"))
 					{
-						crestId = Integer.valueOf(file.getName().substring(10, file.getName().length() - 4));
+						crestId = Integer.parseInt(file.getName().substring(10, file.getName().length() - 4));
 						if(Config.CLEAR_CREST_CACHE)
 						{
 							for(final L2Clan clan : clans)

+ 22 - 22
L2J_Server_BETA/java/com/l2jserver/gameserver/engines/DocumentBase.java

@@ -501,52 +501,52 @@ public abstract class DocumentBase
 			}
 			else if ("resting".equalsIgnoreCase(a.getNodeName()))
 			{
-				boolean val = Boolean.valueOf(a.getNodeValue());
+				boolean val = Boolean.parseBoolean(a.getNodeValue());
 				cond = joinAnd(cond, new ConditionPlayerState(PlayerState.RESTING, val));
 			}
 			else if ("flying".equalsIgnoreCase(a.getNodeName()))
 			{
-				boolean val = Boolean.valueOf(a.getNodeValue());
+				boolean val = Boolean.parseBoolean(a.getNodeValue());
 				cond = joinAnd(cond, new ConditionPlayerState(PlayerState.FLYING, val));
 			}
 			else if ("moving".equalsIgnoreCase(a.getNodeName()))
 			{
-				boolean val = Boolean.valueOf(a.getNodeValue());
+				boolean val = Boolean.parseBoolean(a.getNodeValue());
 				cond = joinAnd(cond, new ConditionPlayerState(PlayerState.MOVING, val));
 			}
 			else if ("running".equalsIgnoreCase(a.getNodeName()))
 			{
-				boolean val = Boolean.valueOf(a.getNodeValue());
+				boolean val = Boolean.parseBoolean(a.getNodeValue());
 				cond = joinAnd(cond, new ConditionPlayerState(PlayerState.RUNNING, val));
 			}
 			else if ("standing".equalsIgnoreCase(a.getNodeName()))
 			{
-				boolean val = Boolean.valueOf(a.getNodeValue());
+				boolean val = Boolean.parseBoolean(a.getNodeValue());
 				cond = joinAnd(cond, new ConditionPlayerState(PlayerState.STANDING, val));
 			}
 			else if ("behind".equalsIgnoreCase(a.getNodeName()))
 			{
-				boolean val = Boolean.valueOf(a.getNodeValue());
+				boolean val = Boolean.parseBoolean(a.getNodeValue());
 				cond = joinAnd(cond, new ConditionPlayerState(PlayerState.BEHIND, val));
 			}
 			else if ("front".equalsIgnoreCase(a.getNodeName()))
 			{
-				boolean val = Boolean.valueOf(a.getNodeValue());
+				boolean val = Boolean.parseBoolean(a.getNodeValue());
 				cond = joinAnd(cond, new ConditionPlayerState(PlayerState.FRONT, val));
 			}
 			else if ("chaotic".equalsIgnoreCase(a.getNodeName()))
 			{
-				boolean val = Boolean.valueOf(a.getNodeValue());
+				boolean val = Boolean.parseBoolean(a.getNodeValue());
 				cond = joinAnd(cond, new ConditionPlayerState(PlayerState.CHAOTIC, val));
 			}
 			else if ("olympiad".equalsIgnoreCase(a.getNodeName()))
 			{
-				boolean val = Boolean.valueOf(a.getNodeValue());
+				boolean val = Boolean.parseBoolean(a.getNodeValue());
 				cond = joinAnd(cond, new ConditionPlayerState(PlayerState.OLYMPIAD, val));
 			}
 			else if ("ishero".equalsIgnoreCase(a.getNodeName()))
 			{
-				boolean val = Boolean.valueOf(a.getNodeValue());
+				boolean val = Boolean.parseBoolean(a.getNodeValue());
 				cond = joinAnd(cond, new ConditionPlayerIsHero(val));
 			}
 			else if ("transformationId".equalsIgnoreCase(a.getNodeName()))
@@ -619,12 +619,12 @@ public abstract class DocumentBase
 			}
 			else if ("isClanLeader".equalsIgnoreCase(a.getNodeName()))
 			{
-				boolean val = Boolean.valueOf(a.getNodeValue());
+				boolean val = Boolean.parseBoolean(a.getNodeValue());
 				cond = joinAnd(cond, new ConditionPlayerIsClanLeader(val));
 			}
 			else if ("onTvTEvent".equalsIgnoreCase(a.getNodeName()))
 			{
-				boolean val = Boolean.valueOf(a.getNodeValue());
+				boolean val = Boolean.parseBoolean(a.getNodeValue());
 				cond = joinAnd(cond, new ConditionPlayerTvTEvent(val));
 			}
 			else if ("pledgeClass".equalsIgnoreCase(a.getNodeName()))
@@ -660,17 +660,17 @@ public abstract class DocumentBase
 			}
 			else if ("flyMounted".equalsIgnoreCase(a.getNodeName()))
 			{
-				boolean val = Boolean.valueOf(a.getNodeValue());
+				boolean val = Boolean.parseBoolean(a.getNodeValue());
 				cond = joinAnd(cond, new ConditionPlayerFlyMounted(val));
 			}
 			else if ("vehicleMounted".equalsIgnoreCase(a.getNodeName()))
 			{
-				boolean val = Boolean.valueOf(a.getNodeValue());
+				boolean val = Boolean.parseBoolean(a.getNodeValue());
 				cond = joinAnd(cond, new ConditionPlayerVehicleMounted(val));
 			}
 			else if ("landingZone".equalsIgnoreCase(a.getNodeName()))
 			{
-				boolean val = Boolean.valueOf(a.getNodeValue());
+				boolean val = Boolean.parseBoolean(a.getNodeValue());
 				cond = joinAnd(cond, new ConditionPlayerLandingZone(val));
 			}
 			else if ("active_effect_id".equalsIgnoreCase(a.getNodeName()))
@@ -710,7 +710,7 @@ public abstract class DocumentBase
 			}
 			else if ("subclass".equalsIgnoreCase(a.getNodeName()))
 			{
-				boolean val = Boolean.valueOf(a.getNodeValue());
+				boolean val = Boolean.parseBoolean(a.getNodeValue());
 				cond = joinAnd(cond, new ConditionPlayerSubclass(val));
 			}
 			else if ("instanceId".equalsIgnoreCase(a.getNodeName()))
@@ -731,7 +731,7 @@ public abstract class DocumentBase
 			}
 			else if ("cloakStatus".equalsIgnoreCase(a.getNodeName()))
 			{
-				int val = Integer.valueOf(a.getNodeValue());
+				int val = Integer.parseInt(a.getNodeValue());
 				cond = joinAnd(cond, new ConditionPlayerCloakStatus(val));
 			}
 			else if ("hasPet".equalsIgnoreCase(a.getNodeName()))
@@ -770,7 +770,7 @@ public abstract class DocumentBase
 			}
 			else if ("canSweep".equalsIgnoreCase(a.getNodeName()))
 			{
-				cond = joinAnd(cond, new ConditionPlayerCanSweep(Boolean.valueOf(a.getNodeValue())));
+				cond = joinAnd(cond, new ConditionPlayerCanSweep(Boolean.parseBoolean(a.getNodeValue())));
 			}
 			else if ("insideZoneId".equalsIgnoreCase(a.getNodeName()))
 			{
@@ -801,7 +801,7 @@ public abstract class DocumentBase
 			Node a = attrs.item(i);
 			if ("aggro".equalsIgnoreCase(a.getNodeName()))
 			{
-				boolean val = Boolean.valueOf(a.getNodeValue());
+				boolean val = Boolean.parseBoolean(a.getNodeValue());
 				cond = joinAnd(cond, new ConditionTargetAggro(val));
 			}
 			else if ("siegezone".equalsIgnoreCase(a.getNodeName()))
@@ -998,7 +998,7 @@ public abstract class DocumentBase
 			}
 			else if ("weaponChange".equalsIgnoreCase(a.getNodeName()))
 			{
-				boolean val = Boolean.valueOf(a.getNodeValue());
+				boolean val = Boolean.parseBoolean(a.getNodeValue());
 				cond = joinAnd(cond, new ConditionChangeWeapon(val));
 			}
 		}
@@ -1015,12 +1015,12 @@ public abstract class DocumentBase
 			Node a = attrs.item(i);
 			if ("skill".equalsIgnoreCase(a.getNodeName()))
 			{
-				boolean val = Boolean.valueOf(a.getNodeValue());
+				boolean val = Boolean.parseBoolean(a.getNodeValue());
 				cond = joinAnd(cond, new ConditionWithSkill(val));
 			}
 			if ("night".equalsIgnoreCase(a.getNodeName()))
 			{
-				boolean val = Boolean.valueOf(a.getNodeValue());
+				boolean val = Boolean.parseBoolean(a.getNodeValue());
 				cond = joinAnd(cond, new ConditionGameTime(CheckGameTime.NIGHT, val));
 			}
 			if ("chance".equalsIgnoreCase(a.getNodeName()))

+ 1 - 1
L2J_Server_BETA/java/com/l2jserver/gameserver/model/actor/instance/L2VillageMasterInstance.java

@@ -126,7 +126,7 @@ public class L2VillageMasterInstance extends L2NpcInstance
 			if (cmdParams.isEmpty() || cmdParams2.isEmpty())
 				return;
 			
-			renameSubPledge(player, Integer.valueOf(cmdParams), cmdParams2);
+			renameSubPledge(player, Integer.parseInt(cmdParams), cmdParams2);
 		}
 		else if (actualCommand.equalsIgnoreCase("create_royal"))
 		{

+ 4 - 4
L2J_Server_BETA/java/com/l2jserver/gameserver/model/zone/type/L2MotherTreeZone.java

@@ -42,19 +42,19 @@ public class L2MotherTreeZone extends L2ZoneType
 	{
 		if (name.equals("enterMsgId"))
 		{
-			_enterMsg = Integer.valueOf(value);
+			_enterMsg = Integer.parseInt(value);
 		}
 		else if (name.equals("leaveMsgId"))
 		{
-			_leaveMsg = Integer.valueOf(value);
+			_leaveMsg = Integer.parseInt(value);
 		}
 		else if (name.equals("MpRegenBonus"))
 		{
-			_mpRegen = Integer.valueOf(value);
+			_mpRegen = Integer.parseInt(value);
 		}
 		else if (name.equals("HpRegenBonus"))
 		{
-			_hpRegen = Integer.valueOf(value);
+			_hpRegen = Integer.parseInt(value);
 		}
 		else
 			super.setParameter(name, value);