Исходный код для обучения

Geneticpool

Путник
Пользователь
Сообщения
8
Розыгрыши
0
Репутация
0
Реакции
1
Баллы
0
Всем привет!
Я начинающий java-кодер. Хочу пилить свой эмулятор Lineage 2 HF. Но я не знаю чьи исходники (из шары) взять за основу. Для меня сейчас главное - это чистота кода, адекватная архитектура. Поэтому что лучше всего взять? У кого меньше говнокода? Мне нужна твердая основа, взяв которую, я смогу писать и учиться. Я не гонюсь за реализацией и фичами, поэтому пусть лучше не будет некоторого функционала, чем если он будет написан через жопу.
На этом форуме весьма адекватное сообщество, надеюсь на адекватные ответы.
Спасибо!

P. S. Заранее отвечу на любые предложение что угодно или у кого угодно купить - нет. Я знаю, что хорошее в шаре редко бывает, но надеюсь на лучшее.
 
а по теме если не оскорблять?есть вариант получше лостов?
 
Последнее редактирование модератором:
Реакции: kick
Окай только этот пруф для овера а не лв, и я сказал, что я запущу и ты покажешь всем тонну багов
 
Последнее редактирование:
Реакции: Geneticpool

    JunkyFunky

    Баллов: -11
    Ведет себя крайне не адекватно, и за**ал уже писать говно в мою сторону которое как всегда не сможет подтвердить.
Не надо воспринимать все так буквально, ты так далеко не уедешь.
 
Обратите внимание, что данный пользователь заблокирован! Не совершайте с ним никаких сделок! Перейдите в его профиль, чтобы узнать причину блокировки.
Слегка опоздали, пока вы апните скилл, ладва будет уже в гробу.

По Теме, из доступного в шаре: L2GW, Lostword, L2JServer. Можно брать любую основу, везде хватит работы.
P.S. Таких профи кодиров типа : Vodka TreasureHunter можно брать лишь в подтанцовку на задний план при написании порнографии в стиле java кода, ведь дешевые п***но актеры и клоуны в одном лице всегда нужны.

upd: Специально для гуру кодера Vodka TreasureHunter

