purgebars fixed

This commit is contained in:
Aubri Seebauer committed 2023-04-28 19:10:28 -04:00
1 parent cd61aa175c
commit 117130f67a
5 files changed
+10 -38

No files matched your search

@@ -951,7 +951,6 @@ public class Raid {
} }
public void refreshDisplayBar() { public void refreshDisplayBar() {
RaidData.addRaidBar(bossBarKey);
BossBar bossBar = Bukkit.getBossBar(bossBarKey); BossBar bossBar = Bukkit.getBossBar(bossBarKey);
if(bossBar == null) bossBar = createNewDisplayBar(); if(bossBar == null) bossBar = createNewDisplayBar();
@@ -974,7 +973,6 @@ public class Raid {
} }
public void setupDisplayBar() { public void setupDisplayBar() {
RaidData.addRaidBar(bossBarKey);
BossBar bossBar = Bukkit.getBossBar(bossBarKey); BossBar bossBar = Bukkit.getBossBar(bossBarKey);
if(bossBar == null) bossBar = createNewDisplayBar(); if(bossBar == null) bossBar = createNewDisplayBar();
@@ -447,7 +447,6 @@ public class Siege {
} }
public void refreshDisplayBar() { public void refreshDisplayBar() {
SiegeData.addSiegeBar(bossBarKey);
BossBar bossBar = Bukkit.getBossBar(bossBarKey); BossBar bossBar = Bukkit.getBossBar(bossBarKey);
if(bossBar == null) bossBar = createNewDisplayBar(); if(bossBar == null) bossBar = createNewDisplayBar();
@@ -470,7 +469,6 @@ public class Siege {
} }
public void setupDisplayBar() { public void setupDisplayBar() {
SiegeData.addSiegeBar(bossBarKey);
BossBar bossBar = Bukkit.getBossBar(bossBarKey); BossBar bossBar = Bukkit.getBossBar(bossBarKey);
if(bossBar == null) bossBar = createNewDisplayBar(); if(bossBar == null) bossBar = createNewDisplayBar();
@@ -16,13 +16,16 @@ import org.bukkit.Bukkit;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.NamespacedKey; import org.bukkit.NamespacedKey;
import org.bukkit.boss.BossBar; import org.bukkit.boss.BossBar;
import org.bukkit.boss.KeyedBossBar;
import org.bukkit.command.Command; import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor; import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
import org.bukkit.entity.Boss;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import java.sql.Timestamp; import java.sql.Timestamp;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Iterator;
import java.util.List; import java.util.List;
import java.util.Random; import java.util.Random;
@@ -143,27 +146,17 @@ public class AdminCommands implements CommandExecutor {
} }
private static boolean purgebars(CommandSender sender, String[] args) { private static boolean purgebars(CommandSender sender, String[] args) {
for (NamespacedKey r : RaidData.getRaidBars()) { for (Iterator<KeyedBossBar> it = Bukkit.getBossBars(); it.hasNext(); ) {
BossBar bb = Bukkit.getBossBar(r); KeyedBossBar b = it.next();
if(bb != null) { if(b.getKey().getKey().contains(Main.getInstance().getName())) {
bb.setVisible(false); b.setVisible(false);
bb.removeAll(); b.removeAll();
Bukkit.removeBossBar(r); Bukkit.removeBossBar(b.getKey());
} }
} }
for (NamespacedKey r : SiegeData.getSiegeBars()) {
BossBar bb = Bukkit.getBossBar(r);
if(bb != null) {
bb.setVisible(false);
bb.removeAll();
Bukkit.removeBossBar(r);
}
}
sender.sendMessage(Helper.chatLabel() + Helper.color("&cCleared all boss bars that have been registered with AlathraWar.")); sender.sendMessage(Helper.chatLabel() + Helper.color("&cCleared all boss bars that have been registered with AlathraWar."));
sender.sendMessage(Helper.chatLabel() + Helper.color("&cNote: If any remain, please contact the plugin author or open an issue on GitHub.")); sender.sendMessage(Helper.chatLabel() + Helper.color("&cNote: If any remain, please contact the plugin author or open an issue on GitHub. The data can be found under the tag CustomBossEvents: in level.dat! You will need an NBT Editing program to delete it manually."));
sender.sendMessage(Helper.chatLabel() + Helper.color("&cThe data can be found under the tag CustomBossEvents: in level.dat!"));
sender.sendMessage(Helper.chatLabel() + Helper.color("&cYou will need an NBT Editing program to delete it manually."));
return saveAll(sender, args); return saveAll(sender, args);
} }
@@ -21,15 +21,7 @@ public class RaidData {
private static ArrayList<Raid> raids = new ArrayList<Raid>(); private static ArrayList<Raid> raids = new ArrayList<Raid>();
private static Set<NamespacedKey> raidBars = new HashSet<>();
public static Set<NamespacedKey> getRaidBars() {
return raidBars;
}
public static void addRaidBar(NamespacedKey key) {
raidBars.add(key);
}
public static ArrayList<Raid> getRaids() { public static ArrayList<Raid> getRaids() {
return raids; return raids;
@@ -23,15 +23,6 @@ public class SiegeData
return sieges; return sieges;
} }
private static Set<NamespacedKey> siegeBars = new HashSet<>();
public static Set<NamespacedKey> getSiegeBars() {
return siegeBars;
}
public static void addSiegeBar(NamespacedKey key) {
siegeBars.add(key);
}
/** /**