Merged with released L2J-Unity files.

This commit is contained in:
mobiusdev
2016-06-12 01:34:09 +00:00
parent e003e87887
commit 635557f5da
18352 changed files with 3245113 additions and 2892959 deletions

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,75 @@
/*
* 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.gameserver.engines;
import java.io.File;
import org.w3c.dom.Document;
import org.w3c.dom.Node;
import com.l2jmobius.gameserver.model.StatsSet;
import com.l2jmobius.gameserver.model.conditions.Condition;
/**
* A dummy class designed only to parse conditions
* @author UnAfraid
*/
public class DocumentBaseGeneral extends DocumentBase
{
protected DocumentBaseGeneral(File file)
{
super(file);
}
@Override
protected void parseDocument(Document doc)
{
}
@Override
protected StatsSet getStatsSet()
{
return null;
}
@Override
protected String getTableValue(String name)
{
return null;
}
@Override
protected String getTableValue(String name, int idx)
{
return null;
}
public Condition parseCondition(Node n)
{
return super.parseCondition(n, null);
}
public static DocumentBaseGeneral getInstance()
{
return SingletonHolder._instance;
}
private static class SingletonHolder
{
protected static final DocumentBaseGeneral _instance = new DocumentBaseGeneral(null);
}
}

View File

@ -1,132 +1,126 @@
/*
* 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.gameserver.engines;
import java.io.File;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.logging.Logger;
import com.l2jmobius.Config;
import com.l2jmobius.gameserver.datatables.SkillData;
import com.l2jmobius.gameserver.engines.items.DocumentItem;
import com.l2jmobius.gameserver.engines.skills.DocumentSkill;
import com.l2jmobius.gameserver.model.items.L2Item;
import com.l2jmobius.gameserver.model.skills.Skill;
import com.l2jmobius.util.file.filter.XMLFilter;
/**
* @author mkizub
*/
public class DocumentEngine
{
private static final Logger _log = Logger.getLogger(DocumentEngine.class.getName());
private final List<File> _itemFiles = new ArrayList<>();
private final List<File> _skillFiles = new ArrayList<>();
public static DocumentEngine getInstance()
{
return SingletonHolder._instance;
}
protected DocumentEngine()
{
hashFiles("stats/items", _itemFiles);
if (Config.CUSTOM_ITEMS_LOAD)
{
hashFiles("stats/items/custom", _itemFiles);
}
hashFiles("stats/skills", _skillFiles);
if (Config.CUSTOM_SKILLS_LOAD)
{
hashFiles("stats/skills/custom", _skillFiles);
}
}
private void hashFiles(String dirname, List<File> hash)
{
final File dir = new File(Config.DATAPACK_ROOT, dirname);
if (!dir.exists())
{
_log.warning("Dir " + dir.getAbsolutePath() + " not exists");
return;
}
final File[] files = dir.listFiles(new XMLFilter());
if (files != null)
{
for (File f : files)
{
hash.add(f);
}
}
}
public List<Skill> loadSkills(File file)
{
if (file == null)
{
_log.warning("Skill file not found.");
return null;
}
final DocumentSkill doc = new DocumentSkill(file);
doc.parse();
return doc.getSkills();
}
public void loadAllSkills(Map<Integer, Skill> allSkills)
{
int count = 0;
for (File file : _skillFiles)
{
final List<Skill> s = loadSkills(file);
if (s == null)
{
continue;
}
for (Skill skill : s)
{
allSkills.put(SkillData.getSkillHashCode(skill), skill);
count++;
}
}
_log.info(getClass().getSimpleName() + ": Loaded " + count + " Skill templates from XML files.");
}
/**
* Return created items
* @return List of {@link L2Item}
*/
public List<L2Item> loadItems()
{
final List<L2Item> list = new ArrayList<>();
for (File f : _itemFiles)
{
final DocumentItem document = new DocumentItem(f);
document.parse();
list.addAll(document.getItemList());
}
return list;
}
private static class SingletonHolder
{
protected static final DocumentEngine _instance = new DocumentEngine();
}
}
/*
* 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.gameserver.engines;
import java.io.File;
import java.util.Collections;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.logging.Logger;
import com.l2jmobius.Config;
import com.l2jmobius.commons.util.file.filter.XMLFilter;
import com.l2jmobius.gameserver.data.xml.impl.SkillData;
import com.l2jmobius.gameserver.engines.items.DocumentItem;
import com.l2jmobius.gameserver.model.items.L2Item;
import com.l2jmobius.gameserver.model.skills.Skill;
/**
* @author mkizub
*/
public class DocumentEngine
{
private static final Logger LOGGER = Logger.getLogger(DocumentEngine.class.getName());
private final List<File> _itemFiles = new LinkedList<>();
private final List<File> _skillFiles = new LinkedList<>();
public static DocumentEngine getInstance()
{
return SingletonHolder._instance;
}
protected DocumentEngine()
{
hashFiles("data/stats/items", _itemFiles);
if (Config.CUSTOM_ITEMS_LOAD)
{
hashFiles("data/stats/items/custom", _itemFiles);
}
hashFiles("data/stats/skills", _skillFiles);
if (Config.CUSTOM_SKILLS_LOAD)
{
hashFiles("data/stats/skills/custom", _skillFiles);
}
}
private void hashFiles(String dirname, List<File> hash)
{
final File dir = new File(Config.DATAPACK_ROOT, dirname);
if (!dir.exists())
{
LOGGER.warning("Dir " + dir.getAbsolutePath() + " not exists");
return;
}
final File[] files = dir.listFiles(new XMLFilter());
for (File f : files)
{
hash.add(f);
}
}
public List<Skill> loadSkills(File file)
{
if (file == null)
{
LOGGER.warning("Skill file not found.");
return null;
}
return Collections.emptyList();
}
public void loadAllSkills(Map<Integer, Skill> allSkills)
{
int count = 0;
for (File file : _skillFiles)
{
final List<Skill> s = loadSkills(file);
if (s == null)
{
continue;
}
for (Skill skill : s)
{
allSkills.put(SkillData.getSkillHashCode(skill), skill);
count++;
}
}
LOGGER.info("Loaded " + count + " Skill templates from XML files.");
}
/**
* Return created items
* @return List of {@link L2Item}
*/
public List<L2Item> loadItems()
{
final List<L2Item> list = new LinkedList<>();
for (File f : _itemFiles)
{
final DocumentItem document = new DocumentItem(f);
document.parse();
list.addAll(document.getItemList());
}
return list;
}
private static class SingletonHolder
{
protected static final DocumentEngine _instance = new DocumentEngine();
}
}