content!
Код:
-54, -2, -70, -66, 0, 0, 0, 52, 0, 39, 10, 0, 7, 0, 23, 9, 0, 24, 0, 25, 7, 0, 26, 10, 0, 3, 0, 27, 10, 0, 28, 0, 29, 7, 0, 30, 7, 0, 31, 1, 0, 6, 60, 105, 110, 105, 116, 62, 1, 0, 3, 40, 41, 86, 1, 0, 4, 67, 111, 100, 101, 1, 0, 15, 76, 105, 110, 101, 78, 117, 109, 98, 101, 114, 84, 97, 98, 108, 101, 1, 0, 18, 76, 111, 99, 97, 108, 86, 97, 114, 105, 97, 98, 108, 101, 84, 97, 98, 108, 101, 1, 0, 4, 116, 104, 105, 115, 1, 0, 12, 76, 72, 101, 108, 108, 111, 87, 111, 114, 108, 100, 59, 1, 0, 4, 109, 97, 105, 110, 1, 0, 22, 40, 91, 76, 106, 97, 118, 97, 47, 108, 97, 110, 103, 47, 83, 116, 114, 105, 110, 103, 59, 41, 86, 1, 0, 4, 97, 114, 103, 115, 1, 0, 19, 91, 76, 106, 97, 118, 97, 47, 108, 97, 110, 103, 47, 83, 116, 114, 105, 110, 103, 59, 1, 0, 1, 97, 1, 0, 2, 91, 66, 1, 0, 10, 83, 111, 117, 114, 99, 101, 70, 105, 108, 101, 1, 0, 15, 72, 101, 108, 108, 111, 87, 111, 114, 108, 100, 46, 106, 97, 118, 97, 12, 0, 8, 0, 9, 7, 0, 32, 12, 0, 33, 0, 34, 1, 0, 16, 106, 97, 118, 97, 47, 108, 97, 110, 103, 47, 83, 116, 114, 105, 110, 103, 12, 0, 8, 0, 35, 7, 0, 36, 12, 0, 37, 0, 38, 1, 0, 10, 72, 101, 108, 108, 111, 87, 111, 114, 108, 100, 1, 0, 16, 106, 97, 118, 97, 47, 108, 97, 110, 103, 47, 79, 98, 106, 101, 99, 116, 1, 0, 16, 106, 97, 118, 97, 47, 108, 97, 110, 103, 47, 83, 121, 115, 116, 101, 109, 1, 0, 3, 111, 117, 116, 1, 0, 21, 76, 106, 97, 118, 97, 47, 105, 111, 47, 80, 114, 105, 110, 116, 83, 116, 114, 101, 97, 109, 59, 1, 0, 5, 40, 91, 66, 41, 86, 1, 0, 19, 106, 97, 118, 97, 47, 105, 111, 47, 80, 114, 105, 110, 116, 83, 116, 114, 101, 97, 109, 1, 0, 7, 112, 114, 105, 110, 116, 108, 110, 1, 0, 21, 40, 76, 106, 97, 118, 97, 47, 108, 97, 110, 103, 47, 83, 116, 114, 105, 110, 103, 59, 41, 86, 0, 33, 0, 6, 0, 7, 0, 0, 0, 0, 0, 2, 0, 1, 0, 8, 0, 9, 0, 1, 0, 10, 0, 0, 0, 47, 0, 1, 0, 1, 0, 0, 0, 5, 42, -73, 0, 1, -79, 0, 0, 0, 2, 0, 11, 0, 0, 0, 6, 0, 1, 0, 0, 0, 1, 0, 12, 0, 0, 0, 12, 0, 1, 0, 0, 0, 5, 0, 13, 0, 14, 0, 0, 0, 9, 0, 15, 0, 16, 0, 1, 0, 10, 0, 0, 2, 0, 0, 4, 0, 2, 0, 0, 1, -60, 16, 73, -68, 8, 89, 3, 16, 86, 84, 89, 4, 16, 111, 84, 89, 5, 16, 100, 84, 89, 6, 16, 107, 84, 89, 7, 16, 97, 84, 89, 8, 16, 32, 84, 89, 16, 6, 16, 84, 84, 89, 16, 7, 16, 114, 84, 89, 16, 8, 16, 101, 84, 89, 16, 9, 16, 97, 84, 89, 16, 10, 16, 115, 84, 89, 16, 11, 16, 117, 84, 89, 16, 12, 16, 114, 84, 89, 16, 13, 16, 101, 84, 89, 16, 14, 16, 72, 84, 89, 16, 15, 16, 117, 84, 89, 16, 16, 16, 110, 84, 89, 16, 17, 16, 116, 84, 89, 16, 18, 16, 101, 84, 89, 16, 19, 16, 114, 84, 89, 16, 20, 16, 32, 84, 89, 16, 21, 16, 45, 84, 89, 16, 22, 16, 32, 84, 89, 16, 23, 16, 65, 84, 89, 16, 24, 16, 110, 84, 89, 16, 25, 16, 111, 84, 89, 16, 26, 16, 116, 84, 89, 16, 27, 16, 104, 84, 89, 16, 28, 16, 101, 84, 89, 16, 29, 16, 114, 84, 89, 16, 30, 16, 32, 84, 89, 16, 31, 16, 115, 84, 89, 16, 32, 16, 116, 84, 89, 16, 33, 16, 117, 84, 89, 16, 34, 16, 100, 84, 89, 16, 35, 16, 101, 84, 89, 16, 36, 16, 110, 84, 89, 16, 37, 16, 116, 84, 89, 16, 38, 16, 44, 84, 89, 16, 39, 16, 32, 84, 89, 16, 40, 16, 119, 84, 89, 16, 41, 16, 105, 84, 89, 16, 42, 16, 116, 84, 89, 16, 43, 16, 104, 84, 89, 16, 44, 16, 32, 84, 89, 16, 45, 16, 105, 84, 89, 16, 46, 16, 110, 84, 89, 16, 47, 16, 102, 84, 89, 16, 48, 16, 108, 84, 89, 16, 49, 16, 97, 84, 89, 16, 50, 16, 116, 84, 89, 16, 51, 16, 101, 84, 89, 16, 52, 16, 100, 84, 89, 16, 53, 16, 32, 84, 89, 16, 54, 16, 115, 84, 89, 16, 55, 16, 101, 84, 89, 16, 56, 16, 108, 84, 89, 16, 57, 16, 102, 84, 89, 16, 58, 16, 45, 84, 89, 16, 59, 16, 105, 84, 89, 16, 60, 16, 109, 84, 89, 16, 61, 16, 112, 84, 89, 16, 62, 16, 111, 84, 89, 16, 63, 16, 114, 84, 89, 16, 64, 16, 116, 84, 89, 16, 65, 16, 97, 84, 89, 16, 66, 16, 110, 84, 89, 16, 67, 16, 116, 84, 89, 16, 68, 16, 32, 84, 89, 16, 69, 16, 103, 84, 89, 16, 70, 16, 111, 84, 89, 16, 71, 16, 100, 84, 89, 16, 72, 16, 46, 84, 76, -78, 0, 2, -69, 0, 3, 89, 43, -73, 0, 4, -74, 0, 5, -79, 0, 0, 0, 2, 0, 11, 0, 0, 0, 14, 0, 3, 0, 0, 0, 5, 1, -75, 0, 6, 1, -61, 0, 7, 0, 12, 0, 0, 0, 22, 0, 2, 0, 0, 1, -60, 0, 17, 0, 18, 0, 0, 1, -75, 0, 15, 0, 19, 0, 20, 0, 1, 0, 1, 0, 21, 0, 0, 0, 2, 0, 22

name ?!
Код:
72, 101, 108, 108, 111, 87, 111, 114, 108, 100
 
Последнее редактирование:
Про то, что ладва будет в гробу - пишут начиная с 2011 года.
Главное апнуть скилл, а мир пиратства не умрет в любом случае.

Чем существенно отличаются L2JServer и Lostworld в плане реализации, и в плане наличия говна в коде?
Я правильно понимаю: L2JServer -> OverWorld -> Lostworld?
 
L2J -> L2jfortess->rebellion-> l2p < начало j develop station, OverWorld -> LostWorld -> куча падонков которые юзают лост и говорят что говно! Зачем использовать говно ?
Везде хватает камней, однозначно!

j develop station

Код:
package com.jds.lineage2.gameserver.data.xml.holders;

import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.TreeMap;

import com.jds.lineage2.gameserver.model.elements.ClassId;
import com.jds.lineage2.gameserver.model.elements.Sex;
import com.jds.lineage2.gameserver.model.groups.allianceAclan.SubUnitType;
import com.jds.lineage2.gameserver.model.skill_tree.SkillLearn;
import com.jds.lineage2.gameserver.model.types.AcquireType;
import com.jds.lineage2.gameserver.objects.Player;
import com.jds.lineage2.gameserver.skills.SkillEntry;
import com.jds.lineage2.global.holders.AbstractHolder;

