Removed subclass change skilltree and skilllearn data.

This commit is contained in:
MobiusDev
2017-12-06 13:23:08 +00:00
parent b36b94b128
commit 1692f55e22
68 changed files with 348 additions and 12220 deletions

View File

@@ -84,7 +84,6 @@ import com.l2jmobius.gameserver.data.xml.impl.SecondaryAuthData;
import com.l2jmobius.gameserver.data.xml.impl.ShuttleData;
import com.l2jmobius.gameserver.data.xml.impl.SiegeScheduleData;
import com.l2jmobius.gameserver.data.xml.impl.SkillData;
import com.l2jmobius.gameserver.data.xml.impl.SkillLearnData;
import com.l2jmobius.gameserver.data.xml.impl.SkillTreesData;
import com.l2jmobius.gameserver.data.xml.impl.SpawnsData;
import com.l2jmobius.gameserver.data.xml.impl.StaticObjectData;
@@ -282,7 +281,6 @@ public class GameServer
}
printSection("NPCs");
SkillLearnData.getInstance();
NpcData.getInstance();
FakePlayerData.getInstance();
FakePlayerChatManager.getInstance();

View File

@@ -44,7 +44,6 @@ import com.l2jmobius.gameserver.enums.MpRewardAffectType;
import com.l2jmobius.gameserver.enums.MpRewardType;
import com.l2jmobius.gameserver.model.StatsSet;
import com.l2jmobius.gameserver.model.actor.templates.L2NpcTemplate;
import com.l2jmobius.gameserver.model.base.ClassId;
import com.l2jmobius.gameserver.model.effects.L2EffectType;
import com.l2jmobius.gameserver.model.holders.DropHolder;
import com.l2jmobius.gameserver.model.skills.Skill;
@@ -80,8 +79,6 @@ public class NpcData implements IGameXmlReader
parseDatapackDirectory("data/stats/npcs/custom", true);
LOGGER.info(getClass().getSimpleName() + ": Loaded " + (_npcs.size() - npcCount) + " Custom NPCs.");
}
loadNpcsSkillLearn();
}
@Override
@@ -787,18 +784,6 @@ public class NpcData implements IGameXmlReader
return getTemplates(template -> CommonUtil.contains(classTypes, template.getType(), true));
}
public void loadNpcsSkillLearn()
{
_npcs.values().forEach(template ->
{
final List<ClassId> teachInfo = SkillLearnData.getInstance().getSkillLearnData(template.getId());
if (teachInfo != null)
{
template.addTeachInfo(teachInfo);
}
});
}
/**
* @return the IDs of monsters that have minions.
*/

View File

@@ -1,103 +0,0 @@
/*
* This file is part of the L2J Mobius project.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jmobius.gameserver.data.xml.impl;
import java.io.File;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.logging.Logger;
import org.w3c.dom.Document;
import org.w3c.dom.Node;
import com.l2jmobius.commons.util.IGameXmlReader;
import com.l2jmobius.gameserver.model.base.ClassId;
/**
* Holds all skill learn data for all npcs.
* @author xban1x
*/
public final class SkillLearnData implements IGameXmlReader
{
private static final Logger LOGGER = Logger.getLogger(SkillLearnData.class.getName());
private final Map<Integer, List<ClassId>> _skillLearn = new HashMap<>();
protected SkillLearnData()
{
load();
}
@Override
public synchronized void load()
{
_skillLearn.clear();
parseDatapackFile("data/SkillLearn.xml");
LOGGER.info(getClass().getSimpleName() + ": Loaded " + _skillLearn.size() + " Skill Learn data.");
}
@Override
public void parseDocument(Document doc, File f)
{
for (Node node = doc.getFirstChild(); node != null; node = node.getNextSibling())
{
if ("list".equalsIgnoreCase(node.getNodeName()))
{
for (Node list_node = node.getFirstChild(); list_node != null; list_node = list_node.getNextSibling())
{
if ("npc".equalsIgnoreCase(list_node.getNodeName()))
{
final List<ClassId> classIds = new ArrayList<>();
for (Node c = list_node.getFirstChild(); c != null; c = c.getNextSibling())
{
if ("classId".equalsIgnoreCase(c.getNodeName()))
{
classIds.add(ClassId.getClassId(Integer.parseInt(c.getTextContent())));
}
}
_skillLearn.put(parseInteger(list_node.getAttributes(), "id"), classIds);
}
}
}
}
}
/**
* @param npcId
* @return {@link List} of {@link ClassId}'s that this npcId can teach.
*/
public List<ClassId> getSkillLearnData(int npcId)
{
return _skillLearn.get(npcId);
}
/**
* Gets the single instance of SkillLearnData.
* @return single instance of SkillLearnData
*/
public static SkillLearnData getInstance()
{
return SingletonHolder._instance;
}
private static class SingletonHolder
{
protected static final SkillLearnData _instance = new SkillLearnData();
}
}

View File

@@ -29,7 +29,9 @@ import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.logging.Logger;
import java.util.stream.Collectors;
import org.w3c.dom.Document;
import org.w3c.dom.NamedNodeMap;
@@ -93,7 +95,6 @@ public final class SkillTreesData implements IGameXmlReader
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<>();
@@ -110,11 +111,11 @@ public final class SkillTreesData implements IGameXmlReader
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. */
private static final Map<ClassId, ClassId> _parentClassMap = new HashMap<>();
private final AtomicBoolean _isLoading = new AtomicBoolean();
/**
* Instantiates a new skill trees data.
*/
@@ -126,7 +127,8 @@ public final class SkillTreesData implements IGameXmlReader
@Override
public void load()
{
_loading = true;
_isLoading.set(true);
_classSkillTrees.clear();
_collectSkillTree.clear();
_fishingSkillTree.clear();
@@ -136,7 +138,6 @@ public final class SkillTreesData implements IGameXmlReader
_transferSkillTrees.clear();
_transformSkillTree.clear();
_nobleSkillTree.clear();
_subClassChangeSkillTree.clear();
_abilitySkillTree.clear();
_alchemySkillTree.clear();
_heroSkillTree.clear();
@@ -154,10 +155,10 @@ public final class SkillTreesData implements IGameXmlReader
// Generate check arrays.
generateCheckArrays();
_loading = false;
// Logs a report with skill trees info.
report();
_isLoading.set(false);
}
/**
@@ -368,11 +369,6 @@ public final class SkillTreesData implements IGameXmlReader
_gameMasterAuraSkillTree.put(skillHashCode, skillLearn);
break;
}
case "subClassChangeSkillTree":
{
_subClassChangeSkillTree.put(skillHashCode, skillLearn);
break;
}
case "dualClassSkillTree":
{
_dualClassSkillTree.put(skillHashCode, skillLearn);
@@ -523,15 +519,6 @@ public final class SkillTreesData implements IGameXmlReader
return _subClassSkillTree;
}
/**
* Gets the sub class change skill tree.
* @return the complete Common Skill Tree
*/
public Map<Long, L2SkillLearn> getSubClassChangeSkillTree()
{
return _subClassChangeSkillTree;
}
/**
* Gets the sub pledge skill tree.
* @return the complete Sub-Pledge Skill Tree
@@ -572,60 +559,45 @@ public final class SkillTreesData implements IGameXmlReader
* Gets the noble skill tree.
* @return the complete Noble Skill Tree
*/
public Map<Long, Skill> getNobleSkillTree()
public List<Skill> getNobleSkillTree()
{
final Map<Long, Skill> tree = new HashMap<>();
final SkillData st = SkillData.getInstance();
for (Entry<Long, L2SkillLearn> e : _nobleSkillTree.entrySet())
{
tree.put(e.getKey(), st.getSkill(e.getValue().getSkillId(), e.getValue().getSkillLevel()));
}
return tree;
return _nobleSkillTree.values().stream().map(entry -> SkillData.getInstance().getSkill(entry.getSkillId(), entry.getSkillLevel())).collect(Collectors.toList());
}
/**
* Gets the noble skill tree.
* @return the complete Noble Skill Tree
*/
public List<Skill> getNobleSkillAutoGetTree()
{
return _nobleSkillTree.values().stream().filter(entry -> entry.isAutoGet()).map(entry -> SkillData.getInstance().getSkill(entry.getSkillId(), entry.getSkillLevel())).collect(Collectors.toList());
}
/**
* Gets the hero skill tree.
* @return the complete Hero Skill Tree
*/
public Map<Long, Skill> getHeroSkillTree()
public List<Skill> getHeroSkillTree()
{
final Map<Long, Skill> tree = new HashMap<>();
final SkillData st = SkillData.getInstance();
for (Entry<Long, L2SkillLearn> e : _heroSkillTree.entrySet())
{
tree.put(e.getKey(), st.getSkill(e.getValue().getSkillId(), e.getValue().getSkillLevel()));
}
return tree;
return _heroSkillTree.values().stream().map(entry -> SkillData.getInstance().getSkill(entry.getSkillId(), entry.getSkillLevel())).collect(Collectors.toList());
}
/**
* Gets the Game Master skill tree.
* @return the complete Game Master Skill Tree
*/
public Map<Long, Skill> getGMSkillTree()
public List<Skill> getGMSkillTree()
{
final Map<Long, Skill> tree = new HashMap<>();
final SkillData st = SkillData.getInstance();
for (Entry<Long, L2SkillLearn> e : _gameMasterSkillTree.entrySet())
{
tree.put(e.getKey(), st.getSkill(e.getValue().getSkillId(), e.getValue().getSkillLevel()));
}
return tree;
return _gameMasterSkillTree.values().stream().map(entry -> SkillData.getInstance().getSkill(entry.getSkillId(), entry.getSkillLevel())).collect(Collectors.toList());
}
/**
* Gets the Game Master Aura skill tree.
* @return the complete Game Master Aura Skill Tree
*/
public Map<Long, Skill> getGMAuraSkillTree()
public List<Skill> getGMAuraSkillTree()
{
final Map<Long, Skill> tree = new HashMap<>();
final SkillData st = SkillData.getInstance();
for (Entry<Long, L2SkillLearn> e : _gameMasterAuraSkillTree.entrySet())
{
tree.put(e.getKey(), st.getSkill(e.getValue().getSkillId(), e.getValue().getSkillLevel()));
}
return tree;
return _gameMasterAuraSkillTree.values().stream().map(entry -> SkillData.getInstance().getSkill(entry.getSkillId(), entry.getSkillLevel())).collect(Collectors.toList());
}
/**
@@ -753,7 +725,6 @@ public final class SkillTreesData implements IGameXmlReader
for (L2SkillLearn skillLearn : learnable)
{
final Skill skill = SkillData.getInstance().getSkill(skillLearn.getSkillId(), skillLearn.getSkillLevel());
// Cleanup skills that has to be removed
for (int skillId : skillLearn.getRemoveSkills())
{
@@ -1536,17 +1507,6 @@ public final class SkillTreesData implements IGameXmlReader
return _pledgeSkillTree.containsKey(hashCode) || _subPledgeSkillTree.containsKey(hashCode);
}
/**
* Checks if a skill is a Subclass change skill.
* @param skillId the Id of the skill to check
* @param skillLevel the level of the skill to check
* @return {@code true} if the skill is present in the Subclass change Skill Trees, {@code false} otherwise
*/
public boolean isSubClassChangeSkill(int skillId, int skillLevel)
{
return _subClassChangeSkillTree.containsKey(SkillData.getSkillHashCode(skillId, skillLevel));
}
public boolean isRemoveSkill(ClassId classId, int skillId)
{
return _removeSkillCache.getOrDefault(classId, Collections.emptySet()).contains(skillId);
@@ -1704,7 +1664,7 @@ public final class SkillTreesData implements IGameXmlReader
}
// Prevent accidental skill remove during reload
if (_loading)
if (_isLoading.get())
{
return true;
}
@@ -1819,7 +1779,6 @@ public final class SkillTreesData implements IGameXmlReader
{
LOGGER.info(className + ": Loaded " + commonSkills + " Common Skills to all classes.");
}
LOGGER.info(className + ": Loaded " + _subClassChangeSkillTree.size() + " Subclass change Skills.");
}
/**

View File

@@ -5104,6 +5104,19 @@ public abstract class L2Character extends L2Object implements ISkillsHolder, IDe
return CategoryData.getInstance().isInCategory(type, getId());
}
public final boolean isInOneOfCategory(CategoryType... types)
{
for (CategoryType type : types)
{
if (CategoryData.getInstance().isInCategory(type, getId()))
{
return true;
}
}
return false;
}
/**
* @return the character that summoned this NPC.
*/

