All pastes #46206 Raw Edit

Anonymous

public text v1 · immutable
#46206 ·published 2006-03-19 07:15 UTC
rendered paste body
    public void loadPetsData() 
    { 
    	java.sql.Connection con = null;
    	try
    	{
    		con = L2DatabaseFactory.getInstance().getConnection();
    		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 FROM pets_stats");
    		ResultSet rset = statement.executeQuery();
    		
    		int petId, petLevel;
    		while (rset.next())
    		{
    			petId = rset.getInt("typeID");
    			petLevel = rset.getInt("level");
    			
    			//build the petdata for this level
    			L2PetData petData = new L2PetData();
    			petData.setPetID(petId);
    			petData.setPetLevel(petLevel);
    			petData.setPetMaxExp(rset.getInt("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") ); 

                //if its the first data for this petId, we initialize its level FastMap
                if (!petTable.containsKey(petId))
    				petTable.put(petId, new FastMap<Integer, L2PetData>());
                
                petTable.get(petId).put(petLevel,petData);
    		}
    	}
    	catch (Exception e)
    	{
    		_log.warning("Could not load pets stats: "+ e);
    	}
    	finally
    	{
    		try { con.close(); } catch (Exception e) {}
    	}
    }