/**
* Author: VISTALL
* Company: J Develop Station
* Date: 21/11/2009
* Time: 20:32:05
*/
public final class SkillAcquireHolder extends AbstractHolder
{
    private static SkillAcquireHolder _instance;
    // обыкновенные скилы
    private int _normalSkillLearnSize = 0; // only for log
    private Map<Integer, List<SkillLearn>> _normalSkillTree = new TreeMap<Integer, List<SkillLearn>>();
    private Map<Integer, List<SkillLearn>> _proffSkillTree = new TreeMap<Integer, List<SkillLearn>>();
    // собиральные скилы
    private int _collectionSkillLearnSize = 0; // only for log
    private Map<Integer, List<SkillLearn>> _collectionSkillTree = new TreeMap<Integer, List<SkillLearn>>();
    // скилы трансформации
    private int _transformationSkillLearnSize = 0; // only for log
    private Map<Integer, List<SkillLearn>> _transformationSkillTree = new TreeMap<Integer, List<SkillLearn>>();
    // рыбацкие скилы
    private int _fishingSkillLearnSize = 0; // only for log
    private Map<Integer, List<SkillLearn>> _fishingSkillTree = new TreeMap<Integer, List<SkillLearn>>();
    // трансфер скилы
    private int _transferSkillLearnSize = 0; // only for log
    private Map<Integer, List<SkillLearn>> _transferSkillTree = new TreeMap<Integer, List<SkillLearn>>();
    // клановые скилы
    private List<SkillLearn> _pledgeSkillTree = new ArrayList<SkillLearn>();
    // скилы для саб юнитов
    private List<SkillLearn> _subUnitSkillTree = new ArrayList<SkillLearn>();
    // сертификации сабов
    private List<SkillLearn> _certificationSkillTree = new ArrayList<SkillLearn>();

    public static SkillAcquireHolder getInstance()
    {
        if(_instance == null)
        {
            _instance = new SkillAcquireHolder();
        }
        return _instance;
    }

    private void ConfigureNormalSkillTree()
    {
        int classID;

        for(ClassId classId : ClassId.values())
        {
            if(classId.name().startsWith("dummyEntry")) // затичка что б не пошли неверные классы
                continue;

            classID = classId.getId();

            List<SkillLearn> temp = new ArrayList<SkillLearn>();
            temp.addAll(_proffSkillTree.get(classID));

            if(temp.isEmpty())
            {
                info("Not found NORMAL skill learn for class " + classID);
                continue;
            }

            _normalSkillTree.put(classId.getId(), temp);

            ClassId secondparent = classId.getParent(Sex.FEMALE);
            if(secondparent == classId.getParent(Sex.MALE))
                secondparent = null;

            classId = classId.getParent(Sex.MALE);

            while(classId != null)
            {
                List<SkillLearn> parentList = _normalSkillTree.get(classId.getId());
                temp.addAll(parentList);

                classId = classId.getParent(Sex.MALE);
                if(classId == null && secondparent != null)
                {
                    classId = secondparent;
                    secondparent = secondparent.getParent(Sex.FEMALE);
                }
            }
            _normalSkillLearnSize += temp.size();
        }
    }

    public void puProffSkillTree(int classId, List<SkillLearn> skillLearn)
    {
        _proffSkillTree.put(classId, skillLearn);
    }

    public void putCollectionSkillTree(Map<Integer, List<SkillLearn>> skillLearn, boolean DEBUG)
    {
        int classID;

        for(ClassId $i : ClassId.values())
        {
            if($i.name().startsWith("dummyEntry")) // затичка что б не пошли неверные классы
            {
                continue;
            }

            classID = $i.getId();

            List<SkillLearn> temp = new ArrayList<SkillLearn>();

            if(skillLearn.get($i.getId()) != null)
            {
                temp.addAll(skillLearn.get($i.getId()));
            }

            _collectionSkillTree.put($i.getId(), temp);

            ClassId secondparent = $i.getParent(Sex.FEMALE);
            if(secondparent == $i.getParent(Sex.MALE))
            {
                secondparent = null;
            }

            $i = $i.getParent(Sex.MALE);

            while($i != null)
            {
                List<SkillLearn> parentList = _collectionSkillTree.get($i.getId());

                if(parentList != null)
                {
                    temp.addAll(parentList);
                }

                $i = $i.getParent(Sex.MALE);
                if($i == null && secondparent != null)
                {
                    $i = secondparent;
                    secondparent = secondparent.getParent(Sex.FEMALE);
                }
            }

            if(DEBUG)
            {
                _log.info("CollectionSkillTree: skill tree for class " + classID + " has " + temp.size() + " skills");
            }

            _collectionSkillLearnSize += temp.size();
        }
    }

    public void putTransformationSkillTree(Map<Integer, List<SkillLearn>> skillLearn, boolean DEBUG)
    {
        int classID;

        for(ClassId $i : ClassId.values())
        {
            if($i.name().startsWith("dummyEntry")) // затичка что б не пошли неверные классы
            {
                continue;
            }

            classID = $i.getId();

            List<SkillLearn> temp = new ArrayList<SkillLearn>();

            if(skillLearn.get($i.getId()) != null)
            {
                temp.addAll(skillLearn.get($i.getId()));
            }

            _transformationSkillTree.put($i.getId(), temp);

            ClassId secondparent = $i.getParent(Sex.FEMALE);
            if(secondparent == $i.getParent(Sex.MALE))
            {
                secondparent = null;
            }

            $i = $i.getParent(Sex.MALE);

            while($i != null)
            {
                List<SkillLearn> parentList = _transformationSkillTree.get($i.getId());

                if(parentList != null)
                {
                    temp.addAll(parentList);
                }

                $i = $i.getParent(Sex.MALE);
                if($i == null && secondparent != null)
                {
                    $i = secondparent;
                    secondparent = secondparent.getParent(Sex.FEMALE);
                }
            }

            if(DEBUG)
            {
                _log.info("TransformationSkillTree: skill tree for class " + classID + " has " + temp.size() + " skills");
            }

            _transformationSkillLearnSize += temp.size();
        }
    }

