/
tofu
/
l2interlude
Обзор
Документация
Войти
/
tofu
/
l2interlude
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
Аналитика
Безопасность
develop
src/main/java/com/l2jserver/gameserver/data/xml/impl/SkillLearnData.java
88 строк
3 KB
Zoey76
Copyright Update
01 янв 2025, 07:57
01 янв 2025, 07:57
16130a5
Код
Авторство
О чём код?
/* * Copyright © 2004-2025 L2J Server * * This file is part of L2J Server. * * L2J Server 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. * * L2J Server 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.l2jserver.gameserver.data.xml.impl; import java.util.HashMap; import java.util.LinkedList; import java.util.List; import java.util.Map; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.w3c.dom.Document; import com.l2jserver.gameserver.model.base.ClassId; import com.l2jserver.gameserver.util.IXmlReader; /** * Holds all skill learn data for all NPCs. * @author xban1x */ public final class SkillLearnData implements IXmlReader { private static final Logger LOG = LoggerFactory.getLogger(SkillLearnData.class); private final Map<Integer, List<ClassId>> _skillLearn = new HashMap<>(); protected SkillLearnData() { load(); } @Override public synchronized void load() { _skillLearn.clear(); parseDatapackFile("data/skillLearn.xml"); LOG.info("Loaded {} skill learn data.", _skillLearn.size()); } @Override public void parseDocument(Document doc) { for (var node = doc.getFirstChild(); node != null; node = node.getNextSibling()) { if ("list".equalsIgnoreCase(node.getNodeName())) { for (var list_node = node.getFirstChild(); list_node != null; list_node = list_node.getNextSibling()) { if ("npc".equalsIgnoreCase(list_node.getNodeName())) { final var classIds = new LinkedList<ClassId>(); for (var 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); } public static SkillLearnData getInstance() { return SingletonHolder.INSTANCE; } private static class SingletonHolder { protected static final SkillLearnData INSTANCE = new SkillLearnData(); } }