Skip to content

Commit

Permalink
Fix not deleted bossbar
Browse files Browse the repository at this point in the history
  • Loading branch information
Elikill58 committed Sep 7, 2023
1 parent 541d53f commit 9b3f07f
Showing 1 changed file with 8 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import org.bukkit.boss.BarStyle;
import org.bukkit.entity.Player;

import com.google.common.collect.Lists;
import com.leonardobishop.quests.bukkit.BukkitQuestsPlugin;

public class BossBar_Bukkit implements BossBar {
Expand All @@ -19,6 +20,13 @@ public class BossBar_Bukkit implements BossBar {

public BossBar_Bukkit(BukkitQuestsPlugin plugin) {
this.plugin = plugin;
String pluginNamespace = new NamespacedKey(plugin, "test").getNamespace(); // get namespace
Lists.newArrayList(Bukkit.getBossBars()).forEach(bb -> { // copy list to prevent current modification
if(bb.getKey().namespace().equals(pluginNamespace)) {
bb.removeAll(); // hide it
Bukkit.removeBossBar(bb.getKey()); // remove it
}
});
plugin.getScheduler().runTaskTimer(() -> {
for (Entry<NamespacedKey, Long> entry : new HashMap<>(players).entrySet()) {
if (entry.getValue() < System.currentTimeMillis()) {
Expand Down

0 comments on commit 9b3f07f

Please sign in to comment.