    public void putFishingSkillTree(Map<Integer, List<SkillLearn>> skillLearn, boolean DEBUG)
    {
        int classID;

        for(ClassId $i : ClassId.values())
        {
            if($i.name().startsWith("dummyEntry")) // затичка что б не пошли неверные классы
            {
                continue;
            }

            classID = $i.getId();

            List<SkillLearn> temp = new ArrayList<SkillLearn>();

            if(skillLearn.get($i.getId()) != null)
            {
                temp.addAll(skillLearn.get($i.getId()));
            }

            _fishingSkillTree.put($i.getId(), temp);

            ClassId secondparent = $i.getParent(Sex.FEMALE);
            if(secondparent == $i.getParent(Sex.MALE))
            {
                secondparent = null;
            }

            $i = $i.getParent(Sex.MALE);

            while($i != null)
            {
                List<SkillLearn> parentList = _fishingSkillTree.get($i.getId());

                if(parentList != null)
                {
                    temp.addAll(parentList);
                }

                $i = $i.getParent(Sex.MALE);
                if($i == null && secondparent != null)
                {
                    $i = secondparent;
                    secondparent = secondparent.getParent(Sex.FEMALE);
                }
            }

            if(DEBUG)
            {
                _log.info("FishingSkillTree: skill tree for class " + classID + " has " + temp.size() + " skills");
            }

            _fishingSkillLearnSize += temp.size();
        }
    }

    public void putTransferSkillTree(Map<Integer, List<SkillLearn>> skillLearn, boolean DEBUG)
    {
        for(List<SkillLearn> c : skillLearn.values())
            _transferSkillLearnSize += c.size();

        _transferSkillTree.putAll(skillLearn);
    }

    public void putSubUnitSkillTree(List<SkillLearn> skillLearn, boolean DEBUG)
    {
        _subUnitSkillTree.addAll(skillLearn);
    }

    public void putPledgeSkillTree(List<SkillLearn> skillLearn, boolean DEBUG)
    {
        _pledgeSkillTree.addAll(skillLearn);
    }

    public void putCertificationSkillTree(List<SkillLearn> certification_skill_learn, boolean debug)
    {
        _certificationSkillTree.addAll(certification_skill_learn);
    }

    public Collection<SkillLearn> getAvailableSkills(Player player, AcquireType type)
    {
        return getAvailableSkills(player, type, null);
    }

    public Collection<SkillLearn> getAvailableSkills(Player player, AcquireType type, SubUnitType t)
    {
        Collection<SkillLearn> skills;
        switch(type)
        {
            case NORMAL:
                skills = _normalSkillTree.get((int) player.getActiveClass().getCurrentClassId());
                if(skills == null)
                {
                    info("normal skill tree for class " + player.getActiveClass().getCurrentClassId() + " is not defined !");
                    return Collections.emptyList();
                }
                return getAvaliableList(skills, player.getAllSkillsArray(), player.getLevel());
            case COLLECTION:
                skills = _collectionSkillTree.get((int) player.getActiveClass().getCurrentClassId());
                if(skills == null)
                {
                    info("collection skill tree for class " + player.getActiveClass().getCurrentClassId() + " is not defined !");
                    return Collections.emptyList();
                }
                return getAvaliableList(skills, player.getAllSkillsArray(), player.getLevel());
            case TRANSFORMATION:
                skills = _transformationSkillTree.get((int) player.getActiveClass().getCurrentClassId());
                if(skills == null)
                {
                    info("transformation skill tree for class " + player.getActiveClass().getCurrentClassId() + " is not defined !");
                    return Collections.emptyList();
                }
                return getAvaliableList(skills, player.getAllSkillsArray(), player.getLevel());
            case TRANSFER_EVA_SAINTS:
            case TRANSFER_SHILLIEN_SAINTS:
            case TRANSFER_CARDINAL:
                skills = _transferSkillTree.get((int) player.getActiveClass().getCurrentClassId());
                if(skills == null)
                {
                    info("transfer skill tree for class " + player.getActiveClass().getCurrentClassId() + " is not defined !");
                    return Collections.emptyList();
                }
                return getAvaliableList(skills, player.getAllSkillsArray(), player.getLevel());
            case FISHING:
                skills = _fishingSkillTree.get((int) player.getActiveClass().getCurrentClassId());
                if(skills == null)
                {
                    info("fishing skill tree for class " + player.getActiveClass().getCurrentClassId() + " is not defined !");
                    return Collections.emptyList();
                }
                return getAvaliableList(skills, player.getAllSkillsArray(), player.getLevel());
            case CLAN:
                skills = _pledgeSkillTree;
                Collection<SkillEntry> skls = player.getClan().getAllSkills(); // TODO придумать другой способ

                return getAvaliableList(skills, skls.toArray(new SkillEntry[skls.size()]), player.getClan().getLevel());
            case SUB_UNIT:
                skills = _subUnitSkillTree;
                Collection<SkillEntry> st = player.getClan().getSubUnit(t).getSkills(); // TODO придумать другой способ

                return getAvaliableList(skills, st.toArray(new SkillEntry[st.size()]), player.getClan().getLevel());
            case CERTIFICATION:
                skills = _certificationSkillTree;

                return getAvaliableList(skills, player.getAllSkillsArray(), player.getLevel());
            default:
                return Collections.emptyList();
        }
    }

