Changeset 5163
- Timestamp:
- Jan 31, 2012 5:02:59 PM (4 months ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/unstable/L2J_Server_BETA/java/com/l2jserver/gameserver/datatables/NpcTable.java
r5146 r5163 47 47 public class NpcTable 48 48 { 49 private static Logger _log = Logger.getLogger(NpcTable.class.getName());49 private static final Logger _log = Logger.getLogger(NpcTable.class.getName()); 50 50 51 51 private final TIntObjectHashMap<L2NpcTemplate> _npcs = new TIntObjectHashMap<L2NpcTemplate>(); 52 53 public static NpcTable getInstance()54 {55 return SingletonHolder._instance;56 }57 52 58 53 private NpcTable() … … 216 211 catch (Exception e) 217 212 { 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); 219 214 } 220 215 } … … 287 282 catch (Exception e) 288 283 { 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); 290 285 } 291 286 finally … … 505 500 } 506 501 507 _log.info( "NpcTable: Loaded " + cont + " (Custom: " + cCont + ") NPC template(s).");502 _log.info(getClass().getSimpleName() + ": Loaded " + cont + " (Custom: " + cCont + ") NPC template(s)."); 508 503 } 509 504 catch (Exception e) 510 505 { 511 _log.log(Level.SEVERE, "NPCTable: Error creating NPC table.", e);506 _log.log(Level.SEVERE, getClass().getSimpleName() + ": Error creating NPC table.", e); 512 507 } 513 508 finally … … 553 548 if (npcDat == null) 554 549 { 555 _log.warning( "NPCTable: Skill data for undefined NPC. npcId: " + mobId);550 _log.warning(getClass().getSimpleName() + ": Skill data for undefined NPC. npcId: " + mobId); 556 551 continue; 557 552 } … … 598 593 if (npcDat == null) 599 594 { 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); 601 596 continue; 602 597 } … … 626 621 } 627 622 628 _log.info( "NpcTable: Loaded " + cont + " (Custom: " + cCont + ") npc skills.");623 _log.info(getClass().getSimpleName() + ": Loaded " + cont + " (Custom: " + cCont + ") npc skills."); 629 624 } 630 625 catch (Exception e) 631 626 { 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); 633 628 } 634 629 finally … … 673 668 if (npcDat == null) 674 669 { 675 _log.warning( "NPCTable: Drop data for undefined NPC. npcId: " + mobId);670 _log.warning(getClass().getSimpleName() + ": Drop data for undefined NPC. npcId: " + mobId); 676 671 continue; 677 672 } … … 687 682 if (ItemTable.getInstance().getTemplate(dropDat.getItemId()) == null) 688 683 { 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()); 690 685 continue; 691 686 } … … 710 705 711 706 rset = statement.executeQuery(); 712 707 int mobId; 708 int category; 713 709 while (rset.next()) 714 710 { 715 intmobId = rset.getInt("mobId");711 mobId = rset.getInt("mobId"); 716 712 npcDat = _npcs.get(mobId); 717 713 if (npcDat == null) 718 714 { 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); 720 716 continue; 721 717 } 718 722 719 dropDat = new L2DropData(); 723 720 dropDat.setItemId(rset.getInt("itemId")); … … 725 722 dropDat.setMaxDrop(rset.getInt("max")); 726 723 dropDat.setChance(rset.getInt("chance")); 727 intcategory = rset.getInt("category");724 category = rset.getInt("category"); 728 725 729 726 if (ItemTable.getInstance().getTemplate(dropDat.getItemId()) == null) 730 727 { 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()); 732 729 continue; 733 730 } … … 739 736 statement.close(); 740 737 } 741 _log.info( "NpcTable: Loaded " + cont + " (Custom: " + cCont + ") drops.");738 _log.info(getClass().getSimpleName() + ": Loaded " + cont + " (Custom: " + cCont + ") drops."); 742 739 } 743 740 catch (Exception e) 744 741 { 745 _log.log(Level.SEVERE, "NPCTable: Error reading NPC dropdata. ", e);742 _log.log(Level.SEVERE, getClass().getSimpleName() + ": Error reading NPC dropdata. ", e); 746 743 } 747 744 finally … … 776 773 777 774 int cont = 0; 778 775 int npcId; 776 int classId; 777 L2NpcTemplate npc; 779 778 while (rset.next()) 780 779 { 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); 785 783 if (npc == null) 786 784 { 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."); 788 786 continue; 789 787 } 788 790 789 cont++; 791 790 npc.addTeachInfo(ClassId.values()[classId]); … … 795 794 statement.close(); 796 795 797 _log.info( "NpcTable: Loaded " + cont + " Skill Learn.");796 _log.info(getClass().getSimpleName() + ": Loaded " + cont + " Skill Learn."); 798 797 } 799 798 catch (Exception e) 800 799 { 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); 802 801 } 803 802 finally … … 834 833 L2NpcTemplate npcDat = null; 835 834 int cnt = 0; 836 835 int raidId; 837 836 while (rset.next()) 838 837 { 839 intraidId = rset.getInt("boss_id");838 raidId = rset.getInt("boss_id"); 840 839 npcDat = _npcs.get(raidId); 841 840 if (npcDat == null) 842 841 { 843 _log.warning( "Minion references undefined boss NPC. Boss NpcId: " + raidId);842 _log.warning(getClass().getSimpleName() + ": Minion references undefined boss NPC. Boss NpcId: " + raidId); 844 843 continue; 845 844 } 845 846 846 minionDat = new L2MinionData(); 847 847 minionDat.setMinionId(rset.getInt("minion_id")); … … 854 854 rset.close(); 855 855 statement.close(); 856 _log.info( "NpcTable: Loaded " + cnt + " Minions.");856 _log.info(getClass().getSimpleName() + ": Loaded " + cnt + " Minions."); 857 857 } 858 858 catch (Exception e) 859 859 { 860 _log.log(Level.SEVERE, "NPCTable: Error loading minion data.", e);860 _log.log(Level.SEVERE, getClass().getSimpleName() + ": Error loading minion data.", e); 861 861 } 862 862 finally … … 895 895 int cont = 0; 896 896 int cCont = 0; 897 897 int npcId; 898 898 while (rset.next()) 899 899 { 900 int npc_id = rset.getInt("npcId");901 npcDat = _npcs.get(npc _id);900 npcId = rset.getInt("npcId"); 901 npcDat = _npcs.get(npcId); 902 902 if (npcDat == null) 903 903 { 904 _log.severe( "NPCTable: AI Data Error with id : " + npc_id);904 _log.severe(getClass().getSimpleName() + ": AI Data Error with id : " + npcId); 905 905 continue; 906 906 } … … 950 950 951 951 rset = statement.executeQuery(); 952 953 952 while (rset.next()) 954 953 { 955 int npc_id = rset.getInt("npcId");956 npcDat = _npcs.get(npc _id);954 npcId = rset.getInt("npcId"); 955 npcDat = _npcs.get(npcId); 957 956 if (npcDat == null) 958 957 { 959 _log.severe( "NPCTable: Custom AI Data Error with id : " + npc_id);958 _log.severe(getClass().getSimpleName() + ": Custom AI Data Error with id : " + npcId); 960 959 continue; 961 960 } … … 993 992 } 994 993 995 _log.info( "NpcTable: Loaded " + cont + " (Custom: " + cCont + ") AI Data.");994 _log.info(getClass().getSimpleName() + ": Loaded " + cont + " (Custom: " + cCont + ") AI Data."); 996 995 } 997 996 catch (Exception e) 998 997 { 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); 1000 999 } 1001 1000 finally … … 1031 1030 int cont = 0; 1032 1031 int cCount = 0; 1033 1032 int npcId; 1034 1033 while (rset.next()) 1035 1034 { 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); 1038 1037 if (npcDat == null) 1039 1038 { 1040 _log.severe("NPCElementals: Elementals Error with id : " + npc _id);1039 _log.severe("NPCElementals: Elementals Error with id : " + npcId); 1041 1040 continue; 1042 1041 } … … 1062 1061 break; 1063 1062 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")); 1065 1064 continue; 1066 1065 } … … 1093 1092 while (rset.next()) 1094 1093 { 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); 1097 1096 if (npcDat == null) 1098 1097 { 1099 _log.severe("NPCElementals: Custom Elementals Error with id : " + npc _id);1098 _log.severe("NPCElementals: Custom Elementals Error with id : " + npcId); 1100 1099 continue; 1101 1100 } … … 1121 1120 break; 1122 1121 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")); 1124 1123 continue; 1125 1124 } … … 1136 1135 } 1137 1136 1138 _log.info( "NpcTable: Loaded " + cont + " (Custom: " + cCount + ") elementals Data.");1137 _log.info(getClass().getSimpleName() + ": Loaded " + cont + " (Custom: " + cCount + ") elementals Data."); 1139 1138 } 1140 1139 catch (Exception e) 1141 1140 { 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); 1143 1142 } 1144 1143 finally … … 1146 1145 L2DatabaseFactory.close(con); 1147 1146 } 1147 } 1148 1149 public static NpcTable getInstance() 1150 { 1151 return SingletonHolder._instance; 1148 1152 } 1149 1153
Note: See TracChangeset
for help on using the changeset viewer.
