Browse Source

BETA: Minor code cleanup and refactoring.

Zoey76 12 years ago
parent
commit
5c42530b14

+ 8 - 8
L2J_Server_BETA/java/com/l2jserver/gameserver/model/items/L2Item.java

@@ -159,7 +159,7 @@ public abstract class L2Item
 	public static final int CRYSTAL_S80 = 0x06; // ??
 	public static final int CRYSTAL_S84 = 0x07; // ??
 	
-	private static final int[] crystalItemId =
+	private static final int[] CRYSTAL_ITEM_ID =
 	{
 		0,
 		1458,
@@ -170,7 +170,7 @@ public abstract class L2Item
 		1462,
 		1462
 	};
-	private static final int[] crystalEnchantBonusArmor =
+	private static final int[] CRYSTAL_ENCHANT_BONUS_ARMOR =
 	{
 		0,
 		11,
@@ -181,7 +181,7 @@ public abstract class L2Item
 		25,
 		25
 	};
-	private static final int[] crystalEnchantBonusWeapon =
+	private static final int[] CRYSTAL_ENCHANT_BONUS_WEAPON =
 	{
 		0,
 		90,
@@ -513,7 +513,7 @@ public abstract class L2Item
 	 */
 	public final int getCrystalItemId()
 	{
-		return crystalItemId[_crystalType];
+		return CRYSTAL_ITEM_ID[_crystalType];
 	}
 	
 	/**
@@ -564,9 +564,9 @@ public abstract class L2Item
 			{
 				case TYPE2_SHIELD_ARMOR:
 				case TYPE2_ACCESSORY:
-					return _crystalCount + (crystalEnchantBonusArmor[getCrystalType()] * ((3 * enchantLevel) - 6));
+					return _crystalCount + (CRYSTAL_ENCHANT_BONUS_ARMOR[getCrystalType()] * ((3 * enchantLevel) - 6));
 				case TYPE2_WEAPON:
-					return _crystalCount + (crystalEnchantBonusWeapon[getCrystalType()] * ((2 * enchantLevel) - 3));
+					return _crystalCount + (CRYSTAL_ENCHANT_BONUS_WEAPON[getCrystalType()] * ((2 * enchantLevel) - 3));
 				default:
 					return _crystalCount;
 			}
@@ -577,9 +577,9 @@ public abstract class L2Item
 			{
 				case TYPE2_SHIELD_ARMOR:
 				case TYPE2_ACCESSORY:
-					return _crystalCount + (crystalEnchantBonusArmor[getCrystalType()] * enchantLevel);
+					return _crystalCount + (CRYSTAL_ENCHANT_BONUS_ARMOR[getCrystalType()] * enchantLevel);
 				case TYPE2_WEAPON:
-					return _crystalCount + (crystalEnchantBonusWeapon[getCrystalType()] * enchantLevel);
+					return _crystalCount + (CRYSTAL_ENCHANT_BONUS_WEAPON[getCrystalType()] * enchantLevel);
 				default:
 					return _crystalCount;
 			}

+ 1 - 1
L2J_Server_BETA/java/com/l2jserver/gameserver/network/clientpackets/RequestActionUse.java

@@ -113,7 +113,7 @@ public final class RequestActionUse extends L2GameClientPacket
 		// Don't allow to do some action if player is transformed
 		if (activeChar.isTransformed())
 		{
-			int[] allowedActions = activeChar.isTransformed() ? ExBasicActionList._actionsOnTransform : ExBasicActionList._defaultActionList;
+			int[] allowedActions = activeChar.isTransformed() ? ExBasicActionList.ACTIONS_ON_TRANSFORM : ExBasicActionList.DEFAULT_ACTION_LIST;
 			if (!(Arrays.binarySearch(allowedActions, _actionId) >= 0))
 			{
 				sendPacket(ActionFailed.STATIC_PACKET);

+ 8 - 8
L2J_Server_BETA/java/com/l2jserver/gameserver/network/serverpackets/ExBasicActionList.java

@@ -26,7 +26,7 @@ import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
 public final class ExBasicActionList extends L2GameServerPacket
 {
 	//@formatter:off
-	public static final int[] _actionsOnTransform =
+	public static final int[] ACTIONS_ON_TRANSFORM =
 	{
 		1, 2, 3, 4,
 		5, 6, 7, 8,
@@ -64,34 +64,34 @@ public final class ExBasicActionList extends L2GameServerPacket
 		1096, 1097, 1098 
 	};
 	//@formatter:on
-	public static final int[] _defaultActionList;
+	public static final int[] DEFAULT_ACTION_LIST;
 	
 	static
 	{
 		int count1 = 74; // 0 <-> (count1 - 1)
 		int count2 = 99; // 1000 <-> (1000 + count2 - 1)
 		int count3 = 16; // 5000 <-> (5000 + count3 - 1)
-		_defaultActionList = new int[count1 + count2 + count3];
+		DEFAULT_ACTION_LIST = new int[count1 + count2 + count3];
 		int i;
 		
 		for (i = count1; i-- > 0;)
 		{
-			_defaultActionList[i] = i;
+			DEFAULT_ACTION_LIST[i] = i;
 		}
 		
 		for (i = count2; i-- > 0;)
 		{
-			_defaultActionList[count1 + i] = 1000 + i;
+			DEFAULT_ACTION_LIST[count1 + i] = 1000 + i;
 		}
 		
 		for (i = count3; i-- > 0;)
 		{
-			_defaultActionList[count1 + count2 + i] = 5000 + i;
+			DEFAULT_ACTION_LIST[count1 + count2 + i] = 5000 + i;
 		}
 	}
 	
-	private static final ExBasicActionList STATIC_PACKET_TRANSFORMED = new ExBasicActionList(_actionsOnTransform);
-	private static final ExBasicActionList STATIC_PACKET = new ExBasicActionList(_defaultActionList);
+	private static final ExBasicActionList STATIC_PACKET_TRANSFORMED = new ExBasicActionList(ACTIONS_ON_TRANSFORM);
+	private static final ExBasicActionList STATIC_PACKET = new ExBasicActionList(DEFAULT_ACTION_LIST);
 	
 	public static final ExBasicActionList getStaticPacket(final L2PcInstance player)
 	{

+ 1 - 5
L2J_Server_BETA/java/com/l2jserver/gameserver/network/serverpackets/ExNotifyPremiumItem.java

@@ -19,16 +19,12 @@
 package com.l2jserver.gameserver.network.serverpackets;
 
 /**
- ** @author Gnacik
+ * @author Gnacik
  */
 public class ExNotifyPremiumItem extends L2GameServerPacket
 {
 	public static final ExNotifyPremiumItem STATIC_PACKET = new ExNotifyPremiumItem();
 	
-	private ExNotifyPremiumItem()
-	{
-	}
-	
 	@Override
 	protected void writeImpl()
 	{

+ 1 - 8
L2J_Server_BETA/java/com/l2jserver/gameserver/network/serverpackets/GMViewItemList.java

@@ -63,14 +63,7 @@ public class GMViewItemList extends L2GameServerPacket
 			writeD(temp.getItem().getBodyPart());
 			writeH(temp.getEnchantLevel());
 			writeH(temp.getCustomType2());
-			if (temp.isAugmented())
-			{
-				writeD(temp.getAugmentation().getAugmentationId());
-			}
-			else
-			{
-				writeD(0x00);
-			}
+			writeD(temp.isAugmented() ? temp.getAugmentation().getAugmentationId() : 0x00);
 			writeD(temp.getMana());
 			writeD(temp.isTimeLimitedItem() ? (int) (temp.getRemainingTime() / 1000) : -9999);
 			writeH(temp.getAttackElementType());

+ 2 - 5
L2J_Server_BETA/java/com/l2jserver/gameserver/network/serverpackets/RecipeBookItemList.java

@@ -41,7 +41,6 @@ public class RecipeBookItemList extends L2GameServerPacket
 	protected final void writeImpl()
 	{
 		writeC(0xdc);
-		
 		writeD(_isDwarvenCraft ? 0x00 : 0x01); // 0 = Dwarven - 1 = Common
 		writeD(_maxMp);
 		
@@ -51,12 +50,10 @@ public class RecipeBookItemList extends L2GameServerPacket
 		}
 		else
 		{
-			writeD(_recipes.length);// number of items in recipe book
-			
+			writeD(_recipes.length); // number of items in recipe book
 			for (int i = 0; i < _recipes.length; i++)
 			{
-				L2RecipeList temp = _recipes[i];
-				writeD(temp.getId());
+				writeD(_recipes[i].getId());
 				writeD(i + 1);
 			}
 		}

+ 0 - 1
L2J_Server_BETA/java/com/l2jserver/gameserver/network/serverpackets/SellList.java

@@ -88,7 +88,6 @@ public class SellList extends L2GameServerPacket
 			writeH(0x00); // TODO: Verify me
 			writeH(item.getCustomType2());
 			writeQ(item.getItem().getReferencePrice() / 2);
-			
 			// T1
 			writeH(item.getAttackElementType());
 			writeH(item.getAttackElementPower());

+ 8 - 3
L2J_Server_BETA/java/com/l2jserver/gameserver/network/serverpackets/WareHouseDepositList.java

@@ -31,6 +31,14 @@ public final class WareHouseDepositList extends L2GameServerPacket
 	public static final int FREIGHT = 1;
 	private final long _playerAdena;
 	private final FastList<L2ItemInstance> _items;
+	/**
+	 * <ul>
+	 * <li>0x01-Private Warehouse</li>
+	 * <li>0x02-Clan Warehouse</li>
+	 * <li>0x03-Castle Warehouse</li>
+	 * <li>0x04-Warehouse</li>
+	 * </ul>
+	 */
 	private final int _whType;
 	
 	public WareHouseDepositList(L2PcInstance player, int type)
@@ -53,9 +61,6 @@ public final class WareHouseDepositList extends L2GameServerPacket
 	protected final void writeImpl()
 	{
 		writeC(0x41);
-		/*
-		 * 0x01-Private Warehouse 0x02-Clan Warehouse 0x03-Castle Warehouse 0x04-Warehouse
-		 */
 		writeH(_whType);
 		writeQ(_playerAdena);
 		final int count = _items.size();

+ 8 - 8
L2J_Server_BETA/java/com/l2jserver/gameserver/network/serverpackets/WareHouseWithdrawalList.java

@@ -31,6 +31,14 @@ public final class WareHouseWithdrawalList extends L2GameServerPacket
 	private L2PcInstance _activeChar;
 	private long _playerAdena;
 	private L2ItemInstance[] _items;
+	/**
+	 * <ul>
+	 * <li>0x01-Private Warehouse</li>
+	 * <li>0x02-Clan Warehouse</li>
+	 * <li>0x03-Castle Warehouse</li>
+	 * <li>0x04-Warehouse</li>
+	 * </ul>
+	 */
 	private int _whType;
 	
 	public WareHouseWithdrawalList(L2PcInstance player, int type)
@@ -60,14 +68,6 @@ public final class WareHouseWithdrawalList extends L2GameServerPacket
 	protected final void writeImpl()
 	{
 		writeC(0x42);
-		/**
-		 * <ul>
-		 * <li>0x01-Private Warehouse</li>
-		 * <li>0x02-Clan Warehouse</li>
-		 * <li>0x03-Castle Warehouse</li>
-		 * <li>0x04-Warehouse</li>
-		 * </ul>
-		 */
 		writeH(_whType);
 		writeQ(_playerAdena);
 		writeH(_items.length);