Search in sources :

Example 1 with ChatUtils

use of net.dzikoysk.funnyguilds.shared.bukkit.ChatUtils in project FunnyGuilds by FunnyGuilds.

the class HologramUpdateHandler method run.

@Override
public void run() {
    HologramConfiguration hologramConfig = config.heart.hologram;
    if (!hologramConfig.enabled) {
        return;
    }
    ItemStack item = new ItemStack(hologramConfig.item);
    HookManager.HOLOGRAPHIC_DISPLAYS.peek(hologramManager -> {
        for (Guild guild : plugin.getGuildManager().getGuilds()) {
            Formatter formatter = Placeholders.GUILD_ALL.toFormatter(guild);
            List<String> lines = PandaStream.of(hologramConfig.displayedLines).map(formatter::format).map(ChatUtils::colored).map(line -> Placeholders.GUILD_MEMBERS_COLOR_CONTEXT.format(line, Pair.of(ChatUtils.getLastColorBefore(line, "{MEMBERS}"), guild))).toList();
            Bukkit.getScheduler().runTask(plugin, () -> hologramManager.getOrCreateHologram(guild).peek(hologram -> {
                hologram.clearHologram();
                if (hologramConfig.item != Material.AIR) {
                    hologram.addIconItem(item);
                }
                hologram.addLines(lines);
            }));
        }
    });
}
Also used : HologramConfiguration(net.dzikoysk.funnyguilds.config.sections.HologramConfiguration) PandaStream(panda.std.stream.PandaStream) HologramConfiguration(net.dzikoysk.funnyguilds.config.sections.HologramConfiguration) Placeholders(net.dzikoysk.funnyguilds.feature.placeholders.Placeholders) ItemStack(org.bukkit.inventory.ItemStack) List(java.util.List) FunnyGuilds(net.dzikoysk.funnyguilds.FunnyGuilds) Guild(net.dzikoysk.funnyguilds.guild.Guild) PluginConfiguration(net.dzikoysk.funnyguilds.config.PluginConfiguration) Pair(panda.std.Pair) Formatter(panda.utilities.text.Formatter) HookManager(net.dzikoysk.funnyguilds.feature.hooks.HookManager) ChatUtils(net.dzikoysk.funnyguilds.shared.bukkit.ChatUtils) Material(org.bukkit.Material) Bukkit(org.bukkit.Bukkit) Formatter(panda.utilities.text.Formatter) ItemStack(org.bukkit.inventory.ItemStack) Guild(net.dzikoysk.funnyguilds.guild.Guild) ChatUtils(net.dzikoysk.funnyguilds.shared.bukkit.ChatUtils)

Aggregations

List (java.util.List)1 FunnyGuilds (net.dzikoysk.funnyguilds.FunnyGuilds)1 PluginConfiguration (net.dzikoysk.funnyguilds.config.PluginConfiguration)1 HologramConfiguration (net.dzikoysk.funnyguilds.config.sections.HologramConfiguration)1 HookManager (net.dzikoysk.funnyguilds.feature.hooks.HookManager)1 Placeholders (net.dzikoysk.funnyguilds.feature.placeholders.Placeholders)1 Guild (net.dzikoysk.funnyguilds.guild.Guild)1 ChatUtils (net.dzikoysk.funnyguilds.shared.bukkit.ChatUtils)1 Bukkit (org.bukkit.Bukkit)1 Material (org.bukkit.Material)1 ItemStack (org.bukkit.inventory.ItemStack)1 Pair (panda.std.Pair)1 PandaStream (panda.std.stream.PandaStream)1 Formatter (panda.utilities.text.Formatter)1