diff --git a/build.gradle.kts b/build.gradle.kts index 2320422..6aaea08 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -7,7 +7,7 @@ plugins { } group = "com.github.alathra.AlathranWars" -version = "3.0.1-SNAPSHOT" +version = "3.0.2-SNAPSHOT" description = "" java { @@ -50,23 +50,31 @@ dependencies { compileOnly("io.papermc.paper:paper-api:1.19.4-R0.1-SNAPSHOT") implementation("com.github.milkdrinkers:simplixstorage:3.2.7") - implementation("com.github.milkdrinkers:colorparser:1.0.7") + implementation("com.github.milkdrinkers:colorparser:2.0.0") { + exclude(group = "net.kyori", module = "adventure-api") + } implementation("io.github.skytasul:guardianbeam:2.3.3") compileOnly("com.github.MilkBowl:VaultAPI:1.7") - compileOnly("com.palmergames.bukkit.towny:towny:0.99.5.0") + compileOnly("com.palmergames.bukkit.towny:towny:0.99.5.5") { + exclude(group = "com.palmergames", module = "adventure") + } compileOnly("me.neznamy:tab-api:4.0.0") - implementation("dev.jorel:commandapi-bukkit-shade:9.0.3") + implementation("dev.jorel:commandapi-bukkit-shade:9.0.3") { + exclude(group = "net.kyori", module = "adventure-api") + } compileOnly("dev.jorel:commandapi-annotations:9.0.3") annotationProcessor("dev.jorel:commandapi-annotations:9.0.3") implementation("com.zaxxer:HikariCP:5.0.1") - implementation("org.mariadb.jdbc:mariadb-java-client:3.1.0") + implementation("org.mariadb.jdbc:mariadb-java-client:3.1.4") - compileOnly("me.clip:placeholderapi:2.11.3") + compileOnly("me.clip:placeholderapi:2.11.3") { + exclude(group = "me.clip.placeholderapi.libs", module = "kyori") + } } tasks { @@ -98,12 +106,18 @@ tasks { reloc("de.leonhard.storage", "storageapi") reloc("dev.jorel.commandapi", "commandapi") reloc("com.zaxxer.hikari", "hikaricp") +// reloc("org.xerial", "sqlite") +// reloc("com.mysql", "mysql") + reloc("org.mariadb.jdbc", "mariadb") reloc("io.github.skytasul", "guardianbeam") } runServer { // Configure the Minecraft version for our task. - minecraftVersion("1.20.1") + minecraftVersion("1.19.4") + jvmArgs("-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=*:5005") + systemProperty("terminal.jline", false) + systemProperty("terminal.ansi", true) } } @@ -116,7 +130,7 @@ bukkit { prefix = "AlathranWars" version = "${project.version}" description = "${project.description}" - authors = listOf("ShermansWorld", "NinjaMandalorian", "AubriTheHuman", "darksaid98") + authors = listOf("darksaid98", "ShermansWorld", "NinjaMandalorian", "AubriTheHuman") contributors = listOf() apiVersion = "1.19" diff --git a/src/main/java/com/github/alathra/AlathranWars/commands/AdminCommand.java b/deprecatedReferences/AdminCommand.java similarity index 93% rename from src/main/java/com/github/alathra/AlathranWars/commands/AdminCommand.java rename to deprecatedReferences/AdminCommand.java index f257d49..54ae831 100644 --- a/src/main/java/com/github/alathra/AlathranWars/commands/AdminCommand.java +++ b/deprecatedReferences/AdminCommand.java @@ -18,6 +18,7 @@ import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; import org.bukkit.inventory.ItemStack; import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; import java.util.List; @@ -147,9 +148,9 @@ public class AdminCommand { }*/ @NotNull - private static StringBuilder getSurrenderedTowns(War war) { - StringBuilder surrenderedTowns = new StringBuilder(); - for (Town t : war.getSurrenderedTowns()) { + private static StringBuilder getSurrenderedTowns(@NotNull War war) { + @NotNull StringBuilder surrenderedTowns = new StringBuilder(); + for (@NotNull Town t : war.getSurrenderedTowns()) { surrenderedTowns.append(t.getName()); surrenderedTowns.append(", "); } @@ -160,17 +161,11 @@ public class AdminCommand { } - private static boolean fail(CommandSender p, CommandArguments args, AdminCommandFailEnum type) throws WrapperCommandSyntaxException { + private static boolean fail(CommandSender p, CommandArguments args, @NotNull AdminCommandFailEnum type) throws WrapperCommandSyntaxException { switch (type) { - case PERMISSIONS -> { - throw CommandAPIBukkit.failWithAdventureComponent(new ColorParser(UtilsChat.getPrefix() + "You do not have permission to do this.").build()); - } - case SYNTAX -> { - throw CommandAPIBukkit.failWithAdventureComponent(new ColorParser(UtilsChat.getPrefix() + "Invalid Arguments. /alathranwarsadmin help").build()); - } - default -> { - throw CommandAPIBukkit.failWithAdventureComponent(new ColorParser(UtilsChat.getPrefix() + "Something wrong. /alathranwarsadmin help").build()); - } + case PERMISSIONS -> throw CommandAPIBukkit.failWithAdventureComponent(ColorParser.of(UtilsChat.getPrefix() + "You do not have permission to do this.").build()); + case SYNTAX -> throw CommandAPIBukkit.failWithAdventureComponent(ColorParser.of(UtilsChat.getPrefix() + "Invalid Arguments. /alathranwarsadmin help").build()); + default -> throw CommandAPIBukkit.failWithAdventureComponent(ColorParser.of(UtilsChat.getPrefix() + "Something wrong. /alathranwarsadmin help").build()); } } @@ -202,9 +197,9 @@ public class AdminCommand { .executesPlayer((Player sender, CommandArguments args) -> { // Parse item if (!(args.get("item") instanceof String argItem)) - throw CommandAPIBukkit.failWithAdventureComponent(new ColorParser(UtilsChat.getPrefix() + "Invalid item argument.").build()); + throw CommandAPIBukkit.failWithAdventureComponent(ColorParser.of(UtilsChat.getPrefix() + "Invalid item argument.").build()); - ItemStack stack; + @Nullable ItemStack stack; if (argItem.contains(Main.getInstance().getName().toLowerCase())) { stack = WarItemRegistry.getInstance().getOrNullNamespace(argItem); } else { @@ -212,7 +207,7 @@ public class AdminCommand { } if (stack == null) - throw CommandAPIBukkit.failWithAdventureComponent(new ColorParser(UtilsChat.getPrefix() + "The item is not an AlathranWars item.").build()); + throw CommandAPIBukkit.failWithAdventureComponent(ColorParser.of(UtilsChat.getPrefix() + "The item is not an AlathranWars item.").build()); // Parse amount int argAmount = (int) args.getOptional("amount").orElse(1); @@ -231,7 +226,7 @@ public class AdminCommand { argPlayer.getInventory().addItem(stack); //log - final Component name = stack.getItemMeta() == null ? new ColorParser(stack.toString()).build() : stack.getItemMeta().displayName(); + final @Nullable Component name = stack.getItemMeta() == null ? ColorParser.of(stack.toString()).build() : stack.getItemMeta().displayName(); sender.sendMessage(UtilsChat.getPrefix() + "Gave " + stack.getAmount() + "x " + name + " to " + argPlayer.getName()); Main.warLogger.log(UtilsChat.getPrefix() + "Gave " + stack.getAmount() + "x " + name + " to " + argPlayer.getName()); }); @@ -268,7 +263,7 @@ public class AdminCommand { ) .executes((CommandSender sender, CommandArguments args) -> { if (!(args.get("war") instanceof final String argWarName)) - throw CommandAPIBukkit.failWithAdventureComponent(new ColorParser(UtilsChat.getPrefix() + "You need to specify a war name.").build()); + throw CommandAPIBukkit.failWithAdventureComponent(ColorParser.of(UtilsChat.getPrefix() + "You need to specify a war name.").build()); for (War war : WarManager.getInstance().getWars()) { if (war.getName().equalsIgnoreCase(argWarName)) { @@ -292,9 +287,7 @@ public class AdminCommand { private CommandAPICommand commandLoad() { return new CommandAPICommand("load") - .executes((CommandSender sender, CommandArguments args) -> { - sender.sendMessage(new ColorParser(UtilsChat.getPrefix() + "Support for loading wars individually is currently unimplemented. Use /awa load-all instead").build()); - }); + .executes((CommandSender sender, CommandArguments args) -> sender.sendMessage(ColorParser.of(UtilsChat.getPrefix() + "Support for loading wars individually is currently unimplemented. Use /awa load-all instead").build())); /*if (args.length >= 3) { if(Boolean.parseBoolean(args[2])) { @@ -411,8 +404,8 @@ public class AdminCommand { .executesPlayer((Player p, CommandArguments args) -> SiegeCommand.siegeStart(p, args, true)), new CommandAPICommand("war") .withArguments( - CommandUtil.customTownAndNationsArgument("side1", "war", true), - CommandUtil.customTownAndNationsArgument("side2", "war", true), + CommandUtil.customTownAndNationArgument("side1", "war", true), + CommandUtil.customTownAndNationArgument("side2", "war", true), new GreedyStringArgument("warlabel") .replaceSuggestions( ArgumentSuggestions.stringCollection(info -> List.of( @@ -424,9 +417,7 @@ public class AdminCommand { ) .executesPlayer(WarCommand::warCreate) ) - .executesPlayer((Player p, CommandArguments args) -> { - fail(p, args, AdminCommandFailEnum.SYNTAX); - }); + .executesPlayer((Player p, CommandArguments args) -> fail(p, args, AdminCommandFailEnum.SYNTAX)); } private CommandAPICommand commandForce() { @@ -468,15 +459,15 @@ public class AdminCommand { ).executesPlayer((Player sender, CommandArguments args) -> { if (!(args.get("oldSiege") instanceof final String argSiegeName)) - throw CommandAPIBukkit.failWithAdventureComponent(new ColorParser(UtilsChat.getPrefix() + "You need to specify a oldSiege!").build()); + throw CommandAPIBukkit.failWithAdventureComponent(ColorParser.of(UtilsChat.getPrefix() + "You need to specify a oldSiege!").build()); final Siege oldSiege = SiegeData.getSiege(argSiegeName); if (oldSiege == null) - throw CommandAPIBukkit.failWithAdventureComponent(new ColorParser(UtilsChat.getPrefix() + "That oldSiege does not exist!").build()); + throw CommandAPIBukkit.failWithAdventureComponent(ColorParser.of(UtilsChat.getPrefix() + "That oldSiege does not exist!").build()); final War war = oldSiege.getWar(); if (war == null) - throw CommandAPIBukkit.failWithAdventureComponent(new ColorParser(UtilsChat.getPrefix() + "The war does not exist!").build()); + throw CommandAPIBukkit.failWithAdventureComponent(ColorParser.of(UtilsChat.getPrefix() + "The war does not exist!").build()); final String argSide = (String) args.getOptional("victor").orElse("none"); @@ -537,15 +528,15 @@ public class AdminCommand { ) ).executesPlayer((Player sender, CommandArguments args) -> { if (!(args.get("oldRaid") instanceof final String argRaidName)) - throw CommandAPIBukkit.failWithAdventureComponent(new ColorParser(UtilsChat.getPrefix() + "You need to specify a oldRaid name!").build()); + throw CommandAPIBukkit.failWithAdventureComponent(ColorParser.of(UtilsChat.getPrefix() + "You need to specify a oldRaid name!").build()); final OldRaid oldRaid = RaidData.getRaid(argRaidName); if (oldRaid == null) - throw CommandAPIBukkit.failWithAdventureComponent(new ColorParser(UtilsChat.getPrefix() + "That oldRaid does not exist!").build()); + throw CommandAPIBukkit.failWithAdventureComponent(ColorParser.of(UtilsChat.getPrefix() + "That oldRaid does not exist!").build()); final War war = oldRaid.getWar(); if (war == null) - throw CommandAPIBukkit.failWithAdventureComponent(new ColorParser(UtilsChat.getPrefix() + "The war does not exist!").build()); + throw CommandAPIBukkit.failWithAdventureComponent(ColorParser.of(UtilsChat.getPrefix() + "The war does not exist!").build()); final String argSide = (String) args.getOptional("victor").orElse("none"); @@ -730,12 +721,12 @@ public class AdminCommand { ) ) .executes((CommandSender sender, CommandArguments args) -> { - if (!(args.get("war") instanceof final War war)) - throw CommandAPIBukkit.failWithAdventureComponent(new ColorParser(UtilsChat.getPrefix() + "You need to specify a war!").build()); + if (!(args.get("war") instanceof final @NotNull War war)) + throw CommandAPIBukkit.failWithAdventureComponent(ColorParser.of(UtilsChat.getPrefix() + "You need to specify a war!").build()); // final War war = WarManager.getInstance().getWar(argWarName); // if (war == null) -// throw CommandAPIBukkit.failWithAdventureComponent(new ColorParser(UtilsChat.getPrefix() + "That war does not exist!").build()); +// throw CommandAPIBukkit.failWithAdventureComponent(ColorParser.of(UtilsChat.getPrefix() + "That war does not exist!").build()); sender.sendMessage(UtilsChat.getPrefix() + "Info dump for war: " + war.getName()); sender.sendMessage(UtilsChat.getPrefix() + "oOo------------===------------oOo"); @@ -747,14 +738,14 @@ public class AdminCommand { // sender.sendMessage(UtilsChat.getPrefix() + "Last Raid for Side 1: " + new Timestamp(((long) war.getLastRaidTimeSide1()) * 1000L)); // TODO // sender.sendMessage(UtilsChat.getPrefix() + "Last Raid for Side 2: " + new Timestamp(((long) war.getLastRaidTimeSide2()) * 1000L)); sender.sendMessage(UtilsChat.getPrefix() + "oOo------------===------------oOo"); - StringBuilder side1Towns = new StringBuilder(); - StringBuilder side1Players = new StringBuilder(); + @NotNull StringBuilder side1Towns = new StringBuilder(); + @NotNull StringBuilder side1Players = new StringBuilder(); - for (Town town : war.getSide1().getTowns()) { + for (@NotNull Town town : war.getSide1().getTowns()) { side1Towns.append(town.getName()); side1Towns.append(", "); } - for (Player player : war.getSide1().getPlayers()) { + for (@NotNull Player player : war.getSide1().getPlayers()) { side1Players.append(player.getName()); side1Players.append(", "); } @@ -768,8 +759,8 @@ public class AdminCommand { sender.sendMessage(UtilsChat.getPrefix() + war.getSide1() + " Players: " + side1Players); sender.sendMessage(UtilsChat.getPrefix() + "oOo------------===------------oOo"); - StringBuilder side2Towns = new StringBuilder(); - StringBuilder side2Players = new StringBuilder(); + @NotNull StringBuilder side2Towns = new StringBuilder(); + @NotNull StringBuilder side2Players = new StringBuilder(); for (Town town : war.getSide2().getTowns()) { side2Towns.append(town); @@ -789,7 +780,7 @@ public class AdminCommand { sender.sendMessage(UtilsChat.getPrefix() + war.getSide2() + " Players: " + side2Players); sender.sendMessage(UtilsChat.getPrefix() + "oOo------------===------------oOo"); - final StringBuilder surrenderedTowns = getSurrenderedTowns(war); + final @NotNull StringBuilder surrenderedTowns = getSurrenderedTowns(war); sender.sendMessage(UtilsChat.getPrefix() + "Surrendered Towns: " + surrenderedTowns); } )/*, @@ -804,11 +795,11 @@ public class AdminCommand { ) .executes((CommandSender sender, CommandArguments args) -> { // TODO Needed if (!(args.get("oldSiege") instanceof final String argSiegeName)) - throw CommandAPIBukkit.failWithAdventureComponent(new ColorParser(UtilsChat.getPrefix() + "You need to specify a oldSiege!").build()); + throw CommandAPIBukkit.failWithAdventureComponent(ColorParser.of(UtilsChat.getPrefix() + "You need to specify a oldSiege!").build()); final Siege oldSiege = SiegeData.getSiege(argSiegeName); if (oldSiege == null) - throw CommandAPIBukkit.failWithAdventureComponent(new ColorParser(UtilsChat.getPrefix() + "That oldSiege does not exist!").build()); + throw CommandAPIBukkit.failWithAdventureComponent(ColorParser.of(UtilsChat.getPrefix() + "That oldSiege does not exist!").build()); sender.sendMessage(UtilsChat.getPrefix() + "Info dump for oldSiege: " + oldSiege.getName()); @@ -855,11 +846,11 @@ public class AdminCommand { ) .executes((CommandSender sender, CommandArguments args) -> { if (!(args.get("oldRaid") instanceof final String argRaidName)) - throw CommandAPIBukkit.failWithAdventureComponent(new ColorParser(UtilsChat.getPrefix() + "You need to specify a oldRaid name!").build()); + throw CommandAPIBukkit.failWithAdventureComponent(ColorParser.of(UtilsChat.getPrefix() + "You need to specify a oldRaid name!").build()); final OldRaid oldRaid = RaidData.getRaid(argRaidName); if (oldRaid == null) - throw CommandAPIBukkit.failWithAdventureComponent(new ColorParser(UtilsChat.getPrefix() + "That oldRaid does not exist!").build()); + throw CommandAPIBukkit.failWithAdventureComponent(ColorParser.of(UtilsChat.getPrefix() + "That oldRaid does not exist!").build()); sender.sendMessage(UtilsChat.getPrefix() + "Info dump for oldRaid: " + oldRaid.getName()); sender.sendMessage(UtilsChat.getPrefix() + "oOo------------===------------oOo"); @@ -947,17 +938,17 @@ public class AdminCommand { ), new IntegerArgument("amount", 1, 10000) ).executesPlayer((Player p, CommandArguments args) -> { - if (!(args.get("action") instanceof final String argAction)) - throw CommandAPIBukkit.failWithAdventureComponent(new ColorParser(UtilsChat.getPrefix() + "You need to specify an action.").build()); + if (!(args.get("action") instanceof final @NotNull String argAction)) + throw CommandAPIBukkit.failWithAdventureComponent(ColorParser.of(UtilsChat.getPrefix() + "You need to specify an action.").build()); if (!List.of("add", "subtract", "set").contains(argAction)) - throw CommandAPIBukkit.failWithAdventureComponent(new ColorParser(UtilsChat.getPrefix() + "Invalid action.").build()); + throw CommandAPIBukkit.failWithAdventureComponent(ColorParser.of(UtilsChat.getPrefix() + "Invalid action.").build()); - if (!(args.get("war") instanceof final War war)) - throw CommandAPIBukkit.failWithAdventureComponent(new ColorParser(UtilsChat.getPrefix() + "The war does not exist!").build()); + if (!(args.get("war") instanceof final @NotNull War war)) + throw CommandAPIBukkit.failWithAdventureComponent(ColorParser.of(UtilsChat.getPrefix() + "The war does not exist!").build()); - if (!(args.get("side") instanceof final Side side)) - throw CommandAPIBukkit.failWithAdventureComponent(new ColorParser(UtilsChat.getPrefix() + "The side does not exist.").build()); + if (!(args.get("side") instanceof final @NotNull Side side)) + throw CommandAPIBukkit.failWithAdventureComponent(ColorParser.of(UtilsChat.getPrefix() + "The side does not exist.").build()); final int amount = (int) args.get("amount"); diff --git a/src/main/java/com/github/alathra/AlathranWars/commands/SiegeCommand.java b/deprecatedReferences/SiegeCommand.java similarity index 57% rename from src/main/java/com/github/alathra/AlathranWars/commands/SiegeCommand.java rename to deprecatedReferences/SiegeCommand.java index 251990e..87aff7e 100644 --- a/src/main/java/com/github/alathra/AlathranWars/commands/SiegeCommand.java +++ b/deprecatedReferences/SiegeCommand.java @@ -18,6 +18,8 @@ import dev.jorel.commandapi.executors.CommandArguments; import org.bukkit.Bukkit; import org.bukkit.OfflinePlayer; import org.bukkit.entity.Player; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; import java.time.Duration; import java.time.Instant; @@ -36,7 +38,7 @@ public class SiegeCommand { ) .executesPlayer((sender, args) -> { if (args.count() == 0) - throw CommandAPIBukkit.failWithAdventureComponent(new ColorParser(UtilsChat.getPrefix() + "Invalid Arguments. /siege help").build()); + throw CommandAPIBukkit.failWithAdventureComponent(ColorParser.of(UtilsChat.getPrefix() + "Invalid Arguments. /siege help").build()); }) .register(); } @@ -117,23 +119,23 @@ public class SiegeCommand { } - protected static void siegeStart(Player sender, CommandArguments args, boolean admin) throws WrapperCommandSyntaxException { - if (!(args.get("war") instanceof final War war)) - throw CommandAPIBukkit.failWithAdventureComponent(new ColorParser(UtilsChat.getPrefix() + "You need to specify a war.").build()); + protected static void siegeStart(@NotNull Player sender, @NotNull CommandArguments args, boolean admin) throws WrapperCommandSyntaxException { + if (!(args.get("war") instanceof final @NotNull War war)) + throw CommandAPIBukkit.failWithAdventureComponent(ColorParser.of(UtilsChat.getPrefix() + "You need to specify a war.").build()); - if (!(args.get("town") instanceof final Town town)) - throw CommandAPIBukkit.failWithAdventureComponent(new ColorParser(UtilsChat.getPrefix() + "You need to specify a town.").build()); + if (!(args.get("town") instanceof final @NotNull Town town)) + throw CommandAPIBukkit.failWithAdventureComponent(ColorParser.of(UtilsChat.getPrefix() + "You need to specify a town.").build()); //if this is admin mode use the forth arg instad of sender. //if player is null after this then force end - final Player siegeOwner = (Player) args.getOptional("leader").orElse(sender); + final @NotNull Player siegeOwner = (Player) args.getOptional("leader").orElse(sender); if (siegeOwner == null) - throw CommandAPIBukkit.failWithAdventureComponent(new ColorParser("You need to pick a valid leader.").build()); + throw CommandAPIBukkit.failWithAdventureComponent(ColorParser.of("You need to pick a valid leader.").build()); // Player participance check - Town leaderTown = TownyAPI.getInstance().getResident(siegeOwner).getTownOrNull(); - Side side = war.getTownSide(leaderTown); + @Nullable Town leaderTown = TownyAPI.getInstance().getResident(siegeOwner).getTownOrNull(); + @Nullable Side side = war.getTownSide(leaderTown); // TODO DEBUG PRINT // Main.warLogger.log("Leader Town: " + leaderTown.getName()); @@ -152,12 +154,12 @@ public class SiegeCommand { }*/ if (!war.isTownInWar(leaderTown)) { - siegeOwner.sendMessage(new ColorParser(UtilsChat.getPrefix() + "You are not in this war.").build()); - if (admin) sender.sendMessage(new ColorParser(UtilsChat.getPrefix() + "You are not in this war.").build()); + siegeOwner.sendMessage(ColorParser.of(UtilsChat.getPrefix() + "You are not in this war.").build()); + if (admin) sender.sendMessage(ColorParser.of(UtilsChat.getPrefix() + "You are not in this war.").build()); return; } else if (side.isTownSurrendered(leaderTown)) { - siegeOwner.sendMessage(new ColorParser(UtilsChat.getPrefix() + "You are under occupation.").build()); - if (admin) sender.sendMessage(new ColorParser(UtilsChat.getPrefix() + "You are under occupation.").build()); + siegeOwner.sendMessage(ColorParser.of(UtilsChat.getPrefix() + "You are under occupation.").build()); + if (admin) sender.sendMessage(ColorParser.of(UtilsChat.getPrefix() + "You are under occupation.").build()); return; } @@ -201,19 +203,19 @@ public class SiegeCommand { // Attacking own side if (side.isTownOnSide(town)) { - siegeOwner.sendMessage(new ColorParser(UtilsChat.getPrefix() + "You cannot attack your own towns.").build()); + siegeOwner.sendMessage(ColorParser.of(UtilsChat.getPrefix() + "You cannot attack your own towns.").build()); if (admin) - sender.sendMessage(new ColorParser(UtilsChat.getPrefix() + "You cannot attack your own towns.").build()); + sender.sendMessage(ColorParser.of(UtilsChat.getPrefix() + "You cannot attack your own towns.").build()); return; } - Siege siege = new Siege(war, town, siegeOwner); + @NotNull Siege siege = new Siege(war, town, siegeOwner); war.addSiege(siege); - Bukkit.broadcast(new ColorParser(UtilsChat.getPrefix() + siege.getTown() + " has been put to siege by " + siege.getAttackerSide().getName() + "!").build()); + Bukkit.broadcast(ColorParser.of(UtilsChat.getPrefix() + siege.getTown() + " has been put to siege by " + siege.getAttackerSide().getName() + "!").build()); if (admin) - sender.sendMessage(new ColorParser("Forcefully started siege from the console.").build()); + sender.sendMessage(ColorParser.of("Forcefully started siege from the console.").build()); siege.start(); // TODO Debug logs... @@ -221,39 +223,39 @@ public class SiegeCommand { // sender.sendMessage("Attacked Town: " + town.getName().toLowerCase()); } - private static void siegeStop(Player sender, CommandArguments args) throws WrapperCommandSyntaxException { - if (!(args.get("war") instanceof final War war)) - throw CommandAPIBukkit.failWithAdventureComponent(new ColorParser(UtilsChat.getPrefix() + "You need to specify a war.").build()); + private static void siegeStop(@NotNull Player sender, @NotNull CommandArguments args) throws WrapperCommandSyntaxException { + if (!(args.get("war") instanceof final @NotNull War war)) + throw CommandAPIBukkit.failWithAdventureComponent(ColorParser.of(UtilsChat.getPrefix() + "You need to specify a war.").build()); - if (!(args.get("town") instanceof final Town town)) - throw CommandAPIBukkit.failWithAdventureComponent(new ColorParser(UtilsChat.getPrefix() + "You need to specify a town.").build()); + if (!(args.get("town") instanceof final @NotNull Town town)) + throw CommandAPIBukkit.failWithAdventureComponent(ColorParser.of(UtilsChat.getPrefix() + "You need to specify a town.").build()); - final Set sieges = war.getSieges(); + final @NotNull Set sieges = war.getSieges(); if (sieges.isEmpty()) - throw CommandAPIBukkit.failWithAdventureComponent(new ColorParser(UtilsChat.getPrefix() + "There are currently no sieges in progress!").build()); + throw CommandAPIBukkit.failWithAdventureComponent(ColorParser.of(UtilsChat.getPrefix() + "There are currently no sieges in progress!").build()); - for (Siege siege : sieges) { + for (@NotNull Siege siege : sieges) { if (siege.getTown().getUUID().equals(town.getUUID()) && siege.getWar().equals(war)) { - sender.sendMessage(new ColorParser(UtilsChat.getPrefix() + "siege cancelled.").build()); - Bukkit.broadcast(new ColorParser(UtilsChat.getPrefix() + "The siege at " + siege.getTown().getName() + " has been cancelled by an admin.").build()); + sender.sendMessage(ColorParser.of(UtilsChat.getPrefix() + "siege cancelled.").build()); + Bukkit.broadcast(ColorParser.of(UtilsChat.getPrefix() + "The siege at " + siege.getTown().getName() + " has been cancelled by an admin.").build()); siege.stop(); return; } } - throw CommandAPIBukkit.failWithAdventureComponent(new ColorParser(UtilsChat.getPrefix() + "A siege could not be found with this town name! Type /siege list to view current sieges").build()); + throw CommandAPIBukkit.failWithAdventureComponent(ColorParser.of(UtilsChat.getPrefix() + "A siege could not be found with this town name! Type /siege list to view current sieges").build()); } - private static void siegeAbandon(Player p, CommandArguments args) throws WrapperCommandSyntaxException { - if (!(args.get("war") instanceof final War war)) - throw CommandAPIBukkit.failWithAdventureComponent(new ColorParser(UtilsChat.getPrefix() + "You need to specify a war.").build()); + private static void siegeAbandon(Player p, @NotNull CommandArguments args) throws WrapperCommandSyntaxException { + if (!(args.get("war") instanceof final @NotNull War war)) + throw CommandAPIBukkit.failWithAdventureComponent(ColorParser.of(UtilsChat.getPrefix() + "You need to specify a war.").build()); - if (!(args.get("town") instanceof final Town town)) - throw CommandAPIBukkit.failWithAdventureComponent(new ColorParser(UtilsChat.getPrefix() + "You need to specify a town.").build()); + if (!(args.get("town") instanceof final @NotNull Town town)) + throw CommandAPIBukkit.failWithAdventureComponent(ColorParser.of(UtilsChat.getPrefix() + "You need to specify a town.").build()); - Siege siege = null; + @Nullable Siege siege = null; - for (Siege siegeVar : war.getSieges()) { + for (@NotNull Siege siegeVar : war.getSieges()) { if (siegeVar.getTown().getUUID().equals(town.getUUID())) { siege = siegeVar; break; @@ -261,59 +263,59 @@ public class SiegeCommand { } if (siege == null) - throw CommandAPIBukkit.failWithAdventureComponent(new ColorParser(UtilsChat.getPrefix() + "Invalid siege").build()); + throw CommandAPIBukkit.failWithAdventureComponent(ColorParser.of(UtilsChat.getPrefix() + "Invalid siege").build()); - OfflinePlayer oPlayer = siege.getSiegeLeader(); + @NotNull OfflinePlayer oPlayer = siege.getSiegeLeader(); if (oPlayer != p) { - throw CommandAPIBukkit.failWithAdventureComponent(new ColorParser(UtilsChat.getPrefix() + "You are not the leader of this siege.").build()); + throw CommandAPIBukkit.failWithAdventureComponent(ColorParser.of(UtilsChat.getPrefix() + "You are not the leader of this siege.").build()); } - Bukkit.broadcast(new ColorParser(UtilsChat.getPrefix() + "The siege at " + siege.getTown().getName() + " has been abandoned.").build()); + Bukkit.broadcast(ColorParser.of(UtilsChat.getPrefix() + "The siege at " + siege.getTown().getName() + " has been abandoned.").build()); // Main.warLogger.log(p.getName() + " abandoned the siege they started at " + siege.getTown().getName()); siege.defendersWin(); } - private static void siegeList(Player sender, CommandArguments args) throws WrapperCommandSyntaxException { - Set wars = WarManager.getInstance().getWars(); + private static void siegeList(@NotNull Player sender, CommandArguments args) throws WrapperCommandSyntaxException { + @NotNull Set wars = WarManager.getInstance().getWars(); - Set sieges = new HashSet<>(); + @NotNull Set sieges = new HashSet<>(); - for (War war : wars) { + for (@NotNull War war : wars) { sieges.addAll(war.getSieges()); } if (sieges.isEmpty()) - throw CommandAPIBukkit.failWithAdventureComponent(new ColorParser(UtilsChat.getPrefix() + "There are currently no sieges in progress.").build()); + throw CommandAPIBukkit.failWithAdventureComponent(ColorParser.of(UtilsChat.getPrefix() + "There are currently no sieges in progress.").build()); - sender.sendMessage(new ColorParser(UtilsChat.getPrefix() + "Sieges currently in progress:").build()); + sender.sendMessage(ColorParser.of(UtilsChat.getPrefix() + "Sieges currently in progress:").build()); - for (Siege siege : sieges) { - War war = siege.getWar(); + for (@NotNull Siege siege : sieges) { + @NotNull War war = siege.getWar(); - final String color = (siege.getSide1AreAttackers() && (war.getTownSide(siege.getTown()).getTeam().equals(BattleTeam.SIDE_1))) ? "" : ""; + final @NotNull String color = (siege.getSide1AreAttackers() && (war.getTownSide(siege.getTown()).getTeam().equals(BattleTeam.SIDE_1))) ? "" : ""; sender.sendMessage( - new ColorParser( + ColorParser.of( color + siege.getTown().getName() + " - Progress: - Time: