Browse Source

BETA: Formatting Multisell related classes and minor changes.

Zoey76 13 years ago
parent
commit
c012fa2002

+ 3 - 4
L2J_Server_BETA/java/com/l2jserver/gameserver/model/multisell/Entry.java

@@ -18,9 +18,7 @@ import java.util.ArrayList;
 import java.util.List;
 
 /**
- * 
  * @author DS
- *
  */
 public class Entry
 {
@@ -38,8 +36,7 @@ public class Entry
 	}
 	
 	/**
-	 * This constructor used in PreparedEntry only
-	 * ArrayLists not created
+	 * This constructor used in PreparedEntry only, ArrayLists not created.
 	 */
 	protected Entry()
 	{
@@ -60,7 +57,9 @@ public class Entry
 		_products.add(product);
 		
 		if (!product.isStackable())
+		{
 			_stackable = false;
+		}
 	}
 	
 	public final List<Ingredient> getProducts()

+ 6 - 3
L2J_Server_BETA/java/com/l2jserver/gameserver/model/multisell/Ingredient.java

@@ -27,8 +27,8 @@ public class Ingredient
 {
 	private int _itemId;
 	private long _itemCount;
-	private boolean _isTaxIngredient, _maintainIngredient;
-	
+	private boolean _isTaxIngredient;
+	private boolean _maintainIngredient;
 	private L2Item _template = null;
 	private ItemInfo _itemInfo = null;
 	
@@ -39,7 +39,9 @@ public class Ingredient
 		_isTaxIngredient = isTaxIngredient;
 		_maintainIngredient = maintainIngredient;
 		if (_itemId > 0)
+		{
 			_template = ItemTable.getInstance().getTemplate(_itemId);
+		}
 	}
 	
 	/**
@@ -114,6 +116,7 @@ public class Ingredient
 	{
 		return _maintainIngredient;
 	}
+	
 	public final boolean isStackable()
 	{
 		return _template == null ? true : _template.isStackable();
@@ -121,7 +124,7 @@ public class Ingredient
 	
 	public final boolean isArmorOrWeapon()
 	{
-		return _template == null ? false : _template instanceof L2Armor || _template instanceof L2Weapon;
+		return _template == null ? false : (_template instanceof L2Armor) || (_template instanceof L2Weapon);
 	}
 	
 	public final int getWeight()

+ 10 - 16
L2J_Server_BETA/java/com/l2jserver/gameserver/model/multisell/ListContainer.java

@@ -18,9 +18,7 @@ import java.util.ArrayList;
 import java.util.List;
 
 /**
- * 
  * @author DS
- *
  */
 public class ListContainer
 {
@@ -37,9 +35,8 @@ public class ListContainer
 	}
 	
 	/**
-	 * This constructor used in PreparedListContainer only
-	 * ArrayList not created
-	 * @param listId 
+	 * This constructor used in PreparedListContainer only ArrayList not created
+	 * @param listId
 	 */
 	protected ListContainer(int listId)
 	{
@@ -76,25 +73,22 @@ public class ListContainer
 		_maintainEnchantment = maintainEnchantment;
 	}
 	
-	public double getUseRate() 
+	public double getUseRate()
 	{
 		return _useRate;
 	}
+	
 	/**
-	 * Set this to create multisell with increased products, all product counts will be multiplied
-	 * by the rate specified<br>
-	 * 
-	 * 
-	 * <b>NOTE:</b> It affects only parser, it won't change values of already parsed multisell
-	 * since MultiSells' parseEntry method handles this feature
-	 * @param rate 
-	 * @see com.l2jserver.gameserver.datatables.MultiSell#parseEntry 
+	 * Set this to create multisell with increased products, all product counts will be multiplied by the rate specified.<br>
+	 * <b>NOTE:</b> It affects only parser, it won't change values of already parsed multisell since MultiSells' parseEntry method handles this feature.
+	 * @param rate
+	 * @see com.l2jserver.gameserver.datatables.MultiSell#parseEntry
 	 */
-	public void setUseRate(double rate) 
+	public void setUseRate(double rate)
 	{
 		_useRate = rate;
 	}
