Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package l2.ae.pvp.gameserver.datatables;
- import java.io.BufferedReader;
- import java.io.File;
- import java.io.FileReader;
- import java.util.HashMap;
- import java.util.Map;
- import java.util.logging.Logger;
- import l2.ae.pvp.gameserver.GameServer;
- public class IconsTable
- {
- private static final Map<Integer, String> itemIcons = new HashMap<>();
- private static final Map<Integer, String> skillIcons = new HashMap<>();
- private static final Logger _log = Logger.getLogger(GameServer.class.getName());
- protected IconsTable()
- {
- parseData();
- }
- public void reload()
- {
- itemIcons.clear();
- // skillIcons.clear();
- parseData();
- }
- public static void parseData()
- {
- final long t0 = System.currentTimeMillis();
- try
- {
- loadItemIcons();
- // not needed loadSkillIcons();
- final long t = System.currentTimeMillis() - t0;
- _log.config("IconsTable: Succesfully loaded " + (itemIcons.size() + skillIcons.size()) + " icons, in " + t + " Milliseconds.");
- }
- catch (final Exception e)
- {
- _log.config("IconsTable: Failed loading IconsTable. Possible error: " + e.getMessage());
- e.printStackTrace();
- }
- }
- private static void loadItemIcons() throws Exception
- {
- final File f = new File("./data/icons.xml");
- try (final BufferedReader br = new BufferedReader(new FileReader(f)))
- {
- String line = null;
- while ((line=br.readLine()) != null)
- {
- String[] explode = line.split("\t");
- if (explode.length > 1)
- {
- final int id = Integer.parseInt(explode[0]);
- itemIcons.put(id, explode[1]);
- }
- }
- }
- }
- /**
- * @param id the requested itemId
- * @return the String value of the Icon of the given itemId.
- */
- public static String getItemIcon(final int id)
- {
- final String ico = itemIcons.get(id);
- if (ico == null)
- {
- _log.config("IconsTable: Invalid Item-Icon request: " + id + ", or it doesn't exist, Ignoring ...");
- return "l2aerogamingicons.pvp_weapons";
- }
- return ico;
- }
- /**
- * @param id the requested skillId
- * @return the String value of the Icon of the given itemId.
- */
- public static String getSkillIcon(final int id)
- {
- final String ico = skillIcons.get(id);
- if (ico == null)
- {
- _log.config("IconsTable: Invalid Skill-Icon request: " + id + ", or it doesn't exist, Ignoring ...");
- return "icon.skill1050";
- }
- return ico;
- }
- public static final IconsTable getInstance()
- {
- return SingletonHolder._instance;
- }
- private static class SingletonHolder
- {
- protected static final IconsTable _instance = new IconsTable();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement