All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.sucy.skill.tree.basic.CustomTree Maven / Gradle / Ivy

Go to download

A Minecraft Bukkit plugin aiming to provide an easy code API and skill editor for all server owners to create unique and fully custom classes and skills.

There is a newer version: 1.3.1-R1
Show newest version
package com.sucy.skill.tree.basic;

import com.sucy.skill.SkillAPI;
import com.sucy.skill.api.classes.RPGClass;
import com.sucy.skill.api.exception.SkillTreeException;
import com.sucy.skill.api.skills.Skill;
import com.sucy.skill.gui.tool.GUIData;
import com.sucy.skill.gui.tool.GUIType;
import mc.promcteam.engine.mccore.config.parse.DataSection;

import java.util.List;

public class CustomTree extends InventoryTree {
    /**
     * Constructor
     *
     * @param api  api reference
     * @param tree
     */
    public CustomTree(SkillAPI api, RPGClass tree) {
        super(api, tree);
    }

    @Override
    protected void arrange(List skills) throws SkillTreeException {
        skillSlots.clear();
        height = 3;
        DataSection section =
                SkillAPI.getConfig("gui").getConfig().getSection(GUIType.SKILL_TREE.getPrefix() + tree.getName());
        if (section == null) {
            return;
        }

        height = Math.max(1, Math.min(section.getInt(GUIData.ROWS, 3), 6));
        DataSection slotsSection = section.getSection(GUIData.SLOTS);
        if (slotsSection == null) {
            return;
        }
        for (String key : slotsSection.keys()) {
            int         page        = Integer.parseInt(key);
            DataSection pageSection = slotsSection.getSection(key);
            for (String skillName : pageSection.keys()) {
                Skill skill = SkillAPI.getSkill(skillName);
                if (skill == null) {
                    continue;
                }
                skillSlots.put(pageSection.getInt(skillName) + (page - 1) * height * 9, skill);
            }
        }
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy