Index: java/net/sf/l2j/gameserver/datatables/FeanorTable.java
===================================================================
@@ -0,0 +1,138 @@
--- java/net/sf/l2j/gameserver/datatables/FeanorTable.java (revision 01)
+++ java/net/sf/l2j/gameserver/datatables/FeanorTable.java (working copy)
+/*
+ * This program is free software: you can redistribute it and/or modify it under
+ * the terms of the GNU General Public License as published by the Free Software
+ * Foundation, either version 3 of the License, or (at your option) any later
+ * version.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
+ * details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+package net.sf.l2j.gameserver.datatables;
+
+import java.io.File;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.logging.Logger;
+
+import net.sf.l2j.gameserver.model.item.DropCategory;
+import net.sf.l2j.gameserver.model.item.DropData;
+import net.sf.l2j.gameserver.xmlfactory.XMLDocumentFactory;
+
+import org.w3c.dom.Document;
+import org.w3c.dom.NamedNodeMap;
+import org.w3c.dom.Node;
+
+/**
+ * @author williams
+ *
+ */
+public class FeanorTable
+{
+ private static Logger _log = Logger.getLogger(FeanorTable.class.getName());
+
+ private final Map<Integer, List<DropCategory>> _feanor = new HashMap<>();
+
+ protected FeanorTable()
+ {
+ try
+ {
+ File file = new File("./data/xml/feanor.xml");
+ Document doc = XMLDocumentFactory.getInstance().loadDocument(file);
+
+ Node n = doc.getFirstChild();
+ for (Node d = n.getFirstChild(); d != null; d = d.getNextSibling())
+ {
+ if ("feanor".equalsIgnoreCase(d.getNodeName()))
+ {
+ NamedNodeMap attrs = d.getAttributes();
+ int feanorId = Integer.parseInt(attrs.getNamedItem("id").getNodeValue());
+
+ List<DropCategory> category;
+ if (_feanor.containsKey(feanorId))
+ category = _feanor.get(feanorId);
+ else
+ {
+ category = new ArrayList<>();
+ _feanor.put(feanorId, category);
+ }
+
+ for (Node cd = d.getFirstChild(); cd != null; cd = cd.getNextSibling())
+ {
+ DropData dropDat = new DropData();
+ if ("item".equalsIgnoreCase(cd.getNodeName()))
+ {
+ attrs = cd.getAttributes();
+ int id = Integer.parseInt(attrs.getNamedItem("id").getNodeValue());
+ int categoryType = Integer.parseInt(attrs.getNamedItem("category").getNodeValue());
+ int minDrop = Integer.parseInt(attrs.getNamedItem("minDrop").getNodeValue());
+ int maxDrop = Integer.parseInt(attrs.getNamedItem("maxDrop").getNodeValue());
+ int chance = Integer.parseInt(attrs.getNamedItem("chance").getNodeValue());
+
+ dropDat.setItemId(id);
+ dropDat.setMinDrop(minDrop);
+ dropDat.setMaxDrop(maxDrop);
+ dropDat.setChance(chance);
+
+ if (ItemTable.getInstance().getTemplate(dropDat.getItemId()) == null)
+ {
+ _log.warning("FeanorTable: FeanorTable data for undefined item template! feanorId: " + feanorId + ", itemId: " + dropDat.getItemId());
+ continue;
+ }
+
+ boolean catExists = false;
+ for (DropCategory cat : category)
+ {
+ // if the category exists, add the drop to this category.
+ if (cat.getCategoryType() == categoryType)
+ {
+ cat.addDropData(dropDat, false);
+ catExists = true;
+ break;
+ }
+ }
+
+ // if the category doesn't exit, create it and add the drop
+ if (!catExists)
+ {
+ DropCategory cat = new DropCategory(categoryType);
+ cat.addDropData(dropDat, false);
+ category.add(cat);
+ }
+ }
+ }
+ }
+ }
+ }
+ catch (Exception e)
+ {
+ _log.warning("FeanorTable: Error while creating table: " + e);
+ }
+ _log.info("FeanorTable: Loaded " + _feanor.size() + " drops feanor.");
+ }
+
+ public List<DropCategory> getTemplate(int feanorId)
+ {
+ return _feanor.get(feanorId);
+ }
+
+ public static FeanorTable getInstance()
+ {
+ return SingletonHolder._instance;
+ }
+
+ private static class SingletonHolder
+ {
+ protected static final FeanorTable _instance = new FeanorTable();
+ }
+}
### Eclipse Workspace Patch 1.0
#P aCis_datapack
Index: data/xml/feanor.xml
===================================================================
--- data/xml/feanor.xml (révision 1)
+++ data/xml/feanor.xml (révision 2)
@@ -0,564 +1,8 @@
<?xml version='1.0' encoding='utf-8'?>
<list>
<group id="1"><!-- Autor Williams -->
<item id="3470" category="7" chance="30000" />>
</group>
</list>
Get the maximum opportunities, income, and profit with our verification.
We help you pass verification on the services and applications you need, opening access to full functionality and scaling.
Fast. Reliable. Secure.
Minimal risks — predictable results.
Bonus for new clients:
Pay for the first verification and get a 10% discount on the next one.
Learn more — Go to
Question
l2jkain
0 answers to this question
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now