-
+	
 	public final boolean getMaintainEnchantment()
 	{
 		return _maintainEnchantment;

+ 16 - 16
L2J_Server_BETA/java/com/l2jserver/gameserver/model/multisell/PreparedEntry.java

@@ -21,9 +21,7 @@ import java.util.ArrayList;
 import com.l2jserver.gameserver.model.items.instance.L2ItemInstance;
 
 /**
- * 
  * @author DS
- *
  */
 public class PreparedEntry extends Entry
 {
@@ -32,8 +30,10 @@ public class PreparedEntry extends Entry
 	public PreparedEntry(Entry template, L2ItemInstance item, boolean applyTaxes, boolean maintainEnchantment, double taxRate)
 	{
 		_entryId = template.getEntryId() * 100000;
-		if (maintainEnchantment && item != null)
+		if (maintainEnchantment && (item != null))
+		{
 			_entryId += item.getEnchantLevel();
+		}
 		
 		ItemInfo info = null;
 		long adenaAmount = 0;
@@ -48,16 +48,18 @@ public class PreparedEntry extends Entry
 				{
 					// if taxes are to be applied, modify/add the adena count based on the template adena/ancient adena count
 					if (applyTaxes)
+					{
 						_taxAmount += Math.round(ing.getItemCount() * taxRate);
+					}
 				}
 				else
+				{
 					adenaAmount += ing.getItemCount();
-				
-				continue; // do not yet add this adena amount to the list as non-taxIngredient adena might be entered later (order not guaranteed)
+				}
+				// do not yet add this adena amount to the list as non-taxIngredient adena might be entered later (order not guaranteed)
+				continue;
 			}
-			else if (maintainEnchantment
-					&& item != null
-					&& ing.isArmorOrWeapon())
+			else if (maintainEnchantment && (item != null) && ing.isArmorOrWeapon())
 			{
 				info = new ItemInfo(item);
 				final Ingredient newIngredient = ing.getCopy();
@@ -69,32 +71,30 @@ public class PreparedEntry extends Entry
 				final Ingredient newIngredient = ing.getCopy();
 				_ingredients.add(newIngredient);
 			}
-				
 		}
 		
 		// now add the adena, if any.
 		adenaAmount += _taxAmount; // do not forget tax
 		if (adenaAmount > 0)
+		{
 			_ingredients.add(new Ingredient(ADENA_ID, adenaAmount, false, false));
+		}
 		
 		// now copy products
 		_products = new ArrayList<Ingredient>(template.getProducts().size());
 		for (Ingredient ing : template.getProducts())
 		{
 			if (!ing.isStackable())
+			{
 				_stackable = false;
+			}
 			
+			final Ingredient newProduct = ing.getCopy();
 			if (maintainEnchantment && ing.isArmorOrWeapon())
 			{
-				final Ingredient newProduct = ing.getCopy();
 				newProduct.setItemInfo(info);
-				_products.add(newProduct);
-			}
-			else
-			{
-				final Ingredient newProduct = ing.getCopy();
-				_products.add(newProduct);
 			}
+			_products.add(newProduct);
 		}
 	}
 	

+ 11 - 6
L2J_Server_BETA/java/com/l2jserver/gameserver/model/multisell/PreparedListContainer.java

@@ -38,9 +38,7 @@ public class PreparedListContainer extends ListContainer
 		if (npc != null)
 		{
 			_npcObjectId = npc.getObjectId();
-			if (template.getApplyTaxes()
-					&& npc.getIsInTown()
-					&& npc.getCastle().getOwnerId() > 0)
+			if (template.getApplyTaxes() && npc.getIsInTown() && (npc.getCastle().getOwnerId() > 0))
 			{
 				_applyTaxes = true;
 				taxRate = npc.getCastle().getTaxRate();
@@ -50,22 +48,27 @@ public class PreparedListContainer extends ListContainer
 		if (inventoryOnly)
 		{
 			if (player == null)
+			{
 				return;
+			}
 			
 			final L2ItemInstance[] items;
 			if (_maintainEnchantment)
+			{
 				items = player.getInventory().getUniqueItemsByEnchantLevel(false, false, false);
+			}
 			else
+			{
 				items = player.getInventory().getUniqueItems(false, false, false);
+			}
 			
 			// size is not known - using FastList
 			_entries = new FastList<Entry>();
 			for (L2ItemInstance item : items)
 			{
-				// only do the matchup on equipable items that are not currently equipped
+				// only do the match up on equippable items that are not currently equipped
 				// so for each appropriate item, produce a set of entries for the multisell list.
-				if (!item.isEquipped()
-						&& ((item.getItem() instanceof L2Armor) || (item.getItem() instanceof L2Weapon)))
+				if (!item.isEquipped() && ((item.getItem() instanceof L2Armor) || (item.getItem() instanceof L2Weapon)))
 				{
 					// loop through the entries to see which ones we wish to include
 					for (Entry ent : template.getEntries())
@@ -87,7 +90,9 @@ public class PreparedListContainer extends ListContainer
 		{
 			_entries = new ArrayList<Entry>(template.getEntries().size());
 			for (Entry ent : template.getEntries())
+			{
 				_entries.add(new PreparedEntry(ent, null, _applyTaxes, false, taxRate));
+			}
 		}
 	}