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

com.sucy.skill.data.CustomScoreboardHolder 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.data;

import com.sucy.skill.SkillAPI;
import com.sucy.skill.util.PlaceholderUtil;
import mc.promcteam.engine.mccore.scoreboard.StatHolder;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;

import java.util.ArrayList;
import java.util.List;
import java.util.UUID;
import java.util.stream.Collectors;

public class CustomScoreboardHolder implements StatHolder {
    private List format;
    private UUID         id;

    public CustomScoreboardHolder(Player player) {
        this.id = player.getUniqueId();
        format = SkillAPI.getSettings().getScoreboardFormat();
    }

    @Override
    public List getNames() {
        Player player = Bukkit.getPlayer(id);
        List formattedLines = PlaceholderUtil.colorizeAndReplace(format, player)
                .stream()
//                .map(s -> {
//                    return
//                            s.length() > 16 ? s.substring(0, 16) :
//                            s;
//                })
                .collect(Collectors.toList());

        return formattedLines;
    }

    @Override
    public List getValues() {
        // Return a list just counting down from to zero from the number of lines
        List values = new ArrayList<>();
        for (int i = format.size(); i > 0; i--) {
            values.add(i);
        }
        return values;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy