Changeset 5163


Ignore:
Timestamp:
Jan 31, 2012 5:02:59 PM (4 months ago)
Author:
Zoey76
Message:

BETA: Misc fixes:

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/unstable/L2J_Server_BETA/java/com/l2jserver/gameserver/datatables/NpcTable.java

    r5146 r5163  
    4747public class NpcTable 
    4848{ 
    49         private static Logger _log = Logger.getLogger(NpcTable.class.getName()); 
     49        private static final Logger _log = Logger.getLogger(NpcTable.class.getName()); 
    5050         
    5151        private final TIntObjectHashMap<L2NpcTemplate> _npcs = new TIntObjectHashMap<L2NpcTemplate>(); 
    52          
    53         public static NpcTable getInstance() 
    54         { 
    55                 return SingletonHolder._instance; 
    56         } 
    5752         
    5853        private NpcTable() 
     
    216211                catch (Exception e) 
    217212                { 
    218                         _log.log(Level.WARNING, "NPCTable: Could not reload data for NPC " + id + ": " + e.getMessage(), e); 
     213                        _log.log(Level.WARNING, getClass().getSimpleName() + ": Could not reload data for NPC " + id + ": " + e.getMessage(), e); 
    219214                } 
    220215        } 
     
    287282                catch (Exception e) 
    288283                { 
    289                         _log.log(Level.WARNING, "NPCTable: Could not store new NPC data in database: " + e.getMessage(), e); 
     284                        _log.log(Level.WARNING, getClass().getSimpleName() + ": Could not store new NPC data in database: " + e.getMessage(), e); 
    290285                } 
    291286                finally 
     
    505500                        } 
    506501                         
    507                         _log.info("NpcTable: Loaded " + cont + " (Custom: " + cCont + ") NPC template(s)."); 
     502                        _log.info(getClass().getSimpleName() + ": Loaded " + cont + " (Custom: " + cCont + ") NPC template(s)."); 
    508503                } 
    509504                catch (Exception e) 
    510505                { 
    511                         _log.log(Level.SEVERE, "NPCTable: Error creating NPC table.", e); 
     506                        _log.log(Level.SEVERE, getClass().getSimpleName() + ": Error creating NPC table.", e); 
    512507                } 
    513508                finally 
     
    553548                                if (npcDat == null) 
    554549                                { 
    555                                         _log.warning("NPCTable: Skill data for undefined NPC. npcId: " + mobId); 
     550                                        _log.warning(getClass().getSimpleName() + ": Skill data for undefined NPC. npcId: " + mobId); 
    556551                                        continue; 
    557552                                } 
     
    598593                                        if (npcDat == null) 
    599594                                        { 
    600                                                 _log.warning("Custom NPCTable: Skill data for undefined NPC. npcId: " + mobId); 
     595                                                _log.warning("Custom " + getClass().getSimpleName() + ": Skill data for undefined NPC. npcId: " + mobId); 
    601596                                                continue; 
    602597                                        } 
     
    626621                        } 
    627622                         
    628                         _log.info("NpcTable: Loaded " + cont + " (Custom: " + cCont + ") npc skills."); 
     623                        _log.info(getClass().getSimpleName() + ": Loaded " + cont + " (Custom: " + cCont + ") npc skills."); 
    629624                } 
    630625                catch (Exception e) 
    631626                { 
    632                         _log.log(Level.SEVERE, "NPCTable: Error reading NPC skills table.", e); 
     627                        _log.log(Level.SEVERE, getClass().getSimpleName() + ": Error reading NPC skills table.", e); 
    633628                } 
    634629                finally 
     
    673668                                if (npcDat == null) 
    674669                                { 
    675                                         _log.warning("NPCTable: Drop data for undefined NPC. npcId: " + mobId); 
     670                                        _log.warning(getClass().getSimpleName() + ": Drop data for undefined NPC. npcId: " + mobId); 
    676671                                        continue; 
    677672                                } 
     
    687682                                if (ItemTable.getInstance().getTemplate(dropDat.getItemId()) == null) 
    688683                                { 
    689                                         _log.warning("Drop data for undefined item template! NpcId: " + mobId + " itemId: " + dropDat.getItemId()); 
     684                                        _log.warning(getClass().getSimpleName() + ": Drop data for undefined item template! NpcId: " + mobId + " itemId: " + dropDat.getItemId()); 
    690685                                        continue; 
    691686                                } 
     
    710705                                 
    711706                                rset = statement.executeQuery(); 
    712                                  
     707                                int mobId; 
     708                                int category; 
    713709                                while (rset.next()) 
    714710                                { 
    715                                         int mobId = rset.getInt("mobId"); 
     711                                        mobId = rset.getInt("mobId"); 
    716712                                        npcDat = _npcs.get(mobId); 
    717713                                        if (npcDat == null) 
    718714                                        { 
    719                                                 _log.warning("NPCTable: CUSTOM DROPLIST: Drop data for undefined NPC. npcId: " + mobId); 
     715                                                _log.warning(getClass().getSimpleName() + ": CUSTOM DROPLIST: Drop data for undefined NPC. npcId: " + mobId); 
    720716                                                continue; 
    721717                                        } 
     718                                         
    722719                                        dropDat = new L2DropData(); 
    723720                                        dropDat.setItemId(rset.getInt("itemId")); 
     
    725722                                        dropDat.setMaxDrop(rset.getInt("max")); 
    726723                                        dropDat.setChance(rset.getInt("chance")); 
    727                                         int category = rset.getInt("category"); 
     724                                        category = rset.getInt("category"); 
    728725                                         
    729726                                        if (ItemTable.getInstance().getTemplate(dropDat.getItemId()) == null) 
    730727                                        { 
    731                                                 _log.warning("Custom drop data for undefined item template! NpcId: " + mobId + " itemId: " + dropDat.getItemId()); 
     728                                                _log.warning(getClass().getSimpleName() + ": Custom drop data for undefined item template! NpcId: " + mobId + " itemId: " + dropDat.getItemId()); 
    732729                                                continue; 
    733730                                        } 
     
    739736                                statement.close(); 
    740737                        } 
    741                         _log.info("NpcTable: Loaded " + cont + " (Custom: " + cCont + ") drops."); 
     738                        _log.info(getClass().getSimpleName() + ": Loaded " + cont + " (Custom: " + cCont + ") drops."); 
    742739                } 
    743740                catch (Exception e) 
    744741                { 
    745                         _log.log(Level.SEVERE, "NPCTable: Error reading NPC dropdata. ", e); 
     742                        _log.log(Level.SEVERE, getClass().getSimpleName() + ": Error reading NPC dropdata. ", e); 
    746743                } 
    747744                finally 
     
    776773                         
    777774                        int cont = 0; 
    778                          
     775                        int npcId; 
     776                        int classId; 
     777                        L2NpcTemplate npc; 
    779778                        while (rset.next()) 
    780779                        { 
    781                                 int npcId = rset.getInt("npc_id"); 
    782                                 int classId = rset.getInt("class_id"); 
    783                                 L2NpcTemplate npc = getTemplate(npcId); 
    784                                  
     780                                npcId = rset.getInt("npc_id"); 
     781                                classId = rset.getInt("class_id"); 
     782                                npc = getTemplate(npcId); 
    785783                                if (npc == null) 
    786784                                { 
    787                                         _log.warning("NPCTable: Error getting NPC template ID " + npcId + " while trying to load skill trainer data."); 
     785                                        _log.warning(getClass().getSimpleName() + ": Error getting NPC template ID " + npcId + " while trying to load skill trainer data."); 
    788786                                        continue; 
    789787                                } 
     788                                 
    790789                                cont++; 
    791790                                npc.addTeachInfo(ClassId.values()[classId]); 
     
    795794                        statement.close(); 
    796795                         
    797                         _log.info("NpcTable: Loaded " + cont + " Skill Learn."); 
     796                        _log.info(getClass().getSimpleName() + ": Loaded " + cont + " Skill Learn."); 
    798797                } 
    799798                catch (Exception e) 
    800799                { 
    801                         _log.log(Level.SEVERE, "NPCTable: Error reading NPC trainer data.", e); 
     800                        _log.log(Level.SEVERE, getClass().getSimpleName() + ": Error reading NPC trainer data.", e); 
    802801                } 
    803802                finally 
     
    834833                        L2NpcTemplate npcDat = null; 
    835834                        int cnt = 0; 
    836                          
     835                        int raidId; 
    837836                        while (rset.next()) 
    838837                        { 
    839                                 int raidId = rset.getInt("boss_id"); 
     838                                raidId = rset.getInt("boss_id"); 
    840839                                npcDat = _npcs.get(raidId); 
    841840                                if (npcDat == null) 
    842841                                { 
    843                                         _log.warning("Minion references undefined boss NPC. Boss NpcId: " + raidId); 
     842                                        _log.warning(getClass().getSimpleName() + ": Minion references undefined boss NPC. Boss NpcId: " + raidId); 
    844843                                        continue; 
    845844                                } 
     845                                 
    846846                                minionDat = new L2MinionData(); 
    847847                                minionDat.setMinionId(rset.getInt("minion_id")); 
     
    854854                        rset.close(); 
    855855                        statement.close(); 
    856                         _log.info("NpcTable: Loaded " + cnt + " Minions."); 
     856                        _log.info(getClass().getSimpleName() + ": Loaded " + cnt + " Minions."); 
    857857                } 
    858858                catch (Exception e) 
    859859                { 
    860                         _log.log(Level.SEVERE, "NPCTable: Error loading minion data.", e); 
     860                        _log.log(Level.SEVERE, getClass().getSimpleName() + ": Error loading minion data.", e); 
    861861                } 
    862862                finally 
     
    895895                        int cont = 0; 
    896896                        int cCont = 0; 
    897                          
     897                        int npcId; 
    898898                        while (rset.next()) 
    899899                        { 
    900                                 int npc_id = rset.getInt("npcId"); 
    901                                 npcDat = _npcs.get(npc_id); 
     900                                npcId = rset.getInt("npcId"); 
     901                                npcDat = _npcs.get(npcId); 
    902902                                if (npcDat == null) 
    903903                                { 
    904                                         _log.severe("NPCTable: AI Data Error with id : " + npc_id); 
     904                                        _log.severe(getClass().getSimpleName() + ": AI Data Error with id : " + npcId); 
    905905                                        continue; 
    906906                                } 
     
    950950                                 
    951951                                rset = statement.executeQuery(); 
    952                                  
    953952                                while (rset.next()) 
    954953                                { 
    955                                         int npc_id = rset.getInt("npcId"); 
    956                                         npcDat = _npcs.get(npc_id); 
     954                                        npcId = rset.getInt("npcId"); 
     955                                        npcDat = _npcs.get(npcId); 
    957956                                        if (npcDat == null) 
    958957                                        { 
    959                                                 _log.severe("NPCTable: Custom AI Data Error with id : " + npc_id); 
     958                                                _log.severe(getClass().getSimpleName() + ": Custom AI Data Error with id : " + npcId); 
    960959                                                continue; 
    961960                                        } 
     
    993992                        } 
    994993                         
    995                         _log.info("NpcTable: Loaded " + cont + " (Custom: " + cCont + ") AI Data."); 
     994                        _log.info(getClass().getSimpleName() + ": Loaded " + cont + " (Custom: " + cCont + ") AI Data."); 
    996995                } 
    997996                catch (Exception e) 
    998997                { 
    999                         _log.log(Level.SEVERE, "NPCTable: Error reading NPC AI Data: " + e.getMessage(), e); 
     998                        _log.log(Level.SEVERE, getClass().getSimpleName() + ": Error reading NPC AI Data: " + e.getMessage(), e); 
    1000999                } 
    10011000                finally 
     
    10311030                        int cont = 0; 
    10321031                        int cCount = 0; 
    1033                          
     1032                        int npcId; 
    10341033                        while (rset.next()) 
    10351034                        { 
    1036                                 int npc_id = rset.getInt("npc_id"); 
    1037                                 npcDat = _npcs.get(npc_id); 
     1035                                npcId = rset.getInt("npc_id"); 
     1036                                npcDat = _npcs.get(npcId); 
    10381037                                if (npcDat == null) 
    10391038                                { 
    1040                                         _log.severe("NPCElementals: Elementals Error with id : " + npc_id); 
     1039                                        _log.severe("NPCElementals: Elementals Error with id : " + npcId); 
    10411040                                        continue; 
    10421041                                } 
     
    10621061                                                break; 
    10631062                                        default: 
    1064                                                 _log.severe("NPCElementals: Elementals Error with id : " + npc_id + "; unknown elementType: " + rset.getByte("elemAtkType")); 
     1063                                                _log.severe("NPCElementals: Elementals Error with id : " + npcId + "; unknown elementType: " + rset.getByte("elemAtkType")); 
    10651064                                                continue; 
    10661065                                } 
     
    10931092                                while (rset.next()) 
    10941093                                { 
    1095                                         int npc_id = rset.getInt("npc_id"); 
    1096                                         npcDat = _npcs.get(npc_id); 
     1094                                        npcId = rset.getInt("npc_id"); 
     1095                                        npcDat = _npcs.get(npcId); 
    10971096                                        if (npcDat == null) 
    10981097                                        { 
    1099                                                 _log.severe("NPCElementals: Custom Elementals Error with id : " + npc_id); 
     1098                                                _log.severe("NPCElementals: Custom Elementals Error with id : " + npcId); 
    11001099                                                continue; 
    11011100                                        } 
     
    11211120                                                        break; 
    11221121                                                default: 
    1123                                                         _log.severe("NPCElementals: Custom Elementals Error with id : " + npc_id + "; unknown elementType: " + rset.getByte("elemAtkType")); 
     1122                                                        _log.severe("NPCElementals: Custom Elementals Error with id : " + npcId + "; unknown elementType: " + rset.getByte("elemAtkType")); 
    11241123                                                        continue; 
    11251124                                        } 
     
    11361135                        } 
    11371136                         
    1138                         _log.info("NpcTable: Loaded " + cont + " (Custom: " + cCount + ") elementals Data."); 
     1137                        _log.info(getClass().getSimpleName() + ": Loaded " + cont + " (Custom: " + cCount + ") elementals Data."); 
    11391138                } 
    11401139                catch (Exception e) 
    11411140                { 
    1142                         _log.log(Level.SEVERE, "NPCTable: Error reading NPC Elementals Data: " + e.getMessage(), e); 
     1141                        _log.log(Level.SEVERE, getClass().getSimpleName() + ": Error reading NPC Elementals Data: " + e.getMessage(), e); 
    11431142                } 
    11441143                finally 
     
    11461145                        L2DatabaseFactory.close(con); 
    11471146                } 
     1147        } 
     1148         
     1149        public static NpcTable getInstance() 
     1150        { 
     1151                return SingletonHolder._instance; 
    11481152        } 
    11491153         
Note: See TracChangeset for help on using the changeset viewer.