Pārlūkot izejas kodu

BETA: Refactoring:
* L2PetLevelData refactor and documentation.
* L2PetData minor refactor and documentation.
* PetDataTable refactor and documentation, now extends DocumentParser.
* ArmorSetsTable renamed to ArmorSetsData, minor refactor.

Zoey76 13 gadi atpakaļ
vecāks
revīzija
b965d0d284

+ 2 - 2
L2J_Server_BETA/java/com/l2jserver/gameserver/GameServer.java

@@ -36,7 +36,7 @@ import com.l2jserver.gameserver.cache.CrestCache;
 import com.l2jserver.gameserver.cache.HtmCache;
 import com.l2jserver.gameserver.datatables.AccessLevels;
 import com.l2jserver.gameserver.datatables.AdminCommandAccessRights;
-import com.l2jserver.gameserver.datatables.ArmorSetsTable;
+import com.l2jserver.gameserver.datatables.ArmorSetsData;
 import com.l2jserver.gameserver.datatables.AugmentationData;
 import com.l2jserver.gameserver.datatables.CharNameTable;
 import com.l2jserver.gameserver.datatables.CharSummonTable;
@@ -227,7 +227,7 @@ public class GameServer
 		TradeController.getInstance();
 		MultiSell.getInstance();
 		RecipeController.getInstance();
-		ArmorSetsTable.getInstance();
+		ArmorSetsData.getInstance();
 		FishTable.getInstance();
 		HennaData.getInstance();
 		

+ 6 - 12
L2J_Server_BETA/java/com/l2jserver/gameserver/datatables/ArmorSetsTable.java → L2J_Server_BETA/java/com/l2jserver/gameserver/datatables/ArmorSetsData.java

@@ -17,7 +17,6 @@ package com.l2jserver.gameserver.datatables;
 import java.io.File;
 import java.util.HashMap;
 import java.util.Map;
-import java.util.logging.Level;
 
 import org.w3c.dom.Document;
 import org.w3c.dom.NamedNodeMap;
@@ -31,20 +30,15 @@ import com.l2jserver.gameserver.model.holders.SkillHolder;
 /**
  * @author godson, Luno, UnAfraid
  */
-public final class ArmorSetsTable extends DocumentParser
+public final class ArmorSetsData extends DocumentParser
 {
-	private final Map<Integer, L2ArmorSet> _armorSets = new HashMap<>();
+	private static final Map<Integer, L2ArmorSet> _armorSets = new HashMap<>();
 	
-	private ArmorSetsTable()
-	{
-		load();
-	}
-	
-	private void load()
+	private ArmorSetsData()
 	{
 		_armorSets.clear();
 		parseDirectory(new File(Config.DATAPACK_ROOT, "data/stats/armorsets"));
-		_log.log(Level.INFO, getClass().getSimpleName() + ": Loaded " + _armorSets.size() + " Armor sets.");
+		_log.info(getClass().getSimpleName() + ": Loaded " + _armorSets.size() + " Armor sets.");
 	}
 	
 	@Override
@@ -174,7 +168,7 @@ public final class ArmorSetsTable extends DocumentParser
 		return _armorSets.get(chestId);
 	}
 	
-	public static ArmorSetsTable getInstance()
+	public static ArmorSetsData getInstance()
 	{
 		return SingletonHolder._instance;
 	}
@@ -182,6 +176,6 @@ public final class ArmorSetsTable extends DocumentParser
 	@SuppressWarnings("synthetic-access")
 	private static class SingletonHolder
 	{
-		protected static final ArmorSetsTable _instance = new ArmorSetsTable();
+		protected static final ArmorSetsData _instance = new ArmorSetsData();
 	}
 }

+ 1 - 1
L2J_Server_BETA/java/com/l2jserver/gameserver/datatables/ItemTable.java

@@ -422,7 +422,7 @@ public class ItemTable
 			}
 			
 			// if it's a pet control item, delete the pet as well
