Walker route data moved from CSV to XML.
This commit is contained in:
@@ -47,7 +47,6 @@ import org.l2jmobius.gameserver.datatables.NobleSkillTable;
|
||||
import org.l2jmobius.gameserver.datatables.OfflineTradeTable;
|
||||
import org.l2jmobius.gameserver.datatables.SchemeBufferTable;
|
||||
import org.l2jmobius.gameserver.datatables.SkillTable;
|
||||
import org.l2jmobius.gameserver.datatables.csv.NpcWalkerRouteTable;
|
||||
import org.l2jmobius.gameserver.datatables.sql.CharNameTable;
|
||||
import org.l2jmobius.gameserver.datatables.sql.CharTemplateTable;
|
||||
import org.l2jmobius.gameserver.datatables.sql.ClanTable;
|
||||
@@ -74,6 +73,7 @@ import org.l2jmobius.gameserver.datatables.xml.MapRegionData;
|
||||
import org.l2jmobius.gameserver.datatables.xml.RecipeData;
|
||||
import org.l2jmobius.gameserver.datatables.xml.StaticObjectData;
|
||||
import org.l2jmobius.gameserver.datatables.xml.SummonItemData;
|
||||
import org.l2jmobius.gameserver.datatables.xml.WalkerRouteData;
|
||||
import org.l2jmobius.gameserver.datatables.xml.ZoneData;
|
||||
import org.l2jmobius.gameserver.geoengine.GeoEngine;
|
||||
import org.l2jmobius.gameserver.handler.AdminCommandHandler;
|
||||
@@ -245,7 +245,7 @@ public class GameServer
|
||||
|
||||
Util.printSection("Npc");
|
||||
SchemeBufferTable.getInstance();
|
||||
NpcWalkerRouteTable.getInstance().load();
|
||||
WalkerRouteData.getInstance();
|
||||
if (!NpcTable.getInstance().isInitialized())
|
||||
{
|
||||
LOGGER.info("Could not find the extracted files. Please Check Your Data.");
|
||||
|
@@ -20,7 +20,7 @@ import java.util.List;
|
||||
|
||||
import org.l2jmobius.Config;
|
||||
import org.l2jmobius.commons.concurrent.ThreadPool;
|
||||
import org.l2jmobius.gameserver.datatables.csv.NpcWalkerRouteTable;
|
||||
import org.l2jmobius.gameserver.datatables.xml.WalkerRouteData;
|
||||
import org.l2jmobius.gameserver.model.Location;
|
||||
import org.l2jmobius.gameserver.model.NpcWalkerNode;
|
||||
import org.l2jmobius.gameserver.model.actor.Creature;
|
||||
@@ -52,7 +52,7 @@ public class NpcWalkerAI extends CreatureAI implements Runnable
|
||||
/**
|
||||
* route of the current npc
|
||||
*/
|
||||
private final List<NpcWalkerNode> _route = NpcWalkerRouteTable.getInstance().getRouteForNpc(getActor().getNpcId());
|
||||
private final List<NpcWalkerNode> _route = WalkerRouteData.getInstance().getRouteForNpc(getActor().getNpcId());
|
||||
|
||||
/**
|
||||
* current node
|
||||
@@ -134,8 +134,7 @@ public class NpcWalkerAI extends CreatureAI implements Runnable
|
||||
if ((getActor().getX() == destinationX) && (getActor().getY() == destinationY) && (getActor().getZ() == destinationZ))
|
||||
{
|
||||
final String chat = _route.get(_currentPos).getChatText();
|
||||
|
||||
if ((chat != null) && !chat.equals("NULL"))
|
||||
if ((chat != null) && !chat.isEmpty())
|
||||
{
|
||||
try
|
||||
{
|
||||
|
@@ -1,174 +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 org.l2jmobius.gameserver.datatables.csv;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.File;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.FileReader;
|
||||
import java.io.IOException;
|
||||
import java.io.LineNumberReader;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.StringTokenizer;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import org.l2jmobius.Config;
|
||||
import org.l2jmobius.gameserver.model.NpcWalkerNode;
|
||||
|
||||
/**
|
||||
* Main Table to Load Npc Walkers Routes and Chat SQL Table.<br>
|
||||
* @author Rayan RPG for L2Emu Project
|
||||
* @since 927
|
||||
*/
|
||||
public class NpcWalkerRouteTable
|
||||
{
|
||||
protected static final Logger LOGGER = Logger.getLogger(NpcWalkerRouteTable.class.getName());
|
||||
|
||||
private List<NpcWalkerNode> _routes;
|
||||
|
||||
private NpcWalkerRouteTable()
|
||||
{
|
||||
}
|
||||
|
||||
public void load()
|
||||
{
|
||||
_routes = new ArrayList<>();
|
||||
|
||||
FileReader reader = null;
|
||||
BufferedReader buff = null;
|
||||
LineNumberReader lnr = null;
|
||||
|
||||
try
|
||||
{
|
||||
final File fileData = new File(Config.DATAPACK_ROOT + "/data/csv/walker_routes.csv");
|
||||
|
||||
reader = new FileReader(fileData);
|
||||
buff = new BufferedReader(reader);
|
||||
lnr = new LineNumberReader(buff);
|
||||
|
||||
NpcWalkerNode route;
|
||||
String line = null;
|
||||
|
||||
// format:
|
||||
// route_id;npc_id;move_point;chatText;move_x;move_y;move_z;delay;running
|
||||
while ((line = lnr.readLine()) != null)
|
||||
{
|
||||
// ignore comments
|
||||
if ((line.trim().length() == 0) || line.startsWith("#"))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
route = new NpcWalkerNode();
|
||||
final StringTokenizer st = new StringTokenizer(line, ";");
|
||||
|
||||
final int route_id = Integer.parseInt(st.nextToken());
|
||||
final int npc_id = Integer.parseInt(st.nextToken());
|
||||
final String move_point = st.nextToken();
|
||||
final String chatText = st.nextToken();
|
||||
final int move_x = Integer.parseInt(st.nextToken());
|
||||
final int move_y = Integer.parseInt(st.nextToken());
|
||||
final int move_z = Integer.parseInt(st.nextToken());
|
||||
final int delay = Integer.parseInt(st.nextToken());
|
||||
final boolean running = Boolean.parseBoolean(st.nextToken());
|
||||
|
||||
route.setRouteId(route_id);
|
||||
route.setNpcId(npc_id);
|
||||
route.setMovePoint(move_point);
|
||||
route.setChatText(chatText);
|
||||
route.setMoveX(move_x);
|
||||
route.setMoveY(move_y);
|
||||
route.setMoveZ(move_z);
|
||||
route.setDelay(delay);
|
||||
route.setRunning(running);
|
||||
|
||||
_routes.add(route);
|
||||
}
|
||||
|
||||
LOGGER.info("WalkerRoutesTable: Loaded " + _routes.size() + " Npc Walker Routes.");
|
||||
}
|
||||
catch (FileNotFoundException e)
|
||||
{
|
||||
LOGGER.warning("walker_routes.csv is missing in data folder");
|
||||
}
|
||||
catch (IOException e0)
|
||||
{
|
||||
LOGGER.warning("Error while creating table: " + e0.getMessage() + "\n" + e0);
|
||||
}
|
||||
finally
|
||||
{
|
||||
if (lnr != null)
|
||||
{
|
||||
try
|
||||
{
|
||||
lnr.close();
|
||||
}
|
||||
catch (Exception e1)
|
||||
{
|
||||
LOGGER.warning("Problem with NpcWalkerRoutesTable: " + e1.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
if (buff != null)
|
||||
{
|
||||
try
|
||||
{
|
||||
buff.close();
|
||||
}
|
||||
catch (Exception e1)
|
||||
{
|
||||
LOGGER.warning("Problem with NpcWalkerRoutesTable: " + e1.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
if (reader != null)
|
||||
{
|
||||
try
|
||||
{
|
||||
reader.close();
|
||||
}
|
||||
catch (Exception e1)
|
||||
{
|
||||
LOGGER.warning("Problem with NpcWalkerRoutesTable: " + e1.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public List<NpcWalkerNode> getRouteForNpc(int id)
|
||||
{
|
||||
final List<NpcWalkerNode> result = new ArrayList<>();
|
||||
for (NpcWalkerNode node : _routes)
|
||||
{
|
||||
if (node.getNpcId() == id)
|
||||
{
|
||||
result.add(node);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
public static NpcWalkerRouteTable getInstance()
|
||||
{
|
||||
return SingletonHolder.INSTANCE;
|
||||
}
|
||||
|
||||
private static class SingletonHolder
|
||||
{
|
||||
protected static final NpcWalkerRouteTable INSTANCE = new NpcWalkerRouteTable();
|
||||
}
|
||||
}
|
@@ -0,0 +1,117 @@
|
||||
/*
|
||||
* 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 org.l2jmobius.gameserver.datatables.xml;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import org.w3c.dom.Document;
|
||||
import org.w3c.dom.NamedNodeMap;
|
||||
import org.w3c.dom.Node;
|
||||
|
||||
import org.l2jmobius.commons.util.IXmlReader;
|
||||
import org.l2jmobius.gameserver.model.NpcWalkerNode;
|
||||
import org.l2jmobius.gameserver.model.StatSet;
|
||||
|
||||
/**
|
||||
* @author Mobius
|
||||
*/
|
||||
public class WalkerRouteData implements IXmlReader
|
||||
{
|
||||
protected static final Logger LOGGER = Logger.getLogger(WalkerRouteData.class.getName());
|
||||
|
||||
private final Map<Integer, List<NpcWalkerNode>> _routes = new HashMap<>();
|
||||
|
||||
protected WalkerRouteData()
|
||||
{
|
||||
load();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void load()
|
||||
{
|
||||
_routes.clear();
|
||||
parseDatapackFile("data/WalkerRoutes.xml");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void parseDocument(Document doc, File f)
|
||||
{
|
||||
try
|
||||
{
|
||||
final Node n = doc.getFirstChild();
|
||||
for (Node node = n.getFirstChild(); node != null; node = node.getNextSibling())
|
||||
{
|
||||
if ("route".equalsIgnoreCase(node.getNodeName()))
|
||||
{
|
||||
final List<NpcWalkerNode> points = new ArrayList<>();
|
||||
for (Node b = node.getFirstChild(); b != null; b = b.getNextSibling())
|
||||
{
|
||||
if (!"point".equalsIgnoreCase(b.getNodeName()))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
final StatSet set = new StatSet();
|
||||
final NamedNodeMap attrs = b.getAttributes();
|
||||
for (int i = 0; i < attrs.getLength(); i++)
|
||||
{
|
||||
final Node attr = attrs.item(i);
|
||||
set.set(attr.getNodeName(), attr.getNodeValue());
|
||||
}
|
||||
|
||||
final NpcWalkerNode route = new NpcWalkerNode();
|
||||
route.setMoveX(set.getInt("x"));
|
||||
route.setMoveY(set.getInt("y"));
|
||||
route.setMoveZ(set.getInt("z"));
|
||||
route.setDelay(set.getInt("delay"));
|
||||
route.setRunning(set.getBoolean("run"));
|
||||
route.setChatText(set.getString("chat", null));
|
||||
|
||||
points.add(route);
|
||||
}
|
||||
_routes.put(Integer.parseInt(node.getAttributes().getNamedItem("npcId").getNodeValue()), points);
|
||||
}
|
||||
}
|
||||
|
||||
LOGGER.info(getClass().getSimpleName() + ": Loaded " + _routes.size() + " walker routes.");
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
LOGGER.warning(getClass().getSimpleName() + ": Error while reading walker route data: " + e);
|
||||
}
|
||||
}
|
||||
|
||||
public List<NpcWalkerNode> getRouteForNpc(int id)
|
||||
{
|
||||
return _routes.get(id);
|
||||
}
|
||||
|
||||
public static WalkerRouteData getInstance()
|
||||
{
|
||||
return SingletonHolder.INSTANCE;
|
||||
}
|
||||
|
||||
private static class SingletonHolder
|
||||
{
|
||||
protected static final WalkerRouteData INSTANCE = new WalkerRouteData();
|
||||
}
|
||||
}
|
@@ -24,9 +24,9 @@ import org.l2jmobius.gameserver.TradeController;
|
||||
import org.l2jmobius.gameserver.cache.HtmCache;
|
||||
import org.l2jmobius.gameserver.datatables.ItemTable;
|
||||
import org.l2jmobius.gameserver.datatables.SkillTable;
|
||||
import org.l2jmobius.gameserver.datatables.csv.NpcWalkerRouteTable;
|
||||
import org.l2jmobius.gameserver.datatables.sql.NpcTable;
|
||||
import org.l2jmobius.gameserver.datatables.sql.TeleportLocationTable;
|
||||
import org.l2jmobius.gameserver.datatables.xml.WalkerRouteData;
|
||||
import org.l2jmobius.gameserver.handler.IAdminCommandHandler;
|
||||
import org.l2jmobius.gameserver.instancemanager.DatatablesManager;
|
||||
import org.l2jmobius.gameserver.instancemanager.Manager;
|
||||
@@ -108,7 +108,7 @@ public class AdminReload implements IAdminCommandHandler
|
||||
}
|
||||
else if (type.startsWith("npcwalkers"))
|
||||
{
|
||||
NpcWalkerRouteTable.getInstance().load();
|
||||
WalkerRouteData.getInstance().load();
|
||||
sendReloadPage(activeChar);
|
||||
BuilderUtil.sendSysMessage(activeChar, "All NPC walker routes have been reloaded");
|
||||
}
|
||||
|
@@ -22,42 +22,18 @@ package org.l2jmobius.gameserver.model;
|
||||
*/
|
||||
public class NpcWalkerNode
|
||||
{
|
||||
private int _routeId;
|
||||
private int _npcId;
|
||||
private String _movePoint;
|
||||
private String _chatText;
|
||||
private int _moveX;
|
||||
private int _moveY;
|
||||
private int _moveZ;
|
||||
private int _delay;
|
||||
|
||||
private boolean _running;
|
||||
private String _chatText;
|
||||
|
||||
public void setRunning(boolean value)
|
||||
{
|
||||
_running = value;
|
||||
}
|
||||
|
||||
public void setRouteId(int id)
|
||||
{
|
||||
_routeId = id;
|
||||
}
|
||||
|
||||
public void setNpcId(int id)
|
||||
{
|
||||
_npcId = id;
|
||||
}
|
||||
|
||||
public void setMovePoint(String value)
|
||||
{
|
||||
_movePoint = value;
|
||||
}
|
||||
|
||||
public void setChatText(String value)
|
||||
{
|
||||
_chatText = value;
|
||||
}
|
||||
|
||||
public void setMoveX(int value)
|
||||
{
|
||||
_moveX = value;
|
||||
@@ -78,24 +54,9 @@ public class NpcWalkerNode
|
||||
_delay = value;
|
||||
}
|
||||
|
||||
public int getRouteId()
|
||||
public void setChatText(String value)
|
||||
{
|
||||
return _routeId;
|
||||
}
|
||||
|
||||
public int getNpcId()
|
||||
{
|
||||
return _npcId;
|
||||
}
|
||||
|
||||
public String getMovePoint()
|
||||
{
|
||||
return _movePoint;
|
||||
}
|
||||
|
||||
public String getChatText()
|
||||
{
|
||||
return _chatText;
|
||||
_chatText = value;
|
||||
}
|
||||
|
||||
public int getMoveX()
|
||||
@@ -123,26 +84,8 @@ public class NpcWalkerNode
|
||||
return _running;
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor of NpcWalker.
|
||||
*/
|
||||
public NpcWalkerNode()
|
||||
public String getChatText()
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor of NpcWalker.<BR>
|
||||
* <BR>
|
||||
* @param set The StatSet object to transfert data to the method
|
||||
*/
|
||||
public NpcWalkerNode(StatSet set)
|
||||
{
|
||||
_npcId = set.getInt("npc_id");
|
||||
_movePoint = set.getString("move_point");
|
||||
_chatText = set.getString("chatText");
|
||||
_moveX = set.getInt("move_x");
|
||||
_moveX = set.getInt("move_y");
|
||||
_moveX = set.getInt("move_z");
|
||||
_delay = set.getInt("delay");
|
||||
return _chatText;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user