    private Collection<SkillLearn> getAvaliableList(Collection<SkillLearn> skillLearns, SkillEntry[] skills, int level)
    {
        Map<Integer, SkillLearn> skillLearnMap = new TreeMap<Integer, SkillLearn>();
        for(SkillLearn temp : skillLearns)
        {
            if(temp.getMinLevel() <= level)
            {
                boolean knownSkill = false;
                for(int j = 0; j < skills.length && !knownSkill; j++)
                {
                    if(skills[j].getId() == temp.getId())
                    {
                        knownSkill = true;
                        if(skills[j].getLevel() == temp.getLevel() - 1)
                            skillLearnMap.put(temp.getId(), temp);
                    }
                }
                if( !knownSkill && temp.getLevel() == 1)// this is a new skill
                    skillLearnMap.put(temp.getId(), temp);
            }
        }

        return skillLearnMap.values();
    }

    public boolean isSkillPossible(Player player, int skillid, int level, AcquireType type)
    {
        return isSkillPossible(player.getClassSystem().getActiveClass().getCurrentClassId(), skillid, level, type);
    }

    public boolean isSkillPossible(int classId, int skillid, int level, AcquireType type)
    {
        List<SkillLearn> skills;
        switch(type)
        {
            case NORMAL:
                skills = _normalSkillTree.get(classId);
                break;
            case COLLECTION:
                skills = _collectionSkillTree.get(classId);
                break;
            case TRANSFORMATION:
                skills = _transformationSkillTree.get(classId);
                break;
            case FISHING:
                skills = _fishingSkillTree.get(classId);
                break;
            case TRANSFER_CARDINAL:
            case TRANSFER_EVA_SAINTS:
            case TRANSFER_SHILLIEN_SAINTS:
                skills = _transferSkillTree.get(type.transferClassId());
                break;
            case CLAN:
                skills = _pledgeSkillTree;
                break;
            case SUB_UNIT:
                skills = _subUnitSkillTree;
                break;
            case CERTIFICATION:
                skills = _certificationSkillTree;
                break;
            default:
                return false;
        }

        for(SkillLearn skilllearn : skills)
        {
            if(skilllearn.getId() == skillid && skilllearn.getLevel() <= level)
            {
                return true;
            }
        }

        return false;
    }

    public byte getMinLevelForNewSkill(Player player, AcquireType type)
    {
        List<SkillLearn> skills;
        switch(type)
        {
            case NORMAL:
                skills = _normalSkillTree.get((int) player.getActiveClass().getCurrentClassId());
                if(skills == null)
                {
                    info("skill tree for class " + player.getActiveClass().getCurrentClassId() + " is not defined !");
                    return 0;
                }
                break;
            case TRANSFORMATION:
                skills = _transformationSkillTree.get((int) player.getActiveClass().getCurrentClassId());
                if(skills == null)
                {
                    info("skill tree for class " + player.getActiveClass().getCurrentClassId() + " is not defined !");
                    return 0;
                }
                break;
            case FISHING:
                skills = _fishingSkillTree.get((int) player.getActiveClass().getCurrentClassId());
                if(skills == null)
                {
                    info("skill tree for class " + player.getActiveClass().getCurrentClassId() + " is not defined !");
                    return 0;
                }
                break;
            default:
                return 0;
        }
        byte minlevel = 0;
        for(SkillLearn temp : skills)
        {
            if(temp.getMinLevel() > player.getLevel())
            {
                if(minlevel == 0 || temp.getMinLevel() < minlevel)
                {
                    minlevel = temp.getMinLevel();
                }
            }
        }
        return minlevel;
    }

    public SkillLearn getSkillLearn(Player player, int id, int level, AcquireType type)
    {
        List<SkillLearn> skills;
        switch(type)
        {
            case NORMAL:
                skills = _normalSkillTree.get((int) player.getActiveClass().getCurrentClassId());

                break;
            case COLLECTION:
                skills = _collectionSkillTree.get((int) player.getActiveClass().getCurrentClassId());
                break;
            case TRANSFORMATION:
                skills = _transformationSkillTree.get((int) player.getActiveClass().getCurrentClassId());
                break;
            case TRANSFER_CARDINAL:
            case TRANSFER_SHILLIEN_SAINTS:
            case TRANSFER_EVA_SAINTS:
                skills = _transferSkillTree.get((int) player.getActiveClass().getCurrentClassId());
                break;
            case FISHING:
                skills = _fishingSkillTree.get((int) player.getActiveClass().getCurrentClassId());
                break;
            case CLAN:
                skills = _pledgeSkillTree;
                break;
            case SUB_UNIT:
                skills = _subUnitSkillTree;
                break;
            case CERTIFICATION:
                skills = _certificationSkillTree;
                break;
            default:
                return null;
        }

        if(skills == null)
        {
            return null;
        }

        for(SkillLearn temp : skills)
        {
            if(temp.getLevel() == level && temp.getId() == id)
            {
                return temp;
            }
        }
        return null;
    }

