From f282cd0c4dacb56c2b578d4d6d26e0214602fe5c Mon Sep 17 00:00:00 2001 From: Elias Fleckenstein Date: Wed, 7 Apr 2021 16:56:21 +0200 Subject: [PATCH] Allow bossbars to be grouped --- mods/HUD/mcl_bossbars/init.lua | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/mods/HUD/mcl_bossbars/init.lua b/mods/HUD/mcl_bossbars/init.lua index 6a3352338..504fc3aef 100644 --- a/mods/HUD/mcl_bossbars/init.lua +++ b/mods/HUD/mcl_bossbars/init.lua @@ -37,9 +37,23 @@ local last_id = 0 function mcl_bossbars.add_bar(player, def) local name = player:get_player_name() + local bars = mcl_bossbars.bars[name] local bar = {text = def.text} bar.color, bar.image = get_color_info(def.color, def.percentage) - table.insert(mcl_bossbars.bars[name], bar) + if def.dynamic then + for _, other in pairs(bars) do + if not other.id and other.color == bar.color and (other.original_text or other.text) == bar.text and other.image == bar.image then + if not other.count then + other.count = 1 + other.original_text = other.text + end + other.count = other.count + 1 + other.text = other.original_text .. " x" .. other.count + return + end + end + end + table.insert(bars, bar) if not def.dynamic then bar.raw_color = def.color bar.id = last_id + 1