-			if (PetDataTable.isPetItem(item.getItemId()))
+			if (item.getItem().isPetItem())
 			{
 				Connection con = null;
 				try

+ 218 - 298
L2J_Server_BETA/java/com/l2jserver/gameserver/datatables/PetDataTable.java

@@ -14,263 +14,219 @@
  */
 package com.l2jserver.gameserver.datatables;
 
-import gnu.trove.map.hash.TIntObjectHashMap;
-
-import java.io.File;
-import java.util.logging.Level;
-import java.util.logging.Logger;
-
-import javax.xml.parsers.DocumentBuilderFactory;
+import java.util.HashMap;
+import java.util.Map;
 
 import org.w3c.dom.Document;
 import org.w3c.dom.NamedNodeMap;
 import org.w3c.dom.Node;
 
-import com.l2jserver.Config;
+import com.l2jserver.gameserver.engines.DocumentParser;
 import com.l2jserver.gameserver.model.L2PetData;
 import com.l2jserver.gameserver.model.L2PetLevelData;
-import com.l2jserver.gameserver.model.items.L2Item;
-import com.l2jserver.gameserver.model.items.type.L2EtcItemType;
+import com.l2jserver.gameserver.model.StatsSet;
 
-public class PetDataTable
+/**
+ * This class parse and hold all pet parameters.
+ * TODO: Unhardcode where is possible boolean methods and load and use all pet parameters.
+ * @author Zoey76 (rework)
+ */
+public final class PetDataTable extends DocumentParser
 {
-	private static Logger _log = Logger.getLogger(PetDataTable.class.getName());
-	
-	private static TIntObjectHashMap<L2PetData> _petTable;
-
-	public static PetDataTable getInstance()
-	{
-		return SingletonHolder._instance;
-	}
+	private static final Map<Integer, L2PetData> _pets = new HashMap<>();
 	
 	private PetDataTable()
 	{
-		_petTable = new TIntObjectHashMap<L2PetData>();
-		load();
+		_pets.clear();
+		parseDatapackFile("data/stats/npc/PetData.xml");
+		_log.info(getClass().getSimpleName() + ": Loaded " + _pets.size() + " Pets.");
 	}
 	
-	public void load()
+	@Override
+	protected void parseDocument(Document doc)
 	{
-		_petTable.clear();
-		DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
-		factory.setValidating(false);
-		factory.setIgnoringComments(true);
-		File file = new File(Config.DATAPACK_ROOT, "data/stats/npc/PetData.xml");
-		Document doc = null;
-		if (file.exists())
+		NamedNodeMap attrs;
+		Node n = doc.getFirstChild();
+		for (Node d = n.getFirstChild(); d != null; d = d.getNextSibling())
 		{
-			try
-			{
-				doc = factory.newDocumentBuilder().parse(file);
-			}
-			catch (Exception e)
+			if (d.getNodeName().equals("pet"))
 			{
-				_log.log(Level.WARNING, "Could not parse PetData.xml file: " + e.getMessage(), e);
-				return;
-			}
-			
-			Node n = doc.getFirstChild();
-			for (Node d = n.getFirstChild(); d != null; d = d.getNextSibling())
-			{
-				if (d.getNodeName().equals("pet"))
+				int npcId = parseInt(d.getAttributes(), "id");
+				// index ignored for now
+				L2PetData data = new L2PetData();
+				for (Node p = d.getFirstChild(); p != null; p = p.getNextSibling())
 				{
-					int npcId = Integer.parseInt(d.getAttributes().getNamedItem("id").getNodeValue());
-					//index ignored for now
-					L2PetData data = new L2PetData();
-					for (Node p = d.getFirstChild(); p != null; p = p.getNextSibling())
+					if (p.getNodeName().equals("set"))
 					{
-						if (p.getNodeName().equals("set"))
+						attrs = p.getAttributes();
+						String type = attrs.getNamedItem("name").getNodeValue();
+						if ("food".equals(type))
 						{
-							NamedNodeMap attrs = p.getAttributes();
-							String type = attrs.getNamedItem("name").getNodeValue();
-							if ("food".equals(type))
+							for (String foodId : attrs.getNamedItem("val").getNodeValue().split(";"))
 							{
-								String[] values = attrs.getNamedItem("val").getNodeValue().split(";");
-								int[] food = new int[values.length];
-								for (int i = 0; i < values.length; i++)
-								{
-									food[i] = Integer.parseInt(values[i]);
-								}
-								data.set_food(food);
+								data.addFood(Integer.valueOf(foodId));
 							}
-							else if ("load".equals(type))
-							{
-								data.set_load(Integer.parseInt(attrs.getNamedItem("val").getNodeValue()));
-							}
-							else if ("hungry_limit".equals(type))
-							{
-								data.set_hungry_limit(Integer.parseInt(attrs.getNamedItem("val").getNodeValue()));
-							}
-							//sync_level and evolve ignored 
 						}
-						else if (p.getNodeName().equals("skills"))
+						else if ("load".equals(type))
+						{
+							data.setLoad(parseInt(attrs, "val"));
+						}
+						else if ("hungry_limit".equals(type))
+						{
+							data.setHungryLimit(parseInt(attrs, "val"));
+						}
+						// sync_level and evolve ignored
+					}
+					else if (p.getNodeName().equals("skills"))
+					{
+						for (Node s = p.getFirstChild(); s != null; s = s.getNextSibling())
 						{
-							for (Node s = p.getFirstChild(); s != null; s = s.getNextSibling())
+							if (s.getNodeName().equals("skill"))
 							{
-								if (s.getNodeName().equals("skill"))
-								{
-									NamedNodeMap attrs = s.getAttributes();
-									int skillId = Integer.parseInt(attrs.getNamedItem("skillId").getNodeValue());
-									int skillLvl = Integer.parseInt(attrs.getNamedItem("skillLvl").getNodeValue());
-									int minLvl = Integer.parseInt(attrs.getNamedItem("minLvl").getNodeValue());
-									data.addNewSkill(skillId, skillLvl, minLvl);
-								}
+								attrs = s.getAttributes();
+								data.addNewSkill(parseInt(attrs, "skillId"), parseInt(attrs, "skillLvl"), parseInt(attrs, "minLvl"));
 							}
 						}
-						else if (p.getNodeName().equals("stats"))
+					}
+					else if (p.getNodeName().equals("stats"))
+					{
+						for (Node s = p.getFirstChild(); s != null; s = s.getNextSibling())
 						{
-							for (Node s = p.getFirstChild(); s != null; s = s.getNextSibling())
+							if (s.getNodeName().equals("stat"))
 							{
-								if (s.getNodeName().equals("stat"))
+								final int level = Integer.parseInt(s.getAttributes().getNamedItem("level").getNodeValue());
+								final StatsSet set = new StatsSet();
+								for (Node bean = s.getFirstChild(); bean != null; bean = bean.getNextSibling())
 								{
-									int level = Integer.parseInt(s.getAttributes().getNamedItem("level").getNodeValue());
-									L2PetLevelData stat = new L2PetLevelData();
-									for (Node bean = s.getFirstChild(); bean != null; bean = bean.getNextSibling())
+									if (bean.getNodeName().equals("set"))
 									{
-										if (bean.getNodeName().equals("set"))
-										{
-											NamedNodeMap attrs = bean.getAttributes();
-											String type = attrs.getNamedItem("name").getNodeValue();
-											String value = attrs.getNamedItem("val").getNodeValue();
-											if ("max_meal".equals(type))
-											{
-												stat.setPetMaxFeed(Integer.parseInt(value));
-											}
-											else if ("exp".equals(type))
-											{
-												stat.setPetMaxExp(Long.parseLong(value));
-											}
-											else if ("get_exp_type".equals(type))
-											{
-												stat.setOwnerExpTaken(Integer.parseInt(value));
-											}
-											else if ("consume_meal_in_battle".equals(type))
-											{
-												stat.setPetFeedBattle(Integer.parseInt(value));
-											}
-											else if ("consume_meal_in_normal".equals(type))
-											{
-												stat.setPetFeedNormal(Integer.parseInt(value));
-											}
-											else if ("org_pattack".equals(type))
-											{
-												stat.setPetPAtk(Float.parseFloat(value));
-											}
-											else if ("org_pdefend".equals(type))
-											{
-												stat.setPetPDef(Float.parseFloat(value));
-											}
-											else if ("org_mattack".equals(type))
-											{
-												stat.setPetMAtk(Float.parseFloat(value));
-											}
-											else if ("org_mdefend".equals(type))
-											{
-												stat.setPetMDef(Float.parseFloat(value));
-											}
-											else if ("org_hp".equals(type))
-											{
-												stat.setPetMaxHP(Float.parseFloat(value));
-											}
-											else if ("org_mp".equals(type))
-											{
-												stat.setPetMaxMP(Float.parseFloat(value));
-											}
-											else if ("org_hp_regen".equals(type))
-											{
-												stat.setPetRegenHP(Float.parseFloat(value));
-											}
-											else if ("org_mp_regen".equals(type))
-											{
-												stat.setPetRegenMP(Float.parseFloat(value));
-											}
-											else if ("soulshot_count".equals(type))
-											{
-												stat.setPetSoulShot((short) Integer.parseInt(value));
-											}
-											else if ("spiritshot_count".equals(type))
-											{
-												stat.setPetSpiritShot((short) Integer.parseInt(value));
-											}
-										}
+										attrs = bean.getAttributes();
+										set.set(attrs.getNamedItem("name").getNodeValue(), attrs.getNamedItem("val").getNodeValue());
 									}
-									data.addNewStat(stat, level);
 								}
+								data.addNewStat(level, new L2PetLevelData(set));
 							}
 						}
 					}
-					_petTable.put(npcId, data);
 				}
+				_pets.put(npcId, data);
 			}
 		}
-		else
-			_log.warning("Not found PetData.xml");
-		
-		_log.info(getClass().getSimpleName()+": Loaded " + _petTable.size() + " Pets.");
-		
 	}
 	
-	public L2PetLevelData getPetLevelData(int petID, int petLevel)
+	/**
+	 * @param petId the pet Id.
+	 * @param petLevel the pet level.
+	 * @return the pet's parameters for the given Id and level.
+	 */
+	public L2PetLevelData getPetLevelData(int petId, int petLevel)
 	{
-		return _petTable.get(petID).getPetLevelData(petLevel);
+		final L2PetData pd = getPetData(petId);
+		if (pd != null)
+		{
+			return pd.getPetLevelData(petLevel);
+		}
+		return null;
 	}
 	
-	public L2PetData getPetData(int petID)
+	/**
+	 * @param petId the pet Id.
+	 * @return 
+	 */
+	public L2PetData getPetData(int petId)
 	{
-		if (!_petTable.contains(petID))
-			_log.info("Missing pet data for npcid: "+petID);
-		return _petTable.get(petID);
+		if (!_pets.containsKey(petId))
+		{
+			_log.info("Missing pet data for npcid: " + petId);
+		}
+		return _pets.get(petId);
 	}
 	
-
-	public int getPetMinLevel(int petID)
+	/**
+	 * @param petId the pet Id.
+	 * @return
+	 */
+	public int getPetMinLevel(int petId)
 	{
-		return _petTable.get(petID).getMinLevel();
+		return _pets.get(petId).getMinLevel();
 	}
-
-	/*
-	 * Pets stuffs
+	
+	/**
+	 * @param npcId the NPC Id to verify.
+	 * @return {@code true} if the given Id is from a wolf, {@code false} otherwise.
 	 */
 	public static boolean isWolf(int npcId)
 	{
 		return npcId == 12077;
 	}
 	
+	/**
+	 * @param npcId the NPC Id to verify.
+	 * @return {@code true} if the given Id is from an evolved wolf, {@code false} otherwise.
+	 */
 	public static boolean isEvolvedWolf(int npcId)
 	{
-		return npcId == 16030 || npcId == 16037 || npcId == 16025 || npcId == 16041 || npcId == 16042;
+		return (npcId == 16030) || (npcId == 16037) || (npcId == 16025) || (npcId == 16041) || (npcId == 16042);
 	}
 	
+	/**
+	 * @param npcId the NPC Id to verify.
+	 * @return {@code true} if the given Id is from a Sin Eater, {@code false} otherwise.
+	 */
 	public static boolean isSinEater(int npcId)
 	{
 		return npcId == 12564;
 	}
 	
+	/**
+	 * @param npcId the NPC Id to verify.
+	 * @return {@code true} if the given Id is from a hatchling, {@code false} otherwise.
+	 */
 	public static boolean isHatchling(int npcId)
 	{
-		return npcId > 12310 && npcId < 12314;
+		return (npcId > 12310) && (npcId < 12314);
 	}
 	
+	/**
+	 * @param npcId the NPC Id to verify.
+	 * @return {@code true} if the given Id is from a strider, {@code false} otherwise.
+	 */
 	public static boolean isStrider(int npcId)
 	{
-		return (npcId > 12525 && npcId < 12529) || (npcId > 16037 && npcId < 16041) || npcId == 16068;
+		return ((npcId > 12525) && (npcId < 12529)) || ((npcId > 16037) && (npcId < 16041)) || (npcId == 16068);
 	}
 	
+	/**
+	 * @param npcId the NPC Id to verify.
+	 * @return {@code true} if the given Id is from a wyvern, {@code false} otherwise.
+	 */
 	public static boolean isWyvern(int npcId)
 	{
 		return npcId == 12621;
 	}
 	
+	/**
+	 * @param npcId the NPC Id to verify.
+	 * @return {@code true} if the given Id is from a baby pet, {@code false} otherwise.
+	 */
 	public static boolean isBaby(int npcId)
 	{
-		return npcId > 12779 && npcId < 12783;
+		return (npcId > 12779) && (npcId < 12783);
 	}
 	
+	/**
+	 * @param npcId the NPC Id to verify.
+	 * @return {@code true} if the given Id is from an improved baby pet, {@code false} otherwise.
+	 */
 	public static boolean isImprovedBaby(int npcId)
 	{
-		return npcId > 16033 && npcId < 16037;
+		return (npcId > 16033) && (npcId < 16037);
 	}
 	
+	/**
+	 * @param itemId the item Id to verify.
+	 * @return {@code true} if the given Id is from a pet's food, {@code false} otherwise.
+	 */
 	public static boolean isPetFood(int itemId)
 	{
 		switch (itemId)
@@ -290,121 +246,57 @@ public class PetDataTable
 	}
 	
 	/**
-	 * @param npcId 
-	 * @return 
-	 * @see L2PetData#getFood()
+	 * @param npcId the NPC Id to get its summoning item.
+	 * @return an array containing the list of summoning items for the given NPC Id.
 	 */
-	@Deprecated
-	public static int[] getFoodItemId(int npcId)
-	{
-		switch (npcId)
-		{
-			case 12077:// Wolf
-			case 12564://Sin Eater
-				return new int[] { 2515 };
-				
-			case 16030:// Great Wolf
-			case 16025:// Black Wolf
-			case 16037:// White Great Wolf
-			case 16041:// Fenrir
-			case 16042:// White Fenrir
-				return new int[] { 9668 };
-				
-			case 12311:// hatchling of wind
-			case 12312:// hatchling of star
-			case 12313:// hatchling of twilight
-				return new int[] { 4038 };
-				
-			case 12526:// wind strider
-			case 12527:// Star strider
-			case 12528:// Twilight strider
-			case 16038:// red wind strider
-			case 16039:// red Star strider
-			case 16040:// red Twilight strider
-			case 16068:// Guardian Strider
-				return new int[] { 5168, 5169 };
-				
-			case 12621: // wyvern
-				return new int[] { 6316 };
-				
-			case 12780:// Baby Buffalo
-			case 12782:// Baby Cougar
-			case 12781:// Baby Kookaburra
-				return new int[] { 7582 };
-				
-			case 16034:// Improved Baby Buffalo
-			case 16036:// Improved Baby Cougar
-			case 16035:// Improved Baby Kookaburra
-				return new int[] { 10425 };
-				
-			default:
-				return new int[] { 0 };
-		}
-	}
-	
-	public static boolean isPetItem(int itemId)
-	{
-		L2Item item = ItemTable.getInstance().getTemplate(itemId);
-		if (item != null && item.getItemType() == L2EtcItemType.PET_COLLAR)
-			return true;
-		return false;
-		
-		/*switch (itemId)
-		{
-			case 2375: // Wolf
-			case 3500: // hatchling of wind
-			case 3501: // hatchling of star
-			case 3502: // hatchling of twilight
-			case 4422: // strider of wind
-			case 4423: // strider of star
-			case 4424: // strider of dusk
-			case 4425: // Sin Eater
-			case 6648: // baby buffalo
-			case 6649: // baby cougar
-			case 6650: // baby kookaburra
-			case 8663: // Wyvern
-			case 9882: // Great Wolf
-			case 10163: // Black Wolf
-			case 10307: // Great Snow Wolf
-			case 10308: // red strider of wind
-			case 10309: // red strider of star
-			case 10310: // red strider of dusk
-			case 10311: // improved buffalo
-			case 10312: // improved cougar
-			case 10313: // improved kookaburra
-			case 10426: // Fenrir
-			case 10611: // White Fenrir
-			case 14819: // Guardian Strider
-				return true;
-			default:
-				return false;
-		}*/
-	}
-	
 	public static int[] getPetItemsByNpc(int npcId)
 	{
 		switch (npcId)
 		{
 			case 12077:// Wolf
-				return new int[] { 2375 };
+				return new int[]
+				{
+					2375
+				};
 			case 16025:// Great Wolf
-				return new int[] { 9882 };
+				return new int[]
+				{
+					9882
+				};
 			case 16030:// Black Wolf
-				return new int[] { 10163 };
+				return new int[]
+				{
+					10163
+				};
 			case 16037:// White Great Wolf
-				return new int[] { 10307 };
+				return new int[]
+				{
+					10307
+				};
 			case 16041:// Fenrir
-				return new int[] { 10426 };
+				return new int[]
+				{
+					10426
+				};
 			case 16042:// White Fenrir
-				return new int[] { 10611 };
-			case 12564://Sin Eater
-				return new int[] { 4425 };
-				
+				return new int[]
+				{
+					10611
+				};
+			case 12564:// Sin Eater
+				return new int[]
+				{
+					4425
+				};
 			case 12311:// hatchling of wind
 			case 12312:// hatchling of star
 			case 12313:// hatchling of twilight
-				return new int[] { 3500, 3501, 3502 };
-				
+				return new int[]
+				{
+					3500,
+					3501,
+					3502
+				};
 			case 12526:// wind strider
 			case 12527:// Star strider
 			case 12528:// Twilight strider
@@ -412,50 +304,78 @@ public class PetDataTable
 			case 16039: // red strider of star
 			case 16040: // red strider of dusk
 			case 16068: // Guardian Strider
-				return new int[] { 4422, 4423, 4424, 10308, 10309, 10310 , 14819};
-				
+				return new int[]
+				{
+					4422,
+					4423,
+					4424,
+					10308,
+					10309,
+					10310,
+					14819
+				};
 			case 12621:// Wyvern
-				return new int[] { 8663 };
-				
+				return new int[]
+				{
+					8663
+				};
 			case 12780:// Baby Buffalo
 			case 12782:// Baby Cougar
 			case 12781:// Baby Kookaburra
-				return new int[] { 6648, 6649, 6650 };
-				
+				return new int[]
+				{
+					6648,
+					6649,
+					6650
+				};
 			case 16034:// Improved Baby Buffalo
 			case 16036:// Improved Baby Cougar
 			case 16035:// Improved Baby Kookaburra
-				return new int[] { 10311, 10312, 10313 };
-				
+				return new int[]
+				{
+					10311,
+					10312,
+					10313
+				};
 				// unknown item id.. should never happen
 			default:
-				return new int[] { 0 };
+				return new int[]
+				{
+					0
+				};
 		}
 	}
 	
+	/**
+	 * @param npcId the NPC Id to verify.
+	 * @return {@code true} if the given Id is from a mountable pet, {@code false} otherwise.
+	 */
 	public static boolean isMountable(int npcId)
 	{
-		return npcId == 12526 // wind strider
-		|| npcId == 12527 // star strider
-		|| npcId == 12528 // twilight strider
-		|| npcId == 12621 // wyvern
-		|| npcId == 16037 // Great Snow Wolf
-		|| npcId == 16041 // Fenrir Wolf
-		|| npcId == 16042 // White Fenrir Wolf
-		|| npcId == 16038 // Red Wind Strider
-		|| npcId == 16039 // Red Star Strider
-		|| npcId == 16040 // Red Twilight Strider
-		|| npcId == 16068; // Guardian Strider
+		return (npcId == 12526 // wind strider
+		) || (npcId == 12527 // star strider
+		) || (npcId == 12528 // twilight strider
+		) || (npcId == 12621 // wyvern
+		) || (npcId == 16037 // Great Snow Wolf
+		) || (npcId == 16041 // Fenrir Wolf
+		) || (npcId == 16042 // White Fenrir Wolf
+		) || (npcId == 16038 // Red Wind Strider
+		) || (npcId == 16039 // Red Star Strider
+		) || (npcId == 16040 // Red Twilight Strider
+		) || (npcId == 16068); // Guardian Strider
 	}
 	
-	@SuppressWarnings("synthetic-access")
-	private static class SingletonHolder
+	/**
+	 * @return this class unique instance.
+	 */
+	public static PetDataTable getInstance()
 	{
-		protected static final PetDataTable _instance = new PetDataTable();
+		return SingletonHolder._instance;
 	}
 	
-	public static void main(String... s)
+	@SuppressWarnings("synthetic-access")
+	private static class SingletonHolder
 	{
-		getInstance();
+		protected static final PetDataTable _instance = new PetDataTable();
 	}
 }

+ 94 - 44
L2J_Server_BETA/java/com/l2jserver/gameserver/model/L2PetData.java

@@ -14,143 +14,193 @@
  */
 package com.l2jserver.gameserver.model;
 
-import gnu.trove.map.hash.TIntObjectHashMap;
-
 import java.util.ArrayList;
+import java.util.HashMap;
 import java.util.List;
+import java.util.Map;
 
 import com.l2jserver.gameserver.datatables.SkillTable;
+import com.l2jserver.gameserver.model.holders.SkillHolder;
 
 /**
- * Class hold information about basic pet stats which are same on each level
+ * Class hold information about basic pet stats which are same on each level.
  * @author JIV
- *
  */
 public class L2PetData
 {
-	private TIntObjectHashMap<L2PetLevelData> _levelStats = new TIntObjectHashMap<L2PetLevelData>();
-	private List<L2PetSkillLearn> _skills = new ArrayList<L2PetSkillLearn>();
+	private final Map<Integer, L2PetLevelData> _levelStats = new HashMap<>();
+	private final List<L2PetSkillLearn> _skills = new ArrayList<>();
 	
 	private int _load = 20000;
-	private int _hungry_limit = 1;
+	private int _hungryLimit = 1;
 	private int _minlvl = Byte.MAX_VALUE;
-	private int[] _food = {};
+	private final List<Integer> _food = new ArrayList<>();
 	
-	public void addNewStat(L2PetLevelData data, int level)
+	/**
+	 * @param level the pet's level.
+	 * @param data the pet's data.
+	 */
+	public void addNewStat(int level, L2PetLevelData data)
 	{
 		if (_minlvl > level)
+		{
 			_minlvl = level;
+		}
 		_levelStats.put(level, data);
 	}
 	
+	/**
+	 * @param petLevel the pet's level.
+	 * @return the pet data associated to that pet level.
+	 */
 	public L2PetLevelData getPetLevelData(int petLevel)
 	{
 		return _levelStats.get(petLevel);
 	}
 	
+	/**
+	 * @return the pet's weight load.
+	 */
 	public int getLoad()
 	{
 		return _load;
 	}
 	
-	public int getHungry_limit()
+	/**
+	 * @return the pet's hunger limit.
+	 */
+	public int getHungryLimit()
 	{
-		return _hungry_limit;
+		return _hungryLimit;
 	}
 	
+	/**
+	 * @return the pet's minimum level.
+	 */
 	public int getMinLevel()
 	{
 		return _minlvl;
 	}
 	
-	public int[] getFood()
+	/**
+	 * @return the pet's food list.
+	 */
+	public List<Integer> getFood()
 	{
 		return _food;
 	}
 	
-	public void set_load(int _load)
+	/**
+	 * @param foodId the pet's food Id to add.
+	 */
+	public void addFood(Integer foodId)
 	{
-		this._load = _load;
+		_food.add(foodId);
 	}
-
-	public void set_hungry_limit(int _hungry_limit)
+	
+	/**
+	 * @param load the weight load to set.
+	 */
+	public void setLoad(int load)
 	{
-		this._hungry_limit = _hungry_limit;
+		_load = load;
 	}
-
-	public void set_food(int[] _food)
+	
+	/**
+	 * @param limit the hunger limit to set.
+	 */
+	public void setHungryLimit(int limit)
 	{
-		this._food = _food;
+		_hungryLimit = limit;
 	}
 	
-	//SKILS
+	// SKILS
 	
-	public void addNewSkill(int id, int lvl, int petLvl)
+	/**
+	 * @param skillId the skill Id to add.
+	 * @param skillLvl the skill level.
+	 * @param petLvl the pet's level when this skill is available.
+	 */
+	public void addNewSkill(int skillId, int skillLvl, int petLvl)
 	{
-		_skills.add(new L2PetSkillLearn(id, lvl, petLvl));
+		_skills.add(new L2PetSkillLearn(skillId, skillLvl, petLvl));
 	}
 	
+	/**
+	 * TODO: Simplify this.
+	 * @param skillId the skill Id.
+	 * @param petLvl the pet level.
+	 * @return the level of the skill for the given skill Id and pet level.
+	 */
 	public int getAvailableLevel(int skillId, int petLvl)
 	{
 		int lvl = 0;
 		for (L2PetSkillLearn temp : _skills)
-		{ 
-			if (temp.getId() != skillId)
+		{
+			if (temp.getSkillId() != skillId)
+			{
 				continue;
-			if (temp.getLevel() == 0)
+			}
+			if (temp.getSkillLvl() == 0)
 			{
 				if (petLvl < 70)
 				{
 					lvl = (petLvl / 10);
 					if (lvl <= 0)
+					{
 						lvl = 1;
+					}
 				}
 				else
+				{
 					lvl = (7 + ((petLvl - 70) / 5));
+				}
 				
 				// formula usable for skill that have 10 or more skill levels
-				int maxLvl = SkillTable.getInstance().getMaxLevel(temp.getId());
+				int maxLvl = SkillTable.getInstance().getMaxLevel(temp.getSkillId());
 				if (lvl > maxLvl)
+				{
 					lvl = maxLvl;
+				}
 				break;
 			}
 			else if (temp.getMinLevel() <= petLvl)
 			{
-				if (temp.getLevel() > lvl)
-					lvl = temp.getLevel();
+				if (temp.getSkillLvl() > lvl)
+				{
+					lvl = temp.getSkillLvl();
+				}
 			}
 		}
 		return lvl;
 	}
 	
+	/**
+	 * @return the list with the pet's skill data.
+	 */
 	public List<L2PetSkillLearn> getAvailableSkills()
 	{
 		return _skills;
 	}
 	
-	public static final class L2PetSkillLearn
+	public static final class L2PetSkillLearn extends SkillHolder
 	{
-		private final int _id;
-		private final int _level;
 		private final int _minLevel;
 		
+		/**
+		 * @param id the skill Id.
+		 * @param lvl the skill level.
+		 * @param minLvl the minimum level when this skill is available.
+		 */
 		public L2PetSkillLearn(int id, int lvl, int minLvl)
 		{
-			_id = id;
-			_level = lvl;
+			super(id, lvl);
 			_minLevel = minLvl;
 		}
 		
-		public int getId()
-		{
-			return _id;
-		}
-		
-		public int getLevel()
-		{
-			return _level;
-		}
-		
+		/**
+		 * @return the minimum level for the pet to get the skill.
+		 */
 		public int getMinLevel()
 		{
 			return _minLevel;

+ 93 - 126
L2J_Server_BETA/java/com/l2jserver/gameserver/model/L2PetLevelData.java

@@ -15,196 +15,163 @@
 package com.l2jserver.gameserver.model;
 
 /**
- * Stats definition for each pet level
- * @author JIV
- *
+ * Stats definition for each pet level.
+ * @author JIV, Zoey76
  */
 public class L2PetLevelData
 {
-	private int _ownerExpTaken;
-	private long _petMaxExp;
-	private float _petMaxHP;
-	private float _petMaxMP;
-	private float _petPAtk;
-	private float _petPDef;
-	private float _petMAtk;
-	private float _petMDef;
-	private int _petMaxFeed;
-	private int _petFeedBattle;
-	private int _petFeedNormal;
-	private float _petRegenHP;
-	private float _petRegenMP;
-	private short _petSoulShot;
-	private short _petSpiritShot;
-	
-	//  Max Exp
-	public long getPetMaxExp()
-	{
-		return _petMaxExp;
-	}
-	
-	public void setPetMaxExp(long pPetMaxExp)
-	{
-		_petMaxExp = pPetMaxExp;
+	private final int _ownerExpTaken;
+	private final int _petFeedBattle;
+	private final int _petFeedNormal;
+	private final float _petMAtk;
+	private final long _petMaxExp;
+	private final int _petMaxFeed;
+	private final float _petMaxHP;
+	private final float _petMaxMP;
+	private final float _petMDef;
+	private final float _petPAtk;
+	private final float _petPDef;
+	private final float _petRegenHP;
+	private final float _petRegenMP;
+	private final short _petSoulShot;
+	private final short _petSpiritShot;
+	
+	public L2PetLevelData(StatsSet set)
+	{
+		_ownerExpTaken = set.getInteger("get_exp_type");
+		_petMaxExp = set.getLong("exp");
+		_petMaxHP = set.getFloat("org_hp");
+		_petMaxMP = set.getFloat("org_mp");
+		_petPAtk = set.getFloat("org_pattack");
+		_petPDef = set.getFloat("org_pdefend");
+		_petMAtk = set.getFloat("org_mattack");
+		_petMDef = set.getFloat("org_mdefend");
+		_petMaxFeed = set.getInteger("max_meal");
+		_petFeedBattle = set.getInteger("consume_meal_in_battle");
+		_petFeedNormal = set.getInteger("consume_meal_in_normal");
+		_petRegenHP = set.getFloat("org_hp_regen");
+		_petRegenMP = set.getFloat("org_mp_regen");
+		_petSoulShot = set.getShort("soulshot_count");
+		_petSpiritShot = set.getShort("spiritshot_count");
 	}
 	
+	/**
+	 * @return the owner's experience points consumed by the pet.
+	 */
 	public int getOwnerExpTaken()
 	{
 		return _ownerExpTaken;
 	}
 	
-	public void setOwnerExpTaken(int pOwnerExpTaken)
-	{
-		_ownerExpTaken = pOwnerExpTaken;
-	}
-	
-	//  Max HP
-	public float getPetMaxHP()
-	{
-		return _petMaxHP;
-	}
-	
-	public void setPetMaxHP(float pPetMaxHP)
-	{
-		_petMaxHP = pPetMaxHP;
-	}
-	
-	//  Max Mp
-	public float getPetMaxMP()
-	{
-		return _petMaxMP;
-	}
-	
-	public void setPetMaxMP(float pPetMaxMP)
-	{
-		_petMaxMP = pPetMaxMP;
-	}
-	
-	//  PAtk
-	public float getPetPAtk()
-	{
-		return _petPAtk;
-	}
-	
-	public void setPetPAtk(float pPetPAtk)
-	{
-		_petPAtk = pPetPAtk;
-	}
-	
-	//  PDef
-	public float getPetPDef()
+	/**
+	 * @return the pet's food consume rate at battle state.
+	 */
+	public int getPetFeedBattle()
 	{
-		return _petPDef;
+		return _petFeedBattle;
 	}
 	
-	public void setPetPDef(float pPetPDef)
+	/**
+	 * @return the pet's food consume rate at normal state.
+	 */
+	public int getPetFeedNormal()
 	{
-		_petPDef = pPetPDef;
+		return _petFeedNormal;
 	}
 	
-	//  MAtk
+	/**
+	 * @return the pet's Magical Attack.
+	 */
 	public float getPetMAtk()
 	{
 		return _petMAtk;
 	}
 	
-	public void setPetMAtk(float pPetMAtk)
-	{
-		_petMAtk = pPetMAtk;
-	}
-	
-	//  MDef
-	public float getPetMDef()
-	{
-		return _petMDef;
-	}
-	
-	public void setPetMDef(float pPetMDef)
+	/**
+	 * @return the pet's maximum experience points.
+	 */
+	public long getPetMaxExp()
 	{
-		_petMDef = pPetMDef;
+		return _petMaxExp;
 	}
 	
-	//  MaxFeed
+	/**
+	 * @return the pet's maximum feed points.
+	 */
 	public int getPetMaxFeed()
 	{
 		return _petMaxFeed;
 	}
 	
-	public void setPetMaxFeed(int pPetMaxFeed)
+	/**
+	 * @return the pet's maximum HP.
+	 */
+	public float getPetMaxHP()
 	{
-		_petMaxFeed = pPetMaxFeed;
+		return _petMaxHP;
 	}
 	
-	//  Normal Feed
-	public int getPetFeedNormal()
+	/**
+	 * @return the pet's maximum MP.
+	 */
+	public float getPetMaxMP()
 	{
-		return _petFeedNormal;
+		return _petMaxMP;
 	}
 	
-	public void setPetFeedNormal(int pPetFeedNormal)
+	/**
+	 * @return the pet's Magical Defense.
+	 */
+	public float getPetMDef()
 	{
-		_petFeedNormal = pPetFeedNormal;
+		return _petMDef;
 	}
 	
-	//  Battle Feed
-	public int getPetFeedBattle()
+	/**
+	 * @return the pet's Physical Attack.
+	 */
+	public float getPetPAtk()
 	{
-		return _petFeedBattle;
+		return _petPAtk;
 	}
 	
-	public void setPetFeedBattle(int pPetFeedBattle)
+	/**
+	 * @return the pet's Physical Defense.
+	 */
+	public float getPetPDef()
 	{
-		_petFeedBattle = pPetFeedBattle;
+		return _petPDef;
 	}
 	
-	//  Regen HP
+	/**
+	 * @return the pet's HP regeneration rate.
+	 */
 	public float getPetRegenHP()
 	{
 		return _petRegenHP;
 	}
 	
-	public void setPetRegenHP(float pPetRegenHP)
-	{
-		_petRegenHP = pPetRegenHP;
-	}
-	
-	//  Regen MP
+	/**
+	 * @return the pet's MP regeneration rate.
+	 */
 	public float getPetRegenMP()
 	{
 		return _petRegenMP;
 	}
 	
-	public void setPetRegenMP(float pPetRegenMP)
-	{
-		_petRegenMP = pPetRegenMP;
-	}
-	
 	/**
-	 * @return the _petSoulShot
+	 * @return the pet's soulshot use count.
 	 */
 	public short getPetSoulShot()
 	{
 		return _petSoulShot;
 	}
+	
 	/**
-	 * @param soulShot the _petSoulShot to set
-	 */
-	public void setPetSoulShot(short soulShot)
-	{
-		_petSoulShot = soulShot;
-	}
-	/**
-	 * @return the _petSpiritShot
+	 * @return the pet's spiritshot use count.
 	 */
 	public short getPetSpiritShot()
 	{
 		return _petSpiritShot;
 	}
-	/**
-	 * @param spiritShot the _petSpiritShot to set
-	 */
-	public void setPetSpiritShot(short spiritShot)
-	{
-		_petSpiritShot = spiritShot;
-	}
 }

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

@@ -76,7 +76,7 @@ public final class L2BabyPetInstance extends L2PetInstance
 		double healPower = 0;
 		for (L2PetSkillLearn psl : PetDataTable.getInstance().getPetData(getNpcId()).getAvailableSkills())
 		{
-			int id = psl.getId();
+			int id = psl.getSkillId();
 			int lvl = PetDataTable.getInstance().getPetData(getNpcId()).getAvailableLevel(id, getLevel());
 			if (lvl == 0) // not enough pet lvl
 				continue;

+ 3 - 3
L2J_Server_BETA/java/com/l2jserver/gameserver/model/actor/instance/L2PcInstance.java

@@ -13922,8 +13922,8 @@ public final class L2PcInstance extends L2Playable
 					sendPacket(SystemMessageId.OUT_OF_FEED_MOUNT_CANCELED);
 				}
 				
-				int[] foodIds = getPetData(getMountNpcId()).getFood();
-				if (foodIds.length == 0)
+				List<Integer> foodIds = getPetData(getMountNpcId()).getFood();
+				if (foodIds.isEmpty())
 					return;
 				L2ItemInstance food = null;
 				for (int id : foodIds)
@@ -14034,7 +14034,7 @@ public final class L2PcInstance extends L2Playable
 	
 	private boolean isHungry()
 	{
-		return _canFeed ? (getCurrentFeed() < (getPetData(getMountNpcId()).getHungry_limit() / 100f * getPetLevelData(getMountNpcId()).getPetMaxFeed())):false;
+		return _canFeed ? (getCurrentFeed() < (getPetData(getMountNpcId()).getHungryLimit() / 100f * getPetLevelData(getMountNpcId()).getPetMaxFeed())):false;
 	}
 	
 	private class Dismount implements Runnable

+ 4 - 6
L2J_Server_BETA/java/com/l2jserver/gameserver/model/actor/instance/L2PetInstance.java

@@ -68,11 +68,9 @@ import com.l2jserver.gameserver.network.serverpackets.StatusUpdate;
 import com.l2jserver.gameserver.network.serverpackets.StopMove;
 import com.l2jserver.gameserver.network.serverpackets.SystemMessage;
 import com.l2jserver.gameserver.taskmanager.DecayTaskManager;
-import com.l2jserver.gameserver.util.Util;
 import com.l2jserver.util.Rnd;
 
 /**
- *
  * This class ...
  *
  * @version $Revision: 1.15.2.10.2.16 $ $Date: 2005/04/06 16:13:40 $
@@ -152,8 +150,8 @@ public class L2PetInstance extends L2Summon
 				
 				broadcastStatusUpdate();
 				
-				int[] foodIds = getPetData().getFood();
-				if (foodIds.length == 0)
+				List<Integer> foodIds = getPetData().getFood();
+				if (foodIds.isEmpty())
 				{
 					if (getCurrentFed() == 0)
 					{
@@ -1299,7 +1297,7 @@ public class L2PetInstance extends L2Summon
 	@Override
 	public final boolean isHungry()
 	{
-		return getCurrentFed() < ((getPetData().getHungry_limit() / 100f) * getPetLevelData().getPetMaxFeed());
+		return getCurrentFed() < ((getPetData().getHungryLimit() / 100f) * getPetLevelData().getPetMaxFeed());
 	}
 	
 	@Override
@@ -1366,7 +1364,7 @@ public class L2PetInstance extends L2Summon
 	
 	public boolean canEatFoodId(int itemId)
 	{
-		return Util.contains(_data.getFood(), itemId);
+		return _data.getFood().contains(Integer.valueOf(itemId));
 	}
 	
 	@Override

+ 2 - 4
L2J_Server_BETA/java/com/l2jserver/gameserver/model/holders/SkillHolder.java

@@ -18,12 +18,10 @@ import com.l2jserver.gameserver.datatables.SkillTable;
 import com.l2jserver.gameserver.model.skills.L2Skill;
 
 /**
- * 
+ * Simple class for storing skill id/level.
  * @author BiggBoss
- * Simple class for storing skill id/level
- *
  */
-public final class SkillHolder
+public class SkillHolder
 {
 	private final int _skillId;
 	private final int _skillLvl;

+ 6 - 6
L2J_Server_BETA/java/com/l2jserver/gameserver/model/itemcontainer/Inventory.java

@@ -26,7 +26,7 @@ import javolution.util.FastList;
 
 import com.l2jserver.Config;
 import com.l2jserver.L2DatabaseFactory;
-import com.l2jserver.gameserver.datatables.ArmorSetsTable;
+import com.l2jserver.gameserver.datatables.ArmorSetsData;
 import com.l2jserver.gameserver.datatables.ItemTable;
 import com.l2jserver.gameserver.model.L2ArmorSet;
 import com.l2jserver.gameserver.model.L2World;
@@ -453,11 +453,11 @@ public abstract class Inventory extends ItemContainer
 				return;
 			
 			// Checks for armor set for the equipped chest.
-			if (!ArmorSetsTable.getInstance().isArmorSet(chestItem.getItemId()))
+			if (!ArmorSetsData.getInstance().isArmorSet(chestItem.getItemId()))
 			{
 				return;
 			}
-			final L2ArmorSet armorSet = ArmorSetsTable.getInstance().getSet(chestItem.getItemId());
+			final L2ArmorSet armorSet = ArmorSetsData.getInstance().getSet(chestItem.getItemId());
 			boolean update = false;
 			boolean updateTimeStamp = false;
 			// Checks if equiped item is part of set
@@ -569,11 +569,11 @@ public abstract class Inventory extends ItemContainer
 			
 			if (slot == PAPERDOLL_CHEST)
 			{
-				if (!ArmorSetsTable.getInstance().isArmorSet(item.getItemId()))
+				if (!ArmorSetsData.getInstance().isArmorSet(item.getItemId()))
 				{
 					return;
 				}
-				final L2ArmorSet armorSet = ArmorSetsTable.getInstance().getSet(item.getItemId());
+				final L2ArmorSet armorSet = ArmorSetsData.getInstance().getSet(item.getItemId());
 				remove = true;
 				skills = armorSet.getSkills();
 				shieldSkill = armorSet.getShieldSkillId();
@@ -585,7 +585,7 @@ public abstract class Inventory extends ItemContainer
 				if (chestItem == null)
 					return;
 				
-				L2ArmorSet armorSet = ArmorSetsTable.getInstance().getSet(chestItem.getItemId());
+				L2ArmorSet armorSet = ArmorSetsData.getInstance().getSet(chestItem.getItemId());
 				if (armorSet == null)
 					return;
 				

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

@@ -1035,4 +1035,9 @@ public abstract class L2Item
 	{
 		return _questEvents;
 	}
+	
+	public boolean isPetItem()
+	{
+		return getItemType() == L2EtcItemType.PET_COLLAR;
+	}
 }

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

@@ -262,7 +262,7 @@ public final class RequestActionUse extends L2GameClientPacket
 						{
 							if (!pet.isHungry())
 								pet.unSummon(activeChar);
-							else if (((L2PetInstance) pet).getPetData().getFood().length > 0)
+							else if (!((L2PetInstance) pet).getPetData().getFood().isEmpty())
 								activeChar.sendPacket(SystemMessageId.YOU_CANNOT_RESTORE_HUNGRY_PETS);
 							else
 								activeChar.sendPacket(SystemMessageId.THE_HELPER_PET_CANNOT_BE_RETURNED);

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

@@ -20,7 +20,6 @@ import java.util.logging.Level;
 
 import com.l2jserver.Config;
 import com.l2jserver.L2DatabaseFactory;
-import com.l2jserver.gameserver.datatables.PetDataTable;
 import com.l2jserver.gameserver.instancemanager.CursedWeaponsManager;
 import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
 import com.l2jserver.gameserver.model.items.instance.L2ItemInstance;
@@ -144,7 +143,7 @@ public final class RequestDestroyItem extends L2GameClientPacket
 			activeChar.broadcastUserInfo();
 		}
 		
-		if (PetDataTable.isPetItem(itemId))
+		if (itemToRemove.getItem().isPetItem())
 		{
 			Connection con = null;
 			try