View File

@@ -20,7 +20,6 @@ import java.util.List;
import java.util.Map;
import com.l2jmobius.Config;
import com.l2jmobius.gameserver.cache.HtmCache;
import com.l2jmobius.gameserver.data.xml.impl.SkillTreesData;
import com.l2jmobius.gameserver.enums.InstanceType;
import com.l2jmobius.gameserver.model.L2SkillLearn;
@@ -31,7 +30,6 @@ import com.l2jmobius.gameserver.model.base.AcquireSkillType;
import com.l2jmobius.gameserver.model.base.ClassId;
import com.l2jmobius.gameserver.network.SystemMessageId;
import com.l2jmobius.gameserver.network.serverpackets.ExAcquirableSkillListByClass;
import com.l2jmobius.gameserver.network.serverpackets.NpcHtmlMessage;
import com.l2jmobius.gameserver.network.serverpackets.SystemMessage;
public class L2NpcInstance extends L2Npc
@@ -55,11 +53,6 @@ public class L2NpcInstance extends L2Npc
setStatus(new FolkStatus(this));
}
public List<ClassId> getClassesToTeach()
{
return getTemplate().getTeachInfo();
}
/**
* Displays Skill Tree for a given player, npc and class Id.
* @param player the active character.
@@ -99,39 +92,6 @@ public class L2NpcInstance extends L2Npc
return;
}
if (!npc.getTemplate().canTeach(classId))
{
String html = "";
if (npc instanceof L2WarehouseInstance)
{
html = HtmCache.getInstance().getHtm(player.getHtmlPrefix(), "data/html/warehouse/" + npcId + "-noteach.htm");
}
final NpcHtmlMessage noTeachMsg = new NpcHtmlMessage(npc.getObjectId());
if (html == null)
{
_log.warning("Npc " + npcId + " missing noTeach html!");
noTeachMsg.setHtml("<html><body>I cannot teach you any skills.<br>You must find your current class teachers.</body></html>");
}
else
{
noTeachMsg.setHtml(html);
noTeachMsg.replace("%objectId%", String.valueOf(npc.getObjectId()));
}
player.sendPacket(noTeachMsg);
return;
}
if (((L2NpcInstance) npc).getClassesToTeach().isEmpty())
{
final NpcHtmlMessage html = new NpcHtmlMessage(npc.getObjectId());
final String sb = "<html><body>I cannot teach you. My class list is empty.<br>Ask admin to fix it. Need add my npcid and classes to skill_learn.sql.<br>NpcId:" + npcId + ", Your classId:" + player.getClassId().getId() + "</body></html>";
html.setHtml(sb);
player.sendPacket(html);
return;
}
// Normal skills, No LearnedByFS, no AutoGet skills.
final List<L2SkillLearn> skills = SkillTreesData.getInstance().getAvailableSkills(player, classId, false, false);
if (skills.isEmpty())

View File

@@ -9236,14 +9236,14 @@ public final class L2PcInstance extends L2Playable
{
if (hero && (_baseClass == _activeClass))
{
for (Skill skill : SkillTreesData.getInstance().getHeroSkillTree().values())
for (Skill skill : SkillTreesData.getInstance().getHeroSkillTree())
{
addSkill(skill, false); // Don't persist hero skills into database
}
}
else
{
for (Skill skill : SkillTreesData.getInstance().getHeroSkillTree().values())
for (Skill skill : SkillTreesData.getInstance().getHeroSkillTree())
{
removeSkill(skill, false, true); // Just remove skills from non-hero players
}
@@ -9402,24 +9402,15 @@ public final class L2PcInstance extends L2Playable
public void setNoble(boolean val)
{
final Collection<Skill> nobleSkillTree = SkillTreesData.getInstance().getNobleSkillTree().values();
if (val)
{
for (Skill skill : nobleSkillTree)
{
addSkill(skill, false);
}
SkillTreesData.getInstance().getNobleSkillAutoGetTree().forEach(skill -> addSkill(skill, false));
}
else
{
for (Skill skill : nobleSkillTree)
{
removeSkill(skill, false, true);
}
SkillTreesData.getInstance().getNobleSkillTree().forEach(skill -> removeSkill(skill, false, true));
}
_noble = val;
sendSkillList();
if (val && (getLevel() >= 99))
{

View File

@@ -36,7 +36,6 @@ import com.l2jmobius.gameserver.enums.Race;
import com.l2jmobius.gameserver.enums.Sex;
import com.l2jmobius.gameserver.model.StatsSet;
import com.l2jmobius.gameserver.model.actor.L2Character;
import com.l2jmobius.gameserver.model.base.ClassId;
import com.l2jmobius.gameserver.model.holders.DropHolder;
import com.l2jmobius.gameserver.model.holders.ItemHolder;
import com.l2jmobius.gameserver.model.interfaces.IIdentifiable;
@@ -113,8 +112,6 @@ public final class L2NpcTemplate extends L2CharTemplate implements IIdentifiable
private int _mpRewardTicks;
private MpRewardAffectType _mpRewardAffectType;
private final List<ClassId> _teachInfo = new ArrayList<>();
private List<Integer> _extendDrop;
/**
@@ -938,26 +935,6 @@ public final class L2NpcTemplate extends L2CharTemplate implements IIdentifiable
return L2NpcTemplate.isAssignableTo(obj.getClass(), clazz);
}
public boolean canTeach(ClassId classId)
{
// If the player is on a third class, fetch the class teacher information for its parent class.
if (classId.level() == 3)
{
return _teachInfo.contains(classId.getParent());
}
return _teachInfo.contains(classId);
}
public List<ClassId> getTeachInfo()
{
return _teachInfo;
}
public void addTeachInfo(List<ClassId> teachInfo)
{
_teachInfo.addAll(teachInfo);
}
public List<Integer> getExtendDrop()
{
return _extendDrop == null ? Collections.emptyList() : _extendDrop;

View File

@@ -17,10 +17,7 @@
package com.l2jmobius.gameserver.network.clientpackets;
import com.l2jmobius.commons.network.PacketReader;
import com.l2jmobius.gameserver.data.xml.impl.SkillData;
import com.l2jmobius.gameserver.data.xml.impl.SkillTreesData;
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
import com.l2jmobius.gameserver.model.skills.CommonSkill;
import com.l2jmobius.gameserver.model.skills.Skill;
import com.l2jmobius.gameserver.network.L2GameClient;
import com.l2jmobius.gameserver.network.SystemMessageId;
@@ -51,6 +48,11 @@ public final class RequestMagicSkillUse implements IClientIncomingPacket
return;
}
if (activeChar.isSpawnProtected())
{
activeChar.onActionRequest();
}
// Get the level of the used skill
Skill skill = activeChar.getKnownSkill(_magicId);
if (skill == null)
@@ -59,16 +61,9 @@ public final class RequestMagicSkillUse implements IClientIncomingPacket
skill = activeChar.getCustomSkill(_magicId);
if (skill == null)
{
if ((_magicId == CommonSkill.HAIR_ACCESSORY_SET.getId()) || SkillTreesData.getInstance().isSubClassChangeSkill(_magicId, 1))
{
skill = SkillData.getInstance().getSkill(_magicId, 1);
}
else
{
activeChar.sendPacket(ActionFailed.STATIC_PACKET);
_log.warning("Skill Id " + _magicId + " not found in player!");
return;
}
activeChar.sendPacket(ActionFailed.STATIC_PACKET);
_log.warning("Player " + activeChar + " tried to use a skill [" + _magicId + "] which hasn't been learned or it belongs to a macro of a currently inactive class.");
return;
}
}