mirror of
https://github.com/darksaid98/AlathranWars.git
synced 2026-12-03 14:38:56 +00:00
awa purgebars, awa load/save framework
This commit is contained in:
1 parent
95175f1057
commit
9d2b8612d2
6 files changed
+109
-7
No files matched your search
@@ -951,6 +951,7 @@ 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();
|
||||||
|
|
||||||
@@ -973,6 +974,7 @@ 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,6 +447,7 @@ 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();
|
||||||
|
|
||||||
@@ -469,6 +470,7 @@ 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();
|
||||||
|
|
||||||
|
|||||||
@@ -14,6 +14,8 @@ import me.ShermansWorld.AlathraWar.data.SiegeData;
|
|||||||
import me.ShermansWorld.AlathraWar.data.WarData;
|
import me.ShermansWorld.AlathraWar.data.WarData;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
|
import org.bukkit.NamespacedKey;
|
||||||
|
import org.bukkit.boss.BossBar;
|
||||||
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;
|
||||||
@@ -125,11 +127,71 @@ public class AdminCommands implements CommandExecutor {
|
|||||||
return modify(sender, args);
|
return modify(sender, args);
|
||||||
} else if (args[0].equalsIgnoreCase("awa")) {
|
} else if (args[0].equalsIgnoreCase("awa")) {
|
||||||
return awa(sender, args);
|
return awa(sender, args);
|
||||||
|
} else if (args[0].equalsIgnoreCase("purgebars")) {
|
||||||
|
return purgebars(sender, args);
|
||||||
|
} else if (args[0].equalsIgnoreCase("save")) {
|
||||||
|
return save(sender, args);
|
||||||
|
} else if (args[0].equalsIgnoreCase("save-all")) {
|
||||||
|
return saveAll(sender, args);
|
||||||
|
} else if (args[0].equalsIgnoreCase("load")) {
|
||||||
|
return load(sender, args);
|
||||||
|
} else if (args[0].equalsIgnoreCase("load-all")) {
|
||||||
|
return loadAll(sender, args);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static boolean purgebars(CommandSender sender, String[] args) {
|
||||||
|
for (NamespacedKey r : RaidData.getRaidBars()) {
|
||||||
|
BossBar bb = Bukkit.getBossBar(r);
|
||||||
|
if(bb != null) {
|
||||||
|
bb.setVisible(false);
|
||||||
|
bb.removeAll();
|
||||||
|
Bukkit.removeBossBar(r);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
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("&cNote: If any remain, please contact the plugin author or open an issue on GitHub."));
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static boolean save(CommandSender sender, String[] args) {
|
||||||
|
//TODO save
|
||||||
|
sender.sendMessage(Helper.Chatlabel() + Helper.color("&csave Unimplemented!"));
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static boolean saveAll(CommandSender sender, String[] args) {
|
||||||
|
//TODO save-all
|
||||||
|
sender.sendMessage(Helper.Chatlabel() + Helper.color("&csave-all Unimplemented!"));
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static boolean load(CommandSender sender, String[] args) {
|
||||||
|
//TODO load
|
||||||
|
sender.sendMessage(Helper.Chatlabel() + Helper.color("&cload Unimplemented!"));
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static boolean loadAll(CommandSender sender, String[] args) {
|
||||||
|
//TODO load-all
|
||||||
|
sender.sendMessage(Helper.Chatlabel() + Helper.color("&cload-all Unimplemented!"));
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* //force make event or war, if owner isn't defined, idk haven't decided
|
* //force make event or war, if owner isn't defined, idk haven't decided
|
||||||
|
|||||||
@@ -15,7 +15,12 @@ public class AdminTabCompletion implements TabCompleter {
|
|||||||
"force",
|
"force",
|
||||||
"help",
|
"help",
|
||||||
"info",
|
"info",
|
||||||
"modify"
|
"modify",
|
||||||
|
"purgebars",
|
||||||
|
"load",
|
||||||
|
"load-all",
|
||||||
|
"save",
|
||||||
|
"save-all"
|
||||||
});
|
});
|
||||||
|
|
||||||
List<String> type = List.of(new String[]{
|
List<String> type = List.of(new String[]{
|
||||||
@@ -186,7 +191,26 @@ public class AdminTabCompletion implements TabCompleter {
|
|||||||
} else if (args.length == 1) {
|
} else if (args.length == 1) {
|
||||||
return NameUtil.filterByStart(base, args[0]);
|
return NameUtil.filterByStart(base, args[0]);
|
||||||
} else {
|
} else {
|
||||||
if (args[0].equalsIgnoreCase("create")) {
|
|
||||||
|
if (args[0].equalsIgnoreCase("purgebars")) {
|
||||||
|
return empty;
|
||||||
|
} else if (args[0].equalsIgnoreCase("save")) {
|
||||||
|
if(args.length > 2) {
|
||||||
|
return empty;
|
||||||
|
} else {
|
||||||
|
return CommandHelper.getWarNames();
|
||||||
|
}
|
||||||
|
} else if (args[0].equalsIgnoreCase("save-all")) {
|
||||||
|
return empty;
|
||||||
|
} else if (args[0].equalsIgnoreCase("load")) {
|
||||||
|
if(args.length > 2) {
|
||||||
|
return empty;
|
||||||
|
} else {
|
||||||
|
return CommandHelper.getWarNames();
|
||||||
|
}
|
||||||
|
} else if (args[0].equalsIgnoreCase("load-all")) {
|
||||||
|
return empty;
|
||||||
|
} else if (args[0].equalsIgnoreCase("create")) {
|
||||||
if (args.length > 2) {
|
if (args.length > 2) {
|
||||||
switch (args[1]) {
|
switch (args[1]) {
|
||||||
case "raid" -> {
|
case "raid" -> {
|
||||||
|
|||||||
@@ -27,6 +27,10 @@ public class RaidData {
|
|||||||
return raidBars;
|
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;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,12 +1,9 @@
|
|||||||
package me.ShermansWorld.AlathraWar.data;
|
package me.ShermansWorld.AlathraWar.data;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.*;
|
||||||
import java.util.Collection;
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.HashSet;
|
|
||||||
import java.util.UUID;
|
|
||||||
|
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.NamespacedKey;
|
||||||
import org.bukkit.OfflinePlayer;
|
import org.bukkit.OfflinePlayer;
|
||||||
|
|
||||||
import com.palmergames.bukkit.towny.TownyAPI;
|
import com.palmergames.bukkit.towny.TownyAPI;
|
||||||
@@ -26,6 +23,17 @@ 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);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets a siege with a specific name
|
* Gets a siege with a specific name
|
||||||
* @param name - Name to check
|
* @param name - Name to check
|
||||||
|
|||||||
Reference in new issue
Block a user