Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- diff --git a/java/net/sf/l2j/gameserver/GameServer.java b/java/net/sf/l2j/gameserver/GameServer.java
- index fd6397d..23c0401 100644
- --- a/java/net/sf/l2j/gameserver/GameServer.java
- +++ b/java/net/sf/l2j/gameserver/GameServer.java
- @@ -39,6 +39,7 @@
- import net.sf.l2j.gameserver.data.manager.LotteryManager;
- import net.sf.l2j.gameserver.data.manager.PartyMatchRoomManager;
- import net.sf.l2j.gameserver.data.manager.PetitionManager;
- import net.sf.l2j.gameserver.data.manager.RaidBossManager;
- import net.sf.l2j.gameserver.data.manager.RaidPointManager;
- import net.sf.l2j.gameserver.data.manager.SevenSignsManager;
- @@ -57,6 +58,7 @@
- import net.sf.l2j.gameserver.data.xml.FishData;
- import net.sf.l2j.gameserver.data.xml.HennaData;
- import net.sf.l2j.gameserver.data.xml.HerbDropData;
- +import net.sf.l2j.gameserver.data.xml.IconTable;
- import net.sf.l2j.gameserver.data.xml.InstantTeleportData;
- import net.sf.l2j.gameserver.data.xml.ItemData;
- import net.sf.l2j.gameserver.data.xml.MapRegionData;
- @@ -209,6 +211,8 @@
- RandomAnimationTaskManager.getInstance();
- ShadowItemTaskManager.getInstance();
- WaterTaskManager.getInstance();
- + IconTable.getInstance();
- StringUtil.printSection("Auto Spawns");
- AutoSpawnTable.getInstance();
- \ No newline at end of file
- diff --git a/java/net/sf/l2j/gameserver/data/xml/IconTable.java b/java/net/sf/l2j/gameserver/data/xml/IconTable.java
- new file mode 100644
- index 0000000..131cdf8
- --- /dev/null
- +++ b/java/net/sf/l2j/gameserver/data/xml/IconTable.java
- @@ -0,0 +1,100 @@
- +/*
- + * 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.data.xml;
- +
- +import java.nio.file.Path;
- +import java.util.Map;
- +import java.util.concurrent.ConcurrentHashMap;
- +import java.util.logging.Level;
- +import java.util.logging.Logger;
- +
- +import net.sf.l2j.commons.data.xml.IXmlReader;
- +
- +import org.w3c.dom.Document;
- +import org.w3c.dom.NamedNodeMap;
- +import org.w3c.dom.Node;
- +
- +/**
- + *
- + * @author Sarada
- + *
- + */
- +public class IconTable implements IXmlReader
- +{
- + private static final Logger _log = Logger.getLogger(IconTable.class.getName());
- +
- + private static Map<Integer, String> _icons = new ConcurrentHashMap<>();
- +
- + public static final IconTable getInstance()
- + {
- + return SingletonHolder._instance;
- + }
- +
- + public IconTable()
- + {
- + load();
- + }
- + @Override
- + public void load()
- + {
- + parseFile("./data/xml/icons.xml");
- + LOGGER.info("Loaded " + _icons.size() + " icons.");
- + }
- + @Override
- + public void parseDocument(Document doc, Path path)
- + {
- + try
- + {
- + Node n = doc.getFirstChild();
- + for (Node d = n.getFirstChild(); d != null; d = d.getNextSibling())
- + {
- + if (d.getNodeName().equalsIgnoreCase("icon"))
- + {
- + NamedNodeMap attrs = d.getAttributes();
- +
- + int itemId = Integer.valueOf(attrs.getNamedItem("itemId").getNodeValue());
- + String iconName = attrs.getNamedItem("iconName").getNodeValue();
- +
- + if (itemId == 0 && itemId < 0)
- + {
- + _log.log(Level.WARNING, "Icon Table: itemId=\"" + itemId + "\" is not item ID, Ignoring it!");
- + continue;
- + }
- + _icons.put(itemId, iconName);
- + }
- + }
- + }
- + catch (Exception e)
- + {
- + _log.log(Level.WARNING, "Icon Table: Error loading from database: " + e.getMessage(), e);
- + }
- +
- + _log.info("Icon Table: Loaded " + _icons.size() + " icons.");
- + }
- +
- + public static String getIcon(int id)
- + {
- + if (_icons.get(id) == null)
- + return "icon.NOIMAGE";
- +
- + return _icons.get(id);
- + }
- +
- + private static class SingletonHolder
- + {
- + protected static final IconTable _instance = new IconTable();
- + }
- +
- +}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement