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);
}));
}
});
}
Aggregations