Replaced static object CSV data with aCis free version XML data.
This commit is contained in:
@@ -51,7 +51,6 @@ import org.l2jmobius.gameserver.datatables.csv.ExtractableItemsData;
|
||||
import org.l2jmobius.gameserver.datatables.csv.MapRegionTable;
|
||||
import org.l2jmobius.gameserver.datatables.csv.NpcWalkerRoutesTable;
|
||||
import org.l2jmobius.gameserver.datatables.csv.RecipeTable;
|
||||
import org.l2jmobius.gameserver.datatables.csv.StaticObjects;
|
||||
import org.l2jmobius.gameserver.datatables.csv.SummonItemsData;
|
||||
import org.l2jmobius.gameserver.datatables.sql.ArmorSetsTable;
|
||||
import org.l2jmobius.gameserver.datatables.sql.CharNameTable;
|
||||
@@ -73,6 +72,7 @@ import org.l2jmobius.gameserver.datatables.xml.ExperienceData;
|
||||
import org.l2jmobius.gameserver.datatables.xml.FenceData;
|
||||
import org.l2jmobius.gameserver.datatables.xml.FishData;
|
||||
import org.l2jmobius.gameserver.datatables.xml.HennaData;
|
||||
import org.l2jmobius.gameserver.datatables.xml.StaticObjectData;
|
||||
import org.l2jmobius.gameserver.datatables.xml.ZoneData;
|
||||
import org.l2jmobius.gameserver.geoengine.GeoEngine;
|
||||
import org.l2jmobius.gameserver.handler.AdminCommandHandler;
|
||||
@@ -210,7 +210,7 @@ public class GameServer
|
||||
Announcements.getInstance();
|
||||
AutoAnnouncementHandler.getInstance();
|
||||
GlobalVariablesManager.getInstance();
|
||||
StaticObjects.getInstance();
|
||||
StaticObjectData.getInstance();
|
||||
TeleportLocationTable.getInstance();
|
||||
PartyMatchWaitingList.getInstance();
|
||||
PartyMatchRoomList.getInstance();
|
||||
|
@@ -1,154 +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.LineNumberReader;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.StringTokenizer;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import org.l2jmobius.Config;
|
||||
import org.l2jmobius.gameserver.idfactory.IdFactory;
|
||||
import org.l2jmobius.gameserver.model.actor.instance.StaticObjectInstance;
|
||||
|
||||
public class StaticObjects
|
||||
{
|
||||
private static final Logger LOGGER = Logger.getLogger(StaticObjects.class.getName());
|
||||
|
||||
private final Map<Integer, StaticObjectInstance> _staticObjects;
|
||||
|
||||
public StaticObjects()
|
||||
{
|
||||
_staticObjects = new HashMap<>();
|
||||
parseData();
|
||||
LOGGER.info("StaticObject: Loaded " + _staticObjects.size() + " StaticObject Templates.");
|
||||
}
|
||||
|
||||
private void parseData()
|
||||
{
|
||||
FileReader reader = null;
|
||||
BufferedReader buff = null;
|
||||
LineNumberReader lnr = null;
|
||||
|
||||
try
|
||||
{
|
||||
final File doorData = new File(Config.DATAPACK_ROOT, "data/csv/staticobjects.csv");
|
||||
|
||||
reader = new FileReader(doorData);
|
||||
buff = new BufferedReader(reader);
|
||||
lnr = new LineNumberReader(buff);
|
||||
|
||||
String line = null;
|
||||
while ((line = lnr.readLine()) != null)
|
||||
{
|
||||
if ((line.trim().length() == 0) || line.startsWith("#"))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
final StaticObjectInstance obj = parse(line);
|
||||
_staticObjects.put(obj.getStaticObjectId(), obj);
|
||||
}
|
||||
}
|
||||
catch (FileNotFoundException e)
|
||||
{
|
||||
LOGGER.warning("staticobjects.csv is missing in data csv folder");
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
LOGGER.warning("Error while creating StaticObjects table " + e);
|
||||
}
|
||||
finally
|
||||
{
|
||||
if (lnr != null)
|
||||
{
|
||||
try
|
||||
{
|
||||
lnr.close();
|
||||
}
|
||||
catch (Exception e1)
|
||||
{
|
||||
LOGGER.warning("Problem with StaticObjects: " + e1.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
if (buff != null)
|
||||
{
|
||||
try
|
||||
{
|
||||
buff.close();
|
||||
}
|
||||
catch (Exception e1)
|
||||
{
|
||||
LOGGER.warning("Problem with StaticObjects: " + e1.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
if (reader != null)
|
||||
{
|
||||
try
|
||||
{
|
||||
reader.close();
|
||||
}
|
||||
catch (Exception e1)
|
||||
{
|
||||
LOGGER.warning("Problem with StaticObjects: " + e1.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static StaticObjectInstance parse(String line)
|
||||
{
|
||||
final StringTokenizer st = new StringTokenizer(line, ";");
|
||||
|
||||
st.nextToken(); // Pass over static object name (not used in server)
|
||||
|
||||
final int id = Integer.parseInt(st.nextToken());
|
||||
final int x = Integer.parseInt(st.nextToken());
|
||||
final int y = Integer.parseInt(st.nextToken());
|
||||
final int z = Integer.parseInt(st.nextToken());
|
||||
final int type = Integer.parseInt(st.nextToken());
|
||||
final String texture = st.nextToken();
|
||||
final int map_x = Integer.parseInt(st.nextToken());
|
||||
final int map_y = Integer.parseInt(st.nextToken());
|
||||
|
||||
final StaticObjectInstance obj = new StaticObjectInstance(IdFactory.getInstance().getNextId());
|
||||
obj.setType(type);
|
||||
obj.setStaticObjectId(id);
|
||||
obj.setXYZ(x, y, z);
|
||||
obj.setMap(texture, map_x, map_y);
|
||||
obj.spawnMe();
|
||||
|
||||
return obj;
|
||||
}
|
||||
|
||||
public static StaticObjects getInstance()
|
||||
{
|
||||
return SingletonHolder.INSTANCE;
|
||||
}
|
||||
|
||||
private static class SingletonHolder
|
||||
{
|
||||
protected static final StaticObjects INSTANCE = new StaticObjects();
|
||||
}
|
||||
}
|
@@ -57,6 +57,7 @@ public class FishData implements IXmlReader
|
||||
|
||||
// First element is never read.
|
||||
final Node n = doc.getFirstChild();
|
||||
|
||||
for (Node node = n.getFirstChild(); node != null; node = node.getNextSibling())
|
||||
{
|
||||
if (!"fish".equalsIgnoreCase(node.getNodeName()))
|
||||
|
@@ -0,0 +1,104 @@
|
||||
/*
|
||||
* 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.Collection;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
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.idfactory.IdFactory;
|
||||
import org.l2jmobius.gameserver.model.StatSet;
|
||||
import org.l2jmobius.gameserver.model.actor.instance.StaticObjectInstance;
|
||||
import org.l2jmobius.gameserver.network.serverpackets.StaticObject;
|
||||
|
||||
/**
|
||||
* This class loads, stores and spawns {@link StaticObject}s.
|
||||
*/
|
||||
public class StaticObjectData implements IXmlReader
|
||||
{
|
||||
private final Map<Integer, StaticObjectInstance> _objects = new HashMap<>();
|
||||
|
||||
protected StaticObjectData()
|
||||
{
|
||||
load();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void load()
|
||||
{
|
||||
parseDatapackFile("data/StaticObjects.xml");
|
||||
LOGGER.info(getClass().getSimpleName() + ": Loaded " + _objects.size() + " static objects.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void parseDocument(Document doc, File f)
|
||||
{
|
||||
// StatsSet used to feed informations. Cleaned on every entry.
|
||||
final StatSet set = new StatSet();
|
||||
|
||||
// First element is never read.
|
||||
final Node n = doc.getFirstChild();
|
||||
|
||||
for (Node node = n.getFirstChild(); node != null; node = node.getNextSibling())
|
||||
{
|
||||
if (!"object".equalsIgnoreCase(node.getNodeName()))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
// Parse and feed content.
|
||||
final NamedNodeMap attrs = node.getAttributes();
|
||||
for (int i = 0; i < attrs.getLength(); i++)
|
||||
{
|
||||
final Node attr = attrs.item(i);
|
||||
set.set(attr.getNodeName(), attr.getNodeValue());
|
||||
}
|
||||
|
||||
// Create and spawn the StaticObject instance.
|
||||
final StaticObjectInstance obj = new StaticObjectInstance(IdFactory.getInstance().getNextId());
|
||||
obj.setType(set.getInt("type"));
|
||||
obj.setStaticObjectId(set.getInt("id"));
|
||||
obj.setXYZ(set.getInt("x"), set.getInt("y"), set.getInt("z"));
|
||||
obj.setMap(set.getString("texture"), set.getInt("mapX"), set.getInt("mapY"));
|
||||
obj.spawnMe();
|
||||
|
||||
// Feed the map with new data.
|
||||
_objects.put(obj.getObjectId(), obj);
|
||||
}
|
||||
}
|
||||
|
||||
public Collection<StaticObjectInstance> getStaticObjects()
|
||||
{
|
||||
return _objects.values();
|
||||
}
|
||||
|
||||
public static StaticObjectData getInstance()
|
||||
{
|
||||
return SingletonHolder.INSTANCE;
|
||||
}
|
||||
|
||||
private static class SingletonHolder
|
||||
{
|
||||
protected static final StaticObjectData INSTANCE = new StaticObjectData();
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user