Sync with L2jUnity (7db5b4f).

This commit is contained in:
MobiusDev
2016-12-04 21:28:20 +00:00
parent 9e1d3569f0
commit b9d3c99cf1
412 changed files with 13806 additions and 10065 deletions

View File

@@ -34,7 +34,7 @@ import com.l2jmobius.gameserver.model.actor.L2Summon;
public class SummonSkillsTable
{
private static Logger LOGGER = Logger.getLogger(SummonSkillsTable.class.getName());
private final Map<Integer, Map<Integer, L2PetSkillLearn>> _skillTrees = new HashMap<>();
private final Map<Integer, Map<Long, L2PetSkillLearn>> _skillTrees = new HashMap<>();
protected SummonSkillsTable()
{
@@ -52,7 +52,7 @@ public class SummonSkillsTable
while (rs.next())
{
final int npcId = rs.getInt("templateId");
Map<Integer, L2PetSkillLearn> skillTree = _skillTrees.get(npcId);
Map<Long, L2PetSkillLearn> skillTree = _skillTrees.get(npcId);
if (skillTree == null)
{
skillTree = new HashMap<>();
@@ -110,9 +110,12 @@ public class SummonSkillsTable
}
break;
}
if ((temp.getMinLevel() <= cha.getLevel()) && (temp.getLevel() > lvl))
else if (temp.getMinLevel() <= cha.getLevel())
{
lvl = temp.getLevel();
if (temp.getLevel() > lvl)
{
lvl = temp.getLevel();
}
}
}
return lvl;

View File

@@ -37,7 +37,7 @@ public class AlchemyData implements IGameXmlReader
{
private static final Logger LOGGER = Logger.getLogger(AlchemyData.class.getName());
private final Map<Integer, AlchemyCraftData> _alchemy = new HashMap<>();
private final Map<Long, AlchemyCraftData> _alchemy = new HashMap<>();
protected AlchemyData()
{
@@ -112,8 +112,7 @@ public class AlchemyData implements IGameXmlReader
}
}
}
final int skillHashCode = SkillData.getSkillHashCode(set.getInt("id"), set.getInt("level"));
_alchemy.put(skillHashCode, alchemyCraft);
_alchemy.put(SkillData.getSkillHashCode(set.getInt("id"), set.getInt("level")), alchemyCraft);
}
}
}

View File

@@ -31,9 +31,10 @@ import com.l2jmobius.gameserver.model.StatsSet;
import com.l2jmobius.gameserver.model.actor.templates.L2CubicTemplate;
import com.l2jmobius.gameserver.model.cubic.CubicSkill;
import com.l2jmobius.gameserver.model.cubic.ICubicConditionHolder;
import com.l2jmobius.gameserver.model.cubic.conditions.GeneralCondition;
import com.l2jmobius.gameserver.model.cubic.conditions.GeneralCondition.GeneralConditionType;
import com.l2jmobius.gameserver.model.cubic.conditions.HealthCondition;
import com.l2jmobius.gameserver.model.cubic.conditions.HpCondition;
import com.l2jmobius.gameserver.model.cubic.conditions.HpCondition.HpConditionType;
import com.l2jmobius.gameserver.model.cubic.conditions.RangeCondition;
/**
* @author UnAfraid
@@ -102,12 +103,17 @@ public class CubicData implements IGameXmlReader
{
switch (conditionNode.getNodeName())
{
case "general":
case "hp":
{
final GeneralConditionType type = parseEnum(conditionNode.getAttributes(), GeneralConditionType.class, "type");
final int hpPer = parseInteger(conditionNode.getAttributes(), "hpPercent");
final int hp = parseInteger(conditionNode.getAttributes(), "hp");
holder.addCondition(new GeneralCondition(type, hpPer, hp));
final HpConditionType type = parseEnum(conditionNode.getAttributes(), HpConditionType.class, "type");
final int hpPer = parseInteger(conditionNode.getAttributes(), "percent");
holder.addCondition(new HpCondition(type, hpPer));
break;
}
case "range":
{
final int range = parseInteger(conditionNode.getAttributes(), "value");
holder.addCondition(new RangeCondition(range));
break;
}
case "healthPercent":

View File

@@ -17,21 +17,22 @@
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.logging.Logger;
import org.w3c.dom.Document;
import org.w3c.dom.NamedNodeMap;
import org.w3c.dom.Node;
import com.l2jmobius.Config;
import com.l2jmobius.commons.util.IGameXmlReader;
import com.l2jmobius.gameserver.model.L2EnchantSkillGroup;
import com.l2jmobius.gameserver.model.L2EnchantSkillGroup.EnchantSkillHolder;
import com.l2jmobius.gameserver.model.L2EnchantSkillLearn;
import com.l2jmobius.gameserver.enums.SkillEnchantType;
import com.l2jmobius.gameserver.model.StatsSet;
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
import com.l2jmobius.gameserver.model.holders.EnchantSkillHolder;
import com.l2jmobius.gameserver.model.holders.ItemHolder;
import com.l2jmobius.gameserver.model.holders.SkillHolder;
import com.l2jmobius.gameserver.model.skills.Skill;
/**
@@ -42,29 +43,10 @@ public class EnchantSkillGroupsData implements IGameXmlReader
{
private static final Logger LOGGER = Logger.getLogger(EnchantSkillGroupsData.class.getName());
public static final int NORMAL_ENCHANT_COST_MULTIPLIER = Config.NORMAL_ENCHANT_COST_MULTIPLIER;
public static final int SAFE_ENCHANT_COST_MULTIPLIER = Config.SAFE_ENCHANT_COST_MULTIPLIER;
private final Map<Integer, EnchantSkillHolder> _enchantSkillHolders = new LinkedHashMap<>();
private final Map<SkillHolder, Set<Integer>> _enchantSkillTrees = new HashMap<>();
public static final int NORMAL_ENCHANT_BOOK_OLD = 6622;
public static final int SAFE_ENCHANT_BOOK_OLD = 9627;
public static final int CHANGE_ENCHANT_BOOK_OLD = 9626;
public static final int UNTRAIN_ENCHANT_BOOK_OLD = 9625;
public static final int NORMAL_ENCHANT_BOOK = 30297;
public static final int SAFE_ENCHANT_BOOK = 30298;
public static final int CHANGE_ENCHANT_BOOK = 30299;
public static final int UNTRAIN_ENCHANT_BOOK = 30300;
public static final int IMMORTAL_SCROLL = 37044;
public static final int NORMAL_ENCHANT_BOOK_V2 = 46150;
public static final int SAFE_ENCHANT_BOOK_V2 = 46151;
public static final int CHANGE_ENCHANT_BOOK_V2 = 46152;
public static final int IMMORTAL_SCROLL_V2 = 46153;
public static final int NORMAL_ENCHANT_BOOK_V3 = 46154;
public static final int SAFE_ENCHANT_BOOK_V3 = 46155;
public static final int CHANGE_ENCHANT_BOOK_V3 = 46156;
public static final int IMMORTAL_SCROLL_V3 = 46157;
private final Map<Integer, L2EnchantSkillGroup> _enchantSkillGroups = new HashMap<>();
private final Map<Integer, L2EnchantSkillLearn> _enchantSkillTrees = new HashMap<>();
public static int MAX_ENCHANT_LEVEL;
/**
* Instantiates a new enchant groups table.
@@ -77,188 +59,78 @@ public class EnchantSkillGroupsData implements IGameXmlReader
@Override
public void load()
{
_enchantSkillGroups.clear();
_enchantSkillTrees.clear();
parseDatapackFile("data/EnchantSkillGroups.xml");
int routes = 0;
for (L2EnchantSkillGroup group : _enchantSkillGroups.values())
{
routes += group.getEnchantGroupDetails().size();
}
LOGGER.info(getClass().getSimpleName() + ": Loaded " + _enchantSkillGroups.size() + " groups and " + routes + " routes.");
_enchantSkillHolders.clear();
parseDatapackFile("data/enchantSkillGroups.xml");
MAX_ENCHANT_LEVEL = _enchantSkillHolders.size();
LOGGER.info(getClass().getSimpleName() + ": Loaded " + _enchantSkillHolders.size() + " enchant routes, max enchant set to " + MAX_ENCHANT_LEVEL + ".");
}
@Override
public void parseDocument(Document doc, File f)
{
NamedNodeMap attrs;
StatsSet set;
Node att;
int id = 0;
L2EnchantSkillGroup group;
for (Node n = doc.getFirstChild(); n != null; n = n.getNextSibling())
forEach(doc, "list", listNode -> forEach(listNode, "enchant", enchantNode ->
{
if ("list".equalsIgnoreCase(n.getNodeName()))
{
for (Node d = n.getFirstChild(); d != null; d = d.getNextSibling())
{
if ("group".equalsIgnoreCase(d.getNodeName()))
{
attrs = d.getAttributes();
id = parseInteger(attrs, "id");
group = _enchantSkillGroups.get(id);
if (group == null)
{
group = new L2EnchantSkillGroup(id);
_enchantSkillGroups.put(id, group);
}
for (Node b = d.getFirstChild(); b != null; b = b.getNextSibling())
{
if ("enchant".equalsIgnoreCase(b.getNodeName()))
{
attrs = b.getAttributes();
set = new StatsSet();
for (int i = 0; i < attrs.getLength(); i++)
{
att = attrs.item(i);
set.set(att.getNodeName(), att.getNodeValue());
}
group.addEnchantDetail(new EnchantSkillHolder(set));
}
}
}
}
}
}
}
/**
* Adds the new route for skill.
* @param skillId the skill id
* @param maxLvL the max lvl
* @param route the route
* @param group the group
* @return the int
*/
public int addNewRouteForSkill(int skillId, int maxLvL, int route, int group)
{
L2EnchantSkillLearn enchantableSkill = _enchantSkillTrees.get(skillId);
if (enchantableSkill == null)
{
enchantableSkill = new L2EnchantSkillLearn(skillId, maxLvL);
_enchantSkillTrees.put(skillId, enchantableSkill);
}
if (_enchantSkillGroups.containsKey(group))
{
enchantableSkill.addNewEnchantRoute(route, group);
final EnchantSkillHolder enchantSkillHolder = new EnchantSkillHolder(new StatsSet(parseAttributes(enchantNode)));
return _enchantSkillGroups.get(group).getEnchantGroupDetails().size();
}
LOGGER.severe(getClass().getSimpleName() + ": Error while loading generating enchant skill id: " + skillId + "; route: " + route + " missing group: " + group);
return 0;
}
/**
* Gets the skill enchantment for skill.
* @param skill the skill
* @return the skill enchantment for skill
*/
public L2EnchantSkillLearn getSkillEnchantmentForSkill(Skill skill)
{
// there is enchantment for this skill and we have the required level of it
final L2EnchantSkillLearn esl = getSkillEnchantmentBySkillId(skill.getId());
if ((esl != null) && (skill.getLevel() >= esl.getBaseLevel()))
{
return esl;
}
return null;
}
/**
* Gets the skill enchantment by skill id.
* @param skillId the skill id
* @return the skill enchantment by skill id
*/
public L2EnchantSkillLearn getSkillEnchantmentBySkillId(int skillId)
{
return _enchantSkillTrees.get(skillId);
}
/**
* Gets the enchant skill group by id.
* @param id the id
* @return the enchant skill group by id
*/
public L2EnchantSkillGroup getEnchantSkillGroupById(int id)
{
return _enchantSkillGroups.get(id);
}
/**
* Gets the enchant skill sp cost.
* @param skill the skill
* @return the enchant skill sp cost
*/
public int getEnchantSkillSpCost(Skill skill)
{
final L2EnchantSkillLearn enchantSkillLearn = _enchantSkillTrees.get(skill.getId());
if (enchantSkillLearn != null)
{
final EnchantSkillHolder esh = enchantSkillLearn.getEnchantSkillHolder(skill.getLevel());
if (esh != null)
forEach(enchantNode, "sps", spsNode -> forEach(spsNode, "sp", spNode ->
{
return esh.getSpCost();
}
}
return Integer.MAX_VALUE;
}
/**
* Gets the enchant skill Adena cost.
* @param skill the skill
* @return the enchant skill Adena cost
*/
public int getEnchantSkillAdenaCost(Skill skill)
{
final L2EnchantSkillLearn enchantSkillLearn = _enchantSkillTrees.get(skill.getId());
if (enchantSkillLearn != null)
{
final EnchantSkillHolder esh = enchantSkillLearn.getEnchantSkillHolder(skill.getLevel());
if (esh != null)
enchantSkillHolder.addSp(parseEnum(spNode.getAttributes(), SkillEnchantType.class, "type"), parseInteger(spNode.getAttributes(), "amount"));
}));
forEach(enchantNode, "chances", chancesNode -> forEach(chancesNode, "chance", chanceNode ->
{
return esh.getAdenaCost();
}
}
return Integer.MAX_VALUE;
}
/**
* Gets the enchant skill rate.
* @param player the player
* @param skill the skill
* @return the enchant skill rate
*/
public byte getEnchantSkillRate(L2PcInstance player, Skill skill)
{
final L2EnchantSkillLearn enchantSkillLearn = _enchantSkillTrees.get(skill.getId());
if (enchantSkillLearn != null)
{
final EnchantSkillHolder esh = enchantSkillLearn.getEnchantSkillHolder(skill.getLevel());
if (esh != null)
enchantSkillHolder.addChance(parseEnum(chanceNode.getAttributes(), SkillEnchantType.class, "type"), parseInteger(chanceNode.getAttributes(), "value"));
}));
forEach(enchantNode, "items", itemsNode -> forEach(itemsNode, "item", itemNode ->
{
return esh.getRate(player);
}
}
return 0;
enchantSkillHolder.addRequiredItem(parseEnum(itemNode.getAttributes(), SkillEnchantType.class, "type"), new ItemHolder(new StatsSet(parseAttributes(itemNode))));
}));
_enchantSkillHolders.put(parseInteger(enchantNode.getAttributes(), "level"), enchantSkillHolder);
}));
}
public void addRouteForSkill(int skillId, int level, int route)
{
addRouteForSkill(new SkillHolder(skillId, level), route);
}
public void addRouteForSkill(SkillHolder holder, int route)
{
_enchantSkillTrees.computeIfAbsent(holder, k -> new HashSet<>()).add(route);
}
public Set<Integer> getRouteForSkill(int skillId, int level)
{
return getRouteForSkill(skillId, level, 0);
}
public Set<Integer> getRouteForSkill(int skillId, int level, int subLevel)
{
return getRouteForSkill(new SkillHolder(skillId, level, subLevel));
}
public Set<Integer> getRouteForSkill(SkillHolder holder)
{
return _enchantSkillTrees.getOrDefault(holder, Collections.emptySet());
}
public boolean isEnchantable(Skill skill)
{
return isEnchantable(new SkillHolder(skill.getId(), skill.getLevel()));
}
public boolean isEnchantable(SkillHolder holder)
{
return _enchantSkillTrees.containsKey(holder);
}
public EnchantSkillHolder getEnchantSkillHolder(int level)
{
return _enchantSkillHolders.getOrDefault(level, null);
}
/**
* Gets the single instance of EnchantGroupsData.
* @return single instance of EnchantGroupsData
*/
public static EnchantSkillGroupsData getInstance()
{
return SingletonHolder._instance;

View File

@@ -225,7 +225,7 @@ public final class InitialShortcutData implements IGameXmlReader
final int shortcutId = parseInteger(attrs, "shortcutId");
final int shortcutLevel = parseInteger(attrs, "shortcutLevel", 0);
final int characterType = parseInteger(attrs, "characterType", 0);
return new Shortcut(slotId, pageId, shortcutType, shortcutId, shortcutLevel, characterType);
return new Shortcut(slotId, pageId, shortcutType, shortcutId, shortcutLevel, 0, characterType);
}
/**
@@ -305,7 +305,7 @@ public final class InitialShortcutData implements IGameXmlReader
}
// Register shortcut
final Shortcut newShortcut = new Shortcut(shortcut.getSlot(), shortcut.getPage(), shortcut.getType(), shortcutId, shortcut.getLevel(), shortcut.getCharacterType());
final Shortcut newShortcut = new Shortcut(shortcut.getSlot(), shortcut.getPage(), shortcut.getType(), shortcutId, shortcut.getLevel(), shortcut.getSubLevel(), shortcut.getCharacterType());
player.sendPacket(new ShortCutRegister(newShortcut));
player.registerShortCut(newShortcut);
}
@@ -348,7 +348,7 @@ public final class InitialShortcutData implements IGameXmlReader
}
}
// Register shortcut
final Shortcut newShortcut = new Shortcut(shortcut.getSlot(), shortcut.getPage(), shortcut.getType(), shortcutId, shortcut.getLevel(), shortcut.getCharacterType());
final Shortcut newShortcut = new Shortcut(shortcut.getSlot(), shortcut.getPage(), shortcut.getType(), shortcutId, shortcut.getLevel(), shortcut.getSubLevel(), shortcut.getCharacterType());
player.sendPacket(new ShortCutRegister(newShortcut));
player.registerShortCut(newShortcut);
}

View File

@@ -56,9 +56,8 @@ public class SkillData implements IGameXmlReader
{
private static final Logger LOGGER = Logger.getLogger(SkillData.class.getName());
private final Map<Integer, Skill> _skills = new HashMap<>();
private final Map<Long, Skill> _skills = new HashMap<>();
private final Map<Integer, Integer> _skillsMaxLevel = new HashMap<>();
private final Set<Integer> _enchantable = new HashSet<>();
private class NamedParamInfo
{
@@ -68,9 +67,8 @@ public class SkillData implements IGameXmlReader
private final Integer _fromSubLevel;
private final Integer _toSubLevel;
private final Map<Integer, Map<Integer, StatsSet>> _info;
private final StatsSet _generalInfo;
public NamedParamInfo(String name, Integer fromLevel, Integer toLevel, Integer fromSubLevel, Integer toSubLevel, Map<Integer, Map<Integer, StatsSet>> info, StatsSet generalInfo)
public NamedParamInfo(String name, Integer fromLevel, Integer toLevel, Integer fromSubLevel, Integer toSubLevel, Map<Integer, Map<Integer, StatsSet>> info)
{
_name = name;
_fromLevel = fromLevel;
@@ -78,7 +76,6 @@ public class SkillData implements IGameXmlReader
_fromSubLevel = fromSubLevel;
_toSubLevel = toSubLevel;
_info = info;
_generalInfo = generalInfo;
}
public String getName()
@@ -110,11 +107,6 @@ public class SkillData implements IGameXmlReader
{
return _info;
}
public StatsSet getGeneralInfo()
{
return _generalInfo;
}
}
protected SkillData()
@@ -127,9 +119,9 @@ public class SkillData implements IGameXmlReader
* @param skill The L2Skill to be hashed
* @return getSkillHashCode(skill.getId(), skill.getLevel())
*/
public static int getSkillHashCode(Skill skill)
public static long getSkillHashCode(Skill skill)
{
return getSkillHashCode(skill.getId(), skill.getLevel());
return getSkillHashCode(skill.getId(), skill.getLevel(), skill.getSubLevel());
}
/**
@@ -138,14 +130,31 @@ public class SkillData implements IGameXmlReader
* @param skillLevel The Skill Level
* @return The Skill hash number
*/
public static int getSkillHashCode(int skillId, int skillLevel)
public static long getSkillHashCode(int skillId, int skillLevel)
{
return (skillId * 1031) + skillLevel;
return getSkillHashCode(skillId, skillLevel, 0);
}
/**
* Centralized method for easier change of the hashing sys
* @param skillId The Skill Id
* @param skillLevel The Skill Level
* @param subSkillLevel The skill sub level
* @return The Skill hash number
*/
public static long getSkillHashCode(int skillId, int skillLevel, int subSkillLevel)
{
return subSkillLevel > 0 ? ((skillId * 4294967296L) + (subSkillLevel * 65536) + skillLevel) : (skillId * 65536) + skillLevel;
}
public Skill getSkill(int skillId, int level)
{
final Skill result = _skills.get(getSkillHashCode(skillId, level));
return getSkill(skillId, level, 0);
}
public Skill getSkill(int skillId, int level, int subLevel)
{
final Skill result = _skills.get(getSkillHashCode(skillId, level, subLevel));
if (result != null)
{
return result;
@@ -156,7 +165,7 @@ public class SkillData implements IGameXmlReader
// requested level too high
if ((maxLvl > 0) && (level > maxLvl))
{
LOGGER.log(Level.WARNING, getClass().getSimpleName() + ": Call to unexisting skill level id: " + skillId + " requested level: " + level + " max level: " + maxLvl, new Throwable());
LOGGER.log(Level.WARNING, getClass().getSimpleName() + ": Call to unexisting skill level id: " + skillId + " requested level: " + level + " max level: " + maxLvl + ".", new Throwable());
return _skills.get(getSkillHashCode(skillId, maxLvl));
}
@@ -170,16 +179,6 @@ public class SkillData implements IGameXmlReader
return maxLevel != null ? maxLevel : 0;
}
/**
* Verifies if the given skill ID correspond to an enchantable skill.
* @param skillId the skill ID
* @return {@code true} if the skill is enchantable, {@code false} otherwise
*/
public boolean isEnchantable(int skillId)
{
return _enchantable.contains(skillId);
}
/**
* @param addNoble
* @param hasCastle
@@ -217,7 +216,6 @@ public class SkillData implements IGameXmlReader
{
_skills.clear();
_skillsMaxLevel.clear();
_enchantable.clear();
parseDatapackDirectory("data/stats/skills/", true);
LOGGER.info(getClass().getSimpleName() + ": Loaded " + _skills.size() + " Skills.");
}
@@ -243,12 +241,11 @@ public class SkillData implements IGameXmlReader
NamedNodeMap attributes = listNode.getAttributes();
final Map<Integer, Set<Integer>> levels = new HashMap<>();
final Map<Integer, Map<Integer, StatsSet>> skillInfo = new HashMap<>();
final StatsSet generalSkillInfo = new StatsSet();
final StatsSet generalSkillInfo = skillInfo.computeIfAbsent(-1, k -> new HashMap<>()).computeIfAbsent(-1, k -> new StatsSet());
parseAttributes(attributes, "", generalSkillInfo);
final Map<String, Map<Integer, Map<Integer, Object>>> variableValues = new HashMap<>();
final Map<String, Object> variableGeneralValues = new HashMap<>();
final Map<EffectScope, List<NamedParamInfo>> effectParamInfo = new HashMap<>();
final Map<SkillConditionScope, List<NamedParamInfo>> conditionParamInfo = new HashMap<>();
for (Node skillNode = listNode.getFirstChild(); skillNode != null; skillNode = skillNode.getNextSibling())
@@ -260,7 +257,7 @@ public class SkillData implements IGameXmlReader
{
attributes = skillNode.getAttributes();
final String name = "@" + parseString(attributes, "name");
variableGeneralValues.put(name, parseValues(skillNode, variableValues.computeIfAbsent(name, k -> new HashMap<>())));
variableValues.put(name, parseValues(skillNode));
break;
}
case "#text":
@@ -278,7 +275,7 @@ public class SkillData implements IGameXmlReader
{
case "effect":
{
effectParamInfo.computeIfAbsent(effectScope, k -> new LinkedList<>()).add(parseNamedParamInfo(effectsNode, variableValues, variableGeneralValues));
effectParamInfo.computeIfAbsent(effectScope, k -> new LinkedList<>()).add(parseNamedParamInfo(effectsNode, variableValues));
break;
}
}
@@ -294,7 +291,7 @@ public class SkillData implements IGameXmlReader
{
case "condition":
{
conditionParamInfo.computeIfAbsent(skillConditionScope, k -> new LinkedList<>()).add(parseNamedParamInfo(conditionNode, variableValues, variableGeneralValues));
conditionParamInfo.computeIfAbsent(skillConditionScope, k -> new LinkedList<>()).add(parseNamedParamInfo(conditionNode, variableValues));
break;
}
}
@@ -302,7 +299,7 @@ public class SkillData implements IGameXmlReader
}
else
{
parseInfo(skillNode, variableValues, variableGeneralValues, skillInfo, generalSkillInfo);
parseInfo(skillNode, variableValues, skillInfo);
}
break;
}
@@ -319,8 +316,16 @@ public class SkillData implements IGameXmlReader
skillInfo.forEach((level, subLevelMap) ->
{
if (level == -1)
{
return;
}
subLevelMap.forEach((subLevel, statsSet) ->
{
if (subLevel == -1)
{
return;
}
levels.computeIfAbsent(level, k -> new HashSet<>()).add(subLevel);
});
});
@@ -331,8 +336,16 @@ public class SkillData implements IGameXmlReader
{
namedParamInfo.getInfo().forEach((level, subLevelMap) ->
{
if (level == -1)
{
return;
}
subLevelMap.forEach((subLevel, statsSet) ->
{
if (subLevel == -1)
{
return;
}
levels.computeIfAbsent(level, k -> new HashSet<>()).add(subLevel);
});
});
@@ -362,8 +375,9 @@ public class SkillData implements IGameXmlReader
{
subLevels.forEach(subLevel ->
{
final StatsSet statsSet = Optional.ofNullable(skillInfo.getOrDefault(level, Collections.emptyMap()).get(subLevel)).orElseGet(() -> new StatsSet());
generalSkillInfo.getSet().forEach((k, v) -> statsSet.getSet().putIfAbsent(k, v));
final StatsSet statsSet = Optional.ofNullable(skillInfo.getOrDefault(level, Collections.emptyMap()).get(subLevel)).orElseGet(StatsSet::new);
skillInfo.getOrDefault(level, Collections.emptyMap()).getOrDefault(-1, StatsSet.EMPTY_STATSET).getSet().forEach(statsSet.getSet()::putIfAbsent);
skillInfo.getOrDefault(-1, Collections.emptyMap()).getOrDefault(-1, StatsSet.EMPTY_STATSET).getSet().forEach(statsSet.getSet()::putIfAbsent);
statsSet.set(".level", level);
statsSet.set(".subLevel", subLevel);
final Skill skill = new Skill(statsSet);
@@ -413,9 +427,9 @@ public class SkillData implements IGameXmlReader
_skills.put(getSkillHashCode(skill), skill);
_skillsMaxLevel.merge(skill.getId(), skill.getLevel(), Integer::max);
if ((skill.getLevel() > 99) && !_enchantable.contains(skill.getId()))
if ((skill.getSubLevel() % 1000) == 1)
{
_enchantable.add(skill.getId());
EnchantSkillGroupsData.getInstance().addRouteForSkill(skill.getId(), skill.getLevel(), skill.getSubLevel());
}
});
});
@@ -435,8 +449,9 @@ public class SkillData implements IGameXmlReader
{
if (((namedParamInfo.getFromSubLevel() == null) && (namedParamInfo.getToSubLevel() == null)) || ((namedParamInfo.getFromSubLevel() <= subLevel) && (namedParamInfo.getToSubLevel() >= subLevel)))
{
final StatsSet params = Optional.ofNullable(namedParamInfo.getInfo().getOrDefault(level, Collections.emptyMap()).get(subLevel)).orElseGet(() -> new StatsSet());
namedParamInfo.getGeneralInfo().getSet().forEach((k, v) -> params.getSet().putIfAbsent(k, v));
final StatsSet params = Optional.ofNullable(namedParamInfo.getInfo().getOrDefault(level, Collections.emptyMap()).get(subLevel)).orElseGet(StatsSet::new);
namedParamInfo.getInfo().getOrDefault(level, Collections.emptyMap()).getOrDefault(-1, StatsSet.EMPTY_STATSET).getSet().forEach(params.getSet()::putIfAbsent);
namedParamInfo.getInfo().getOrDefault(-1, Collections.emptyMap()).getOrDefault(-1, StatsSet.EMPTY_STATSET).getSet().forEach(params.getSet()::putIfAbsent);
params.set(".name", namedParamInfo.getName());
consumer.accept(scope, params);
}
@@ -445,58 +460,46 @@ public class SkillData implements IGameXmlReader
});
}
private NamedParamInfo parseNamedParamInfo(Node node, Map<String, Map<Integer, Map<Integer, Object>>> variableValues, Map<String, Object> variableGeneralValues)
private NamedParamInfo parseNamedParamInfo(Node node, Map<String, Map<Integer, Map<Integer, Object>>> variableValues)
{
final NamedNodeMap attributes = node.getAttributes();
final String name = parseString(attributes, "name");
final Integer level = parseInteger(attributes, "level");
final Integer fromLevel = parseInteger(attributes, "fromLevel", level);
final Integer toLevel = parseInteger(attributes, "toLevel", level);
final Integer subLevel = parseInteger(attributes, "subLevel", 0);
final Integer subLevel = parseInteger(attributes, "subLevel");
final Integer fromSubLevel = parseInteger(attributes, "fromSubLevel", subLevel);
final Integer toSubLevel = parseInteger(attributes, "toSubLevel", subLevel);
final Map<Integer, Map<Integer, StatsSet>> info = new HashMap<>();
final StatsSet generalInfo = new StatsSet();
for (node = node.getFirstChild(); node != null; node = node.getNextSibling())
{
if (!node.getNodeName().equals("#text"))
{
parseInfo(node, variableValues, variableGeneralValues, info, generalInfo);
parseInfo(node, variableValues, info);
}
}
return new NamedParamInfo(name, fromLevel, toLevel, fromSubLevel, toSubLevel, info, generalInfo);
return new NamedParamInfo(name, fromLevel, toLevel, fromSubLevel, toSubLevel, info);
}
private void parseInfo(Node node, Map<String, Map<Integer, Map<Integer, Object>>> variableValues, Map<String, Object> variableGeneralValues, Map<Integer, Map<Integer, StatsSet>> info, StatsSet generalInfo)
private void parseInfo(Node node, Map<String, Map<Integer, Map<Integer, Object>>> variableValues, Map<Integer, Map<Integer, StatsSet>> info)
{
Map<Integer, Map<Integer, Object>> values = new HashMap<>();
final Object generalValue = parseValues(node, values);
Map<Integer, Map<Integer, Object>> values = parseValues(node);
final Object generalValue = values.getOrDefault(-1, Collections.emptyMap()).get(-1);
if (generalValue != null)
{
final String stringGeneralValue = String.valueOf(generalValue);
if (stringGeneralValue.startsWith("@"))
{
final Map<Integer, Map<Integer, Object>> tableValue = variableValues.get(stringGeneralValue);
if (tableValue != null)
Map<Integer, Map<Integer, Object>> variableValue = variableValues.get(stringGeneralValue);
if (variableValue != null)
{
if (!tableValue.isEmpty())
{
values = tableValue;
}
else
{
generalInfo.set(node.getNodeName(), variableGeneralValues.get(stringGeneralValue));
}
values = variableValue;
}
else
{
throw new IllegalArgumentException("undefined variable " + stringGeneralValue);
}
}
else
{
generalInfo.set(node.getNodeName(), generalValue);
}
}
values.forEach((level, subLevelMap) ->
@@ -508,60 +511,62 @@ public class SkillData implements IGameXmlReader
});
}
private Object parseValues(Node node, Map<Integer, Map<Integer, Object>> values)
private Map<Integer, Map<Integer, Object>> parseValues(Node node)
{
final Map<Integer, Map<Integer, Object>> values = new HashMap<>();
Object parsedValue = parseValue(node, true, false, Collections.emptyMap());
if (parsedValue != null)
{
return parsedValue;
values.computeIfAbsent(-1, k -> new HashMap<>()).put(-1, parsedValue);
}
final List<Object> list = null;
for (node = node.getFirstChild(); node != null; node = node.getNextSibling())
else
{
if (node.getNodeName().equalsIgnoreCase("value"))
for (node = node.getFirstChild(); node != null; node = node.getNextSibling())
{
final NamedNodeMap attributes = node.getAttributes();
final Integer level = parseInteger(attributes, "level");
if (level != null)
if (node.getNodeName().equalsIgnoreCase("value"))
{
parsedValue = parseValue(node, false, false, Collections.emptyMap());
if (parsedValue != null)
final NamedNodeMap attributes = node.getAttributes();
final Integer level = parseInteger(attributes, "level");
if (level != null)
{
final Integer subLevel = parseInteger(attributes, "subLevel", 0);
values.computeIfAbsent(level, k -> new HashMap<>()).put(subLevel, parsedValue);
}
}
else
{
final int fromLevel = parseInteger(attributes, "fromLevel");
final int toLevel = parseInteger(attributes, "toLevel");
final int fromSubLevel = parseInteger(attributes, "fromSubLevel", 0);
final int toSubLevel = parseInteger(attributes, "toSubLevel", 0);
for (int i = fromLevel; i <= toLevel; i++)
{
for (int j = fromSubLevel; j <= toSubLevel; j++)
parsedValue = parseValue(node, false, false, Collections.emptyMap());
if (parsedValue != null)
{
final Map<Integer, Object> subValues = values.computeIfAbsent(i, k -> new HashMap<>());
final Map<String, Double> variables = new HashMap<>();
variables.put("index", (i - fromLevel) + 1d);
variables.put("subIndex", (j - fromSubLevel) + 1d);
final Object base = values.getOrDefault(i, Collections.emptyMap()).get(0);
if ((base != null) && !(base instanceof StatsSet))
final Integer subLevel = parseInteger(attributes, "subLevel", -1);
values.computeIfAbsent(level, k -> new HashMap<>()).put(subLevel, parsedValue);
}
}
else
{
final int fromLevel = parseInteger(attributes, "fromLevel");
final int toLevel = parseInteger(attributes, "toLevel");
final int fromSubLevel = parseInteger(attributes, "fromSubLevel", -1);
final int toSubLevel = parseInteger(attributes, "toSubLevel", -1);
for (int i = fromLevel; i <= toLevel; i++)
{
for (int j = fromSubLevel; j <= toSubLevel; j++)
{
variables.put("base", Double.parseDouble(String.valueOf(base)));
}
parsedValue = parseValue(node, false, false, variables);
if (parsedValue != null)
{
subValues.put(j, parsedValue);
Map<Integer, Object> subValues = values.computeIfAbsent(i, k -> new HashMap<>());
Map<String, Double> variables = new HashMap<>();
variables.put("index", (i - fromLevel) + 1d);
variables.put("subIndex", (j - fromSubLevel) + 1d);
Object base = values.getOrDefault(i, Collections.emptyMap()).get(-1);
if ((base != null) && !(base instanceof StatsSet))
{
variables.put("base", Double.parseDouble(String.valueOf(base)));
}
parsedValue = parseValue(node, false, false, variables);
if (parsedValue != null)
{
subValues.put(j, parsedValue);
}
}
}
}
}
}
}
return list;
return values;
}
Object parseValue(Node node, boolean blockValue, boolean parseAttributes, Map<String, Double> variables)

View File

@@ -80,39 +80,39 @@ public final class SkillTreesData implements IGameXmlReader
private static final Logger LOGGER = Logger.getLogger(SkillTreesData.class.getName());
// ClassId, Map of Skill Hash Code, L2SkillLearn
private static final Map<ClassId, Map<Integer, L2SkillLearn>> _classSkillTrees = new HashMap<>();
private static final Map<ClassId, Map<Integer, L2SkillLearn>> _transferSkillTrees = new HashMap<>();
private static final Map<Race, Map<Integer, L2SkillLearn>> _raceSkillTree = new HashMap<>();
private static final Map<SubclassType, Map<Integer, L2SkillLearn>> _revelationSkillTree = new HashMap<>();
private static final Map<ClassId, Map<Long, L2SkillLearn>> _classSkillTrees = new HashMap<>();
private static final Map<ClassId, Map<Long, L2SkillLearn>> _transferSkillTrees = new HashMap<>();
private static final Map<Race, Map<Long, L2SkillLearn>> _raceSkillTree = new HashMap<>();
private static final Map<SubclassType, Map<Long, L2SkillLearn>> _revelationSkillTree = new HashMap<>();
private static final Map<ClassId, Set<Integer>> _awakeningSaveSkillTree = new HashMap<>();
// Skill Hash Code, L2SkillLearn
private static final Map<Integer, L2SkillLearn> _collectSkillTree = new HashMap<>();
private static final Map<Integer, L2SkillLearn> _fishingSkillTree = new HashMap<>();
private static final Map<Integer, L2SkillLearn> _pledgeSkillTree = new HashMap<>();
private static final Map<Integer, L2SkillLearn> _subClassSkillTree = new HashMap<>();
private static final Map<Integer, L2SkillLearn> _subPledgeSkillTree = new HashMap<>();
private static final Map<Integer, L2SkillLearn> _transformSkillTree = new HashMap<>();
private static final Map<Integer, L2SkillLearn> _commonSkillTree = new HashMap<>();
private static final Map<Integer, L2SkillLearn> _subClassChangeSkillTree = new HashMap<>();
private static final Map<Integer, L2SkillLearn> _abilitySkillTree = new HashMap<>();
private static final Map<Integer, L2SkillLearn> _alchemySkillTree = new HashMap<>();
private static final Map<Integer, L2SkillLearn> _dualClassSkillTree = new HashMap<>();
private static final Map<Long, L2SkillLearn> _collectSkillTree = new HashMap<>();
private static final Map<Long, L2SkillLearn> _fishingSkillTree = new HashMap<>();
private static final Map<Long, L2SkillLearn> _pledgeSkillTree = new HashMap<>();
private static final Map<Long, L2SkillLearn> _subClassSkillTree = new HashMap<>();
private static final Map<Long, L2SkillLearn> _subPledgeSkillTree = new HashMap<>();
private static final Map<Long, L2SkillLearn> _transformSkillTree = new HashMap<>();
private static final Map<Long, L2SkillLearn> _commonSkillTree = new HashMap<>();
private static final Map<Long, L2SkillLearn> _subClassChangeSkillTree = new HashMap<>();
private static final Map<Long, L2SkillLearn> _abilitySkillTree = new HashMap<>();
private static final Map<Long, L2SkillLearn> _alchemySkillTree = new HashMap<>();
private static final Map<Long, L2SkillLearn> _dualClassSkillTree = new HashMap<>();
// Other skill trees
private static final Map<Integer, L2SkillLearn> _nobleSkillTree = new HashMap<>();
private static final Map<Integer, L2SkillLearn> _heroSkillTree = new HashMap<>();
private static final Map<Integer, L2SkillLearn> _gameMasterSkillTree = new HashMap<>();
private static final Map<Integer, L2SkillLearn> _gameMasterAuraSkillTree = new HashMap<>();
private static final Map<Long, L2SkillLearn> _nobleSkillTree = new HashMap<>();
private static final Map<Long, L2SkillLearn> _heroSkillTree = new HashMap<>();
private static final Map<Long, L2SkillLearn> _gameMasterSkillTree = new HashMap<>();
private static final Map<Long, L2SkillLearn> _gameMasterAuraSkillTree = new HashMap<>();
// Remove skill tree
private static final Map<ClassId, Set<Integer>> _removeSkillCache = new HashMap<>();
// Checker, sorted arrays of hash codes
private Map<Integer, int[]> _skillsByClassIdHashCodes; // Occupation skills
private Map<Integer, int[]> _skillsByRaceHashCodes; // Race-specific Transformations
private int[] _allSkillsHashCodes; // Fishing, Collection, Transformations, Common Skills.
private Map<Integer, long[]> _skillsByClassIdHashCodes; // Occupation skills
private Map<Integer, long[]> _skillsByRaceHashCodes; // Race-specific Transformations
private long[] _allSkillsHashCodes; // Fishing, Collection, Transformations, Common Skills.
private boolean _loading = true;
/** Parent class IDs are read from XML and stored in this map, to allow easy customization. */
/** 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<>();
/**
@@ -182,10 +182,10 @@ public final class SkillTreesData implements IGameXmlReader
{
if ("skillTree".equalsIgnoreCase(d.getNodeName()))
{
final Map<Integer, L2SkillLearn> classSkillTree = new HashMap<>();
final Map<Integer, L2SkillLearn> transferSkillTree = new HashMap<>();
final Map<Integer, L2SkillLearn> raceSkillTree = new HashMap<>();
final Map<Integer, L2SkillLearn> revelationSkillTree = new HashMap<>();
final Map<Long, L2SkillLearn> classSkillTree = new HashMap<>();
final Map<Long, L2SkillLearn> transferSkillTree = new HashMap<>();
final Map<Long, L2SkillLearn> raceSkillTree = new HashMap<>();
final Map<Long, L2SkillLearn> revelationSkillTree = new HashMap<>();
type = d.getAttributes().getNamedItem("type").getNodeValue();
attr = d.getAttributes().getNamedItem("classId");
@@ -274,7 +274,7 @@ public final class SkillTreesData implements IGameXmlReader
}
}
final int skillHashCode = SkillData.getSkillHashCode(skillLearn.getSkillId(), skillLearn.getSkillLevel());
final long skillHashCode = SkillData.getSkillHashCode(skillLearn.getSkillId(), skillLearn.getSkillLevel());
switch (type)
{
case "classSkillTree":
@@ -393,35 +393,38 @@ public final class SkillTreesData implements IGameXmlReader
}
else if (type.equals("classSkillTree") && (cId > -1))
{
if (!_classSkillTrees.containsKey(classId))
final Map<Long, L2SkillLearn> classSkillTrees = _classSkillTrees.get(classId);
if (classSkillTrees == null)
{
_classSkillTrees.put(classId, classSkillTree);
}
else
{
_classSkillTrees.get(classId).putAll(classSkillTree);
classSkillTrees.putAll(classSkillTree);
}
}
else if (type.equals("raceSkillTree") && (race != null))
{
if (!_raceSkillTree.containsKey(race))
final Map<Long, L2SkillLearn> raceSkillTrees = _raceSkillTree.get(race);
if (raceSkillTrees == null)
{
_raceSkillTree.put(race, raceSkillTree);
}
else
{
_raceSkillTree.get(race).putAll(raceSkillTree);
raceSkillTrees.putAll(raceSkillTree);
}
}
else if (type.equals("revelationSkillTree") && (subType != null))
{
if (!_revelationSkillTree.containsKey(subType))
final Map<Long, L2SkillLearn> revelationSkillTrees = _revelationSkillTree.get(race);
if (revelationSkillTrees == null)
{
_revelationSkillTree.put(subType, revelationSkillTree);
}
else
{
_revelationSkillTree.get(subType).putAll(revelationSkillTree);
revelationSkillTrees.putAll(revelationSkillTree);
}
}
}
@@ -437,9 +440,9 @@ public final class SkillTreesData implements IGameXmlReader
* @param classId the class skill tree Id
* @return the complete Class Skill Tree including skill trees from parent class for a given {@code classId}
*/
public Map<Integer, L2SkillLearn> getCompleteClassSkillTree(ClassId classId)
public Map<Long, L2SkillLearn> getCompleteClassSkillTree(ClassId classId)
{
final Map<Integer, L2SkillLearn> skillTree = new HashMap<>();
final Map<Long, L2SkillLearn> skillTree = new HashMap<>();
// Add all skills that belong to all classes.
skillTree.putAll(_commonSkillTree);
while ((classId != null) && (_classSkillTrees.get(classId) != null))
@@ -456,7 +459,7 @@ public final class SkillTreesData implements IGameXmlReader
* @param classId the transfer skill tree Id
* @return the complete Transfer Skill Tree for a given {@code classId}
*/
public Map<Integer, L2SkillLearn> getTransferSkillTree(ClassId classId)
public Map<Long, L2SkillLearn> getTransferSkillTree(ClassId classId)
{
return _transferSkillTrees.get(classId);
}
@@ -475,7 +478,7 @@ public final class SkillTreesData implements IGameXmlReader
* Gets the common skill tree.
* @return the complete Common Skill Tree
*/
public Map<Integer, L2SkillLearn> getCommonSkillTree()
public Map<Long, L2SkillLearn> getCommonSkillTree()
{
return _commonSkillTree;
}
@@ -484,7 +487,7 @@ public final class SkillTreesData implements IGameXmlReader
* Gets the collect skill tree.
* @return the complete Collect Skill Tree
*/
public Map<Integer, L2SkillLearn> getCollectSkillTree()
public Map<Long, L2SkillLearn> getCollectSkillTree()
{
return _collectSkillTree;
}
@@ -493,7 +496,7 @@ public final class SkillTreesData implements IGameXmlReader
* Gets the fishing skill tree.
* @return the complete Fishing Skill Tree
*/
public Map<Integer, L2SkillLearn> getFishingSkillTree()
public Map<Long, L2SkillLearn> getFishingSkillTree()
{
return _fishingSkillTree;
}
@@ -502,7 +505,7 @@ public final class SkillTreesData implements IGameXmlReader
* Gets the pledge skill tree.
* @return the complete Pledge Skill Tree
*/
public Map<Integer, L2SkillLearn> getPledgeSkillTree()
public Map<Long, L2SkillLearn> getPledgeSkillTree()
{
return _pledgeSkillTree;
}
@@ -511,7 +514,7 @@ public final class SkillTreesData implements IGameXmlReader
* Gets the sub class skill tree.
* @return the complete Sub-Class Skill Tree
*/
public Map<Integer, L2SkillLearn> getSubClassSkillTree()
public Map<Long, L2SkillLearn> getSubClassSkillTree()
{
return _subClassSkillTree;
}
@@ -520,7 +523,7 @@ public final class SkillTreesData implements IGameXmlReader
* Gets the sub class change skill tree.
* @return the complete Common Skill Tree
*/
public Map<Integer, L2SkillLearn> getSubClassChangeSkillTree()
public Map<Long, L2SkillLearn> getSubClassChangeSkillTree()
{
return _subClassChangeSkillTree;
}
@@ -529,7 +532,7 @@ public final class SkillTreesData implements IGameXmlReader
* Gets the sub pledge skill tree.
* @return the complete Sub-Pledge Skill Tree
*/
public Map<Integer, L2SkillLearn> getSubPledgeSkillTree()
public Map<Long, L2SkillLearn> getSubPledgeSkillTree()
{
return _subPledgeSkillTree;
}
@@ -538,7 +541,7 @@ public final class SkillTreesData implements IGameXmlReader
* Gets the transform skill tree.
* @return the complete Transform Skill Tree
*/
public Map<Integer, L2SkillLearn> getTransformSkillTree()
public Map<Long, L2SkillLearn> getTransformSkillTree()
{
return _transformSkillTree;
}
@@ -547,7 +550,7 @@ public final class SkillTreesData implements IGameXmlReader
* Gets the ability skill tree.
* @return the complete Ability Skill Tree
*/
public Map<Integer, L2SkillLearn> getAbilitySkillTree()
public Map<Long, L2SkillLearn> getAbilitySkillTree()
{
return _abilitySkillTree;
}
@@ -556,7 +559,7 @@ public final class SkillTreesData implements IGameXmlReader
* Gets the ability skill tree.
* @return the complete Ability Skill Tree
*/
public Map<Integer, L2SkillLearn> getAlchemySkillTree()
public Map<Long, L2SkillLearn> getAlchemySkillTree()
{
return _alchemySkillTree;
}
@@ -565,11 +568,11 @@ public final class SkillTreesData implements IGameXmlReader
* Gets the noble skill tree.
* @return the complete Noble Skill Tree
*/
public Map<Integer, Skill> getNobleSkillTree()
public Map<Long, Skill> getNobleSkillTree()
{
final Map<Integer, Skill> tree = new HashMap<>();
final Map<Long, Skill> tree = new HashMap<>();
final SkillData st = SkillData.getInstance();
for (Entry<Integer, L2SkillLearn> e : _nobleSkillTree.entrySet())
for (Entry<Long, L2SkillLearn> e : _nobleSkillTree.entrySet())
{
tree.put(e.getKey(), st.getSkill(e.getValue().getSkillId(), e.getValue().getSkillLevel()));
}
@@ -580,11 +583,11 @@ public final class SkillTreesData implements IGameXmlReader
* Gets the hero skill tree.
* @return the complete Hero Skill Tree
*/
public Map<Integer, Skill> getHeroSkillTree()
public Map<Long, Skill> getHeroSkillTree()
{
final Map<Integer, Skill> tree = new HashMap<>();
final Map<Long, Skill> tree = new HashMap<>();
final SkillData st = SkillData.getInstance();
for (Entry<Integer, L2SkillLearn> e : _heroSkillTree.entrySet())
for (Entry<Long, L2SkillLearn> e : _heroSkillTree.entrySet())
{
tree.put(e.getKey(), st.getSkill(e.getValue().getSkillId(), e.getValue().getSkillLevel()));
}
@@ -595,11 +598,11 @@ public final class SkillTreesData implements IGameXmlReader
* Gets the Game Master skill tree.
* @return the complete Game Master Skill Tree
*/
public Map<Integer, Skill> getGMSkillTree()
public Map<Long, Skill> getGMSkillTree()
{
final Map<Integer, Skill> tree = new HashMap<>();
final Map<Long, Skill> tree = new HashMap<>();
final SkillData st = SkillData.getInstance();
for (Entry<Integer, L2SkillLearn> e : _gameMasterSkillTree.entrySet())
for (Entry<Long, L2SkillLearn> e : _gameMasterSkillTree.entrySet())
{
tree.put(e.getKey(), st.getSkill(e.getValue().getSkillId(), e.getValue().getSkillLevel()));
}
@@ -610,11 +613,11 @@ public final class SkillTreesData implements IGameXmlReader
* Gets the Game Master Aura skill tree.
* @return the complete Game Master Aura Skill Tree
*/
public Map<Integer, Skill> getGMAuraSkillTree()
public Map<Long, Skill> getGMAuraSkillTree()
{
final Map<Integer, Skill> tree = new HashMap<>();
final Map<Long, Skill> tree = new HashMap<>();
final SkillData st = SkillData.getInstance();
for (Entry<Integer, L2SkillLearn> e : _gameMasterAuraSkillTree.entrySet())
for (Entry<Long, L2SkillLearn> e : _gameMasterAuraSkillTree.entrySet())
{
tree.put(e.getKey(), st.getSkill(e.getValue().getSkillId(), e.getValue().getSkillLevel()));
}
@@ -628,7 +631,7 @@ public final class SkillTreesData implements IGameXmlReader
*/
public boolean hasAvailableSkills(L2PcInstance player, ClassId classId)
{
final Map<Integer, L2SkillLearn> skills = getCompleteClassSkillTree(classId);
final Map<Long, L2SkillLearn> skills = getCompleteClassSkillTree(classId);
for (L2SkillLearn skill : skills.values())
{
if ((skill.getSkillId() == CommonSkill.DIVINE_INSPIRATION.getId()) || skill.isAutoGet() || skill.isLearnedByFS() || (skill.getGetLevel() > player.getLevel()))
@@ -673,7 +676,7 @@ public final class SkillTreesData implements IGameXmlReader
private List<L2SkillLearn> getAvailableSkills(L2PcInstance player, ClassId classId, boolean includeByFs, boolean includeAutoGet, ISkillsHolder holder)
{
final List<L2SkillLearn> result = new LinkedList<>();
final Map<Integer, L2SkillLearn> skills = getCompleteClassSkillTree(classId);
final Map<Long, L2SkillLearn> skills = getCompleteClassSkillTree(classId);
if (skills.isEmpty())
{
@@ -684,7 +687,7 @@ public final class SkillTreesData implements IGameXmlReader
final boolean isAwaken = player.isInCategory(CategoryType.AWAKEN_GROUP) && (player.getRace() != Race.ERTHEIA);
for (Entry<Integer, L2SkillLearn> entry : skills.entrySet())
for (Entry<Long, L2SkillLearn> entry : skills.entrySet())
{
final L2SkillLearn skill = entry.getValue();
@@ -787,7 +790,7 @@ public final class SkillTreesData implements IGameXmlReader
public List<L2SkillLearn> getAvailableAutoGetSkills(L2PcInstance player)
{
final List<L2SkillLearn> result = new ArrayList<>();
final Map<Integer, L2SkillLearn> skills = getCompleteClassSkillTree(player.getClassId());
final Map<Long, L2SkillLearn> skills = getCompleteClassSkillTree(player.getClassId());
if (skills.isEmpty())
{
// The Skill Tree for this class is undefined, so we return an empty list.
@@ -818,7 +821,7 @@ public final class SkillTreesData implements IGameXmlReader
}
final int maxLvl = SkillData.getInstance().getMaxLevel(skill.getSkillId());
final int hashCode = SkillData.getSkillHashCode(skill.getSkillId(), maxLvl);
final long hashCode = SkillData.getSkillHashCode(skill.getSkillId(), maxLvl);
if (skill.isAutoGet() && (player.getLevel() >= skill.getGetLevel()))
{
@@ -884,7 +887,7 @@ public final class SkillTreesData implements IGameXmlReader
public List<L2SkillLearn> getAvailableRevelationSkills(L2PcInstance player, SubclassType type)
{
final List<L2SkillLearn> result = new ArrayList<>();
final Map<Integer, L2SkillLearn> revelationSkills = _revelationSkillTree.get(type);
final Map<Long, L2SkillLearn> revelationSkills = _revelationSkillTree.get(type);
for (L2SkillLearn skill : revelationSkills.values())
{
@@ -1382,7 +1385,7 @@ public final class SkillTreesData implements IGameXmlReader
* @param skillTree the skill tree to search the minimum get level
* @return the minimum level for a new skill for a given {@code player} and {@code skillTree}
*/
public int getMinLevelForNewSkill(L2PcInstance player, Map<Integer, L2SkillLearn> skillTree)
public int getMinLevelForNewSkill(L2PcInstance player, Map<Long, L2SkillLearn> skillTree)
{
int minLevel = 0;
if (skillTree.isEmpty())
@@ -1407,7 +1410,7 @@ public final class SkillTreesData implements IGameXmlReader
public List<L2SkillLearn> getNextAvailableSkills(L2PcInstance player, ClassId classId, boolean includeByFs, boolean includeAutoGet)
{
final Map<Integer, L2SkillLearn> completeClassSkillTree = getCompleteClassSkillTree(classId);
final Map<Long, L2SkillLearn> completeClassSkillTree = getCompleteClassSkillTree(classId);
final List<L2SkillLearn> result = new LinkedList<>();
if (completeClassSkillTree.isEmpty())
{
@@ -1448,7 +1451,7 @@ public final class SkillTreesData implements IGameXmlReader
for (Skill skill : player.getAllSkills())
{
final int maxLvl = SkillData.getInstance().getMaxLevel(skill.getId());
final int hashCode = SkillData.getSkillHashCode(skill.getId(), maxLvl);
final long hashCode = SkillData.getSkillHashCode(skill.getId(), maxLvl);
if (!isCurrentClassSkillNoParent(player.getClassId(), hashCode) && !isRemoveSkill(player.getClassId(), skill.getId()) && !isAwakenSaveSkill(player.getClassId(), skill.getId()))
{
@@ -1481,7 +1484,7 @@ public final class SkillTreesData implements IGameXmlReader
*/
public boolean isGMSkill(int skillId, int skillLevel)
{
final int hashCode = SkillData.getSkillHashCode(skillId, skillLevel);
final long hashCode = SkillData.getSkillHashCode(skillId, skillLevel);
return _gameMasterSkillTree.containsKey(hashCode) || _gameMasterAuraSkillTree.containsKey(hashCode);
}
@@ -1493,7 +1496,7 @@ public final class SkillTreesData implements IGameXmlReader
*/
public boolean isClanSkill(int skillId, int skillLevel)
{
final int hashCode = SkillData.getSkillHashCode(skillId, skillLevel);
final long hashCode = SkillData.getSkillHashCode(skillId, skillLevel);
return _pledgeSkillTree.containsKey(hashCode) || _subPledgeSkillTree.containsKey(hashCode);
}
@@ -1513,7 +1516,7 @@ public final class SkillTreesData implements IGameXmlReader
return _removeSkillCache.getOrDefault(classId, Collections.emptySet()).contains(skillId);
}
public boolean isCurrentClassSkillNoParent(ClassId classId, Integer hashCode)
public boolean isCurrentClassSkillNoParent(ClassId classId, Long hashCode)
{
return _classSkillTrees.getOrDefault(classId, Collections.emptyMap()).containsKey(hashCode);
}
@@ -1544,18 +1547,18 @@ public final class SkillTreesData implements IGameXmlReader
private void generateCheckArrays()
{
int i;
int[] array;
long[] array;
// Class specific skills:
Map<Integer, L2SkillLearn> tempMap;
Map<Long, L2SkillLearn> tempMap;
final Set<ClassId> keySet = _classSkillTrees.keySet();
_skillsByClassIdHashCodes = new HashMap<>(keySet.size());
for (ClassId cls : keySet)
{
i = 0;
tempMap = getCompleteClassSkillTree(cls);
array = new int[tempMap.size()];
for (int h : tempMap.keySet())
array = new long[tempMap.size()];
for (long h : tempMap.keySet())
{
array[i++] = h;
}
@@ -1565,7 +1568,7 @@ public final class SkillTreesData implements IGameXmlReader
}
// Race specific skills from Fishing and Transformation skill trees.
final List<Integer> list = new ArrayList<>();
final List<Long> list = new ArrayList<>();
_skillsByRaceHashCodes = new HashMap<>(Race.values().length);
for (Race r : Race.values())
{
@@ -1586,8 +1589,8 @@ public final class SkillTreesData implements IGameXmlReader
}
i = 0;
array = new int[list.size()];
for (int s : list)
array = new long[list.size()];
for (long s : list)
{
array[i++] = s;
}
@@ -1636,9 +1639,9 @@ public final class SkillTreesData implements IGameXmlReader
list.add(SkillData.getSkillHashCode(s.getSkillId(), s.getSkillLevel()));
}
_allSkillsHashCodes = new int[list.size()];
_allSkillsHashCodes = new long[list.size()];
int j = 0;
for (int hashcode : list)
for (long hashcode : list)
{
_allSkillsHashCodes[j++] = hashcode;
}
@@ -1671,7 +1674,7 @@ public final class SkillTreesData implements IGameXmlReader
}
final int maxLvl = SkillData.getInstance().getMaxLevel(skill.getId());
final int hashCode = SkillData.getSkillHashCode(skill.getId(), Math.min(skill.getLevel(), maxLvl));
final long hashCode = SkillData.getSkillHashCode(skill.getId(), Math.min(skill.getLevel(), maxLvl));
if (Arrays.binarySearch(_skillsByClassIdHashCodes.get(player.getClassId().ordinal()), hashCode) >= 0)
{
@@ -1708,25 +1711,25 @@ public final class SkillTreesData implements IGameXmlReader
private void report()
{
int classSkillTreeCount = 0;
for (Map<Integer, L2SkillLearn> classSkillTree : _classSkillTrees.values())
for (Map<Long, L2SkillLearn> classSkillTree : _classSkillTrees.values())
{
classSkillTreeCount += classSkillTree.size();
}
int transferSkillTreeCount = 0;
for (Map<Integer, L2SkillLearn> trasferSkillTree : _transferSkillTrees.values())
for (Map<Long, L2SkillLearn> trasferSkillTree : _transferSkillTrees.values())
{
transferSkillTreeCount += trasferSkillTree.size();
}
int raceSkillTreeCount = 0;
for (Map<Integer, L2SkillLearn> raceSkillTree : _raceSkillTree.values())
for (Map<Long, L2SkillLearn> raceSkillTree : _raceSkillTree.values())
{
raceSkillTreeCount += raceSkillTree.size();
}
int revelationSkillTreeCount = 0;
for (Map<Integer, L2SkillLearn> revelationSkillTree : _revelationSkillTree.values())
for (Map<Long, L2SkillLearn> revelationSkillTree : _revelationSkillTree.values())
{
revelationSkillTreeCount += revelationSkillTree.size();
}

View File

@@ -117,7 +117,17 @@ public class SpawnsData implements IGameXmlReader
return _spawns;
}
public List<NpcSpawnTemplate> getSpawns(Predicate<NpcSpawnTemplate> condition)
public List<SpawnTemplate> getSpawns(Predicate<SpawnTemplate> condition)
{
return _spawns.stream().filter(condition).collect(Collectors.toList());
}
public List<SpawnGroup> getGroupsByName(String groupName)
{
return _spawns.stream().filter(template -> (template.getName() != null) && groupName.equalsIgnoreCase(template.getName())).flatMap(template -> template.getGroups().stream()).collect(Collectors.toList());
}
public List<NpcSpawnTemplate> getNpcSpawns(Predicate<NpcSpawnTemplate> condition)
{
return _spawns.stream().flatMap(template -> template.getGroups().stream()).flatMap(group -> group.getSpawns().stream()).filter(condition).collect(Collectors.toList());
}