From 6c6828f7fa139c634b479808c26e2345db3512cc Mon Sep 17 00:00:00 2001 From: Aubri Seebauer Date: Thu, 27 Apr 2023 19:37:15 -0400 Subject: [PATCH 1/5] Shift Admin and raid commands to use console as well. --- .../AlathraWar/commands/AdminCommands.java | 138 +++++++++++------- .../AlathraWar/commands/RaidCommands.java | 45 ++++-- .../AlathraWar/commands/WarCommands.java | 19 ++- 3 files changed, 130 insertions(+), 72 deletions(-) diff --git a/src/main/java/me/ShermansWorld/AlathraWar/commands/AdminCommands.java b/src/main/java/me/ShermansWorld/AlathraWar/commands/AdminCommands.java index 38813d6..babd8f5 100644 --- a/src/main/java/me/ShermansWorld/AlathraWar/commands/AdminCommands.java +++ b/src/main/java/me/ShermansWorld/AlathraWar/commands/AdminCommands.java @@ -106,26 +106,25 @@ public class AdminCommands implements CommandExecutor { */ @Override public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { - final Player p = (Player) sender; - if (!p.hasPermission("AlathraWar.admin")) { - return fail(p, args, "permissions"); + if (!sender.hasPermission("AlathraWar.admin")) { + return fail(sender, args, "permissions"); } if (args.length == 0) { - return fail(p, args, "syntax"); + return fail(sender, args, "syntax"); } else if (args.length >= 1) { if (args[0].equalsIgnoreCase("create")) { - return create(p, args); + return create(sender, args); } else if (args[0].equalsIgnoreCase("force")) { - return force(p, args); + return force(sender, args); } else if (args[0].equalsIgnoreCase("help")) { - return help(p, args); + return help(sender, args); } else if (args[0].equalsIgnoreCase("info")) { - return info(p, args); + return info(sender, args); } else if (args[0].equalsIgnoreCase("modify")) { - return modify(p, args); + return modify(sender, args); } else if (args[0].equalsIgnoreCase("awa")) { - return awa(p, args); + return awa(sender, args); } } return true; @@ -138,18 +137,19 @@ public class AdminCommands implements CommandExecutor { * -create raid [war] [raidTown] [gatherTown] (owner) * -create war [name] [side1] [side2] */ - private static boolean create(Player p, String[] args) { + private static boolean create(CommandSender p, String[] args) { if (args.length >= 2) { if (args[1].equalsIgnoreCase("raid")) { if (args.length >= 4) { //specific behavior exists if an admin ran this //using same method so that this doesnt get fucked up if we go back and change original implementation RaidCommands.startRaid(p, args, true); + return true; } else { //defaultCode will bypass the custom gather town to force set owner p.sendMessage(Helper.color("&cUsage: /alathrawaradmin create raid [war] [raidTown] (gatherTown/\"defaultCode\") (owner)")); + return true; } - return true; } else if (args[1].equalsIgnoreCase("siege")) { //this exists to force a seige with a new owner if (args.length >= 4) { @@ -161,6 +161,7 @@ public class AdminCommands implements CommandExecutor { }; SiegeCommands.siegeStart(p, adjusted, true); p.sendMessage(Helper.Chatlabel() + "Try again later!"); + return true; } else { p.sendMessage(Helper.color("&cUsage: /alathrawaradmin create siege [war] [town] (owner)")); return true; @@ -176,6 +177,7 @@ public class AdminCommands implements CommandExecutor { args[4] }; WarCommands.warCreate(p, adjusted); + return true; } else { p.sendMessage(Helper.color("&cUsage: /alathrawaradmin create war [name] [side1] [side2]")); return true; @@ -203,7 +205,7 @@ public class AdminCommands implements CommandExecutor { * @param args args * @return result */ - private static boolean force(Player p, String[] args) { + private static boolean force(CommandSender p, String[] args) { if (args.length >= 2) { if (args[1].equalsIgnoreCase("end")) { if (args.length >= 3) { @@ -429,7 +431,7 @@ public class AdminCommands implements CommandExecutor { return fail(p, args, "syntax"); } - private static boolean help(Player p, String[] args) { + private static boolean help(CommandSender p, String[] args) { p.sendMessage(Helper.Chatlabel() + "/alathrawaradmin create"); p.sendMessage(Helper.Chatlabel() + "/alathrawaradmin force"); p.sendMessage(Helper.Chatlabel() + "/alathrawaradmin help"); @@ -450,7 +452,7 @@ public class AdminCommands implements CommandExecutor { * @param args args * @return result */ - private static boolean info(Player p, String[] args) { + private static boolean info(CommandSender p, String[] args) { if (args.length >= 2) { if (args[1].equalsIgnoreCase("war")) { if (args.length >= 3) { @@ -643,7 +645,7 @@ public class AdminCommands implements CommandExecutor { * @param args args * @return result */ - private static boolean modify(Player p, String[] args) { + private static boolean modify(CommandSender p, String[] args) { if (args.length >= 2) { if (args[1].equalsIgnoreCase("raid")) { if (args.length >= 3) { @@ -756,15 +758,19 @@ public class AdminCommands implements CommandExecutor { } Town t = r.getRaidedTown(); if (args.length >= 8) { - if (p.getWorld() == t.getWorld()) { + if(!(p instanceof Player runner)) { + p.sendMessage(Helper.Chatlabel() + "This command cannot be run through console!"); + return true; + } + if (runner.getWorld() == t.getWorld()) { try { - WorldCoord tb = WorldCoord.parseWorldCoord(p.getWorld().getName(), (int) Double.parseDouble(args[5]), (int) Double.parseDouble(args[7])); + WorldCoord tb = WorldCoord.parseWorldCoord(runner.getWorld().getName(), (int) Double.parseDouble(args[5]), (int) Double.parseDouble(args[7])); if (t.hasTownBlock(tb)) { t.setHomeBlock(tb.getTownBlock()); - t.setSpawn(new Location(p.getWorld(), Double.parseDouble(args[5]), Double.parseDouble(args[6]), Double.parseDouble(args[7]))); + t.setSpawn(new Location(runner.getWorld(), Double.parseDouble(args[5]), Double.parseDouble(args[6]), Double.parseDouble(args[7]))); r.setHomeBlockRaided(tb.getTownBlock()); r.setTownSpawnRaided(t.getSpawn()); - p.sendMessage(Helper.Chatlabel() + "Set town spawn for raided town " + args[4] + " in war " + args[3] + " to " + p.getLocation().toString()); + p.sendMessage(Helper.Chatlabel() + "Set town spawn for raided town " + args[4] + " in war " + args[3] + " to " + runner.getLocation().toString()); Main.warLogger.log("Set town spawn for raided town " + args[4] + " in war " + args[3] + " to [" + args[5] + "," + args[6] + "," + args[7] + "]"); return finalizeRaid(r); } else { @@ -783,19 +789,23 @@ public class AdminCommands implements CommandExecutor { return true; } } else { - if (p.getWorld() == t.getWorld()) { + if(!(p instanceof Player runner)) { + p.sendMessage(Helper.Chatlabel() + "This command cannot be run through console!"); + return true; + } + if (runner.getWorld() == t.getWorld()) { try { - WorldCoord tb = WorldCoord.parseWorldCoord(p.getWorld().getName(), (int) p.getLocation().getX(), (int) p.getLocation().getZ()); + WorldCoord tb = WorldCoord.parseWorldCoord(runner.getWorld().getName(), (int) runner.getLocation().getX(), (int) runner.getLocation().getZ()); if (t.hasTownBlock(tb)) { t.setHomeBlock(tb.getTownBlock()); - t.setSpawn(p.getLocation()); + t.setSpawn(runner.getLocation()); r.setHomeBlockRaided(tb.getTownBlock()); r.setTownSpawnRaided(t.getSpawn()); - p.sendMessage(Helper.Chatlabel() + "Set town spawn for raided town " + args[4] + " in war " + args[3] + " to " + p.getLocation().toString()); - Main.warLogger.log("Set town spawn for raided town " + args[4] + " in war " + args[3] + " to " + p.getLocation().toString()); + p.sendMessage(Helper.Chatlabel() + "Set town spawn for raided town " + args[4] + " in war " + args[3] + " to " + runner.getLocation().toString()); + Main.warLogger.log("Set town spawn for raided town " + args[4] + " in war " + args[3] + " to " + runner.getLocation().toString()); return finalizeRaid(r); } else { - p.sendMessage(Helper.color("&cTown does not contain town block at your location [" + (int) p.getLocation().getX() + "," + (int) p.getLocation().getZ() + "]")); + p.sendMessage(Helper.color("&cTown does not contain town block at your location [" + (int) runner.getLocation().getX() + "," + (int) runner.getLocation().getZ() + "]")); return true; } } catch (NotRegisteredException e) { @@ -880,13 +890,18 @@ public class AdminCommands implements CommandExecutor { for (Raid r : RaidData.getRaids()) { if (r.getWar().getName().equals(args[3]) && r.getRaidedTown().getName().equals(args[4])) { //parse phase - if (!p.getWorld().equals(r.getRaidedTown().getWorld())) { + if(!(p instanceof Player runner)) { + p.sendMessage(Helper.Chatlabel() + "This command cannot be run through console!"); + return true; + } + + if (!runner.getWorld().equals(r.getRaidedTown().getWorld())) { p.sendMessage(Helper.Chatlabel() + "Error wrong world"); return true; } if (args.length >= 9) { if (args[5].equalsIgnoreCase("value")) { - WorldCoord wc = WorldCoord.parseWorldCoord(p.getWorld().getName(), (int) Double.parseDouble(args[7]), (int) Double.parseDouble(args[8])); + WorldCoord wc = WorldCoord.parseWorldCoord(runner.getWorld().getName(), (int) Double.parseDouble(args[7]), (int) Double.parseDouble(args[8])); Raid.LootBlock lb = r.getLootedChunks().get(wc); if(lb == null) { r.addLootedChunk(wc); @@ -898,7 +913,7 @@ public class AdminCommands implements CommandExecutor { Main.warLogger.log("Set value for a chunk [" + args[7] + "," + args[8] + "] in raid against " + args[4] + " in war " + args[3] + " to " + args[6]); return finalizeRaid(r); } else if (args[5].equalsIgnoreCase("looted")) { - WorldCoord wc = WorldCoord.parseWorldCoord(p.getWorld().getName(), (int) Double.parseDouble(args[7]), (int) Double.parseDouble(args[8])); + WorldCoord wc = WorldCoord.parseWorldCoord(runner.getWorld().getName(), (int) Double.parseDouble(args[7]), (int) Double.parseDouble(args[8])); Raid.LootBlock lb = r.getLootedChunks().get(wc); //The base value can be abjusted if(!lb.finished && Boolean.parseBoolean(args[6])) { @@ -914,14 +929,14 @@ public class AdminCommands implements CommandExecutor { Main.warLogger.log("Set finished flag for a chunk [" + args[7] + "," + args[8] + "] in raid against " + args[4] + " in war " + args[3] + " to " + args[6]); return finalizeRaid(r); } else if (args[5].equalsIgnoreCase("ticks")) { - WorldCoord wc = WorldCoord.parseWorldCoord(p.getWorld().getName(), (int) Double.parseDouble(args[7]), (int) Double.parseDouble(args[8])); + WorldCoord wc = WorldCoord.parseWorldCoord(runner.getWorld().getName(), (int) Double.parseDouble(args[7]), (int) Double.parseDouble(args[8])); Raid.LootBlock lb = r.getLootedChunks().get(wc); lb.ticks = Integer.parseInt(args[6]); p.sendMessage(Helper.Chatlabel() + "Set ticks for a chunk [" + args[7] + "," + args[8] + "] in raid against " + args[4] + " in war " + args[3] + " to " + args[6]); Main.warLogger.log("Set ticks for a chunk [" + args[7] + "," + args[8] + "] in raid against " + args[4] + " in war " + args[3] + " to " + args[6]); return finalizeRaid(r); } else if (args[5].equalsIgnoreCase("reset")) { - WorldCoord wc = WorldCoord.parseWorldCoord(p.getWorld().getName(), (int) Double.parseDouble(args[6]), (int) Double.parseDouble(args[7])); + WorldCoord wc = WorldCoord.parseWorldCoord(runner.getWorld().getName(), (int) Double.parseDouble(args[6]), (int) Double.parseDouble(args[7])); r.getLootedChunks().remove(wc); p.sendMessage(Helper.Chatlabel() + "Reset loot for a chunk [" + args[7] + "," + args[8] + "] in raid against " + args[4] + " in war " + args[3]); Main.warLogger.log("Reset loot for a chunk [" + args[7] + "," + args[8] + "] in raid against " + args[4] + " in war " + args[3]); @@ -935,31 +950,31 @@ public class AdminCommands implements CommandExecutor { return true; } else { if (args[5].equalsIgnoreCase("value")) { - WorldCoord wc = WorldCoord.parseWorldCoord(p.getLocation()); + WorldCoord wc = WorldCoord.parseWorldCoord(runner.getLocation()); Raid.LootBlock lb = r.getLootedChunks().get(wc); lb.value = Integer.parseInt(args[6]); - p.sendMessage(Helper.Chatlabel() + "Set value for a chunk [" + p.getLocation().getX() + "," + p.getLocation().getZ() + "] in raid against " + args[4] + " in war " + args[3] + " to " + args[6]); - Main.warLogger.log("Set value for a chunk [" + p.getLocation().getX() + "," + p.getLocation().getZ() + "] in raid against " + args[4] + " in war " + args[3] + " to " + args[6]); + p.sendMessage(Helper.Chatlabel() + "Set value for a chunk [" + runner.getLocation().getX() + "," + runner.getLocation().getZ() + "] in raid against " + args[4] + " in war " + args[3] + " to " + args[6]); + Main.warLogger.log("Set value for a chunk [" + runner.getLocation().getX() + "," + runner.getLocation().getZ() + "] in raid against " + args[4] + " in war " + args[3] + " to " + args[6]); return finalizeRaid(r); } else if (args[5].equalsIgnoreCase("looted")) { - WorldCoord wc = WorldCoord.parseWorldCoord(p.getLocation()); + WorldCoord wc = WorldCoord.parseWorldCoord(runner.getLocation()); Raid.LootBlock lb = r.getLootedChunks().get(wc); lb.finished = Boolean.parseBoolean(args[6]); - p.sendMessage(Helper.Chatlabel() + "Set looted status for a chunk [" + p.getLocation().getX() + "," + p.getLocation().getZ() + "] in raid against " + args[4] + " in war " + args[3] + " to " + args[6]); - Main.warLogger.log("Set looted status for a chunk [" + p.getLocation().getX() + "," + p.getLocation().getZ() + "] in raid against " + args[4] + " in war " + args[3] + " to " + args[6]); + p.sendMessage(Helper.Chatlabel() + "Set looted status for a chunk [" + runner.getLocation().getX() + "," + runner.getLocation().getZ() + "] in raid against " + args[4] + " in war " + args[3] + " to " + args[6]); + Main.warLogger.log("Set looted status for a chunk [" + runner.getLocation().getX() + "," + runner.getLocation().getZ() + "] in raid against " + args[4] + " in war " + args[3] + " to " + args[6]); return finalizeRaid(r); } else if (args[5].equalsIgnoreCase("ticks")) { - WorldCoord wc = WorldCoord.parseWorldCoord(p.getLocation()); + WorldCoord wc = WorldCoord.parseWorldCoord(runner.getLocation()); Raid.LootBlock lb = r.getLootedChunks().get(wc); lb.ticks = Integer.parseInt(args[6]); - p.sendMessage(Helper.Chatlabel() + "Set ticks for a chunk [" + p.getLocation().getX() + "," + p.getLocation().getZ() + "] in raid against " + args[4] + " in war " + args[3] + " to " + args[6]); - Main.warLogger.log("Set ticks for a chunk [" + p.getLocation().getX() + "," + p.getLocation().getZ() + "] in raid against " + args[4] + " in war " + args[3] + " to " + args[6]); + p.sendMessage(Helper.Chatlabel() + "Set ticks for a chunk [" + runner.getLocation().getX() + "," + runner.getLocation().getZ() + "] in raid against " + args[4] + " in war " + args[3] + " to " + args[6]); + Main.warLogger.log("Set ticks for a chunk [" + runner.getLocation().getX() + "," + runner.getLocation().getZ() + "] in raid against " + args[4] + " in war " + args[3] + " to " + args[6]); return finalizeRaid(r); } else if (args[5].equalsIgnoreCase("reset")) { - WorldCoord wc = WorldCoord.parseWorldCoord(p.getLocation()); + WorldCoord wc = WorldCoord.parseWorldCoord(runner.getLocation()); r.getLootedChunks().remove(wc); - p.sendMessage(Helper.Chatlabel() + "Reset loot for a chunk [" + p.getLocation().getX() + "," + p.getLocation().getZ() + "] in raid against " + args[4] + " in war " + args[3]); - Main.warLogger.log("Reset Loot for a chunk [" + p.getLocation().getX() + "," + p.getLocation().getZ() + "] in raid against " + args[4] + " in war " + args[3]); + p.sendMessage(Helper.Chatlabel() + "Reset loot for a chunk [" + runner.getLocation().getX() + "," + runner.getLocation().getZ() + "] in raid against " + args[4] + " in war " + args[3]); + Main.warLogger.log("Reset Loot for a chunk [" + runner.getLocation().getX() + "," + runner.getLocation().getZ() + "] in raid against " + args[4] + " in war " + args[3]); return finalizeRaid(r); } else { p.sendMessage(Helper.color("&cUsage: /alathrawaradmin modify raid loot [war] [town] [value,looted,ticks,reset] [amt] (x) (z)")); @@ -1123,15 +1138,19 @@ public class AdminCommands implements CommandExecutor { } Town t = s.getTown(); if (args.length >= 8) { - if (p.getWorld() == t.getWorld()) { + if(!(p instanceof Player runner)) { + p.sendMessage(Helper.Chatlabel() + "This command cannot be run through console!"); + return true; + } + if (runner.getWorld() == t.getWorld()) { try { - WorldCoord tb = WorldCoord.parseWorldCoord(p.getWorld().getName(), (int) Double.parseDouble(args[5]), (int) Double.parseDouble(args[7])); + WorldCoord tb = WorldCoord.parseWorldCoord(runner.getWorld().getName(), (int) Double.parseDouble(args[5]), (int) Double.parseDouble(args[7])); if (t.hasTownBlock(tb)) { t.setHomeBlock(tb.getTownBlock()); - t.setSpawn(new Location(p.getWorld(), (int) Double.parseDouble(args[5]), (int) Double.parseDouble(args[6]), (int) Double.parseDouble(args[7]))); + t.setSpawn(new Location(runner.getWorld(), (int) Double.parseDouble(args[5]), (int) Double.parseDouble(args[6]), (int) Double.parseDouble(args[7]))); s.setHomeBlock(tb.getTownBlock()); s.setTownSpawn(t.getSpawn()); - p.sendMessage(Helper.Chatlabel() + "Set town spawn for sieged town " + args[4] + " in war " + args[3] + " to " + p.getLocation().toString()); + p.sendMessage(Helper.Chatlabel() + "Set town spawn for sieged town " + args[4] + " in war " + args[3] + " to " + runner.getLocation().toString()); Main.warLogger.log("Set town spawn for sieged town " + args[4] + " in war " + args[3] + " to [" + args[5] + "," + args[6] + "," + args[7] + "]"); return finalizeSiege(s); } else { @@ -1150,19 +1169,24 @@ public class AdminCommands implements CommandExecutor { return true; } } else { - if (p.getWorld() == t.getWorld()) { + + if(!(p instanceof Player runner)) { + p.sendMessage(Helper.Chatlabel() + "This command cannot be run through console!"); + return true; + } + if (runner.getWorld() == t.getWorld()) { try { - WorldCoord tb = WorldCoord.parseWorldCoord(p.getWorld().getName(), (int) p.getLocation().getX(), (int) p.getLocation().getZ()); + WorldCoord tb = WorldCoord.parseWorldCoord(runner.getWorld().getName(), (int) runner.getLocation().getX(), (int) runner.getLocation().getZ()); if (t.hasTownBlock(tb)) { t.setHomeBlock(tb.getTownBlock()); - t.setSpawn(p.getLocation()); + t.setSpawn(runner.getLocation()); s.setHomeBlock(tb.getTownBlock()); s.setTownSpawn(t.getSpawn()); - p.sendMessage(Helper.Chatlabel() + "Set town spawn for sieged town " + args[4] + " in war " + args[3] + " to " + p.getLocation().toString()); - Main.warLogger.log("Set town spawn for sieged town " + args[4] + " in war " + args[3] + " to " + p.getLocation().toString()); + p.sendMessage(Helper.Chatlabel() + "Set town spawn for sieged town " + args[4] + " in war " + args[3] + " to " + runner.getLocation().toString()); + Main.warLogger.log("Set town spawn for sieged town " + args[4] + " in war " + args[3] + " to " + runner.getLocation().toString()); return finalizeSiege(s); } else { - p.sendMessage(Helper.color("&cTown does not contain town block at your location [" + (int) p.getLocation().getX() + "," + (int) p.getLocation().getZ() + "]")); + p.sendMessage(Helper.color("&cTown does not contain town block at your location [" + (int) runner.getLocation().getX() + "," + (int) runner.getLocation().getZ() + "]")); return true; } } catch (NotRegisteredException e) { @@ -1726,7 +1750,8 @@ public class AdminCommands implements CommandExecutor { return true; } - private static boolean awa(Player sender, String[] args) { + private static boolean awa(CommandSender sender, String[] args) { + if (args.length > 1) { Player p = Bukkit.getPlayer(args[1]); if (p == null) { @@ -1736,11 +1761,12 @@ public class AdminCommands implements CommandExecutor { p.chat("awa awa! ^.^ UwU"); return true; } - sender.chat("awa awa! ^.^ UwU"); + if(sender instanceof Player) + ((Player) sender).chat("awa awa! ^.^ UwU"); return true; } - private static boolean fail(Player p, String[] args, String type) { + private static boolean fail(CommandSender p, String[] args, String type) { switch (type) { case "permissions" -> { p.sendMessage(String.valueOf(Helper.Chatlabel()) + Helper.color("&cYou do not have permission to do this.")); diff --git a/src/main/java/me/ShermansWorld/AlathraWar/commands/RaidCommands.java b/src/main/java/me/ShermansWorld/AlathraWar/commands/RaidCommands.java index d3a6aaa..e729ad3 100644 --- a/src/main/java/me/ShermansWorld/AlathraWar/commands/RaidCommands.java +++ b/src/main/java/me/ShermansWorld/AlathraWar/commands/RaidCommands.java @@ -63,7 +63,7 @@ public class RaidCommands implements CommandExecutor { * @param p * @param args */ - protected static void startRaid(Player p, String[] args, boolean admin) { + protected static void startRaid(CommandSender p, String[] args, boolean admin) { boolean warFound = false; boolean townExists = false; for (final War war : WarData.getWars()) { @@ -71,13 +71,20 @@ public class RaidCommands implements CommandExecutor { if (war.getName().equalsIgnoreCase(args[1 + (admin ? 1 : 0)])) { warFound = true; - Player raidOwner = p; + Player raidOwner = null; + if(p instanceof Player) { + raidOwner = (Player) p; + } else { + p.sendMessage("Running this from the console requires a Player Argument!"); + return; + } TownyWorld townyWorld; townyWorld = WorldCoord.parseWorldCoord(raidOwner.getLocation()).getTownyWorld(); if(admin && args.length >= 6) { raidOwner = Bukkit.getPlayer(args[5]); if(raidOwner == null) { - raidOwner = p; + p.sendMessage("Player Does not exist"); + return; } } @@ -249,7 +256,7 @@ public class RaidCommands implements CommandExecutor { } //check player balance - final OfflinePlayer offlinePlayer = Bukkit.getOfflinePlayer(p.getUniqueId()); + final OfflinePlayer offlinePlayer = Bukkit.getOfflinePlayer(raidOwner.getUniqueId()); if (Main.econ.getBalance(offlinePlayer) <= 1000.0) { if (admin) p.sendMessage(String.valueOf(Helper.Chatlabel()) + "You must have at least $1000 to put up to start a raid."); raidOwner.sendMessage(String.valueOf(Helper.Chatlabel()) + "You must have at least $1000 to put up to start a raid."); @@ -294,7 +301,7 @@ public class RaidCommands implements CommandExecutor { * @param p * @param args */ - private static void stopRaid(Player p, String[] args) { + private static void stopRaid(CommandSender p, String[] args) { //admin check if (!p.hasPermission("AlathraWar.admin")) { fail(p, args, "permission"); @@ -319,12 +326,16 @@ public class RaidCommands implements CommandExecutor { } } - protected static void joinRaid(Player p, String[] args, boolean admin) { + protected static void joinRaid(CommandSender p, String[] args, boolean admin) { //Grab raid! Raid raid = RaidData.getRaidOrNull(args[1] + "-" + args[2]); if (raid != null) { if (raid.getWar().getName().equalsIgnoreCase(args[1])) { - Player joiner = p; + Player joiner = null; + if(p instanceof Player) { + joiner = (Player) p; + } + if (admin) { joiner = Bukkit.getPlayer(args[3]); @@ -351,6 +362,11 @@ public class RaidCommands implements CommandExecutor { } } + if(joiner == null) { + p.sendMessage(String.valueOf(Helper.Chatlabel()) + "Player not found! Is something broken?"); + return; + } + if (!raid.getWar().getSide1Players().contains(joiner.getName()) && !raid.getWar().getSide2Players().contains(joiner.getName())) { joiner.sendMessage(String.valueOf(Helper.Chatlabel()) + "You are not in this war! Type /war join [war] [side]"); } @@ -425,9 +441,9 @@ public class RaidCommands implements CommandExecutor { } } - protected static void leaveRaid(Player player, String[] args, boolean admin) { + protected static void leaveRaid(CommandSender player, String[] args, boolean admin) { //Get raid! - Player p = player; + Player p = null; if (admin) { p = Bukkit.getPlayer(args[3]); if (p == null) { @@ -435,6 +451,9 @@ public class RaidCommands implements CommandExecutor { return; } } + if(p == null) { + p = (Player) player; + } Raid raid = RaidData.getRaidOrNull(args[1] + "-" + args[2]); if (raid != null) { @@ -477,7 +496,7 @@ public class RaidCommands implements CommandExecutor { * @param p * @param args */ - private static void abandonRaid(Player p, String[] args) { + private static void abandonRaid(CommandSender p, String[] args) { //Get raid Raid raid = RaidData.getRaidOrNull(args[1] + "-" + args[2]); if (raid != null) { @@ -506,7 +525,7 @@ public class RaidCommands implements CommandExecutor { p.sendMessage(String.valueOf(Helper.Chatlabel()) + "This raid does not exist!"); } - private static void listRaids(Player p, String[] args) { + private static void listRaids(CommandSender p, String[] args) { if (RaidData.getRaids().isEmpty()) { p.sendMessage(String.valueOf(Helper.Chatlabel()) + "There are currently no Raids in progress"); return; @@ -528,7 +547,7 @@ public class RaidCommands implements CommandExecutor { } } - private static void raidHelp(Player p, String[] args) { + private static void raidHelp(CommandSender p, String[] args) { if (p.hasPermission("!AlathraWar.admin")) { p.sendMessage(Helper.Chatlabel() + "/raid stop [name]"); } @@ -539,7 +558,7 @@ public class RaidCommands implements CommandExecutor { p.sendMessage(Helper.Chatlabel() + "/raid list"); } - private static void fail(Player p, String[] args, String type) { + private static void fail(CommandSender p, String[] args, String type) { switch (type) { case "permissions" -> p.sendMessage(String.valueOf(Helper.Chatlabel()) + "&cYou do not have permission to do this"); case "syntax" -> p.sendMessage(String.valueOf(Helper.Chatlabel()) + "Invalid Syntax. /raid help"); diff --git a/src/main/java/me/ShermansWorld/AlathraWar/commands/WarCommands.java b/src/main/java/me/ShermansWorld/AlathraWar/commands/WarCommands.java index 1f77d88..ce109cf 100644 --- a/src/main/java/me/ShermansWorld/AlathraWar/commands/WarCommands.java +++ b/src/main/java/me/ShermansWorld/AlathraWar/commands/WarCommands.java @@ -67,7 +67,7 @@ public class WarCommands implements CommandExecutor { return false; } - protected static void warCreate(Player p, String[] args) { + protected static void warCreate(CommandSender p, String[] args) { if (!p.hasPermission("AlathraWar.admin")) { p.sendMessage("You do not have permission to run this command."); return; @@ -122,7 +122,7 @@ public class WarCommands implements CommandExecutor { * @param args * @param admin - admin behavior */ - protected static void warJoin(Player p, String[] args, boolean admin) { + protected static void warJoin(CommandSender p, String[] args, boolean admin) { // Sufficient args check if (args.length < 3) { p.sendMessage(Helper.Chatlabel() @@ -138,8 +138,21 @@ public class WarCommands implements CommandExecutor { return; } + Player player = null; + if (admin){ + player = Bukkit.getPlayer(args[3]); + if(player == null) { + p.sendMessage(Helper.Chatlabel() + "Player " + args[3] + " not found!"); + return; + } + } + if(player == null) { + player = (Player) p; + } + + // Towny Resident Object, if admin then dont use command runner, use declared player - Resident res = TownyAPI.getInstance().getResident(admin ? Bukkit.getPlayer(args[3]) : p); + Resident res = TownyAPI.getInstance().getResident(player); // Town check Town town = res.getTownOrNull(); From 95175f10577430df9c9f48dcf7911a483b791935 Mon Sep 17 00:00:00 2001 From: Aubri Seebauer Date: Fri, 28 Apr 2023 18:31:36 -0400 Subject: [PATCH 2/5] finalize creation of events through console --- .../AlathraWar/commands/AdminCommands.java | 8 +++- .../AlathraWar/commands/RaidCommands.java | 48 +++++++++---------- .../AlathraWar/commands/SiegeCommands.java | 43 ++++++++++------- .../AlathraWar/data/RaidData.java | 9 ++++ 4 files changed, 63 insertions(+), 45 deletions(-) diff --git a/src/main/java/me/ShermansWorld/AlathraWar/commands/AdminCommands.java b/src/main/java/me/ShermansWorld/AlathraWar/commands/AdminCommands.java index babd8f5..3817c49 100644 --- a/src/main/java/me/ShermansWorld/AlathraWar/commands/AdminCommands.java +++ b/src/main/java/me/ShermansWorld/AlathraWar/commands/AdminCommands.java @@ -144,6 +144,7 @@ public class AdminCommands implements CommandExecutor { //specific behavior exists if an admin ran this //using same method so that this doesnt get fucked up if we go back and change original implementation RaidCommands.startRaid(p, args, true); + p.sendMessage(Helper.color("&cForcefully started raid from the console.")); return true; } else { //defaultCode will bypass the custom gather town to force set owner @@ -157,10 +158,12 @@ public class AdminCommands implements CommandExecutor { "start", args[2], args[3], - args[4] + args[4], + args[5] }; SiegeCommands.siegeStart(p, adjusted, true); - p.sendMessage(Helper.Chatlabel() + "Try again later!"); +// p.sendMessage(Helper.Chatlabel() + "Try again later!"); + p.sendMessage(Helper.color("&cForcefully started siege from the console.")); return true; } else { p.sendMessage(Helper.color("&cUsage: /alathrawaradmin create siege [war] [town] (owner)")); @@ -177,6 +180,7 @@ public class AdminCommands implements CommandExecutor { args[4] }; WarCommands.warCreate(p, adjusted); + p.sendMessage(Helper.color("&cForcefully started war from the console.")); return true; } else { p.sendMessage(Helper.color("&cUsage: /alathrawaradmin create war [name] [side1] [side2]")); diff --git a/src/main/java/me/ShermansWorld/AlathraWar/commands/RaidCommands.java b/src/main/java/me/ShermansWorld/AlathraWar/commands/RaidCommands.java index e729ad3..9034f17 100644 --- a/src/main/java/me/ShermansWorld/AlathraWar/commands/RaidCommands.java +++ b/src/main/java/me/ShermansWorld/AlathraWar/commands/RaidCommands.java @@ -26,33 +26,33 @@ public class RaidCommands implements CommandExecutor { } public boolean onCommand(final CommandSender sender, final Command cmd, final String label, final String[] args) { - final Player p = (Player) sender; +// final Player p = (Player) sender; if (args.length == 0) { - fail(p, args, "syntax"); + fail(sender, args, "syntax"); } else if (args.length == 1) { if (args[0].equalsIgnoreCase("list")) { - listRaids(p, args); + listRaids(sender, args); } else if (args[0].equalsIgnoreCase("help")) { - raidHelp(p, args); + raidHelp(sender, args); } else { - fail(p, args, "syntax"); + fail(sender, args, "syntax"); } }else if (args.length == 3) { if (args[0].equalsIgnoreCase("start")) { - startRaid(p, args, false); + startRaid(sender, args, false); } else if (args[0].equalsIgnoreCase("stop")) { - stopRaid(p, args); + stopRaid(sender, args); } else if (args[0].equalsIgnoreCase("join")) { - joinRaid(p, args, false); + joinRaid(sender, args, false); } else if (args[0].equalsIgnoreCase("leave")) { - leaveRaid(p, args, false); + leaveRaid(sender, args, false); } else if (args[0].equalsIgnoreCase("abandon")) { - abandonRaid(p, args); + abandonRaid(sender, args); } else { - fail(p, args, "syntax"); + fail(sender, args, "syntax"); } } else { - fail(p, args, "syntax"); + fail(sender, args, "syntax"); } return true; } @@ -72,14 +72,9 @@ public class RaidCommands implements CommandExecutor { warFound = true; Player raidOwner = null; - if(p instanceof Player) { + if((p instanceof Player)) { raidOwner = (Player) p; - } else { - p.sendMessage("Running this from the console requires a Player Argument!"); - return; } - TownyWorld townyWorld; - townyWorld = WorldCoord.parseWorldCoord(raidOwner.getLocation()).getTownyWorld(); if(admin && args.length >= 6) { raidOwner = Bukkit.getPlayer(args[5]); if(raidOwner == null) { @@ -88,10 +83,13 @@ public class RaidCommands implements CommandExecutor { } } + TownyWorld townyWorld; + townyWorld = WorldCoord.parseWorldCoord(raidOwner.getLocation()).getTownyWorld(); + String side = ""; - if (war.getSide1Players().contains(p.getName())) { + if (war.getSide1Players().contains(raidOwner.getName())) { side = war.getSide1(); - } else if (war.getSide2Players().contains(p.getName())) { + } else if (war.getSide2Players().contains(raidOwner.getName())) { side = war.getSide2(); } else { p.sendMessage(String.valueOf(Helper.Chatlabel()) + "You are not in this war! Type /war join [war] [side]"); @@ -100,7 +98,7 @@ public class RaidCommands implements CommandExecutor { //Minutemen countermeasures, 86400 * 4 time. 86400 seconds in a day, 4 days min playtime if (admin) { - if (System.currentTimeMillis() - CommandHelper.getPlayerJoinDate(args[3]) < 86400000L * Main.getInstance().getConfig().getInt("minimumPlayerAge") ) { + if (System.currentTimeMillis() - CommandHelper.getPlayerJoinDate(raidOwner.getName()) < 86400000L * Main.getInstance().getConfig().getInt("minimumPlayerAge") ) { if(args.length >= 5) { //player has joined to recently p.sendMessage(ChatColor.RED + "Warning! Ignoring Minuteman Countermeasure!"); @@ -112,7 +110,7 @@ public class RaidCommands implements CommandExecutor { } } } else { - if (System.currentTimeMillis() - CommandHelper.getPlayerJoinDate(p.getName()) < 86400000 * Main.getInstance().getConfig().getInt("minimumPlayerAge") ) { + if (System.currentTimeMillis() - CommandHelper.getPlayerJoinDate(raidOwner.getName()) < 86400000L * Main.getInstance().getConfig().getInt("minimumPlayerAge") ) { //player has joined to recently p.sendMessage(ChatColor.RED + "You have joined the server too recently! You can only join a war after 4 days from joining."); return; @@ -179,7 +177,7 @@ public class RaidCommands implements CommandExecutor { townExists = true; Raid raid2; - if (war.getSide1Players().contains(p.getName())) { + if (war.getSide1Players().contains(raidOwner.getName())) { //Time and raid activity validity check int c = RaidData.isValidRaid(war, side, raidedTown); if (c == 2) { @@ -206,7 +204,7 @@ public class RaidCommands implements CommandExecutor { } } else { //Something broke if this runs - if (!war.getSide2Players().contains(p.getName())) { + if (!war.getSide2Players().contains(raidOwner.getName())) { Bukkit.getLogger().info("Unable to find player declaring raid in the war"); return; } @@ -392,7 +390,7 @@ public class RaidCommands implements CommandExecutor { } } } else { - if (System.currentTimeMillis() - CommandHelper.getPlayerJoinDate(p.getName()) < 86400000L * Main.getInstance().getConfig().getInt("minimumPlayerAge") ) { + if (System.currentTimeMillis() - CommandHelper.getPlayerJoinDate(joiner.getName()) < 86400000L * Main.getInstance().getConfig().getInt("minimumPlayerAge") ) { //player has joined to recently p.sendMessage(ChatColor.RED + "You have joined the server too recently! You can only join a war after 4 days from joining."); return; diff --git a/src/main/java/me/ShermansWorld/AlathraWar/commands/SiegeCommands.java b/src/main/java/me/ShermansWorld/AlathraWar/commands/SiegeCommands.java index 1399406..ae481e2 100644 --- a/src/main/java/me/ShermansWorld/AlathraWar/commands/SiegeCommands.java +++ b/src/main/java/me/ShermansWorld/AlathraWar/commands/SiegeCommands.java @@ -60,13 +60,19 @@ public class SiegeCommands implements CommandExecutor { } protected static void siegeStart(CommandSender sender, String[] args, boolean admin) { - if (!(sender instanceof Player)) return; +// if (!(sender instanceof Player)) return; //if this is admin mode use the forth arg instad of sender. //if player is null after this then force end - Player player = !admin ? (Player) sender : args.length >= 4 ? Bukkit.getPlayer(args[3]) : null; - if(player == null) { - sender.sendMessage("Forced owner not found!"); - return; + Player siegeOwner = null; + if((sender instanceof Player)) { + siegeOwner = (Player) sender; + } + if(admin && args.length >= 5) { + siegeOwner = Bukkit.getPlayer(args[3]); + if(siegeOwner == null) { + sender.sendMessage("Player Does not exist"); + return; + } } if (args.length < 3) { @@ -77,27 +83,27 @@ public class SiegeCommands implements CommandExecutor { // War check War war = WarData.getWar(args[1]); if (war == null) { - player.sendMessage(String.valueOf(Helper.Chatlabel()) + "That war does not exist! /siege start [war] [town]"); + siegeOwner.sendMessage(String.valueOf(Helper.Chatlabel()) + "That war does not exist! /siege start [war] [town]"); if(admin) sender.sendMessage(String.valueOf(Helper.Chatlabel()) + "That war does not exist! /siege start [war] [town]"); return; } // Player participance check - Town leaderTown = TownyAPI.getInstance().getResident(player).getTownOrNull(); + Town leaderTown = TownyAPI.getInstance().getResident(siegeOwner).getTownOrNull(); int side = war.getSide(leaderTown.getName()); if (side == 0) { - player.sendMessage(Helper.Chatlabel() + "You are not in this war."); + siegeOwner.sendMessage(Helper.Chatlabel() + "You are not in this war."); if(admin) sender.sendMessage(Helper.Chatlabel() + "You are not in this war."); return; } else if (side == -1) { - player.sendMessage(Helper.Chatlabel() + "You have surrendered."); + siegeOwner.sendMessage(Helper.Chatlabel() + "You have surrendered."); if(admin) sender.sendMessage(Helper.Chatlabel() + "You have surrendered."); return; } //Minutemen countermeasures, 86400 * 4 time. 86400 seconds in a day, 4 days min playtime if (admin) { - if (System.currentTimeMillis() - CommandHelper.getPlayerJoinDate(args[3]) < 86400000L * Main.getInstance().getConfig().getInt("minimumPlayerAge") ) { + if (System.currentTimeMillis() - CommandHelper.getPlayerJoinDate(siegeOwner.getName()) < 86400000L * Main.getInstance().getConfig().getInt("minimumPlayerAge") ) { if(args.length >= 5) { if (Boolean.parseBoolean(args[4])) { //player has joined to recently @@ -105,20 +111,20 @@ public class SiegeCommands implements CommandExecutor { } else { //player has joined to recently sender.sendMessage(ChatColor.RED + "You have joined the server too recently! You can only join a war after 4 days from joining."); - player.getPlayer().sendMessage(ChatColor.RED + "You have joined the server too recently! You can only join a war after 4 days from joining."); + siegeOwner.getPlayer().sendMessage(ChatColor.RED + "You have joined the server too recently! You can only join a war after 4 days from joining."); return; } } else { //player has joined to recently sender.sendMessage(ChatColor.RED + "You have joined the server too recently! You can only join a war after 4 days from joining."); - player.getPlayer().sendMessage(ChatColor.RED + "You have joined the server too recently! You can only join a war after 4 days from joining."); + siegeOwner.getPlayer().sendMessage(ChatColor.RED + "You have joined the server too recently! You can only join a war after 4 days from joining."); return; } } } else { - if (System.currentTimeMillis() - CommandHelper.getPlayerJoinDate(player.getName()) < 86400000L * Main.getInstance().getConfig().getInt("minimumPlayerAge") ) { + if (System.currentTimeMillis() - CommandHelper.getPlayerJoinDate(siegeOwner.getName()) < 86400000L * Main.getInstance().getConfig().getInt("minimumPlayerAge") ) { //player has joined to recently - player.sendMessage(ChatColor.RED + "You have joined the server too recently! You can only join a war after 4 days from joining."); + siegeOwner.sendMessage(ChatColor.RED + "You have joined the server too recently! You can only join a war after 4 days from joining."); return; } } @@ -126,7 +132,7 @@ public class SiegeCommands implements CommandExecutor { // Town check Town town = TownyAPI.getInstance().getTown(args[2]); if (town == null) { - player.sendMessage(String.valueOf(Helper.Chatlabel()) + "That town does not exist! /siege start [war] [town]"); + siegeOwner.sendMessage(String.valueOf(Helper.Chatlabel()) + "That town does not exist! /siege start [war] [town]"); if(admin) sender.sendMessage(String.valueOf(Helper.Chatlabel()) + "That town does not exist! /siege start [war] [town]"); return; } @@ -134,19 +140,20 @@ public class SiegeCommands implements CommandExecutor { // Is being raided check for ( Raid r : RaidData.getRaids()) { if(r.getRaidedTown().getName().equals(town.getName())) { - player.sendMessage(String.valueOf(Helper.Chatlabel()) + "That town is already currently being raided! Cannot siege at this time!"); + siegeOwner.sendMessage(String.valueOf(Helper.Chatlabel()) + "That town is already currently being raided! Cannot siege at this time!"); if(admin) sender.sendMessage(String.valueOf(Helper.Chatlabel()) + "That town is already currently being raided! Cannot siege at this time!"); + return; } } // Attacking own side if (war.getSide(town) == side) { - player.sendMessage(Helper.Chatlabel() + "You cannot attack your own towns."); + siegeOwner.sendMessage(Helper.Chatlabel() + "You cannot attack your own towns."); if(admin) sender.sendMessage(Helper.Chatlabel() + "You cannot attack your own towns."); return; } - Siege siege = new Siege(war, town, player); + Siege siege = new Siege(war, town, siegeOwner); SiegeData.addSiege(siege); war.addSiege(siege); diff --git a/src/main/java/me/ShermansWorld/AlathraWar/data/RaidData.java b/src/main/java/me/ShermansWorld/AlathraWar/data/RaidData.java index dcdf0e1..edb6580 100644 --- a/src/main/java/me/ShermansWorld/AlathraWar/data/RaidData.java +++ b/src/main/java/me/ShermansWorld/AlathraWar/data/RaidData.java @@ -10,6 +10,7 @@ import me.ShermansWorld.AlathraWar.Main; import me.ShermansWorld.AlathraWar.Raid; import me.ShermansWorld.AlathraWar.War; import org.bukkit.Bukkit; +import org.bukkit.NamespacedKey; import org.bukkit.OfflinePlayer; import javax.annotation.Nonnull; @@ -19,10 +20,18 @@ public class RaidData { // Static Raid list for all active raids private static ArrayList raids = new ArrayList(); + + private static Set raidBars = new HashSet<>(); + + public static Set getRaidBars() { + return raidBars; + } + public static ArrayList getRaids() { return raids; } + /** * Gets a raid with a specific name * From 9d2b8612d26fe07deeba93da830994482b74439a Mon Sep 17 00:00:00 2001 From: Aubri Seebauer Date: Fri, 28 Apr 2023 18:55:58 -0400 Subject: [PATCH 3/5] awa purgebars, awa load/save framework --- .../me/ShermansWorld/AlathraWar/Raid.java | 2 + .../me/ShermansWorld/AlathraWar/Siege.java | 2 + .../AlathraWar/commands/AdminCommands.java | 62 +++++++++++++++++++ .../commands/AdminTabCompletion.java | 28 ++++++++- .../AlathraWar/data/RaidData.java | 4 ++ .../AlathraWar/data/SiegeData.java | 18 ++++-- 6 files changed, 109 insertions(+), 7 deletions(-) diff --git a/src/main/java/me/ShermansWorld/AlathraWar/Raid.java b/src/main/java/me/ShermansWorld/AlathraWar/Raid.java index a6e7a52..2f83f82 100644 --- a/src/main/java/me/ShermansWorld/AlathraWar/Raid.java +++ b/src/main/java/me/ShermansWorld/AlathraWar/Raid.java @@ -951,6 +951,7 @@ public class Raid { } public void refreshDisplayBar() { + RaidData.addRaidBar(bossBarKey); BossBar bossBar = Bukkit.getBossBar(bossBarKey); if(bossBar == null) bossBar = createNewDisplayBar(); @@ -973,6 +974,7 @@ public class Raid { } public void setupDisplayBar() { + RaidData.addRaidBar(bossBarKey); BossBar bossBar = Bukkit.getBossBar(bossBarKey); if(bossBar == null) bossBar = createNewDisplayBar(); diff --git a/src/main/java/me/ShermansWorld/AlathraWar/Siege.java b/src/main/java/me/ShermansWorld/AlathraWar/Siege.java index 99b8685..3f241a9 100644 --- a/src/main/java/me/ShermansWorld/AlathraWar/Siege.java +++ b/src/main/java/me/ShermansWorld/AlathraWar/Siege.java @@ -447,6 +447,7 @@ public class Siege { } public void refreshDisplayBar() { + SiegeData.addSiegeBar(bossBarKey); BossBar bossBar = Bukkit.getBossBar(bossBarKey); if(bossBar == null) bossBar = createNewDisplayBar(); @@ -469,6 +470,7 @@ public class Siege { } public void setupDisplayBar() { + SiegeData.addSiegeBar(bossBarKey); BossBar bossBar = Bukkit.getBossBar(bossBarKey); if(bossBar == null) bossBar = createNewDisplayBar(); diff --git a/src/main/java/me/ShermansWorld/AlathraWar/commands/AdminCommands.java b/src/main/java/me/ShermansWorld/AlathraWar/commands/AdminCommands.java index 3817c49..219788f 100644 --- a/src/main/java/me/ShermansWorld/AlathraWar/commands/AdminCommands.java +++ b/src/main/java/me/ShermansWorld/AlathraWar/commands/AdminCommands.java @@ -14,6 +14,8 @@ import me.ShermansWorld.AlathraWar.data.SiegeData; import me.ShermansWorld.AlathraWar.data.WarData; import org.bukkit.Bukkit; import org.bukkit.Location; +import org.bukkit.NamespacedKey; +import org.bukkit.boss.BossBar; import org.bukkit.command.Command; import org.bukkit.command.CommandExecutor; import org.bukkit.command.CommandSender; @@ -125,11 +127,71 @@ public class AdminCommands implements CommandExecutor { return modify(sender, args); } else if (args[0].equalsIgnoreCase("awa")) { 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; } + 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 diff --git a/src/main/java/me/ShermansWorld/AlathraWar/commands/AdminTabCompletion.java b/src/main/java/me/ShermansWorld/AlathraWar/commands/AdminTabCompletion.java index c14573c..7547e1c 100644 --- a/src/main/java/me/ShermansWorld/AlathraWar/commands/AdminTabCompletion.java +++ b/src/main/java/me/ShermansWorld/AlathraWar/commands/AdminTabCompletion.java @@ -15,7 +15,12 @@ public class AdminTabCompletion implements TabCompleter { "force", "help", "info", - "modify" + "modify", + "purgebars", + "load", + "load-all", + "save", + "save-all" }); List type = List.of(new String[]{ @@ -186,7 +191,26 @@ public class AdminTabCompletion implements TabCompleter { } else if (args.length == 1) { return NameUtil.filterByStart(base, args[0]); } 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) { switch (args[1]) { case "raid" -> { diff --git a/src/main/java/me/ShermansWorld/AlathraWar/data/RaidData.java b/src/main/java/me/ShermansWorld/AlathraWar/data/RaidData.java index edb6580..64a24da 100644 --- a/src/main/java/me/ShermansWorld/AlathraWar/data/RaidData.java +++ b/src/main/java/me/ShermansWorld/AlathraWar/data/RaidData.java @@ -27,6 +27,10 @@ public class RaidData { return raidBars; } + public static void addRaidBar(NamespacedKey key) { + raidBars.add(key); + } + public static ArrayList getRaids() { return raids; } diff --git a/src/main/java/me/ShermansWorld/AlathraWar/data/SiegeData.java b/src/main/java/me/ShermansWorld/AlathraWar/data/SiegeData.java index c8d9fe7..034f48e 100644 --- a/src/main/java/me/ShermansWorld/AlathraWar/data/SiegeData.java +++ b/src/main/java/me/ShermansWorld/AlathraWar/data/SiegeData.java @@ -1,12 +1,9 @@ package me.ShermansWorld.AlathraWar.data; -import java.util.ArrayList; -import java.util.Collection; -import java.util.HashMap; -import java.util.HashSet; -import java.util.UUID; +import java.util.*; import org.bukkit.Bukkit; +import org.bukkit.NamespacedKey; import org.bukkit.OfflinePlayer; import com.palmergames.bukkit.towny.TownyAPI; @@ -26,6 +23,17 @@ public class SiegeData return sieges; } + private static Set siegeBars = new HashSet<>(); + + public static Set getSiegeBars() { + return siegeBars; + } + + public static void addSiegeBar(NamespacedKey key) { + siegeBars.add(key); + } + + /** * Gets a siege with a specific name * @param name - Name to check From cd61aa175c6d4354f43f0fa03ddbe283ecc46d3a Mon Sep 17 00:00:00 2001 From: Aubri Seebauer Date: Fri, 28 Apr 2023 18:57:41 -0400 Subject: [PATCH 4/5] chatLabel name refactor --- .../me/ShermansWorld/AlathraWar/Helper.java | 2 +- .../me/ShermansWorld/AlathraWar/Raid.java | 66 +-- .../me/ShermansWorld/AlathraWar/Siege.java | 28 +- .../AlathraWar/commands/AdminCommands.java | 430 +++++++++--------- .../AlathraWar/commands/RaidCommands.java | 174 +++---- .../AlathraWar/commands/SiegeCommands.java | 66 +-- .../AlathraWar/commands/WarCommands.java | 56 +-- .../listeners/CommandsListener.java | 36 +- .../AlathraWar/listeners/KillsListener.java | 10 +- 9 files changed, 434 insertions(+), 434 deletions(-) diff --git a/src/main/java/me/ShermansWorld/AlathraWar/Helper.java b/src/main/java/me/ShermansWorld/AlathraWar/Helper.java index 0678dba..77c3876 100644 --- a/src/main/java/me/ShermansWorld/AlathraWar/Helper.java +++ b/src/main/java/me/ShermansWorld/AlathraWar/Helper.java @@ -18,7 +18,7 @@ public class Helper return ChatColor.translateAlternateColorCodes('&', input); } - public static String Chatlabel() { + public static String chatLabel() { return color("&6[&4AlathraWar&6]&r "); } diff --git a/src/main/java/me/ShermansWorld/AlathraWar/Raid.java b/src/main/java/me/ShermansWorld/AlathraWar/Raid.java index 2f83f82..cb77c05 100644 --- a/src/main/java/me/ShermansWorld/AlathraWar/Raid.java +++ b/src/main/java/me/ShermansWorld/AlathraWar/Raid.java @@ -285,11 +285,11 @@ public class Raid { //Broadcast to the whole raid for (String s : activeRaiders) { Player pl = Bukkit.getPlayer(s); - if(pl != null) pl.sendMessage(Helper.Chatlabel() + String.format("A townblock has been looted for $%.2f and +10 points. (Added to pool)", lb.value)); + if(pl != null) pl.sendMessage(Helper.chatLabel() + String.format("A townblock has been looted for $%.2f and +10 points. (Added to pool)", lb.value)); } for (String s : defenderPlayers) { Player pl = Bukkit.getPlayer(s); - if(pl != null) pl.sendMessage(Helper.Chatlabel() + String.format("A townblock has been looted for $%.2f and +10 points. (Added to pool)", lb.value)); + if(pl != null) pl.sendMessage(Helper.chatLabel() + String.format("A townblock has been looted for $%.2f and +10 points. (Added to pool)", lb.value)); } this.save(); @@ -299,11 +299,11 @@ public class Raid { this.addLootedChunk(wc); for (String s : activeRaiders) { Player pl = Bukkit.getPlayer(s); - if(pl != null) pl.sendMessage(String.valueOf(Helper.Chatlabel()) + "Raiders have started looting a town block!"); + if(pl != null) pl.sendMessage(String.valueOf(Helper.chatLabel()) + "Raiders have started looting a town block!"); } for (String s : defenderPlayers) { Player pl = Bukkit.getPlayer(s); - if(pl != null) pl.sendMessage(String.valueOf(Helper.Chatlabel()) + "Raiders have started looting a town block!"); + if(pl != null) pl.sendMessage(String.valueOf(Helper.chatLabel()) + "Raiders have started looting a town block!"); } } @@ -321,7 +321,7 @@ public class Raid { */ private void startTravel() { Raid.this.phase = RaidPhase.TRAVEL; - Bukkit.broadcastMessage(String.valueOf(Helper.Chatlabel()) + "The Raiders of " + Bukkit.broadcastMessage(String.valueOf(Helper.chatLabel()) + "The Raiders of " + (side1AreRaiders ? Raid.this.war.getSide1() : Raid.this.war.getSide2()) + " are coming to raid " + Raid.this.getRaidedTown().getName() + "!"); @@ -334,7 +334,7 @@ public class Raid { */ private void startCombat() { Raid.this.phase = RaidPhase.COMBAT; - Bukkit.broadcastMessage(String.valueOf(Helper.Chatlabel()) + "The Raiders of " + Bukkit.broadcastMessage(String.valueOf(Helper.chatLabel()) + "The Raiders of " + (side1AreRaiders ? Raid.this.war.getSide1() : Raid.this.war.getSide2()) + " have arrived at " + Raid.this.getRaidedTown().getName() + " and the fighting has begun!"); @@ -351,11 +351,11 @@ public class Raid { this.addPointsToDefenderScore(40); for (final String playerName : this.getActiveRaiders()) { Player pl = Bukkit.getPlayer(playerName); - if(pl != null) pl.sendMessage(String.valueOf(Helper.Chatlabel()) + "Raider killed! -40 Raid Score"); + if(pl != null) pl.sendMessage(String.valueOf(Helper.chatLabel()) + "Raider killed! -40 Raid Score"); } for (final String playerName : this.getDefenderPlayers()) { Player pl = Bukkit.getPlayer(playerName); - if(pl != null) pl.sendMessage(String.valueOf(Helper.Chatlabel()) + "Raider killed! -40 Raid Score"); + if(pl != null) pl.sendMessage(String.valueOf(Helper.chatLabel()) + "Raider killed! -40 Raid Score"); } } @@ -366,11 +366,11 @@ public class Raid { this.addPointsToRaiderScore(20); for (final String playerName : this.getActiveRaiders()) { Player pl = Bukkit.getPlayer(playerName); - if(pl != null) pl.sendMessage(String.valueOf(Helper.Chatlabel()) + "Defender killed! +20 Raid Score"); + if(pl != null) pl.sendMessage(String.valueOf(Helper.chatLabel()) + "Defender killed! +20 Raid Score"); } for (final String playerName : this.getDefenderPlayers()) { Player pl = Bukkit.getPlayer(playerName); - if(pl != null) pl.sendMessage(String.valueOf(Helper.Chatlabel()) + "Defender killed! +20 Raid Score"); + if(pl != null) pl.sendMessage(String.valueOf(Helper.chatLabel()) + "Defender killed! +20 Raid Score"); } // //tp to raid town spawn @@ -389,11 +389,11 @@ public class Raid { //award negative score for (final String playerName : this.getActiveRaiders()) { Player pl = Bukkit.getPlayer(playerName); - if(pl != null) pl.sendMessage(String.valueOf(Helper.Chatlabel()) + "Raider killed before combat, no points awarded and death treated normally."); + if(pl != null) pl.sendMessage(String.valueOf(Helper.chatLabel()) + "Raider killed before combat, no points awarded and death treated normally."); } for (final String playerName : this.getDefenderPlayers()) { Player pl = Bukkit.getPlayer(playerName); - if(pl != null) pl.sendMessage(String.valueOf(Helper.Chatlabel()) + "Raider killed before combat, no points awarded and death treated normally."); + if(pl != null) pl.sendMessage(String.valueOf(Helper.chatLabel()) + "Raider killed before combat, no points awarded and death treated normally."); } // // //tp to gather town spawn @@ -410,7 +410,7 @@ public class Raid { if (this.getDefenderSide().contains(killed.getKiller().getName())) { try { killed.getKiller().teleport(this.getRaidedTown().getSpawn()); - killed.getKiller().sendMessage(String.valueOf(Helper.Chatlabel()) + "You killed a raider before the raid began and have been teleported back to the defending town."); + killed.getKiller().sendMessage(String.valueOf(Helper.chatLabel()) + "You killed a raider before the raid began and have been teleported back to the defending town."); } catch (TownyException e) { throw new RuntimeException(e); } @@ -424,11 +424,11 @@ public class Raid { public void defenderKilledOutofCombat(PlayerDeathEvent event) { for (final String playerName : this.getActiveRaiders()) { Player pl = Bukkit.getPlayer(playerName); - if(pl != null) pl.sendMessage(String.valueOf(Helper.Chatlabel()) + "Defender killed before combat, no points awarded and death treated normally."); + if(pl != null) pl.sendMessage(String.valueOf(Helper.chatLabel()) + "Defender killed before combat, no points awarded and death treated normally."); } for (final String playerName : this.getDefenderPlayers()) { Player pl = Bukkit.getPlayer(playerName); - if(pl != null) pl.sendMessage(String.valueOf(Helper.Chatlabel()) + "Defender killed before combat, no points awarded and death treated normally."); + if(pl != null) pl.sendMessage(String.valueOf(Helper.chatLabel()) + "Defender killed before combat, no points awarded and death treated normally."); } //tp to raid town spawn @@ -443,7 +443,7 @@ public class Raid { if (this.getActiveRaiders().contains(killed.getKiller().getName())) { try { killed.getKiller().teleport(this.getGatherTown().getSpawn()); - killed.getKiller().sendMessage(String.valueOf(Helper.Chatlabel()) + "You killed a defender before the raid began and have been teleported back to the gather town."); + killed.getKiller().sendMessage(String.valueOf(Helper.chatLabel()) + "You killed a defender before the raid began and have been teleported back to the gather town."); } catch (TownyException e) { throw new RuntimeException(e); } @@ -466,7 +466,7 @@ public class Raid { if (factor > 3.0) factor = 3.0; if (factor < 0) factor = 0.0; - Bukkit.broadcastMessage(String.valueOf(Helper.Chatlabel()) + "The raiders from " + this.raiders + Bukkit.broadcastMessage(String.valueOf(Helper.chatLabel()) + "The raiders from " + this.raiders + " have successfully raided " + this.raidedTown.getName() + "!"); /* @@ -554,25 +554,25 @@ public class Raid { if (factor < 0) factor = 0.0; if (factor <= 0.5) { - Bukkit.broadcastMessage(Helper.Chatlabel() + "The defenders from " + this.defenders + Bukkit.broadcastMessage(Helper.chatLabel() + "The defenders from " + this.defenders + " have barely pushed back the raiders of " + this.raiders + ". More has been lost than gained."); - Bukkit.broadcastMessage(Helper.Chatlabel() + this.raidedTown.getName() + Bukkit.broadcastMessage(Helper.chatLabel() + this.raidedTown.getName() + " has recovered part of the attackers' raid chest, valued at $500"); Main.warLogger .log("The defenders from " + this.defenders + " have won the raid of " + this.raidedTown.getName() + "!"); this.raidedTown.getAccount().deposit(500, "Raid chest"); } else if (factor <= 1.5) { - Bukkit.broadcastMessage(Helper.Chatlabel() + "The defenders from " + this.defenders + Bukkit.broadcastMessage(Helper.chatLabel() + "The defenders from " + this.defenders + " have fended off the raiders of " + this.raiders + "!"); - Bukkit.broadcastMessage(Helper.Chatlabel() + this.raidedTown.getName() + Bukkit.broadcastMessage(Helper.chatLabel() + this.raidedTown.getName() + " has recovered the attackers' raid chest, valued at $1000"); Main.warLogger .log("The defenders from " + this.defenders + " have won the raid of " + this.raidedTown.getName() + "!"); this.raidedTown.getAccount().deposit(1000, "Raid chest"); } else if (factor <= 3.0) { - Bukkit.broadcastMessage(Helper.Chatlabel() + "The defenders from " + this.defenders + Bukkit.broadcastMessage(Helper.chatLabel() + "The defenders from " + this.defenders + " have wholly defeated the raiders of " + this.raiders + "! They barely broke the walls."); - Bukkit.broadcastMessage(Helper.Chatlabel() + this.raidedTown.getName() + Bukkit.broadcastMessage(Helper.chatLabel() + this.raidedTown.getName() + " has recovered the attackers' raid chest, valued at $1000."); Main.warLogger .log("The defenders from " + this.defenders + " have won the raid of " + this.raidedTown.getName() + "!"); @@ -594,7 +594,7 @@ public class Raid { public void noWinner() { //TODO finalize payout - Bukkit.broadcastMessage(String.valueOf(Helper.Chatlabel()) + "The defenders from " + this.defenders + Bukkit.broadcastMessage(String.valueOf(Helper.chatLabel()) + "The defenders from " + this.defenders + " didn't push back the raiders of " + this.raiders + ". Yet no loot was taken, raid considered a draw."); Main.warLogger .log("No one won the raid of " + this.raidedTown.getName() + "!"); @@ -837,7 +837,7 @@ public class Raid { if (Raid.this.phase == RaidPhase.GATHER) { //Broadcast if (raidTicks % 6000 == 0) { - Bukkit.broadcastMessage(String.valueOf(Helper.Chatlabel()) + "The raid of " + Bukkit.broadcastMessage(String.valueOf(Helper.chatLabel()) + "The raid of " + Raid.this.getRaidedTown().getName() + " will begin in " + (int) ((RaidPhase.TRAVEL.startTick - raidTicks) / 20 / 60) + " minutes!"); Bukkit.broadcastMessage( "The Raiders are gathering at " + getGatherTown().getName() + " before making the journey over!"); @@ -853,12 +853,12 @@ public class Raid { if (!cluster.contains(WorldCoord.parseWorldCoord(p))) { if (p.equals(owner)) { p.teleport(gatherTown.getSpawn()); - p.sendMessage(String.valueOf(Helper.Chatlabel()) + "You cannot leave the gather town. As raid party leader, you have remained in the party. To stop the raid type /raid abandon"); - p.sendMessage(String.valueOf(Helper.Chatlabel()) + "You have been teleported to the gather town's spawn."); + p.sendMessage(String.valueOf(Helper.chatLabel()) + "You cannot leave the gather town. As raid party leader, you have remained in the party. To stop the raid type /raid abandon"); + p.sendMessage(String.valueOf(Helper.chatLabel()) + "You have been teleported to the gather town's spawn."); } else { Raid.this.removeActiveRaider(p.getName()); - p.sendMessage(String.valueOf(Helper.Chatlabel()) + "By leaving the gathering town you have left the raid on " + Raid.this.getRaidedTown().getName() + "!"); - p.sendMessage(String.valueOf(Helper.Chatlabel()) + "To rejoin, do /raid join [war] [town]"); + p.sendMessage(String.valueOf(Helper.chatLabel()) + "By leaving the gathering town you have left the raid on " + Raid.this.getRaidedTown().getName() + "!"); + p.sendMessage(String.valueOf(Helper.chatLabel()) + "To rejoin, do /raid join [war] [town]"); } } } @@ -873,7 +873,7 @@ public class Raid { //Report if (raidTicks % 2400 == 0) { - Bukkit.broadcastMessage(String.valueOf(Helper.Chatlabel()) + "The Raiders of " + Bukkit.broadcastMessage(String.valueOf(Helper.chatLabel()) + "The Raiders of " + (side1AreRaiders ? Raid.this.war.getSide1() : Raid.this.war.getSide2()) + " are on their way to raid " + Raid.this.getRaidedTown().getName() + "!"); @@ -908,7 +908,7 @@ public class Raid { //Report if (Raid.this.raidTicks % 6000 == 0) { - Bukkit.broadcastMessage(Helper.Chatlabel() + "Report on the raid of " + Bukkit.broadcastMessage(Helper.chatLabel() + "Report on the raid of " + Raid.this.getRaidedTown().getName() + ":"); Bukkit.broadcastMessage( "Raider Score - " + Raid.this.raiderScore); @@ -928,7 +928,7 @@ public class Raid { //Idk if thisll work but if it do then ye if (Raid.this.lootedChunks.containsKey(wc)) { if (Raid.this.lootedChunks.get(wc).finished) { - p.sendMessage(Helper.Chatlabel() + "This chunk is already looted, try another."); + p.sendMessage(Helper.chatLabel() + "This chunk is already looted, try another."); } else { doLootAt(p, wc); } @@ -936,7 +936,7 @@ public class Raid { if (Raid.this.getRaidedTown().hasTownBlock(wc)) { doLootAt(p, wc); } else { - p.sendMessage(Helper.Chatlabel() + "This space is not part of the raided town, you cannot loot this area."); + p.sendMessage(Helper.chatLabel() + "This space is not part of the raided town, you cannot loot this area."); } } } diff --git a/src/main/java/me/ShermansWorld/AlathraWar/Siege.java b/src/main/java/me/ShermansWorld/AlathraWar/Siege.java index 3f241a9..af2da11 100644 --- a/src/main/java/me/ShermansWorld/AlathraWar/Siege.java +++ b/src/main/java/me/ShermansWorld/AlathraWar/Siege.java @@ -134,14 +134,14 @@ public class Siege { if (this.homeBlockControl != 1) { for (final String playerName : Siege.this.attackerPlayers) { try { - Bukkit.getPlayer(playerName).sendMessage(String.valueOf(Helper.Chatlabel()) + Bukkit.getPlayer(playerName).sendMessage(String.valueOf(Helper.chatLabel()) + "HomeBlock at " + Siege.this.town.getName() + " contested!"); } catch (NullPointerException ex5) { } } for (final String playerName : Siege.this.defenderPlayers) { try { - Bukkit.getPlayer(playerName).sendMessage(String.valueOf(Helper.Chatlabel()) + Bukkit.getPlayer(playerName).sendMessage(String.valueOf(Helper.chatLabel()) + "HomeBlock at " + Siege.this.town.getName() + " contested!"); } catch (NullPointerException ex6) { } @@ -152,7 +152,7 @@ public class Siege { if (this.homeBlockControl != 2) { for (final String playerName : Siege.this.attackerPlayers) { try { - Bukkit.getPlayer(playerName).sendMessage(String.valueOf(Helper.Chatlabel()) + Bukkit.getPlayer(playerName).sendMessage(String.valueOf(Helper.chatLabel()) + "Attackers have captured the HomeBlock at " + Siege.this.town.getName() + "! +1 Attacker Points per second"); } catch (NullPointerException ex7) { @@ -160,7 +160,7 @@ public class Siege { } for (final String playerName : Siege.this.defenderPlayers) { try { - Bukkit.getPlayer(playerName).sendMessage(String.valueOf(Helper.Chatlabel()) + Bukkit.getPlayer(playerName).sendMessage(String.valueOf(Helper.chatLabel()) + "Attackers have captured the HomeBlock at " + Siege.this.town.getName() + "! +1 Attacker Points per second"); } catch (NullPointerException ex8) { @@ -173,7 +173,7 @@ public class Siege { if (this.homeBlockControl != 3) { for (final String playerName : Siege.this.attackerPlayers) { try { - Bukkit.getPlayer(playerName).sendMessage(String.valueOf(Helper.Chatlabel()) + Bukkit.getPlayer(playerName).sendMessage(String.valueOf(Helper.chatLabel()) + "Defenders retain control of the HomeBlock at " + Siege.this.town.getName() + "! +1 Defender Points per second"); } catch (NullPointerException ex9) { @@ -181,7 +181,7 @@ public class Siege { } for (final String playerName : Siege.this.defenderPlayers) { try { - Bukkit.getPlayer(playerName).sendMessage(String.valueOf(Helper.Chatlabel()) + Bukkit.getPlayer(playerName).sendMessage(String.valueOf(Helper.chatLabel()) + "Defenders retain control of the HomeBlock at " + Siege.this.town.getName() + "! +1 Defender Points per second"); } catch (NullPointerException ex10) { @@ -192,7 +192,7 @@ public class Siege { this.homeBlockControl = 3; } if (Siege.this.siegeTicks % 6000 == 0) { // Updates every 5 minutes - Bukkit.broadcastMessage(String.valueOf(Helper.Chatlabel()) + "Report on the siege of " + Bukkit.broadcastMessage(String.valueOf(Helper.chatLabel()) + "Report on the siege of " + Siege.this.town.getName() + ":"); Bukkit.broadcastMessage( "Attacker Points - " + String.valueOf(Siege.this.attackerPoints)); @@ -232,12 +232,12 @@ public class Siege { public void attackersWin(final OfflinePlayer siegeLeader) { final Resident resident = TownyAPI.getInstance().getResident(siegeLeader.getUniqueId()); Nation nation = null; - Bukkit.broadcastMessage(String.valueOf(Helper.Chatlabel()) + "The attackers have won the siege of " + this.town.getName() + "!"); + Bukkit.broadcastMessage(String.valueOf(Helper.chatLabel()) + "The attackers have won the siege of " + this.town.getName() + "!"); try { nation = resident.getTown().getNation(); } catch (Exception e) {} if (nation != null) { - Bukkit.broadcastMessage(String.valueOf(Helper.Chatlabel()) + "The town of " + this.town.getName() + Bukkit.broadcastMessage(String.valueOf(Helper.chatLabel()) + "The town of " + this.town.getName() + " has been placed under occupation by " + nation.getName() + "!"); } Main.econ.depositPlayer(siegeLeader, 2500.0); @@ -248,7 +248,7 @@ public class Siege { } else { if (this.town.getAccount().getHoldingBalance() < 2500.0) { amt = this.town.getAccount().getHoldingBalance(); - Bukkit.broadcastMessage(String.valueOf(Helper.Chatlabel()) + "The town of " + this.town.getName() + Bukkit.broadcastMessage(String.valueOf(Helper.chatLabel()) + "The town of " + this.town.getName() + " has been destroyed by " + this.getAttackerSide() + "!"); TownyUniverse.getInstance().getDataSource().deleteTown(this.town); Main.econ.depositPlayer(siegeLeader, amt); @@ -275,8 +275,8 @@ public class Siege { public void defendersWin() { this.town.getAccount().deposit(2500.0, "War chest"); - Bukkit.broadcastMessage(String.valueOf(Helper.Chatlabel()) + "The defenders have won the siege of " + this.town.getName() + "!"); - Bukkit.broadcastMessage(String.valueOf(Helper.Chatlabel()) + this.town.getName() + Bukkit.broadcastMessage(String.valueOf(Helper.chatLabel()) + "The defenders have won the siege of " + this.town.getName() + "!"); + Bukkit.broadcastMessage(String.valueOf(Helper.chatLabel()) + this.town.getName() + " has recovered the attackers' war chest, valued at $2,500"); Main.warLogger .log(war.getName() + ": The defenders have won the siege of " + this.town.getName() + "!"); @@ -295,8 +295,8 @@ public class Siege { * No winnder declared */ public void noWinner() { - Bukkit.broadcastMessage(String.valueOf(Helper.Chatlabel()) + "The siege of " + this.town.getName() + " was a draw!"); - Bukkit.broadcastMessage(String.valueOf(Helper.Chatlabel()) + "No money has been recovered."); + Bukkit.broadcastMessage(String.valueOf(Helper.chatLabel()) + "The siege of " + this.town.getName() + " was a draw!"); + Bukkit.broadcastMessage(String.valueOf(Helper.chatLabel()) + "No money has been recovered."); Main.warLogger .log(war.getName() + ": No one won the siege of " + this.town.getName() + "!"); stop(); diff --git a/src/main/java/me/ShermansWorld/AlathraWar/commands/AdminCommands.java b/src/main/java/me/ShermansWorld/AlathraWar/commands/AdminCommands.java index 219788f..433e8ef 100644 --- a/src/main/java/me/ShermansWorld/AlathraWar/commands/AdminCommands.java +++ b/src/main/java/me/ShermansWorld/AlathraWar/commands/AdminCommands.java @@ -160,35 +160,35 @@ public class AdminCommands implements CommandExecutor { 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.")); + 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!")); + 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!")); + 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!")); + 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!")); + sender.sendMessage(Helper.chatLabel() + Helper.color("&cload-all Unimplemented!")); return true; } @@ -282,12 +282,12 @@ public class AdminCommands implements CommandExecutor { if (r.getSide1AreRaiders()) { if (args[5].equals(r.getWar().getSide1())) { r.raidersWin(r.getOwner(), r.getRaiderScore(), r.getDefenderScore()); - p.sendMessage(Helper.Chatlabel() + "Raid forcefully ended on " + args[4] + " in war " + args[3] + " with " + args[5] + " (raiders) declared as victor."); + p.sendMessage(Helper.chatLabel() + "Raid forcefully ended on " + args[4] + " in war " + args[3] + " with " + args[5] + " (raiders) declared as victor."); Main.warLogger.log("Raid forcefully ended on " + args[4] + " in war " + args[3] + " with " + args[5] + " (raiders) declared as victor."); return true; } else if (args[5].equals(r.getWar().getSide2())) { r.defendersWin(r.getRaiderScore(), r.getDefenderScore()); - p.sendMessage(Helper.Chatlabel() + "Raid forcefully ended on " + args[4] + " in war " + args[3] + " with " + args[5] + " (defenders) declared as victor."); + p.sendMessage(Helper.chatLabel() + "Raid forcefully ended on " + args[4] + " in war " + args[3] + " with " + args[5] + " (defenders) declared as victor."); Main.warLogger.log("Raid forcefully ended on " + args[4] + " in war " + args[3] + " with " + args[5] + " (defenders) declared as victor."); return true; } else { @@ -297,12 +297,12 @@ public class AdminCommands implements CommandExecutor { } else { if (args[5].equals(r.getWar().getSide1())) { r.defendersWin(r.getRaiderScore(), r.getDefenderScore()); - p.sendMessage(Helper.Chatlabel() + "Raid forcefully ended on " + args[4] + " in war " + args[3] + " with " + args[5] + " (defenders) declared as victor."); + p.sendMessage(Helper.chatLabel() + "Raid forcefully ended on " + args[4] + " in war " + args[3] + " with " + args[5] + " (defenders) declared as victor."); Main.warLogger.log("Raid forcefully ended on " + args[4] + " in war " + args[3] + " with " + args[5] + " (defenders) declared as victor."); return true; } else if (args[5].equals(r.getWar().getSide2())) { r.raidersWin(r.getOwner(), r.getRaiderScore(), r.getDefenderScore()); - p.sendMessage(Helper.Chatlabel() + "Raid forcefully ended on " + args[4] + " in war " + args[3] + " with " + args[5] + " (raiders) declared as victor."); + p.sendMessage(Helper.chatLabel() + "Raid forcefully ended on " + args[4] + " in war " + args[3] + " with " + args[5] + " (raiders) declared as victor."); Main.warLogger.log("Raid forcefully ended on " + args[4] + " in war " + args[3] + " with " + args[5] + " (raiders) declared as victor."); return true; } else { @@ -314,7 +314,7 @@ public class AdminCommands implements CommandExecutor { } else if (args.length == 5) { if (r.getWar().getName().equals(args[3]) && r.getRaidedTown().getName().equals(args[4])) { r.noWinner(); - p.sendMessage(Helper.Chatlabel() + "Raid forcefully ended on " + args[4] + " in war " + args[3] + " with no victor."); + p.sendMessage(Helper.chatLabel() + "Raid forcefully ended on " + args[4] + " in war " + args[3] + " with no victor."); Main.warLogger.log("Raid forcefully ended on " + args[4] + " in war " + args[3] + " with no victor."); return true; } @@ -333,12 +333,12 @@ public class AdminCommands implements CommandExecutor { if (s.getSide1AreAttackers()) { if (args[5].equals(s.getWar().getSide1())) { s.attackersWin(s.getSiegeOwner()); - p.sendMessage(Helper.Chatlabel() + "Siege forcefully ended on " + args[4] + " in war " + args[3] + " with " + args[6] + " (attackers) declared as victor."); + p.sendMessage(Helper.chatLabel() + "Siege forcefully ended on " + args[4] + " in war " + args[3] + " with " + args[6] + " (attackers) declared as victor."); Main.warLogger.log("Siege forcefully ended on " + args[4] + " in war " + args[3] + " with " + args[6] + " (attackers) declared as victor."); return true; } else if (args[5].equals(s.getWar().getSide2())) { s.defendersWin(); - p.sendMessage(Helper.Chatlabel() + "Siege forcefully ended on " + args[4] + " in war " + args[3] + " with " + args[6] + " (defenders) declared as victor."); + p.sendMessage(Helper.chatLabel() + "Siege forcefully ended on " + args[4] + " in war " + args[3] + " with " + args[6] + " (defenders) declared as victor."); Main.warLogger.log("Siege forcefully ended on " + args[4] + " in war " + args[3] + " with " + args[6] + " (defenders) declared as victor."); return true; } else { @@ -348,12 +348,12 @@ public class AdminCommands implements CommandExecutor { } else { if (args[5].equals(s.getWar().getSide1())) { s.defendersWin(); - p.sendMessage(Helper.Chatlabel() + "Siege forcefully ended on " + args[4] + " in war " + args[3] + " with " + args[6] + " (defenders) declared as victor."); + p.sendMessage(Helper.chatLabel() + "Siege forcefully ended on " + args[4] + " in war " + args[3] + " with " + args[6] + " (defenders) declared as victor."); Main.warLogger.log("Siege forcefully ended on " + args[4] + " in war " + args[3] + " with " + args[6] + " (defenders) declared as victor."); return true; } else if (args[5].equals(s.getWar().getSide2())) { s.attackersWin(s.getSiegeOwner()); - p.sendMessage(Helper.Chatlabel() + "Siege forcefully ended on " + args[4] + " in war " + args[3] + " with " + args[6] + " (attackers) declared as victor."); + p.sendMessage(Helper.chatLabel() + "Siege forcefully ended on " + args[4] + " in war " + args[3] + " with " + args[6] + " (attackers) declared as victor."); Main.warLogger.log("Siege forcefully ended on " + args[4] + " in war " + args[3] + " with " + args[6] + " (attackers) declared as victor."); return true; } else { @@ -365,7 +365,7 @@ public class AdminCommands implements CommandExecutor { } else if (args.length == 5) { if (s.getWar().getName().equals(args[3]) && s.getTown().getName().equals(args[4])) { s.noWinner(); - p.sendMessage(Helper.Chatlabel() + "Siege forcefully ended on " + args[4] + " in war " + args[3] + " with no victor."); + p.sendMessage(Helper.chatLabel() + "Siege forcefully ended on " + args[4] + " in war " + args[3] + " with no victor."); Main.warLogger.log("Siege forcefully ended on " + args[4] + " in war " + args[3] + " with no victor."); return true; } @@ -460,7 +460,7 @@ public class AdminCommands implements CommandExecutor { args[5] }; RaidCommands.leaveRaid(p, fixed, true); - p.sendMessage(Helper.Chatlabel() + "Forced player " + args[5] + " to leave raid on " + args[4] + " in war " + args[3]); + p.sendMessage(Helper.chatLabel() + "Forced player " + args[5] + " to leave raid on " + args[4] + " in war " + args[3]); Main.warLogger.log("Forced player " + args[5] + " to leave raid on " + args[4] + " in war " + args[3]); return finalizeRaid(r); } else { @@ -498,11 +498,11 @@ public class AdminCommands implements CommandExecutor { } private static boolean help(CommandSender p, String[] args) { - p.sendMessage(Helper.Chatlabel() + "/alathrawaradmin create"); - p.sendMessage(Helper.Chatlabel() + "/alathrawaradmin force"); - p.sendMessage(Helper.Chatlabel() + "/alathrawaradmin help"); - p.sendMessage(Helper.Chatlabel() + "/alathrawaradmin info"); - p.sendMessage(Helper.Chatlabel() + "/alathrawaradmin modify"); + p.sendMessage(Helper.chatLabel() + "/alathrawaradmin create"); + p.sendMessage(Helper.chatLabel() + "/alathrawaradmin force"); + p.sendMessage(Helper.chatLabel() + "/alathrawaradmin help"); + p.sendMessage(Helper.chatLabel() + "/alathrawaradmin info"); + p.sendMessage(Helper.chatLabel() + "/alathrawaradmin modify"); return true; } @@ -524,16 +524,16 @@ public class AdminCommands implements CommandExecutor { if (args.length >= 3) { for (War w : WarData.getWars()) { if (w.getName().equals(args[2])) { - p.sendMessage(Helper.Chatlabel() + "Info dump for war: " + w.getName()); - p.sendMessage(Helper.Chatlabel() + "oOo------------===------------oOo"); - p.sendMessage(Helper.Chatlabel() + "Name: " + w.getName()); - p.sendMessage(Helper.Chatlabel() + "Side 1: " + w.getSide1()); - p.sendMessage(Helper.Chatlabel() + "Side 2: " + w.getSide2()); - p.sendMessage(Helper.Chatlabel() + "Side 1 Score: " + w.getSide1Points()); - p.sendMessage(Helper.Chatlabel() + "Side 2 Score: " + w.getSide2Points()); - p.sendMessage(Helper.Chatlabel() + "Last Raid for Side 1: " + new Timestamp(((long) w.getLastRaidTimeSide1()) * 1000L)); - p.sendMessage(Helper.Chatlabel() + "Last Raid for Side 2: " + new Timestamp(((long) w.getLastRaidTimeSide2()) * 1000L)); - p.sendMessage(Helper.Chatlabel() + "oOo------------===------------oOo"); + p.sendMessage(Helper.chatLabel() + "Info dump for war: " + w.getName()); + p.sendMessage(Helper.chatLabel() + "oOo------------===------------oOo"); + p.sendMessage(Helper.chatLabel() + "Name: " + w.getName()); + p.sendMessage(Helper.chatLabel() + "Side 1: " + w.getSide1()); + p.sendMessage(Helper.chatLabel() + "Side 2: " + w.getSide2()); + p.sendMessage(Helper.chatLabel() + "Side 1 Score: " + w.getSide1Points()); + p.sendMessage(Helper.chatLabel() + "Side 2 Score: " + w.getSide2Points()); + p.sendMessage(Helper.chatLabel() + "Last Raid for Side 1: " + new Timestamp(((long) w.getLastRaidTimeSide1()) * 1000L)); + p.sendMessage(Helper.chatLabel() + "Last Raid for Side 2: " + new Timestamp(((long) w.getLastRaidTimeSide2()) * 1000L)); + p.sendMessage(Helper.chatLabel() + "oOo------------===------------oOo"); StringBuilder side1Towns = new StringBuilder(); StringBuilder side1Players = new StringBuilder(); for (String t : w.getSide1Towns()) { @@ -547,10 +547,10 @@ public class AdminCommands implements CommandExecutor { //cut off last two characters if(side1Towns.length() > 2) side1Towns = new StringBuilder(side1Towns.substring(0, side1Towns.length() - 2)); if(side1Players.length() > 2) side1Players = new StringBuilder(side1Players.substring(0, side1Players.length() - 2)); - p.sendMessage(Helper.Chatlabel() + w.getSide1() + " Towns: " + side1Towns); - p.sendMessage(Helper.Chatlabel() + w.getSide1() + " Players: " + side1Players); + p.sendMessage(Helper.chatLabel() + w.getSide1() + " Towns: " + side1Towns); + p.sendMessage(Helper.chatLabel() + w.getSide1() + " Players: " + side1Players); - p.sendMessage(Helper.Chatlabel() + "oOo------------===------------oOo"); + p.sendMessage(Helper.chatLabel() + "oOo------------===------------oOo"); StringBuilder side2Towns = new StringBuilder(); StringBuilder side2Players = new StringBuilder(); for (String t : w.getSide2Towns()) { @@ -564,10 +564,10 @@ public class AdminCommands implements CommandExecutor { //cut off last two characters if(side2Towns.length() > 2) side2Towns = new StringBuilder(side2Towns.substring(0, side2Towns.length() - 2)); if(side2Players.length() > 2) side2Players = new StringBuilder(side2Players.substring(0, side2Players.length() - 2)); - p.sendMessage(Helper.Chatlabel() + w.getSide2() + " Towns: " + side2Towns); - p.sendMessage(Helper.Chatlabel() + w.getSide2() + " Players: " + side2Players); + p.sendMessage(Helper.chatLabel() + w.getSide2() + " Towns: " + side2Towns); + p.sendMessage(Helper.chatLabel() + w.getSide2() + " Players: " + side2Players); - p.sendMessage(Helper.Chatlabel() + "oOo------------===------------oOo"); + p.sendMessage(Helper.chatLabel() + "oOo------------===------------oOo"); StringBuilder surrenderedTowns = new StringBuilder(); for (String t : w.getSurrenderedTowns()) { surrenderedTowns.append(t); @@ -575,7 +575,7 @@ public class AdminCommands implements CommandExecutor { } //cut off last two characters if(surrenderedTowns.length() > 2) surrenderedTowns = new StringBuilder(surrenderedTowns.substring(0, surrenderedTowns.length() - 2)); - p.sendMessage(Helper.Chatlabel() + "Surrendered Towns: " + surrenderedTowns); + p.sendMessage(Helper.chatLabel() + "Surrendered Towns: " + surrenderedTowns); return true; } } @@ -588,23 +588,23 @@ public class AdminCommands implements CommandExecutor { if (args.length >= 4) { for (Raid r : RaidData.getRaids()) { if (r.getWar().getName().equals(args[2]) && r.getRaidedTown().getName().equals(args[3])) { - p.sendMessage(Helper.Chatlabel() + "Info dump for raid: " + r.getName()); - p.sendMessage(Helper.Chatlabel() + "oOo------------===------------oOo"); - p.sendMessage(Helper.Chatlabel() + "Name: " + r.getName()); - p.sendMessage(Helper.Chatlabel() + "Raiders: " + r.getRaiderSide()); - p.sendMessage(Helper.Chatlabel() + "Defenders: " + r.getDefenderSide()); - p.sendMessage(Helper.Chatlabel() + "Side1Raiders: " + r.getSide1AreRaiders()); - p.sendMessage(Helper.Chatlabel() + "Raider Score: " + r.getRaiderScore()); - p.sendMessage(Helper.Chatlabel() + "Defender Score: " + r.getDefenderScore()); - p.sendMessage(Helper.Chatlabel() + "War: " + r.getWar().getName()); - p.sendMessage(Helper.Chatlabel() + "Raided Town: " + r.getRaidedTown().getName()); - p.sendMessage(Helper.Chatlabel() + "Gather Town: " + r.getGatherTown().getName()); - p.sendMessage(Helper.Chatlabel() + "Current Phase: " + r.getPhase().name()); - p.sendMessage(Helper.Chatlabel() + "Tick progress: " + r.getRaidTicks()); - p.sendMessage(Helper.Chatlabel() + "Owner: " + r.getOwner().getName()); - p.sendMessage(Helper.Chatlabel() + "Gather Homeblock: " + (r.getHomeBlockGather() == null ? "NONE" : r.getHomeBlockGather().toString())); - p.sendMessage(Helper.Chatlabel() + "Raided Homeblock: " + (r.getHomeBlockRaided() == null ? "NONE" : r.getHomeBlockRaided().toString())); - p.sendMessage(Helper.Chatlabel() + "oOo------------===------------oOo"); + p.sendMessage(Helper.chatLabel() + "Info dump for raid: " + r.getName()); + p.sendMessage(Helper.chatLabel() + "oOo------------===------------oOo"); + p.sendMessage(Helper.chatLabel() + "Name: " + r.getName()); + p.sendMessage(Helper.chatLabel() + "Raiders: " + r.getRaiderSide()); + p.sendMessage(Helper.chatLabel() + "Defenders: " + r.getDefenderSide()); + p.sendMessage(Helper.chatLabel() + "Side1Raiders: " + r.getSide1AreRaiders()); + p.sendMessage(Helper.chatLabel() + "Raider Score: " + r.getRaiderScore()); + p.sendMessage(Helper.chatLabel() + "Defender Score: " + r.getDefenderScore()); + p.sendMessage(Helper.chatLabel() + "War: " + r.getWar().getName()); + p.sendMessage(Helper.chatLabel() + "Raided Town: " + r.getRaidedTown().getName()); + p.sendMessage(Helper.chatLabel() + "Gather Town: " + r.getGatherTown().getName()); + p.sendMessage(Helper.chatLabel() + "Current Phase: " + r.getPhase().name()); + p.sendMessage(Helper.chatLabel() + "Tick progress: " + r.getRaidTicks()); + p.sendMessage(Helper.chatLabel() + "Owner: " + r.getOwner().getName()); + p.sendMessage(Helper.chatLabel() + "Gather Homeblock: " + (r.getHomeBlockGather() == null ? "NONE" : r.getHomeBlockGather().toString())); + p.sendMessage(Helper.chatLabel() + "Raided Homeblock: " + (r.getHomeBlockRaided() == null ? "NONE" : r.getHomeBlockRaided().toString())); + p.sendMessage(Helper.chatLabel() + "oOo------------===------------oOo"); StringBuilder activeRaiders = new StringBuilder(); for (String pl : r.getActiveRaiders()) { activeRaiders.append(pl); @@ -612,9 +612,9 @@ public class AdminCommands implements CommandExecutor { } //cut off last two characters if(activeRaiders.length() > 2) activeRaiders = new StringBuilder(activeRaiders.substring(0, activeRaiders.length() - 2)); - p.sendMessage(Helper.Chatlabel() + "Raiding Players: " + activeRaiders); + p.sendMessage(Helper.chatLabel() + "Raiding Players: " + activeRaiders); - p.sendMessage(Helper.Chatlabel() + "oOo------------===------------oOo"); + p.sendMessage(Helper.chatLabel() + "oOo------------===------------oOo"); StringBuilder defenderPlayers = new StringBuilder(); for (String pl : r.getDefenderPlayers()) { defenderPlayers.append(pl); @@ -622,7 +622,7 @@ public class AdminCommands implements CommandExecutor { } //cut off last two characters if(defenderPlayers.length() > 2) defenderPlayers = new StringBuilder(defenderPlayers.substring(0, defenderPlayers.length() - 2)); - p.sendMessage(Helper.Chatlabel() + "Defending Players: " + defenderPlayers); + p.sendMessage(Helper.chatLabel() + "Defending Players: " + defenderPlayers); return true; } } @@ -635,20 +635,20 @@ public class AdminCommands implements CommandExecutor { if (args.length >= 4) { for (Siege s : SiegeData.getSieges()) { if (s.getWar().getName().equals(args[2]) && s.getTown().getName().equals(args[3])) { - p.sendMessage(Helper.Chatlabel() + "Info dump for siege: " + s.getName()); - p.sendMessage(Helper.Chatlabel() + "oOo------------===------------oOo"); - p.sendMessage(Helper.Chatlabel() + "Name: " + s.getName()); - p.sendMessage(Helper.Chatlabel() + "Attackers: " + s.getAttackerSide()); - p.sendMessage(Helper.Chatlabel() + "Defenders: " + s.getDefenderSide()); - p.sendMessage(Helper.Chatlabel() + "Attacker points: " + s.getAttackerPoints()); - p.sendMessage(Helper.Chatlabel() + "Defender points: " + s.getDefenderPoints()); - p.sendMessage(Helper.Chatlabel() + "War: " + s.getWar().getName()); - p.sendMessage(Helper.Chatlabel() + "Attacked Town: " + s.getTown().getName()); - p.sendMessage(Helper.Chatlabel() + "Max Ticks: " + s.getMaxSiegeTicks()); - p.sendMessage(Helper.Chatlabel() + "Tick progress: " + s.getSiegeTicks()); - p.sendMessage(Helper.Chatlabel() + "Owner: " + s.getSiegeOwner()); - p.sendMessage(Helper.Chatlabel() + "Homeblock: " + s.getHomeBlock().toString()); - p.sendMessage(Helper.Chatlabel() + "oOo------------===------------oOo"); + p.sendMessage(Helper.chatLabel() + "Info dump for siege: " + s.getName()); + p.sendMessage(Helper.chatLabel() + "oOo------------===------------oOo"); + p.sendMessage(Helper.chatLabel() + "Name: " + s.getName()); + p.sendMessage(Helper.chatLabel() + "Attackers: " + s.getAttackerSide()); + p.sendMessage(Helper.chatLabel() + "Defenders: " + s.getDefenderSide()); + p.sendMessage(Helper.chatLabel() + "Attacker points: " + s.getAttackerPoints()); + p.sendMessage(Helper.chatLabel() + "Defender points: " + s.getDefenderPoints()); + p.sendMessage(Helper.chatLabel() + "War: " + s.getWar().getName()); + p.sendMessage(Helper.chatLabel() + "Attacked Town: " + s.getTown().getName()); + p.sendMessage(Helper.chatLabel() + "Max Ticks: " + s.getMaxSiegeTicks()); + p.sendMessage(Helper.chatLabel() + "Tick progress: " + s.getSiegeTicks()); + p.sendMessage(Helper.chatLabel() + "Owner: " + s.getSiegeOwner()); + p.sendMessage(Helper.chatLabel() + "Homeblock: " + s.getHomeBlock().toString()); + p.sendMessage(Helper.chatLabel() + "oOo------------===------------oOo"); StringBuilder attackers = new StringBuilder(); for (String pl : s.getAttackerPlayers()) { attackers.append(pl); @@ -656,7 +656,7 @@ public class AdminCommands implements CommandExecutor { } //cut off last two characters if(attackers.length() > 2) attackers = new StringBuilder(attackers.substring(0, attackers.length() - 2)); - p.sendMessage(Helper.Chatlabel() + "Attacking Players: " + attackers); + p.sendMessage(Helper.chatLabel() + "Attacking Players: " + attackers); StringBuilder defenders = new StringBuilder(); for (String pl : s.getDefenderPlayers()) { defenders.append(pl); @@ -664,7 +664,7 @@ public class AdminCommands implements CommandExecutor { } //cut off last two characters if(defenders.length() > 2) defenders = new StringBuilder(defenders.substring(0, defenders.length() - 2)); - p.sendMessage(Helper.Chatlabel() + "Defending Players: " + defenders); + p.sendMessage(Helper.chatLabel() + "Defending Players: " + defenders); return true; } } @@ -723,17 +723,17 @@ public class AdminCommands implements CommandExecutor { if(r.getSide1AreRaiders()) { if (args[5].equalsIgnoreCase("add")) { r.addPointsToRaiderScore(Integer.parseInt(args[7])); - p.sendMessage(Helper.Chatlabel() + "Added " + args[7] + " points to the raid score in the war " + args[3] + " on town " + args[4]); + p.sendMessage(Helper.chatLabel() + "Added " + args[7] + " points to the raid score in the war " + args[3] + " on town " + args[4]); Main.warLogger.log("Added " + args[7] + " points to the raid score in the war " + args[3] + " on town " + args[4]); return finalizeRaid(r); } else if (args[5].equalsIgnoreCase("subtract")) { r.subtractPointsFromRaiderScore(Integer.parseInt(args[7])); - p.sendMessage(Helper.Chatlabel() + "Subtracted " + args[7] + " points to the raid score in the war " + args[3] + " on town " + args[4]); + p.sendMessage(Helper.chatLabel() + "Subtracted " + args[7] + " points to the raid score in the war " + args[3] + " on town " + args[4]); Main.warLogger.log("Subtracted " + args[7] + " points to the raid score in the war " + args[3] + " on town " + args[4]); return finalizeRaid(r); } else if (args[5].equalsIgnoreCase("set")) { r.setRaiderScore(Integer.parseInt(args[7])); - p.sendMessage(Helper.Chatlabel() + "Set " + args[7] + " points as the raid score in the war " + args[3] + " on town " + args[4]); + p.sendMessage(Helper.chatLabel() + "Set " + args[7] + " points as the raid score in the war " + args[3] + " on town " + args[4]); Main.warLogger.log("Set " + args[7] + " points as the raid score in the war " + args[3] + " on town " + args[4]); return finalizeRaid(r); } else { @@ -743,17 +743,17 @@ public class AdminCommands implements CommandExecutor { } else { if (args[5].equalsIgnoreCase("add")) { r.addPointsToDefenderScore(Integer.parseInt(args[7])); - p.sendMessage(Helper.Chatlabel() + "Added " + args[7] + " points to the raid score in the war " + args[3] + " on town " + args[4]); + p.sendMessage(Helper.chatLabel() + "Added " + args[7] + " points to the raid score in the war " + args[3] + " on town " + args[4]); Main.warLogger.log("Added " + args[7] + " points to the raid score in the war " + args[3] + " on town " + args[4]); return finalizeRaid(r); } else if (args[5].equalsIgnoreCase("subtract")) { r.subtractPointsFromDefenderScore(Integer.parseInt(args[7])); - p.sendMessage(Helper.Chatlabel() + "Subtracted " + args[7] + " points to the raid score in the war " + args[3] + " on town " + args[4]); + p.sendMessage(Helper.chatLabel() + "Subtracted " + args[7] + " points to the raid score in the war " + args[3] + " on town " + args[4]); Main.warLogger.log("Subtracted " + args[7] + " points to the raid score in the war " + args[3] + " on town " + args[4]); return finalizeRaid(r); } else if (args[5].equalsIgnoreCase("set")) { r.setDefenderScore(Integer.parseInt(args[7])); - p.sendMessage(Helper.Chatlabel() + "Set " + args[7] + " points as the raid score in the war " + args[3] + " on town " + args[4]); + p.sendMessage(Helper.chatLabel() + "Set " + args[7] + " points as the raid score in the war " + args[3] + " on town " + args[4]); Main.warLogger.log("Set " + args[7] + " points as the raid score in the war " + args[3] + " on town " + args[4]); return finalizeRaid(r); } else { @@ -765,17 +765,17 @@ public class AdminCommands implements CommandExecutor { if(!r.getSide1AreRaiders()) { if (args[5].equalsIgnoreCase("add")) { r.addPointsToRaiderScore(Integer.parseInt(args[7])); - p.sendMessage(Helper.Chatlabel() + "Added " + args[7] + " points to the raid score in the war " + args[3] + " on town " + args[4]); + p.sendMessage(Helper.chatLabel() + "Added " + args[7] + " points to the raid score in the war " + args[3] + " on town " + args[4]); Main.warLogger.log("Added " + args[7] + " points to the raid score in the war " + args[3] + " on town " + args[4]); return finalizeRaid(r); } else if (args[5].equalsIgnoreCase("subtract")) { r.subtractPointsFromRaiderScore(Integer.parseInt(args[7])); - p.sendMessage(Helper.Chatlabel() + "Subtracted " + args[7] + " points to the raid score in the war " + args[3] + " on town " + args[4]); + p.sendMessage(Helper.chatLabel() + "Subtracted " + args[7] + " points to the raid score in the war " + args[3] + " on town " + args[4]); Main.warLogger.log("Subtracted " + args[7] + " points to the raid score in the war " + args[3] + " on town " + args[4]); return finalizeRaid(r); } else if (args[5].equalsIgnoreCase("set")) { r.setRaiderScore(Integer.parseInt(args[7])); - p.sendMessage(Helper.Chatlabel() + "Set " + args[7] + " points as the raid score in the war " + args[3] + " on town " + args[4]); + p.sendMessage(Helper.chatLabel() + "Set " + args[7] + " points as the raid score in the war " + args[3] + " on town " + args[4]); Main.warLogger.log("Set " + args[7] + " points as the raid score in the war " + args[3] + " on town " + args[4]); return finalizeRaid(r); } else { @@ -785,17 +785,17 @@ public class AdminCommands implements CommandExecutor { } else { if (args[5].equalsIgnoreCase("add")) { r.addPointsToDefenderScore(Integer.parseInt(args[7])); - p.sendMessage(Helper.Chatlabel() + "Added " + args[7] + " points to the raid score in the war " + args[3] + " on town " + args[4]); + p.sendMessage(Helper.chatLabel() + "Added " + args[7] + " points to the raid score in the war " + args[3] + " on town " + args[4]); Main.warLogger.log("Added " + args[7] + " points to the raid score in the war " + args[3] + " on town " + args[4]); return finalizeRaid(r); } else if (args[5].equalsIgnoreCase("subtract")) { r.subtractPointsFromDefenderScore(Integer.parseInt(args[7])); - p.sendMessage(Helper.Chatlabel() + "Subtracted " + args[7] + " points to the raid score in the war " + args[3] + " on town " + args[4]); + p.sendMessage(Helper.chatLabel() + "Subtracted " + args[7] + " points to the raid score in the war " + args[3] + " on town " + args[4]); Main.warLogger.log("Subtracted " + args[7] + " points to the raid score in the war " + args[3] + " on town " + args[4]); return finalizeRaid(r); } else if (args[5].equalsIgnoreCase("set")) { r.setDefenderScore(Integer.parseInt(args[7])); - p.sendMessage(Helper.Chatlabel() + "Set " + args[7] + " points as the raid score in the war " + args[3] + " on town " + args[4]); + p.sendMessage(Helper.chatLabel() + "Set " + args[7] + " points as the raid score in the war " + args[3] + " on town " + args[4]); Main.warLogger.log("Set " + args[7] + " points as the raid score in the war " + args[3] + " on town " + args[4]); return finalizeRaid(r); } else { @@ -809,7 +809,7 @@ public class AdminCommands implements CommandExecutor { } } } - p.sendMessage(Helper.Chatlabel() + Helper.color("&cRaid cannot be found.")); + p.sendMessage(Helper.chatLabel() + Helper.color("&cRaid cannot be found.")); } else { p.sendMessage(Helper.color("&cUsage: /alathrawaradmin modify raid score [war] [town] [add/subtract/set] [side] [value]")); } @@ -825,7 +825,7 @@ public class AdminCommands implements CommandExecutor { Town t = r.getRaidedTown(); if (args.length >= 8) { if(!(p instanceof Player runner)) { - p.sendMessage(Helper.Chatlabel() + "This command cannot be run through console!"); + p.sendMessage(Helper.chatLabel() + "This command cannot be run through console!"); return true; } if (runner.getWorld() == t.getWorld()) { @@ -836,7 +836,7 @@ public class AdminCommands implements CommandExecutor { t.setSpawn(new Location(runner.getWorld(), Double.parseDouble(args[5]), Double.parseDouble(args[6]), Double.parseDouble(args[7]))); r.setHomeBlockRaided(tb.getTownBlock()); r.setTownSpawnRaided(t.getSpawn()); - p.sendMessage(Helper.Chatlabel() + "Set town spawn for raided town " + args[4] + " in war " + args[3] + " to " + runner.getLocation().toString()); + p.sendMessage(Helper.chatLabel() + "Set town spawn for raided town " + args[4] + " in war " + args[3] + " to " + runner.getLocation().toString()); Main.warLogger.log("Set town spawn for raided town " + args[4] + " in war " + args[3] + " to [" + args[5] + "," + args[6] + "," + args[7] + "]"); return finalizeRaid(r); } else { @@ -856,7 +856,7 @@ public class AdminCommands implements CommandExecutor { } } else { if(!(p instanceof Player runner)) { - p.sendMessage(Helper.Chatlabel() + "This command cannot be run through console!"); + p.sendMessage(Helper.chatLabel() + "This command cannot be run through console!"); return true; } if (runner.getWorld() == t.getWorld()) { @@ -867,7 +867,7 @@ public class AdminCommands implements CommandExecutor { t.setSpawn(runner.getLocation()); r.setHomeBlockRaided(tb.getTownBlock()); r.setTownSpawnRaided(t.getSpawn()); - p.sendMessage(Helper.Chatlabel() + "Set town spawn for raided town " + args[4] + " in war " + args[3] + " to " + runner.getLocation().toString()); + p.sendMessage(Helper.chatLabel() + "Set town spawn for raided town " + args[4] + " in war " + args[3] + " to " + runner.getLocation().toString()); Main.warLogger.log("Set town spawn for raided town " + args[4] + " in war " + args[3] + " to " + runner.getLocation().toString()); return finalizeRaid(r); } else { @@ -887,7 +887,7 @@ public class AdminCommands implements CommandExecutor { } } } - p.sendMessage(Helper.Chatlabel() + Helper.color("&cRaid cannot be found.")); + p.sendMessage(Helper.chatLabel() + Helper.color("&cRaid cannot be found.")); } else { p.sendMessage(Helper.color("&cUsage: /alathrawaradmin modify raid homeblock [war] [town] (x) (Z)")); } @@ -903,10 +903,10 @@ public class AdminCommands implements CommandExecutor { r.setTownSpawnGather(t.getSpawn()); r.setHomeBlockGather(t.getHomeBlock()); } catch (TownyException e) { - p.sendMessage(Helper.Chatlabel() + "Error!"); + p.sendMessage(Helper.chatLabel() + "Error!"); throw new RuntimeException(e); } - p.sendMessage(Helper.Chatlabel() + "Set town new gather town " + t.getName() + " for raid against " + args[4] + " in war " + args[3]); + p.sendMessage(Helper.chatLabel() + "Set town new gather town " + t.getName() + " for raid against " + args[4] + " in war " + args[3]); Main.warLogger.log("Set town new gather town " + t.getName() + " for raid against " + args[4] + " in war " + args[3]); return finalizeRaid(r); } else { @@ -915,7 +915,7 @@ public class AdminCommands implements CommandExecutor { } } } - p.sendMessage(Helper.Chatlabel() + Helper.color("&cRaid cannot be found.")); + p.sendMessage(Helper.chatLabel() + Helper.color("&cRaid cannot be found.")); } else { p.sendMessage(Helper.color("&cUsage: /alathrawaradmin modify raid gather [war] [town] [town]")); } @@ -937,7 +937,7 @@ public class AdminCommands implements CommandExecutor { r.setPhase(ph); r.setRaidTicks(ph.startTick); - p.sendMessage(Helper.Chatlabel() + "Set phase for raid against " + args[4] + " in war " + args[3] + " to " + ph.name()); + p.sendMessage(Helper.chatLabel() + "Set phase for raid against " + args[4] + " in war " + args[3] + " to " + ph.name()); Main.warLogger.log("Set phase for raid against " + args[4] + " in war " + args[3] + " to " + ph.name()); return finalizeRaid(r); } else { @@ -946,7 +946,7 @@ public class AdminCommands implements CommandExecutor { } } } - p.sendMessage(Helper.Chatlabel() + Helper.color("&cRaid cannot be found.")); + p.sendMessage(Helper.chatLabel() + Helper.color("&cRaid cannot be found.")); } else { p.sendMessage(Helper.color("&cUsage: /alathrawaradmin modify raid phase [war] [town] [phase]")); } @@ -957,12 +957,12 @@ public class AdminCommands implements CommandExecutor { if (r.getWar().getName().equals(args[3]) && r.getRaidedTown().getName().equals(args[4])) { //parse phase if(!(p instanceof Player runner)) { - p.sendMessage(Helper.Chatlabel() + "This command cannot be run through console!"); + p.sendMessage(Helper.chatLabel() + "This command cannot be run through console!"); return true; } if (!runner.getWorld().equals(r.getRaidedTown().getWorld())) { - p.sendMessage(Helper.Chatlabel() + "Error wrong world"); + p.sendMessage(Helper.chatLabel() + "Error wrong world"); return true; } if (args.length >= 9) { @@ -972,10 +972,10 @@ public class AdminCommands implements CommandExecutor { if(lb == null) { r.addLootedChunk(wc); lb = r.getLootedChunks().get(wc); - p.sendMessage(Helper.Chatlabel() + "Created empty loot chunk data to modify"); + p.sendMessage(Helper.chatLabel() + "Created empty loot chunk data to modify"); } lb.value = Double.parseDouble(args[6]); - p.sendMessage(Helper.Chatlabel() + "Set value for a chunk [" + args[7] + "," + args[8] + "] in raid against " + args[4] + " in war " + args[3] + " to " + args[6]); + p.sendMessage(Helper.chatLabel() + "Set value for a chunk [" + args[7] + "," + args[8] + "] in raid against " + args[4] + " in war " + args[3] + " to " + args[6]); Main.warLogger.log("Set value for a chunk [" + args[7] + "," + args[8] + "] in raid against " + args[4] + " in war " + args[3] + " to " + args[6]); return finalizeRaid(r); } else if (args[5].equalsIgnoreCase("looted")) { @@ -986,25 +986,25 @@ public class AdminCommands implements CommandExecutor { lb.value = new Random().nextDouble() * 100; //score for looting r.addPointsToRaiderScore(10); - p.sendMessage(Helper.Chatlabel() + "Gave value and score because flag was false before."); + p.sendMessage(Helper.chatLabel() + "Gave value and score because flag was false before."); Main.warLogger.log("Gave value and score because flag was false before."); } lb.finished = Boolean.parseBoolean(args[6]); - p.sendMessage(Helper.Chatlabel() + "Set finished flag for a chunk [" + args[7] + "," + args[8] + "] in raid against " + args[4] + " in war " + args[3] + " to " + args[6]); + p.sendMessage(Helper.chatLabel() + "Set finished flag for a chunk [" + args[7] + "," + args[8] + "] in raid against " + args[4] + " in war " + args[3] + " to " + args[6]); Main.warLogger.log("Set finished flag for a chunk [" + args[7] + "," + args[8] + "] in raid against " + args[4] + " in war " + args[3] + " to " + args[6]); return finalizeRaid(r); } else if (args[5].equalsIgnoreCase("ticks")) { WorldCoord wc = WorldCoord.parseWorldCoord(runner.getWorld().getName(), (int) Double.parseDouble(args[7]), (int) Double.parseDouble(args[8])); Raid.LootBlock lb = r.getLootedChunks().get(wc); lb.ticks = Integer.parseInt(args[6]); - p.sendMessage(Helper.Chatlabel() + "Set ticks for a chunk [" + args[7] + "," + args[8] + "] in raid against " + args[4] + " in war " + args[3] + " to " + args[6]); + p.sendMessage(Helper.chatLabel() + "Set ticks for a chunk [" + args[7] + "," + args[8] + "] in raid against " + args[4] + " in war " + args[3] + " to " + args[6]); Main.warLogger.log("Set ticks for a chunk [" + args[7] + "," + args[8] + "] in raid against " + args[4] + " in war " + args[3] + " to " + args[6]); return finalizeRaid(r); } else if (args[5].equalsIgnoreCase("reset")) { WorldCoord wc = WorldCoord.parseWorldCoord(runner.getWorld().getName(), (int) Double.parseDouble(args[6]), (int) Double.parseDouble(args[7])); r.getLootedChunks().remove(wc); - p.sendMessage(Helper.Chatlabel() + "Reset loot for a chunk [" + args[7] + "," + args[8] + "] in raid against " + args[4] + " in war " + args[3]); + p.sendMessage(Helper.chatLabel() + "Reset loot for a chunk [" + args[7] + "," + args[8] + "] in raid against " + args[4] + " in war " + args[3]); Main.warLogger.log("Reset loot for a chunk [" + args[7] + "," + args[8] + "] in raid against " + args[4] + " in war " + args[3]); return finalizeRaid(r); } else { @@ -1019,27 +1019,27 @@ public class AdminCommands implements CommandExecutor { WorldCoord wc = WorldCoord.parseWorldCoord(runner.getLocation()); Raid.LootBlock lb = r.getLootedChunks().get(wc); lb.value = Integer.parseInt(args[6]); - p.sendMessage(Helper.Chatlabel() + "Set value for a chunk [" + runner.getLocation().getX() + "," + runner.getLocation().getZ() + "] in raid against " + args[4] + " in war " + args[3] + " to " + args[6]); + p.sendMessage(Helper.chatLabel() + "Set value for a chunk [" + runner.getLocation().getX() + "," + runner.getLocation().getZ() + "] in raid against " + args[4] + " in war " + args[3] + " to " + args[6]); Main.warLogger.log("Set value for a chunk [" + runner.getLocation().getX() + "," + runner.getLocation().getZ() + "] in raid against " + args[4] + " in war " + args[3] + " to " + args[6]); return finalizeRaid(r); } else if (args[5].equalsIgnoreCase("looted")) { WorldCoord wc = WorldCoord.parseWorldCoord(runner.getLocation()); Raid.LootBlock lb = r.getLootedChunks().get(wc); lb.finished = Boolean.parseBoolean(args[6]); - p.sendMessage(Helper.Chatlabel() + "Set looted status for a chunk [" + runner.getLocation().getX() + "," + runner.getLocation().getZ() + "] in raid against " + args[4] + " in war " + args[3] + " to " + args[6]); + p.sendMessage(Helper.chatLabel() + "Set looted status for a chunk [" + runner.getLocation().getX() + "," + runner.getLocation().getZ() + "] in raid against " + args[4] + " in war " + args[3] + " to " + args[6]); Main.warLogger.log("Set looted status for a chunk [" + runner.getLocation().getX() + "," + runner.getLocation().getZ() + "] in raid against " + args[4] + " in war " + args[3] + " to " + args[6]); return finalizeRaid(r); } else if (args[5].equalsIgnoreCase("ticks")) { WorldCoord wc = WorldCoord.parseWorldCoord(runner.getLocation()); Raid.LootBlock lb = r.getLootedChunks().get(wc); lb.ticks = Integer.parseInt(args[6]); - p.sendMessage(Helper.Chatlabel() + "Set ticks for a chunk [" + runner.getLocation().getX() + "," + runner.getLocation().getZ() + "] in raid against " + args[4] + " in war " + args[3] + " to " + args[6]); + p.sendMessage(Helper.chatLabel() + "Set ticks for a chunk [" + runner.getLocation().getX() + "," + runner.getLocation().getZ() + "] in raid against " + args[4] + " in war " + args[3] + " to " + args[6]); Main.warLogger.log("Set ticks for a chunk [" + runner.getLocation().getX() + "," + runner.getLocation().getZ() + "] in raid against " + args[4] + " in war " + args[3] + " to " + args[6]); return finalizeRaid(r); } else if (args[5].equalsIgnoreCase("reset")) { WorldCoord wc = WorldCoord.parseWorldCoord(runner.getLocation()); r.getLootedChunks().remove(wc); - p.sendMessage(Helper.Chatlabel() + "Reset loot for a chunk [" + runner.getLocation().getX() + "," + runner.getLocation().getZ() + "] in raid against " + args[4] + " in war " + args[3]); + p.sendMessage(Helper.chatLabel() + "Reset loot for a chunk [" + runner.getLocation().getX() + "," + runner.getLocation().getZ() + "] in raid against " + args[4] + " in war " + args[3]); Main.warLogger.log("Reset Loot for a chunk [" + runner.getLocation().getX() + "," + runner.getLocation().getZ() + "] in raid against " + args[4] + " in war " + args[3]); return finalizeRaid(r); } else { @@ -1049,7 +1049,7 @@ public class AdminCommands implements CommandExecutor { } } } - p.sendMessage(Helper.Chatlabel() + Helper.color("&cRaid cannot be found.")); + p.sendMessage(Helper.chatLabel() + Helper.color("&cRaid cannot be found.")); } else { p.sendMessage(Helper.color("&cUsage: /alathrawaradmin modify raid loot [war] [town] [value,looted,ticks,reset] [amt] (x) (z)")); } @@ -1061,18 +1061,18 @@ public class AdminCommands implements CommandExecutor { //parse phase if (args[5].equalsIgnoreCase("add")) { r.setRaidTicks(r.getRaidTicks() + Integer.parseInt(args[6])); - p.sendMessage(Helper.Chatlabel() + "Set time for raid against " + args[4] + " in war " + args[3] + " to " + args[6]); + p.sendMessage(Helper.chatLabel() + "Set time for raid against " + args[4] + " in war " + args[3] + " to " + args[6]); Main.warLogger.log("Set time for raid against " + args[4] + " in war " + args[3] + " to " + args[6]); return finalizeRaid(r); } else if (args[5].equalsIgnoreCase("set")) { int t = Integer.parseInt(args[6]); if (t >= r.getPhase().startTick) { r.setRaidTicks(t); - p.sendMessage(Helper.Chatlabel() + "Set time for raid against " + args[4] + " in war " + args[3] + " to " + args[6]); + p.sendMessage(Helper.chatLabel() + "Set time for raid against " + args[4] + " in war " + args[3] + " to " + args[6]); Main.warLogger.log("Set time for raid against " + args[4] + " in war " + args[3] + " to " + args[6]); return finalizeRaid(r); } else { - p.sendMessage(Helper.Chatlabel() + Helper.color("&cTime set before current phase, use \"/alathrawaradmin modify raid phase\" instead")); + p.sendMessage(Helper.chatLabel() + Helper.color("&cTime set before current phase, use \"/alathrawaradmin modify raid phase\" instead")); return true; } } else { @@ -1081,7 +1081,7 @@ public class AdminCommands implements CommandExecutor { } } } - p.sendMessage(Helper.Chatlabel() + Helper.color("&cRaid cannot be found.")); + p.sendMessage(Helper.chatLabel() + Helper.color("&cRaid cannot be found.")); } else { p.sendMessage(Helper.color("&cUsage: /alathrawaradmin modify raid time [war] [town] [add/set] [value]")); } @@ -1094,11 +1094,11 @@ public class AdminCommands implements CommandExecutor { if (own != null) { if(r.getActiveRaiders().contains(own.getName())) { r.setOwner(own); - p.sendMessage(Helper.Chatlabel() + "Set owner of raid against " + args[4] + " in war " + args[3] + " to " + own.getName()); + p.sendMessage(Helper.chatLabel() + "Set owner of raid against " + args[4] + " in war " + args[3] + " to " + own.getName()); Main.warLogger.log("Set owner of raid against " + args[4] + " in war " + args[3] + " to " + own.getName()); return finalizeRaid(r); } else { - p.sendMessage(Helper.Chatlabel() + "Player is not an active raider!"); + p.sendMessage(Helper.chatLabel() + "Player is not an active raider!"); return true; } } else { @@ -1107,7 +1107,7 @@ public class AdminCommands implements CommandExecutor { } } } - p.sendMessage(Helper.Chatlabel() + Helper.color("&cRaid cannot be found.")); + p.sendMessage(Helper.chatLabel() + Helper.color("&cRaid cannot be found.")); } else { p.sendMessage(Helper.color("&cUsage: /alathrawaradmin modify raid owner [war] [town] [player]")); } @@ -1141,7 +1141,7 @@ public class AdminCommands implements CommandExecutor { } else { s.addPointsToDefenders(Integer.parseInt(args[7])); } - p.sendMessage(Helper.Chatlabel() + "Added " + args[7] + " points to side " + args[6] + " in sige on " + args[4] + " in war " + args[3]); + p.sendMessage(Helper.chatLabel() + "Added " + args[7] + " points to side " + args[6] + " in sige on " + args[4] + " in war " + args[3]); Main.warLogger.log("Added " + args[7] + " points to side " + args[6] + " in sige on " + args[4] + " in war " + args[3]); return finalizeSiege(s); } else if (s.getWar().getSide2().equals(args[6])) { @@ -1150,7 +1150,7 @@ public class AdminCommands implements CommandExecutor { } else { s.addPointsToAttackers(Integer.parseInt(args[7])); } - p.sendMessage(Helper.Chatlabel() + "Added " + args[7] + " points to side " + args[6] + " in sige on " + args[4] + " in war " + args[3]); + p.sendMessage(Helper.chatLabel() + "Added " + args[7] + " points to side " + args[6] + " in sige on " + args[4] + " in war " + args[3]); Main.warLogger.log("Added " + args[7] + " points to side " + args[6] + " in sige on " + args[4] + " in war " + args[3]); return finalizeSiege(s); } else { @@ -1164,7 +1164,7 @@ public class AdminCommands implements CommandExecutor { } else { s.setDefenderPoints(Integer.parseInt(args[7])); } - p.sendMessage(Helper.Chatlabel() + "Set " + args[7] + " points for side " + args[6] + " in sige on " + args[4] + " in war " + args[3]); + p.sendMessage(Helper.chatLabel() + "Set " + args[7] + " points for side " + args[6] + " in sige on " + args[4] + " in war " + args[3]); Main.warLogger.log("Set " + args[7] + " points for side " + args[6] + " in sige on " + args[4] + " in war " + args[3]); return finalizeSiege(s); } else if (s.getWar().getSide2().equals(args[6])) { @@ -1173,7 +1173,7 @@ public class AdminCommands implements CommandExecutor { } else { s.setAttackerPoints(Integer.parseInt(args[7])); } - p.sendMessage(Helper.Chatlabel() + "Set " + args[7] + " points for side " + args[6] + " in sige on " + args[4] + " in war " + args[3]); + p.sendMessage(Helper.chatLabel() + "Set " + args[7] + " points for side " + args[6] + " in sige on " + args[4] + " in war " + args[3]); Main.warLogger.log("Set " + args[7] + " points for side " + args[6] + " in sige on " + args[4] + " in war " + args[3]); return finalizeSiege(s); } else { @@ -1189,7 +1189,7 @@ public class AdminCommands implements CommandExecutor { return true; } } - p.sendMessage(Helper.Chatlabel() + Helper.color("&cSiege cannot be found.")); + p.sendMessage(Helper.chatLabel() + Helper.color("&cSiege cannot be found.")); } else { p.sendMessage(Helper.color("&cUsage: /alathrawaradmin modify siege score [war] [town] [add/set] [side] [amt]")); } @@ -1205,7 +1205,7 @@ public class AdminCommands implements CommandExecutor { Town t = s.getTown(); if (args.length >= 8) { if(!(p instanceof Player runner)) { - p.sendMessage(Helper.Chatlabel() + "This command cannot be run through console!"); + p.sendMessage(Helper.chatLabel() + "This command cannot be run through console!"); return true; } if (runner.getWorld() == t.getWorld()) { @@ -1216,7 +1216,7 @@ public class AdminCommands implements CommandExecutor { t.setSpawn(new Location(runner.getWorld(), (int) Double.parseDouble(args[5]), (int) Double.parseDouble(args[6]), (int) Double.parseDouble(args[7]))); s.setHomeBlock(tb.getTownBlock()); s.setTownSpawn(t.getSpawn()); - p.sendMessage(Helper.Chatlabel() + "Set town spawn for sieged town " + args[4] + " in war " + args[3] + " to " + runner.getLocation().toString()); + p.sendMessage(Helper.chatLabel() + "Set town spawn for sieged town " + args[4] + " in war " + args[3] + " to " + runner.getLocation().toString()); Main.warLogger.log("Set town spawn for sieged town " + args[4] + " in war " + args[3] + " to [" + args[5] + "," + args[6] + "," + args[7] + "]"); return finalizeSiege(s); } else { @@ -1237,7 +1237,7 @@ public class AdminCommands implements CommandExecutor { } else { if(!(p instanceof Player runner)) { - p.sendMessage(Helper.Chatlabel() + "This command cannot be run through console!"); + p.sendMessage(Helper.chatLabel() + "This command cannot be run through console!"); return true; } if (runner.getWorld() == t.getWorld()) { @@ -1248,7 +1248,7 @@ public class AdminCommands implements CommandExecutor { t.setSpawn(runner.getLocation()); s.setHomeBlock(tb.getTownBlock()); s.setTownSpawn(t.getSpawn()); - p.sendMessage(Helper.Chatlabel() + "Set town spawn for sieged town " + args[4] + " in war " + args[3] + " to " + runner.getLocation().toString()); + p.sendMessage(Helper.chatLabel() + "Set town spawn for sieged town " + args[4] + " in war " + args[3] + " to " + runner.getLocation().toString()); Main.warLogger.log("Set town spawn for sieged town " + args[4] + " in war " + args[3] + " to " + runner.getLocation().toString()); return finalizeSiege(s); } else { @@ -1269,7 +1269,7 @@ public class AdminCommands implements CommandExecutor { } } } - p.sendMessage(Helper.Chatlabel() + Helper.color("&cSiege cannot be found.")); + p.sendMessage(Helper.chatLabel() + Helper.color("&cSiege cannot be found.")); } else { p.sendMessage(Helper.color("&cUsage: /alathrawaradmin modify siege townspawn [war] [town] (x) (y) (Z)")); } @@ -1281,12 +1281,12 @@ public class AdminCommands implements CommandExecutor { //parse phase if (args[5].equalsIgnoreCase("add")) { s.setSiegeTicks(s.getSiegeTicks() + Integer.parseInt(args[6])); - p.sendMessage(Helper.Chatlabel() + "Set time for siege against " + args[4] + " in war " + args[3] + " to " + args[6]); + p.sendMessage(Helper.chatLabel() + "Set time for siege against " + args[4] + " in war " + args[3] + " to " + args[6]); Main.warLogger.log("Set time for siege against " + args[4] + " in war " + args[3] + " to " + args[6]); return finalizeSiege(s); } else if (args[5].equalsIgnoreCase("set")) { s.setSiegeTicks(Integer.parseInt(args[6])); - p.sendMessage(Helper.Chatlabel() + "Set time for siege against " + args[4] + " in war " + args[3] + " to " + args[6]); + p.sendMessage(Helper.chatLabel() + "Set time for siege against " + args[4] + " in war " + args[3] + " to " + args[6]); Main.warLogger.log("Set time for siege against " + args[4] + " in war " + args[3] + " to " + args[6]); return finalizeSiege(s); } else { @@ -1295,7 +1295,7 @@ public class AdminCommands implements CommandExecutor { } } } - p.sendMessage(Helper.Chatlabel() + Helper.color("&cSiege cannot be found.")); + p.sendMessage(Helper.chatLabel() + Helper.color("&cSiege cannot be found.")); } else { p.sendMessage(Helper.color("&cUsage: /alathrawaradmin modify siege time [war] [town] [add/set/max] [value]")); } @@ -1308,7 +1308,7 @@ public class AdminCommands implements CommandExecutor { if (own != null) { if (s.attackerPlayers.contains(own.getName())) { s.setSiegeOwner(own); - p.sendMessage(Helper.Chatlabel() + "Set owner of siege against " + args[4] + " in war " + args[3] + " to " + own.getName()); + p.sendMessage(Helper.chatLabel() + "Set owner of siege against " + args[4] + " in war " + args[3] + " to " + own.getName()); Main.warLogger.log("Set owner of siege against " + args[4] + " in war " + args[3] + " to " + own.getName()); return finalizeSiege(s); } else { @@ -1321,7 +1321,7 @@ public class AdminCommands implements CommandExecutor { } } } - p.sendMessage(Helper.Chatlabel() + Helper.color("&cSiege cannot be found.")); + p.sendMessage(Helper.chatLabel() + Helper.color("&cSiege cannot be found.")); } else { p.sendMessage(Helper.color("&cUsage: /alathrawaradmin modify siege owner [war] [town] [newOwner]")); } @@ -1347,17 +1347,17 @@ public class AdminCommands implements CommandExecutor { if(args[4].equals(w.getSide1())) { if (args[5].equalsIgnoreCase("add")) { w.addSide1Points(Integer.parseInt(args[6])); - p.sendMessage(Helper.Chatlabel() + "Added " + args[6] + " points to the raid war in the war " + args[3] + " on side " + args[4]); + p.sendMessage(Helper.chatLabel() + "Added " + args[6] + " points to the raid war in the war " + args[3] + " on side " + args[4]); Main.warLogger.log("Added " + args[6] + " points to the raid war in the war " + args[3] + " on side " + args[4]); return finalizeWar(w); } else if (args[5].equalsIgnoreCase("subtract")) { w.addSide1Points(- Integer.parseInt(args[6])); - p.sendMessage(Helper.Chatlabel() + "Subtracted " + args[6] + " points to the war score in the war " + args[3] + " on side " + args[4]); + p.sendMessage(Helper.chatLabel() + "Subtracted " + args[6] + " points to the war score in the war " + args[3] + " on side " + args[4]); Main.warLogger.log("Subtracted " + args[6] + " points to the raid war in the war " + args[3] + " on side " + args[4]); return finalizeWar(w); } else if (args[5].equalsIgnoreCase("set")) { w.setSide1Points(Integer.parseInt(args[6])); - p.sendMessage(Helper.Chatlabel() + "Set " + args[6] + " points as the war score in the war " + args[3] + " on side " + args[4]); + p.sendMessage(Helper.chatLabel() + "Set " + args[6] + " points as the war score in the war " + args[3] + " on side " + args[4]); Main.warLogger.log("Set " + args[6] + " points as the war score in the war " + args[3] + " on side " + args[4]); return finalizeWar(w); } else { @@ -1367,17 +1367,17 @@ public class AdminCommands implements CommandExecutor { } else if(args[4].equals(w.getSide2())) { if (args[5].equalsIgnoreCase("add")) { w.addSide2Points(Integer.parseInt(args[6])); - p.sendMessage(Helper.Chatlabel() + "Added " + args[6] + " points to the war score in the war " + args[3] + " on side " + args[4]); + p.sendMessage(Helper.chatLabel() + "Added " + args[6] + " points to the war score in the war " + args[3] + " on side " + args[4]); Main.warLogger.log("Added " + args[6] + " points to the war score in the war " + args[3] + " on side " + args[4]); return finalizeWar(w); } else if (args[5].equalsIgnoreCase("subtract")) { w.addSide2Points(- Integer.parseInt(args[6])); - p.sendMessage(Helper.Chatlabel() + "Subtracted " + args[6] + " points to the war score in the war " + args[3] + " on side " + args[4]); + p.sendMessage(Helper.chatLabel() + "Subtracted " + args[6] + " points to the war score in the war " + args[3] + " on side " + args[4]); Main.warLogger.log("Subtracted " + args[6] + " points to the war score in the war " + args[3] + " on side " + args[4]); return finalizeWar(w); } else if (args[5].equalsIgnoreCase("set")) { w.setSide2Points(Integer.parseInt(args[6])); - p.sendMessage(Helper.Chatlabel() + "Set " + args[6] + " points as the war score in the war " + args[3] + " on side " + args[4]); + p.sendMessage(Helper.chatLabel() + "Set " + args[6] + " points as the war score in the war " + args[3] + " on side " + args[4]); Main.warLogger.log("Set " + args[6] + " points as the war score in the war " + args[3] + " on side " + args[4]); return finalizeWar(w); } else { @@ -1402,14 +1402,14 @@ public class AdminCommands implements CommandExecutor { if (w.getSide1().equals(args[4])) { w.setSide1(args[5]); w.save(); - p.sendMessage(Helper.Chatlabel() + "Set side " + args[4] + " to " + args[5] + " in war " + args[3]); - Main.warLogger.log(Helper.Chatlabel() + "Set side " + args[4] + " to " + args[5] + " in war " + args[3]); + p.sendMessage(Helper.chatLabel() + "Set side " + args[4] + " to " + args[5] + " in war " + args[3]); + Main.warLogger.log(Helper.chatLabel() + "Set side " + args[4] + " to " + args[5] + " in war " + args[3]); return finalizeWar(w); } else if (w.getSide2().equals(args[4])) { w.setSide2(args[5]); w.save(); - p.sendMessage(Helper.Chatlabel() + "Set side " + args[4] + " to " + args[5] + " in war " + args[3]); - Main.warLogger.log(Helper.Chatlabel() + "Set side " + args[4] + " to " + args[5] + " in war " + args[3]); + p.sendMessage(Helper.chatLabel() + "Set side " + args[4] + " to " + args[5] + " in war " + args[3]); + Main.warLogger.log(Helper.chatLabel() + "Set side " + args[4] + " to " + args[5] + " in war " + args[3]); return finalizeWar(w); } else { p.sendMessage(Helper.color("&cError: Side not found!")); @@ -1427,8 +1427,8 @@ public class AdminCommands implements CommandExecutor { for (War w : WarData.getWars()) { if (w.getName().equals(args[3])) { w.setName(args[4]); - p.sendMessage(Helper.Chatlabel() + "Set name of war " + args[3] + " to " + args[4]); - Main.warLogger.log(Helper.Chatlabel() + "Set name of war " + args[3] + " to " + args[4]); + p.sendMessage(Helper.chatLabel() + "Set name of war " + args[3] + " to " + args[4]); + Main.warLogger.log(Helper.chatLabel() + "Set name of war " + args[3] + " to " + args[4]); return finalizeWar(w); } } @@ -1456,18 +1456,18 @@ public class AdminCommands implements CommandExecutor { //if we already have surrendered if(w.getSurrenderedTowns().contains(args[6])) { w.unSurrenderTown(args[6]); - p.sendMessage(Helper.Chatlabel() + "Un-surrendered town " + args[6]); - Main.warLogger.log(Helper.Chatlabel() + "Un-surrendered town " + args[6]); + p.sendMessage(Helper.chatLabel() + "Un-surrendered town " + args[6]); + Main.warLogger.log(Helper.chatLabel() + "Un-surrendered town " + args[6]); } if(w.getSide1().equals(args[4])) { if(w.getSide2Towns().remove(args[6])) { - p.sendMessage(Helper.Chatlabel() + "Removed town " + args[6] + " from side " + w.getSide2()); - Main.warLogger.log(Helper.Chatlabel() + "Un-surrendered town " + args[6]); + p.sendMessage(Helper.chatLabel() + "Removed town " + args[6] + " from side " + w.getSide2()); + Main.warLogger.log(Helper.chatLabel() + "Un-surrendered town " + args[6]); } } else if(w.getSide2().equals(args[4])) { if(w.getSide1Towns().remove(args[6])) { - p.sendMessage(Helper.Chatlabel() + "Removed town " + args[6] + " from side " + w.getSide2()); - Main.warLogger.log(Helper.Chatlabel() + "Un-surrendered town " + args[6]); + p.sendMessage(Helper.chatLabel() + "Removed town " + args[6] + " from side " + w.getSide2()); + Main.warLogger.log(Helper.chatLabel() + "Un-surrendered town " + args[6]); } } } @@ -1475,16 +1475,16 @@ public class AdminCommands implements CommandExecutor { // Side checks int side = w.getSide(t.getName().toLowerCase()); if (side == -1) { - p.sendMessage(Helper.Chatlabel() + "Town already surrendered!"); + p.sendMessage(Helper.chatLabel() + "Town already surrendered!"); return true; } else if (side > 0) { - p.sendMessage(Helper.Chatlabel() + "Town already in this war!"); + p.sendMessage(Helper.chatLabel() + "Town already in this war!"); return true; } w.addTown(t, args[4]); - p.sendMessage(Helper.Chatlabel() + "Forcefully added town " + args[6] + " war " + args[3] + " on side " + args[4]); - Main.warLogger.log(Helper.Chatlabel() + "Forcefully added town " + args[6] + " war " + args[3] + " on side " + args[4]); + p.sendMessage(Helper.chatLabel() + "Forcefully added town " + args[6] + " war " + args[3] + " on side " + args[4]); + Main.warLogger.log(Helper.chatLabel() + "Forcefully added town " + args[6] + " war " + args[3] + " on side " + args[4]); return true; } else { p.sendMessage(Helper.color("&cError: Town not found!")); @@ -1500,18 +1500,18 @@ public class AdminCommands implements CommandExecutor { for(Town t : n.getTowns()) { if(w.getSurrenderedTowns().contains(t.getName())) { w.unSurrenderTown(t.getName()); - p.sendMessage(Helper.Chatlabel() + "Unsurrendered town " + t.getName()); - Main.warLogger.log(Helper.Chatlabel() + "Unsurrendered town " + t.getName()); + p.sendMessage(Helper.chatLabel() + "Unsurrendered town " + t.getName()); + Main.warLogger.log(Helper.chatLabel() + "Unsurrendered town " + t.getName()); } if(w.getSide1().equals(args[4])) { if(w.getSide2Towns().remove(t.getName())) { - p.sendMessage(Helper.Chatlabel() + "Removed town " + t.getName() + " from side " + w.getSide2()); - Main.warLogger.log(Helper.Chatlabel() + "Un-surrendered town " + t.getName()); + p.sendMessage(Helper.chatLabel() + "Removed town " + t.getName() + " from side " + w.getSide2()); + Main.warLogger.log(Helper.chatLabel() + "Un-surrendered town " + t.getName()); } } else if(w.getSide2().equals(args[4])) { if(w.getSide1Towns().remove(t.getName())) { - p.sendMessage(Helper.Chatlabel() + "Removed town " + t.getName() + " from side " + w.getSide2()); - Main.warLogger.log(Helper.Chatlabel() + "Un-surrendered town " + t.getName()); + p.sendMessage(Helper.chatLabel() + "Removed town " + t.getName() + " from side " + w.getSide2()); + Main.warLogger.log(Helper.chatLabel() + "Un-surrendered town " + t.getName()); } } } @@ -1522,17 +1522,17 @@ public class AdminCommands implements CommandExecutor { // Side checks int side = w.getSide(t.getName().toLowerCase()); if (side == -1) { - p.sendMessage(Helper.Chatlabel() + "Town " + t.getName() + " already surrendered!"); + p.sendMessage(Helper.chatLabel() + "Town " + t.getName() + " already surrendered!"); continue; } else if (side > 0) { - p.sendMessage(Helper.Chatlabel() + "Town " + t.getName() + " already in this war!"); + p.sendMessage(Helper.chatLabel() + "Town " + t.getName() + " already in this war!"); continue; } w.addTown(t, args[4]); } - p.sendMessage(Helper.Chatlabel() + "Forcefully added nation " + args[6] + " war " + args[3] + " on side " + args[4]); - Main.warLogger.log(Helper.Chatlabel() + "Forcefully added nation " + args[6] + " war " + args[3] + " on side " + args[4]); + p.sendMessage(Helper.chatLabel() + "Forcefully added nation " + args[6] + " war " + args[3] + " on side " + args[4]); + Main.warLogger.log(Helper.chatLabel() + "Forcefully added nation " + args[6] + " war " + args[3] + " on side " + args[4]); return finalizeWar(w); } else { p.sendMessage(Helper.color("&cError: Nation not found!")); @@ -1560,13 +1560,13 @@ public class AdminCommands implements CommandExecutor { if (t != null) { if(w.getSurrenderedTowns().contains(args[5])) { w.unSurrenderTown(args[5]); - p.sendMessage(Helper.Chatlabel() + "Un-surrendered town " + args[5]); - Main.warLogger.log(Helper.Chatlabel() + "Un-surrendered town " + args[5]); + p.sendMessage(Helper.chatLabel() + "Un-surrendered town " + args[5]); + Main.warLogger.log(Helper.chatLabel() + "Un-surrendered town " + args[5]); p.sendMessage(Helper.color("&cTo re-add, use: /alathrawaradmin modify war add, or have the town loader join.")); return true; } - p.sendMessage(Helper.Chatlabel() + "Town " + args[5] + " not already surrendered, ignoring."); - Main.warLogger.log(Helper.Chatlabel() + "Town " + args[5] + " not already surrendered, ignoring."); + p.sendMessage(Helper.chatLabel() + "Town " + args[5] + " not already surrendered, ignoring."); + Main.warLogger.log(Helper.chatLabel() + "Town " + args[5] + " not already surrendered, ignoring."); return true; } else { p.sendMessage(Helper.color("&cError: Town not found!")); @@ -1578,13 +1578,13 @@ public class AdminCommands implements CommandExecutor { for(Town t : n.getTowns()) { if (w.getSurrenderedTowns().contains(t.getName())) { w.unSurrenderTown(t.getName()); - p.sendMessage(Helper.Chatlabel() + "Un-surrendered town " + t.getName()); - Main.warLogger.log(Helper.Chatlabel() + "Un-surrendered town " + t.getName()); + p.sendMessage(Helper.chatLabel() + "Un-surrendered town " + t.getName()); + Main.warLogger.log(Helper.chatLabel() + "Un-surrendered town " + t.getName()); } } - p.sendMessage(Helper.Chatlabel() + "Un-surrendered nation " + args[5] + " in war " + args[3]); - Main.warLogger.log(Helper.Chatlabel() + "Un-surrendered nation " + args[5] + " in war " + args[3]); + p.sendMessage(Helper.chatLabel() + "Un-surrendered nation " + args[5] + " in war " + args[3]); + Main.warLogger.log(Helper.chatLabel() + "Un-surrendered nation " + args[5] + " in war " + args[3]); p.sendMessage(Helper.color("&cTo re-add, use: /alathrawaradmin modify war add, or have the nation loader join.")); return finalizeWar(w); } else { @@ -1618,22 +1618,22 @@ public class AdminCommands implements CommandExecutor { if (t != null) { if(w.getSide1Towns().contains(t.getName()) && w.getSide1().equals(args[4])) { w.surrenderTown(t.getName()); - p.sendMessage(Helper.Chatlabel() + "Forcefully surrendered town " + args[6] + " war " + args[3] + " on side " + args[4]); - Main.warLogger.log(Helper.Chatlabel() + "Forcefully surrendered town " + args[6] + " war " + args[3] + " on side " + args[4]); + p.sendMessage(Helper.chatLabel() + "Forcefully surrendered town " + args[6] + " war " + args[3] + " on side " + args[4]); + Main.warLogger.log(Helper.chatLabel() + "Forcefully surrendered town " + args[6] + " war " + args[3] + " on side " + args[4]); return finalizeWar(w); } else if(w.getSide2Towns().contains(t.getName()) && w.getSide2().equals(args[4])) { w.surrenderTown(t.getName()); - p.sendMessage(Helper.Chatlabel() + "Forcefully surrendered town " + args[6] + " war " + args[3] + " on side " + args[4]); - Main.warLogger.log(Helper.Chatlabel() + "Forcefully surrendered town " + args[6] + " war " + args[3] + " on side " + args[4]); + p.sendMessage(Helper.chatLabel() + "Forcefully surrendered town " + args[6] + " war " + args[3] + " on side " + args[4]); + Main.warLogger.log(Helper.chatLabel() + "Forcefully surrendered town " + args[6] + " war " + args[3] + " on side " + args[4]); return finalizeWar(w); } else { if (w.getSide1().equals(args[4]) || w.getSide2().equals(args[4])) { - p.sendMessage(Helper.Chatlabel() + "Town " + args[5] + " is not on either side of the war!"); - Main.warLogger.log(Helper.Chatlabel() + "Town " + args[5] + " is not on either side of the war!"); + p.sendMessage(Helper.chatLabel() + "Town " + args[5] + " is not on either side of the war!"); + Main.warLogger.log(Helper.chatLabel() + "Town " + args[5] + " is not on either side of the war!"); return true; } - p.sendMessage(Helper.Chatlabel() + "Town " + args[5] + " is on a side but side not correct! ERROR!"); - Main.warLogger.log(Helper.Chatlabel() + "Town " + args[5] + " is on a side but side not correct! ERROR!"); + p.sendMessage(Helper.chatLabel() + "Town " + args[5] + " is on a side but side not correct! ERROR!"); + Main.warLogger.log(Helper.chatLabel() + "Town " + args[5] + " is on a side but side not correct! ERROR!"); return true; } } else { @@ -1646,27 +1646,27 @@ public class AdminCommands implements CommandExecutor { for (Town t : n.getTowns()) { if(w.getSide1Towns().contains(t.getName()) && w.getSide1().equals(args[4])) { w.surrenderTown(t.getName()); - p.sendMessage(Helper.Chatlabel() + "Forcefully surrendered town " + t.getName() + " war " + args[3] + " on side " + args[4]); - Main.warLogger.log(Helper.Chatlabel() + "Forcefully surrendered town " + t.getName() + " war " + args[3] + " on side " + args[4]); + p.sendMessage(Helper.chatLabel() + "Forcefully surrendered town " + t.getName() + " war " + args[3] + " on side " + args[4]); + Main.warLogger.log(Helper.chatLabel() + "Forcefully surrendered town " + t.getName() + " war " + args[3] + " on side " + args[4]); } else if(w.getSide2Towns().contains(t.getName()) && w.getSide2().equals(args[4])) { w.surrenderTown(t.getName()); - p.sendMessage(Helper.Chatlabel() + "Forcefully surrendered town " + t.getName() + " war " + args[3] + " on side " + args[4]); - Main.warLogger.log(Helper.Chatlabel() + "Forcefully surrendered town " + t.getName() + " war " + args[3] + " on side " + args[4]); + p.sendMessage(Helper.chatLabel() + "Forcefully surrendered town " + t.getName() + " war " + args[3] + " on side " + args[4]); + Main.warLogger.log(Helper.chatLabel() + "Forcefully surrendered town " + t.getName() + " war " + args[3] + " on side " + args[4]); } else { if (w.getSide1().equals(args[4]) || w.getSide2().equals(args[4])) { - p.sendMessage(Helper.Chatlabel() + "Town " + t.getName() + " is not on either side of the war!"); - Main.warLogger.log(Helper.Chatlabel() + "Town " + t.getName() + " is not on either side of the war!"); + p.sendMessage(Helper.chatLabel() + "Town " + t.getName() + " is not on either side of the war!"); + Main.warLogger.log(Helper.chatLabel() + "Town " + t.getName() + " is not on either side of the war!"); return true; } - p.sendMessage(Helper.Chatlabel() + "Town " + t.getName() + " is on a side but side not correct! ERROR!"); - Main.warLogger.log(Helper.Chatlabel() + "Town " + t.getName() + " is on a side but side not correct! ERROR!"); + p.sendMessage(Helper.chatLabel() + "Town " + t.getName() + " is on a side but side not correct! ERROR!"); + Main.warLogger.log(Helper.chatLabel() + "Town " + t.getName() + " is on a side but side not correct! ERROR!"); return true; } } - p.sendMessage(Helper.Chatlabel() + "Surrendered nation " + args[6] + " war " + args[3] + " on side " + args[4]); - Main.warLogger.log(Helper.Chatlabel() + "Surrendered nation " + args[6] + " war " + args[3] + " on side " + args[4]); + p.sendMessage(Helper.chatLabel() + "Surrendered nation " + args[6] + " war " + args[3] + " on side " + args[4]); + Main.warLogger.log(Helper.chatLabel() + "Surrendered nation " + args[6] + " war " + args[3] + " on side " + args[4]); return finalizeWar(w); } else { p.sendMessage(Helper.color("&cError: Nation not found!")); @@ -1691,13 +1691,13 @@ public class AdminCommands implements CommandExecutor { if (args.length >= 7) { if (args[6].equals(w.getSide1())) { w.setLastRaidTimeSide1(w.getLastRaidTimeSide1() + Integer.parseInt(args[5])); - p.sendMessage(Helper.Chatlabel() + "Added " + args[6] + " to last raid time in war " + args[4]); - Main.warLogger.log(Helper.Chatlabel() + "Added " + args[6] + " to last raid time in war " + args[4]); + p.sendMessage(Helper.chatLabel() + "Added " + args[6] + " to last raid time in war " + args[4]); + Main.warLogger.log(Helper.chatLabel() + "Added " + args[6] + " to last raid time in war " + args[4]); return finalizeWar(w); } else if (args[6].equals(w.getSide2())) { w.setLastRaidTimeSide2(w.getLastRaidTimeSide2() + Integer.parseInt(args[5])); - p.sendMessage(Helper.Chatlabel() + "Added " + args[6] + " to last raid time in war " + args[4]); - Main.warLogger.log(Helper.Chatlabel() + "Added " + args[6] + " to last raid time in war " + args[4]); + p.sendMessage(Helper.chatLabel() + "Added " + args[6] + " to last raid time in war " + args[4]); + Main.warLogger.log(Helper.chatLabel() + "Added " + args[6] + " to last raid time in war " + args[4]); return finalizeWar(w); } else { p.sendMessage(Helper.color("&cSide not found!")); @@ -1711,13 +1711,13 @@ public class AdminCommands implements CommandExecutor { if (args.length >= 7) { if (args[6].equals(w.getSide1())) { w.setLastRaidTimeSide1(Integer.parseInt(args[5])); - p.sendMessage(Helper.Chatlabel() + "Set last raid time in war " + args[4] + " to " + args[6]); - Main.warLogger.log(Helper.Chatlabel() + "Set last raid time in war " + args[4] + " to " + args[6]); + p.sendMessage(Helper.chatLabel() + "Set last raid time in war " + args[4] + " to " + args[6]); + Main.warLogger.log(Helper.chatLabel() + "Set last raid time in war " + args[4] + " to " + args[6]); return finalizeWar(w); } else if (args[6].equals(w.getSide2())) { w.setLastRaidTimeSide2(Integer.parseInt(args[5])); - p.sendMessage(Helper.Chatlabel() + "Set last raid time in war " + args[4] + " to " + args[6]); - Main.warLogger.log(Helper.Chatlabel() + "Set last raid time in war " + args[4] + " to " + args[6]); + p.sendMessage(Helper.chatLabel() + "Set last raid time in war " + args[4] + " to " + args[6]); + Main.warLogger.log(Helper.chatLabel() + "Set last raid time in war " + args[4] + " to " + args[6]); return finalizeWar(w); } else { p.sendMessage(Helper.color("&cSide not found!")); @@ -1732,13 +1732,13 @@ public class AdminCommands implements CommandExecutor { if (args.length >= 6) { if (args[5].equals(w.getSide1())) { w.setLastRaidTimeSide1(0); - p.sendMessage(Helper.Chatlabel() + "Reset last raid time in war " + args[4]); - Main.warLogger.log(Helper.Chatlabel() + "Reset last raid time in war " + args[4]); + p.sendMessage(Helper.chatLabel() + "Reset last raid time in war " + args[4]); + Main.warLogger.log(Helper.chatLabel() + "Reset last raid time in war " + args[4]); return finalizeWar(w); } else if (args[5].equals(w.getSide2())) { w.setLastRaidTimeSide2(0); - p.sendMessage(Helper.Chatlabel() + "Reset last raid time in war " + args[4]); - Main.warLogger.log(Helper.Chatlabel() + "Reset last raid time in war " + args[4]); + p.sendMessage(Helper.chatLabel() + "Reset last raid time in war " + args[4]); + Main.warLogger.log(Helper.chatLabel() + "Reset last raid time in war " + args[4]); return finalizeWar(w); } else { p.sendMessage(Helper.color("&cSide not found!")); @@ -1771,8 +1771,8 @@ public class AdminCommands implements CommandExecutor { } else { t.addMetaData(new LongDataField("lastRaided", Long.parseLong(args[6]))); } - p.sendMessage(Helper.Chatlabel() + "Added " + args[6] + " to last raid time in war " + args[3]); - Main.warLogger.log(Helper.Chatlabel() + "Added " + args[6] + " to last raid time in war " + args[3]); + p.sendMessage(Helper.chatLabel() + "Added " + args[6] + " to last raid time in war " + args[3]); + Main.warLogger.log(Helper.chatLabel() + "Added " + args[6] + " to last raid time in war " + args[3]); } else { p.sendMessage(Helper.color("&cUsage: /alathrawaradmin modify war raidTimeTown [add,set,reset] [town/war] [amt] [side]")); } @@ -1780,16 +1780,16 @@ public class AdminCommands implements CommandExecutor { } else if (args[3].equalsIgnoreCase("set")) { if (args.length >= 6) { t.addMetaData(new LongDataField("lastRaided", Long.parseLong(args[6]))); - p.sendMessage(Helper.Chatlabel() + "Set last raid time in war " + args[4] + " to " + args[6]); - Main.warLogger.log(Helper.Chatlabel() + "Set last raid time in war " + args[4] + " to " + args[6]); + p.sendMessage(Helper.chatLabel() + "Set last raid time in war " + args[4] + " to " + args[6]); + Main.warLogger.log(Helper.chatLabel() + "Set last raid time in war " + args[4] + " to " + args[6]); } else { p.sendMessage(Helper.color("&cUsage: /alathrawaradmin modify war raidTimeTown [add,set,reset] [town/war] [amt] [side]")); } return true; } else if (args[3].equalsIgnoreCase("reset")) { t.addMetaData(new LongDataField("lastRaided", 0L)); - p.sendMessage(Helper.Chatlabel() + "Reset last raid time in town " + args[4]); - Main.warLogger.log(Helper.Chatlabel() + "Reset last raid time in war " + args[4]); + p.sendMessage(Helper.chatLabel() + "Reset last raid time in town " + args[4]); + Main.warLogger.log(Helper.chatLabel() + "Reset last raid time in war " + args[4]); return true; } else { p.sendMessage(Helper.color("&cUsage: /alathrawaradmin modify war raidTimeTown [add,set,reset] [town] [amt]")); @@ -1821,7 +1821,7 @@ public class AdminCommands implements CommandExecutor { if (args.length > 1) { Player p = Bukkit.getPlayer(args[1]); if (p == null) { - sender.sendMessage(Helper.Chatlabel() + Helper.color("&cPlayer not found!")); + sender.sendMessage(Helper.chatLabel() + Helper.color("&cPlayer not found!")); return true; } p.chat("awa awa! ^.^ UwU"); @@ -1835,15 +1835,15 @@ public class AdminCommands implements CommandExecutor { private static boolean fail(CommandSender p, String[] args, String type) { switch (type) { case "permissions" -> { - p.sendMessage(String.valueOf(Helper.Chatlabel()) + Helper.color("&cYou do not have permission to do this.")); + p.sendMessage(String.valueOf(Helper.chatLabel()) + Helper.color("&cYou do not have permission to do this.")); return true; } case "syntax" -> { - p.sendMessage(Helper.Chatlabel() + "Invalid Arguments. /alathrawaradmin help"); + p.sendMessage(Helper.chatLabel() + "Invalid Arguments. /alathrawaradmin help"); return true; } default -> { - p.sendMessage(Helper.Chatlabel() + "Something wrong. /alathrawaradmin help"); + p.sendMessage(Helper.chatLabel() + "Something wrong. /alathrawaradmin help"); return true; } } diff --git a/src/main/java/me/ShermansWorld/AlathraWar/commands/RaidCommands.java b/src/main/java/me/ShermansWorld/AlathraWar/commands/RaidCommands.java index 9034f17..1925a33 100644 --- a/src/main/java/me/ShermansWorld/AlathraWar/commands/RaidCommands.java +++ b/src/main/java/me/ShermansWorld/AlathraWar/commands/RaidCommands.java @@ -92,7 +92,7 @@ public class RaidCommands implements CommandExecutor { } else if (war.getSide2Players().contains(raidOwner.getName())) { side = war.getSide2(); } else { - p.sendMessage(String.valueOf(Helper.Chatlabel()) + "You are not in this war! Type /war join [war] [side]"); + p.sendMessage(String.valueOf(Helper.chatLabel()) + "You are not in this war! Type /war join [war] [side]"); return; } @@ -129,21 +129,21 @@ public class RaidCommands implements CommandExecutor { } else if(TownyAPI.getInstance().getTown(args[4]) != null) { gatherTown = TownyAPI.getInstance().getTown(args[4]); } else { - if (admin) p.sendMessage(String.valueOf(Helper.Chatlabel()) + "No valid town set for gather town, defaulting to current location"); - raidOwner.sendMessage(String.valueOf(Helper.Chatlabel()) + "No valid town set for gather town, defaulting to current location"); + if (admin) p.sendMessage(String.valueOf(Helper.chatLabel()) + "No valid town set for gather town, defaulting to current location"); + raidOwner.sendMessage(String.valueOf(Helper.chatLabel()) + "No valid town set for gather town, defaulting to current location"); gatherTown = TownyAPI.getInstance().getTownOrNull(WorldCoord.parseWorldCoord(raidOwner.getLocation()).getTownBlock()); } } else { gatherTown = TownyAPI.getInstance().getTownOrNull(WorldCoord.parseWorldCoord(raidOwner.getLocation()).getTownBlock()); } } catch (NotRegisteredException e2) { - if (admin) p.sendMessage(String.valueOf(Helper.Chatlabel()) + "You must be within a town's claim to begin a raid. That town you are in will be the gathering town."); - raidOwner.sendMessage(String.valueOf(Helper.Chatlabel()) + "You must be within a town's claim to begin a raid. That town you are in will be the gathering town."); + if (admin) p.sendMessage(String.valueOf(Helper.chatLabel()) + "You must be within a town's claim to begin a raid. That town you are in will be the gathering town."); + raidOwner.sendMessage(String.valueOf(Helper.chatLabel()) + "You must be within a town's claim to begin a raid. That town you are in will be the gathering town."); return; } if (gatherTown == null) { - if (admin) p.sendMessage(String.valueOf(Helper.Chatlabel()) + "You must be within a town's claim to begin a raid. That town you are in will be the gathering town."); - raidOwner.sendMessage(String.valueOf(Helper.Chatlabel()) + "You must be within a town's claim to begin a raid. That town you are in will be the gathering town."); + if (admin) p.sendMessage(String.valueOf(Helper.chatLabel()) + "You must be within a town's claim to begin a raid. That town you are in will be the gathering town."); + raidOwner.sendMessage(String.valueOf(Helper.chatLabel()) + "You must be within a town's claim to begin a raid. That town you are in will be the gathering town."); return; } @@ -157,20 +157,20 @@ public class RaidCommands implements CommandExecutor { //check if the town were attempting to raid is in the war if(!war.getSide1Towns().contains(raidedTown.getName()) && !war.getSide2Towns().contains(raidedTown.getName())) { if (war.getSurrenderedTowns().contains(raidedTown.getName())) { - if (admin) p.sendMessage(String.valueOf(Helper.Chatlabel()) + "The town you are trying to raid has already surrendered!"); - raidOwner.sendMessage(String.valueOf(Helper.Chatlabel()) + "The town you are trying to raid has already surrendered!"); + if (admin) p.sendMessage(String.valueOf(Helper.chatLabel()) + "The town you are trying to raid has already surrendered!"); + raidOwner.sendMessage(String.valueOf(Helper.chatLabel()) + "The town you are trying to raid has already surrendered!"); return; } - if (admin) p.sendMessage(String.valueOf(Helper.Chatlabel()) + "The town you are trying to raid is not part of the war!"); - raidOwner.sendMessage(String.valueOf(Helper.Chatlabel()) + "The town you are trying to raid is not part of the war!"); + if (admin) p.sendMessage(String.valueOf(Helper.chatLabel()) + "The town you are trying to raid is not part of the war!"); + raidOwner.sendMessage(String.valueOf(Helper.chatLabel()) + "The town you are trying to raid is not part of the war!"); return; } // Is being sieged check for (Siege s : SiegeData.getSieges()) { if(s.getTown().getName().equals(raidedTown.getName())) { - raidOwner.sendMessage(String.valueOf(Helper.Chatlabel()) + "That town is already currently being sieged! Cannot raid at this time!"); - if(admin) p.sendMessage(String.valueOf(Helper.Chatlabel()) + "That town is already currently being sieged! Cannot raid at this time!"); + raidOwner.sendMessage(String.valueOf(Helper.chatLabel()) + "That town is already currently being sieged! Cannot raid at this time!"); + if(admin) p.sendMessage(String.valueOf(Helper.chatLabel()) + "That town is already currently being sieged! Cannot raid at this time!"); } } @@ -184,20 +184,20 @@ public class RaidCommands implements CommandExecutor { //if were admin, see if an owner arg exists, and if so then use it raid2 = new Raid(war, raidedTown, gatherTown, true, raidOwner); } else if (c == 1) { - if (admin) p.sendMessage(String.valueOf(Helper.Chatlabel()) + "This town is already being raided at this time!"); - raidOwner.sendMessage(String.valueOf(Helper.Chatlabel()) + "This town is already being raided at this time!"); + if (admin) p.sendMessage(String.valueOf(Helper.chatLabel()) + "This town is already being raided at this time!"); + raidOwner.sendMessage(String.valueOf(Helper.chatLabel()) + "This town is already being raided at this time!"); return; } else if (c == 0) { - if (admin) p.sendMessage(String.valueOf(Helper.Chatlabel()) + "Your side has raided too recently!"); - raidOwner.sendMessage(String.valueOf(Helper.Chatlabel()) + "Your side has raided too recently!"); + if (admin) p.sendMessage(String.valueOf(Helper.chatLabel()) + "Your side has raided too recently!"); + raidOwner.sendMessage(String.valueOf(Helper.chatLabel()) + "Your side has raided too recently!"); return; } else if (c == -1) { - if (admin) p.sendMessage(String.valueOf(Helper.Chatlabel()) + "This town was raided too recently!"); - raidOwner.sendMessage(String.valueOf(Helper.Chatlabel()) + "This town was raided too recently!"); + if (admin) p.sendMessage(String.valueOf(Helper.chatLabel()) + "This town was raided too recently!"); + raidOwner.sendMessage(String.valueOf(Helper.chatLabel()) + "This town was raided too recently!"); return; } else if (c == -2) { - if (admin) p.sendMessage(String.valueOf(Helper.Chatlabel()) + "At least on member of the raided town must be online to defend it!"); - raidOwner.sendMessage(String.valueOf(Helper.Chatlabel()) + "At least on member of the raided town must be online to defend it!"); + if (admin) p.sendMessage(String.valueOf(Helper.chatLabel()) + "At least on member of the raided town must be online to defend it!"); + raidOwner.sendMessage(String.valueOf(Helper.chatLabel()) + "At least on member of the raided town must be online to defend it!"); return; } else { throw new IllegalArgumentException(); @@ -213,20 +213,20 @@ public class RaidCommands implements CommandExecutor { if (c == 2) { raid2 = new Raid(war, raidedTown, gatherTown, false, raidOwner); } else if (c == 1) { - if (admin) p.sendMessage(String.valueOf(Helper.Chatlabel()) + "This town is already being raided at this time!"); - raidOwner.sendMessage(String.valueOf(Helper.Chatlabel()) + "This town is already being raided at this time!"); + if (admin) p.sendMessage(String.valueOf(Helper.chatLabel()) + "This town is already being raided at this time!"); + raidOwner.sendMessage(String.valueOf(Helper.chatLabel()) + "This town is already being raided at this time!"); return; } else if (c == 0) { - if (admin) p.sendMessage(String.valueOf(Helper.Chatlabel()) + "Your side has raided too recently!"); - raidOwner.sendMessage(String.valueOf(Helper.Chatlabel()) + "Your side has raided too recently!"); + if (admin) p.sendMessage(String.valueOf(Helper.chatLabel()) + "Your side has raided too recently!"); + raidOwner.sendMessage(String.valueOf(Helper.chatLabel()) + "Your side has raided too recently!"); return; } else if (c == -1) { - if (admin) p.sendMessage(String.valueOf(Helper.Chatlabel()) + "This town was raided too recently!"); - raidOwner.sendMessage(String.valueOf(Helper.Chatlabel()) + "This town was raided too recently!"); + if (admin) p.sendMessage(String.valueOf(Helper.chatLabel()) + "This town was raided too recently!"); + raidOwner.sendMessage(String.valueOf(Helper.chatLabel()) + "This town was raided too recently!"); return; } else if (c == -2) { - if (admin) p.sendMessage(String.valueOf(Helper.Chatlabel()) + "At least on member of the raided town must be online to defend it!"); - raidOwner.sendMessage(String.valueOf(Helper.Chatlabel()) + "At least on member of the raided town must be online to defend it!"); + if (admin) p.sendMessage(String.valueOf(Helper.chatLabel()) + "At least on member of the raided town must be online to defend it!"); + raidOwner.sendMessage(String.valueOf(Helper.chatLabel()) + "At least on member of the raided town must be online to defend it!"); return; } else { throw new IllegalArgumentException(); @@ -237,27 +237,27 @@ public class RaidCommands implements CommandExecutor { Town leaderTown = TownyAPI.getInstance().getResident(raidOwner).getTownOrNull(); int sideR = war.getSide(leaderTown.getName()); if (sideR == 0) { - if (admin) p.sendMessage(Helper.Chatlabel() + "You are not in this war."); - raidOwner.sendMessage(Helper.Chatlabel() + "You are not in this war."); + if (admin) p.sendMessage(Helper.chatLabel() + "You are not in this war."); + raidOwner.sendMessage(Helper.chatLabel() + "You are not in this war."); return; } else if (sideR == -1) { - if (admin) p.sendMessage(Helper.Chatlabel() + "You have surrendered."); - raidOwner.sendMessage(Helper.Chatlabel() + "You have surrendered."); + if (admin) p.sendMessage(Helper.chatLabel() + "You have surrendered."); + raidOwner.sendMessage(Helper.chatLabel() + "You have surrendered."); return; } // Attacking own side if (war.getSide(raidedTown) == sideR) { - if (admin) p.sendMessage(Helper.Chatlabel() + "You cannot attack your own towns."); - raidOwner.sendMessage(Helper.Chatlabel() + "You cannot attack your own towns."); + if (admin) p.sendMessage(Helper.chatLabel() + "You cannot attack your own towns."); + raidOwner.sendMessage(Helper.chatLabel() + "You cannot attack your own towns."); return; } //check player balance final OfflinePlayer offlinePlayer = Bukkit.getOfflinePlayer(raidOwner.getUniqueId()); if (Main.econ.getBalance(offlinePlayer) <= 1000.0) { - if (admin) p.sendMessage(String.valueOf(Helper.Chatlabel()) + "You must have at least $1000 to put up to start a raid."); - raidOwner.sendMessage(String.valueOf(Helper.Chatlabel()) + "You must have at least $1000 to put up to start a raid."); + if (admin) p.sendMessage(String.valueOf(Helper.chatLabel()) + "You must have at least $1000 to put up to start a raid."); + raidOwner.sendMessage(String.valueOf(Helper.chatLabel()) + "You must have at least $1000 to put up to start a raid."); return; } @@ -269,11 +269,11 @@ public class RaidCommands implements CommandExecutor { WarData.saveWar(raid2.getWar()); //broadcast - Bukkit.broadcastMessage(String.valueOf(Helper.Chatlabel()) + "As part of " + war.getName() + ", forces from " + raid2.getRaiderSide() + " are gathering to raid the town of " + raidedTown.getName() + "!"); - Bukkit.broadcastMessage(String.valueOf(Helper.Chatlabel()) + "All players from the defending side have been drafted for the town's defense."); - Bukkit.broadcastMessage(Helper.Chatlabel() + "The raid of " + Bukkit.broadcastMessage(String.valueOf(Helper.chatLabel()) + "As part of " + war.getName() + ", forces from " + raid2.getRaiderSide() + " are gathering to raid the town of " + raidedTown.getName() + "!"); + Bukkit.broadcastMessage(String.valueOf(Helper.chatLabel()) + "All players from the defending side have been drafted for the town's defense."); + Bukkit.broadcastMessage(Helper.chatLabel() + "The raid of " + raidedTown.getName() + " will begin in " + (int) (RaidPhase.TRAVEL.startTick / 20 / 60) + " minutes!"); - Bukkit.broadcastMessage(Helper.Chatlabel() + + Bukkit.broadcastMessage(Helper.chatLabel() + "The Raiders are gathering at " + gatherTown.getName() + " before making the journey over!"); Main.warLogger.log(raidOwner.getName() + " started a raid."); @@ -285,11 +285,11 @@ public class RaidCommands implements CommandExecutor { } } if (!warFound) { - p.sendMessage(Helper.Chatlabel() + "That war does not exist! /raid start [war] [town]"); + p.sendMessage(Helper.chatLabel() + "That war does not exist! /raid start [war] [town]"); return; } if (!townExists) { - p.sendMessage(Helper.Chatlabel() + "That town does not exist! /raid start [war] [town]"); + p.sendMessage(Helper.chatLabel() + "That town does not exist! /raid start [war] [town]"); } } @@ -316,8 +316,8 @@ public class RaidCommands implements CommandExecutor { Raid raid = RaidData.getRaidOrNull(args[1] + "-" + args[2]); if (raid != null) { - p.sendMessage(String.valueOf(Helper.Chatlabel()) + "raid cancelled"); - Bukkit.broadcastMessage(String.valueOf(Helper.Chatlabel()) + "The raid of " + raid.getRaidedTown().getName() + " has been cancelled by an admin"); + p.sendMessage(String.valueOf(Helper.chatLabel()) + "raid cancelled"); + Bukkit.broadcastMessage(String.valueOf(Helper.chatLabel()) + "The raid of " + raid.getRaidedTown().getName() + " has been cancelled by an admin"); raid.stop(); //this purges itself from raids } else { fail(p, args, "badName"); @@ -342,31 +342,31 @@ public class RaidCommands implements CommandExecutor { if (args[4].equals(raid.getDefenderSide())) { if (!raid.getDefenderPlayers().contains(joiner.getName())) raid.getDefenderPlayers().add(joiner.getName()); - p.sendMessage(String.valueOf(Helper.Chatlabel()) + "Player " + joiner.getName() + " added to defender side."); + p.sendMessage(String.valueOf(Helper.chatLabel()) + "Player " + joiner.getName() + " added to defender side."); Main.warLogger.log("Player " + joiner.getName() + " added to defender side."); - joiner.sendMessage(String.valueOf(Helper.Chatlabel()) + "You were forcefully added to the defender side against the raid party on " + raid.getRaidedTown() + " by an admin."); + joiner.sendMessage(String.valueOf(Helper.chatLabel()) + "You were forcefully added to the defender side against the raid party on " + raid.getRaidedTown() + " by an admin."); return; } else { if (!raid.getRaiderPlayers().contains(joiner.getName())) raid.getRaiderPlayers().add(joiner.getName()); - p.sendMessage(String.valueOf(Helper.Chatlabel()) + "Player " + joiner.getName() + " added to raider side."); + p.sendMessage(String.valueOf(Helper.chatLabel()) + "Player " + joiner.getName() + " added to raider side."); Main.warLogger.log("Player " + joiner.getName() + " added to raider side."); - joiner.sendMessage(String.valueOf(Helper.Chatlabel()) + "You were forcefully added to the raid party on " + raid.getRaidedTown() + " by an admin. Leaving the gather town will remove you from the raid party."); + joiner.sendMessage(String.valueOf(Helper.chatLabel()) + "You were forcefully added to the raid party on " + raid.getRaidedTown() + " by an admin. Leaving the gather town will remove you from the raid party."); } } } else { - p.sendMessage(String.valueOf(Helper.Chatlabel()) + "Player " + args[3] + " not found!"); + p.sendMessage(String.valueOf(Helper.chatLabel()) + "Player " + args[3] + " not found!"); return; } } if(joiner == null) { - p.sendMessage(String.valueOf(Helper.Chatlabel()) + "Player not found! Is something broken?"); + p.sendMessage(String.valueOf(Helper.chatLabel()) + "Player not found! Is something broken?"); return; } if (!raid.getWar().getSide1Players().contains(joiner.getName()) && !raid.getWar().getSide2Players().contains(joiner.getName())) { - joiner.sendMessage(String.valueOf(Helper.Chatlabel()) + "You are not in this war! Type /war join [war] [side]"); + joiner.sendMessage(String.valueOf(Helper.chatLabel()) + "You are not in this war! Type /war join [war] [side]"); } //Minutemen countermeasures, 86400 * 4 time. 86400 seconds in a day, 4 days min playtime @@ -405,16 +405,16 @@ public class RaidCommands implements CommandExecutor { ArrayList cluster = Helper.getCluster(raid.getGatherTown().getHomeBlock().getWorldCoord()); if (cluster.contains(WorldCoord.parseWorldCoord(joiner))) { raid.addActiveRaider(joiner.getName()); - joiner.sendMessage(String.valueOf(Helper.Chatlabel()) + "You have joined the raid on " + raid.getRaidedTown().getName() + "!"); - joiner.sendMessage(String.valueOf(Helper.Chatlabel()) + "Leaving " + raid.getGatherTown().getName() + " will cause you to leave the raid party."); + joiner.sendMessage(String.valueOf(Helper.chatLabel()) + "You have joined the raid on " + raid.getRaidedTown().getName() + "!"); + joiner.sendMessage(String.valueOf(Helper.chatLabel()) + "Leaving " + raid.getGatherTown().getName() + " will cause you to leave the raid party."); } else { - joiner.sendMessage(String.valueOf(Helper.Chatlabel()) + "You must be in the gathering town to join the raid on " + raid.getRaidedTown().getName() + "."); + joiner.sendMessage(String.valueOf(Helper.chatLabel()) + "You must be in the gathering town to join the raid on " + raid.getRaidedTown().getName() + "."); } } catch (TownyException e) { throw new RuntimeException(e); } } else { - joiner.sendMessage(String.valueOf(Helper.Chatlabel()) + "You cannot join the raid on " + raid.getRaidedTown().getName() + "! It has already started!"); + joiner.sendMessage(String.valueOf(Helper.chatLabel()) + "You cannot join the raid on " + raid.getRaidedTown().getName() + "! It has already started!"); } } else { try { @@ -422,10 +422,10 @@ public class RaidCommands implements CommandExecutor { ArrayList cluster = Helper.getCluster(raid.getGatherTown().getHomeBlock().getWorldCoord()); if (cluster.contains(WorldCoord.parseWorldCoord(joiner))) { raid.addActiveRaider(joiner.getName()); - joiner.sendMessage(String.valueOf(Helper.Chatlabel()) + "You have joined the raid on " + raid.getRaidedTown().getName() + "!"); - joiner.sendMessage(String.valueOf(Helper.Chatlabel()) + "Leaving " + raid.getGatherTown().getName() + " will cause you to leave the raid party."); + joiner.sendMessage(String.valueOf(Helper.chatLabel()) + "You have joined the raid on " + raid.getRaidedTown().getName() + "!"); + joiner.sendMessage(String.valueOf(Helper.chatLabel()) + "Leaving " + raid.getGatherTown().getName() + " will cause you to leave the raid party."); } else { - joiner.sendMessage(String.valueOf(Helper.Chatlabel()) + "You must be in the gathering town to join the raid on " + raid.getRaidedTown().getName() + "."); + joiner.sendMessage(String.valueOf(Helper.chatLabel()) + "You must be in the gathering town to join the raid on " + raid.getRaidedTown().getName() + "."); } } catch (TownyException e) { throw new RuntimeException(e); @@ -435,7 +435,7 @@ public class RaidCommands implements CommandExecutor { raid.save(); } } else { - p.sendMessage(String.valueOf(Helper.Chatlabel()) + "No raid is gathering in this town or this town does not exist!"); + p.sendMessage(String.valueOf(Helper.chatLabel()) + "No raid is gathering in this town or this town does not exist!"); } } @@ -445,7 +445,7 @@ public class RaidCommands implements CommandExecutor { if (admin) { p = Bukkit.getPlayer(args[3]); if (p == null) { - player.sendMessage(String.valueOf(Helper.Chatlabel()) + "Error: player not found!"); + player.sendMessage(String.valueOf(Helper.chatLabel()) + "Error: player not found!"); return; } } @@ -457,8 +457,8 @@ public class RaidCommands implements CommandExecutor { if (raid != null) { if (raid.getWar().getName().equalsIgnoreCase(args[1])) { if (!raid.getWar().getSide1Players().contains(p.getName()) && !raid.getWar().getSide2Players().contains(p.getName())) { - p.sendMessage(String.valueOf(Helper.Chatlabel()) + "You are not in this war! Type /war join [war] [side]"); - if (admin) player.sendMessage(String.valueOf(Helper.Chatlabel()) + "You are not in this war! Type /war join [war] [side]"); + p.sendMessage(String.valueOf(Helper.chatLabel()) + "You are not in this war! Type /war join [war] [side]"); + if (admin) player.sendMessage(String.valueOf(Helper.chatLabel()) + "You are not in this war! Type /war join [war] [side]"); } //check if gather phase @@ -468,12 +468,12 @@ public class RaidCommands implements CommandExecutor { ArrayList cluster = Helper.getCluster(raid.getGatherTown().getHomeBlock().getWorldCoord()); if (cluster.contains(WorldCoord.parseWorldCoord(p))) { raid.removeActiveRaider(p.getName()); - p.sendMessage(String.valueOf(Helper.Chatlabel()) + "You have left the raid on " + raid.getRaidedTown().getName() + "!"); - if (admin) player.sendMessage(String.valueOf(Helper.Chatlabel()) + "You have left the raid on " + raid.getRaidedTown().getName() + "!"); + p.sendMessage(String.valueOf(Helper.chatLabel()) + "You have left the raid on " + raid.getRaidedTown().getName() + "!"); + if (admin) player.sendMessage(String.valueOf(Helper.chatLabel()) + "You have left the raid on " + raid.getRaidedTown().getName() + "!"); } else { - p.sendMessage(String.valueOf(Helper.Chatlabel()) + "You cannot leave the raid on " + raid.getRaidedTown().getName() + "! It has already started!"); - if (admin) player.sendMessage(String.valueOf(Helper.Chatlabel()) + "You cannot leave the raid on " + raid.getRaidedTown().getName() + "! It has already started!"); + p.sendMessage(String.valueOf(Helper.chatLabel()) + "You cannot leave the raid on " + raid.getRaidedTown().getName() + "! It has already started!"); + if (admin) player.sendMessage(String.valueOf(Helper.chatLabel()) + "You cannot leave the raid on " + raid.getRaidedTown().getName() + "! It has already started!"); } } catch (TownyException e) { throw new RuntimeException(e); @@ -483,8 +483,8 @@ public class RaidCommands implements CommandExecutor { raid.save(); } else { - p.sendMessage(String.valueOf(Helper.Chatlabel()) + "No raid is gathering in this town or this town does not exist!"); - if (admin) player.sendMessage(String.valueOf(Helper.Chatlabel()) + "No raid is gathering in this town or this town does not exist!"); + p.sendMessage(String.valueOf(Helper.chatLabel()) + "No raid is gathering in this town or this town does not exist!"); + if (admin) player.sendMessage(String.valueOf(Helper.chatLabel()) + "No raid is gathering in this town or this town does not exist!"); } } @@ -500,7 +500,7 @@ public class RaidCommands implements CommandExecutor { if (raid != null) { if (raid.getWar().getName().equalsIgnoreCase(args[1])) { if (!raid.getWar().getSide1Players().contains(p.getName()) && !raid.getWar().getSide2Players().contains(p.getName())) { - p.sendMessage(String.valueOf(Helper.Chatlabel()) + "You are not in this war! Type /war join [war] [side]"); + p.sendMessage(String.valueOf(Helper.chatLabel()) + "You are not in this war! Type /war join [war] [side]"); return; } @@ -508,11 +508,11 @@ public class RaidCommands implements CommandExecutor { //check if gather phase if (raid.getPhase() == RaidPhase.GATHER || raid.getPhase() == RaidPhase.START || raid.getPhase() == RaidPhase.TRAVEL || raid.getPhase() == RaidPhase.COMBAT) { //force defender victory - Bukkit.broadcastMessage(String.valueOf(Helper.Chatlabel()) + "The raid on " + raid.getRaidedTown().getName() + " has been abandoned by " + raid.getRaiderSide()); + Bukkit.broadcastMessage(String.valueOf(Helper.chatLabel()) + "The raid on " + raid.getRaidedTown().getName() + " has been abandoned by " + raid.getRaiderSide()); Main.warLogger.log(p.getName() + " abandoned the raid on " + raid.getRaidedTown().getName() + " they started at " + raid.getGatherTown().getName()); raid.defendersWin(raid.getRaiderScore(), raid.getDefenderScore()); } else { - p.sendMessage(String.valueOf(Helper.Chatlabel()) + "You cannot abandon the raid on " + raid.getRaidedTown().getName() + "! It has a problem!"); + p.sendMessage(String.valueOf(Helper.chatLabel()) + "You cannot abandon the raid on " + raid.getRaidedTown().getName() + "! It has a problem!"); } } else { fail(p, args, "owner"); @@ -520,15 +520,15 @@ public class RaidCommands implements CommandExecutor { } } - p.sendMessage(String.valueOf(Helper.Chatlabel()) + "This raid does not exist!"); + p.sendMessage(String.valueOf(Helper.chatLabel()) + "This raid does not exist!"); } private static void listRaids(CommandSender p, String[] args) { if (RaidData.getRaids().isEmpty()) { - p.sendMessage(String.valueOf(Helper.Chatlabel()) + "There are currently no Raids in progress"); + p.sendMessage(String.valueOf(Helper.chatLabel()) + "There are currently no Raids in progress"); return; } - p.sendMessage(String.valueOf(Helper.Chatlabel()) + "Raids currently in progress:"); + p.sendMessage(String.valueOf(Helper.chatLabel()) + "Raids currently in progress:"); for (final Raid raid : RaidData.getRaids()) { p.sendMessage("Name: " + raid.getName()); p.sendMessage("War: " + raid.getWar().getName()); @@ -547,23 +547,23 @@ public class RaidCommands implements CommandExecutor { private static void raidHelp(CommandSender p, String[] args) { if (p.hasPermission("!AlathraWar.admin")) { - p.sendMessage(Helper.Chatlabel() + "/raid stop [name]"); + p.sendMessage(Helper.chatLabel() + "/raid stop [name]"); } - p.sendMessage(Helper.Chatlabel() + "/raid start [war] [town]"); - p.sendMessage(Helper.Chatlabel() + "/raid join [war] [town]"); - p.sendMessage(Helper.Chatlabel() + "/raid leave [war] [town]"); - p.sendMessage(Helper.Chatlabel() + "/raid abandon [war] [town]"); - p.sendMessage(Helper.Chatlabel() + "/raid list"); + p.sendMessage(Helper.chatLabel() + "/raid start [war] [town]"); + p.sendMessage(Helper.chatLabel() + "/raid join [war] [town]"); + p.sendMessage(Helper.chatLabel() + "/raid leave [war] [town]"); + p.sendMessage(Helper.chatLabel() + "/raid abandon [war] [town]"); + p.sendMessage(Helper.chatLabel() + "/raid list"); } private static void fail(CommandSender p, String[] args, String type) { switch (type) { - case "permissions" -> p.sendMessage(String.valueOf(Helper.Chatlabel()) + "&cYou do not have permission to do this"); - case "syntax" -> p.sendMessage(String.valueOf(Helper.Chatlabel()) + "Invalid Syntax. /raid help"); - case "noRaids" -> p.sendMessage(String.valueOf(Helper.Chatlabel()) + "There are currently no Raids in progress"); - case "badName" -> p.sendMessage(String.valueOf(Helper.Chatlabel()) + "A raid could not be found with this Name! Type /raid list to view current raids"); - case "owner" -> p.sendMessage(String.valueOf(Helper.Chatlabel()) + "Only the player who started the raid can abandon it."); - default -> p.sendMessage(String.valueOf(Helper.Chatlabel()) + "Invalid Arguments. /raid help"); + case "permissions" -> p.sendMessage(String.valueOf(Helper.chatLabel()) + "&cYou do not have permission to do this"); + case "syntax" -> p.sendMessage(String.valueOf(Helper.chatLabel()) + "Invalid Syntax. /raid help"); + case "noRaids" -> p.sendMessage(String.valueOf(Helper.chatLabel()) + "There are currently no Raids in progress"); + case "badName" -> p.sendMessage(String.valueOf(Helper.chatLabel()) + "A raid could not be found with this Name! Type /raid list to view current raids"); + case "owner" -> p.sendMessage(String.valueOf(Helper.chatLabel()) + "Only the player who started the raid can abandon it."); + default -> p.sendMessage(String.valueOf(Helper.chatLabel()) + "Invalid Arguments. /raid help"); } } } diff --git a/src/main/java/me/ShermansWorld/AlathraWar/commands/SiegeCommands.java b/src/main/java/me/ShermansWorld/AlathraWar/commands/SiegeCommands.java index ae481e2..910fdb2 100644 --- a/src/main/java/me/ShermansWorld/AlathraWar/commands/SiegeCommands.java +++ b/src/main/java/me/ShermansWorld/AlathraWar/commands/SiegeCommands.java @@ -24,7 +24,7 @@ public class SiegeCommands implements CommandExecutor { public boolean onCommand(final CommandSender sender, final Command cmd, final String label, final String[] args) { if (args.length == 0) { - sender.sendMessage(String.valueOf(Helper.Chatlabel()) + "Invalid Arguments. /siege help"); + sender.sendMessage(String.valueOf(Helper.chatLabel()) + "Invalid Arguments. /siege help"); return true; } @@ -76,15 +76,15 @@ public class SiegeCommands implements CommandExecutor { } if (args.length < 3) { - sender.sendMessage(Helper.Chatlabel() + "/war siege [war] [town]"); + sender.sendMessage(Helper.chatLabel() + "/war siege [war] [town]"); return; } // War check War war = WarData.getWar(args[1]); if (war == null) { - siegeOwner.sendMessage(String.valueOf(Helper.Chatlabel()) + "That war does not exist! /siege start [war] [town]"); - if(admin) sender.sendMessage(String.valueOf(Helper.Chatlabel()) + "That war does not exist! /siege start [war] [town]"); + siegeOwner.sendMessage(String.valueOf(Helper.chatLabel()) + "That war does not exist! /siege start [war] [town]"); + if(admin) sender.sendMessage(String.valueOf(Helper.chatLabel()) + "That war does not exist! /siege start [war] [town]"); return; } @@ -92,12 +92,12 @@ public class SiegeCommands implements CommandExecutor { Town leaderTown = TownyAPI.getInstance().getResident(siegeOwner).getTownOrNull(); int side = war.getSide(leaderTown.getName()); if (side == 0) { - siegeOwner.sendMessage(Helper.Chatlabel() + "You are not in this war."); - if(admin) sender.sendMessage(Helper.Chatlabel() + "You are not in this war."); + siegeOwner.sendMessage(Helper.chatLabel() + "You are not in this war."); + if(admin) sender.sendMessage(Helper.chatLabel() + "You are not in this war."); return; } else if (side == -1) { - siegeOwner.sendMessage(Helper.Chatlabel() + "You have surrendered."); - if(admin) sender.sendMessage(Helper.Chatlabel() + "You have surrendered."); + siegeOwner.sendMessage(Helper.chatLabel() + "You have surrendered."); + if(admin) sender.sendMessage(Helper.chatLabel() + "You have surrendered."); return; } @@ -132,24 +132,24 @@ public class SiegeCommands implements CommandExecutor { // Town check Town town = TownyAPI.getInstance().getTown(args[2]); if (town == null) { - siegeOwner.sendMessage(String.valueOf(Helper.Chatlabel()) + "That town does not exist! /siege start [war] [town]"); - if(admin) sender.sendMessage(String.valueOf(Helper.Chatlabel()) + "That town does not exist! /siege start [war] [town]"); + siegeOwner.sendMessage(String.valueOf(Helper.chatLabel()) + "That town does not exist! /siege start [war] [town]"); + if(admin) sender.sendMessage(String.valueOf(Helper.chatLabel()) + "That town does not exist! /siege start [war] [town]"); return; } // Is being raided check for ( Raid r : RaidData.getRaids()) { if(r.getRaidedTown().getName().equals(town.getName())) { - siegeOwner.sendMessage(String.valueOf(Helper.Chatlabel()) + "That town is already currently being raided! Cannot siege at this time!"); - if(admin) sender.sendMessage(String.valueOf(Helper.Chatlabel()) + "That town is already currently being raided! Cannot siege at this time!"); + siegeOwner.sendMessage(String.valueOf(Helper.chatLabel()) + "That town is already currently being raided! Cannot siege at this time!"); + if(admin) sender.sendMessage(String.valueOf(Helper.chatLabel()) + "That town is already currently being raided! Cannot siege at this time!"); return; } } // Attacking own side if (war.getSide(town) == side) { - siegeOwner.sendMessage(Helper.Chatlabel() + "You cannot attack your own towns."); - if(admin) sender.sendMessage(Helper.Chatlabel() + "You cannot attack your own towns."); + siegeOwner.sendMessage(Helper.chatLabel() + "You cannot attack your own towns."); + if(admin) sender.sendMessage(Helper.chatLabel() + "You cannot attack your own towns."); return; } @@ -157,7 +157,7 @@ public class SiegeCommands implements CommandExecutor { SiegeData.addSiege(siege); war.addSiege(siege); - Bukkit.broadcastMessage(Helper.Chatlabel() + "A siege has been laid on " + siege.getTown() + " by " + siege.getAttackerSide() + "!"); + Bukkit.broadcastMessage(Helper.chatLabel() + "A siege has been laid on " + siege.getTown() + " by " + siege.getAttackerSide() + "!"); war.save(); siege.start(); @@ -165,37 +165,37 @@ public class SiegeCommands implements CommandExecutor { private static void siegeStop(CommandSender sender, String[] args) { if (!sender.hasPermission("AlathraWar.admin")) { - sender.sendMessage(String.valueOf(Helper.Chatlabel()) + Helper.color("&cYou do not have permission to do this")); + sender.sendMessage(String.valueOf(Helper.chatLabel()) + Helper.color("&cYou do not have permission to do this")); return; } HashSet sieges = SiegeData.getSieges(); if (sieges.isEmpty()) { - sender.sendMessage(String.valueOf(Helper.Chatlabel()) + "There are currently no sieges in progress"); + sender.sendMessage(String.valueOf(Helper.chatLabel()) + "There are currently no sieges in progress"); return; } if (args.length < 3) { - sender.sendMessage(Helper.Chatlabel() + "/siege stop [town]"); + sender.sendMessage(Helper.chatLabel() + "/siege stop [town]"); return; } // War check War war = WarData.getWar(args[1]); if (war == null) { - sender.sendMessage(String.valueOf(Helper.Chatlabel()) + "That war does not exist! /siege stop [war] [town]"); + sender.sendMessage(String.valueOf(Helper.chatLabel()) + "That war does not exist! /siege stop [war] [town]"); return; } for (Siege siege : sieges) { if (siege.getTown().getName().equalsIgnoreCase(args[2])) { - sender.sendMessage(String.valueOf(Helper.Chatlabel()) + "siege cancelled"); - Bukkit.broadcastMessage(String.valueOf(Helper.Chatlabel()) + "The siege at " + siege.getTown().getName() + " has been cancelled by an admin"); + sender.sendMessage(String.valueOf(Helper.chatLabel()) + "siege cancelled"); + Bukkit.broadcastMessage(String.valueOf(Helper.chatLabel()) + "The siege at " + siege.getTown().getName() + " has been cancelled by an admin"); //siege.clearBeacon(); siege.stop(); return; } } - sender.sendMessage(String.valueOf(Helper.Chatlabel()) + "A siege could not be found with this town name! Type /siege list to view current sieges"); + sender.sendMessage(String.valueOf(Helper.chatLabel()) + "A siege could not be found with this town name! Type /siege list to view current sieges"); } private static void siegeAbandon(CommandSender sender, String[] args) { @@ -203,30 +203,30 @@ public class SiegeCommands implements CommandExecutor { final Player p = (Player) sender; if (args.length < 3) { - sender.sendMessage(Helper.Chatlabel() + "/siege abandon [town]"); + sender.sendMessage(Helper.chatLabel() + "/siege abandon [town]"); return; } // War check War war = WarData.getWar(args[1]); if (war == null) { - p.sendMessage(String.valueOf(Helper.Chatlabel()) + "That war does not exist! /siege abandon [war] [town]"); + p.sendMessage(String.valueOf(Helper.chatLabel()) + "That war does not exist! /siege abandon [war] [town]"); return; } Siege siege = SiegeData.getSiege(args[2]); if (siege == null) { - p.sendMessage(Helper.Chatlabel() + "Invalid siege"); + p.sendMessage(Helper.chatLabel() + "Invalid siege"); return; } OfflinePlayer oPlayer = siege.getSiegeLeader(); if (oPlayer != (OfflinePlayer) p) { - p.sendMessage(Helper.Chatlabel() + "You are not the leader of this siege."); + p.sendMessage(Helper.chatLabel() + "You are not the leader of this siege."); return; } - Bukkit.broadcastMessage(String.valueOf(Helper.Chatlabel()) + "The siege at " + siege.getTown().getName() + " has been abandoned."); + Bukkit.broadcastMessage(String.valueOf(Helper.chatLabel()) + "The siege at " + siege.getTown().getName() + " has been abandoned."); Main.warLogger.log(p.getName() + " abandoned the siege they started at " + siege.getTown().getName()); siege.defendersWin(); @@ -235,11 +235,11 @@ public class SiegeCommands implements CommandExecutor { private static void siegeList(CommandSender sender, String[] args) { HashSet sieges = SiegeData.getSieges(); if (sieges.isEmpty()) { - sender.sendMessage(String.valueOf(Helper.Chatlabel()) + "There are currently no sieges in progress"); + sender.sendMessage(String.valueOf(Helper.chatLabel()) + "There are currently no sieges in progress"); return; } - sender.sendMessage(String.valueOf(Helper.Chatlabel()) + "Sieges currently in progress:"); + sender.sendMessage(String.valueOf(Helper.chatLabel()) + "Sieges currently in progress:"); for (Siege siege : sieges) { War war = siege.getWar(); String color = (siege.getSide1AreAttackers() && (war.getSide(siege.getTown().getName()) == 1) ) ? "§c" : "§9"; @@ -254,10 +254,10 @@ public class SiegeCommands implements CommandExecutor { private static void siegeHelp(CommandSender sender, String[] args) { if (sender.hasPermission("AlathraWar.admin")) { - sender.sendMessage(Helper.Chatlabel() + "/siege stop [town]"); + sender.sendMessage(Helper.chatLabel() + "/siege stop [town]"); } - sender.sendMessage(Helper.Chatlabel() + "/siege start [war] [town]"); - sender.sendMessage(Helper.Chatlabel() + "/siege abandon [town]"); - sender.sendMessage(Helper.Chatlabel() + "/siege list"); + sender.sendMessage(Helper.chatLabel() + "/siege start [war] [town]"); + sender.sendMessage(Helper.chatLabel() + "/siege abandon [town]"); + sender.sendMessage(Helper.chatLabel() + "/siege list"); } } diff --git a/src/main/java/me/ShermansWorld/AlathraWar/commands/WarCommands.java b/src/main/java/me/ShermansWorld/AlathraWar/commands/WarCommands.java index ce109cf..1f4834b 100644 --- a/src/main/java/me/ShermansWorld/AlathraWar/commands/WarCommands.java +++ b/src/main/java/me/ShermansWorld/AlathraWar/commands/WarCommands.java @@ -32,7 +32,7 @@ public class WarCommands implements CommandExecutor { final Player p = (Player) sender; if (args.length == 0) { - p.sendMessage(String.valueOf(Helper.Chatlabel()) + "Invalid Arguments. /war help"); + p.sendMessage(String.valueOf(Helper.chatLabel()) + "Invalid Arguments. /war help"); return true; } else if (args.length >= 1) { @@ -59,7 +59,7 @@ public class WarCommands implements CommandExecutor { warHelp(p, args); return true; default: - p.sendMessage(String.valueOf(Helper.Chatlabel()) + "Invalid Arguments. /war help"); + p.sendMessage(String.valueOf(Helper.chatLabel()) + "Invalid Arguments. /war help"); return true; } @@ -77,13 +77,13 @@ public class WarCommands implements CommandExecutor { WarData.addWar(war); war.save(); - p.sendMessage(String.valueOf(Helper.Chatlabel()) + "War created with the name " + args[1] + ", " + p.sendMessage(String.valueOf(Helper.chatLabel()) + "War created with the name " + args[1] + ", " + args[2] + " vs. " + args[3]); Main.warLogger.log(p.getName() + " created a new war with the name " + args[1] + ", " + args[2] + " vs. " + args[3]); return; } else { - p.sendMessage(String.valueOf(Helper.Chatlabel()) + p.sendMessage(String.valueOf(Helper.chatLabel()) + "Invalid Arguments. /war create [name] [side1] [side2]"); } @@ -100,18 +100,18 @@ public class WarCommands implements CommandExecutor { // War Check if (war == null) { - p.sendMessage(Helper.Chatlabel() + p.sendMessage(Helper.chatLabel() + "War not found. Type /war list to view current wars."); return; } WarData.removeWar(war); - p.sendMessage(String.valueOf(Helper.Chatlabel()) + "War " + args[1] + " deleted."); + p.sendMessage(String.valueOf(Helper.chatLabel()) + "War " + args[1] + " deleted."); Main.warLogger.log(p.getName() + " deleted " + args[1]); return; } else { - p.sendMessage(String.valueOf(Helper.Chatlabel()) + p.sendMessage(String.valueOf(Helper.chatLabel()) + "Invalid Arguments. /war delete [name]"); } } @@ -125,7 +125,7 @@ public class WarCommands implements CommandExecutor { protected static void warJoin(CommandSender p, String[] args, boolean admin) { // Sufficient args check if (args.length < 3) { - p.sendMessage(Helper.Chatlabel() + p.sendMessage(Helper.chatLabel() + "/war join [name] [side], type /war list to view current wars"); return; } @@ -133,7 +133,7 @@ public class WarCommands implements CommandExecutor { // War check War war = WarData.getWar(args[1]); if (war == null) { - p.sendMessage(Helper.Chatlabel() + p.sendMessage(Helper.chatLabel() + "War not found. /war join [name] [side], type /war list to view current wars"); return; } @@ -142,7 +142,7 @@ public class WarCommands implements CommandExecutor { if (admin){ player = Bukkit.getPlayer(args[3]); if(player == null) { - p.sendMessage(Helper.Chatlabel() + "Player " + args[3] + " not found!"); + p.sendMessage(Helper.chatLabel() + "Player " + args[3] + " not found!"); return; } } @@ -192,10 +192,10 @@ public class WarCommands implements CommandExecutor { // Side checks int side = war.getSide(town.getName().toLowerCase()); if (side == -1) { - p.sendMessage(Helper.Chatlabel() + "You've already surrendered!"); + p.sendMessage(Helper.chatLabel() + "You've already surrendered!"); return; } else if (side > 0) { - p.sendMessage(Helper.Chatlabel() + "You're already in this war!"); + p.sendMessage(Helper.chatLabel() + "You're already in this war!"); return; } @@ -203,26 +203,26 @@ public class WarCommands implements CommandExecutor { if(res.getPlayer().hasPermission("AlathraWar.nationjoin" )|| res.isKing()) { // Has nation declaration permission war.addNation(res.getNationOrNull(), args[2]); - res.getPlayer().sendMessage(Helper.Chatlabel() + "You have joined the war for " + res.getNationOrNull().getName()); - p.sendMessage(Helper.Chatlabel() + "You have joined the war for " + res.getNationOrNull().getName()); + res.getPlayer().sendMessage(Helper.chatLabel() + "You have joined the war for " + res.getNationOrNull().getName()); + p.sendMessage(Helper.chatLabel() + "You have joined the war for " + res.getNationOrNull().getName()); war.save(); return; } else { // Cannot declare nation involvement - p.sendMessage(Helper.Chatlabel() + "You cannot declare war for your nation."); + p.sendMessage(Helper.chatLabel() + "You cannot declare war for your nation."); return; } } else if (res.hasTown()) { if (res.getPlayer().hasPermission("AlathraWar.townjoin") || res.isMayor()) { // Is in indepdenent town & has declaration perms war.addTown(res.getTownOrNull(), args[2]); - res.getPlayer().sendMessage(Helper.Chatlabel() + "You have joined the war for " + res.getTownOrNull().getName()); - p.sendMessage(Helper.Chatlabel() + "You have joined the war for " + res.getTownOrNull().getName()); + res.getPlayer().sendMessage(Helper.chatLabel() + "You have joined the war for " + res.getTownOrNull().getName()); + p.sendMessage(Helper.chatLabel() + "You have joined the war for " + res.getTownOrNull().getName()); war.save(); return; } else { // No perms - p.sendMessage(Helper.Chatlabel() + "You cannot declare war for your town."); + p.sendMessage(Helper.chatLabel() + "You cannot declare war for your town."); return; } } @@ -231,7 +231,7 @@ public class WarCommands implements CommandExecutor { protected static void warSurrender(Player p, String[] args, boolean admin) { // Sufficient args check if (args.length < 2) { - p.sendMessage(Helper.Chatlabel() + p.sendMessage(Helper.chatLabel() + "/war surrender [name], type /war list to view current wars"); return; } @@ -239,7 +239,7 @@ public class WarCommands implements CommandExecutor { // War check War war = WarData.getWar(args[1]); if (war == null) { - p.sendMessage(Helper.Chatlabel() + p.sendMessage(Helper.chatLabel() + "War not found. Type /war list to view current wars"); return; } @@ -258,24 +258,24 @@ public class WarCommands implements CommandExecutor { if(p.hasPermission("AlathraWar.nationsurrender" )|| res.isKing()) { // Has nation surrender permission war.surrenderNation(res.getNationOrNull()); - p.sendMessage(Helper.Chatlabel() + "You have surrendered the war for " + res.getNationOrNull().getName()); + p.sendMessage(Helper.chatLabel() + "You have surrendered the war for " + res.getNationOrNull().getName()); war.save(); return; } else { // Cannot surrender nation involvement - p.sendMessage(Helper.Chatlabel() + "You cannot surrender war for your nation."); + p.sendMessage(Helper.chatLabel() + "You cannot surrender war for your nation."); return; } } else if (res.hasTown()) { if (p.hasPermission("AlathraWar.townsurrender") || res.isMayor()) { // Is in indepdenent town & has surrender perms war.surrenderTown(res.getTownOrNull().getName()); - p.sendMessage(Helper.Chatlabel() + "You have surrendered the war for " + res.getTownOrNull().getName()); + p.sendMessage(Helper.chatLabel() + "You have surrendered the war for " + res.getTownOrNull().getName()); war.save(); return; } else { // No perms - p.sendMessage(Helper.Chatlabel() + "You cannot surrender war for your town."); + p.sendMessage(Helper.chatLabel() + "You cannot surrender war for your town."); return; } } @@ -283,7 +283,7 @@ public class WarCommands implements CommandExecutor { } private static void warList(Player p, String[] args) { - p.sendMessage(Helper.Chatlabel()+ "Wars:"); + p.sendMessage(Helper.chatLabel()+ "Wars:"); ArrayList wars = WarData.getWars(); if (wars.size() < 1) { p.sendMessage("There are no current wars."); @@ -296,15 +296,15 @@ public class WarCommands implements CommandExecutor { private static void warInfo(Player p, String[] args) { if (args.length < 2) { - p.sendMessage(Helper.Chatlabel() + "/war info [Player]"); + p.sendMessage(Helper.chatLabel() + "/war info [Player]"); } Resident res = TownyAPI.getInstance().getResident(args[1]); if (res == null || res.getTownOrNull() == null) { - p.sendMessage(Helper.Chatlabel() + "Invalid town resident."); + p.sendMessage(Helper.chatLabel() + "Invalid town resident."); } - p.sendMessage(Helper.Chatlabel() + p.getName() + "'s wars:"); + p.sendMessage(Helper.chatLabel() + p.getName() + "'s wars:"); for (War war : WarData.getWars()) { int side = war.getSide(args[1]); if (side != 0) { diff --git a/src/main/java/me/ShermansWorld/AlathraWar/listeners/CommandsListener.java b/src/main/java/me/ShermansWorld/AlathraWar/listeners/CommandsListener.java index c15f846..ad3e73b 100644 --- a/src/main/java/me/ShermansWorld/AlathraWar/listeners/CommandsListener.java +++ b/src/main/java/me/ShermansWorld/AlathraWar/listeners/CommandsListener.java @@ -74,7 +74,7 @@ public class CommandsListener implements Listener { //payment check for (String cmd : blacklistedXLong) { if (parse.equals(prefix + (prefix.isEmpty() ? "" : ":") + cmd)) { - p.sendMessage(String.valueOf(Helper.Chatlabel()) + Helper.color("&cYou cannot modify this property during a raid!")); + p.sendMessage(String.valueOf(Helper.chatLabel()) + Helper.color("&cYou cannot modify this property during a raid!")); event.setCancelled(true); return; } @@ -90,7 +90,7 @@ public class CommandsListener implements Listener { for (String cmd : payment) { //check for each prefix if (parse.equals(prefix + (prefix.isEmpty() ? "" : ":") + cmd)) { - p.sendMessage(String.valueOf(Helper.Chatlabel()) + Helper.color("&cYou cannot withdraw money whilst in a raid!")); + p.sendMessage(String.valueOf(Helper.chatLabel()) + Helper.color("&cYou cannot withdraw money whilst in a raid!")); event.setCancelled(true); return; } @@ -105,17 +105,17 @@ public class CommandsListener implements Listener { || parse.equals("t spawn") || parse.equals("town spawn") || parse.equals("towny:n spawn") || parse.equals("towny:nat spawn") || parse.equals("towny:nation spawn") || parse.equals("towny:t spawn") || parse.equals("towny:town spawn")) { - p.sendMessage(String.valueOf(Helper.Chatlabel()) + Helper.color("&eYou are stuck in spawn and are allowed to teleport to your town or nation.")); + p.sendMessage(String.valueOf(Helper.chatLabel()) + Helper.color("&eYou are stuck in spawn and are allowed to teleport to your town or nation.")); return; } - p.sendMessage(String.valueOf(Helper.Chatlabel()) + Helper.color("&eYou are stuck in spawn and are allowed to teleport to your town or nation.")); - p.sendMessage(String.valueOf(Helper.Chatlabel()) + Helper.color("&eUse /t spawn, or /n spawn")); + p.sendMessage(String.valueOf(Helper.chatLabel()) + Helper.color("&eYou are stuck in spawn and are allowed to teleport to your town or nation.")); + p.sendMessage(String.valueOf(Helper.chatLabel()) + Helper.color("&eUse /t spawn, or /n spawn")); event.setCancelled(true); return; } //else - p.sendMessage(String.valueOf(Helper.Chatlabel()) + Helper.color("&cYou cannot teleport whilst in a raid!")); + p.sendMessage(String.valueOf(Helper.chatLabel()) + Helper.color("&cYou cannot teleport whilst in a raid!")); event.setCancelled(true); return; } @@ -132,13 +132,13 @@ public class CommandsListener implements Listener { if (parse.equals(prefix + (prefix.isEmpty() ? "" : ":") + cmd)) { //spawn world check if (p.getWorld().getName().equals("world")) { - p.sendMessage(String.valueOf(Helper.Chatlabel()) + Helper.color("&eYou are stuck in spawn and are allowed to teleport to your town or nation.")); - p.sendMessage(String.valueOf(Helper.Chatlabel()) + Helper.color("&eUse /t spawn, or /n spawn")); + p.sendMessage(String.valueOf(Helper.chatLabel()) + Helper.color("&eYou are stuck in spawn and are allowed to teleport to your town or nation.")); + p.sendMessage(String.valueOf(Helper.chatLabel()) + Helper.color("&eUse /t spawn, or /n spawn")); event.setCancelled(true); return; } - p.sendMessage(String.valueOf(Helper.Chatlabel()) + Helper.color("&cYou cannot teleport whilst in a raid!")); + p.sendMessage(String.valueOf(Helper.chatLabel()) + Helper.color("&cYou cannot teleport whilst in a raid!")); event.setCancelled(true); return; } @@ -164,7 +164,7 @@ public class CommandsListener implements Listener { //payment check for (String cmd : blacklistedXLong) { if (parse.equals(prefix + (prefix.isEmpty() ? "" : ":") + cmd)) { - p.sendMessage(String.valueOf(Helper.Chatlabel()) + Helper.color("&cYou cannot modify this property during a siege!")); + p.sendMessage(String.valueOf(Helper.chatLabel()) + Helper.color("&cYou cannot modify this property during a siege!")); event.setCancelled(true); return; } @@ -180,7 +180,7 @@ public class CommandsListener implements Listener { for (String cmd : payment) { //check for each prefix if (parse.equals(prefix + (prefix.isEmpty() ? "" : ":") + cmd)) { - p.sendMessage(String.valueOf(Helper.Chatlabel()) + Helper.color("&cYou cannot withdraw money whilst in a siege!")); + p.sendMessage(String.valueOf(Helper.chatLabel()) + Helper.color("&cYou cannot withdraw money whilst in a siege!")); event.setCancelled(true); return; } @@ -195,17 +195,17 @@ public class CommandsListener implements Listener { || parse.equals("t spawn") || parse.equals("town spawn") || parse.equals("towny:n spawn") || parse.equals("towny:nat spawn") || parse.equals("towny:nation spawn") || parse.equals("towny:t spawn") || parse.equals("towny:town spawn")) { - p.sendMessage(String.valueOf(Helper.Chatlabel()) + Helper.color("&eYou are stuck in spawn and are allowed to teleport to your town or nation.")); + p.sendMessage(String.valueOf(Helper.chatLabel()) + Helper.color("&eYou are stuck in spawn and are allowed to teleport to your town or nation.")); return; } - p.sendMessage(String.valueOf(Helper.Chatlabel()) + Helper.color("&eYou are stuck in spawn and are allowed to teleport to your town or nation.")); - p.sendMessage(String.valueOf(Helper.Chatlabel()) + Helper.color("&eUse /t spawn, or /n spawn")); + p.sendMessage(String.valueOf(Helper.chatLabel()) + Helper.color("&eYou are stuck in spawn and are allowed to teleport to your town or nation.")); + p.sendMessage(String.valueOf(Helper.chatLabel()) + Helper.color("&eUse /t spawn, or /n spawn")); event.setCancelled(true); return; } //else - p.sendMessage(String.valueOf(Helper.Chatlabel()) + Helper.color("&cYou cannot teleport whilst in a siege!")); + p.sendMessage(String.valueOf(Helper.chatLabel()) + Helper.color("&cYou cannot teleport whilst in a siege!")); event.setCancelled(true); return; } @@ -222,13 +222,13 @@ public class CommandsListener implements Listener { if (parse.equals(prefix + (prefix.isEmpty() ? "" : ":") + cmd)) { //spawn world check if (p.getWorld().getName().equals("world")) { - p.sendMessage(String.valueOf(Helper.Chatlabel()) + Helper.color("&eYou are stuck in spawn and are allowed to teleport to your town or nation.")); - p.sendMessage(String.valueOf(Helper.Chatlabel()) + Helper.color("&eUse /t spawn, or /n spawn")); + p.sendMessage(String.valueOf(Helper.chatLabel()) + Helper.color("&eYou are stuck in spawn and are allowed to teleport to your town or nation.")); + p.sendMessage(String.valueOf(Helper.chatLabel()) + Helper.color("&eUse /t spawn, or /n spawn")); event.setCancelled(true); return; } - p.sendMessage(String.valueOf(Helper.Chatlabel()) + Helper.color("&cYou cannot teleport whilst in a siege!")); + p.sendMessage(String.valueOf(Helper.chatLabel()) + Helper.color("&cYou cannot teleport whilst in a siege!")); event.setCancelled(true); return; } diff --git a/src/main/java/me/ShermansWorld/AlathraWar/listeners/KillsListener.java b/src/main/java/me/ShermansWorld/AlathraWar/listeners/KillsListener.java index a58fbda..d0f4f59 100644 --- a/src/main/java/me/ShermansWorld/AlathraWar/listeners/KillsListener.java +++ b/src/main/java/me/ShermansWorld/AlathraWar/listeners/KillsListener.java @@ -110,7 +110,7 @@ public final class KillsListener implements Listener for (final String playerName : siege.getAttackerPlayers()) { try { Player p = Bukkit.getPlayer(playerName); - if (p != null) p.sendMessage(String.valueOf(Helper.Chatlabel()) + "Defender killed! + 20 Attacker Points"); + if (p != null) p.sendMessage(String.valueOf(Helper.chatLabel()) + "Defender killed! + 20 Attacker Points"); } catch (NullPointerException ignored) { ignored.printStackTrace(); @@ -119,7 +119,7 @@ public final class KillsListener implements Listener for (final String playerName : siege.getDefenderPlayers()) { try { Player p = Bukkit.getPlayer(playerName); - if (p != null) p.sendMessage(String.valueOf(Helper.Chatlabel()) + "Defender killed! + 20 Attacker Points"); + if (p != null) p.sendMessage(String.valueOf(Helper.chatLabel()) + "Defender killed! + 20 Attacker Points"); } catch (NullPointerException ignored) { ignored.printStackTrace(); @@ -135,7 +135,7 @@ public final class KillsListener implements Listener for (final String playerName : siege.getAttackerPlayers()) { try { Player p = Bukkit.getPlayer(playerName); - if (p != null) p.sendMessage(String.valueOf(Helper.Chatlabel()) + "Attacker killed! + 20 Defender Points"); + if (p != null) p.sendMessage(String.valueOf(Helper.chatLabel()) + "Attacker killed! + 20 Defender Points"); } catch (NullPointerException ex3) { ex3.printStackTrace(); @@ -144,7 +144,7 @@ public final class KillsListener implements Listener for (final String playerName : siege.getDefenderPlayers()) { try { Player p = Bukkit.getPlayer(playerName); - if (p != null) p.sendMessage(String.valueOf(Helper.Chatlabel()) + "Attacker killed! + 20 Defender Points"); + if (p != null) p.sendMessage(String.valueOf(Helper.chatLabel()) + "Attacker killed! + 20 Defender Points"); } catch (NullPointerException ex4) { ex4.printStackTrace(); @@ -179,7 +179,7 @@ public final class KillsListener implements Listener //do raider respawn try { event.setRespawnLocation(raid.getGatherTown().getSpawn()); - event.getPlayer().sendMessage(String.valueOf(Helper.Chatlabel()) + "You died " + (raid.getPhase().equals(RaidPhase.COMBAT) ? "raiding" : "before combat") + " and have been teleported back to the gather point."); + event.getPlayer().sendMessage(String.valueOf(Helper.chatLabel()) + "You died " + (raid.getPhase().equals(RaidPhase.COMBAT) ? "raiding" : "before combat") + " and have been teleported back to the gather point."); } catch (TownyException e) { throw new RuntimeException(e); } From 117130f67a2dbc90c4592d71df68cd8693310087 Mon Sep 17 00:00:00 2001 From: Aubri Seebauer Date: Fri, 28 Apr 2023 19:10:28 -0400 Subject: [PATCH 5/5] purgebars fixed --- .../me/ShermansWorld/AlathraWar/Raid.java | 2 -- .../me/ShermansWorld/AlathraWar/Siege.java | 2 -- .../AlathraWar/commands/AdminCommands.java | 27 +++++++------------ .../AlathraWar/data/RaidData.java | 8 ------ .../AlathraWar/data/SiegeData.java | 9 ------- 5 files changed, 10 insertions(+), 38 deletions(-) diff --git a/src/main/java/me/ShermansWorld/AlathraWar/Raid.java b/src/main/java/me/ShermansWorld/AlathraWar/Raid.java index cb77c05..e461a1f 100644 --- a/src/main/java/me/ShermansWorld/AlathraWar/Raid.java +++ b/src/main/java/me/ShermansWorld/AlathraWar/Raid.java @@ -951,7 +951,6 @@ public class Raid { } public void refreshDisplayBar() { - RaidData.addRaidBar(bossBarKey); BossBar bossBar = Bukkit.getBossBar(bossBarKey); if(bossBar == null) bossBar = createNewDisplayBar(); @@ -974,7 +973,6 @@ public class Raid { } public void setupDisplayBar() { - RaidData.addRaidBar(bossBarKey); BossBar bossBar = Bukkit.getBossBar(bossBarKey); if(bossBar == null) bossBar = createNewDisplayBar(); diff --git a/src/main/java/me/ShermansWorld/AlathraWar/Siege.java b/src/main/java/me/ShermansWorld/AlathraWar/Siege.java index af2da11..2cf9fd2 100644 --- a/src/main/java/me/ShermansWorld/AlathraWar/Siege.java +++ b/src/main/java/me/ShermansWorld/AlathraWar/Siege.java @@ -447,7 +447,6 @@ public class Siege { } public void refreshDisplayBar() { - SiegeData.addSiegeBar(bossBarKey); BossBar bossBar = Bukkit.getBossBar(bossBarKey); if(bossBar == null) bossBar = createNewDisplayBar(); @@ -470,7 +469,6 @@ public class Siege { } public void setupDisplayBar() { - SiegeData.addSiegeBar(bossBarKey); BossBar bossBar = Bukkit.getBossBar(bossBarKey); if(bossBar == null) bossBar = createNewDisplayBar(); diff --git a/src/main/java/me/ShermansWorld/AlathraWar/commands/AdminCommands.java b/src/main/java/me/ShermansWorld/AlathraWar/commands/AdminCommands.java index 433e8ef..3e92afe 100644 --- a/src/main/java/me/ShermansWorld/AlathraWar/commands/AdminCommands.java +++ b/src/main/java/me/ShermansWorld/AlathraWar/commands/AdminCommands.java @@ -16,13 +16,16 @@ import org.bukkit.Bukkit; import org.bukkit.Location; import org.bukkit.NamespacedKey; import org.bukkit.boss.BossBar; +import org.bukkit.boss.KeyedBossBar; import org.bukkit.command.Command; import org.bukkit.command.CommandExecutor; import org.bukkit.command.CommandSender; +import org.bukkit.entity.Boss; import org.bukkit.entity.Player; import java.sql.Timestamp; import java.util.ArrayList; +import java.util.Iterator; import java.util.List; import java.util.Random; @@ -143,27 +146,17 @@ public class AdminCommands implements CommandExecutor { } 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 (Iterator it = Bukkit.getBossBars(); it.hasNext(); ) { + KeyedBossBar b = it.next(); + if(b.getKey().getKey().contains(Main.getInstance().getName())) { + b.setVisible(false); + b.removeAll(); + 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("&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.")); + 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.")); return saveAll(sender, args); } diff --git a/src/main/java/me/ShermansWorld/AlathraWar/data/RaidData.java b/src/main/java/me/ShermansWorld/AlathraWar/data/RaidData.java index 64a24da..79d7cfd 100644 --- a/src/main/java/me/ShermansWorld/AlathraWar/data/RaidData.java +++ b/src/main/java/me/ShermansWorld/AlathraWar/data/RaidData.java @@ -21,15 +21,7 @@ public class RaidData { private static ArrayList raids = new ArrayList(); - private static Set raidBars = new HashSet<>(); - public static Set getRaidBars() { - return raidBars; - } - - public static void addRaidBar(NamespacedKey key) { - raidBars.add(key); - } public static ArrayList getRaids() { return raids; diff --git a/src/main/java/me/ShermansWorld/AlathraWar/data/SiegeData.java b/src/main/java/me/ShermansWorld/AlathraWar/data/SiegeData.java index 034f48e..aac95c9 100644 --- a/src/main/java/me/ShermansWorld/AlathraWar/data/SiegeData.java +++ b/src/main/java/me/ShermansWorld/AlathraWar/data/SiegeData.java @@ -23,15 +23,6 @@ public class SiegeData return sieges; } - private static Set siegeBars = new HashSet<>(); - - public static Set getSiegeBars() { - return siegeBars; - } - - public static void addSiegeBar(NamespacedKey key) { - siegeBars.add(key); - } /**