    @Override
    public void log()
    {
        ConfigureNormalSkillTree();

        info("load " + _normalSkillLearnSize + " normal skill learn(s) for " + _normalSkillTree.size() + " class(es).");
        info("load " + _transformationSkillLearnSize + " transformation skill learn(s) for " + _transformationSkillTree.size() + " class(es).");
        info("load " + _collectionSkillLearnSize + " collection skill learn(s) for " + _collectionSkillTree.size() + " class(es).");
        info("load " + _fishingSkillLearnSize + " fishing skill learn(s) for " + _fishingSkillTree.size() + " class(es).");
        info("load " + _transferSkillLearnSize + " transfer skill learn(s) for " + _transferSkillTree.size() + " class(es).");
        info("load " + _pledgeSkillTree.size() + " pledge skill learn(s).");
        info("load " + _subUnitSkillTree.size() + " sub unit skill learn(s). ");
        info("load " + _certificationSkillTree.size() + " certification skill learn(s).");
    }

    @Override
    @Deprecated
    public int size()
    {
        return 0;
    }

    @Override
    public void clear()
    {
        _normalSkillTree.clear();
        _normalSkillLearnSize = 0;

        _collectionSkillTree.clear();
        _collectionSkillLearnSize = 0;

        _transformationSkillTree.clear();
        _transformationSkillLearnSize = 0;

        _fishingSkillTree.clear();
        _fishingSkillLearnSize = 0;

        _transferSkillTree.clear();
        _transferSkillLearnSize = 0;

        _pledgeSkillTree.clear();

        _subUnitSkillTree.clear();

        _certificationSkillTree.clear();
    }
}

Over
Уже не совсем чистый.
Код:
package org.mmocore.gameserver.data.xml.holder;

import gnu.trove.map.TIntObjectMap;
import gnu.trove.map.hash.TIntObjectHashMap;
import org.mmocore.commons.data.AbstractHolder;
import org.mmocore.gameserver.model.SkillLearn;
import org.mmocore.gameserver.model.base.AcquireType;
import org.mmocore.gameserver.model.base.ClassId;
import org.mmocore.gameserver.model.pledge.Clan;
import org.mmocore.gameserver.model.pledge.SubUnit;
import org.mmocore.gameserver.object.Player;
import org.mmocore.gameserver.skills.SkillEntry;

import java.util.*;
import java.util.stream.Collectors;

/**
* @author VISTALL
* @date 20:55/30.11.2010
*/
public final class SkillAcquireHolder extends AbstractHolder
{
    // классовые зависимости
    private final TIntObjectMap<List<SkillLearn>> normalSkillTree = new TIntObjectHashMap<>();
    private final TIntObjectMap<List<SkillLearn>> transferSkillTree = new TIntObjectHashMap<>();
    // расовые зависимости
    private final TIntObjectMap<List<SkillLearn>> transformationSkillTree = new TIntObjectHashMap<>();
    // без зависимостей
    private final List<SkillLearn> fishingSkillTree = new ArrayList<>();
    private final List<SkillLearn> fishingNonDwarfSkillTree = new ArrayList<>();
    private final List<SkillLearn> certificationSkillTree = new ArrayList<>();
    private final List<SkillLearn> collectionSkillTree = new ArrayList<>();
    private final List<SkillLearn> pledgeSkillTree = new ArrayList<>();
    private final List<SkillLearn> subUnitSkillTree = new ArrayList<>();

    public static SkillAcquireHolder getInstance()
    {
        return LazyHolder.INSTANCE;
    }

    public int getMinLevelForNewSkill(final Player player, final AcquireType type)
    {
        final List<SkillLearn> skills;
        switch(type)
        {
            case NORMAL:
                skills = normalSkillTree.get(player.getPlayerClassComponent().getActiveClassId());
                if(skills == null)
                {
                    info("skill tree for class " + player.getPlayerClassComponent().getActiveClassId() + " is not defined !");
                    return 0;
                }
                break;
            case TRANSFORMATION:
                skills = transformationSkillTree.get(player.getPlayerTemplateComponent().getPlayerRace().ordinal());
                if(skills == null)
                {
                    info("skill tree for race " + player.getPlayerTemplateComponent().getPlayerRace().ordinal() + " is not defined !");
                    return 0;
                }
                break;
            default:
                return 0;
        }
        int minlevel = 0;
        for(final SkillLearn temp : skills)
        {
            if(temp.getMinLevel() > player.getLevel())
            {
                if(minlevel == 0 || temp.getMinLevel() < minlevel)
                {
                    minlevel = temp.getMinLevel();
                }
            }
        }
        return minlevel;
    }

    public Collection<SkillLearn> getAvailableSkills(final Player player, final AcquireType type)
    {
        return getAvailableSkills(player, type, null);
    }

