// Decompiled by DJ v3.11.11.95 Copyright 2009 Atanas Neshkov Date: 15.09.2012 11:25:14
// Home Page: http://members.fortu...kov.com/dj.html - Check often for new version!
// Decompiler options: packimports(3)
// Source File Name: PetDataTable.java
package net.l2emuproject.gameserver.datatables;
import java.sql.*;
import javolution.util.FastMap;
import net.l2emuproject.L2DatabaseFactory;
import net.l2emuproject.gameserver.model.L2PetData;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
public class PetDataTable
{
/* member class not found */
class L2Pet {}
public static PetDataTable getInstance()
{
if(_instance == null)
_instance = new PetDataTable();
return _instance;
}
private PetDataTable()
{
petTable = new FastMap();
}
public void loadPetsData()
{
Connection con = null;
con = L2DatabaseFactory.getInstance().getConnection(con);
PreparedStatement statement = con.prepareStatement("SELECT typeID, level, expMax, hpMax, mpMax, patk, pdef, matk, mdef, acc, evasion, crit, speed, atk_speed, cast_speed, feedMax, feedbattle, feednormal, loadMax, hpregen, mpregen, owner_exp_taken FROM pets_stats");
ResultSet rset;
int petId;
int petLevel;
L2PetData petData;
for(rset = statement.executeQuery(); rset.next(); ((FastMap)petTable.get(Integer.valueOf(petId))).put(Integer.valueOf(petLevel), petData))
{
petId = rset.getInt("typeID");
petLevel = rset.getInt("level");
petData = new L2PetData();
petData.setPetID(petId);
petData.setPetLevel(petLevel);
petData.setPetMaxExp(rset.getLong("expMax"));
petData.setPetMaxHP(rset.getInt("hpMax"));
petData.setPetMaxMP(rset.getInt("mpMax"));
petData.setPetPAtk(rset.getInt("patk"));
petData.setPetPDef(rset.getInt("pdef"));
petData.setPetMAtk(rset.getInt("matk"));
petData.setPetMDef(rset.getInt("mdef"));
petData.setPetAccuracy(rset.getInt("acc"));
petData.setPetEvasion(rset.getInt("evasion"));
petData.setPetCritical(rset.getInt("crit"));
petData.setPetSpeed(rset.getInt("speed"));
petData.setPetAtkSpeed(rset.getInt("atk_speed"));
petData.setPetCastSpeed(rset.getInt("cast_speed"));
petData.setPetMaxFeed(rset.getInt("feedMax"));
petData.setPetFeedNormal(rset.getInt("feednormal"));
petData.setPetFeedBattle(rset.getInt("feedbattle"));
petData.setPetMaxLoad(rset.getInt("loadMax"));
petData.setPetRegenHP(rset.getInt("hpregen"));
petData.setPetRegenMP(rset.getInt("mpregen"));
petData.setOwnerExpTaken(rset.getFloat("owner_exp_taken"));
if(!petTable.containsKey(Integer.valueOf(petId)))
petTable.put(Integer.valueOf(petId), new FastMap());
}
rset.close();
statement.close();
Exception e;
try
{
if(con != null)
con.close();
}
// Misplaced declaration of an exception variable
catch(Exception e)
{
e.printStackTrace();
}
break MISSING_BLOCK_LABEL_506;
e;
_log.warn((new StringBuilder()).append("Could not load pets stats: ").append(e).toString());
try
{
if(con != null)
con.close();
}
// Misplaced declaration of an exception variable
catch(Exception e)
{
e.printStackTrace();
}
break MISSING_BLOCK_LABEL_506;
Exception exception;
exception;
try
{
if(con != null)
con.close();
}
catch(SQLException e)
{
e.printStackTrace();
}
throw exception;
_log.info((new StringBuilder()).append("PetDataTable: loaded ").append(petTable.size()).append(" pets.").toString());
return;
}
public void addPetData(L2PetData petData)
{
FastMap h = (FastMap)petTable.get(Integer.valueOf(petData.getPetID()));
if(h == null)
{
FastMap statTable = new FastMap();
statTable.put(Integer.valueOf(petData.getPetLevel()), petData);
petTable.put(Integer.valueOf(petData.getPetID()), statTable);
return;
} else
{
h.put(Integer.valueOf(petData.getPetLevel()), petData);
return;
}
}
public void addPetData(L2PetData petLevelsList[])
{
for(int i = 0; i < petLevelsList.length; i++)
addPetData(petLevelsList);
}
public L2PetData getPetData(int petID, int petLevel)
{
try
{
return (L2PetData)((FastMap)petTable.get(Integer.valueOf(petID))).get(Integer.valueOf(petLevel));
}
catch(NullPointerException npe)
{
return null;
}
}
public static int getPetIdByItemId(int itemId)
{
L2Pet arr$[] = L2Pet.values();
int len$ = arr$.length;
for(int i$ = 0; i$ < len$; i$++)
{
L2Pet pet = arr$[i$];
if(pet.getControlItemId() == itemId)
return pet.getNpcId();
}
return 0;
}
public static int getItemIdByPetId(int npcId)
{
L2Pet arr$[] = L2Pet.values();
int len$ = arr$.length;
for(int i$ = 0; i$ < len$; i$++)
{
L2Pet pet = arr$[i$];
if(pet.getNpcId() == npcId)
return pet.getControlItemId();
}
return 0;
}
public static int[] getFoodItemId(int npcId)
{
L2Pet arr$[] = L2Pet.values();
int len$ = arr$.length;
for(int i$ = 0; i$ < len$; i$++)
{
L2Pet pet = arr$[i$];
if(pet.getNpcId() == npcId)
return pet.getFoodIds();
}
return EMPTY_INT;
}
public static boolean isPet(int npcId)
{
L2Pet arr$[] = L2Pet.values();
int len$ = arr$.length;
for(int i$ = 0; i$ < len$; i$++)
{
L2Pet pet = arr$[i$];
if(pet.getNpcId() == npcId)
return true;
}
return false;
}
public static boolean isPetFood(int npcId, int itemId)
{
L2Pet arr$[] = L2Pet.values();
int len$ = arr$.length;
label0:
for(int i$ = 0; i$ < len$; i$++)
{
L2Pet pet = arr$[i$];
if(pet.getNpcId() != npcId)
continue;
int arr$[] = pet.getFoodIds();
int len$ = arr$.length;
int i$ = 0;
do
{
if(i$ >= len$)
continue label0;
int id = arr$[i$];
if(id == itemId)
return true;
i$++;
} while(true);
}
return false;
}
public static boolean isPetFood(int itemId)
{
L2Pet arr$[] = L2Pet.values();
int len$ = arr$.length;
for(int i$ = 0; i$ < len$; i$++)
{
L2Pet pet = arr$[i$];
int arr$[] = pet.getFoodIds();
int len$ = arr$.length;
for(int i$ = 0; i$ < len$; i$++)
{
int id = arr$[i$];
if(id == itemId)
return true;
}
}
return false;
}
public static boolean isPetItem(int itemId)
{
L2Pet arr$[] = L2Pet.values();
int len$ = arr$.length;
for(int i$ = 0; i$ < len$; i$++)
{
L2Pet pet = arr$[i$];
if(pet.getControlItemId() == itemId)
return true;
}
return false;
}
public static boolean isMountable(int npcId)
{
L2Pet arr$[] = L2Pet.values();
int len$ = arr$.length;
for(int i$ = 0; i$ < len$; i$++)
{
L2Pet pet = arr$[i$];
if(pet.getNpcId() == npcId)
return pet.isMountable();
}
return false;
}
public static boolean isWolf(int npcId)
{
return 12077 == npcId;
}
public static boolean isHatchling(int npcId)
{
return 12311 == npcId || 12312 == npcId || 12313 == npcId;
}
public static boolean isStrider(int npcId)
{
switch(npcId)
{
case 12526:
case 12527:
case 12528:
case 16038:
case 16039:
case 16040:
return true;
}
return false;
}
public static boolean isWyvern(int npcId)
{
return 12621 == npcId;
}
public static boolean isEvolvedWolf(int npcId)
{
switch(npcId)
{
case 16025:
case 16030:
case 16037:
case 16041:
case 16042:
return true;
}
return false;
}
public static boolean isBaby(int npcId)
{
return 12780 == npcId || 12781 == npcId || 12782 == npcId;
}
public static boolean isImprovedBaby(int npcId)
{
return 16034 == npcId || 16035 == npcId || 16036 == npcId;
}
public static boolean isSinEater(int npcId)
{
return npcId == 12564;
}
public static boolean isHorse(int npcId)
{
return 13130 == npcId || 43130 == npcId || 43131 == npcId || 43132 == npcId || 43133 == npcId || 43134 == npcId;
}
private static final Log _log = LogFactory.getLog(net/l2emuproject/gameserver/datatables/PetDataTable.getName());
private static PetDataTable _instance;
public static final int PET_WOLF_ID = 12077;
public static final int HATCHLING_WIND_ID = 12311;
public static final int HATCHLING_STAR_ID = 12312;
public static final int HATCHLING_TWILIGHT_ID = 12313;
public static final int STRIDER_WIND_ID = 12526;
public static final int STRIDER_STAR_ID = 12527;
public static final int STRIDER_TWILIGHT_ID = 12528;
public static final int RED_STRIDER_WIND_ID = 16038;
public static final int RED_STRIDER_STAR_ID = 16039;
public static final int RED_STRIDER_TWILIGHT_ID = 16040;
public static final int WYVERN_ID = 12621;
public static final int BABY_BUFFALO_ID = 12780;
public static final int BABY_KOOKABURRA_ID = 12781;
public static final int BABY_COUGAR_ID = 12782;
public static final int IMPROVED_BABY_BUFFALO_ID = 16034;
public static final int IMPROVED_BABY_KOOKABURRA_ID = 16035;
public static final int IMPROVED_BABY_COUGAR_ID = 16036;
public static final int SIN_EATER_ID = 12564;
public static final int BLACK_WOLF_ID = 16030;
public static final int WGREAT_WOLF_ID = 16037;
public static final int GREAT_WOLF_ID = 16025;
public static final int FENRIR_WOLF_ID = 16041;
public static final int WFENRIR_WOLF_ID = 16042;
public static final int PURPLE_HORSE_ID = 13130;
public static final int PURPLE_HORSE_ID = 43130;
public static final int PURPLE_HORSE_ID = 43131;
public static final int PURPLE_HORSE_ID = 43132;
public static final int PURPLE_HORSE_ID = 43133;
public static final int PURPLE_HORSE_ID = 43134;
private static FastMap petTable;
public static final int EMPTY_INT[] = {
0
};
}
Вот что я сделал красным это правильно ???