View File

@ -1,178 +1,254 @@
/*
* 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.gameserver.engines.items;
import java.io.File;
import java.lang.reflect.InvocationTargetException;
import java.util.ArrayList;
import java.util.List;
import java.util.logging.Level;
import org.w3c.dom.Document;
import org.w3c.dom.Node;
import com.l2jmobius.gameserver.engines.DocumentBase;
import com.l2jmobius.gameserver.model.StatsSet;
import com.l2jmobius.gameserver.model.conditions.Condition;
import com.l2jmobius.gameserver.model.items.L2Item;
/**
* @author mkizub, JIV
*/
public final class DocumentItem extends DocumentBase
{
private Item _currentItem = null;
private final List<L2Item> _itemsInFile = new ArrayList<>();
/**
* @param file
*/
public DocumentItem(File file)
{
super(file);
}
@Override
protected StatsSet getStatsSet()
{
return _currentItem.set;
}
@Override
protected String getTableValue(String name)
{
return _tables.get(name)[_currentItem.currentLevel];
}
@Override
protected String getTableValue(String name, int idx)
{
return _tables.get(name)[idx - 1];
}
@Override
protected void parseDocument(Document doc)
{
for (Node n = doc.getFirstChild(); n != null; n = n.getNextSibling())
{
if ("list".equalsIgnoreCase(n.getNodeName()))
{
for (Node d = n.getFirstChild(); d != null; d = d.getNextSibling())
{
if ("item".equalsIgnoreCase(d.getNodeName()))
{
try
{
_currentItem = new Item();
parseItem(d);
_itemsInFile.add(_currentItem.item);
resetTable();
}
catch (Exception e)
{
_log.log(Level.WARNING, "Cannot create item " + _currentItem.id, e);
}
}
}
}
}
}
protected void parseItem(Node n) throws InvocationTargetException
{
final int itemId = Integer.parseInt(n.getAttributes().getNamedItem("id").getNodeValue());
final String className = n.getAttributes().getNamedItem("type").getNodeValue();
final String itemName = n.getAttributes().getNamedItem("name").getNodeValue();
final String additionalName = n.getAttributes().getNamedItem("additionalName") != null ? n.getAttributes().getNamedItem("additionalName").getNodeValue() : null;
_currentItem.id = itemId;
_currentItem.name = itemName;
_currentItem.type = className;
_currentItem.set = new StatsSet();
_currentItem.set.set("item_id", itemId);
_currentItem.set.set("name", itemName);
_currentItem.set.set("additionalName", additionalName);
final Node first = n.getFirstChild();
for (n = first; n != null; n = n.getNextSibling())
{
if ("table".equalsIgnoreCase(n.getNodeName()))
{
if (_currentItem.item != null)
{
throw new IllegalStateException("Item created but table node found! Item " + itemId);
}
parseTable(n);
}
else if ("set".equalsIgnoreCase(n.getNodeName()))
{
if (_currentItem.item != null)
{
throw new IllegalStateException("Item created but set node found! Item " + itemId);
}
parseBeanSet(n, _currentItem.set, 1);
}
else if ("for".equalsIgnoreCase(n.getNodeName()))
{
makeItem();
parseTemplate(n, _currentItem.item);
}
else if ("cond".equalsIgnoreCase(n.getNodeName()))
{
makeItem();
final Condition condition = parseCondition(n.getFirstChild(), _currentItem.item);
final Node msg = n.getAttributes().getNamedItem("msg");
final Node msgId = n.getAttributes().getNamedItem("msgId");
if ((condition != null) && (msg != null))
{
condition.setMessage(msg.getNodeValue());
}
else if ((condition != null) && (msgId != null))
{
condition.setMessageId(Integer.decode(getValue(msgId.getNodeValue(), null)));
if ((n.getAttributes().getNamedItem("addName") != null) && (Integer.decode(getValue(msgId.getNodeValue(), null)) > 0))
{
condition.addName();
}
}
_currentItem.item.attach(condition);
}
}
// bah! in this point item doesn't have to be still created
makeItem();
}
private void makeItem() throws InvocationTargetException
{
if (_currentItem.item != null)
{
return; // item is already created
}
try
{
_currentItem.item = (L2Item) Class.forName("com.l2jmobius.gameserver.model.items.L2" + _currentItem.type).getConstructor(StatsSet.class).newInstance(_currentItem.set);
}
catch (Exception e)
{
throw new InvocationTargetException(e);
}
}
public List<L2Item> getItemList()
{
return _itemsInFile;
}
}
/*
* 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.gameserver.engines.items;
import java.io.File;
import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationTargetException;
import java.util.LinkedList;
import java.util.List;
import java.util.logging.Level;
import org.w3c.dom.Document;
import org.w3c.dom.Node;
import com.l2jmobius.commons.util.IGameXmlReader;
import com.l2jmobius.gameserver.engines.DocumentBase;
import com.l2jmobius.gameserver.enums.ItemSkillType;
import com.l2jmobius.gameserver.model.L2ExtractableProduct;
import com.l2jmobius.gameserver.model.StatsSet;
import com.l2jmobius.gameserver.model.conditions.Condition;
import com.l2jmobius.gameserver.model.holders.ItemChanceHolder;
import com.l2jmobius.gameserver.model.holders.ItemSkillHolder;
import com.l2jmobius.gameserver.model.items.L2Item;
import com.l2jmobius.gameserver.model.stats.Stats;
import com.l2jmobius.gameserver.model.stats.functions.FuncTemplate;
/**
* @author mkizub, JIV
*/
public final class DocumentItem extends DocumentBase implements IGameXmlReader
{
private Item _currentItem = null;
private final List<L2Item> _itemsInFile = new LinkedList<>();
/**
* @param file
*/
public DocumentItem(File file)
{
super(file);
}
@Override
protected StatsSet getStatsSet()
{
return _currentItem.set;
}
@Override
protected String getTableValue(String name)
{
return _tables.get(name)[_currentItem.currentLevel];
}
@Override
protected String getTableValue(String name, int idx)
{
return _tables.get(name)[idx - 1];
}
@Override
protected void parseDocument(Document doc)
{
for (Node n = doc.getFirstChild(); n != null; n = n.getNextSibling())
{
if ("list".equalsIgnoreCase(n.getNodeName()))
{
for (Node d = n.getFirstChild(); d != null; d = d.getNextSibling())
{
if ("item".equalsIgnoreCase(d.getNodeName()))
{
try
{
_currentItem = new Item();
parseItem(d);
_itemsInFile.add(_currentItem.item);
resetTable();
}
catch (Exception e)
{
_log.log(Level.WARNING, "Cannot create item " + _currentItem.id, e);
}
}
}
}
}
}
protected void parseItem(Node n) throws InvocationTargetException
{
final int itemId = Integer.parseInt(n.getAttributes().getNamedItem("id").getNodeValue());
final String className = n.getAttributes().getNamedItem("type").getNodeValue();
final String itemName = n.getAttributes().getNamedItem("name").getNodeValue();
_currentItem.id = itemId;
_currentItem.name = itemName;
_currentItem.type = className;
_currentItem.set = new StatsSet();
_currentItem.set.set("item_id", itemId);
_currentItem.set.set("name", itemName);
final Node first = n.getFirstChild();
for (n = first; n != null; n = n.getNextSibling())
{
if ("table".equalsIgnoreCase(n.getNodeName()))
{
if (_currentItem.item != null)
{
throw new IllegalStateException("Item created but table node found! Item " + itemId);
}
parseTable(n);
}
else if ("set".equalsIgnoreCase(n.getNodeName()))
{
if (_currentItem.item != null)
{
throw new IllegalStateException("Item created but set node found! Item " + itemId);
}
parseBeanSet(n, _currentItem.set, 1);
}
else if ("stats".equalsIgnoreCase(n.getNodeName()))
{
makeItem();
for (Node b = n.getFirstChild(); b != null; b = b.getNextSibling())
{
if ("stat".equalsIgnoreCase(b.getNodeName()))
{
final Stats type = Stats.valueOfXml(b.getAttributes().getNamedItem("type").getNodeValue());
final double value = Double.valueOf(b.getTextContent());
_currentItem.item.addFunctionTemplate(new FuncTemplate(null, null, "add", 0x00, type, value));
}
}
}
else if ("skills".equalsIgnoreCase(n.getNodeName()))
{
makeItem();
for (Node b = n.getFirstChild(); b != null; b = b.getNextSibling())
{
if ("skill".equalsIgnoreCase(b.getNodeName()))
{
final int id = parseInteger(b.getAttributes(), "id");
final int level = parseInteger(b.getAttributes(), "level");
final ItemSkillType type = parseEnum(b.getAttributes(), ItemSkillType.class, "type", ItemSkillType.NORMAL);
final int chance = parseInteger(b.getAttributes(), "type_chance", 0);
final int value = parseInteger(b.getAttributes(), "type_value", 0);
_currentItem.item.addSkill(new ItemSkillHolder(id, level, type, chance, value));
}
}
}
else if ("capsuled_items".equalsIgnoreCase(n.getNodeName()))
{
makeItem();
for (Node b = n.getFirstChild(); b != null; b = b.getNextSibling())
{
if ("item".equals(b.getNodeName()))
{
final int id = parseInteger(b.getAttributes(), "id");
final int min = parseInteger(b.getAttributes(), "min");
final int max = parseInteger(b.getAttributes(), "max");
final double chance = parseDouble(b.getAttributes(), "chance");
_currentItem.item.addCapsuledItem(new L2ExtractableProduct(id, min, max, chance));
}
}
}
else if ("createItems".equalsIgnoreCase(n.getNodeName()))
{
makeItem();
for (Node b = n.getFirstChild(); b != null; b = b.getNextSibling())
{
if ("item".equals(b.getNodeName()))
{
final int id = parseInteger(b.getAttributes(), "id");
final int count = parseInteger(b.getAttributes(), "count");
final double chance = parseDouble(b.getAttributes(), "chance");
_currentItem.item.addCreateItem(new ItemChanceHolder(id, chance, count));
}
}
}
else if ("cond".equalsIgnoreCase(n.getNodeName()))
{
makeItem();
final Condition condition = parseCondition(n.getFirstChild(), _currentItem.item);
final Node msg = n.getAttributes().getNamedItem("msg");
final Node msgId = n.getAttributes().getNamedItem("msgId");
if ((condition != null) && (msg != null))
{
condition.setMessage(msg.getNodeValue());
}
else if ((condition != null) && (msgId != null))
{
condition.setMessageId(Integer.decode(getValue(msgId.getNodeValue(), null)));
final Node addName = n.getAttributes().getNamedItem("addName");
if ((addName != null) && (Integer.decode(getValue(msgId.getNodeValue(), null)) > 0))
{
condition.addName();
}
}
_currentItem.item.attachCondition(condition);
}
}
// bah! in this point item doesn't have to be still created
makeItem();
}
private void makeItem() throws InvocationTargetException
{
// If item exists just reload the data.
if (_currentItem.item != null)
{
_currentItem.item.set(_currentItem.set);
return;
}
try
{
final Constructor<?> itemClass = Class.forName("com.l2jmobius.gameserver.model.items.L2" + _currentItem.type).getConstructor(StatsSet.class);
_currentItem.item = (L2Item) itemClass.newInstance(_currentItem.set);
}
catch (Exception e)
{
throw new InvocationTargetException(e);
}
}
public List<L2Item> getItemList()
{
return _itemsInFile;
}
@Override
public void load()
{
}
@Override
public void parseDocument(Document doc, File f)
{
}
}

View File

@ -1,31 +1,30 @@
/*
* 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.gameserver.engines.items;
import com.l2jmobius.gameserver.model.StatsSet;
import com.l2jmobius.gameserver.model.items.L2Item;
public class Item
{
public int id;
public String type;
public String name;
public StatsSet set;
public int currentLevel;
public L2Item item;
public L2Item isBlessedItem;
}
/*
* 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.gameserver.engines.items;
import com.l2jmobius.gameserver.model.StatsSet;
import com.l2jmobius.gameserver.model.items.L2Item;
public class Item
{
public int id;
public String type;
public String name;
public StatsSet set;
public int currentLevel;
public L2Item item;
}