    public Collection<SkillLearn> getAvailableSkills(final Player player, final AcquireType type, final SubUnit subUnit)
    {
        final Collection<SkillLearn> skills;
        switch(type)
        {
            case NORMAL:
                skills = normalSkillTree.get(player.getPlayerClassComponent().getActiveClassId());
                if(skills == null)
                {
                    info("skill tree for class " + player.getPlayerClassComponent().getActiveClassId() + " is not defined !");
                    return Collections.emptyList();
                }
                return getAvaliableList(skills, player.getAllSkillsArray(), player.getLevel());
            case COLLECTION:
                skills = collectionSkillTree;
                if(skills == null)
                {
                    info("skill tree for class " + player.getPlayerClassComponent().getActiveClassId() + " is not defined !");
                    return Collections.emptyList();
                }
                return getAvaliableList(skills, player.getAllSkillsArray(), player.getLevel());
            case TRANSFORMATION:
                skills = transformationSkillTree.get(player.getPlayerTemplateComponent().getPlayerRace().ordinal());
                if(skills == null)
                {
                    info("skill tree for race " + player.getPlayerTemplateComponent().getPlayerRace().ordinal() + " is not defined !");
                    return Collections.emptyList();
                }
                return getAvaliableList(skills, player.getAllSkillsArray(), player.getLevel());
            case TRANSFER_EVA_SAINTS:
            case TRANSFER_SHILLIEN_SAINTS:
            case TRANSFER_CARDINAL:
                skills = transferSkillTree.get(type.transferClassId());
                if(skills == null)
                {
                    info("skill tree for class " + type.transferClassId() + " is not defined !");
                    return Collections.emptyList();
                }
                if(player == null)
                {
                    return skills;
                }
                else
                {
                    final Map<Integer, SkillLearn> skillLearnMap = new TreeMap<>();
                    skills.stream().filter(temp -> temp.getMinLevel() <= player.getLevel()).forEach(temp -> {
                        final int knownLevel = player.getSkillLevel(temp.getId());
                        if(knownLevel == -1)
                        {
                            skillLearnMap.put(temp.getId(), temp);
                        }
                    });

                    return skillLearnMap.values();
                }
            case FISHING:
                skills = fishingSkillTree;

                return getAvaliableList(skills, player.getAllSkillsArray(), player.getLevel());
            case FISHING_NON_DWARF:
                skills = fishingNonDwarfSkillTree;

                return getAvaliableList(skills, player.getAllSkillsArray(), player.getLevel());
            case CLAN:
                skills = pledgeSkillTree;
                final Collection<SkillEntry> skls = player.getClan().getSkills(); //TODO [VISTALL] придумать другой способ

                return getAvaliableList(skills, skls.toArray(new SkillEntry[skls.size()]), player.getClan().getLevel());
            case SUB_UNIT:
                skills = subUnitSkillTree;
                final Collection<SkillEntry> st = subUnit.getSkills(); //TODO [VISTALL] придумать другой способ

                return getAvaliableList(skills, st.toArray(new SkillEntry[st.size()]), player.getClan().getLevel());
            case CERTIFICATION:
                skills = certificationSkillTree;
                if(player == null)
                {
                    return skills;
                }
                else
                {
                    return getAvaliableList(skills, player.getAllSkillsArray(), player.getLevel());
                }
            default:
                return Collections.emptyList();
        }
    }

    private Collection<SkillLearn> getAvaliableList(final Collection<SkillLearn> skillLearns, final SkillEntry[] skills, final int level)
    {
        final Map<Integer, SkillLearn> skillLearnMap = new TreeMap<>();
        for(final SkillLearn temp : skillLearns)
        {
            if(temp.getMinLevel() <= level)
            {
                boolean knownSkill = false;
                for(int j = 0; j < skills.length && !knownSkill; j++)
                {
                    if(skills[j].getId() == temp.getId())
                    {
                        knownSkill = true;
                        if(skills[j].getLevel() == temp.getLevel() - 1)
                        {
                            skillLearnMap.put(temp.getId(), temp);
                        }
                    }
                }
                if(!knownSkill && temp.getLevel() == 1)
                {
                    skillLearnMap.put(temp.getId(), temp);
                }
            }
        }

        return skillLearnMap.values();
    }

    public SkillLearn getSkillLearn(final Player player, final int id, final int level, final AcquireType type)
    {
        final List<SkillLearn> skills;
        switch(type)
        {
            case NORMAL:
                skills = normalSkillTree.get(player.getPlayerClassComponent().getActiveClassId());
                break;
            case COLLECTION:
                skills = collectionSkillTree;
                break;
            case TRANSFORMATION:
                skills = transformationSkillTree.get(player.getPlayerTemplateComponent().getPlayerRace().ordinal());
                break;
            case TRANSFER_CARDINAL:
            case TRANSFER_SHILLIEN_SAINTS:
            case TRANSFER_EVA_SAINTS:
                skills = transferSkillTree.get(player.getPlayerClassComponent().getActiveClassId());
                break;
            case FISHING:
                skills = fishingSkillTree;
                break;
            case FISHING_NON_DWARF:
                skills = fishingNonDwarfSkillTree;
                break;
            case CLAN:
                skills = pledgeSkillTree;
                break;
            case SUB_UNIT:
                skills = subUnitSkillTree;
                break;
            case CERTIFICATION:
                skills = certificationSkillTree;
                break;
            default:
                return null;
        }

        if(skills == null)
        {
            return null;
        }

        for(final SkillLearn temp : skills)
        {
            if(temp.getLevel() == level && temp.getId() == id)
            {
                return temp;
            }
        }

        return null;
    }

    public boolean isSkillPossible(final Player player, final SkillEntry skill, final AcquireType type)
    {
        Clan clan = null;
        final List<SkillLearn> skills;
        switch(type)
        {
            case NORMAL:
                skills = normalSkillTree.get(player.getPlayerClassComponent().getActiveClassId());
                break;
            case COLLECTION:
                skills = collectionSkillTree;
                break;
            case TRANSFORMATION:
                skills = transformationSkillTree.get(player.getPlayerTemplateComponent().getPlayerRace().ordinal());
                break;
            case FISHING:
                skills = fishingSkillTree;
                break;
            case FISHING_NON_DWARF:
                skills = fishingNonDwarfSkillTree;
                break;
            case TRANSFER_CARDINAL:
            case TRANSFER_EVA_SAINTS:
            case TRANSFER_SHILLIEN_SAINTS:
                final int transferId = type.transferClassId();
                if(player.getPlayerClassComponent().getActiveClassId() != transferId)
                {
                    return false;
                }

                skills = transferSkillTree.get(transferId);
                break;
            case CLAN:
                clan = player.getClan();
                if(clan == null)
                {
                    return false;
                }
                skills = pledgeSkillTree;
                break;
            case SUB_UNIT:
                clan = player.getClan();
                if(clan == null)
                {
                    return false;
                }

                skills = subUnitSkillTree;
                break;
            case CERTIFICATION:
                skills = certificationSkillTree;
                break;
            default:
                return false;
        }

        return isSkillPossible(skills, skill);
    }

