Dropped IGameXmlReader.

ScriptEngineManager class cleanup.
Use of ThreadPool to decrease startup time.
This commit is contained in:
MobiusDevelopment
2019-04-05 04:14:32 +00:00
parent e5fd371ae8
commit eed915b9dc
1036 changed files with 4975 additions and 6228 deletions

View File

@@ -2,10 +2,7 @@
<list xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../data/xsd/Scripts.xsd">
<!-- Skip these filenames from script loading, because they are already loaded using a different way. -->
<exclude file="package-info.java" />
<exclude file="MasterHandler.java" />
<exclude file="EffectMasterHandler.java" />
<exclude file="SkillConditionMasterHandler.java" />
<exclude file="ConditionMasterHandler.java" />
<exclude file="handlers" />
<!--
With this file you can exclude/include specific folders/files from within the scripts directory.

View File

@@ -29,7 +29,7 @@ import org.w3c.dom.NamedNodeMap;
import org.w3c.dom.Node;
import com.l2jmobius.commons.concurrent.ThreadPool;
import com.l2jmobius.commons.util.IGameXmlReader;
import com.l2jmobius.commons.util.IXmlReader;
import com.l2jmobius.gameserver.ai.CtrlIntention;
import com.l2jmobius.gameserver.enums.ChatType;
import com.l2jmobius.gameserver.geoengine.GeoEngine;
@@ -56,7 +56,7 @@ import quests.Q00620_FourGoblets.Q00620_FourGoblets;
* Four Selpuchers AI
* @author Mobius
*/
public final class FourSepulchers extends AbstractNpcAI implements IGameXmlReader
public final class FourSepulchers extends AbstractNpcAI implements IXmlReader
{
Logger LOGGER = Logger.getLogger(FourSepulchers.class.getName());

View File

@@ -30,7 +30,7 @@ import org.w3c.dom.NamedNodeMap;
import org.w3c.dom.Node;
import com.l2jmobius.commons.util.CommonUtil;
import com.l2jmobius.commons.util.IGameXmlReader;
import com.l2jmobius.commons.util.IXmlReader;
import com.l2jmobius.gameserver.ai.CtrlIntention;
import com.l2jmobius.gameserver.enums.Movie;
import com.l2jmobius.gameserver.enums.TrapAction;
@@ -66,7 +66,7 @@ import instances.AbstractInstance;
* Please maintain consistency between the Seed scripts.
* @author Gigiikun
*/
public final class Stage1 extends AbstractInstance implements IGameXmlReader
public final class Stage1 extends AbstractInstance implements IXmlReader
{
Logger LOGGER = Logger.getLogger(Stage1.class.getName());

View File

@@ -30,7 +30,7 @@ import org.w3c.dom.NamedNodeMap;
import org.w3c.dom.Node;
import com.l2jmobius.Config;
import com.l2jmobius.commons.util.IGameXmlReader;
import com.l2jmobius.commons.util.IXmlReader;
import com.l2jmobius.gameserver.data.xml.impl.CategoryData;
import com.l2jmobius.gameserver.data.xml.impl.ClassListData;
import com.l2jmobius.gameserver.data.xml.impl.SkillData;
@@ -63,7 +63,7 @@ import ai.AbstractNpcAI;
* Class Master AI.
* @author Nik
*/
public final class ClassMaster extends AbstractNpcAI implements IGameXmlReader
public final class ClassMaster extends AbstractNpcAI implements IXmlReader
{
// NPCs
private static final List<Integer> CLASS_MASTERS = new ArrayList<>();

View File

@@ -26,7 +26,7 @@ import org.w3c.dom.Document;
import org.w3c.dom.Node;
import com.l2jmobius.Config;
import com.l2jmobius.commons.util.IGameXmlReader;
import com.l2jmobius.commons.util.IXmlReader;
import com.l2jmobius.gameserver.enums.CategoryType;
import com.l2jmobius.gameserver.enums.MailType;
import com.l2jmobius.gameserver.instancemanager.MailManager;
@@ -62,7 +62,7 @@ import ai.AbstractNpcAI;
* Mentor Guide AI.
* @author Gnacik, UnAfraid
*/
public final class MentorGuide extends AbstractNpcAI implements IGameXmlReader
public final class MentorGuide extends AbstractNpcAI implements IXmlReader
{
private static final Logger LOGGER = Logger.getLogger(MentorGuide.class.getName());

View File

@@ -27,13 +27,13 @@ import org.w3c.dom.Document;
import org.w3c.dom.NamedNodeMap;
import org.w3c.dom.Node;
import com.l2jmobius.commons.util.IGameXmlReader;
import com.l2jmobius.commons.util.IXmlReader;
import com.l2jmobius.gameserver.model.StatsSet;
/**
* @author UnAfraid
*/
class NpcBuffersData implements IGameXmlReader
class NpcBuffersData implements IXmlReader
{
private static final Logger LOGGER = Logger.getLogger(NpcBuffersData.class.getName());

View File

@@ -320,7 +320,7 @@ public class AdminQuest implements IAdminCommandHandler
{
sb.append("<a action=\"bypass -h admin_script_dir " + c + "\">" + c + "</a><br1>");
}
else if (c.endsWith(".java") || c.endsWith(".py"))
else if (c.endsWith(".java"))
{
sb.append("<a action=\"bypass -h admin_script_load " + c + "\"><font color=\"LEVEL\">" + c + "</font></a><br1>");
}
@@ -352,7 +352,7 @@ public class AdminQuest implements IAdminCommandHandler
{
sb.append("<a action=\"bypass -h admin_script_dir " + currentPath + "/" + c + "\">" + (questReducedNames ? getQuestName(c) : c) + "</a><br1>");
}
else if (c.endsWith(".java") || c.endsWith(".py"))
else if (c.endsWith(".java"))
{
sb.append("<a action=\"bypass -h admin_script_load " + currentPath + "/" + c + "\"><font color=\"LEVEL\">" + c + "</font></a><br1>");
}

View File

@@ -221,7 +221,7 @@ public class AdminReload implements IAdminCommandHandler
{
try
{
ScriptEngineManager.getInstance().executeEffectMasterHandler();
ScriptEngineManager.getInstance().executeScript(ScriptEngineManager.EFFECT_MASTER_HANDLER_FILE);
AdminData.getInstance().broadcastMessageToGMs(activeChar.getName() + ": Reloaded effect master handler.");
}
catch (Exception e)
@@ -235,7 +235,7 @@ public class AdminReload implements IAdminCommandHandler
{
try
{
ScriptEngineManager.getInstance().executeMasterHandler();
ScriptEngineManager.getInstance().executeScript(ScriptEngineManager.MASTER_HANDLER_FILE);
AdminData.getInstance().broadcastMessageToGMs(activeChar.getName() + ": Reloaded master handler.");
}
catch (Exception e)

View File

@@ -182,7 +182,7 @@ public class Reload implements ITelnetCommand
{
try
{
ScriptEngineManager.getInstance().executeEffectMasterHandler();
ScriptEngineManager.getInstance().executeScript(ScriptEngineManager.EFFECT_MASTER_HANDLER_FILE);
return AdminData.getInstance().broadcastMessageToGMs("Telnet Admin: Reloaded effect master handler.");
}
catch (Exception e)
@@ -195,7 +195,7 @@ public class Reload implements ITelnetCommand
{
try
{
ScriptEngineManager.getInstance().executeMasterHandler();
ScriptEngineManager.getInstance().executeScript(ScriptEngineManager.MASTER_HANDLER_FILE);
return AdminData.getInstance().broadcastMessageToGMs("Telnet Admin: Reloaded master handler.");
}
catch (Exception e)

View File

@@ -54,7 +54,7 @@ import org.w3c.dom.Document;
import org.w3c.dom.NamedNodeMap;
import org.w3c.dom.Node;
import com.l2jmobius.commons.util.IGameXmlReader;
import com.l2jmobius.commons.util.IXmlReader;
import com.l2jmobius.commons.util.PropertiesParser;
import com.l2jmobius.commons.util.StringUtil;
import com.l2jmobius.gameserver.enums.ChatType;
@@ -3098,7 +3098,7 @@ public final class Config
return result;
}
private static class IPConfigData implements IGameXmlReader
private static class IPConfigData implements IXmlReader
{
private static final List<String> _subnets = new ArrayList<>(5);
private static final List<String> _hosts = new ArrayList<>(5);

View File

@@ -1,118 +0,0 @@
/*
* 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 <http://www.gnu.org/licenses/>.
*/
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<String, Object> parseParameters(Node n)
{
final Map<String, Object> 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<MinionHolder> 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);
}
}

View File

@@ -18,8 +18,13 @@ package com.l2jmobius.commons.util;
import java.io.File;
import java.io.FileFilter;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.concurrent.CopyOnWriteArrayList;
import java.util.concurrent.ScheduledFuture;
import java.util.function.Consumer;
import java.util.function.Predicate;
import java.util.logging.Level;
@@ -35,7 +40,12 @@ import org.w3c.dom.NodeList;
import org.xml.sax.ErrorHandler;
import org.xml.sax.SAXParseException;
import com.l2jmobius.Config;
import com.l2jmobius.commons.concurrent.ThreadPool;
import com.l2jmobius.commons.util.file.filter.XMLFilter;
import com.l2jmobius.gameserver.model.Location;
import com.l2jmobius.gameserver.model.holders.MinionHolder;
import com.l2jmobius.gameserver.model.holders.SkillHolder;
/**
* Interface for XML parsers.
@@ -56,6 +66,15 @@ public interface IXmlReader
*/
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.<br>
* If the file was successfully parsed, call {@link #parseDocument(Document, File)} for the parsed document.<br>
@@ -121,6 +140,17 @@ public interface IXmlReader
return parseDirectory(file, 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 parseDatapackDirectory(String path, boolean recursive)
{
return parseDirectory(new File(Config.DATAPACK_ROOT, 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.
@@ -135,6 +165,7 @@ public interface IXmlReader
return false;
}
final List<ScheduledFuture<?>> jobs = new CopyOnWriteArrayList<>();
final File[] listOfFiles = dir.listFiles();
for (File f : listOfFiles)
{
@@ -144,9 +175,23 @@ public interface IXmlReader
}
else if (getCurrentFileFilter().accept(f))
{
parseFile(f);
jobs.add(ThreadPool.schedule(() ->
{
parseFile(f);
}, 0));
}
}
while (!jobs.isEmpty())
{
for (ScheduledFuture<?> job : jobs)
{
if ((job == null) || job.isDone() || job.isCancelled())
{
jobs.remove(job);
}
}
}
return true;
}
@@ -531,6 +576,16 @@ public interface IXmlReader
return parseString(attrs.getNamedItem(name), defaultValue);
}
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);
}
/**
* Parses an enumerated value.
* @param <T> the enumerated type
@@ -612,6 +667,56 @@ public interface IXmlReader
return map;
}
/**
* @param n
* @return a map of parameters
*/
default Map<String, Object> parseParameters(Node n)
{
final Map<String, Object> 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<MinionHolder> 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;
}
/**
* Executes action for each child of node
* @param node

View File

@@ -354,7 +354,7 @@ public class GameServer
try
{
LOGGER.info(getClass().getSimpleName() + ": Loading server scripts:");
ScriptEngineManager.getInstance().executeMasterHandler();
ScriptEngineManager.getInstance().executeScript(ScriptEngineManager.MASTER_HANDLER_FILE);
ScriptEngineManager.getInstance().executeScriptList();
}
catch (Exception e)

View File

@@ -25,13 +25,13 @@ import org.w3c.dom.Document;
import org.w3c.dom.NamedNodeMap;
import org.w3c.dom.Node;
import com.l2jmobius.commons.util.IGameXmlReader;
import com.l2jmobius.commons.util.IXmlReader;
import com.l2jmobius.gameserver.model.holders.RangeAbilityPointsHolder;
/**
* @author UnAfraid
*/
public final class AbilityPointsData implements IGameXmlReader
public final class AbilityPointsData implements IXmlReader
{
private static final Logger LOGGER = Logger.getLogger(AbilityPointsData.class.getName());
private final List<RangeAbilityPointsHolder> _points = new ArrayList<>();

View File

@@ -23,14 +23,14 @@ import java.util.logging.Logger;
import org.w3c.dom.Document;
import com.l2jmobius.commons.util.IGameXmlReader;
import com.l2jmobius.commons.util.IXmlReader;
import com.l2jmobius.gameserver.model.ActionDataHolder;
import com.l2jmobius.gameserver.model.StatsSet;
/**
* @author UnAfraid
*/
public class ActionData implements IGameXmlReader
public class ActionData implements IXmlReader
{
private static final Logger LOGGER = Logger.getLogger(ActionData.class.getName());

View File

@@ -29,7 +29,7 @@ import org.w3c.dom.Document;
import org.w3c.dom.NamedNodeMap;
import org.w3c.dom.Node;
import com.l2jmobius.commons.util.IGameXmlReader;
import com.l2jmobius.commons.util.IXmlReader;
import com.l2jmobius.gameserver.model.AccessLevel;
import com.l2jmobius.gameserver.model.AdminCommandAccessRight;
import com.l2jmobius.gameserver.model.StatsSet;
@@ -42,7 +42,7 @@ import com.l2jmobius.gameserver.network.serverpackets.SystemMessage;
* Loads administrator access levels and commands.
* @author UnAfraid
*/
public final class AdminData implements IGameXmlReader
public final class AdminData implements IXmlReader
{
private static final Logger LOGGER = Logger.getLogger(AdminData.class.getName());

View File

@@ -25,7 +25,7 @@ import org.w3c.dom.Document;
import org.w3c.dom.NamedNodeMap;
import org.w3c.dom.Node;
import com.l2jmobius.commons.util.IGameXmlReader;
import com.l2jmobius.commons.util.IXmlReader;
import com.l2jmobius.gameserver.model.StatsSet;
import com.l2jmobius.gameserver.model.alchemy.AlchemyCraftData;
import com.l2jmobius.gameserver.model.holders.ItemHolder;
@@ -33,7 +33,7 @@ import com.l2jmobius.gameserver.model.holders.ItemHolder;
/**
* @author Sdw
*/
public class AlchemyData implements IGameXmlReader
public class AlchemyData implements IXmlReader
{
private static final Logger LOGGER = Logger.getLogger(AlchemyData.class.getName());

View File

@@ -24,7 +24,7 @@ import java.util.logging.Logger;
import org.w3c.dom.Document;
import org.w3c.dom.Node;
import com.l2jmobius.commons.util.IGameXmlReader;
import com.l2jmobius.commons.util.IXmlReader;
import com.l2jmobius.gameserver.datatables.ItemTable;
import com.l2jmobius.gameserver.enums.Race;
import com.l2jmobius.gameserver.model.StatsSet;
@@ -36,7 +36,7 @@ import com.l2jmobius.gameserver.model.items.type.CrystalType;
/**
* @author UnAfraid
*/
public class AppearanceItemData implements IGameXmlReader
public class AppearanceItemData implements IXmlReader
{
private static final Logger LOGGER = Logger.getLogger(AppearanceItemData.class.getName());

View File

@@ -19,9 +19,9 @@ package com.l2jmobius.gameserver.data.xml.impl;
import java.io.File;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import java.util.logging.Logger;
import java.util.stream.Stream;
@@ -29,7 +29,7 @@ import org.w3c.dom.Document;
import org.w3c.dom.NamedNodeMap;
import org.w3c.dom.Node;
import com.l2jmobius.commons.util.IGameXmlReader;
import com.l2jmobius.commons.util.IXmlReader;
import com.l2jmobius.gameserver.datatables.ItemTable;
import com.l2jmobius.gameserver.model.ArmorSet;
import com.l2jmobius.gameserver.model.holders.ArmorsetSkillHolder;
@@ -40,12 +40,12 @@ import com.l2jmobius.gameserver.model.stats.BaseStats;
* Loads armor set bonuses.
* @author godson, Luno, UnAfraid
*/
public final class ArmorSetsData implements IGameXmlReader
public final class ArmorSetsData implements IXmlReader
{
private static final Logger LOGGER = Logger.getLogger(ArmorSetsData.class.getName());
private final Map<Integer, ArmorSet> _armorSets = new HashMap<>();
private final Map<Integer, List<ArmorSet>> _armorSetItems = new HashMap<>();
private final Map<Integer, ArmorSet> _armorSets = new ConcurrentHashMap<>();
private final Map<Integer, List<ArmorSet>> _armorSetItems = new ConcurrentHashMap<>();
protected ArmorSetsData()
{

View File

@@ -24,7 +24,7 @@ import org.w3c.dom.Document;
import org.w3c.dom.NamedNodeMap;
import org.w3c.dom.Node;
import com.l2jmobius.commons.util.IGameXmlReader;
import com.l2jmobius.commons.util.IXmlReader;
import com.l2jmobius.gameserver.enums.Race;
import com.l2jmobius.gameserver.enums.Sex;
import com.l2jmobius.gameserver.model.StatsSet;
@@ -34,7 +34,7 @@ import com.l2jmobius.gameserver.model.beautyshop.BeautyItem;
/**
* @author Sdw
*/
public final class BeautyShopData implements IGameXmlReader
public final class BeautyShopData implements IXmlReader
{
private final Map<Race, Map<Sex, BeautyData>> _beautyList = new HashMap<>();
private final Map<Sex, BeautyData> _beautyData = new HashMap<>();

View File

@@ -21,8 +21,8 @@ import java.io.FileFilter;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.Statement;
import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import java.util.logging.Level;
import java.util.logging.Logger;
@@ -31,7 +31,7 @@ import org.w3c.dom.NamedNodeMap;
import com.l2jmobius.Config;
import com.l2jmobius.commons.database.DatabaseFactory;
import com.l2jmobius.commons.util.IGameXmlReader;
import com.l2jmobius.commons.util.IXmlReader;
import com.l2jmobius.commons.util.file.filter.NumericNameFilter;
import com.l2jmobius.gameserver.datatables.ItemTable;
import com.l2jmobius.gameserver.model.buylist.Product;
@@ -42,11 +42,11 @@ import com.l2jmobius.gameserver.model.items.Item;
* Loads buy lists for NPCs.
* @author NosBit
*/
public final class BuyListData implements IGameXmlReader
public final class BuyListData implements IXmlReader
{
private static final Logger LOGGER = Logger.getLogger(BuyListData.class.getName());
private final Map<Integer, ProductList> _buyLists = new HashMap<>();
private final Map<Integer, ProductList> _buyLists = new ConcurrentHashMap<>();
private static final FileFilter NUMERIC_FILTER = new NumericNameFilter();
protected BuyListData()

View File

@@ -19,16 +19,16 @@ package com.l2jmobius.gameserver.data.xml.impl;
import java.io.File;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import java.util.stream.Collectors;
import org.w3c.dom.Document;
import org.w3c.dom.NamedNodeMap;
import org.w3c.dom.Node;
import com.l2jmobius.commons.util.IGameXmlReader;
import com.l2jmobius.commons.util.IXmlReader;
import com.l2jmobius.gameserver.enums.CastleSide;
import com.l2jmobius.gameserver.enums.SiegeGuardType;
import com.l2jmobius.gameserver.model.holders.CastleSpawnHolder;
@@ -37,10 +37,10 @@ import com.l2jmobius.gameserver.model.holders.SiegeGuardHolder;
/**
* @author St3eT
*/
public final class CastleData implements IGameXmlReader
public final class CastleData implements IXmlReader
{
private final Map<Integer, List<CastleSpawnHolder>> _spawns = new HashMap<>();
private static final Map<Integer, List<SiegeGuardHolder>> _siegeGuards = new HashMap<>();
private final Map<Integer, List<CastleSpawnHolder>> _spawns = new ConcurrentHashMap<>();
private static final Map<Integer, List<SiegeGuardHolder>> _siegeGuards = new ConcurrentHashMap<>();
protected CastleData()
{

View File

@@ -27,14 +27,14 @@ import org.w3c.dom.Document;
import org.w3c.dom.NamedNodeMap;
import org.w3c.dom.Node;
import com.l2jmobius.commons.util.IGameXmlReader;
import com.l2jmobius.commons.util.IXmlReader;
import com.l2jmobius.gameserver.enums.CategoryType;
/**
* Loads the category data with Class or NPC IDs.
* @author NosBit, xban1x
*/
public final class CategoryData implements IGameXmlReader
public final class CategoryData implements IXmlReader
{
private static final Logger LOGGER = Logger.getLogger(CategoryData.class.getName());

View File

@@ -20,9 +20,9 @@ import java.io.File;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Comparator;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import java.util.logging.Logger;
import java.util.stream.Collectors;
@@ -30,7 +30,7 @@ import org.w3c.dom.Document;
import org.w3c.dom.NamedNodeMap;
import org.w3c.dom.Node;
import com.l2jmobius.commons.util.IGameXmlReader;
import com.l2jmobius.commons.util.IXmlReader;
import com.l2jmobius.gameserver.enums.ClanHallGrade;
import com.l2jmobius.gameserver.enums.ClanHallType;
import com.l2jmobius.gameserver.model.Location;
@@ -43,10 +43,10 @@ import com.l2jmobius.gameserver.model.holders.ClanHallTeleportHolder;
/**
* @author St3eT
*/
public final class ClanHallData implements IGameXmlReader
public final class ClanHallData implements IXmlReader
{
private static final Logger LOGGER = Logger.getLogger(ClanHallData.class.getName());
private static final Map<Integer, ClanHall> _clanHalls = new HashMap<>();
private static final Map<Integer, ClanHall> _clanHalls = new ConcurrentHashMap<>();
protected ClanHallData()
{

View File

@@ -28,7 +28,6 @@ import org.w3c.dom.Document;
import org.w3c.dom.NamedNodeMap;
import org.w3c.dom.Node;
import com.l2jmobius.commons.util.IGameXmlReader;
import com.l2jmobius.commons.util.IXmlReader;
import com.l2jmobius.gameserver.enums.ClanRewardType;
import com.l2jmobius.gameserver.model.clan.ClanRewardBonus;
@@ -38,7 +37,7 @@ import com.l2jmobius.gameserver.model.holders.SkillHolder;
/**
* @author UnAfraid
*/
public class ClanRewardData implements IGameXmlReader
public class ClanRewardData implements IXmlReader
{
private static final Logger LOGGER = Logger.getLogger(ClanRewardData.class.getName());
private final Map<ClanRewardType, List<ClanRewardBonus>> _clanRewards = new ConcurrentHashMap<>();

View File

@@ -17,15 +17,15 @@
package com.l2jmobius.gameserver.data.xml.impl;
import java.io.File;
import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import java.util.logging.Logger;
import org.w3c.dom.Document;
import org.w3c.dom.NamedNodeMap;
import org.w3c.dom.Node;
import com.l2jmobius.commons.util.IGameXmlReader;
import com.l2jmobius.commons.util.IXmlReader;
import com.l2jmobius.gameserver.model.base.ClassId;
import com.l2jmobius.gameserver.model.base.ClassInfo;
@@ -33,11 +33,11 @@ import com.l2jmobius.gameserver.model.base.ClassInfo;
* Loads the the list of classes and it's info.
* @author Zoey76
*/
public final class ClassListData implements IGameXmlReader
public final class ClassListData implements IXmlReader
{
private static final Logger LOGGER = Logger.getLogger(ClassListData.class.getName());
private final Map<ClassId, ClassInfo> _classData = new HashMap<>();
private final Map<ClassId, ClassInfo> _classData = new ConcurrentHashMap<>();
/**
* Instantiates a new class list data.

View File

@@ -24,7 +24,7 @@ import java.util.stream.Collectors;
import org.w3c.dom.Document;
import com.l2jmobius.commons.util.IGameXmlReader;
import com.l2jmobius.commons.util.IXmlReader;
import com.l2jmobius.gameserver.datatables.ItemTable;
import com.l2jmobius.gameserver.model.StatsSet;
import com.l2jmobius.gameserver.model.items.combination.CombinationItem;
@@ -34,7 +34,7 @@ import com.l2jmobius.gameserver.model.items.combination.CombinationItemType;
/**
* @author UnAfraid
*/
public class CombinationItemsData implements IGameXmlReader
public class CombinationItemsData implements IXmlReader
{
private static final Logger LOGGER = Logger.getLogger(CombinationItemsData.class.getName());
private final List<CombinationItem> _items = new ArrayList<>();

View File

@@ -20,12 +20,12 @@ import java.io.File;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import java.util.logging.Logger;
import org.w3c.dom.Document;
import org.w3c.dom.Node;
import com.l2jmobius.commons.util.IGameXmlReader;
import com.l2jmobius.commons.util.IXmlReader;
import com.l2jmobius.gameserver.model.StatsSet;
import com.l2jmobius.gameserver.model.actor.templates.CubicTemplate;
@@ -39,11 +39,11 @@ import com.l2jmobius.gameserver.model.cubic.conditions.RangeCondition;
/**
* @author UnAfraid
*/
public class CubicData implements IGameXmlReader
public class CubicData implements IXmlReader
{
private static final Logger LOGGER = Logger.getLogger(CubicData.class.getName());
private final Map<Integer, Map<Integer, CubicTemplate>> _cubics = new HashMap<>();
private final Map<Integer, Map<Integer, CubicTemplate>> _cubics = new ConcurrentHashMap<>();
protected CubicData()
{

View File

@@ -32,7 +32,6 @@ import org.w3c.dom.Document;
import org.w3c.dom.NamedNodeMap;
import org.w3c.dom.Node;
import com.l2jmobius.commons.util.IGameXmlReader;
import com.l2jmobius.commons.util.IXmlReader;
import com.l2jmobius.gameserver.instancemanager.MapRegionManager;
import com.l2jmobius.gameserver.model.Location;
@@ -45,7 +44,7 @@ import com.l2jmobius.gameserver.model.instancezone.Instance;
* This class loads and hold info about doors.
* @author JIV, GodKratos, UnAfraid
*/
public final class DoorData implements IGameXmlReader
public final class DoorData implements IXmlReader
{
private static final Logger LOGGER = Logger.getLogger(DoorData.class.getName());

View File

@@ -25,7 +25,7 @@ import org.w3c.dom.Document;
import org.w3c.dom.NamedNodeMap;
import org.w3c.dom.Node;
import com.l2jmobius.commons.util.IGameXmlReader;
import com.l2jmobius.commons.util.IXmlReader;
import com.l2jmobius.gameserver.model.StatsSet;
import com.l2jmobius.gameserver.model.items.enchant.EnchantScroll;
import com.l2jmobius.gameserver.model.items.enchant.EnchantSupportItem;
@@ -35,7 +35,7 @@ import com.l2jmobius.gameserver.model.items.instance.ItemInstance;
* Loads item enchant data.
* @author UnAfraid
*/
public class EnchantItemData implements IGameXmlReader
public class EnchantItemData implements IXmlReader
{
private static final Logger LOGGER = Logger.getLogger(EnchantItemData.class.getName());

View File

@@ -25,7 +25,7 @@ import org.w3c.dom.Document;
import org.w3c.dom.NamedNodeMap;
import org.w3c.dom.Node;
import com.l2jmobius.commons.util.IGameXmlReader;
import com.l2jmobius.commons.util.IXmlReader;
import com.l2jmobius.gameserver.datatables.ItemTable;
import com.l2jmobius.gameserver.model.holders.RangeChanceHolder;
import com.l2jmobius.gameserver.model.items.Item;
@@ -37,7 +37,7 @@ import com.l2jmobius.gameserver.util.Util;
/**
* @author UnAfraid
*/
public final class EnchantItemGroupsData implements IGameXmlReader
public final class EnchantItemGroupsData implements IXmlReader
{
private static final Logger LOGGER = Logger.getLogger(EnchantItemGroupsData.class.getName());

View File

@@ -26,7 +26,7 @@ import java.util.logging.Logger;
import org.w3c.dom.Document;
import org.w3c.dom.Node;
import com.l2jmobius.commons.util.IGameXmlReader;
import com.l2jmobius.commons.util.IXmlReader;
import com.l2jmobius.gameserver.model.items.Item;
import com.l2jmobius.gameserver.model.items.instance.ItemInstance;
import com.l2jmobius.gameserver.model.items.type.CrystalType;
@@ -35,7 +35,7 @@ import com.l2jmobius.gameserver.model.items.type.CrystalType;
* This class holds the Enchant HP Bonus Data.
* @author MrPoke, Zoey76
*/
public class EnchantItemHPBonusData implements IGameXmlReader
public class EnchantItemHPBonusData implements IXmlReader
{
private static final Logger LOGGER = Logger.getLogger(EnchantItemHPBonusData.class.getName());

View File

@@ -24,7 +24,7 @@ import java.util.logging.Logger;
import org.w3c.dom.Document;
import org.w3c.dom.Node;
import com.l2jmobius.commons.util.IGameXmlReader;
import com.l2jmobius.commons.util.IXmlReader;
import com.l2jmobius.gameserver.model.items.instance.ItemInstance;
import com.l2jmobius.gameserver.model.options.EnchantOptions;
import com.l2jmobius.gameserver.util.Util;
@@ -32,7 +32,7 @@ import com.l2jmobius.gameserver.util.Util;
/**
* @author UnAfraid
*/
public class EnchantItemOptionsData implements IGameXmlReader
public class EnchantItemOptionsData implements IXmlReader
{
private static final Logger LOGGER = Logger.getLogger(EnchantItemOptionsData.class.getName());

View File

@@ -18,16 +18,15 @@ package com.l2jmobius.gameserver.data.xml.impl;
import java.io.File;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedHashMap;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
import java.util.logging.Logger;
import org.w3c.dom.Document;
import com.l2jmobius.commons.util.IGameXmlReader;
import com.l2jmobius.commons.util.IXmlReader;
import com.l2jmobius.gameserver.enums.SkillEnchantType;
import com.l2jmobius.gameserver.model.StatsSet;
import com.l2jmobius.gameserver.model.holders.EnchantSkillHolder;
@@ -39,12 +38,12 @@ import com.l2jmobius.gameserver.model.skills.Skill;
* This class holds the Enchant Groups information.
* @author Micr0
*/
public class EnchantSkillGroupsData implements IGameXmlReader
public class EnchantSkillGroupsData implements IXmlReader
{
private static final Logger LOGGER = Logger.getLogger(EnchantSkillGroupsData.class.getName());
private final Map<Integer, EnchantSkillHolder> _enchantSkillHolders = new LinkedHashMap<>();
private final Map<SkillHolder, Set<Integer>> _enchantSkillTrees = new HashMap<>();
private final Map<Integer, EnchantSkillHolder> _enchantSkillHolders = new ConcurrentHashMap<>();
private final Map<SkillHolder, Set<Integer>> _enchantSkillTrees = new ConcurrentHashMap<>();
public static int MAX_ENCHANT_LEVEL;

View File

@@ -32,7 +32,6 @@ import org.w3c.dom.Document;
import org.w3c.dom.NamedNodeMap;
import org.w3c.dom.Node;
import com.l2jmobius.commons.util.IGameXmlReader;
import com.l2jmobius.commons.util.IXmlReader;
import com.l2jmobius.gameserver.model.Location;
import com.l2jmobius.gameserver.model.StatsSet;
@@ -54,7 +53,7 @@ import com.l2jmobius.gameserver.model.holders.SkillHolder;
/**
* @author UnAfraid
*/
public final class EventEngineData implements IGameXmlReader
public final class EventEngineData implements IXmlReader
{
private static final Logger LOGGER = Logger.getLogger(EventEngineData.class.getName());

View File

@@ -26,13 +26,13 @@ import org.w3c.dom.NamedNodeMap;
import org.w3c.dom.Node;
import com.l2jmobius.Config;
import com.l2jmobius.commons.util.IGameXmlReader;
import com.l2jmobius.commons.util.IXmlReader;
/**
* This class holds the Experience points for each level for players and pets.
* @author mrTJO
*/
public final class ExperienceData implements IGameXmlReader
public final class ExperienceData implements IXmlReader
{
private static final Logger LOGGER = Logger.getLogger(ExperienceData.class.getName());

View File

@@ -28,7 +28,7 @@ import java.util.logging.Logger;
import org.w3c.dom.Document;
import org.w3c.dom.Node;
import com.l2jmobius.commons.util.IGameXmlReader;
import com.l2jmobius.commons.util.IXmlReader;
import com.l2jmobius.gameserver.handler.ConditionHandler;
import com.l2jmobius.gameserver.model.StatsSet;
import com.l2jmobius.gameserver.model.conditions.ICondition;
@@ -39,7 +39,7 @@ import com.l2jmobius.gameserver.network.SystemMessageId;
/**
* @author Sdw
*/
public class ExtendDropData implements IGameXmlReader
public class ExtendDropData implements IXmlReader
{
private static final Logger LOGGER = Logger.getLogger(ExtendDropData.class.getName());
private final Map<Integer, ExtendDropDataHolder> _extendDrop = new HashMap<>();

View File

@@ -26,7 +26,7 @@ import java.util.logging.Logger;
import org.w3c.dom.Document;
import com.l2jmobius.Config;
import com.l2jmobius.commons.util.IGameXmlReader;
import com.l2jmobius.commons.util.IXmlReader;
import com.l2jmobius.gameserver.data.sql.impl.CharNameTable;
import com.l2jmobius.gameserver.model.StatsSet;
import com.l2jmobius.gameserver.model.actor.templates.NpcTemplate;
@@ -35,7 +35,7 @@ import com.l2jmobius.gameserver.model.holders.FakePlayerHolder;
/**
* @author Mobius
*/
public class FakePlayerData implements IGameXmlReader
public class FakePlayerData implements IXmlReader
{
private static Logger LOGGER = Logger.getLogger(FakePlayerData.class.getName());

View File

@@ -28,7 +28,7 @@ import java.util.logging.Logger;
import org.w3c.dom.Document;
import org.w3c.dom.Node;
import com.l2jmobius.commons.util.IGameXmlReader;
import com.l2jmobius.commons.util.IXmlReader;
import com.l2jmobius.gameserver.enums.FenceState;
import com.l2jmobius.gameserver.model.StatsSet;
import com.l2jmobius.gameserver.model.World;
@@ -39,7 +39,7 @@ import com.l2jmobius.gameserver.model.instancezone.Instance;
/**
* @author HoridoJoho / FBIagent
*/
public final class FenceData implements IGameXmlReader
public final class FenceData implements IXmlReader
{
private static final Logger LOGGER = Logger.getLogger(FenceData.class.getSimpleName());

View File

@@ -26,7 +26,7 @@ import org.w3c.dom.NamedNodeMap;
import org.w3c.dom.Node;
import com.l2jmobius.Config;
import com.l2jmobius.commons.util.IGameXmlReader;
import com.l2jmobius.commons.util.IXmlReader;
import com.l2jmobius.gameserver.datatables.ItemTable;
import com.l2jmobius.gameserver.model.fishing.FishingBait;
import com.l2jmobius.gameserver.model.fishing.FishingCatch;
@@ -36,7 +36,7 @@ import com.l2jmobius.gameserver.model.fishing.FishingRod;
* This class holds the Fishing information.
* @author bit
*/
public final class FishingData implements IGameXmlReader
public final class FishingData implements IXmlReader
{
private static final Logger LOGGER = Logger.getLogger(FishingData.class.getName());
private final Map<Integer, FishingBait> _baitData = new HashMap<>();

View File

@@ -27,7 +27,7 @@ import org.w3c.dom.Document;
import org.w3c.dom.NamedNodeMap;
import org.w3c.dom.Node;
import com.l2jmobius.commons.util.IGameXmlReader;
import com.l2jmobius.commons.util.IXmlReader;
import com.l2jmobius.gameserver.model.StatsSet;
import com.l2jmobius.gameserver.model.base.ClassId;
import com.l2jmobius.gameserver.model.items.Henna;
@@ -40,7 +40,7 @@ import com.l2jmobius.gameserver.model.skills.Skill;
* Allowed classes to wear each henna.
* @author Zoey76, Mobius
*/
public final class HennaData implements IGameXmlReader
public final class HennaData implements IXmlReader
{
private static final Logger LOGGER = Logger.getLogger(HennaData.class.getName());

View File

@@ -23,7 +23,7 @@ import org.w3c.dom.Document;
import org.w3c.dom.NamedNodeMap;
import org.w3c.dom.Node;
import com.l2jmobius.commons.util.IGameXmlReader;
import com.l2jmobius.commons.util.IXmlReader;
import com.l2jmobius.gameserver.GameTimeController;
import com.l2jmobius.gameserver.enums.Position;
import com.l2jmobius.gameserver.model.actor.Creature;
@@ -32,7 +32,7 @@ import com.l2jmobius.gameserver.model.actor.Creature;
* This class load, holds and calculates the hit condition bonuses.
* @author Nik
*/
public final class HitConditionBonusData implements IGameXmlReader
public final class HitConditionBonusData implements IXmlReader
{
private static final Logger LOGGER = Logger.getLogger(HitConditionBonusData.class.getName());

View File

@@ -28,7 +28,7 @@ import org.w3c.dom.NamedNodeMap;
import org.w3c.dom.Node;
import com.l2jmobius.Config;
import com.l2jmobius.commons.util.IGameXmlReader;
import com.l2jmobius.commons.util.IXmlReader;
import com.l2jmobius.gameserver.model.StatsSet;
import com.l2jmobius.gameserver.model.base.ClassId;
import com.l2jmobius.gameserver.model.items.PlayerItemTemplate;
@@ -38,7 +38,7 @@ import com.l2jmobius.gameserver.model.items.PlayerItemTemplate;
* What items get each newly created character and if this item is equipped upon creation (<b>Requires the item to be equippable</b>).
* @author Zoey76
*/
public final class InitialEquipmentData implements IGameXmlReader
public final class InitialEquipmentData implements IXmlReader
{
private static final Logger LOGGER = Logger.getLogger(InitialEquipmentData.class.getName());

View File

@@ -27,7 +27,7 @@ import org.w3c.dom.Document;
import org.w3c.dom.NamedNodeMap;
import org.w3c.dom.Node;
import com.l2jmobius.commons.util.IGameXmlReader;
import com.l2jmobius.commons.util.IXmlReader;
import com.l2jmobius.gameserver.enums.MacroType;
import com.l2jmobius.gameserver.enums.ShortcutType;
import com.l2jmobius.gameserver.model.Macro;
@@ -43,7 +43,7 @@ import com.l2jmobius.gameserver.network.serverpackets.ShortCutRegister;
* What shortcuts get each newly created character.
* @author Zoey76
*/
public final class InitialShortcutData implements IGameXmlReader
public final class InitialShortcutData implements IXmlReader
{
private static final Logger LOGGER = Logger.getLogger(InitialShortcutData.class.getName());

View File

@@ -28,7 +28,7 @@ import org.w3c.dom.Document;
import org.w3c.dom.NamedNodeMap;
import org.w3c.dom.Node;
import com.l2jmobius.commons.util.IGameXmlReader;
import com.l2jmobius.commons.util.IXmlReader;
import com.l2jmobius.gameserver.datatables.ItemTable;
import com.l2jmobius.gameserver.enums.CrystallizationType;
import com.l2jmobius.gameserver.model.holders.CrystallizationDataHolder;
@@ -42,7 +42,7 @@ import com.l2jmobius.gameserver.model.items.type.CrystalType;
/**
* @author UnAfraid
*/
public final class ItemCrystallizationData implements IGameXmlReader
public final class ItemCrystallizationData implements IXmlReader
{
private static final Logger LOGGER = Logger.getLogger(ItemCrystallizationData.class.getName());

View File

@@ -26,12 +26,12 @@ import org.w3c.dom.NamedNodeMap;
import org.w3c.dom.Node;
import com.l2jmobius.Config;
import com.l2jmobius.commons.util.IGameXmlReader;
import com.l2jmobius.commons.util.IXmlReader;
/**
* @author UnAfraid
*/
public class KarmaData implements IGameXmlReader
public class KarmaData implements IXmlReader
{
private static final Logger LOGGER = Logger.getLogger(KarmaData.class.getName());

View File

@@ -23,7 +23,7 @@ import java.util.concurrent.atomic.AtomicInteger;
import org.w3c.dom.Document;
import com.l2jmobius.commons.util.IGameXmlReader;
import com.l2jmobius.commons.util.IXmlReader;
import com.l2jmobius.gameserver.model.StatsSet;
import com.l2jmobius.gameserver.model.holders.ItemChanceHolder;
import com.l2jmobius.gameserver.model.holders.ItemPointHolder;
@@ -32,7 +32,7 @@ import com.l2jmobius.gameserver.model.holders.LuckyGameDataHolder;
/**
* @author Sdw
*/
public class LuckyGameData implements IGameXmlReader
public class LuckyGameData implements IXmlReader
{
private final Map<Integer, LuckyGameDataHolder> _luckyGame = new HashMap<>();
private final AtomicInteger _serverPlay = new AtomicInteger();

View File

@@ -19,11 +19,11 @@ package com.l2jmobius.gameserver.data.xml.impl;
import java.io.File;
import java.io.FileFilter;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
import java.util.logging.Level;
import java.util.logging.Logger;
@@ -31,7 +31,7 @@ import org.w3c.dom.Document;
import org.w3c.dom.Node;
import com.l2jmobius.Config;
import com.l2jmobius.commons.util.IGameXmlReader;
import com.l2jmobius.commons.util.IXmlReader;
import com.l2jmobius.commons.util.file.filter.NumericNameFilter;
import com.l2jmobius.gameserver.datatables.ItemTable;
import com.l2jmobius.gameserver.enums.SpecialItemType;
@@ -46,14 +46,14 @@ import com.l2jmobius.gameserver.model.holders.PreparedMultisellListHolder;
import com.l2jmobius.gameserver.model.items.Item;
import com.l2jmobius.gameserver.network.serverpackets.MultiSellList;
public final class MultisellData implements IGameXmlReader
public final class MultisellData implements IXmlReader
{
private static final Logger LOGGER = Logger.getLogger(MultisellData.class.getName());
public static final int PAGE_SIZE = 40;
private static final FileFilter NUMERIC_FILTER = new NumericNameFilter();
private final Map<Integer, MultisellListHolder> _multisells = new HashMap<>();
private final Map<Integer, MultisellListHolder> _multisells = new ConcurrentHashMap<>();
protected MultisellData()
{

View File

@@ -26,6 +26,8 @@ import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.CopyOnWriteArrayList;
import java.util.function.Predicate;
import java.util.logging.Logger;
import java.util.stream.Collectors;
@@ -36,7 +38,7 @@ import org.w3c.dom.Node;
import com.l2jmobius.Config;
import com.l2jmobius.commons.util.CommonUtil;
import com.l2jmobius.commons.util.IGameXmlReader;
import com.l2jmobius.commons.util.IXmlReader;
import com.l2jmobius.gameserver.datatables.ItemTable;
import com.l2jmobius.gameserver.enums.AISkillScope;
import com.l2jmobius.gameserver.enums.DropType;
@@ -52,13 +54,13 @@ import com.l2jmobius.gameserver.model.skills.Skill;
* NPC data parser.
* @author NosBit
*/
public class NpcData implements IGameXmlReader
public class NpcData implements IXmlReader
{
protected static final Logger LOGGER = Logger.getLogger(NpcData.class.getName());
private final Map<Integer, NpcTemplate> _npcs = new HashMap<>();
private final Map<String, Integer> _clans = new HashMap<>();
private static final List<Integer> _masterMonsterIDs = new ArrayList<>();
private final Map<Integer, NpcTemplate> _npcs = new ConcurrentHashMap<>();
private final Map<String, Integer> _clans = new ConcurrentHashMap<>();
private static final List<Integer> _masterMonsterIDs = new CopyOnWriteArrayList<>();
protected NpcData()
{

View File

@@ -18,13 +18,12 @@ package com.l2jmobius.gameserver.data.xml.impl;
import java.io.File;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import java.util.logging.Logger;
import org.w3c.dom.Document;
import com.l2jmobius.commons.util.IGameXmlReader;
import com.l2jmobius.commons.util.IXmlReader;
import com.l2jmobius.gameserver.handler.EffectHandler;
import com.l2jmobius.gameserver.model.StatsSet;
@@ -36,11 +35,11 @@ import com.l2jmobius.gameserver.model.options.OptionsSkillType;
/**
* @author UnAfraid
*/
public class OptionData implements IGameXmlReader
public class OptionData implements IXmlReader
{
private static final Logger LOGGER = Logger.getLogger(OptionData.class.getName());
private final Map<Integer, Options> _optionData = new HashMap<>();
private final Map<Integer, Options> _optionData = new ConcurrentHashMap<>();
protected OptionData()
{

View File

@@ -17,15 +17,15 @@
package com.l2jmobius.gameserver.data.xml.impl;
import java.io.File;
import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import java.util.logging.Logger;
import org.w3c.dom.Document;
import org.w3c.dom.NamedNodeMap;
import org.w3c.dom.Node;
import com.l2jmobius.commons.util.IGameXmlReader;
import com.l2jmobius.commons.util.IXmlReader;
import com.l2jmobius.gameserver.enums.MountType;
import com.l2jmobius.gameserver.model.PetData;
import com.l2jmobius.gameserver.model.PetLevelData;
@@ -36,11 +36,11 @@ import com.l2jmobius.gameserver.model.StatsSet;
* TODO: load and use all pet parameters.
* @author Zoey76 (rework)
*/
public final class PetDataTable implements IGameXmlReader
public final class PetDataTable implements IXmlReader
{
private static final Logger LOGGER = Logger.getLogger(PetDataTable.class.getName());
private final Map<Integer, PetData> _pets = new HashMap<>();
private final Map<Integer, PetData> _pets = new ConcurrentHashMap<>();
/**
* Instantiates a new pet data table.

View File

@@ -27,14 +27,14 @@ import org.w3c.dom.Document;
import org.w3c.dom.NamedNodeMap;
import org.w3c.dom.Node;
import com.l2jmobius.commons.util.IGameXmlReader;
import com.l2jmobius.commons.util.IXmlReader;
import com.l2jmobius.gameserver.model.actor.Summon;
import com.l2jmobius.gameserver.model.holders.SkillHolder;
/**
* @author Mobius
*/
public class PetSkillData implements IGameXmlReader
public class PetSkillData implements IXmlReader
{
private static Logger LOGGER = Logger.getLogger(PetSkillData.class.getName());
private final Map<Integer, Map<Long, SkillHolder>> _skillTrees = new HashMap<>();

View File

@@ -18,9 +18,9 @@ package com.l2jmobius.gameserver.data.xml.impl;
import java.io.File;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import java.util.logging.Logger;
import org.w3c.dom.Document;
@@ -28,7 +28,7 @@ import org.w3c.dom.NamedNodeMap;
import org.w3c.dom.Node;
import com.l2jmobius.Config;
import com.l2jmobius.commons.util.IGameXmlReader;
import com.l2jmobius.commons.util.IXmlReader;
import com.l2jmobius.gameserver.model.Location;
import com.l2jmobius.gameserver.model.StatsSet;
import com.l2jmobius.gameserver.model.actor.templates.PlayerTemplate;
@@ -38,11 +38,11 @@ import com.l2jmobius.gameserver.model.base.ClassId;
* Loads player's base stats.
* @author Forsaiken, Zoey76, GKR
*/
public final class PlayerTemplateData implements IGameXmlReader
public final class PlayerTemplateData implements IXmlReader
{
private static final Logger LOGGER = Logger.getLogger(PlayerTemplateData.class.getName());
private final Map<ClassId, PlayerTemplate> _playerTemplates = new HashMap<>();
private final Map<ClassId, PlayerTemplate> _playerTemplates = new ConcurrentHashMap<>();
private int _dataCount = 0;
private int _autoGeneratedCount = 0;

View File

@@ -24,13 +24,13 @@ import org.w3c.dom.Document;
import org.w3c.dom.NamedNodeMap;
import org.w3c.dom.Node;
import com.l2jmobius.commons.util.IGameXmlReader;
import com.l2jmobius.commons.util.IXmlReader;
/**
* This class holds the Player Xp Percent Lost Data for each level for players.
* @author Zealar
*/
public final class PlayerXpPercentLostData implements IGameXmlReader
public final class PlayerXpPercentLostData implements IXmlReader
{
private static final Logger LOGGER = Logger.getLogger(PlayerXpPercentLostData.class.getName());

View File

@@ -27,7 +27,7 @@ import org.w3c.dom.Document;
import org.w3c.dom.NamedNodeMap;
import org.w3c.dom.Node;
import com.l2jmobius.commons.util.IGameXmlReader;
import com.l2jmobius.commons.util.IXmlReader;
import com.l2jmobius.gameserver.datatables.ItemTable;
import com.l2jmobius.gameserver.model.StatsSet;
import com.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
@@ -39,7 +39,7 @@ import com.l2jmobius.gameserver.network.serverpackets.primeshop.ExBRProductInfo;
/**
* @author Gnacik, UnAfraid
*/
public class PrimeShopData implements IGameXmlReader
public class PrimeShopData implements IXmlReader
{
private static final Logger LOGGER = Logger.getLogger(PrimeShopData.class.getName());

View File

@@ -27,7 +27,7 @@ import org.w3c.dom.Document;
import org.w3c.dom.NamedNodeMap;
import org.w3c.dom.Node;
import com.l2jmobius.commons.util.IGameXmlReader;
import com.l2jmobius.commons.util.IXmlReader;
import com.l2jmobius.gameserver.model.RecipeInstance;
import com.l2jmobius.gameserver.model.RecipeList;
import com.l2jmobius.gameserver.model.RecipeStatInstance;
@@ -38,7 +38,7 @@ import com.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
* The Class RecipeData.
* @author Zoey76
*/
public class RecipeData implements IGameXmlReader
public class RecipeData implements IXmlReader
{
private static final Logger LOGGER = Logger.getLogger(RecipeData.class.getName());

View File

@@ -28,7 +28,7 @@ import org.w3c.dom.Document;
import org.w3c.dom.NamedNodeMap;
import org.w3c.dom.Node;
import com.l2jmobius.commons.util.IGameXmlReader;
import com.l2jmobius.commons.util.IXmlReader;
import com.l2jmobius.gameserver.model.StatsSet;
import com.l2jmobius.gameserver.model.residences.ResidenceFunctionTemplate;
@@ -36,7 +36,7 @@ import com.l2jmobius.gameserver.model.residences.ResidenceFunctionTemplate;
* The residence functions data
* @author UnAfraid
*/
public final class ResidenceFunctionsData implements IGameXmlReader
public final class ResidenceFunctionsData implements IXmlReader
{
private static final Logger LOGGER = Logger.getLogger(ResidenceFunctionsData.class.getName());
private final Map<Integer, List<ResidenceFunctionTemplate>> _functions = new HashMap<>();

View File

@@ -26,13 +26,13 @@ import org.w3c.dom.Document;
import org.w3c.dom.NamedNodeMap;
import org.w3c.dom.Node;
import com.l2jmobius.commons.util.IGameXmlReader;
import com.l2jmobius.commons.util.IXmlReader;
import com.l2jmobius.gameserver.model.SayuneEntry;
/**
* @author UnAfraid
*/
public class SayuneData implements IGameXmlReader
public class SayuneData implements IXmlReader
{
private static final Logger LOGGER = Logger.getLogger(SayuneData.class.getName());

View File

@@ -25,12 +25,12 @@ import java.util.logging.Logger;
import org.w3c.dom.Document;
import org.w3c.dom.Node;
import com.l2jmobius.commons.util.IGameXmlReader;
import com.l2jmobius.commons.util.IXmlReader;
/**
* @author NosBit
*/
public class SecondaryAuthData implements IGameXmlReader
public class SecondaryAuthData implements IXmlReader
{
private static final Logger LOGGER = Logger.getLogger(SecondaryAuthData.class.getName());

View File

@@ -27,7 +27,7 @@ import org.w3c.dom.Document;
import org.w3c.dom.NamedNodeMap;
import org.w3c.dom.Node;
import com.l2jmobius.commons.util.IGameXmlReader;
import com.l2jmobius.commons.util.IXmlReader;
import com.l2jmobius.gameserver.model.Location;
import com.l2jmobius.gameserver.model.StatsSet;
import com.l2jmobius.gameserver.model.VehiclePathPoint;
@@ -40,7 +40,7 @@ import com.l2jmobius.gameserver.model.shuttle.ShuttleStop;
/**
* @author UnAfraid
*/
public final class ShuttleData implements IGameXmlReader
public final class ShuttleData implements IXmlReader
{
private static final Logger LOGGER = Logger.getLogger(ShuttleData.class.getName());

View File

@@ -27,7 +27,7 @@ import org.w3c.dom.Document;
import org.w3c.dom.NamedNodeMap;
import org.w3c.dom.Node;
import com.l2jmobius.commons.util.IGameXmlReader;
import com.l2jmobius.commons.util.IXmlReader;
import com.l2jmobius.gameserver.model.SiegeScheduleDate;
import com.l2jmobius.gameserver.model.StatsSet;
import com.l2jmobius.gameserver.util.Util;
@@ -35,7 +35,7 @@ import com.l2jmobius.gameserver.util.Util;
/**
* @author UnAfraid
*/
public class SiegeScheduleData implements IGameXmlReader
public class SiegeScheduleData implements IXmlReader
{
private static final Logger LOGGER = Logger.getLogger(SiegeScheduleData.class.getName());

View File

@@ -25,6 +25,7 @@ import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
import java.util.function.BiConsumer;
import java.util.function.Function;
import java.util.logging.Level;
@@ -35,7 +36,7 @@ import org.w3c.dom.Document;
import org.w3c.dom.NamedNodeMap;
import org.w3c.dom.Node;
import com.l2jmobius.commons.util.IGameXmlReader;
import com.l2jmobius.commons.util.IXmlReader;
import com.l2jmobius.gameserver.handler.EffectHandler;
import com.l2jmobius.gameserver.handler.SkillConditionHandler;
import com.l2jmobius.gameserver.model.StatsSet;
@@ -51,12 +52,12 @@ import com.l2jmobius.gameserver.util.exp4j.ExpressionBuilder;
* Skill data parser.
* @author NosBit
*/
public class SkillData implements IGameXmlReader
public class SkillData implements IXmlReader
{
private static final Logger LOGGER = Logger.getLogger(SkillData.class.getName());
private final Map<Long, Skill> _skills = new HashMap<>();
private final Map<Integer, Integer> _skillsMaxLevel = new HashMap<>();
private final Map<Long, Skill> _skills = new ConcurrentHashMap<>();
private final Map<Integer, Integer> _skillsMaxLevel = new ConcurrentHashMap<>();
private class NamedParamInfo
{

View File

@@ -29,6 +29,7 @@ import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.logging.Logger;
import java.util.stream.Collectors;
@@ -38,7 +39,7 @@ import org.w3c.dom.NamedNodeMap;
import org.w3c.dom.Node;
import com.l2jmobius.Config;
import com.l2jmobius.commons.util.IGameXmlReader;
import com.l2jmobius.commons.util.IXmlReader;
import com.l2jmobius.gameserver.enums.CategoryType;
import com.l2jmobius.gameserver.enums.Race;
import com.l2jmobius.gameserver.enums.SubclassType;
@@ -77,34 +78,34 @@ 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.<br>
* @author Zoey76
*/
public final class SkillTreesData implements IGameXmlReader
public final class SkillTreesData implements IXmlReader
{
private static final Logger LOGGER = Logger.getLogger(SkillTreesData.class.getName());
// ClassId, Map of Skill Hash Code, SkillLearn
private static final Map<ClassId, Map<Long, SkillLearn>> _classSkillTrees = new HashMap<>();
private static final Map<ClassId, Map<Long, SkillLearn>> _transferSkillTrees = new HashMap<>();
private static final Map<Race, Map<Long, SkillLearn>> _raceSkillTree = new HashMap<>();
private static final Map<SubclassType, Map<Long, SkillLearn>> _revelationSkillTree = new HashMap<>();
private static final Map<ClassId, Set<Integer>> _awakeningSaveSkillTree = new HashMap<>();
private static final Map<ClassId, Map<Long, SkillLearn>> _classSkillTrees = new ConcurrentHashMap<>();
private static final Map<ClassId, Map<Long, SkillLearn>> _transferSkillTrees = new ConcurrentHashMap<>();
private static final Map<Race, Map<Long, SkillLearn>> _raceSkillTree = new ConcurrentHashMap<>();
private static final Map<SubclassType, Map<Long, SkillLearn>> _revelationSkillTree = new ConcurrentHashMap<>();
private static final Map<ClassId, Set<Integer>> _awakeningSaveSkillTree = new ConcurrentHashMap<>();
// Skill Hash Code, SkillLearn
private static final Map<Long, SkillLearn> _collectSkillTree = new HashMap<>();
private static final Map<Long, SkillLearn> _fishingSkillTree = new HashMap<>();
private static final Map<Long, SkillLearn> _pledgeSkillTree = new HashMap<>();
private static final Map<Long, SkillLearn> _subClassSkillTree = new HashMap<>();
private static final Map<Long, SkillLearn> _subPledgeSkillTree = new HashMap<>();
private static final Map<Long, SkillLearn> _transformSkillTree = new HashMap<>();
private static final Map<Long, SkillLearn> _commonSkillTree = new HashMap<>();
private static final Map<Long, SkillLearn> _abilitySkillTree = new HashMap<>();
private static final Map<Long, SkillLearn> _alchemySkillTree = new HashMap<>();
private static final Map<Long, SkillLearn> _dualClassSkillTree = new HashMap<>();
private static final Map<Long, SkillLearn> _collectSkillTree = new ConcurrentHashMap<>();
private static final Map<Long, SkillLearn> _fishingSkillTree = new ConcurrentHashMap<>();
private static final Map<Long, SkillLearn> _pledgeSkillTree = new ConcurrentHashMap<>();
private static final Map<Long, SkillLearn> _subClassSkillTree = new ConcurrentHashMap<>();
private static final Map<Long, SkillLearn> _subPledgeSkillTree = new ConcurrentHashMap<>();
private static final Map<Long, SkillLearn> _transformSkillTree = new ConcurrentHashMap<>();
private static final Map<Long, SkillLearn> _commonSkillTree = new ConcurrentHashMap<>();
private static final Map<Long, SkillLearn> _abilitySkillTree = new ConcurrentHashMap<>();
private static final Map<Long, SkillLearn> _alchemySkillTree = new ConcurrentHashMap<>();
private static final Map<Long, SkillLearn> _dualClassSkillTree = new ConcurrentHashMap<>();
// Other skill trees
private static final Map<Long, SkillLearn> _nobleSkillTree = new HashMap<>();
private static final Map<Long, SkillLearn> _heroSkillTree = new HashMap<>();
private static final Map<Long, SkillLearn> _gameMasterSkillTree = new HashMap<>();
private static final Map<Long, SkillLearn> _gameMasterAuraSkillTree = new HashMap<>();
private static final Map<Long, SkillLearn> _nobleSkillTree = new ConcurrentHashMap<>();
private static final Map<Long, SkillLearn> _heroSkillTree = new ConcurrentHashMap<>();
private static final Map<Long, SkillLearn> _gameMasterSkillTree = new ConcurrentHashMap<>();
private static final Map<Long, SkillLearn> _gameMasterAuraSkillTree = new ConcurrentHashMap<>();
// Remove skill tree
private static final Map<ClassId, Set<Integer>> _removeSkillCache = new HashMap<>();
private static final Map<ClassId, Set<Integer>> _removeSkillCache = new ConcurrentHashMap<>();
// Checker, sorted arrays of hash codes
private Map<Integer, long[]> _skillsByClassIdHashCodes; // Occupation skills
@@ -112,7 +113,7 @@ public final class SkillTreesData implements IGameXmlReader
private long[] _allSkillsHashCodes; // Fishing, Collection, Transformations, Common Skills.
/** Parent class Ids are read from XML and stored in this map, to allow easy customization. */
private static final Map<ClassId, ClassId> _parentClassMap = new HashMap<>();
private static final Map<ClassId, ClassId> _parentClassMap = new ConcurrentHashMap<>();
private final AtomicBoolean _isLoading = new AtomicBoolean();

View File

@@ -19,9 +19,10 @@ package com.l2jmobius.gameserver.data.xml.impl;
import java.io.File;
import java.util.ArrayList;
import java.util.Collections;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.concurrent.CopyOnWriteArrayList;
import java.util.concurrent.ScheduledFuture;
import java.util.function.Predicate;
import java.util.logging.Level;
import java.util.logging.Logger;
@@ -31,7 +32,7 @@ import org.w3c.dom.Document;
import org.w3c.dom.Node;
import com.l2jmobius.Config;
import com.l2jmobius.commons.util.IGameXmlReader;
import com.l2jmobius.commons.concurrent.ThreadPool;
import com.l2jmobius.commons.util.IXmlReader;
import com.l2jmobius.gameserver.model.ChanceLocation;
import com.l2jmobius.gameserver.model.StatsSet;
@@ -49,11 +50,11 @@ import com.l2jmobius.gameserver.model.zone.type.SpawnTerritory;
/**
* @author UnAfraid
*/
public class SpawnsData implements IGameXmlReader
public class SpawnsData implements IXmlReader
{
protected static final Logger LOGGER = Logger.getLogger(SpawnsData.class.getName());
private final List<SpawnTemplate> _spawns = new LinkedList<>();
private final List<SpawnTemplate> _spawns = new CopyOnWriteArrayList<>();
protected SpawnsData()
{
@@ -94,11 +95,28 @@ public class SpawnsData implements IGameXmlReader
}
LOGGER.info(getClass().getSimpleName() + ": Initializing spawns...");
_spawns.stream().filter(SpawnTemplate::isSpawningByDefault).forEach(template ->
final List<ScheduledFuture<?>> jobs = new CopyOnWriteArrayList<>();
for (SpawnTemplate template : _spawns)
{
template.spawnAll(null);
template.notifyActivate();
});
if (template.isSpawningByDefault())
{
jobs.add(ThreadPool.schedule(() ->
{
template.spawnAll(null);
template.notifyActivate();
}, 0));
}
}
while (!jobs.isEmpty())
{
for (ScheduledFuture<?> job : jobs)
{
if ((job == null) || job.isDone() || job.isCancelled())
{
jobs.remove(job);
}
}
}
LOGGER.info(getClass().getSimpleName() + ": All spawns has been initialized!");
}

View File

@@ -26,7 +26,7 @@ import org.w3c.dom.Document;
import org.w3c.dom.NamedNodeMap;
import org.w3c.dom.Node;
import com.l2jmobius.commons.util.IGameXmlReader;
import com.l2jmobius.commons.util.IXmlReader;
import com.l2jmobius.gameserver.model.StatsSet;
import com.l2jmobius.gameserver.model.actor.instance.StaticObjectInstance;
import com.l2jmobius.gameserver.model.actor.templates.CreatureTemplate;
@@ -35,7 +35,7 @@ import com.l2jmobius.gameserver.model.actor.templates.CreatureTemplate;
* This class loads and holds all static object data.
* @author UnAfraid
*/
public final class StaticObjectData implements IGameXmlReader
public final class StaticObjectData implements IXmlReader
{
private static final Logger LOGGER = Logger.getLogger(StaticObjectData.class.getName());

View File

@@ -20,12 +20,13 @@ import java.io.File;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import java.util.logging.Logger;
import org.w3c.dom.Document;
import org.w3c.dom.NamedNodeMap;
import com.l2jmobius.commons.util.IGameXmlReader;
import com.l2jmobius.commons.util.IXmlReader;
import com.l2jmobius.gameserver.enums.TeleportType;
import com.l2jmobius.gameserver.model.StatsSet;
import com.l2jmobius.gameserver.model.teleporter.TeleportHolder;
@@ -33,12 +34,12 @@ import com.l2jmobius.gameserver.model.teleporter.TeleportHolder;
/**
* @author UnAfraid
*/
public class TeleportersData implements IGameXmlReader
public class TeleportersData implements IXmlReader
{
// Logger instance
private static final Logger LOGGER = Logger.getLogger(TeleportersData.class.getName());
// Teleporter data
private final Map<Integer, Map<String, TeleportHolder>> _teleporters = new HashMap<>();
private final Map<Integer, Map<String, TeleportHolder>> _teleporters = new ConcurrentHashMap<>();
protected TeleportersData()
{

View File

@@ -17,15 +17,15 @@
package com.l2jmobius.gameserver.data.xml.impl;
import java.io.File;
import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import java.util.logging.Logger;
import org.w3c.dom.Document;
import org.w3c.dom.NamedNodeMap;
import org.w3c.dom.Node;
import com.l2jmobius.commons.util.IGameXmlReader;
import com.l2jmobius.commons.util.IXmlReader;
import com.l2jmobius.gameserver.model.StatsSet;
import com.l2jmobius.gameserver.model.actor.transform.Transform;
import com.l2jmobius.gameserver.model.actor.transform.TransformLevelData;
@@ -39,11 +39,11 @@ import com.l2jmobius.gameserver.network.serverpackets.ExBasicActionList;
* Transformation data.
* @author UnAfraid
*/
public final class TransformData implements IGameXmlReader
public final class TransformData implements IXmlReader
{
private static final Logger LOGGER = Logger.getLogger(TransformData.class.getName());
private final Map<Integer, Transform> _transformData = new HashMap<>();
private final Map<Integer, Transform> _transformData = new ConcurrentHashMap<>();
protected TransformData()
{

View File

@@ -22,11 +22,12 @@ import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import java.util.logging.Logger;
import org.w3c.dom.Document;
import com.l2jmobius.commons.util.IGameXmlReader;
import com.l2jmobius.commons.util.IXmlReader;
import com.l2jmobius.gameserver.datatables.ItemTable;
import com.l2jmobius.gameserver.model.VariationInstance;
import com.l2jmobius.gameserver.model.items.instance.ItemInstance;
@@ -40,12 +41,12 @@ import com.l2jmobius.gameserver.model.options.VariationWeaponType;
/**
* @author Pere
*/
public class VariationData implements IGameXmlReader
public class VariationData implements IXmlReader
{
private static final Logger LOGGER = Logger.getLogger(VariationData.class.getSimpleName());
private final Map<Integer, Variation> _variations = new HashMap<>();
private final Map<Integer, Map<Integer, VariationFee>> _fees = new HashMap<>();
private final Map<Integer, Variation> _variations = new ConcurrentHashMap<>();
private final Map<Integer, Map<Integer, VariationFee>> _fees = new ConcurrentHashMap<>();
protected VariationData()
{

View File

@@ -17,11 +17,14 @@
package com.l2jmobius.gameserver.engines;
import java.io.File;
import java.util.LinkedList;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.CopyOnWriteArrayList;
import java.util.concurrent.ScheduledFuture;
import java.util.logging.Logger;
import com.l2jmobius.Config;
import com.l2jmobius.commons.concurrent.ThreadPool;
import com.l2jmobius.commons.util.file.filter.XMLFilter;
import com.l2jmobius.gameserver.engines.items.DocumentItem;
import com.l2jmobius.gameserver.model.items.Item;
@@ -33,34 +36,29 @@ public class DocumentEngine
{
private static final Logger LOGGER = Logger.getLogger(DocumentEngine.class.getName());
private final List<File> _itemFiles = new LinkedList<>();
public static DocumentEngine getInstance()
{
return SingletonHolder._instance;
}
private final List<File> _itemFiles = new ArrayList<>();
protected DocumentEngine()
{
hashFiles("data/stats/items", _itemFiles);
processDirectory("data/stats/items", _itemFiles);
if (Config.CUSTOM_ITEMS_LOAD)
{
hashFiles("data/stats/items/custom", _itemFiles);
processDirectory("data/stats/items/custom", _itemFiles);
}
}
private void hashFiles(String dirname, List<File> hash)
private void processDirectory(String dirName, List<File> list)
{
final File dir = new File(Config.DATAPACK_ROOT, dirname);
final File dir = new File(Config.DATAPACK_ROOT, dirName);
if (!dir.exists())
{
LOGGER.warning("Dir " + dir.getAbsolutePath() + " not exists");
LOGGER.warning("Dir " + dir.getAbsolutePath() + " does not exist.");
return;
}
final File[] files = dir.listFiles(new XMLFilter());
for (File f : files)
for (File file : files)
{
hash.add(f);
list.add(file);
}
}
@@ -70,12 +68,26 @@ public class DocumentEngine
*/
public List<Item> loadItems()
{
final List<Item> list = new LinkedList<>();
for (File f : _itemFiles)
final List<Item> list = new CopyOnWriteArrayList<>();
final List<ScheduledFuture<?>> jobs = new CopyOnWriteArrayList<>();
for (File file : _itemFiles)
{
final DocumentItem document = new DocumentItem(f);
document.parse();
list.addAll(document.getItemList());
jobs.add(ThreadPool.schedule(() ->
{
final DocumentItem document = new DocumentItem(file);
document.parse();
list.addAll(document.getItemList());
}, 0));
}
while (!jobs.isEmpty())
{
for (ScheduledFuture<?> job : jobs)
{
if ((job == null) || job.isDone() || job.isCancelled())
{
jobs.remove(job);
}
}
}
return list;
}
@@ -84,4 +96,9 @@ public class DocumentEngine
{
protected static final DocumentEngine _instance = new DocumentEngine();
}
public static DocumentEngine getInstance()
{
return SingletonHolder._instance;
}
}

View File

@@ -19,7 +19,7 @@ package com.l2jmobius.gameserver.engines.items;
import java.io.File;
import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationTargetException;
import java.util.LinkedList;
import java.util.ArrayList;
import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;
@@ -27,7 +27,7 @@ import java.util.logging.Logger;
import org.w3c.dom.Document;
import org.w3c.dom.Node;
import com.l2jmobius.commons.util.IGameXmlReader;
import com.l2jmobius.commons.util.IXmlReader;
import com.l2jmobius.gameserver.engines.DocumentBase;
import com.l2jmobius.gameserver.enums.ItemSkillType;
import com.l2jmobius.gameserver.model.ExtractableProduct;
@@ -41,12 +41,12 @@ import com.l2jmobius.gameserver.model.stats.functions.FuncTemplate;
/**
* @author mkizub, JIV
*/
public final class DocumentItem extends DocumentBase implements IGameXmlReader
public final class DocumentItem extends DocumentBase implements IXmlReader
{
Logger LOGGER = Logger.getLogger(DocumentItem.class.getName());
private ItemDataHolder _currentItem = null;
private final List<Item> _itemsInFile = new LinkedList<>();
private final List<Item> _itemsInFile = new ArrayList<>();
/**
* @param file

View File

@@ -50,7 +50,7 @@ public final class ConditionHandler
{
try
{
ScriptEngineManager.getInstance().executeConditionMasterHandler();
ScriptEngineManager.getInstance().executeScript(ScriptEngineManager.CONDITION_HANDLER_FILE);
}
catch (Exception e)
{

View File

@@ -50,7 +50,7 @@ public final class EffectHandler
{
try
{
ScriptEngineManager.getInstance().executeEffectMasterHandler();
ScriptEngineManager.getInstance().executeScript(ScriptEngineManager.EFFECT_MASTER_HANDLER_FILE);
}
catch (Exception e)
{

View File

@@ -50,7 +50,7 @@ public final class SkillConditionHandler
{
try
{
ScriptEngineManager.getInstance().executeSkillConditionMasterHandler();
ScriptEngineManager.getInstance().executeScript(ScriptEngineManager.SKILL_CONDITION_HANDLER_FILE);
}
catch (Exception e)
{

View File

@@ -40,7 +40,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.IGameXmlReader;
import com.l2jmobius.commons.util.IXmlReader;
import com.l2jmobius.commons.util.Rnd;
import com.l2jmobius.gameserver.enums.ManorMode;
import com.l2jmobius.gameserver.model.CropProcure;
@@ -58,7 +58,7 @@ import com.l2jmobius.gameserver.network.SystemMessageId;
* Castle manor system.
* @author malyelfik
*/
public final class CastleManorManager implements IGameXmlReader, IStorable
public final class CastleManorManager implements IXmlReader, IStorable
{
private static final Logger LOGGER = Logger.getLogger(CastleManorManager.class.getName());

View File

@@ -35,7 +35,7 @@ import org.w3c.dom.Node;
import com.l2jmobius.Config;
import com.l2jmobius.commons.database.DatabaseFactory;
import com.l2jmobius.commons.util.IGameXmlReader;
import com.l2jmobius.commons.util.IXmlReader;
import com.l2jmobius.gameserver.model.CursedWeapon;
import com.l2jmobius.gameserver.model.actor.Attackable;
import com.l2jmobius.gameserver.model.actor.Creature;
@@ -54,7 +54,7 @@ import com.l2jmobius.gameserver.util.Broadcast;
* UnAfraid: TODO: Rewrite with DocumentParser
* @author Micht
*/
public final class CursedWeaponsManager implements IGameXmlReader
public final class CursedWeaponsManager implements IXmlReader
{
private static final Logger LOGGER = Logger.getLogger(CursedWeaponsManager.class.getName());

View File

@@ -25,7 +25,7 @@ import org.w3c.dom.Document;
import com.l2jmobius.Config;
import com.l2jmobius.commons.concurrent.ThreadPool;
import com.l2jmobius.commons.util.IGameXmlReader;
import com.l2jmobius.commons.util.IXmlReader;
import com.l2jmobius.commons.util.Rnd;
import com.l2jmobius.gameserver.data.xml.impl.FakePlayerData;
import com.l2jmobius.gameserver.datatables.SpawnTable;
@@ -41,7 +41,7 @@ import com.l2jmobius.gameserver.network.serverpackets.CreatureSay;
/**
* @author Mobius
*/
public final class FakePlayerChatManager implements IGameXmlReader
public final class FakePlayerChatManager implements IXmlReader
{
private static Logger LOGGER = Logger.getLogger(FakePlayerChatManager.class.getName());
final List<FakePlayerChatHolder> MESSAGES = new ArrayList<>();

View File

@@ -40,7 +40,6 @@ import org.w3c.dom.Node;
import com.l2jmobius.Config;
import com.l2jmobius.commons.database.DatabaseFactory;
import com.l2jmobius.commons.util.IGameXmlReader;
import com.l2jmobius.commons.util.IXmlReader;
import com.l2jmobius.gameserver.data.xml.impl.DoorData;
import com.l2jmobius.gameserver.data.xml.impl.SpawnsData;
@@ -61,7 +60,7 @@ import com.l2jmobius.gameserver.model.spawns.SpawnTemplate;
* Instance manager.
* @author evill33t, GodKratos, malyelfik
*/
public final class InstanceManager implements IGameXmlReader
public final class InstanceManager implements IXmlReader
{
private static final Logger LOGGER = Logger.getLogger(InstanceManager.class.getName());
// Database query

View File

@@ -34,13 +34,13 @@ import org.w3c.dom.Node;
import com.l2jmobius.Config;
import com.l2jmobius.commons.database.DatabaseFactory;
import com.l2jmobius.commons.util.IGameXmlReader;
import com.l2jmobius.commons.util.IXmlReader;
import com.l2jmobius.gameserver.model.itemauction.ItemAuctionInstance;
/**
* @author Forsaiken
*/
public final class ItemAuctionManager implements IGameXmlReader
public final class ItemAuctionManager implements IXmlReader
{
private static final Logger LOGGER = Logger.getLogger(ItemAuctionManager.class.getName());

View File

@@ -27,7 +27,7 @@ import org.w3c.dom.NamedNodeMap;
import org.w3c.dom.Node;
import com.l2jmobius.Config;
import com.l2jmobius.commons.util.IGameXmlReader;
import com.l2jmobius.commons.util.IXmlReader;
import com.l2jmobius.gameserver.data.xml.impl.ClanHallData;
import com.l2jmobius.gameserver.model.Location;
import com.l2jmobius.gameserver.model.MapRegion;
@@ -47,7 +47,7 @@ import com.l2jmobius.gameserver.model.zone.type.RespawnZone;
* Map Region Manager.
* @author Nyaran
*/
public final class MapRegionManager implements IGameXmlReader
public final class MapRegionManager implements IXmlReader
{
private static final Logger LOGGER = Logger.getLogger(MapRegionManager.class.getName());

View File

@@ -26,7 +26,7 @@ import org.w3c.dom.Element;
import org.w3c.dom.NodeList;
import com.l2jmobius.Config;
import com.l2jmobius.commons.util.IGameXmlReader;
import com.l2jmobius.commons.util.IXmlReader;
import com.l2jmobius.gameserver.cache.HtmCache;
import com.l2jmobius.gameserver.data.xml.impl.SkillData;
import com.l2jmobius.gameserver.datatables.ItemTable;
@@ -46,7 +46,7 @@ import com.l2jmobius.gameserver.util.Util;
* Sell Buffs Manager
* @author St3eT
*/
public final class SellBuffsManager implements IGameXmlReader
public final class SellBuffsManager implements IXmlReader
{
private static final Logger LOGGER = Logger.getLogger(SellBuffsManager.class.getName());
private static final List<Integer> ALLOWED_BUFFS = new ArrayList<>();

View File

@@ -28,7 +28,7 @@ import org.w3c.dom.NamedNodeMap;
import org.w3c.dom.Node;
import com.l2jmobius.commons.concurrent.ThreadPool;
import com.l2jmobius.commons.util.IGameXmlReader;
import com.l2jmobius.commons.util.IXmlReader;
import com.l2jmobius.gameserver.ai.CtrlIntention;
import com.l2jmobius.gameserver.data.xml.impl.NpcData;
import com.l2jmobius.gameserver.enums.ChatType;
@@ -49,7 +49,7 @@ import com.l2jmobius.gameserver.network.NpcStringId;
* This class manages walking monsters.
* @author GKR
*/
public final class WalkingManager implements IGameXmlReader
public final class WalkingManager implements IXmlReader
{
private static final Logger LOGGER = Logger.getLogger(WalkingManager.class.getName());

View File

@@ -26,6 +26,7 @@ import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.OptionalInt;
import java.util.concurrent.ConcurrentHashMap;
import java.util.logging.Level;
import java.util.logging.Logger;
@@ -33,7 +34,7 @@ import org.w3c.dom.Document;
import org.w3c.dom.NamedNodeMap;
import org.w3c.dom.Node;
import com.l2jmobius.commons.util.IGameXmlReader;
import com.l2jmobius.commons.util.IXmlReader;
import com.l2jmobius.gameserver.model.World;
import com.l2jmobius.gameserver.model.WorldObject;
import com.l2jmobius.gameserver.model.actor.Creature;
@@ -55,7 +56,7 @@ import com.l2jmobius.gameserver.model.zone.type.SpawnTerritory;
* This class manages the zones
* @author durgus
*/
public final class ZoneManager implements IGameXmlReader
public final class ZoneManager implements IXmlReader
{
private static final Logger LOGGER = Logger.getLogger(ZoneManager.class.getName());
@@ -65,9 +66,9 @@ public final class ZoneManager implements IGameXmlReader
private static final int OFFSET_X = Math.abs(World.MAP_MIN_X >> SHIFT_BY);
private static final int OFFSET_Y = Math.abs(World.MAP_MIN_Y >> SHIFT_BY);
private final Map<Class<? extends ZoneType>, Map<Integer, ? extends ZoneType>> _classZones = new HashMap<>();
private final Map<String, SpawnTerritory> _spawnTerritories = new HashMap<>();
private int _lastDynamicId = 300000;
private final Map<Class<? extends ZoneType>, ConcurrentHashMap<Integer, ? extends ZoneType>> _classZones = new ConcurrentHashMap<>();
private final Map<String, SpawnTerritory> _spawnTerritories = new ConcurrentHashMap<>();
private volatile int _lastDynamicId = 300000;
private List<ItemInstance> _debugItems;
private final ZoneRegion[][] _zoneRegions = new ZoneRegion[(World.MAP_MAX_X >> SHIFT_BY) + OFFSET_X + 1][(World.MAP_MAX_Y >> SHIFT_BY) + OFFSET_Y + 1];
@@ -365,7 +366,7 @@ public final class ZoneManager implements IGameXmlReader
}
if (checkId(zoneId))
{
LOGGER.config(getClass().getSimpleName() + ": Caution: Zone (" + zoneId + ") from file: " + f.getName() + " overrides previos definition.");
LOGGER.config(getClass().getSimpleName() + ": Caution: Zone (" + zoneId + ") from file: " + f.getName() + " overrides previuos definition.");
}
if ((zoneName != null) && !zoneName.isEmpty())
@@ -453,10 +454,10 @@ public final class ZoneManager implements IGameXmlReader
@SuppressWarnings("unchecked")
private <T extends ZoneType> void addZone(Integer id, T zone)
{
Map<Integer, T> map = (Map<Integer, T>) _classZones.get(zone.getClass());
ConcurrentHashMap<Integer, T> map = (ConcurrentHashMap<Integer, T>) _classZones.get(zone.getClass());
if (map == null)
{
map = new HashMap<>();
map = new ConcurrentHashMap<>();
map.put(id, zone);
_classZones.put(zone.getClass(), map);
}

View File

@@ -32,7 +32,7 @@ import org.w3c.dom.Node;
import com.l2jmobius.commons.concurrent.ThreadPool;
import com.l2jmobius.commons.database.DatabaseFactory;
import com.l2jmobius.commons.util.IGameXmlReader;
import com.l2jmobius.commons.util.IXmlReader;
import com.l2jmobius.gameserver.data.sql.impl.AnnouncementsTable;
import com.l2jmobius.gameserver.data.xml.impl.NpcData;
import com.l2jmobius.gameserver.datatables.EventDroplist;
@@ -117,7 +117,7 @@ public class LongTimeEvent extends Quest
*/
private void loadConfig()
{
new IGameXmlReader()
new IXmlReader()
{
@Override
public void load()

View File

@@ -23,7 +23,6 @@ import java.util.logging.Logger;
import org.w3c.dom.Document;
import org.w3c.dom.NamedNodeMap;
import com.l2jmobius.commons.util.IGameXmlReader;
import com.l2jmobius.commons.util.IXmlReader;
import com.l2jmobius.gameserver.model.actor.Creature;
@@ -105,7 +104,7 @@ public enum BaseStats
static
{
new IGameXmlReader()
new IXmlReader()
{
final Logger LOGGER = Logger.getLogger(BaseStats.class.getName());

View File

@@ -28,8 +28,6 @@ import java.nio.file.attribute.BasicFileAttributes;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
@@ -42,14 +40,14 @@ import java.util.logging.Logger;
import org.w3c.dom.Document;
import com.l2jmobius.Config;
import com.l2jmobius.commons.util.IGameXmlReader;
import com.l2jmobius.commons.util.IXmlReader;
import com.l2jmobius.gameserver.scripting.java.JavaScriptingEngine;
/**
* Caches script engines and provides functionality for executing and managing scripts.
* @author KenM, HorridoJoho
*/
public final class ScriptEngineManager implements IGameXmlReader
public final class ScriptEngineManager implements IXmlReader
{
private static final Logger LOGGER = Logger.getLogger(ScriptEngineManager.class.getName());
public static final Path SCRIPT_FOLDER = Paths.get(Config.DATAPACK_ROOT.getAbsolutePath(), "data", "scripts");
@@ -58,8 +56,7 @@ public final class ScriptEngineManager implements IGameXmlReader
public static final Path SKILL_CONDITION_HANDLER_FILE = Paths.get(SCRIPT_FOLDER.toString(), "handlers", "SkillConditionMasterHandler.java");
public static final Path CONDITION_HANDLER_FILE = Paths.get(SCRIPT_FOLDER.toString(), "handlers", "ConditionMasterHandler.java");
private final Map<String, IExecutionContext> _extEngines = new HashMap<>();
private IExecutionContext _currentExecutionContext = null;
private IExecutionContext _javaExecutionContext = null;
static final List<String> _exclusions = new ArrayList<>();
protected ScriptEngineManager()
@@ -165,11 +162,7 @@ public final class ScriptEngineManager implements IGameXmlReader
private void registerEngine(IScriptingEngine engine, Properties props)
{
maybeSetProperties("language." + engine.getLanguageName() + ".", props, engine);
final IExecutionContext context = engine.createExecutionContext();
for (String commonExtension : engine.getCommonFileExtensions())
{
_extEngines.put(commonExtension, context);
}
_javaExecutionContext = engine.createExecutionContext();
LOGGER.info("ScriptEngine: " + engine.getEngineName() + " " + engine.getEngineVersion() + " (" + engine.getLanguageName() + " " + engine.getLanguageVersion() + ")");
}
@@ -199,61 +192,6 @@ public final class ScriptEngineManager implements IGameXmlReader
}
}
private IExecutionContext getEngineByExtension(String ext)
{
return _extEngines.get(ext);
}
private String getFileExtension(Path p)
{
final String name = p.getFileName().toString();
final int lastDotIdx = name.lastIndexOf('.');
if (lastDotIdx == -1)
{
return null;
}
final String extension = name.substring(lastDotIdx + 1);
if (extension.isEmpty())
{
return null;
}
return extension;
}
private void checkExistingFile(String messagePre, Path filePath) throws Exception
{
if (!Files.exists(filePath))
{
throw new Exception(messagePre + ": " + filePath + " does not exists!");
}
else if (!Files.isRegularFile(filePath))
{
throw new Exception(messagePre + ": " + filePath + " is not a file!");
}
}
public void executeMasterHandler() throws Exception
{
executeScript(MASTER_HANDLER_FILE);
}
public void executeEffectMasterHandler() throws Exception
{
executeScript(EFFECT_MASTER_HANDLER_FILE);
}
public void executeSkillConditionMasterHandler() throws Exception
{
executeScript(SKILL_CONDITION_HANDLER_FILE);
}
public void executeConditionMasterHandler() throws Exception
{
executeScript(CONDITION_HANDLER_FILE);
}
public void executeScriptList() throws Exception
{
if (Config.ALT_DEV_NO_QUESTS)
@@ -261,77 +199,35 @@ public final class ScriptEngineManager implements IGameXmlReader
return;
}
final Map<IExecutionContext, List<Path>> files = new LinkedHashMap<>();
final List<Path> files = new ArrayList<>();
processDirectory(SCRIPT_FOLDER.toFile(), files);
for (Entry<IExecutionContext, List<Path>> entry : files.entrySet())
final Map<Path, Throwable> invokationErrors = _javaExecutionContext.executeScripts(files);
for (Entry<Path, Throwable> entry : invokationErrors.entrySet())
{
_currentExecutionContext = entry.getKey();
try
{
final Map<Path, Throwable> invokationErrors = entry.getKey().executeScripts(entry.getValue());
for (Entry<Path, Throwable> entry2 : invokationErrors.entrySet())
{
LOGGER.log(Level.WARNING, "ScriptEngine: " + entry2.getKey() + " failed execution!", entry2.getValue());
}
}
finally
{
_currentExecutionContext = null;
}
LOGGER.log(Level.WARNING, "ScriptEngine: " + entry.getKey() + " failed execution!", entry.getValue());
}
}
private void processDirectory(File dir, Map<IExecutionContext, List<Path>> files)
private void processDirectory(File dir, List<Path> files)
{
for (File file : dir.listFiles())
{
if (file.isDirectory())
if (file.isFile())
{
final String fileName = file.getName();
if (fileName.endsWith(".java") && !_exclusions.contains(fileName))
{
files.add(file.toPath().toAbsolutePath());
}
}
else if (file.isDirectory())
{
processDirectory(file, files);
}
else
{
processFile(file, files);
}
}
}
private void processFile(File file, Map<IExecutionContext, List<Path>> files)
{
if (_exclusions.contains(file.getName()))
{
return;
}
Path sourceFile = file.toPath();
try
{
checkExistingFile("ScriptFile", sourceFile);
}
catch (Exception e)
{
LOGGER.warning(e.getMessage());
return;
}
sourceFile = sourceFile.toAbsolutePath();
final String ext = getFileExtension(sourceFile);
if (ext == null)
{
LOGGER.warning("ScriptFile: " + sourceFile + " does not have an extension to determine the script engine!");
return;
}
final IExecutionContext engine = getEngineByExtension(ext);
if (engine == null)
{
return;
}
files.computeIfAbsent(engine, k -> new LinkedList<>()).add(sourceFile);
}
public void executeScript(Path sourceFile) throws Exception
{
Objects.requireNonNull(sourceFile);
@@ -341,34 +237,19 @@ public final class ScriptEngineManager implements IGameXmlReader
sourceFile = SCRIPT_FOLDER.resolve(sourceFile);
}
// throws exception if not exists or not file
checkExistingFile("ScriptFile", sourceFile);
sourceFile = sourceFile.toAbsolutePath();
final String ext = getFileExtension(sourceFile);
Objects.requireNonNull(sourceFile, "ScriptFile: " + sourceFile + " does not have an extension to determine the script engine!");
final IExecutionContext engine = getEngineByExtension(ext);
Objects.requireNonNull(engine, "ScriptEngine: No engine registered for extension " + ext + "!");
_currentExecutionContext = engine;
try
final Entry<Path, Throwable> error = _javaExecutionContext.executeScript(sourceFile);
if (error != null)
{
final Entry<Path, Throwable> error = engine.executeScript(sourceFile);
if (error != null)
{
throw new Exception("ScriptEngine: " + error.getKey() + " failed execution!", error.getValue());
}
}
finally
{
_currentExecutionContext = null;
throw new Exception("ScriptEngine: " + error.getKey() + " failed execution!", error.getValue());
}
}
public Path getCurrentLoadingScript()
{
return _currentExecutionContext != null ? _currentExecutionContext.getCurrentExecutingScript() : null;
return _javaExecutionContext.getCurrentExecutingScript();
}
public static ScriptEngineManager getInstance()

View File

@@ -36,8 +36,8 @@ 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;
@@ -45,7 +45,7 @@ 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 IGameXmlReader
public final class GameServerTable implements IXmlReader
{
private static final Logger LOGGER = Logger.getLogger(GameServerTable.class.getName());

View File

@@ -2,11 +2,7 @@
<list xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../data/xsd/Scripts.xsd">
<!-- Skip these filenames from script loading, because they are already loaded using a different way. -->
<exclude file="package-info.java" />
<exclude file="MasterHandler.java" />
<exclude file="EffectMasterHandler.java" />
<exclude file="SkillConditionMasterHandler.java" />
<exclude file="ConditionMasterHandler.java" />
<exclude file="DailyMissionMasterHandler.java" />
<exclude file="handlers" />
<!--
With this file you can exclude/include specific folders/files from within the scripts directory.

View File

@@ -29,7 +29,7 @@ import org.w3c.dom.NamedNodeMap;
import org.w3c.dom.Node;
import com.l2jmobius.commons.concurrent.ThreadPool;
import com.l2jmobius.commons.util.IGameXmlReader;
import com.l2jmobius.commons.util.IXmlReader;
import com.l2jmobius.gameserver.ai.CtrlIntention;
import com.l2jmobius.gameserver.enums.ChatType;
import com.l2jmobius.gameserver.geoengine.GeoEngine;
@@ -56,7 +56,7 @@ import quests.Q00620_FourGoblets.Q00620_FourGoblets;
* Four Selpuchers AI
* @author Mobius
*/
public final class FourSepulchers extends AbstractNpcAI implements IGameXmlReader
public final class FourSepulchers extends AbstractNpcAI implements IXmlReader
{
Logger LOGGER = Logger.getLogger(FourSepulchers.class.getName());

View File

@@ -30,7 +30,7 @@ import org.w3c.dom.NamedNodeMap;
import org.w3c.dom.Node;
import com.l2jmobius.commons.util.CommonUtil;
import com.l2jmobius.commons.util.IGameXmlReader;
import com.l2jmobius.commons.util.IXmlReader;
import com.l2jmobius.gameserver.ai.CtrlIntention;
import com.l2jmobius.gameserver.enums.Movie;
import com.l2jmobius.gameserver.enums.TrapAction;
@@ -66,7 +66,7 @@ import instances.AbstractInstance;
* Please maintain consistency between the Seed scripts.
* @author Gigiikun
*/
public final class Stage1 extends AbstractInstance implements IGameXmlReader
public final class Stage1 extends AbstractInstance implements IXmlReader
{
Logger LOGGER = Logger.getLogger(Stage1.class.getName());

View File

@@ -30,7 +30,7 @@ import org.w3c.dom.NamedNodeMap;
import org.w3c.dom.Node;
import com.l2jmobius.Config;
import com.l2jmobius.commons.util.IGameXmlReader;
import com.l2jmobius.commons.util.IXmlReader;
import com.l2jmobius.gameserver.data.xml.impl.CategoryData;
import com.l2jmobius.gameserver.data.xml.impl.ClassListData;
import com.l2jmobius.gameserver.data.xml.impl.SkillData;
@@ -63,7 +63,7 @@ import ai.AbstractNpcAI;
* Class Master AI.
* @author Nik
*/
public final class ClassMaster extends AbstractNpcAI implements IGameXmlReader
public final class ClassMaster extends AbstractNpcAI implements IXmlReader
{
// NPCs
private static final List<Integer> CLASS_MASTERS = new ArrayList<>();

View File

@@ -26,7 +26,7 @@ import org.w3c.dom.Document;
import org.w3c.dom.Node;
import com.l2jmobius.Config;
import com.l2jmobius.commons.util.IGameXmlReader;
import com.l2jmobius.commons.util.IXmlReader;
import com.l2jmobius.gameserver.enums.CategoryType;
import com.l2jmobius.gameserver.enums.MailType;
import com.l2jmobius.gameserver.instancemanager.MailManager;
@@ -62,7 +62,7 @@ import ai.AbstractNpcAI;
* Mentor Guide AI.
* @author Gnacik, UnAfraid
*/
public final class MentorGuide extends AbstractNpcAI implements IGameXmlReader
public final class MentorGuide extends AbstractNpcAI implements IXmlReader
{
private static final Logger LOGGER = Logger.getLogger(MentorGuide.class.getName());

View File

@@ -27,13 +27,13 @@ import org.w3c.dom.Document;
import org.w3c.dom.NamedNodeMap;
import org.w3c.dom.Node;
import com.l2jmobius.commons.util.IGameXmlReader;
import com.l2jmobius.commons.util.IXmlReader;
import com.l2jmobius.gameserver.model.StatsSet;
/**
* @author UnAfraid
*/
class NpcBuffersData implements IGameXmlReader
class NpcBuffersData implements IXmlReader
{
private static final Logger LOGGER = Logger.getLogger(NpcBuffersData.class.getName());

View File

@@ -320,7 +320,7 @@ public class AdminQuest implements IAdminCommandHandler
{
sb.append("<a action=\"bypass -h admin_script_dir " + c + "\">" + c + "</a><br1>");
}
else if (c.endsWith(".java") || c.endsWith(".py"))
else if (c.endsWith(".java"))
{
sb.append("<a action=\"bypass -h admin_script_load " + c + "\"><font color=\"LEVEL\">" + c + "</font></a><br1>");
}
@@ -352,7 +352,7 @@ public class AdminQuest implements IAdminCommandHandler
{
sb.append("<a action=\"bypass -h admin_script_dir " + currentPath + "/" + c + "\">" + (questReducedNames ? getQuestName(c) : c) + "</a><br1>");
}
else if (c.endsWith(".java") || c.endsWith(".py"))
else if (c.endsWith(".java"))
{
sb.append("<a action=\"bypass -h admin_script_load " + currentPath + "/" + c + "\"><font color=\"LEVEL\">" + c + "</font></a><br1>");
}

View File

@@ -222,7 +222,7 @@ public class AdminReload implements IAdminCommandHandler
{
try
{
ScriptEngineManager.getInstance().executeEffectMasterHandler();
ScriptEngineManager.getInstance().executeScript(ScriptEngineManager.EFFECT_MASTER_HANDLER_FILE);
AdminData.getInstance().broadcastMessageToGMs(activeChar.getName() + ": Reloaded effect master handler.");
}
catch (Exception e)
@@ -236,7 +236,7 @@ public class AdminReload implements IAdminCommandHandler
{
try
{
ScriptEngineManager.getInstance().executeMasterHandler();
ScriptEngineManager.getInstance().executeScript(ScriptEngineManager.MASTER_HANDLER_FILE);
AdminData.getInstance().broadcastMessageToGMs(activeChar.getName() + ": Reloaded master handler.");
}
catch (Exception e)

View File

@@ -182,7 +182,7 @@ public class Reload implements ITelnetCommand
{
try
{
ScriptEngineManager.getInstance().executeEffectMasterHandler();
ScriptEngineManager.getInstance().executeScript(ScriptEngineManager.EFFECT_MASTER_HANDLER_FILE);
return AdminData.getInstance().broadcastMessageToGMs("Telnet Admin: Reloaded effect master handler.");
}
catch (Exception e)
@@ -195,7 +195,7 @@ public class Reload implements ITelnetCommand
{
try
{
ScriptEngineManager.getInstance().executeMasterHandler();
ScriptEngineManager.getInstance().executeScript(ScriptEngineManager.MASTER_HANDLER_FILE);
return AdminData.getInstance().broadcastMessageToGMs("Telnet Admin: Reloaded master handler.");
}
catch (Exception e)

View File

@@ -54,7 +54,7 @@ import org.w3c.dom.Document;
import org.w3c.dom.NamedNodeMap;
import org.w3c.dom.Node;
import com.l2jmobius.commons.util.IGameXmlReader;
import com.l2jmobius.commons.util.IXmlReader;
import com.l2jmobius.commons.util.PropertiesParser;
import com.l2jmobius.commons.util.StringUtil;
import com.l2jmobius.gameserver.enums.ChatType;
@@ -3114,7 +3114,7 @@ public final class Config
return result;
}
private static class IPConfigData implements IGameXmlReader
private static class IPConfigData implements IXmlReader
{
private static final List<String> _subnets = new ArrayList<>(5);
private static final List<String> _hosts = new ArrayList<>(5);

View File

@@ -1,118 +0,0 @@
/*
* 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 <http://www.gnu.org/licenses/>.
*/
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<String, Object> parseParameters(Node n)
{
final Map<String, Object> 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<MinionHolder> 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);
}
}

View File

@@ -18,8 +18,13 @@ package com.l2jmobius.commons.util;
import java.io.File;
import java.io.FileFilter;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.concurrent.CopyOnWriteArrayList;
import java.util.concurrent.ScheduledFuture;
import java.util.function.Consumer;
import java.util.function.Predicate;
import java.util.logging.Level;
@@ -35,7 +40,12 @@ import org.w3c.dom.NodeList;
import org.xml.sax.ErrorHandler;
import org.xml.sax.SAXParseException;
import com.l2jmobius.Config;
import com.l2jmobius.commons.concurrent.ThreadPool;
import com.l2jmobius.commons.util.file.filter.XMLFilter;
import com.l2jmobius.gameserver.model.Location;
import com.l2jmobius.gameserver.model.holders.MinionHolder;
import com.l2jmobius.gameserver.model.holders.SkillHolder;
/**
* Interface for XML parsers.
@@ -56,6 +66,15 @@ public interface IXmlReader
*/
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.<br>
* If the file was successfully parsed, call {@link #parseDocument(Document, File)} for the parsed document.<br>
@@ -121,6 +140,17 @@ public interface IXmlReader
return parseDirectory(file, 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 parseDatapackDirectory(String path, boolean recursive)
{
return parseDirectory(new File(Config.DATAPACK_ROOT, 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.
@@ -135,6 +165,7 @@ public interface IXmlReader
return false;
}
final List<ScheduledFuture<?>> jobs = new CopyOnWriteArrayList<>();
final File[] listOfFiles = dir.listFiles();
for (File f : listOfFiles)
{
@@ -144,9 +175,23 @@ public interface IXmlReader
}
else if (getCurrentFileFilter().accept(f))
{
parseFile(f);
jobs.add(ThreadPool.schedule(() ->
{
parseFile(f);
}, 0));
}
}
while (!jobs.isEmpty())
{
for (ScheduledFuture<?> job : jobs)
{
if ((job == null) || job.isDone() || job.isCancelled())
{
jobs.remove(job);
}
}
}
return true;
}
@@ -531,6 +576,16 @@ public interface IXmlReader
return parseString(attrs.getNamedItem(name), defaultValue);
}
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);
}
/**
* Parses an enumerated value.
* @param <T> the enumerated type
@@ -612,6 +667,56 @@ public interface IXmlReader
return map;
}
/**
* @param n
* @return a map of parameters
*/
default Map<String, Object> parseParameters(Node n)
{
final Map<String, Object> 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<MinionHolder> 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;
}
/**
* Executes action for each child of node
* @param node

View File

@@ -362,7 +362,7 @@ public class GameServer
try
{
LOGGER.info(getClass().getSimpleName() + ": Loading server scripts:");
ScriptEngineManager.getInstance().executeMasterHandler();
ScriptEngineManager.getInstance().executeScript(ScriptEngineManager.MASTER_HANDLER_FILE);
ScriptEngineManager.getInstance().executeScriptList();
}
catch (Exception e)

View File

@@ -25,13 +25,13 @@ import org.w3c.dom.Document;
import org.w3c.dom.NamedNodeMap;
import org.w3c.dom.Node;
import com.l2jmobius.commons.util.IGameXmlReader;
import com.l2jmobius.commons.util.IXmlReader;
import com.l2jmobius.gameserver.model.holders.RangeAbilityPointsHolder;
/**
* @author UnAfraid
*/
public final class AbilityPointsData implements IGameXmlReader
public final class AbilityPointsData implements IXmlReader
{
private static final Logger LOGGER = Logger.getLogger(AbilityPointsData.class.getName());
private final List<RangeAbilityPointsHolder> _points = new ArrayList<>();

Some files were not shown because too many files have changed in this diff Show More