From 81d82a90acff18afd3164bf834a52f262161b2fa Mon Sep 17 00:00:00 2001 From: MobiusDev <8391001+MobiusDevelopment@users.noreply.github.com> Date: Tue, 3 Apr 2018 18:15:04 +0000 Subject: [PATCH] Updated IXmlReader to match newer branches. --- .../ai/npc/ForgeOfTheGods/TarBeetleSpawn.java | 13 +- .../ai/npc/NpcBuffers/NpcBuffersData.java | 7 +- .../scripts/hellbound/HellboundPointData.java | 7 +- .../scripts/hellbound/HellboundSpawns.java | 7 +- .../FinalEmperialTomb/FinalEmperialTomb.java | 7 +- .../dist/game/data/zones/no_bookmark.xml | 4 +- .../java/com/l2jmobius/Config.java | 37 +- .../commons/util/IGameXmlReader.java | 118 ++ .../l2jmobius/commons/util/IXmlReader.java | 1371 +++++++++-------- .../gameserver/LoginServerThread.java | 2 +- .../gameserver/data/xml/impl/AdminData.java | 7 +- .../data/xml/impl/ArmorSetsData.java | 7 +- .../gameserver/data/xml/impl/BuyListData.java | 4 +- .../data/xml/impl/CategoryData.java | 7 +- .../data/xml/impl/ClassListData.java | 7 +- .../gameserver/data/xml/impl/DoorData.java | 7 +- .../data/xml/impl/EnchantItemData.java | 7 +- .../data/xml/impl/EnchantItemGroupsData.java | 7 +- .../data/xml/impl/EnchantItemHPBonusData.java | 7 +- .../data/xml/impl/EnchantItemOptionsData.java | 7 +- .../data/xml/impl/EnchantSkillGroupsData.java | 7 +- .../data/xml/impl/ExperienceData.java | 7 +- .../gameserver/data/xml/impl/FishData.java | 7 +- .../data/xml/impl/FishingMonstersData.java | 7 +- .../data/xml/impl/FishingRodsData.java | 7 +- .../gameserver/data/xml/impl/HennaData.java | 7 +- .../data/xml/impl/HitConditionBonusData.java | 8 +- .../data/xml/impl/InitialEquipmentData.java | 7 +- .../data/xml/impl/InitialShortcutData.java | 7 +- .../data/xml/impl/ItemMallData.java | 7 +- .../gameserver/data/xml/impl/KarmaData.java | 7 +- .../data/xml/impl/MultisellData.java | 4 +- .../gameserver/data/xml/impl/NpcData.java | 8 +- .../gameserver/data/xml/impl/OptionData.java | 7 +- .../data/xml/impl/PetDataTable.java | 7 +- .../data/xml/impl/PetSkillData.java | 4 +- .../data/xml/impl/PlayerTemplateData.java | 7 +- .../xml/impl/PlayerXpPercentLostData.java | 7 +- .../gameserver/data/xml/impl/RecipeData.java | 7 +- .../data/xml/impl/SecondaryAuthData.java | 6 +- .../data/xml/impl/SiegeScheduleData.java | 7 +- .../data/xml/impl/SkillLearnData.java | 7 +- .../data/xml/impl/SkillTreesData.java | 7 +- .../data/xml/impl/StaticObjectData.java | 7 +- .../data/xml/impl/TransformData.java | 7 +- .../gameserver/data/xml/impl/UIData.java | 7 +- .../gameserver/datatables/SpawnTable.java | 7 +- .../instancemanager/CastleManorManager.java | 7 +- .../instancemanager/InstanceManager.java | 7 +- .../instancemanager/MapRegionManager.java | 7 +- .../instancemanager/WalkingManager.java | 7 +- .../instancemanager/ZoneManager.java | 4 +- .../gameserver/model/quest/Quest.java | 2 +- .../loginserver/GameServerTable.java | 22 +- 54 files changed, 1050 insertions(+), 830 deletions(-) create mode 100644 L2J_Mobius_CT_2.6_HighFive/java/com/l2jmobius/commons/util/IGameXmlReader.java diff --git a/L2J_Mobius_CT_2.6_HighFive/dist/game/data/scripts/ai/npc/ForgeOfTheGods/TarBeetleSpawn.java b/L2J_Mobius_CT_2.6_HighFive/dist/game/data/scripts/ai/npc/ForgeOfTheGods/TarBeetleSpawn.java index 0a55620761..dedc387414 100644 --- a/L2J_Mobius_CT_2.6_HighFive/dist/game/data/scripts/ai/npc/ForgeOfTheGods/TarBeetleSpawn.java +++ b/L2J_Mobius_CT_2.6_HighFive/dist/game/data/scripts/ai/npc/ForgeOfTheGods/TarBeetleSpawn.java @@ -16,6 +16,7 @@ */ package ai.npc.ForgeOfTheGods; +import java.io.File; import java.util.ArrayList; import java.util.List; import java.util.concurrent.CopyOnWriteArrayList; @@ -26,7 +27,7 @@ import org.w3c.dom.NamedNodeMap; import org.w3c.dom.Node; import com.l2jmobius.commons.concurrent.ThreadPool; -import com.l2jmobius.commons.util.IXmlReader; +import com.l2jmobius.commons.util.IGameXmlReader; import com.l2jmobius.commons.util.Rnd; import com.l2jmobius.gameserver.geoengine.GeoEngine; import com.l2jmobius.gameserver.model.L2Spawn; @@ -38,7 +39,7 @@ import com.l2jmobius.gameserver.model.actor.L2Npc; * Tar Beetle zone spawn * @author malyelfik */ -public class TarBeetleSpawn implements IXmlReader +public class TarBeetleSpawn implements IGameXmlReader { private final List zones = new ArrayList<>(); private ScheduledFuture spawnTask; @@ -61,7 +62,7 @@ public class TarBeetleSpawn implements IXmlReader } @Override - public void parseDocument(Document doc) + public void parseDocument(Document doc, File f) { int i = 0; for (Node d = doc.getFirstChild(); d != null; d = d.getNextSibling()) @@ -97,11 +98,11 @@ public class TarBeetleSpawn implements IXmlReader final Zone bannedZone = new Zone(); final int bMinZ = parseInteger(attrs, "minZ"); final int bMaxZ = parseInteger(attrs, "maxZ"); - for (Node f = c.getFirstChild(); f != null; f = f.getNextSibling()) + for (Node h = c.getFirstChild(); h != null; h = h.getNextSibling()) { - if (f.getNodeName().equals("point")) + if (h.getNodeName().equals("point")) { - attrs = f.getAttributes(); + attrs = h.getAttributes(); final int x = parseInteger(attrs, "x"); final int y = parseInteger(attrs, "y"); bannedZone.add(x, y, bMinZ, bMaxZ, 0); diff --git a/L2J_Mobius_CT_2.6_HighFive/dist/game/data/scripts/ai/npc/NpcBuffers/NpcBuffersData.java b/L2J_Mobius_CT_2.6_HighFive/dist/game/data/scripts/ai/npc/NpcBuffers/NpcBuffersData.java index 007e6e50ec..77b311bac5 100644 --- a/L2J_Mobius_CT_2.6_HighFive/dist/game/data/scripts/ai/npc/NpcBuffers/NpcBuffersData.java +++ b/L2J_Mobius_CT_2.6_HighFive/dist/game/data/scripts/ai/npc/NpcBuffers/NpcBuffersData.java @@ -16,6 +16,7 @@ */ package ai.npc.NpcBuffers; +import java.io.File; import java.util.Collection; import java.util.HashMap; import java.util.Map; @@ -26,13 +27,13 @@ import org.w3c.dom.Document; import org.w3c.dom.NamedNodeMap; import org.w3c.dom.Node; -import com.l2jmobius.commons.util.IXmlReader; +import com.l2jmobius.commons.util.IGameXmlReader; import com.l2jmobius.gameserver.model.StatsSet; /** * @author UnAfraid */ -public class NpcBuffersData implements IXmlReader +public class NpcBuffersData implements IGameXmlReader { private final Map _npcBuffers = new HashMap<>(); @@ -49,7 +50,7 @@ public class NpcBuffersData implements IXmlReader } @Override - public void parseDocument(Document doc) + public void parseDocument(Document doc, File f) { StatsSet set; Node attr; diff --git a/L2J_Mobius_CT_2.6_HighFive/dist/game/data/scripts/hellbound/HellboundPointData.java b/L2J_Mobius_CT_2.6_HighFive/dist/game/data/scripts/hellbound/HellboundPointData.java index 2ea513b90d..9f154f79a8 100644 --- a/L2J_Mobius_CT_2.6_HighFive/dist/game/data/scripts/hellbound/HellboundPointData.java +++ b/L2J_Mobius_CT_2.6_HighFive/dist/game/data/scripts/hellbound/HellboundPointData.java @@ -16,6 +16,7 @@ */ package hellbound; +import java.io.File; import java.util.HashMap; import java.util.Map; @@ -23,13 +24,13 @@ import org.w3c.dom.Document; import org.w3c.dom.NamedNodeMap; import org.w3c.dom.Node; -import com.l2jmobius.commons.util.IXmlReader; +import com.l2jmobius.commons.util.IGameXmlReader; /** * Point data parser. * @author Zoey76 */ -public final class HellboundPointData implements IXmlReader +public final class HellboundPointData implements IGameXmlReader { private final Map _pointsInfo = new HashMap<>(); @@ -47,7 +48,7 @@ public final class HellboundPointData implements IXmlReader } @Override - public void parseDocument(Document doc) + public void parseDocument(Document doc, File f) { for (Node n = doc.getFirstChild(); n != null; n = n.getNextSibling()) { diff --git a/L2J_Mobius_CT_2.6_HighFive/dist/game/data/scripts/hellbound/HellboundSpawns.java b/L2J_Mobius_CT_2.6_HighFive/dist/game/data/scripts/hellbound/HellboundSpawns.java index 9ed7e418f0..45865f234b 100644 --- a/L2J_Mobius_CT_2.6_HighFive/dist/game/data/scripts/hellbound/HellboundSpawns.java +++ b/L2J_Mobius_CT_2.6_HighFive/dist/game/data/scripts/hellbound/HellboundSpawns.java @@ -16,6 +16,7 @@ */ package hellbound; +import java.io.File; import java.util.ArrayList; import java.util.HashMap; import java.util.List; @@ -25,7 +26,7 @@ import org.w3c.dom.Document; import org.w3c.dom.NamedNodeMap; import org.w3c.dom.Node; -import com.l2jmobius.commons.util.IXmlReader; +import com.l2jmobius.commons.util.IGameXmlReader; import com.l2jmobius.gameserver.datatables.SpawnTable; import com.l2jmobius.gameserver.model.L2Spawn; import com.l2jmobius.gameserver.model.Location; @@ -34,7 +35,7 @@ import com.l2jmobius.gameserver.model.Location; * Hellbound Spawns parser. * @author Zoey76 */ -public final class HellboundSpawns implements IXmlReader +public final class HellboundSpawns implements IGameXmlReader { private final List _spawns = new ArrayList<>(); private final Map _spawnLevels = new HashMap<>(); @@ -54,7 +55,7 @@ public final class HellboundSpawns implements IXmlReader } @Override - public void parseDocument(Document doc) + public void parseDocument(Document doc, File f) { for (Node node = doc.getFirstChild(); node != null; node = node.getNextSibling()) { diff --git a/L2J_Mobius_CT_2.6_HighFive/dist/game/data/scripts/instances/FinalEmperialTomb/FinalEmperialTomb.java b/L2J_Mobius_CT_2.6_HighFive/dist/game/data/scripts/instances/FinalEmperialTomb/FinalEmperialTomb.java index 36107bff4b..d0ac2bcda2 100644 --- a/L2J_Mobius_CT_2.6_HighFive/dist/game/data/scripts/instances/FinalEmperialTomb/FinalEmperialTomb.java +++ b/L2J_Mobius_CT_2.6_HighFive/dist/game/data/scripts/instances/FinalEmperialTomb/FinalEmperialTomb.java @@ -16,6 +16,7 @@ */ package instances.FinalEmperialTomb; +import java.io.File; import java.util.ArrayList; import java.util.HashMap; import java.util.List; @@ -31,7 +32,7 @@ import org.w3c.dom.NamedNodeMap; import org.w3c.dom.Node; import com.l2jmobius.commons.concurrent.ThreadPool; -import com.l2jmobius.commons.util.IXmlReader; +import com.l2jmobius.commons.util.IGameXmlReader; import com.l2jmobius.gameserver.ai.CtrlIntention; import com.l2jmobius.gameserver.enums.InstanceType; import com.l2jmobius.gameserver.geoengine.GeoEngine; @@ -74,7 +75,7 @@ import instances.AbstractInstance; * Use proper zone spawn system. * @author Gigiikun */ -public final class FinalEmperialTomb extends AbstractInstance implements IXmlReader +public final class FinalEmperialTomb extends AbstractInstance implements IGameXmlReader { protected class FETWorld extends InstanceWorld { @@ -258,7 +259,7 @@ public final class FinalEmperialTomb extends AbstractInstance implements IXmlRea } @Override - public void parseDocument(Document doc) + public void parseDocument(Document doc, File f) { final Node first = doc.getFirstChild(); if ((first != null) && "list".equalsIgnoreCase(first.getNodeName())) diff --git a/L2J_Mobius_CT_2.6_HighFive/dist/game/data/zones/no_bookmark.xml b/L2J_Mobius_CT_2.6_HighFive/dist/game/data/zones/no_bookmark.xml index 919d664f00..f1646f20d2 100644 --- a/L2J_Mobius_CT_2.6_HighFive/dist/game/data/zones/no_bookmark.xml +++ b/L2J_Mobius_CT_2.6_HighFive/dist/game/data/zones/no_bookmark.xml @@ -2813,7 +2813,7 @@ - + @@ -2827,7 +2827,7 @@ - + diff --git a/L2J_Mobius_CT_2.6_HighFive/java/com/l2jmobius/Config.java b/L2J_Mobius_CT_2.6_HighFive/java/com/l2jmobius/Config.java index eb52fba4a5..2c697484e9 100644 --- a/L2J_Mobius_CT_2.6_HighFive/java/com/l2jmobius/Config.java +++ b/L2J_Mobius_CT_2.6_HighFive/java/com/l2jmobius/Config.java @@ -52,9 +52,8 @@ import org.w3c.dom.Document; import org.w3c.dom.NamedNodeMap; import org.w3c.dom.Node; -import com.l2jmobius.commons.util.IXmlReader; +import com.l2jmobius.commons.util.IGameXmlReader; import com.l2jmobius.commons.util.PropertiesParser; -import com.l2jmobius.gameserver.GameServer; import com.l2jmobius.gameserver.enums.ChatType; import com.l2jmobius.gameserver.enums.IllegalActionPunishmentType; import com.l2jmobius.gameserver.model.Location; @@ -3299,7 +3298,7 @@ public final class Config return result; } - private static class IPConfigData implements IXmlReader + private static class IPConfigData implements IGameXmlReader { private static final List _subnets = new ArrayList<>(5); private static final List _hosts = new ArrayList<>(5); @@ -3312,22 +3311,22 @@ public final class Config @Override public void load() { - GameServer.printSection("Network Configuration"); - if ((new File(IPCONFIG_FILE)).exists()) + final File f = new File(IPCONFIG_FILE); + if (f.exists()) { - LOGGER.log(Level.INFO, "Using existing ipconfig.xml."); + LOGGER.info("Network Config: ipconfig.xml exists using manual configuration..."); parseFile(new File(IPCONFIG_FILE)); } else // Auto configuration... { - LOGGER.log(Level.INFO, "Using automatic network configuration."); + LOGGER.info("Network Config: ipconfig.xml doesn't exists using automatic configuration..."); autoIpConfig(); } } @Override - public void parseDocument(Document doc) + public void parseDocument(Document doc, File f) { NamedNodeMap attrs; for (Node n = doc.getFirstChild(); n != null; n = n.getNextSibling()) @@ -3344,7 +3343,7 @@ public final class Config if (_hosts.size() != _subnets.size()) { - LOGGER.log(Level.WARNING, "Failed to Load " + IPCONFIG_FILE + " File - subnets does not match server addresses."); + LOGGER.warning("Failed to Load " + IPCONFIG_FILE + " File - subnets does not match server addresses."); } } } @@ -3352,7 +3351,7 @@ public final class Config final Node att = n.getAttributes().getNamedItem("address"); if (att == null) { - LOGGER.log(Level.WARNING, "Failed to load " + IPCONFIG_FILE + " file - default server address is missing."); + LOGGER.warning("Failed to load " + IPCONFIG_FILE + " file - default server address is missing."); _hosts.add("127.0.0.1"); } else @@ -3417,7 +3416,7 @@ public final class Config { _subnets.add(subnet); _hosts.add(hostAddress); - LOGGER.log(Level.INFO, "Adding new subnet: " + subnet + " address: " + hostAddress); + LOGGER.info("Network Config: Adding new subnet: " + subnet + " address: " + hostAddress); } } } @@ -3425,23 +3424,31 @@ public final class Config // External host and subnet _hosts.add(externalIp); _subnets.add("0.0.0.0/0"); - LOGGER.log(Level.INFO, "Adding new subnet: 0.0.0.0/0 address: " + externalIp); + LOGGER.info("Network Config: Adding new subnet: 0.0.0.0/0 address: " + externalIp); } catch (SocketException e) { - LOGGER.log(Level.INFO, "Configuration failed please manually configure ipconfig.xml", e); + LOGGER.log(Level.INFO, "Network Config: Configuration failed please configure manually using ipconfig.xml", e); System.exit(0); } } protected List getSubnets() { - return _subnets.isEmpty() ? Arrays.asList("0.0.0.0/0") : _subnets; + if (_subnets.isEmpty()) + { + return Arrays.asList("0.0.0.0/0"); + } + return _subnets; } protected List getHosts() { - return _hosts.isEmpty() ? Arrays.asList("127.0.0.1") : _hosts; + if (_hosts.isEmpty()) + { + return Arrays.asList("127.0.0.1"); + } + return _hosts; } } } diff --git a/L2J_Mobius_CT_2.6_HighFive/java/com/l2jmobius/commons/util/IGameXmlReader.java b/L2J_Mobius_CT_2.6_HighFive/java/com/l2jmobius/commons/util/IGameXmlReader.java new file mode 100644 index 0000000000..b29089db77 --- /dev/null +++ b/L2J_Mobius_CT_2.6_HighFive/java/com/l2jmobius/commons/util/IGameXmlReader.java @@ -0,0 +1,118 @@ +/* + * This file is part of the L2J Mobius project. + * + * 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 . + */ +package com.l2jmobius.commons.util; + +import java.io.File; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import org.w3c.dom.NamedNodeMap; +import org.w3c.dom.Node; + +import com.l2jmobius.Config; +import com.l2jmobius.gameserver.model.Location; +import com.l2jmobius.gameserver.model.holders.MinionHolder; +import com.l2jmobius.gameserver.model.holders.SkillHolder; + +/** + * Interface for XML parsers. + * @author Zoey76 + */ +public interface IGameXmlReader extends IXmlReader +{ + /** + * Wrapper for {@link #parseFile(File)} method. + * @param path the relative path to the datapack root of the XML file to parse. + */ + default void parseDatapackFile(String path) + { + parseFile(new File(Config.DATAPACK_ROOT, path)); + } + + /** + * Wrapper for {@link #parseDirectory(File, boolean)}. + * @param path the path to the directory where the XML files are + * @param recursive parses all sub folders if there is + * @return {@code false} if it fails to find the directory, {@code true} otherwise + */ + default boolean parseDatapackDirectory(String path, boolean recursive) + { + return parseDirectory(new File(Config.DATAPACK_ROOT, path), recursive); + } + + /** + * @param n + * @return a map of parameters + */ + default Map parseParameters(Node n) + { + final Map parameters = new HashMap<>(); + for (Node parameters_node = n.getFirstChild(); parameters_node != null; parameters_node = parameters_node.getNextSibling()) + { + NamedNodeMap attrs = parameters_node.getAttributes(); + switch (parameters_node.getNodeName().toLowerCase()) + { + case "param": + { + parameters.put(parseString(attrs, "name"), parseString(attrs, "value")); + break; + } + case "skill": + { + parameters.put(parseString(attrs, "name"), new SkillHolder(parseInteger(attrs, "id"), parseInteger(attrs, "level"))); + break; + } + case "location": + { + parameters.put(parseString(attrs, "name"), new Location(parseInteger(attrs, "x"), parseInteger(attrs, "y"), parseInteger(attrs, "z"), parseInteger(attrs, "heading", 0))); + break; + } + case "minions": + { + final List minions = new ArrayList<>(1); + for (Node minions_node = parameters_node.getFirstChild(); minions_node != null; minions_node = minions_node.getNextSibling()) + { + if (minions_node.getNodeName().equalsIgnoreCase("npc")) + { + attrs = minions_node.getAttributes(); + minions.add(new MinionHolder(parseInteger(attrs, "id"), parseInteger(attrs, "count"), parseInteger(attrs, "respawnTime"), parseInteger(attrs, "weightPoint"))); + } + } + + if (!minions.isEmpty()) + { + parameters.put(parseString(parameters_node.getAttributes(), "name"), minions); + } + break; + } + } + } + return parameters; + } + + default Location parseLocation(Node n) + { + final NamedNodeMap attrs = n.getAttributes(); + final int x = parseInteger(attrs, "x"); + final int y = parseInteger(attrs, "y"); + final int z = parseInteger(attrs, "z"); + final int heading = parseInteger(attrs, "heading", 0); + return new Location(x, y, z, heading); + } +} diff --git a/L2J_Mobius_CT_2.6_HighFive/java/com/l2jmobius/commons/util/IXmlReader.java b/L2J_Mobius_CT_2.6_HighFive/java/com/l2jmobius/commons/util/IXmlReader.java index 21f6d1b894..0317816fd8 100644 --- a/L2J_Mobius_CT_2.6_HighFive/java/com/l2jmobius/commons/util/IXmlReader.java +++ b/L2J_Mobius_CT_2.6_HighFive/java/com/l2jmobius/commons/util/IXmlReader.java @@ -1,665 +1,706 @@ -/* - * This file is part of the L2J Mobius project. - * - * 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 . - */ -package com.l2jmobius.commons.util; - -import java.io.File; -import java.io.FileFilter; -import java.util.logging.Logger; - -import javax.xml.parsers.DocumentBuilder; -import javax.xml.parsers.DocumentBuilderFactory; - -import org.w3c.dom.Document; -import org.w3c.dom.NamedNodeMap; -import org.w3c.dom.Node; -import org.xml.sax.ErrorHandler; -import org.xml.sax.SAXParseException; - -import com.l2jmobius.Config; -import com.l2jmobius.commons.util.file.filter.XMLFilter; - -/** - * Interface for XML parsers. - * @author Zoey76 - */ -public interface IXmlReader -{ - Logger LOGGER = Logger.getLogger(IXmlReader.class.getName()); - String JAXP_SCHEMA_LANGUAGE = "http://java.sun.com/xml/jaxp/properties/schemaLanguage"; - String W3C_XML_SCHEMA = "http://www.w3.org/2001/XMLSchema"; - /** The default file filter, ".xml" files only. */ - XMLFilter XML_FILTER = new XMLFilter(); - - /** - * This method can be used to load/reload the data.
- * It's highly recommended to clear the data storage, either the list or map. - */ - void load(); - - /** - * Wrapper for {@link #parseFile(File)} method. - * @param path the relative path to the datapack root of the XML file to parse. - */ - default void parseDatapackFile(String path) - { - parseFile(new File(Config.DATAPACK_ROOT, path)); - } - - /** - * Parses a single XML file.
- * If the file was successfully parsed, call {@link #parseDocument(Document, File)} for the parsed document.
- * Validation is enforced. - * @param f the XML file to parse. - */ - default void parseFile(File f) - { - if (!getCurrentFileFilter().accept(f)) - { - LOGGER.warning(getClass().getSimpleName() + ": Could not parse " + f.getName() + " is not a file or it doesn't exist!"); - return; - } - - final DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); - dbf.setNamespaceAware(true); - dbf.setValidating(true); - dbf.setIgnoringComments(true); - try - { - dbf.setAttribute(JAXP_SCHEMA_LANGUAGE, W3C_XML_SCHEMA); - final DocumentBuilder db = dbf.newDocumentBuilder(); - db.setErrorHandler(new XMLErrorHandler()); - parseDocument(db.parse(f), f); - } - catch (SAXParseException e) - { - LOGGER.warning(getClass().getSimpleName() + ": Could not parse file " + f.getName() + " at line " + e.getLineNumber() + ", column " + e.getColumnNumber() + ": " + e.getMessage()); - return; - } - catch (Exception e) - { - LOGGER.warning(getClass().getSimpleName() + ": Could not parse file " + f.getName() + ": " + e.getMessage()); - return; - } - } - - /** - * Wrapper for {@link #parseDirectory(File, boolean)}. - * @param file the path to the directory where the XML files are. - * @return {@code false} if it fails to find the directory, {@code true} otherwise. - */ - default boolean parseDirectory(File file) - { - return parseDirectory(file, false); - } - - /** - * Wrapper for {@link #parseDirectory(File, boolean)}. - * @param path the path to the directory where the XML files are. - * @return {@code false} if it fails to find the directory, {@code true} otherwise. - */ - default boolean parseDirectory(String path) - { - return parseDirectory(new File(path), false); - } - - /** - * Wrapper for {@link #parseDirectory(File, boolean)}. - * @param path the path to the directory where the XML files are. - * @param recursive parses all sub folders if there is. - * @return {@code false} if it fails to find the directory, {@code true} otherwise. - */ - default boolean parseDirectory(String path, boolean recursive) - { - return parseDirectory(new File(path), recursive); - } - - /** - * Loads all XML files from {@code path} and calls {@link #parseFile(File)} for each one of them. - * @param dir the directory object to scan. - * @param recursive parses all sub folders if there is. - * @return {@code false} if it fails to find the directory, {@code true} otherwise. - */ - default boolean parseDirectory(File dir, boolean recursive) - { - if (!dir.exists()) - { - LOGGER.warning(getClass().getSimpleName() + ": Folder " + dir.getAbsolutePath() + " doesn't exist!"); - return false; - } - - final File[] files = dir.listFiles(); - if (files != null) - { - for (File f : files) - { - if (recursive && f.isDirectory()) - { - parseDirectory(f, recursive); - } - else if (getCurrentFileFilter().accept(f)) - { - parseFile(f); - } - } - } - return true; - } - - /** - * Wrapper for {@link #parseDirectory(File, boolean)}. - * @param path the path to the directory where the XML files are - * @param recursive parses all sub folders if there is - * @return {@code false} if it fails to find the directory, {@code true} otherwise - */ - default boolean parseDatapackDirectory(String path, boolean recursive) - { - return parseDirectory(new File(Config.DATAPACK_ROOT, path), recursive); - } - - /** - * Abstract method that when implemented will parse the current document.
- * Is expected to be call from {@link #parseFile(File)}. - * @param doc the current document to parse - * @param f the current file - */ - default void parseDocument(Document doc, File f) - { - parseDocument(doc); - } - - /** - * Abstract method that when implemented will parse the current document.
- * Is expected to be call from {@link #parseFile(File)}. - * @param doc the current document to parse - */ - default void parseDocument(Document doc) - { - LOGGER.severe("Parser not implemented!"); - } - - /** - * Parses a boolean value. - * @param node the node to parse - * @param defaultValue the default value - * @return if the node is not null, the value of the parsed node, otherwise the default value - */ - default Boolean parseBoolean(Node node, Boolean defaultValue) - { - return node != null ? Boolean.valueOf(node.getNodeValue()) : defaultValue; - } - - /** - * Parses a boolean value. - * @param node the node to parse - * @return if the node is not null, the value of the parsed node, otherwise null - */ - default Boolean parseBoolean(Node node) - { - return parseBoolean(node, null); - } - - /** - * Parses a boolean value. - * @param attrs the attributes - * @param name the name of the attribute to parse - * @return if the node is not null, the value of the parsed node, otherwise null - */ - default Boolean parseBoolean(NamedNodeMap attrs, String name) - { - return parseBoolean(attrs.getNamedItem(name)); - } - - /** - * Parses a boolean value. - * @param attrs the attributes - * @param name the name of the attribute to parse - * @param defaultValue the default value - * @return if the node is not null, the value of the parsed node, otherwise the default value - */ - default Boolean parseBoolean(NamedNodeMap attrs, String name, Boolean defaultValue) - { - return parseBoolean(attrs.getNamedItem(name), defaultValue); - } - - /** - * Parses a byte value. - * @param node the node to parse - * @param defaultValue the default value - * @return if the node is not null, the value of the parsed node, otherwise the default value - */ - default Byte parseByte(Node node, Byte defaultValue) - { - return node != null ? Byte.valueOf(node.getNodeValue()) : defaultValue; - } - - /** - * Parses a byte value. - * @param node the node to parse - * @return if the node is not null, the value of the parsed node, otherwise null - */ - default Byte parseByte(Node node) - { - return parseByte(node, null); - } - - /** - * Parses a byte value. - * @param attrs the attributes - * @param name the name of the attribute to parse - * @return if the node is not null, the value of the parsed node, otherwise null - */ - default Byte parseByte(NamedNodeMap attrs, String name) - { - return parseByte(attrs.getNamedItem(name)); - } - - /** - * Parses a byte value. - * @param attrs the attributes - * @param name the name of the attribute to parse - * @param defaultValue the default value - * @return if the node is not null, the value of the parsed node, otherwise the default value - */ - default Byte parseByte(NamedNodeMap attrs, String name, Byte defaultValue) - { - return parseByte(attrs.getNamedItem(name), defaultValue); - } - - /** - * Parses a short value. - * @param node the node to parse - * @param defaultValue the default value - * @return if the node is not null, the value of the parsed node, otherwise the default value - */ - default Short parseShort(Node node, Short defaultValue) - { - return node != null ? Short.valueOf(node.getNodeValue()) : defaultValue; - } - - /** - * Parses a short value. - * @param node the node to parse - * @return if the node is not null, the value of the parsed node, otherwise null - */ - default Short parseShort(Node node) - { - return parseShort(node, null); - } - - /** - * Parses a short value. - * @param attrs the attributes - * @param name the name of the attribute to parse - * @return if the node is not null, the value of the parsed node, otherwise null - */ - default Short parseShort(NamedNodeMap attrs, String name) - { - return parseShort(attrs.getNamedItem(name)); - } - - /** - * Parses a short value. - * @param attrs the attributes - * @param name the name of the attribute to parse - * @param defaultValue the default value - * @return if the node is not null, the value of the parsed node, otherwise the default value - */ - default Short parseShort(NamedNodeMap attrs, String name, Short defaultValue) - { - return parseShort(attrs.getNamedItem(name), defaultValue); - } - - /** - * Parses an int value. - * @param node the node to parse - * @param defaultValue the default value - * @return if the node is not null, the value of the parsed node, otherwise the default value - */ - default int parseInt(Node node, Integer defaultValue) - { - return node != null ? Integer.parseInt(node.getNodeValue()) : defaultValue; - } - - /** - * Parses an int value. - * @param node the node to parse - * @return if the node is not null, the value of the parsed node, otherwise the default value - */ - default int parseInt(Node node) - { - return parseInt(node, -1); - } - - /** - * Parses an integer value. - * @param node the node to parse - * @param defaultValue the default value - * @return if the node is not null, the value of the parsed node, otherwise the default value - */ - default Integer parseInteger(Node node, Integer defaultValue) - { - return node != null ? Integer.valueOf(node.getNodeValue()) : defaultValue; - } - - /** - * Parses an integer value. - * @param node the node to parse - * @return if the node is not null, the value of the parsed node, otherwise null - */ - default Integer parseInteger(Node node) - { - return parseInteger(node, null); - } - - /** - * Parses an integer value. - * @param attrs the attributes - * @param name the name of the attribute to parse - * @return if the node is not null, the value of the parsed node, otherwise null - */ - default Integer parseInteger(NamedNodeMap attrs, String name) - { - return parseInteger(attrs.getNamedItem(name)); - } - - /** - * Parses an integer value. - * @param attrs the attributes - * @param name the name of the attribute to parse - * @param defaultValue the default value - * @return if the node is not null, the value of the parsed node, otherwise the default value - */ - default Integer parseInteger(NamedNodeMap attrs, String name, Integer defaultValue) - { - return parseInteger(attrs.getNamedItem(name), defaultValue); - } - - /** - * Parses a long value. - * @param node the node to parse - * @param defaultValue the default value - * @return if the node is not null, the value of the parsed node, otherwise the default value - */ - default Long parseLong(Node node, Long defaultValue) - { - return node != null ? Long.valueOf(node.getNodeValue()) : defaultValue; - } - - /** - * Parses a long value. - * @param node the node to parse - * @return if the node is not null, the value of the parsed node, otherwise null - */ - default Long parseLong(Node node) - { - return parseLong(node, null); - } - - /** - * Parses a long value. - * @param attrs the attributes - * @param name the name of the attribute to parse - * @return if the node is not null, the value of the parsed node, otherwise null - */ - default Long parseLong(NamedNodeMap attrs, String name) - { - return parseLong(attrs.getNamedItem(name)); - } - - /** - * Parses a long value. - * @param attrs the attributes - * @param name the name of the attribute to parse - * @param defaultValue the default value - * @return if the node is not null, the value of the parsed node, otherwise the default value - */ - default Long parseLong(NamedNodeMap attrs, String name, Long defaultValue) - { - return parseLong(attrs.getNamedItem(name), defaultValue); - } - - /** - * Parses a float value. - * @param node the node to parse - * @param defaultValue the default value - * @return if the node is not null, the value of the parsed node, otherwise the default value - */ - default Float parseFloat(Node node, Float defaultValue) - { - return node != null ? Float.valueOf(node.getNodeValue()) : defaultValue; - } - - /** - * Parses a float value. - * @param node the node to parse - * @return if the node is not null, the value of the parsed node, otherwise null - */ - default Float parseFloat(Node node) - { - return parseFloat(node, null); - } - - /** - * Parses a float value. - * @param attrs the attributes - * @param name the name of the attribute to parse - * @return if the node is not null, the value of the parsed node, otherwise null - */ - default Float parseFloat(NamedNodeMap attrs, String name) - { - return parseFloat(attrs.getNamedItem(name)); - } - - /** - * Parses a float value. - * @param attrs the attributes - * @param name the name of the attribute to parse - * @param defaultValue the default value - * @return if the node is not null, the value of the parsed node, otherwise the default value - */ - default Float parseFloat(NamedNodeMap attrs, String name, Float defaultValue) - { - return parseFloat(attrs.getNamedItem(name), defaultValue); - } - - /** - * Parses a double value. - * @param node the node to parse - * @param defaultValue the default value - * @return if the node is not null, the value of the parsed node, otherwise the default value - */ - default Double parseDouble(Node node, Double defaultValue) - { - return node != null ? Double.valueOf(node.getNodeValue()) : defaultValue; - } - - /** - * Parses a double value. - * @param node the node to parse - * @return if the node is not null, the value of the parsed node, otherwise null - */ - default Double parseDouble(Node node) - { - return parseDouble(node, null); - } - - /** - * Parses a double value. - * @param attrs the attributes - * @param name the name of the attribute to parse - * @return if the node is not null, the value of the parsed node, otherwise null - */ - default Double parseDouble(NamedNodeMap attrs, String name) - { - return parseDouble(attrs.getNamedItem(name)); - } - - /** - * Parses a double value. - * @param attrs the attributes - * @param name the name of the attribute to parse - * @param defaultValue the default value - * @return if the node is not null, the value of the parsed node, otherwise the default value - */ - default Double parseDouble(NamedNodeMap attrs, String name, Double defaultValue) - { - return parseDouble(attrs.getNamedItem(name), defaultValue); - } - - /** - * Parses a string value. - * @param node the node to parse - * @param defaultValue the default value - * @return if the node is not null, the value of the parsed node, otherwise the default value - */ - default String parseString(Node node, String defaultValue) - { - return node != null ? node.getNodeValue() : defaultValue; - } - - /** - * Parses a string value. - * @param node the node to parse - * @return if the node is not null, the value of the parsed node, otherwise null - */ - default String parseString(Node node) - { - return parseString(node, null); - } - - /** - * Parses a string value. - * @param attrs the attributes - * @param name the name of the attribute to parse - * @return if the node is not null, the value of the parsed node, otherwise null - */ - default String parseString(NamedNodeMap attrs, String name) - { - return parseString(attrs.getNamedItem(name)); - } - - /** - * Parses a string value. - * @param attrs the attributes - * @param name the name of the attribute to parse - * @param defaultValue the default value - * @return if the node is not null, the value of the parsed node, otherwise the default value - */ - default String parseString(NamedNodeMap attrs, String name, String defaultValue) - { - return parseString(attrs.getNamedItem(name), defaultValue); - } - - /** - * Parses an enumerated value. - * @param the enumerated type - * @param node the node to parse - * @param clazz the class of the enumerated - * @param defaultValue the default value - * @return if the node is not null and the node value is valid the parsed value, otherwise the default value - */ - default > T parseEnum(Node node, Class clazz, T defaultValue) - { - if (node == null) - { - return defaultValue; - } - - try - { - return Enum.valueOf(clazz, node.getNodeValue()); - } - catch (IllegalArgumentException e) - { - LOGGER.warning("Invalid value specified for node: " + node.getNodeName() + " specified value: " + node.getNodeValue() + " should be enum value of \"" + clazz.getSimpleName() + "\" using default value: " + defaultValue); - return defaultValue; - } - } - - /** - * Parses an enumerated value. - * @param the enumerated type - * @param node the node to parse - * @param clazz the class of the enumerated - * @return if the node is not null and the node value is valid the parsed value, otherwise null - */ - default > T parseEnum(Node node, Class clazz) - { - return parseEnum(node, clazz, null); - } - - /** - * Parses an enumerated value. - * @param the enumerated type - * @param attrs the attributes - * @param clazz the class of the enumerated - * @param name the name of the attribute to parse - * @return if the node is not null and the node value is valid the parsed value, otherwise null - */ - default > T parseEnum(NamedNodeMap attrs, Class clazz, String name) - { - return parseEnum(attrs.getNamedItem(name), clazz); - } - - /** - * Parses an enumerated value. - * @param the enumerated type - * @param attrs the attributes - * @param clazz the class of the enumerated - * @param name the name of the attribute to parse - * @param defaultValue the default value - * @return if the node is not null and the node value is valid the parsed value, otherwise the default value - */ - default > T parseEnum(NamedNodeMap attrs, Class clazz, String name, T defaultValue) - { - return parseEnum(attrs.getNamedItem(name), clazz, defaultValue); - } - - /** - * Gets the current file filter. - * @return the current file filter - */ - default FileFilter getCurrentFileFilter() - { - return XML_FILTER; - } - - /** - * Simple XML error handler. - * @author Zoey76 - */ - static class XMLErrorHandler implements ErrorHandler - { - @Override - public void warning(SAXParseException e) throws SAXParseException - { - throw e; - } - - @Override - public void error(SAXParseException e) throws SAXParseException - { - throw e; - } - - @Override - public void fatalError(SAXParseException e) throws SAXParseException - { - throw e; - } - } -} +/* + * This file is part of the L2J Mobius project. + * + * 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 . + */ +package com.l2jmobius.commons.util; + +import java.io.File; +import java.io.FileFilter; +import java.util.LinkedHashMap; +import java.util.Map; +import java.util.function.Consumer; +import java.util.function.Predicate; +import java.util.logging.Level; +import java.util.logging.Logger; + +import javax.xml.parsers.DocumentBuilder; +import javax.xml.parsers.DocumentBuilderFactory; + +import org.w3c.dom.Document; +import org.w3c.dom.NamedNodeMap; +import org.w3c.dom.Node; +import org.w3c.dom.NodeList; +import org.xml.sax.ErrorHandler; +import org.xml.sax.SAXParseException; + +import com.l2jmobius.commons.util.file.filter.XMLFilter; + +/** + * Interface for XML parsers. + * @author Zoey76 + */ +public interface IXmlReader +{ + Logger LOGGER = Logger.getLogger(IXmlReader.class.getName()); + + String JAXP_SCHEMA_LANGUAGE = "http://java.sun.com/xml/jaxp/properties/schemaLanguage"; + String W3C_XML_SCHEMA = "http://www.w3.org/2001/XMLSchema"; + /** The default file filter, ".xml" files only. */ + XMLFilter XML_FILTER = new XMLFilter(); + + /** + * This method can be used to load/reload the data.
+ * It's highly recommended to clear the data storage, either the list or map. + */ + void load(); + + /** + * Parses a single XML file.
+ * If the file was successfully parsed, call {@link #parseDocument(Document, File)} for the parsed document.
+ * Validation is enforced. + * @param f the XML file to parse. + */ + default void parseFile(File f) + { + if (!getCurrentFileFilter().accept(f)) + { + LOGGER.warning("Could not parse " + f.getName() + " is not a file or it doesn't exist!"); + return; + } + + final DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); + dbf.setNamespaceAware(true); + dbf.setValidating(isValidating()); + dbf.setIgnoringComments(isIgnoringComments()); + try + { + dbf.setAttribute(JAXP_SCHEMA_LANGUAGE, W3C_XML_SCHEMA); + final DocumentBuilder db = dbf.newDocumentBuilder(); + db.setErrorHandler(new XMLErrorHandler()); + parseDocument(db.parse(f), f); + } + catch (SAXParseException e) + { + LOGGER.log(Level.WARNING, "Could not parse file: " + f.getName() + " at line: " + e.getLineNumber() + ", column: " + e.getColumnNumber() + " :", e); + return; + } + catch (Exception e) + { + LOGGER.log(Level.WARNING, "Could not parse file: " + f.getName(), e); + return; + } + } + + /** + * Checks if XML validation is enabled. + * @return {@code true} if its enabled, {@code false} otherwise + */ + default boolean isValidating() + { + return true; + } + + /** + * Checks if XML comments are ignored. + * @return {@code true} if its comments are ignored, {@code false} otherwise + */ + default boolean isIgnoringComments() + { + return true; + } + + /** + * Wrapper for {@link #parseDirectory(File, boolean)}. + * @param file the path to the directory where the XML files are. + * @return {@code false} if it fails to find the directory, {@code true} otherwise. + */ + default boolean parseDirectory(File file) + { + return parseDirectory(file, false); + } + + /** + * Loads all XML files from {@code path} and calls {@link #parseFile(File)} for each one of them. + * @param dir the directory object to scan. + * @param recursive parses all sub folders if there is. + * @return {@code false} if it fails to find the directory, {@code true} otherwise. + */ + default boolean parseDirectory(File dir, boolean recursive) + { + if (!dir.exists()) + { + LOGGER.warning("Folder " + dir.getAbsolutePath() + " doesn't exist!"); + return false; + } + + final File[] listOfFiles = dir.listFiles(); + for (File f : listOfFiles) + { + if (recursive && f.isDirectory()) + { + parseDirectory(f, recursive); + } + else if (getCurrentFileFilter().accept(f)) + { + parseFile(f); + } + } + return true; + } + + /** + * Abstract method that when implemented will parse the current document.
+ * Is expected to be call from {@link #parseFile(File)}. + * @param doc the current document to parse + * @param f the current file + */ + void parseDocument(Document doc, File f); + + /** + * Parses a boolean value. + * @param node the node to parse + * @param defaultValue the default value + * @return if the node is not null, the value of the parsed node, otherwise the default value + */ + default Boolean parseBoolean(Node node, Boolean defaultValue) + { + return node != null ? Boolean.valueOf(node.getNodeValue()) : defaultValue; + } + + /** + * Parses a boolean value. + * @param node the node to parse + * @return if the node is not null, the value of the parsed node, otherwise null + */ + default Boolean parseBoolean(Node node) + { + return parseBoolean(node, null); + } + + /** + * Parses a boolean value. + * @param attrs the attributes + * @param name the name of the attribute to parse + * @return if the node is not null, the value of the parsed node, otherwise null + */ + default Boolean parseBoolean(NamedNodeMap attrs, String name) + { + return parseBoolean(attrs.getNamedItem(name)); + } + + /** + * Parses a boolean value. + * @param attrs the attributes + * @param name the name of the attribute to parse + * @param defaultValue the default value + * @return if the node is not null, the value of the parsed node, otherwise the default value + */ + default Boolean parseBoolean(NamedNodeMap attrs, String name, Boolean defaultValue) + { + return parseBoolean(attrs.getNamedItem(name), defaultValue); + } + + /** + * Parses a byte value. + * @param node the node to parse + * @param defaultValue the default value + * @return if the node is not null, the value of the parsed node, otherwise the default value + */ + default Byte parseByte(Node node, Byte defaultValue) + { + return node != null ? Byte.decode(node.getNodeValue()) : defaultValue; + } + + /** + * Parses a byte value. + * @param node the node to parse + * @return if the node is not null, the value of the parsed node, otherwise null + */ + default Byte parseByte(Node node) + { + return parseByte(node, null); + } + + /** + * Parses a byte value. + * @param attrs the attributes + * @param name the name of the attribute to parse + * @return if the node is not null, the value of the parsed node, otherwise null + */ + default Byte parseByte(NamedNodeMap attrs, String name) + { + return parseByte(attrs.getNamedItem(name)); + } + + /** + * Parses a byte value. + * @param attrs the attributes + * @param name the name of the attribute to parse + * @param defaultValue the default value + * @return if the node is not null, the value of the parsed node, otherwise the default value + */ + default Byte parseByte(NamedNodeMap attrs, String name, Byte defaultValue) + { + return parseByte(attrs.getNamedItem(name), defaultValue); + } + + /** + * Parses a short value. + * @param node the node to parse + * @param defaultValue the default value + * @return if the node is not null, the value of the parsed node, otherwise the default value + */ + default Short parseShort(Node node, Short defaultValue) + { + return node != null ? Short.decode(node.getNodeValue()) : defaultValue; + } + + /** + * Parses a short value. + * @param node the node to parse + * @return if the node is not null, the value of the parsed node, otherwise null + */ + default Short parseShort(Node node) + { + return parseShort(node, null); + } + + /** + * Parses a short value. + * @param attrs the attributes + * @param name the name of the attribute to parse + * @return if the node is not null, the value of the parsed node, otherwise null + */ + default Short parseShort(NamedNodeMap attrs, String name) + { + return parseShort(attrs.getNamedItem(name)); + } + + /** + * Parses a short value. + * @param attrs the attributes + * @param name the name of the attribute to parse + * @param defaultValue the default value + * @return if the node is not null, the value of the parsed node, otherwise the default value + */ + default Short parseShort(NamedNodeMap attrs, String name, Short defaultValue) + { + return parseShort(attrs.getNamedItem(name), defaultValue); + } + + /** + * Parses an int value. + * @param node the node to parse + * @param defaultValue the default value + * @return if the node is not null, the value of the parsed node, otherwise the default value + */ + default int parseInt(Node node, Integer defaultValue) + { + return node != null ? Integer.decode(node.getNodeValue()) : defaultValue; + } + + /** + * Parses an int value. + * @param node the node to parse + * @return if the node is not null, the value of the parsed node, otherwise the default value + */ + default int parseInt(Node node) + { + return parseInt(node, -1); + } + + /** + * Parses an integer value. + * @param node the node to parse + * @param defaultValue the default value + * @return if the node is not null, the value of the parsed node, otherwise the default value + */ + default Integer parseInteger(Node node, Integer defaultValue) + { + return node != null ? Integer.decode(node.getNodeValue()) : defaultValue; + } + + /** + * Parses an integer value. + * @param node the node to parse + * @return if the node is not null, the value of the parsed node, otherwise null + */ + default Integer parseInteger(Node node) + { + return parseInteger(node, null); + } + + /** + * Parses an integer value. + * @param attrs the attributes + * @param name the name of the attribute to parse + * @return if the node is not null, the value of the parsed node, otherwise null + */ + default Integer parseInteger(NamedNodeMap attrs, String name) + { + return parseInteger(attrs.getNamedItem(name)); + } + + /** + * Parses an integer value. + * @param attrs the attributes + * @param name the name of the attribute to parse + * @param defaultValue the default value + * @return if the node is not null, the value of the parsed node, otherwise the default value + */ + default Integer parseInteger(NamedNodeMap attrs, String name, Integer defaultValue) + { + return parseInteger(attrs.getNamedItem(name), defaultValue); + } + + /** + * Parses a long value. + * @param node the node to parse + * @param defaultValue the default value + * @return if the node is not null, the value of the parsed node, otherwise the default value + */ + default Long parseLong(Node node, Long defaultValue) + { + return node != null ? Long.decode(node.getNodeValue()) : defaultValue; + } + + /** + * Parses a long value. + * @param node the node to parse + * @return if the node is not null, the value of the parsed node, otherwise null + */ + default Long parseLong(Node node) + { + return parseLong(node, null); + } + + /** + * Parses a long value. + * @param attrs the attributes + * @param name the name of the attribute to parse + * @return if the node is not null, the value of the parsed node, otherwise null + */ + default Long parseLong(NamedNodeMap attrs, String name) + { + return parseLong(attrs.getNamedItem(name)); + } + + /** + * Parses a long value. + * @param attrs the attributes + * @param name the name of the attribute to parse + * @param defaultValue the default value + * @return if the node is not null, the value of the parsed node, otherwise the default value + */ + default Long parseLong(NamedNodeMap attrs, String name, Long defaultValue) + { + return parseLong(attrs.getNamedItem(name), defaultValue); + } + + /** + * Parses a float value. + * @param node the node to parse + * @param defaultValue the default value + * @return if the node is not null, the value of the parsed node, otherwise the default value + */ + default Float parseFloat(Node node, Float defaultValue) + { + return node != null ? Float.valueOf(node.getNodeValue()) : defaultValue; + } + + /** + * Parses a float value. + * @param node the node to parse + * @return if the node is not null, the value of the parsed node, otherwise null + */ + default Float parseFloat(Node node) + { + return parseFloat(node, null); + } + + /** + * Parses a float value. + * @param attrs the attributes + * @param name the name of the attribute to parse + * @return if the node is not null, the value of the parsed node, otherwise null + */ + default Float parseFloat(NamedNodeMap attrs, String name) + { + return parseFloat(attrs.getNamedItem(name)); + } + + /** + * Parses a float value. + * @param attrs the attributes + * @param name the name of the attribute to parse + * @param defaultValue the default value + * @return if the node is not null, the value of the parsed node, otherwise the default value + */ + default Float parseFloat(NamedNodeMap attrs, String name, Float defaultValue) + { + return parseFloat(attrs.getNamedItem(name), defaultValue); + } + + /** + * Parses a double value. + * @param node the node to parse + * @param defaultValue the default value + * @return if the node is not null, the value of the parsed node, otherwise the default value + */ + default Double parseDouble(Node node, Double defaultValue) + { + return node != null ? Double.valueOf(node.getNodeValue()) : defaultValue; + } + + /** + * Parses a double value. + * @param node the node to parse + * @return if the node is not null, the value of the parsed node, otherwise null + */ + default Double parseDouble(Node node) + { + return parseDouble(node, null); + } + + /** + * Parses a double value. + * @param attrs the attributes + * @param name the name of the attribute to parse + * @return if the node is not null, the value of the parsed node, otherwise null + */ + default Double parseDouble(NamedNodeMap attrs, String name) + { + return parseDouble(attrs.getNamedItem(name)); + } + + /** + * Parses a double value. + * @param attrs the attributes + * @param name the name of the attribute to parse + * @param defaultValue the default value + * @return if the node is not null, the value of the parsed node, otherwise the default value + */ + default Double parseDouble(NamedNodeMap attrs, String name, Double defaultValue) + { + return parseDouble(attrs.getNamedItem(name), defaultValue); + } + + /** + * Parses a string value. + * @param node the node to parse + * @param defaultValue the default value + * @return if the node is not null, the value of the parsed node, otherwise the default value + */ + default String parseString(Node node, String defaultValue) + { + return node != null ? node.getNodeValue() : defaultValue; + } + + /** + * Parses a string value. + * @param node the node to parse + * @return if the node is not null, the value of the parsed node, otherwise null + */ + default String parseString(Node node) + { + return parseString(node, null); + } + + /** + * Parses a string value. + * @param attrs the attributes + * @param name the name of the attribute to parse + * @return if the node is not null, the value of the parsed node, otherwise null + */ + default String parseString(NamedNodeMap attrs, String name) + { + return parseString(attrs.getNamedItem(name)); + } + + /** + * Parses a string value. + * @param attrs the attributes + * @param name the name of the attribute to parse + * @param defaultValue the default value + * @return if the node is not null, the value of the parsed node, otherwise the default value + */ + default String parseString(NamedNodeMap attrs, String name, String defaultValue) + { + return parseString(attrs.getNamedItem(name), defaultValue); + } + + /** + * Parses an enumerated value. + * @param the enumerated type + * @param node the node to parse + * @param clazz the class of the enumerated + * @param defaultValue the default value + * @return if the node is not null and the node value is valid the parsed value, otherwise the default value + */ + default > T parseEnum(Node node, Class clazz, T defaultValue) + { + if (node == null) + { + return defaultValue; + } + + try + { + return Enum.valueOf(clazz, node.getNodeValue()); + } + catch (IllegalArgumentException e) + { + LOGGER.warning("Invalid value specified for node: " + node.getNodeName() + " specified value: " + node.getNodeValue() + " should be enum value of \"" + clazz.getSimpleName() + "\" using default value: " + defaultValue); + return defaultValue; + } + } + + /** + * Parses an enumerated value. + * @param the enumerated type + * @param node the node to parse + * @param clazz the class of the enumerated + * @return if the node is not null and the node value is valid the parsed value, otherwise null + */ + default > T parseEnum(Node node, Class clazz) + { + return parseEnum(node, clazz, null); + } + + /** + * Parses an enumerated value. + * @param the enumerated type + * @param attrs the attributes + * @param clazz the class of the enumerated + * @param name the name of the attribute to parse + * @return if the node is not null and the node value is valid the parsed value, otherwise null + */ + default > T parseEnum(NamedNodeMap attrs, Class clazz, String name) + { + return parseEnum(attrs.getNamedItem(name), clazz); + } + + /** + * Parses an enumerated value. + * @param the enumerated type + * @param attrs the attributes + * @param clazz the class of the enumerated + * @param name the name of the attribute to parse + * @param defaultValue the default value + * @return if the node is not null and the node value is valid the parsed value, otherwise the default value + */ + default > T parseEnum(NamedNodeMap attrs, Class clazz, String name, T defaultValue) + { + return parseEnum(attrs.getNamedItem(name), clazz, defaultValue); + } + + /** + * @param node + * @return parses all attributes to a Map + */ + default Map parseAttributes(Node node) + { + final NamedNodeMap attrs = node.getAttributes(); + final Map map = new LinkedHashMap<>(); + for (int i = 0; i < attrs.getLength(); i++) + { + final Node att = attrs.item(i); + map.put(att.getNodeName(), att.getNodeValue()); + } + return map; + } + + /** + * Executes action for each child of node + * @param node + * @param action + */ + default void forEach(Node node, Consumer action) + { + forEach(node, a -> true, action); + } + + /** + * Executes action for each child that matches nodeName + * @param node + * @param nodeName + * @param action + */ + default void forEach(Node node, String nodeName, Consumer action) + { + forEach(node, innerNode -> nodeName.equalsIgnoreCase(innerNode.getNodeName()), action); + } + + /** + * Executes action for each child of node if matches the filter specified + * @param node + * @param filter + * @param action + */ + default void forEach(Node node, Predicate filter, Consumer action) + { + final NodeList list = node.getChildNodes(); + for (int i = 0; i < list.getLength(); i++) + { + final Node targetNode = list.item(i); + if (filter.test(targetNode)) + { + action.accept(targetNode); + } + } + } + + /** + * @param node + * @return {@code true} if the node is an element type, {@code false} otherwise + */ + static boolean isNode(Node node) + { + return node.getNodeType() == Node.ELEMENT_NODE; + } + + /** + * @param node + * @return {@code true} if the node is an element type, {@code false} otherwise + */ + static boolean isText(Node node) + { + return node.getNodeType() == Node.TEXT_NODE; + } + + /** + * Gets the current file filter. + * @return the current file filter + */ + default FileFilter getCurrentFileFilter() + { + return XML_FILTER; + } + + /** + * Simple XML error handler. + * @author Zoey76 + */ + class XMLErrorHandler implements ErrorHandler + { + @Override + public void warning(SAXParseException e) throws SAXParseException + { + throw e; + } + + @Override + public void error(SAXParseException e) throws SAXParseException + { + throw e; + } + + @Override + public void fatalError(SAXParseException e) throws SAXParseException + { + throw e; + } + } +} diff --git a/L2J_Mobius_CT_2.6_HighFive/java/com/l2jmobius/gameserver/LoginServerThread.java b/L2J_Mobius_CT_2.6_HighFive/java/com/l2jmobius/gameserver/LoginServerThread.java index 7e2922798e..401b006579 100644 --- a/L2J_Mobius_CT_2.6_HighFive/java/com/l2jmobius/gameserver/LoginServerThread.java +++ b/L2J_Mobius_CT_2.6_HighFive/java/com/l2jmobius/gameserver/LoginServerThread.java @@ -45,8 +45,8 @@ import java.util.logging.Logger; import com.l2jmobius.Config; import com.l2jmobius.commons.database.DatabaseFactory; import com.l2jmobius.commons.network.BaseSendablePacket; -import com.l2jmobius.commons.util.Rnd; import com.l2jmobius.commons.util.CommonUtil; +import com.l2jmobius.commons.util.Rnd; import com.l2jmobius.commons.util.crypt.NewCrypt; import com.l2jmobius.gameserver.model.L2World; import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance; diff --git a/L2J_Mobius_CT_2.6_HighFive/java/com/l2jmobius/gameserver/data/xml/impl/AdminData.java b/L2J_Mobius_CT_2.6_HighFive/java/com/l2jmobius/gameserver/data/xml/impl/AdminData.java index 19f9d4c99f..1bcddf9fb0 100644 --- a/L2J_Mobius_CT_2.6_HighFive/java/com/l2jmobius/gameserver/data/xml/impl/AdminData.java +++ b/L2J_Mobius_CT_2.6_HighFive/java/com/l2jmobius/gameserver/data/xml/impl/AdminData.java @@ -16,6 +16,7 @@ */ package com.l2jmobius.gameserver.data.xml.impl; +import java.io.File; import java.util.ArrayList; import java.util.HashMap; import java.util.List; @@ -28,7 +29,7 @@ import org.w3c.dom.Document; import org.w3c.dom.NamedNodeMap; import org.w3c.dom.Node; -import com.l2jmobius.commons.util.IXmlReader; +import com.l2jmobius.commons.util.IGameXmlReader; import com.l2jmobius.gameserver.model.L2AccessLevel; import com.l2jmobius.gameserver.model.L2AdminCommandAccessRight; import com.l2jmobius.gameserver.model.StatsSet; @@ -41,7 +42,7 @@ import com.l2jmobius.gameserver.network.serverpackets.SystemMessage; * Loads administrator access levels and commands. * @author UnAfraid */ -public final class AdminData implements IXmlReader +public final class AdminData implements IGameXmlReader { private final Map _accessLevels = new HashMap<>(); private final Map _adminCommandAccessRights = new HashMap<>(); @@ -65,7 +66,7 @@ public final class AdminData implements IXmlReader } @Override - public void parseDocument(Document doc) + public void parseDocument(Document doc, File f) { NamedNodeMap attrs; Node attr; diff --git a/L2J_Mobius_CT_2.6_HighFive/java/com/l2jmobius/gameserver/data/xml/impl/ArmorSetsData.java b/L2J_Mobius_CT_2.6_HighFive/java/com/l2jmobius/gameserver/data/xml/impl/ArmorSetsData.java index d33d2efeeb..e7e324861a 100644 --- a/L2J_Mobius_CT_2.6_HighFive/java/com/l2jmobius/gameserver/data/xml/impl/ArmorSetsData.java +++ b/L2J_Mobius_CT_2.6_HighFive/java/com/l2jmobius/gameserver/data/xml/impl/ArmorSetsData.java @@ -16,6 +16,7 @@ */ package com.l2jmobius.gameserver.data.xml.impl; +import java.io.File; import java.util.HashMap; import java.util.Map; @@ -23,7 +24,7 @@ import org.w3c.dom.Document; import org.w3c.dom.NamedNodeMap; import org.w3c.dom.Node; -import com.l2jmobius.commons.util.IXmlReader; +import com.l2jmobius.commons.util.IGameXmlReader; import com.l2jmobius.gameserver.model.L2ArmorSet; import com.l2jmobius.gameserver.model.holders.SkillHolder; @@ -31,7 +32,7 @@ import com.l2jmobius.gameserver.model.holders.SkillHolder; * Loads armor set bonuses. * @author godson, Luno, UnAfraid */ -public final class ArmorSetsData implements IXmlReader +public final class ArmorSetsData implements IGameXmlReader { private final Map _armorSets = new HashMap<>(); @@ -52,7 +53,7 @@ public final class ArmorSetsData implements IXmlReader } @Override - public void parseDocument(Document doc) + public void parseDocument(Document doc, File f) { for (Node n = doc.getFirstChild(); n != null; n = n.getNextSibling()) { diff --git a/L2J_Mobius_CT_2.6_HighFive/java/com/l2jmobius/gameserver/data/xml/impl/BuyListData.java b/L2J_Mobius_CT_2.6_HighFive/java/com/l2jmobius/gameserver/data/xml/impl/BuyListData.java index e3c2cfe157..fa8d99133c 100644 --- a/L2J_Mobius_CT_2.6_HighFive/java/com/l2jmobius/gameserver/data/xml/impl/BuyListData.java +++ b/L2J_Mobius_CT_2.6_HighFive/java/com/l2jmobius/gameserver/data/xml/impl/BuyListData.java @@ -32,7 +32,7 @@ import org.w3c.dom.Node; import com.l2jmobius.Config; import com.l2jmobius.commons.database.DatabaseFactory; -import com.l2jmobius.commons.util.IXmlReader; +import com.l2jmobius.commons.util.IGameXmlReader; import com.l2jmobius.commons.util.file.filter.NumericNameFilter; import com.l2jmobius.gameserver.datatables.ItemTable; import com.l2jmobius.gameserver.model.buylist.L2BuyList; @@ -43,7 +43,7 @@ import com.l2jmobius.gameserver.model.items.L2Item; * Loads buy lists for NPCs. * @author NosBit */ -public final class BuyListData implements IXmlReader +public final class BuyListData implements IGameXmlReader { private static final Logger LOGGER = Logger.getLogger(BuyListData.class.getName()); diff --git a/L2J_Mobius_CT_2.6_HighFive/java/com/l2jmobius/gameserver/data/xml/impl/CategoryData.java b/L2J_Mobius_CT_2.6_HighFive/java/com/l2jmobius/gameserver/data/xml/impl/CategoryData.java index de5479de05..d0fd9d4731 100644 --- a/L2J_Mobius_CT_2.6_HighFive/java/com/l2jmobius/gameserver/data/xml/impl/CategoryData.java +++ b/L2J_Mobius_CT_2.6_HighFive/java/com/l2jmobius/gameserver/data/xml/impl/CategoryData.java @@ -16,6 +16,7 @@ */ package com.l2jmobius.gameserver.data.xml.impl; +import java.io.File; import java.util.HashMap; import java.util.HashSet; import java.util.Map; @@ -27,14 +28,14 @@ import org.w3c.dom.Document; import org.w3c.dom.NamedNodeMap; import org.w3c.dom.Node; -import com.l2jmobius.commons.util.IXmlReader; +import com.l2jmobius.commons.util.IGameXmlReader; import com.l2jmobius.gameserver.enums.CategoryType; /** * Loads the category data with Class or NPC IDs. * @author NosBit, xban1x */ -public final class CategoryData implements IXmlReader +public final class CategoryData implements IGameXmlReader { private static final Logger LOGGER = Logger.getLogger(CategoryData.class.getName()); @@ -54,7 +55,7 @@ public final class CategoryData implements IXmlReader } @Override - public void parseDocument(Document doc) + public void parseDocument(Document doc, File f) { for (Node node = doc.getFirstChild(); node != null; node = node.getNextSibling()) { diff --git a/L2J_Mobius_CT_2.6_HighFive/java/com/l2jmobius/gameserver/data/xml/impl/ClassListData.java b/L2J_Mobius_CT_2.6_HighFive/java/com/l2jmobius/gameserver/data/xml/impl/ClassListData.java index d35b9f9f8b..8d3a89606b 100644 --- a/L2J_Mobius_CT_2.6_HighFive/java/com/l2jmobius/gameserver/data/xml/impl/ClassListData.java +++ b/L2J_Mobius_CT_2.6_HighFive/java/com/l2jmobius/gameserver/data/xml/impl/ClassListData.java @@ -16,6 +16,7 @@ */ package com.l2jmobius.gameserver.data.xml.impl; +import java.io.File; import java.util.HashMap; import java.util.Map; @@ -23,7 +24,7 @@ import org.w3c.dom.Document; import org.w3c.dom.NamedNodeMap; import org.w3c.dom.Node; -import com.l2jmobius.commons.util.IXmlReader; +import com.l2jmobius.commons.util.IGameXmlReader; import com.l2jmobius.gameserver.model.base.ClassId; import com.l2jmobius.gameserver.model.base.ClassInfo; @@ -31,7 +32,7 @@ import com.l2jmobius.gameserver.model.base.ClassInfo; * Loads the the list of classes and it's info. * @author Zoey76 */ -public final class ClassListData implements IXmlReader +public final class ClassListData implements IGameXmlReader { private final Map _classData = new HashMap<>(); @@ -52,7 +53,7 @@ public final class ClassListData implements IXmlReader } @Override - public void parseDocument(Document doc) + public void parseDocument(Document doc, File f) { for (Node n = doc.getFirstChild(); n != null; n = n.getNextSibling()) { diff --git a/L2J_Mobius_CT_2.6_HighFive/java/com/l2jmobius/gameserver/data/xml/impl/DoorData.java b/L2J_Mobius_CT_2.6_HighFive/java/com/l2jmobius/gameserver/data/xml/impl/DoorData.java index a9e7b45640..dbce84ebc7 100644 --- a/L2J_Mobius_CT_2.6_HighFive/java/com/l2jmobius/gameserver/data/xml/impl/DoorData.java +++ b/L2J_Mobius_CT_2.6_HighFive/java/com/l2jmobius/gameserver/data/xml/impl/DoorData.java @@ -16,6 +16,7 @@ */ package com.l2jmobius.gameserver.data.xml.impl; +import java.io.File; import java.util.ArrayList; import java.util.Collection; import java.util.HashMap; @@ -28,7 +29,7 @@ import org.w3c.dom.Document; import org.w3c.dom.NamedNodeMap; import org.w3c.dom.Node; -import com.l2jmobius.commons.util.IXmlReader; +import com.l2jmobius.commons.util.IGameXmlReader; import com.l2jmobius.gameserver.instancemanager.InstanceManager; import com.l2jmobius.gameserver.instancemanager.MapRegionManager; import com.l2jmobius.gameserver.model.Location; @@ -40,7 +41,7 @@ import com.l2jmobius.gameserver.model.actor.templates.L2DoorTemplate; * Loads doors. * @author JIV, GodKratos, UnAfraid */ -public class DoorData implements IXmlReader +public class DoorData implements IGameXmlReader { private static final Map> _groups = new HashMap<>(); private final Map _doors = new HashMap<>(); @@ -62,7 +63,7 @@ public class DoorData implements IXmlReader } @Override - public void parseDocument(Document doc) + public void parseDocument(Document doc, File f) { for (Node a = doc.getFirstChild(); a != null; a = a.getNextSibling()) { diff --git a/L2J_Mobius_CT_2.6_HighFive/java/com/l2jmobius/gameserver/data/xml/impl/EnchantItemData.java b/L2J_Mobius_CT_2.6_HighFive/java/com/l2jmobius/gameserver/data/xml/impl/EnchantItemData.java index 7af4b57e19..e2e0a218a7 100644 --- a/L2J_Mobius_CT_2.6_HighFive/java/com/l2jmobius/gameserver/data/xml/impl/EnchantItemData.java +++ b/L2J_Mobius_CT_2.6_HighFive/java/com/l2jmobius/gameserver/data/xml/impl/EnchantItemData.java @@ -16,6 +16,7 @@ */ package com.l2jmobius.gameserver.data.xml.impl; +import java.io.File; import java.util.HashMap; import java.util.Map; import java.util.logging.Level; @@ -24,7 +25,7 @@ import org.w3c.dom.Document; import org.w3c.dom.NamedNodeMap; import org.w3c.dom.Node; -import com.l2jmobius.commons.util.IXmlReader; +import com.l2jmobius.commons.util.IGameXmlReader; import com.l2jmobius.gameserver.model.StatsSet; import com.l2jmobius.gameserver.model.items.enchant.EnchantScroll; import com.l2jmobius.gameserver.model.items.enchant.EnchantSupportItem; @@ -34,7 +35,7 @@ import com.l2jmobius.gameserver.model.items.instance.L2ItemInstance; * Loads item enchant data. * @author UnAfraid */ -public class EnchantItemData implements IXmlReader +public class EnchantItemData implements IGameXmlReader { private final Map _scrolls = new HashMap<>(); private final Map _supports = new HashMap<>(); @@ -58,7 +59,7 @@ public class EnchantItemData implements IXmlReader } @Override - public void parseDocument(Document doc) + public void parseDocument(Document doc, File f) { StatsSet set; Node att; diff --git a/L2J_Mobius_CT_2.6_HighFive/java/com/l2jmobius/gameserver/data/xml/impl/EnchantItemGroupsData.java b/L2J_Mobius_CT_2.6_HighFive/java/com/l2jmobius/gameserver/data/xml/impl/EnchantItemGroupsData.java index 356fccd37d..8c3f0d6035 100644 --- a/L2J_Mobius_CT_2.6_HighFive/java/com/l2jmobius/gameserver/data/xml/impl/EnchantItemGroupsData.java +++ b/L2J_Mobius_CT_2.6_HighFive/java/com/l2jmobius/gameserver/data/xml/impl/EnchantItemGroupsData.java @@ -16,6 +16,7 @@ */ package com.l2jmobius.gameserver.data.xml.impl; +import java.io.File; import java.util.HashMap; import java.util.Map; import java.util.logging.Level; @@ -24,7 +25,7 @@ import org.w3c.dom.Document; import org.w3c.dom.NamedNodeMap; import org.w3c.dom.Node; -import com.l2jmobius.commons.util.IXmlReader; +import com.l2jmobius.commons.util.IGameXmlReader; import com.l2jmobius.gameserver.datatables.ItemTable; import com.l2jmobius.gameserver.model.holders.RangeChanceHolder; import com.l2jmobius.gameserver.model.items.L2Item; @@ -36,7 +37,7 @@ import com.l2jmobius.gameserver.util.Util; /** * @author UnAfraid */ -public final class EnchantItemGroupsData implements IXmlReader +public final class EnchantItemGroupsData implements IGameXmlReader { private final Map _itemGroups = new HashMap<>(); private final Map _scrollGroups = new HashMap<>(); @@ -57,7 +58,7 @@ public final class EnchantItemGroupsData implements IXmlReader } @Override - public void parseDocument(Document doc) + public void parseDocument(Document doc, File f) { for (Node n = doc.getFirstChild(); n != null; n = n.getNextSibling()) { diff --git a/L2J_Mobius_CT_2.6_HighFive/java/com/l2jmobius/gameserver/data/xml/impl/EnchantItemHPBonusData.java b/L2J_Mobius_CT_2.6_HighFive/java/com/l2jmobius/gameserver/data/xml/impl/EnchantItemHPBonusData.java index 67e712c360..a6fdee53ec 100644 --- a/L2J_Mobius_CT_2.6_HighFive/java/com/l2jmobius/gameserver/data/xml/impl/EnchantItemHPBonusData.java +++ b/L2J_Mobius_CT_2.6_HighFive/java/com/l2jmobius/gameserver/data/xml/impl/EnchantItemHPBonusData.java @@ -16,6 +16,7 @@ */ package com.l2jmobius.gameserver.data.xml.impl; +import java.io.File; import java.util.ArrayList; import java.util.Collection; import java.util.EnumMap; @@ -25,7 +26,7 @@ import java.util.Map; import org.w3c.dom.Document; import org.w3c.dom.Node; -import com.l2jmobius.commons.util.IXmlReader; +import com.l2jmobius.commons.util.IGameXmlReader; import com.l2jmobius.gameserver.datatables.ItemTable; import com.l2jmobius.gameserver.enums.StatFunction; import com.l2jmobius.gameserver.model.items.L2Item; @@ -38,7 +39,7 @@ import com.l2jmobius.gameserver.model.stats.functions.FuncTemplate; * This class holds the Enchant HP Bonus Data. * @author MrPoke, Zoey76 */ -public class EnchantItemHPBonusData implements IXmlReader +public class EnchantItemHPBonusData implements IGameXmlReader { private final Map> _armorHPBonuses = new EnumMap<>(CrystalType.class); @@ -53,7 +54,7 @@ public class EnchantItemHPBonusData implements IXmlReader } @Override - public void parseDocument(Document doc) + public void parseDocument(Document doc, File f) { for (Node n = doc.getFirstChild(); n != null; n = n.getNextSibling()) { diff --git a/L2J_Mobius_CT_2.6_HighFive/java/com/l2jmobius/gameserver/data/xml/impl/EnchantItemOptionsData.java b/L2J_Mobius_CT_2.6_HighFive/java/com/l2jmobius/gameserver/data/xml/impl/EnchantItemOptionsData.java index 18f28f5d15..8f3db05050 100644 --- a/L2J_Mobius_CT_2.6_HighFive/java/com/l2jmobius/gameserver/data/xml/impl/EnchantItemOptionsData.java +++ b/L2J_Mobius_CT_2.6_HighFive/java/com/l2jmobius/gameserver/data/xml/impl/EnchantItemOptionsData.java @@ -16,6 +16,7 @@ */ package com.l2jmobius.gameserver.data.xml.impl; +import java.io.File; import java.util.HashMap; import java.util.Map; import java.util.logging.Level; @@ -23,7 +24,7 @@ import java.util.logging.Level; import org.w3c.dom.Document; import org.w3c.dom.Node; -import com.l2jmobius.commons.util.IXmlReader; +import com.l2jmobius.commons.util.IGameXmlReader; import com.l2jmobius.gameserver.model.items.instance.L2ItemInstance; import com.l2jmobius.gameserver.model.options.EnchantOptions; import com.l2jmobius.gameserver.util.Util; @@ -31,7 +32,7 @@ import com.l2jmobius.gameserver.util.Util; /** * @author UnAfraid */ -public class EnchantItemOptionsData implements IXmlReader +public class EnchantItemOptionsData implements IGameXmlReader { private final Map> _data = new HashMap<>(); @@ -48,7 +49,7 @@ public class EnchantItemOptionsData implements IXmlReader } @Override - public void parseDocument(Document doc) + public void parseDocument(Document doc, File f) { int counter = 0; for (Node n = doc.getFirstChild(); n != null; n = n.getNextSibling()) diff --git a/L2J_Mobius_CT_2.6_HighFive/java/com/l2jmobius/gameserver/data/xml/impl/EnchantSkillGroupsData.java b/L2J_Mobius_CT_2.6_HighFive/java/com/l2jmobius/gameserver/data/xml/impl/EnchantSkillGroupsData.java index 7cc2e9d0c9..24be909a4a 100644 --- a/L2J_Mobius_CT_2.6_HighFive/java/com/l2jmobius/gameserver/data/xml/impl/EnchantSkillGroupsData.java +++ b/L2J_Mobius_CT_2.6_HighFive/java/com/l2jmobius/gameserver/data/xml/impl/EnchantSkillGroupsData.java @@ -16,6 +16,7 @@ */ package com.l2jmobius.gameserver.data.xml.impl; +import java.io.File; import java.util.HashMap; import java.util.Map; import java.util.logging.Level; @@ -25,7 +26,7 @@ import org.w3c.dom.NamedNodeMap; import org.w3c.dom.Node; import com.l2jmobius.Config; -import com.l2jmobius.commons.util.IXmlReader; +import com.l2jmobius.commons.util.IGameXmlReader; import com.l2jmobius.gameserver.model.L2EnchantSkillGroup; import com.l2jmobius.gameserver.model.L2EnchantSkillGroup.EnchantSkillHolder; import com.l2jmobius.gameserver.model.L2EnchantSkillLearn; @@ -37,7 +38,7 @@ import com.l2jmobius.gameserver.model.skills.Skill; * This class holds the Enchant Groups information. * @author Micr0 */ -public class EnchantSkillGroupsData implements IXmlReader +public class EnchantSkillGroupsData implements IGameXmlReader { public static final int NORMAL_ENCHANT_COST_MULTIPLIER = Config.NORMAL_ENCHANT_COST_MULTIPLIER; public static final int SAFE_ENCHANT_COST_MULTIPLIER = Config.SAFE_ENCHANT_COST_MULTIPLIER; @@ -73,7 +74,7 @@ public class EnchantSkillGroupsData implements IXmlReader } @Override - public void parseDocument(Document doc) + public void parseDocument(Document doc, File f) { for (Node n = doc.getFirstChild(); n != null; n = n.getNextSibling()) { diff --git a/L2J_Mobius_CT_2.6_HighFive/java/com/l2jmobius/gameserver/data/xml/impl/ExperienceData.java b/L2J_Mobius_CT_2.6_HighFive/java/com/l2jmobius/gameserver/data/xml/impl/ExperienceData.java index eba8f5c95f..07c2327207 100644 --- a/L2J_Mobius_CT_2.6_HighFive/java/com/l2jmobius/gameserver/data/xml/impl/ExperienceData.java +++ b/L2J_Mobius_CT_2.6_HighFive/java/com/l2jmobius/gameserver/data/xml/impl/ExperienceData.java @@ -16,6 +16,7 @@ */ package com.l2jmobius.gameserver.data.xml.impl; +import java.io.File; import java.util.HashMap; import java.util.Map; @@ -23,13 +24,13 @@ import org.w3c.dom.Document; import org.w3c.dom.NamedNodeMap; import org.w3c.dom.Node; -import com.l2jmobius.commons.util.IXmlReader; +import com.l2jmobius.commons.util.IGameXmlReader; /** * This class holds the Experience points for each level for players and pets. * @author mrTJO */ -public final class ExperienceData implements IXmlReader +public final class ExperienceData implements IGameXmlReader { private final Map _expTable = new HashMap<>(); @@ -55,7 +56,7 @@ public final class ExperienceData implements IXmlReader } @Override - public void parseDocument(Document doc) + public void parseDocument(Document doc, File f) { final Node table = doc.getFirstChild(); final NamedNodeMap tableAttr = table.getAttributes(); diff --git a/L2J_Mobius_CT_2.6_HighFive/java/com/l2jmobius/gameserver/data/xml/impl/FishData.java b/L2J_Mobius_CT_2.6_HighFive/java/com/l2jmobius/gameserver/data/xml/impl/FishData.java index 8fb78e3284..ccb147d2bf 100644 --- a/L2J_Mobius_CT_2.6_HighFive/java/com/l2jmobius/gameserver/data/xml/impl/FishData.java +++ b/L2J_Mobius_CT_2.6_HighFive/java/com/l2jmobius/gameserver/data/xml/impl/FishData.java @@ -16,6 +16,7 @@ */ package com.l2jmobius.gameserver.data.xml.impl; +import java.io.File; import java.util.ArrayList; import java.util.HashMap; import java.util.List; @@ -25,7 +26,7 @@ import org.w3c.dom.Document; import org.w3c.dom.NamedNodeMap; import org.w3c.dom.Node; -import com.l2jmobius.commons.util.IXmlReader; +import com.l2jmobius.commons.util.IGameXmlReader; import com.l2jmobius.gameserver.model.StatsSet; import com.l2jmobius.gameserver.model.fishing.L2Fish; @@ -33,7 +34,7 @@ import com.l2jmobius.gameserver.model.fishing.L2Fish; * This class holds the Fish information. * @author nonom */ -public final class FishData implements IXmlReader +public final class FishData implements IGameXmlReader { private final Map _fishNormal = new HashMap<>(); private final Map _fishEasy = new HashMap<>(); @@ -58,7 +59,7 @@ public final class FishData implements IXmlReader } @Override - public void parseDocument(Document doc) + public void parseDocument(Document doc, File f) { for (Node n = doc.getFirstChild(); n != null; n = n.getNextSibling()) { diff --git a/L2J_Mobius_CT_2.6_HighFive/java/com/l2jmobius/gameserver/data/xml/impl/FishingMonstersData.java b/L2J_Mobius_CT_2.6_HighFive/java/com/l2jmobius/gameserver/data/xml/impl/FishingMonstersData.java index 668e3fedad..4964ed659f 100644 --- a/L2J_Mobius_CT_2.6_HighFive/java/com/l2jmobius/gameserver/data/xml/impl/FishingMonstersData.java +++ b/L2J_Mobius_CT_2.6_HighFive/java/com/l2jmobius/gameserver/data/xml/impl/FishingMonstersData.java @@ -16,6 +16,7 @@ */ package com.l2jmobius.gameserver.data.xml.impl; +import java.io.File; import java.util.HashMap; import java.util.Map; @@ -23,7 +24,7 @@ import org.w3c.dom.Document; import org.w3c.dom.NamedNodeMap; import org.w3c.dom.Node; -import com.l2jmobius.commons.util.IXmlReader; +import com.l2jmobius.commons.util.IGameXmlReader; import com.l2jmobius.gameserver.model.StatsSet; import com.l2jmobius.gameserver.model.fishing.L2FishingMonster; @@ -31,7 +32,7 @@ import com.l2jmobius.gameserver.model.fishing.L2FishingMonster; * This class holds the Fishing Monsters information. * @author nonom */ -public final class FishingMonstersData implements IXmlReader +public final class FishingMonstersData implements IGameXmlReader { private final Map _fishingMonstersData = new HashMap<>(); @@ -52,7 +53,7 @@ public final class FishingMonstersData implements IXmlReader } @Override - public void parseDocument(Document doc) + public void parseDocument(Document doc, File f) { for (Node n = doc.getFirstChild(); n != null; n = n.getNextSibling()) { diff --git a/L2J_Mobius_CT_2.6_HighFive/java/com/l2jmobius/gameserver/data/xml/impl/FishingRodsData.java b/L2J_Mobius_CT_2.6_HighFive/java/com/l2jmobius/gameserver/data/xml/impl/FishingRodsData.java index 65e7e4664e..c6bff4c62d 100644 --- a/L2J_Mobius_CT_2.6_HighFive/java/com/l2jmobius/gameserver/data/xml/impl/FishingRodsData.java +++ b/L2J_Mobius_CT_2.6_HighFive/java/com/l2jmobius/gameserver/data/xml/impl/FishingRodsData.java @@ -16,6 +16,7 @@ */ package com.l2jmobius.gameserver.data.xml.impl; +import java.io.File; import java.util.HashMap; import java.util.Map; @@ -23,7 +24,7 @@ import org.w3c.dom.Document; import org.w3c.dom.NamedNodeMap; import org.w3c.dom.Node; -import com.l2jmobius.commons.util.IXmlReader; +import com.l2jmobius.commons.util.IGameXmlReader; import com.l2jmobius.gameserver.model.StatsSet; import com.l2jmobius.gameserver.model.fishing.L2FishingRod; @@ -31,7 +32,7 @@ import com.l2jmobius.gameserver.model.fishing.L2FishingRod; * This class holds the Fishing Rods information. * @author nonom */ -public final class FishingRodsData implements IXmlReader +public final class FishingRodsData implements IGameXmlReader { private final Map _fishingRods = new HashMap<>(); @@ -52,7 +53,7 @@ public final class FishingRodsData implements IXmlReader } @Override - public void parseDocument(Document doc) + public void parseDocument(Document doc, File f) { for (Node n = doc.getFirstChild(); n != null; n = n.getNextSibling()) { diff --git a/L2J_Mobius_CT_2.6_HighFive/java/com/l2jmobius/gameserver/data/xml/impl/HennaData.java b/L2J_Mobius_CT_2.6_HighFive/java/com/l2jmobius/gameserver/data/xml/impl/HennaData.java index 737bb99223..db5b90c751 100644 --- a/L2J_Mobius_CT_2.6_HighFive/java/com/l2jmobius/gameserver/data/xml/impl/HennaData.java +++ b/L2J_Mobius_CT_2.6_HighFive/java/com/l2jmobius/gameserver/data/xml/impl/HennaData.java @@ -16,6 +16,7 @@ */ package com.l2jmobius.gameserver.data.xml.impl; +import java.io.File; import java.util.ArrayList; import java.util.HashMap; import java.util.List; @@ -25,7 +26,7 @@ import org.w3c.dom.Document; import org.w3c.dom.NamedNodeMap; import org.w3c.dom.Node; -import com.l2jmobius.commons.util.IXmlReader; +import com.l2jmobius.commons.util.IGameXmlReader; import com.l2jmobius.gameserver.model.StatsSet; import com.l2jmobius.gameserver.model.base.ClassId; import com.l2jmobius.gameserver.model.items.L2Henna; @@ -37,7 +38,7 @@ import com.l2jmobius.gameserver.model.items.L2Henna; * Allowed classes to wear each henna. * @author Zoey76 */ -public final class HennaData implements IXmlReader +public final class HennaData implements IGameXmlReader { private final Map _hennaList = new HashMap<>(); @@ -58,7 +59,7 @@ public final class HennaData implements IXmlReader } @Override - public void parseDocument(Document doc) + public void parseDocument(Document doc, File f) { for (Node n = doc.getFirstChild(); n != null; n = n.getNextSibling()) { diff --git a/L2J_Mobius_CT_2.6_HighFive/java/com/l2jmobius/gameserver/data/xml/impl/HitConditionBonusData.java b/L2J_Mobius_CT_2.6_HighFive/java/com/l2jmobius/gameserver/data/xml/impl/HitConditionBonusData.java index 7a4dd6758e..ca613fcdbf 100644 --- a/L2J_Mobius_CT_2.6_HighFive/java/com/l2jmobius/gameserver/data/xml/impl/HitConditionBonusData.java +++ b/L2J_Mobius_CT_2.6_HighFive/java/com/l2jmobius/gameserver/data/xml/impl/HitConditionBonusData.java @@ -16,11 +16,13 @@ */ package com.l2jmobius.gameserver.data.xml.impl; +import java.io.File; + import org.w3c.dom.Document; import org.w3c.dom.NamedNodeMap; import org.w3c.dom.Node; -import com.l2jmobius.commons.util.IXmlReader; +import com.l2jmobius.commons.util.IGameXmlReader; import com.l2jmobius.gameserver.GameTimeController; import com.l2jmobius.gameserver.model.actor.L2Character; @@ -28,7 +30,7 @@ import com.l2jmobius.gameserver.model.actor.L2Character; * This class load, holds and calculates the hit condition bonuses. * @author Nik */ -public final class HitConditionBonusData implements IXmlReader +public final class HitConditionBonusData implements IGameXmlReader { private int frontBonus = 0; private int sideBonus = 0; @@ -55,7 +57,7 @@ public final class HitConditionBonusData implements IXmlReader } @Override - public void parseDocument(Document doc) + public void parseDocument(Document doc, File f) { for (Node d = doc.getFirstChild().getFirstChild(); d != null; d = d.getNextSibling()) { diff --git a/L2J_Mobius_CT_2.6_HighFive/java/com/l2jmobius/gameserver/data/xml/impl/InitialEquipmentData.java b/L2J_Mobius_CT_2.6_HighFive/java/com/l2jmobius/gameserver/data/xml/impl/InitialEquipmentData.java index 785f0b44e4..4d89e79ba2 100644 --- a/L2J_Mobius_CT_2.6_HighFive/java/com/l2jmobius/gameserver/data/xml/impl/InitialEquipmentData.java +++ b/L2J_Mobius_CT_2.6_HighFive/java/com/l2jmobius/gameserver/data/xml/impl/InitialEquipmentData.java @@ -16,6 +16,7 @@ */ package com.l2jmobius.gameserver.data.xml.impl; +import java.io.File; import java.util.ArrayList; import java.util.HashMap; import java.util.List; @@ -26,7 +27,7 @@ import org.w3c.dom.NamedNodeMap; import org.w3c.dom.Node; import com.l2jmobius.Config; -import com.l2jmobius.commons.util.IXmlReader; +import com.l2jmobius.commons.util.IGameXmlReader; import com.l2jmobius.gameserver.model.StatsSet; import com.l2jmobius.gameserver.model.base.ClassId; import com.l2jmobius.gameserver.model.items.PcItemTemplate; @@ -36,7 +37,7 @@ import com.l2jmobius.gameserver.model.items.PcItemTemplate; * What items get each newly created character and if this item is equipped upon creation (Requires the item to be equippable). * @author Zoey76 */ -public final class InitialEquipmentData implements IXmlReader +public final class InitialEquipmentData implements IGameXmlReader { private final Map> _initialEquipmentList = new HashMap<>(); private static final String NORMAL = "data/stats/initialEquipment.xml"; @@ -59,7 +60,7 @@ public final class InitialEquipmentData implements IXmlReader } @Override - public void parseDocument(Document doc) + public void parseDocument(Document doc, File f) { for (Node n = doc.getFirstChild(); n != null; n = n.getNextSibling()) { diff --git a/L2J_Mobius_CT_2.6_HighFive/java/com/l2jmobius/gameserver/data/xml/impl/InitialShortcutData.java b/L2J_Mobius_CT_2.6_HighFive/java/com/l2jmobius/gameserver/data/xml/impl/InitialShortcutData.java index 980d74f1fc..d07f3d9876 100644 --- a/L2J_Mobius_CT_2.6_HighFive/java/com/l2jmobius/gameserver/data/xml/impl/InitialShortcutData.java +++ b/L2J_Mobius_CT_2.6_HighFive/java/com/l2jmobius/gameserver/data/xml/impl/InitialShortcutData.java @@ -16,6 +16,7 @@ */ package com.l2jmobius.gameserver.data.xml.impl; +import java.io.File; import java.util.ArrayList; import java.util.HashMap; import java.util.List; @@ -25,7 +26,7 @@ import org.w3c.dom.Document; import org.w3c.dom.NamedNodeMap; import org.w3c.dom.Node; -import com.l2jmobius.commons.util.IXmlReader; +import com.l2jmobius.commons.util.IGameXmlReader; import com.l2jmobius.gameserver.enums.MacroType; import com.l2jmobius.gameserver.enums.ShortcutType; import com.l2jmobius.gameserver.model.Macro; @@ -41,7 +42,7 @@ import com.l2jmobius.gameserver.network.serverpackets.ShortCutRegister; * What shortcuts get each newly created character. * @author Zoey76 */ -public final class InitialShortcutData implements IXmlReader +public final class InitialShortcutData implements IGameXmlReader { private final Map> _initialShortcutData = new HashMap<>(); private final List _initialGlobalShortcutList = new ArrayList<>(); @@ -69,7 +70,7 @@ public final class InitialShortcutData implements IXmlReader } @Override - public void parseDocument(Document doc) + public void parseDocument(Document doc, File f) { for (Node n = doc.getFirstChild(); n != null; n = n.getNextSibling()) { diff --git a/L2J_Mobius_CT_2.6_HighFive/java/com/l2jmobius/gameserver/data/xml/impl/ItemMallData.java b/L2J_Mobius_CT_2.6_HighFive/java/com/l2jmobius/gameserver/data/xml/impl/ItemMallData.java index 42005f9126..8e454a0eae 100644 --- a/L2J_Mobius_CT_2.6_HighFive/java/com/l2jmobius/gameserver/data/xml/impl/ItemMallData.java +++ b/L2J_Mobius_CT_2.6_HighFive/java/com/l2jmobius/gameserver/data/xml/impl/ItemMallData.java @@ -16,6 +16,7 @@ */ package com.l2jmobius.gameserver.data.xml.impl; +import java.io.File; import java.util.Collection; import java.util.HashMap; import java.util.Map; @@ -26,14 +27,14 @@ import org.w3c.dom.NamedNodeMap; import org.w3c.dom.Node; import com.l2jmobius.Config; -import com.l2jmobius.commons.util.IXmlReader; +import com.l2jmobius.commons.util.IGameXmlReader; import com.l2jmobius.gameserver.model.ItemMallProduct; import com.l2jmobius.gameserver.model.StatsSet; /** * @author Mobius */ -public class ItemMallData implements IXmlReader +public class ItemMallData implements IGameXmlReader { private static final Logger _log = Logger.getLogger(ItemMallData.class.getName()); private final Map _mallList = new HashMap<>(); @@ -57,7 +58,7 @@ public class ItemMallData implements IXmlReader } @Override - public void parseDocument(Document doc) + public void parseDocument(Document doc, File f) { NamedNodeMap attrs; Node att; diff --git a/L2J_Mobius_CT_2.6_HighFive/java/com/l2jmobius/gameserver/data/xml/impl/KarmaData.java b/L2J_Mobius_CT_2.6_HighFive/java/com/l2jmobius/gameserver/data/xml/impl/KarmaData.java index 6de0d32cae..b0bec30b14 100644 --- a/L2J_Mobius_CT_2.6_HighFive/java/com/l2jmobius/gameserver/data/xml/impl/KarmaData.java +++ b/L2J_Mobius_CT_2.6_HighFive/java/com/l2jmobius/gameserver/data/xml/impl/KarmaData.java @@ -16,6 +16,7 @@ */ package com.l2jmobius.gameserver.data.xml.impl; +import java.io.File; import java.util.HashMap; import java.util.Map; import java.util.logging.Level; @@ -24,12 +25,12 @@ import org.w3c.dom.Document; import org.w3c.dom.NamedNodeMap; import org.w3c.dom.Node; -import com.l2jmobius.commons.util.IXmlReader; +import com.l2jmobius.commons.util.IGameXmlReader; /** * @author UnAfraid */ -public class KarmaData implements IXmlReader +public class KarmaData implements IGameXmlReader { private final Map _karmaTable = new HashMap<>(); @@ -47,7 +48,7 @@ public class KarmaData implements IXmlReader } @Override - public void parseDocument(Document doc) + public void parseDocument(Document doc, File f) { for (Node n = doc.getFirstChild(); n != null; n = n.getNextSibling()) { diff --git a/L2J_Mobius_CT_2.6_HighFive/java/com/l2jmobius/gameserver/data/xml/impl/MultisellData.java b/L2J_Mobius_CT_2.6_HighFive/java/com/l2jmobius/gameserver/data/xml/impl/MultisellData.java index c2dece8dee..235e9e3c53 100644 --- a/L2J_Mobius_CT_2.6_HighFive/java/com/l2jmobius/gameserver/data/xml/impl/MultisellData.java +++ b/L2J_Mobius_CT_2.6_HighFive/java/com/l2jmobius/gameserver/data/xml/impl/MultisellData.java @@ -29,7 +29,7 @@ import org.w3c.dom.NamedNodeMap; import org.w3c.dom.Node; import com.l2jmobius.Config; -import com.l2jmobius.commons.util.IXmlReader; +import com.l2jmobius.commons.util.IGameXmlReader; import com.l2jmobius.commons.util.file.filter.NumericNameFilter; import com.l2jmobius.gameserver.model.StatsSet; import com.l2jmobius.gameserver.model.actor.L2Npc; @@ -45,7 +45,7 @@ import com.l2jmobius.gameserver.network.serverpackets.SystemMessage; import com.l2jmobius.gameserver.network.serverpackets.UserInfo; import com.l2jmobius.gameserver.util.Util; -public final class MultisellData implements IXmlReader +public final class MultisellData implements IGameXmlReader { private final Map _entries = new HashMap<>(); diff --git a/L2J_Mobius_CT_2.6_HighFive/java/com/l2jmobius/gameserver/data/xml/impl/NpcData.java b/L2J_Mobius_CT_2.6_HighFive/java/com/l2jmobius/gameserver/data/xml/impl/NpcData.java index c61523a568..15f32773be 100644 --- a/L2J_Mobius_CT_2.6_HighFive/java/com/l2jmobius/gameserver/data/xml/impl/NpcData.java +++ b/L2J_Mobius_CT_2.6_HighFive/java/com/l2jmobius/gameserver/data/xml/impl/NpcData.java @@ -34,7 +34,7 @@ import org.w3c.dom.NamedNodeMap; import org.w3c.dom.Node; import com.l2jmobius.Config; -import com.l2jmobius.commons.util.IXmlReader; +import com.l2jmobius.commons.util.IGameXmlReader; import com.l2jmobius.gameserver.datatables.ItemTable; import com.l2jmobius.gameserver.datatables.SkillData; import com.l2jmobius.gameserver.enums.AISkillScope; @@ -53,7 +53,7 @@ import com.l2jmobius.gameserver.util.Util; * NPC data parser. * @author NosBit */ -public class NpcData implements IXmlReader +public class NpcData implements IGameXmlReader { private final Map _npcs = new ConcurrentHashMap<>(); private final Map _clans = new ConcurrentHashMap<>(); @@ -790,7 +790,7 @@ public class NpcData implements IXmlReader * Once Spawn System gets reworked delete this class
* @author Zealar */ - private final class MinionData implements IXmlReader + private final class MinionData implements IGameXmlReader { public final Map> _tempMinions = new HashMap<>(); @@ -808,7 +808,7 @@ public class NpcData implements IXmlReader } @Override - public void parseDocument(Document doc) + public void parseDocument(Document doc, File f) { for (Node node = doc.getFirstChild(); node != null; node = node.getNextSibling()) { diff --git a/L2J_Mobius_CT_2.6_HighFive/java/com/l2jmobius/gameserver/data/xml/impl/OptionData.java b/L2J_Mobius_CT_2.6_HighFive/java/com/l2jmobius/gameserver/data/xml/impl/OptionData.java index 3cd925a3ee..de780e668c 100644 --- a/L2J_Mobius_CT_2.6_HighFive/java/com/l2jmobius/gameserver/data/xml/impl/OptionData.java +++ b/L2J_Mobius_CT_2.6_HighFive/java/com/l2jmobius/gameserver/data/xml/impl/OptionData.java @@ -16,6 +16,7 @@ */ package com.l2jmobius.gameserver.data.xml.impl; +import java.io.File; import java.util.HashMap; import java.util.Map; import java.util.logging.Level; @@ -24,7 +25,7 @@ import org.w3c.dom.Document; import org.w3c.dom.NamedNodeMap; import org.w3c.dom.Node; -import com.l2jmobius.commons.util.IXmlReader; +import com.l2jmobius.commons.util.IGameXmlReader; import com.l2jmobius.gameserver.model.holders.SkillHolder; import com.l2jmobius.gameserver.model.options.Options; import com.l2jmobius.gameserver.model.options.OptionsSkillHolder; @@ -36,7 +37,7 @@ import com.l2jmobius.gameserver.model.stats.functions.FuncTemplate; * Item Option data. * @author UnAfraid */ -public class OptionData implements IXmlReader +public class OptionData implements IGameXmlReader { private final Map _optionData = new HashMap<>(); @@ -54,7 +55,7 @@ public class OptionData implements IXmlReader } @Override - public void parseDocument(Document doc) + public void parseDocument(Document doc, File f) { for (Node n = doc.getFirstChild(); n != null; n = n.getNextSibling()) { diff --git a/L2J_Mobius_CT_2.6_HighFive/java/com/l2jmobius/gameserver/data/xml/impl/PetDataTable.java b/L2J_Mobius_CT_2.6_HighFive/java/com/l2jmobius/gameserver/data/xml/impl/PetDataTable.java index 1ba066e069..13e4db84fb 100644 --- a/L2J_Mobius_CT_2.6_HighFive/java/com/l2jmobius/gameserver/data/xml/impl/PetDataTable.java +++ b/L2J_Mobius_CT_2.6_HighFive/java/com/l2jmobius/gameserver/data/xml/impl/PetDataTable.java @@ -16,6 +16,7 @@ */ package com.l2jmobius.gameserver.data.xml.impl; +import java.io.File; import java.util.HashMap; import java.util.Map; @@ -23,7 +24,7 @@ import org.w3c.dom.Document; import org.w3c.dom.NamedNodeMap; import org.w3c.dom.Node; -import com.l2jmobius.commons.util.IXmlReader; +import com.l2jmobius.commons.util.IGameXmlReader; import com.l2jmobius.gameserver.enums.MountType; import com.l2jmobius.gameserver.model.L2PetData; import com.l2jmobius.gameserver.model.L2PetLevelData; @@ -34,7 +35,7 @@ import com.l2jmobius.gameserver.model.StatsSet; * TODO: load and use all pet parameters. * @author Zoey76 (rework) */ -public final class PetDataTable implements IXmlReader +public final class PetDataTable implements IGameXmlReader { private final Map _pets = new HashMap<>(); @@ -55,7 +56,7 @@ public final class PetDataTable implements IXmlReader } @Override - public void parseDocument(Document doc) + public void parseDocument(Document doc, File f) { NamedNodeMap attrs; for (Node d = doc.getFirstChild().getFirstChild(); d != null; d = d.getNextSibling()) diff --git a/L2J_Mobius_CT_2.6_HighFive/java/com/l2jmobius/gameserver/data/xml/impl/PetSkillData.java b/L2J_Mobius_CT_2.6_HighFive/java/com/l2jmobius/gameserver/data/xml/impl/PetSkillData.java index 0d474ade0b..cdfc1f2201 100644 --- a/L2J_Mobius_CT_2.6_HighFive/java/com/l2jmobius/gameserver/data/xml/impl/PetSkillData.java +++ b/L2J_Mobius_CT_2.6_HighFive/java/com/l2jmobius/gameserver/data/xml/impl/PetSkillData.java @@ -27,7 +27,7 @@ import org.w3c.dom.Document; import org.w3c.dom.NamedNodeMap; import org.w3c.dom.Node; -import com.l2jmobius.commons.util.IXmlReader; +import com.l2jmobius.commons.util.IGameXmlReader; import com.l2jmobius.gameserver.datatables.SkillData; import com.l2jmobius.gameserver.model.actor.L2Summon; import com.l2jmobius.gameserver.model.holders.SkillHolder; @@ -35,7 +35,7 @@ import com.l2jmobius.gameserver.model.holders.SkillHolder; /** * @author Mobius */ -public class PetSkillData implements IXmlReader +public class PetSkillData implements IGameXmlReader { private static Logger LOGGER = Logger.getLogger(PetSkillData.class.getName()); private final Map> _skillTrees = new HashMap<>(); diff --git a/L2J_Mobius_CT_2.6_HighFive/java/com/l2jmobius/gameserver/data/xml/impl/PlayerTemplateData.java b/L2J_Mobius_CT_2.6_HighFive/java/com/l2jmobius/gameserver/data/xml/impl/PlayerTemplateData.java index 9ddbfb2a9a..8c96aa1bfe 100644 --- a/L2J_Mobius_CT_2.6_HighFive/java/com/l2jmobius/gameserver/data/xml/impl/PlayerTemplateData.java +++ b/L2J_Mobius_CT_2.6_HighFive/java/com/l2jmobius/gameserver/data/xml/impl/PlayerTemplateData.java @@ -16,6 +16,7 @@ */ package com.l2jmobius.gameserver.data.xml.impl; +import java.io.File; import java.util.ArrayList; import java.util.HashMap; import java.util.List; @@ -26,7 +27,7 @@ import org.w3c.dom.Document; import org.w3c.dom.NamedNodeMap; import org.w3c.dom.Node; -import com.l2jmobius.commons.util.IXmlReader; +import com.l2jmobius.commons.util.IGameXmlReader; import com.l2jmobius.gameserver.model.Location; import com.l2jmobius.gameserver.model.StatsSet; import com.l2jmobius.gameserver.model.actor.templates.L2PcTemplate; @@ -36,7 +37,7 @@ import com.l2jmobius.gameserver.model.base.ClassId; * Loads player's base stats. * @author Forsaiken, Zoey76, GKR */ -public final class PlayerTemplateData implements IXmlReader +public final class PlayerTemplateData implements IGameXmlReader { private static final Logger LOGGER = Logger.getLogger(PlayerTemplateData.class.getName()); @@ -59,7 +60,7 @@ public final class PlayerTemplateData implements IXmlReader } @Override - public void parseDocument(Document doc) + public void parseDocument(Document doc, File f) { NamedNodeMap attrs; int classId = 0; diff --git a/L2J_Mobius_CT_2.6_HighFive/java/com/l2jmobius/gameserver/data/xml/impl/PlayerXpPercentLostData.java b/L2J_Mobius_CT_2.6_HighFive/java/com/l2jmobius/gameserver/data/xml/impl/PlayerXpPercentLostData.java index a39a095161..c4529b48b4 100644 --- a/L2J_Mobius_CT_2.6_HighFive/java/com/l2jmobius/gameserver/data/xml/impl/PlayerXpPercentLostData.java +++ b/L2J_Mobius_CT_2.6_HighFive/java/com/l2jmobius/gameserver/data/xml/impl/PlayerXpPercentLostData.java @@ -16,19 +16,20 @@ */ package com.l2jmobius.gameserver.data.xml.impl; +import java.io.File; import java.util.Arrays; import org.w3c.dom.Document; import org.w3c.dom.NamedNodeMap; import org.w3c.dom.Node; -import com.l2jmobius.commons.util.IXmlReader; +import com.l2jmobius.commons.util.IGameXmlReader; /** * This class holds the Player Xp Percent Lost Data for each level for players. * @author Zealar */ -public final class PlayerXpPercentLostData implements IXmlReader +public final class PlayerXpPercentLostData implements IGameXmlReader { private final int _maxlevel = ExperienceData.getInstance().getMaxLevel(); private final double[] _playerXpPercentLost = new double[_maxlevel + 1]; @@ -46,7 +47,7 @@ public final class PlayerXpPercentLostData implements IXmlReader } @Override - public void parseDocument(Document doc) + public void parseDocument(Document doc, File f) { for (Node n = doc.getFirstChild(); n != null; n = n.getNextSibling()) { diff --git a/L2J_Mobius_CT_2.6_HighFive/java/com/l2jmobius/gameserver/data/xml/impl/RecipeData.java b/L2J_Mobius_CT_2.6_HighFive/java/com/l2jmobius/gameserver/data/xml/impl/RecipeData.java index d556126f46..92862dd983 100644 --- a/L2J_Mobius_CT_2.6_HighFive/java/com/l2jmobius/gameserver/data/xml/impl/RecipeData.java +++ b/L2J_Mobius_CT_2.6_HighFive/java/com/l2jmobius/gameserver/data/xml/impl/RecipeData.java @@ -16,6 +16,7 @@ */ package com.l2jmobius.gameserver.data.xml.impl; +import java.io.File; import java.util.ArrayList; import java.util.HashMap; import java.util.List; @@ -25,7 +26,7 @@ import org.w3c.dom.Document; import org.w3c.dom.NamedNodeMap; import org.w3c.dom.Node; -import com.l2jmobius.commons.util.IXmlReader; +import com.l2jmobius.commons.util.IGameXmlReader; import com.l2jmobius.gameserver.model.L2RecipeInstance; import com.l2jmobius.gameserver.model.L2RecipeList; import com.l2jmobius.gameserver.model.L2RecipeStatInstance; @@ -36,7 +37,7 @@ import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance; * The Class RecipeData. * @author Zoey76 */ -public class RecipeData implements IXmlReader +public class RecipeData implements IGameXmlReader { private final Map _recipes = new HashMap<>(); @@ -57,7 +58,7 @@ public class RecipeData implements IXmlReader } @Override - public void parseDocument(Document doc) + public void parseDocument(Document doc, File f) { // TODO: Cleanup checks enforced by XSD. final List recipePartList = new ArrayList<>(); diff --git a/L2J_Mobius_CT_2.6_HighFive/java/com/l2jmobius/gameserver/data/xml/impl/SecondaryAuthData.java b/L2J_Mobius_CT_2.6_HighFive/java/com/l2jmobius/gameserver/data/xml/impl/SecondaryAuthData.java index 29ca0af890..22996482fd 100644 --- a/L2J_Mobius_CT_2.6_HighFive/java/com/l2jmobius/gameserver/data/xml/impl/SecondaryAuthData.java +++ b/L2J_Mobius_CT_2.6_HighFive/java/com/l2jmobius/gameserver/data/xml/impl/SecondaryAuthData.java @@ -24,13 +24,13 @@ import java.util.logging.Level; import org.w3c.dom.Document; import org.w3c.dom.Node; -import com.l2jmobius.commons.util.IXmlReader; +import com.l2jmobius.commons.util.IGameXmlReader; /** * Secondary Auth data. * @author NosBit */ -public class SecondaryAuthData implements IXmlReader +public class SecondaryAuthData implements IGameXmlReader { private final Set _forbiddenPasswords = new HashSet<>(); private boolean _enabled = false; @@ -52,7 +52,7 @@ public class SecondaryAuthData implements IXmlReader } @Override - public void parseDocument(Document doc) + public void parseDocument(Document doc, File f) { try { diff --git a/L2J_Mobius_CT_2.6_HighFive/java/com/l2jmobius/gameserver/data/xml/impl/SiegeScheduleData.java b/L2J_Mobius_CT_2.6_HighFive/java/com/l2jmobius/gameserver/data/xml/impl/SiegeScheduleData.java index 8fdf463060..e4883b72fa 100644 --- a/L2J_Mobius_CT_2.6_HighFive/java/com/l2jmobius/gameserver/data/xml/impl/SiegeScheduleData.java +++ b/L2J_Mobius_CT_2.6_HighFive/java/com/l2jmobius/gameserver/data/xml/impl/SiegeScheduleData.java @@ -16,6 +16,7 @@ */ package com.l2jmobius.gameserver.data.xml.impl; +import java.io.File; import java.util.ArrayList; import java.util.Calendar; import java.util.List; @@ -25,7 +26,7 @@ import org.w3c.dom.Document; import org.w3c.dom.NamedNodeMap; import org.w3c.dom.Node; -import com.l2jmobius.commons.util.IXmlReader; +import com.l2jmobius.commons.util.IGameXmlReader; import com.l2jmobius.gameserver.model.SiegeScheduleDate; import com.l2jmobius.gameserver.model.StatsSet; import com.l2jmobius.gameserver.util.Util; @@ -33,7 +34,7 @@ import com.l2jmobius.gameserver.util.Util; /** * @author UnAfraid */ -public class SiegeScheduleData implements IXmlReader +public class SiegeScheduleData implements IGameXmlReader { private final List _scheduleData = new ArrayList<>(); @@ -56,7 +57,7 @@ public class SiegeScheduleData implements IXmlReader } @Override - public void parseDocument(Document doc) + public void parseDocument(Document doc, File f) { for (Node n = doc.getFirstChild(); n != null; n = n.getNextSibling()) { diff --git a/L2J_Mobius_CT_2.6_HighFive/java/com/l2jmobius/gameserver/data/xml/impl/SkillLearnData.java b/L2J_Mobius_CT_2.6_HighFive/java/com/l2jmobius/gameserver/data/xml/impl/SkillLearnData.java index 65e7c629fa..fc2496c691 100644 --- a/L2J_Mobius_CT_2.6_HighFive/java/com/l2jmobius/gameserver/data/xml/impl/SkillLearnData.java +++ b/L2J_Mobius_CT_2.6_HighFive/java/com/l2jmobius/gameserver/data/xml/impl/SkillLearnData.java @@ -16,6 +16,7 @@ */ package com.l2jmobius.gameserver.data.xml.impl; +import java.io.File; import java.util.ArrayList; import java.util.HashMap; import java.util.List; @@ -24,14 +25,14 @@ import java.util.Map; import org.w3c.dom.Document; import org.w3c.dom.Node; -import com.l2jmobius.commons.util.IXmlReader; +import com.l2jmobius.commons.util.IGameXmlReader; import com.l2jmobius.gameserver.model.base.ClassId; /** * Holds all skill learn data for all NPCs. * @author xban1x */ -public final class SkillLearnData implements IXmlReader +public final class SkillLearnData implements IGameXmlReader { private final Map> _skillLearn = new HashMap<>(); @@ -49,7 +50,7 @@ public final class SkillLearnData implements IXmlReader } @Override - public void parseDocument(Document doc) + public void parseDocument(Document doc, File f) { for (Node node = doc.getFirstChild(); node != null; node = node.getNextSibling()) { diff --git a/L2J_Mobius_CT_2.6_HighFive/java/com/l2jmobius/gameserver/data/xml/impl/SkillTreesData.java b/L2J_Mobius_CT_2.6_HighFive/java/com/l2jmobius/gameserver/data/xml/impl/SkillTreesData.java index b70048b07c..726061340f 100644 --- a/L2J_Mobius_CT_2.6_HighFive/java/com/l2jmobius/gameserver/data/xml/impl/SkillTreesData.java +++ b/L2J_Mobius_CT_2.6_HighFive/java/com/l2jmobius/gameserver/data/xml/impl/SkillTreesData.java @@ -16,6 +16,7 @@ */ package com.l2jmobius.gameserver.data.xml.impl; +import java.io.File; import java.util.ArrayList; import java.util.Arrays; import java.util.Collection; @@ -32,7 +33,7 @@ import org.w3c.dom.NamedNodeMap; import org.w3c.dom.Node; import com.l2jmobius.Config; -import com.l2jmobius.commons.util.IXmlReader; +import com.l2jmobius.commons.util.IGameXmlReader; import com.l2jmobius.gameserver.datatables.SkillData; import com.l2jmobius.gameserver.enums.Race; import com.l2jmobius.gameserver.model.L2Clan; @@ -72,7 +73,7 @@ import com.l2jmobius.gameserver.model.skills.Skill; * For XML schema please refer to skillTrees.xsd in datapack in xsd folder and for parameters documentation refer to documentation.txt in skillTrees folder.
* @author Zoey76 */ -public final class SkillTreesData implements IXmlReader +public final class SkillTreesData implements IGameXmlReader { // ClassId, Map of Skill Hash Code, L2SkillLearn private final Map> _classSkillTrees = new LinkedHashMap<>(); @@ -142,7 +143,7 @@ public final class SkillTreesData implements IXmlReader * Parse a skill tree file and store it into the correct skill tree. */ @Override - public void parseDocument(Document doc) + public void parseDocument(Document doc, File f) { int cId = -1; ClassId classId = null; diff --git a/L2J_Mobius_CT_2.6_HighFive/java/com/l2jmobius/gameserver/data/xml/impl/StaticObjectData.java b/L2J_Mobius_CT_2.6_HighFive/java/com/l2jmobius/gameserver/data/xml/impl/StaticObjectData.java index abc8bfcd61..17c7aa0433 100644 --- a/L2J_Mobius_CT_2.6_HighFive/java/com/l2jmobius/gameserver/data/xml/impl/StaticObjectData.java +++ b/L2J_Mobius_CT_2.6_HighFive/java/com/l2jmobius/gameserver/data/xml/impl/StaticObjectData.java @@ -16,6 +16,7 @@ */ package com.l2jmobius.gameserver.data.xml.impl; +import java.io.File; import java.util.Collection; import java.util.HashMap; import java.util.Map; @@ -24,7 +25,7 @@ import org.w3c.dom.Document; import org.w3c.dom.NamedNodeMap; import org.w3c.dom.Node; -import com.l2jmobius.commons.util.IXmlReader; +import com.l2jmobius.commons.util.IGameXmlReader; import com.l2jmobius.gameserver.model.StatsSet; import com.l2jmobius.gameserver.model.actor.instance.L2StaticObjectInstance; import com.l2jmobius.gameserver.model.actor.templates.L2CharTemplate; @@ -33,7 +34,7 @@ import com.l2jmobius.gameserver.model.actor.templates.L2CharTemplate; * This class loads and holds all static object data. * @author UnAfraid */ -public final class StaticObjectData implements IXmlReader +public final class StaticObjectData implements IGameXmlReader { private final Map _staticObjects = new HashMap<>(); @@ -54,7 +55,7 @@ public final class StaticObjectData implements IXmlReader } @Override - public void parseDocument(Document doc) + public void parseDocument(Document doc, File f) { for (Node n = doc.getFirstChild(); n != null; n = n.getNextSibling()) { diff --git a/L2J_Mobius_CT_2.6_HighFive/java/com/l2jmobius/gameserver/data/xml/impl/TransformData.java b/L2J_Mobius_CT_2.6_HighFive/java/com/l2jmobius/gameserver/data/xml/impl/TransformData.java index fbd5bf9d97..a8dc9c0878 100644 --- a/L2J_Mobius_CT_2.6_HighFive/java/com/l2jmobius/gameserver/data/xml/impl/TransformData.java +++ b/L2J_Mobius_CT_2.6_HighFive/java/com/l2jmobius/gameserver/data/xml/impl/TransformData.java @@ -16,6 +16,7 @@ */ package com.l2jmobius.gameserver.data.xml.impl; +import java.io.File; import java.util.HashMap; import java.util.Map; import java.util.logging.Level; @@ -24,7 +25,7 @@ import org.w3c.dom.Document; import org.w3c.dom.NamedNodeMap; import org.w3c.dom.Node; -import com.l2jmobius.commons.util.IXmlReader; +import com.l2jmobius.commons.util.IGameXmlReader; import com.l2jmobius.gameserver.model.StatsSet; import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance; import com.l2jmobius.gameserver.model.actor.transform.Transform; @@ -38,7 +39,7 @@ import com.l2jmobius.gameserver.network.serverpackets.ExBasicActionList; /** * @author UnAfraid */ -public final class TransformData implements IXmlReader +public final class TransformData implements IGameXmlReader { private final Map _transformData = new HashMap<>(); @@ -56,7 +57,7 @@ public final class TransformData implements IXmlReader } @Override - public void parseDocument(Document doc) + public void parseDocument(Document doc, File f) { for (Node n = doc.getFirstChild(); n != null; n = n.getNextSibling()) { diff --git a/L2J_Mobius_CT_2.6_HighFive/java/com/l2jmobius/gameserver/data/xml/impl/UIData.java b/L2J_Mobius_CT_2.6_HighFive/java/com/l2jmobius/gameserver/data/xml/impl/UIData.java index 09cc8e2993..b388a55748 100644 --- a/L2J_Mobius_CT_2.6_HighFive/java/com/l2jmobius/gameserver/data/xml/impl/UIData.java +++ b/L2J_Mobius_CT_2.6_HighFive/java/com/l2jmobius/gameserver/data/xml/impl/UIData.java @@ -16,6 +16,7 @@ */ package com.l2jmobius.gameserver.data.xml.impl; +import java.io.File; import java.util.ArrayList; import java.util.HashMap; import java.util.List; @@ -25,14 +26,14 @@ import java.util.logging.Logger; import org.w3c.dom.Document; import org.w3c.dom.Node; -import com.l2jmobius.commons.util.IXmlReader; +import com.l2jmobius.commons.util.IGameXmlReader; import com.l2jmobius.gameserver.model.ActionKey; /** * UI Data parser. * @author Zoey76 */ -public class UIData implements IXmlReader +public class UIData implements IGameXmlReader { private static final Logger LOGGER = Logger.getLogger(UIData.class.getName()); @@ -54,7 +55,7 @@ public class UIData implements IXmlReader } @Override - public void parseDocument(Document doc) + public void parseDocument(Document doc, File f) { for (Node n = doc.getFirstChild(); n != null; n = n.getNextSibling()) { diff --git a/L2J_Mobius_CT_2.6_HighFive/java/com/l2jmobius/gameserver/datatables/SpawnTable.java b/L2J_Mobius_CT_2.6_HighFive/java/com/l2jmobius/gameserver/datatables/SpawnTable.java index 0cbf09f0fe..55457c4d7a 100644 --- a/L2J_Mobius_CT_2.6_HighFive/java/com/l2jmobius/gameserver/datatables/SpawnTable.java +++ b/L2J_Mobius_CT_2.6_HighFive/java/com/l2jmobius/gameserver/datatables/SpawnTable.java @@ -16,6 +16,7 @@ */ package com.l2jmobius.gameserver.datatables; +import java.io.File; import java.sql.Connection; import java.sql.PreparedStatement; import java.sql.ResultSet; @@ -35,7 +36,7 @@ import org.w3c.dom.Node; import com.l2jmobius.Config; import com.l2jmobius.commons.database.DatabaseFactory; -import com.l2jmobius.commons.util.IXmlReader; +import com.l2jmobius.commons.util.IGameXmlReader; import com.l2jmobius.gameserver.data.xml.impl.NpcData; import com.l2jmobius.gameserver.instancemanager.DayNightSpawnManager; import com.l2jmobius.gameserver.instancemanager.ZoneManager; @@ -47,7 +48,7 @@ import com.l2jmobius.gameserver.model.actor.templates.L2NpcTemplate; * Spawn data retriever. * @author Zoey76 */ -public final class SpawnTable implements IXmlReader +public final class SpawnTable implements IGameXmlReader { private static final Logger LOGGER = Logger.getLogger(SpawnTable.class.getName()); // SQL @@ -105,7 +106,7 @@ public final class SpawnTable implements IXmlReader } @Override - public void parseDocument(Document doc) + public void parseDocument(Document doc, File f) { NamedNodeMap attrs; for (Node list = doc.getFirstChild(); list != null; list = list.getNextSibling()) diff --git a/L2J_Mobius_CT_2.6_HighFive/java/com/l2jmobius/gameserver/instancemanager/CastleManorManager.java b/L2J_Mobius_CT_2.6_HighFive/java/com/l2jmobius/gameserver/instancemanager/CastleManorManager.java index 1e796c8f3a..861236f919 100644 --- a/L2J_Mobius_CT_2.6_HighFive/java/com/l2jmobius/gameserver/instancemanager/CastleManorManager.java +++ b/L2J_Mobius_CT_2.6_HighFive/java/com/l2jmobius/gameserver/instancemanager/CastleManorManager.java @@ -16,6 +16,7 @@ */ package com.l2jmobius.gameserver.instancemanager; +import java.io.File; import java.sql.Connection; import java.sql.PreparedStatement; import java.sql.ResultSet; @@ -37,7 +38,7 @@ import org.w3c.dom.Node; import com.l2jmobius.Config; import com.l2jmobius.commons.concurrent.ThreadPool; import com.l2jmobius.commons.database.DatabaseFactory; -import com.l2jmobius.commons.util.IXmlReader; +import com.l2jmobius.commons.util.IGameXmlReader; import com.l2jmobius.commons.util.Rnd; import com.l2jmobius.gameserver.enums.ManorMode; import com.l2jmobius.gameserver.model.CropProcure; @@ -55,7 +56,7 @@ import com.l2jmobius.gameserver.network.SystemMessageId; * Castle manor system. * @author malyelfik */ -public final class CastleManorManager implements IXmlReader, IStorable +public final class CastleManorManager implements IGameXmlReader, IStorable { // SQL queries private static final String INSERT_PRODUCT = "INSERT INTO castle_manor_production VALUES (?, ?, ?, ?, ?, ?)"; @@ -119,7 +120,7 @@ public final class CastleManorManager implements IXmlReader, IStorable } @Override - public final void parseDocument(Document doc) + public void parseDocument(Document doc, File f) { StatsSet set; NamedNodeMap attrs; diff --git a/L2J_Mobius_CT_2.6_HighFive/java/com/l2jmobius/gameserver/instancemanager/InstanceManager.java b/L2J_Mobius_CT_2.6_HighFive/java/com/l2jmobius/gameserver/instancemanager/InstanceManager.java index ac78778a1f..ab69cb5cd5 100644 --- a/L2J_Mobius_CT_2.6_HighFive/java/com/l2jmobius/gameserver/instancemanager/InstanceManager.java +++ b/L2J_Mobius_CT_2.6_HighFive/java/com/l2jmobius/gameserver/instancemanager/InstanceManager.java @@ -16,6 +16,7 @@ */ package com.l2jmobius.gameserver.instancemanager; +import java.io.File; import java.sql.Connection; import java.sql.PreparedStatement; import java.sql.ResultSet; @@ -28,7 +29,7 @@ import org.w3c.dom.NamedNodeMap; import org.w3c.dom.Node; import com.l2jmobius.commons.database.DatabaseFactory; -import com.l2jmobius.commons.util.IXmlReader; +import com.l2jmobius.commons.util.IGameXmlReader; import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance; import com.l2jmobius.gameserver.model.entity.Instance; import com.l2jmobius.gameserver.model.instancezone.InstanceWorld; @@ -36,7 +37,7 @@ import com.l2jmobius.gameserver.model.instancezone.InstanceWorld; /** * @author evill33t, GodKratos */ -public final class InstanceManager implements IXmlReader +public final class InstanceManager implements IGameXmlReader { private static final Map INSTANCES = new ConcurrentHashMap<>(); private final Map _instanceWorlds = new ConcurrentHashMap<>(); @@ -198,7 +199,7 @@ public final class InstanceManager implements IXmlReader } @Override - public void parseDocument(Document doc) + public void parseDocument(Document doc, File f) { for (Node n = doc.getFirstChild(); n != null; n = n.getNextSibling()) { diff --git a/L2J_Mobius_CT_2.6_HighFive/java/com/l2jmobius/gameserver/instancemanager/MapRegionManager.java b/L2J_Mobius_CT_2.6_HighFive/java/com/l2jmobius/gameserver/instancemanager/MapRegionManager.java index 9ca6f99e80..a3ca0b5434 100644 --- a/L2J_Mobius_CT_2.6_HighFive/java/com/l2jmobius/gameserver/instancemanager/MapRegionManager.java +++ b/L2J_Mobius_CT_2.6_HighFive/java/com/l2jmobius/gameserver/instancemanager/MapRegionManager.java @@ -16,6 +16,7 @@ */ package com.l2jmobius.gameserver.instancemanager; +import java.io.File; import java.util.HashMap; import java.util.List; import java.util.Map; @@ -24,7 +25,7 @@ import org.w3c.dom.Document; import org.w3c.dom.NamedNodeMap; import org.w3c.dom.Node; -import com.l2jmobius.commons.util.IXmlReader; +import com.l2jmobius.commons.util.IGameXmlReader; import com.l2jmobius.gameserver.SevenSigns; import com.l2jmobius.gameserver.model.L2MapRegion; import com.l2jmobius.gameserver.model.L2Object; @@ -46,7 +47,7 @@ import com.l2jmobius.gameserver.model.zone.type.L2RespawnZone; * Map Region Manager. * @author Nyaran */ -public final class MapRegionManager implements IXmlReader +public final class MapRegionManager implements IGameXmlReader { private static final Map _regions = new HashMap<>(); private static final String defaultRespawn = "talking_island_town"; @@ -65,7 +66,7 @@ public final class MapRegionManager implements IXmlReader } @Override - public void parseDocument(Document doc) + public void parseDocument(Document doc, File f) { NamedNodeMap attrs; String name; diff --git a/L2J_Mobius_CT_2.6_HighFive/java/com/l2jmobius/gameserver/instancemanager/WalkingManager.java b/L2J_Mobius_CT_2.6_HighFive/java/com/l2jmobius/gameserver/instancemanager/WalkingManager.java index ba95e86bbe..6617b729f7 100644 --- a/L2J_Mobius_CT_2.6_HighFive/java/com/l2jmobius/gameserver/instancemanager/WalkingManager.java +++ b/L2J_Mobius_CT_2.6_HighFive/java/com/l2jmobius/gameserver/instancemanager/WalkingManager.java @@ -16,6 +16,7 @@ */ package com.l2jmobius.gameserver.instancemanager; +import java.io.File; import java.util.ArrayList; import java.util.HashMap; import java.util.List; @@ -26,7 +27,7 @@ import org.w3c.dom.NamedNodeMap; import org.w3c.dom.Node; import com.l2jmobius.commons.concurrent.ThreadPool; -import com.l2jmobius.commons.util.IXmlReader; +import com.l2jmobius.commons.util.IGameXmlReader; import com.l2jmobius.gameserver.ai.CtrlIntention; import com.l2jmobius.gameserver.enums.ChatType; import com.l2jmobius.gameserver.instancemanager.tasks.StartMovingTask; @@ -46,7 +47,7 @@ import com.l2jmobius.gameserver.network.NpcStringId; * This class manages walking monsters. * @author GKR */ -public final class WalkingManager implements IXmlReader +public final class WalkingManager implements IGameXmlReader { // Repeat style: // -1 - no repeat @@ -77,7 +78,7 @@ public final class WalkingManager implements IXmlReader } @Override - public void parseDocument(Document doc) + public void parseDocument(Document doc, File f) { for (Node d = doc.getFirstChild().getFirstChild(); d != null; d = d.getNextSibling()) { diff --git a/L2J_Mobius_CT_2.6_HighFive/java/com/l2jmobius/gameserver/instancemanager/ZoneManager.java b/L2J_Mobius_CT_2.6_HighFive/java/com/l2jmobius/gameserver/instancemanager/ZoneManager.java index be9e82c416..8290a4fe09 100644 --- a/L2J_Mobius_CT_2.6_HighFive/java/com/l2jmobius/gameserver/instancemanager/ZoneManager.java +++ b/L2J_Mobius_CT_2.6_HighFive/java/com/l2jmobius/gameserver/instancemanager/ZoneManager.java @@ -29,7 +29,7 @@ import org.w3c.dom.Document; import org.w3c.dom.NamedNodeMap; import org.w3c.dom.Node; -import com.l2jmobius.commons.util.IXmlReader; +import com.l2jmobius.commons.util.IGameXmlReader; import com.l2jmobius.gameserver.model.L2Object; import com.l2jmobius.gameserver.model.L2World; import com.l2jmobius.gameserver.model.L2WorldRegion; @@ -51,7 +51,7 @@ import com.l2jmobius.gameserver.model.zone.type.NpcSpawnTerritory; * This class manages the zones * @author durgus */ -public final class ZoneManager implements IXmlReader +public final class ZoneManager implements IGameXmlReader { private static final Map _settings = new HashMap<>(); diff --git a/L2J_Mobius_CT_2.6_HighFive/java/com/l2jmobius/gameserver/model/quest/Quest.java b/L2J_Mobius_CT_2.6_HighFive/java/com/l2jmobius/gameserver/model/quest/Quest.java index 2cc96ab98b..bc5ce25f52 100644 --- a/L2J_Mobius_CT_2.6_HighFive/java/com/l2jmobius/gameserver/model/quest/Quest.java +++ b/L2J_Mobius_CT_2.6_HighFive/java/com/l2jmobius/gameserver/model/quest/Quest.java @@ -34,8 +34,8 @@ import java.util.logging.Level; import com.l2jmobius.Config; import com.l2jmobius.commons.database.DatabaseFactory; -import com.l2jmobius.commons.util.Rnd; import com.l2jmobius.commons.util.CommonUtil; +import com.l2jmobius.commons.util.Rnd; import com.l2jmobius.gameserver.cache.HtmCache; import com.l2jmobius.gameserver.datatables.ItemTable; import com.l2jmobius.gameserver.enums.CategoryType; diff --git a/L2J_Mobius_CT_2.6_HighFive/java/com/l2jmobius/loginserver/GameServerTable.java b/L2J_Mobius_CT_2.6_HighFive/java/com/l2jmobius/loginserver/GameServerTable.java index 800850c93b..23ab31bac8 100644 --- a/L2J_Mobius_CT_2.6_HighFive/java/com/l2jmobius/loginserver/GameServerTable.java +++ b/L2J_Mobius_CT_2.6_HighFive/java/com/l2jmobius/loginserver/GameServerTable.java @@ -16,6 +16,7 @@ */ package com.l2jmobius.loginserver; +import java.io.File; import java.math.BigInteger; import java.net.InetAddress; import java.net.UnknownHostException; @@ -29,13 +30,14 @@ import java.sql.Statement; import java.util.ArrayList; import java.util.HashMap; import java.util.Map; +import java.util.logging.Logger; import org.w3c.dom.Document; import org.w3c.dom.NodeList; import com.l2jmobius.commons.database.DatabaseFactory; +import com.l2jmobius.commons.util.IGameXmlReader; import com.l2jmobius.commons.util.IPSubnet; -import com.l2jmobius.commons.util.IXmlReader; import com.l2jmobius.commons.util.Rnd; import com.l2jmobius.loginserver.network.gameserverpackets.ServerStatus; @@ -43,8 +45,10 @@ import com.l2jmobius.loginserver.network.gameserverpackets.ServerStatus; * The Class GameServerTable loads the game server names and initialize the game server tables. * @author KenM, Zoey76 */ -public final class GameServerTable implements IXmlReader +public final class GameServerTable implements IGameXmlReader { + private static final Logger LOGGER = Logger.getLogger(GameServerTable.class.getName()); + // Server Names private static final Map SERVER_NAMES = new HashMap<>(); // Game Server Table @@ -76,7 +80,7 @@ public final class GameServerTable implements IXmlReader } @Override - public void parseDocument(Document doc) + public void parseDocument(Document doc, File f) { final NodeList servers = doc.getElementsByTagName("server"); for (int s = 0; s < servers.getLength(); s++) @@ -277,7 +281,11 @@ public final class GameServerTable implements IXmlReader */ private String hexToString(byte[] hex) { - return hex == null ? "null" : new BigInteger(hex).toString(16); + if (hex == null) + { + return "null"; + } + return new BigInteger(hex).toString(16); } /** @@ -454,7 +462,11 @@ public final class GameServerTable implements IXmlReader */ public int getCurrentPlayerCount() { - return _gst == null ? 0 : _gst.getPlayerCount(); + if (_gst == null) + { + return 0; + } + return _gst.getPlayerCount(); } /**