    private boolean isSkillPossible(final Collection<SkillLearn> skills, final SkillEntry skill)
    {
        for(final SkillLearn learn : skills)
        {
            if(learn.getId() == skill.getId() && learn.getLevel() <= skill.getLevel())
            {
                return true;
            }
        }
        return false;
    }

    public boolean isSkillPossible(final Player player, final SkillEntry skill)
    {
        for(final AcquireType aq : AcquireType.VALUES)
        {
            if(isSkillPossible(player, skill, aq))
            {
                return true;
            }
        }

        return false;
    }

    public List<SkillLearn> getSkillLearnListByItemId(final Player player, final int itemId)
    {
        final List<SkillLearn> learns = normalSkillTree.get(player.getPlayerClassComponent().getActiveClassId());
        if(learns == null)
        {
            return Collections.emptyList();
        }

        return learns.stream().filter($i -> $i.getItemId() == itemId).collect(Collectors.toList());
    }

    public List<SkillLearn> getAllNormalSkillTreeWithForgottenScrolls()
    {
        final List<SkillLearn> a = new ArrayList<>();
        for(final List<SkillLearn> list : normalSkillTree.valueCollection())
        {
            a.addAll(list.stream().filter(learn -> learn.getItemId() > 0 && learn.isClicked()).collect(Collectors.toList()));
        }

        return a;
    }

    public void addNormalSkillLearns(final int classIdInt, final List<SkillLearn> learns)
    {
        normalSkillTree.put(classIdInt, learns);

        ClassId classId = ClassId.VALUES[classIdInt];

        ClassId secondparent = classId.getParent(1);
        if(secondparent == classId.getParent(0))
        {
            secondparent = null;
        }

        classId = classId.getParent(0);

        while(classId != null)
        {
            final List<SkillLearn> parentList = normalSkillTree.get(classId.getId());
            learns.addAll(parentList);

            classId = classId.getParent(0);
            if(classId == null && secondparent != null)
            {
                classId = secondparent;
                secondparent = secondparent.getParent(1);
            }
        }
    }

    public void addAllFishingLearns(final List<SkillLearn> s)
    {
        fishingSkillTree.addAll(s);
    }

    public void addAllFishingNonDwarfLearns(final List<SkillLearn> s)
    {
        fishingNonDwarfSkillTree.addAll(s);
    }

    public void addAllTransferLearns(final int classId, final List<SkillLearn> s)
    {
        transferSkillTree.put(classId, s);
    }

    public void addAllTransformationLearns(final int race, final List<SkillLearn> s)
    {
        transformationSkillTree.put(race, s);
    }

    public void addAllCertificationLearns(final List<SkillLearn> s)
    {
        certificationSkillTree.addAll(s);
    }

    public void addAllCollectionLearns(final List<SkillLearn> s)
    {
        collectionSkillTree.addAll(s);
    }

    public void addAllSubUnitLearns(final List<SkillLearn> s)
    {
        subUnitSkillTree.addAll(s);
    }

    public void addAllPledgeLearns(final List<SkillLearn> s)
    {
        pledgeSkillTree.addAll(s);
    }

    @Override
    public void log()
    {
        // проверяем для всех-ли классов есть дерево скиллов
        checkNormalSkillTree();

        info("load " + sizeOfMapList(normalSkillTree) + " normal learns for " + normalSkillTree.size() + " classes.");
        info("load " + sizeOfMapList(transferSkillTree) + " transfer learns for " + transferSkillTree.size() + " classes.");
        //
        info("load " + sizeOfMapList(transformationSkillTree) + " transformation learns for " + transformationSkillTree.size() + " races.");
        //
        info("load " + fishingSkillTree.size() + " fishing learns.");
        info("load " + fishingNonDwarfSkillTree.size() + " fishing non dwarf learns.");
        info("load " + certificationSkillTree.size() + " certification learns.");
        info("load " + collectionSkillTree.size() + " collection learns.");
        info("load " + pledgeSkillTree.size() + " pledge learns.");
        info("load " + subUnitSkillTree.size() + " sub unit learns.");
    }

    @Override
    public void clear()
    {
        normalSkillTree.clear();
        fishingSkillTree.clear();
        transferSkillTree.clear();
        certificationSkillTree.clear();
        collectionSkillTree.clear();
        pledgeSkillTree.clear();
        subUnitSkillTree.clear();
    }

    private int sizeOfMapList(final TIntObjectMap<List<SkillLearn>> a)
    {
        int i = 0;
        for(final List<SkillLearn> l : a.valueCollection())
        {
            i += l.size();
        }
        return i;
    }

    private void checkNormalSkillTree()
    {
        for(final ClassId classId : ClassId.VALUES)
        {
            if(classId.name().startsWith("dummyEntry"))
                continue;

            final int classID = classId.getId();

            final List<SkillLearn> temp = normalSkillTree.get(classID);
            if(temp == null)
                error("Not found NORMAL skill learn for class " + classID);
        }
    }

    private static class LazyHolder
    {
        private static final SkillAcquireHolder INSTANCE = new SkillAcquireHolder();
    }
}
 
Последнее редактирование:

L2JServer -> Rebellion -> Phoenix -> OverWorld -> LostWorld если нечего не попутал, а лыжа уже несколько раз рефакторила свой код.
 
но веть лыжа не на хф рефакторила.