SHOW:
|
|
- or go back to the newest paste.
1 | ### Eclipse Workspace Patch 1.0 | |
2 | #P aCis_gameserver | |
3 | Index: java/net/sf/l2j/gameserver/GameServer.java | |
4 | =================================================================== | |
5 | --- java/net/sf/l2j/gameserver/GameServer.java (revision 121) | |
6 | +++ java/net/sf/l2j/gameserver/GameServer.java (working copy) | |
7 | @@ -49,6 +49,7 @@ | |
8 | import net.sf.l2j.gameserver.datatables.ClanTable; | |
9 | import net.sf.l2j.gameserver.datatables.DoorTable; | |
10 | import net.sf.l2j.gameserver.datatables.EnchantTable; | |
11 | +import net.sf.l2j.gameserver.datatables.FeanorTable; | |
12 | import net.sf.l2j.gameserver.datatables.FishTable; | |
13 | import net.sf.l2j.gameserver.datatables.GmListTable; | |
14 | import net.sf.l2j.gameserver.datatables.HelperBuffTable; | |
15 | @@ -193,6 +194,7 @@ | |
16 | CursedWeaponsManager.getInstance(); | |
17 | EnchantTable.getInstance(); | |
18 | AuctionTable.getInstance(); | |
19 | + FeanorTable.getInstance(); | |
20 | ||
21 | StringUtil.printSection("Admins"); | |
22 | AccessLevels.getInstance(); | |
23 | Index: java/net/sf/l2j/gameserver/datatables/FeanorTable.java | |
24 | =================================================================== | |
25 | @@ -0,0 +1,138 @@ | |
26 | --- java/net/sf/l2j/gameserver/datatables/FeanorTable.java (revision 01) | |
27 | +++ java/net/sf/l2j/gameserver/datatables/FeanorTable.java (working copy) | |
28 | +/* | |
29 | +* This program is free software: you can redistribute it and/or modify it under | |
30 | +* the terms of the GNU General Public License as published by the Free Software | |
31 | +* Foundation, either version 3 of the License, or (at your option) any later | |
32 | +* version. | |
33 | +* | |
34 | +* This program is distributed in the hope that it will be useful, but WITHOUT | |
35 | +* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS | |
36 | +* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more | |
37 | +* details. | |
38 | +* | |
39 | +* You should have received a copy of the GNU General Public License along with | |
40 | +* this program. If not, see <http://www.gnu.org/licenses/>. | |
41 | +*/ | |
42 | +package net.sf.l2j.gameserver.datatables; | |
43 | + | |
44 | +import java.io.File; | |
45 | +import java.util.ArrayList; | |
46 | +import java.util.Collection; | |
47 | +import java.util.HashMap; | |
48 | +import java.util.List; | |
49 | +import java.util.Map; | |
50 | +import java.util.logging.Level; | |
51 | +import java.util.logging.Logger; | |
52 | + | |
53 | +import net.sf.l2j.gameserver.model.actor.template.NpcTemplate; | |
54 | +import net.sf.l2j.gameserver.model.item.DropCategory; | |
55 | +import net.sf.l2j.gameserver.model.item.DropData; | |
56 | +import net.sf.l2j.gameserver.templates.StatsSet; | |
57 | +import net.sf.l2j.gameserver.xmlfactory.XMLDocumentFactory; | |
58 | + | |
59 | +import org.w3c.dom.Document; | |
60 | +import org.w3c.dom.NamedNodeMap; | |
61 | +import org.w3c.dom.Node; | |
62 | + | |
63 | + | |
64 | +/** | |
65 | + * @author williams | |
66 | + * | |
67 | + */ | |
68 | +public class FeanorTable | |
69 | +{ | |
70 | + private static final Logger _log = Logger.getLogger(FeanorTable.class.getName()); | |
71 | + | |
72 | + private final Map<Integer, NpcTemplate> _feanor = new HashMap<>(); | |
73 | + | |
74 | + protected FeanorTable() | |
75 | + { | |
76 | + load(); | |
77 | + } | |
78 | + | |
79 | + public void reloadAllNpc() | |
80 | + { | |
81 | + _feanor.clear(); | |
82 | + load(); | |
83 | + } | |
84 | + | |
85 | + private void load() | |
86 | + { | |
87 | + try | |
88 | + { | |
89 | + final File dir = new File("./data/xml/feanor.xml"); | |
90 | + final StatsSet set = new StatsSet(); | |
91 | + | |
92 | + for (File file : dir.listFiles()) | |
93 | + { | |
94 | + final Document doc = XMLDocumentFactory.getInstance().loadDocument(file); | |
95 | + | |
96 | + Node list = doc.getFirstChild(); | |
97 | + for (Node feanor = list.getFirstChild(); feanor != null; feanor = feanor.getNextSibling()) | |
98 | + { | |
99 | + NamedNodeMap attrs = feanor.getAttributes(); | |
100 | + | |
101 | + if ("feanor".equalsIgnoreCase(feanor.getNodeName())) | |
102 | + { | |
103 | + final String type = set.getString("type"); | |
104 | + final boolean isRaid = type.equalsIgnoreCase("L2RaidBoss") || type.equalsIgnoreCase("L2GrandBoss"); | |
105 | + final List<DropCategory> drops = new ArrayList<>(); | |
106 | + final DropCategory category = new DropCategory(Integer.parseInt(attrs.getNamedItem("id").getNodeValue())); | |
107 | + | |
108 | + for (Node dropCat = feanor.getFirstChild(); dropCat != null; dropCat = dropCat.getNextSibling()) | |
109 | + { | |
110 | + if ("category".equalsIgnoreCase(dropCat.getNodeName())) | |
111 | + { | |
112 | + attrs = feanor.getAttributes(); | |
113 | + | |
114 | + for (Node item = dropCat.getFirstChild(); item != null; item = item.getNextSibling()) | |
115 | + { | |
116 | + if ("drop".equalsIgnoreCase(item.getNodeName())) | |
117 | + { | |
118 | + attrs = item.getAttributes(); | |
119 | + | |
120 | + final DropData data = new DropData(); | |
121 | + data.setItemId(Integer.parseInt(attrs.getNamedItem("itemid").getNodeValue())); | |
122 | + data.setMinDrop(Integer.parseInt(attrs.getNamedItem("min").getNodeValue())); | |
123 | + data.setMaxDrop(Integer.parseInt(attrs.getNamedItem("max").getNodeValue())); | |
124 | + data.setChance(Integer.parseInt(attrs.getNamedItem("chance").getNodeValue())); | |
125 | + | |
126 | + if (ItemTable.getInstance().getTemplate(data.getItemId()) == null) | |
127 | + { | |
128 | + _log.warning("Droplist data for undefined itemId: " + data.getItemId()); | |
129 | + continue; | |
130 | + } | |
131 | + category.addDropData(data, isRaid); | |
132 | + } | |
133 | + } | |
134 | + drops.add(category); | |
135 | + } | |
136 | + } | |
137 | + set.set("feanor", drops); | |
138 | + } | |
139 | + else if ("teachTo".equalsIgnoreCase(feanor.getNodeName())) | |
140 | + set.set("teachTo", feanor.getAttributes().getNamedItem("classes").getNodeValue()); | |
141 | + } | |
142 | + } | |
143 | + } | |
144 | + catch (Exception e) | |
145 | + { | |
146 | + _log.log(Level.SEVERE, "FeanorTable: Error parsing Feanor Table : ", e); | |
147 | + } | |
148 | + _log.info("FeanorTable: Loaded " + _feanor.size() + " Feanor Table."); | |
149 | + } | |
150 | + | |
151 | + public Collection<NpcTemplate> getAllNpcs() | |
152 | + { | |
153 | + return _feanor.values(); | |
154 | + } | |
155 | + | |
156 | + public static FeanorTable getInstance() | |
157 | + { | |
158 | + return SingletonHolder._instance; | |
159 | + } | |
160 | + | |
161 | + private static class SingletonHolder | |
162 | + { | |
163 | + protected static final FeanorTable _instance = new FeanorTable(); | |
164 | + } | |
165 | +} | |
166 | ### Eclipse Workspace Patch 1.0 | |
167 | #P aCis_datapack | |
168 | Index: data/xml/feanor.xml | |
169 | =================================================================== | |
170 | --- data/xml/feanor.xml (révision 1) | |
171 | +++ data/xml/feanor.xml (révision 2) | |
172 | @@ -0,564 +1,8 @@ | |
173 | <!-- | |
174 | @author williams | |
175 | --> | |
176 | +<?xml version="1.0" encoding="UTF-8"?> | |
177 | +<list> | |
178 | + <drops> | |
179 | + <category id="1"> | |
180 | + <drop itemid="3470" min="1" max="1" chance="100" /> | |
181 | + </category> | |
182 | + </drops> | |
183 | +</list> |