chatLabel name refactor

This commit is contained in:
Aubri Seebauer committed 2023-04-28 18:57:41 -04:00
1 parent 9d2b8612d2
commit cd61aa175c
9 files changed
+434 -434

No files matched your search

@@ -18,7 +18,7 @@ public class Helper
return ChatColor.translateAlternateColorCodes('&', input); return ChatColor.translateAlternateColorCodes('&', input);
} }
public static String Chatlabel() { public static String chatLabel() {
return color("&6[&4AlathraWar&6]&r "); return color("&6[&4AlathraWar&6]&r ");
} }
@@ -285,11 +285,11 @@ public class Raid {
//Broadcast to the whole raid //Broadcast to the whole raid
for (String s : activeRaiders) { for (String s : activeRaiders) {
Player pl = Bukkit.getPlayer(s); 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) { for (String s : defenderPlayers) {
Player pl = Bukkit.getPlayer(s); 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(); this.save();
@@ -299,11 +299,11 @@ public class Raid {
this.addLootedChunk(wc); this.addLootedChunk(wc);
for (String s : activeRaiders) { for (String s : activeRaiders) {
Player pl = Bukkit.getPlayer(s); 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) { for (String s : defenderPlayers) {
Player pl = Bukkit.getPlayer(s); 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() { private void startTravel() {
Raid.this.phase = RaidPhase.TRAVEL; 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()) + (side1AreRaiders ? Raid.this.war.getSide1() : Raid.this.war.getSide2())
+ " are coming to raid " + " are coming to raid "
+ Raid.this.getRaidedTown().getName() + "!"); + Raid.this.getRaidedTown().getName() + "!");
@@ -334,7 +334,7 @@ public class Raid {
*/ */
private void startCombat() { private void startCombat() {
Raid.this.phase = RaidPhase.COMBAT; 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()) + (side1AreRaiders ? Raid.this.war.getSide1() : Raid.this.war.getSide2())
+ " have arrived at " + " have arrived at "
+ Raid.this.getRaidedTown().getName() + " and the fighting has begun!"); + Raid.this.getRaidedTown().getName() + " and the fighting has begun!");
@@ -351,11 +351,11 @@ public class Raid {
this.addPointsToDefenderScore(40); this.addPointsToDefenderScore(40);
for (final String playerName : this.getActiveRaiders()) { for (final String playerName : this.getActiveRaiders()) {
Player pl = Bukkit.getPlayer(playerName); 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()) { for (final String playerName : this.getDefenderPlayers()) {
Player pl = Bukkit.getPlayer(playerName); 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); this.addPointsToRaiderScore(20);
for (final String playerName : this.getActiveRaiders()) { for (final String playerName : this.getActiveRaiders()) {
Player pl = Bukkit.getPlayer(playerName); 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()) { for (final String playerName : this.getDefenderPlayers()) {
Player pl = Bukkit.getPlayer(playerName); 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 // //tp to raid town spawn
@@ -389,11 +389,11 @@ public class Raid {
//award negative score //award negative score
for (final String playerName : this.getActiveRaiders()) { for (final String playerName : this.getActiveRaiders()) {
Player pl = Bukkit.getPlayer(playerName); 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()) { for (final String playerName : this.getDefenderPlayers()) {
Player pl = Bukkit.getPlayer(playerName); 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 // //tp to gather town spawn
@@ -410,7 +410,7 @@ public class Raid {
if (this.getDefenderSide().contains(killed.getKiller().getName())) { if (this.getDefenderSide().contains(killed.getKiller().getName())) {
try { try {
killed.getKiller().teleport(this.getRaidedTown().getSpawn()); 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) { } catch (TownyException e) {
throw new RuntimeException(e); throw new RuntimeException(e);
} }
@@ -424,11 +424,11 @@ public class Raid {
public void defenderKilledOutofCombat(PlayerDeathEvent event) { public void defenderKilledOutofCombat(PlayerDeathEvent event) {
for (final String playerName : this.getActiveRaiders()) { for (final String playerName : this.getActiveRaiders()) {
Player pl = Bukkit.getPlayer(playerName); 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()) { for (final String playerName : this.getDefenderPlayers()) {
Player pl = Bukkit.getPlayer(playerName); 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 //tp to raid town spawn
@@ -443,7 +443,7 @@ public class Raid {
if (this.getActiveRaiders().contains(killed.getKiller().getName())) { if (this.getActiveRaiders().contains(killed.getKiller().getName())) {
try { try {
killed.getKiller().teleport(this.getGatherTown().getSpawn()); 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) { } catch (TownyException e) {
throw new RuntimeException(e); throw new RuntimeException(e);
} }
@@ -466,7 +466,7 @@ public class Raid {
if (factor > 3.0) factor = 3.0; if (factor > 3.0) factor = 3.0;
if (factor < 0) factor = 0.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() + "!"); + " have successfully raided " + this.raidedTown.getName() + "!");
/* /*
@@ -554,25 +554,25 @@ public class Raid {
if (factor < 0) factor = 0.0; if (factor < 0) factor = 0.0;
if (factor <= 0.5) { 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."); + " 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"); + " has recovered part of the attackers' raid chest, valued at $500");
Main.warLogger Main.warLogger
.log("The defenders from " + this.defenders + " have won the raid of " + this.raidedTown.getName() + "!"); .log("The defenders from " + this.defenders + " have won the raid of " + this.raidedTown.getName() + "!");
this.raidedTown.getAccount().deposit(500, "Raid chest"); this.raidedTown.getAccount().deposit(500, "Raid chest");
} else if (factor <= 1.5) { } 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 + "!"); + " 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"); + " has recovered the attackers' raid chest, valued at $1000");
Main.warLogger Main.warLogger
.log("The defenders from " + this.defenders + " have won the raid of " + this.raidedTown.getName() + "!"); .log("The defenders from " + this.defenders + " have won the raid of " + this.raidedTown.getName() + "!");
this.raidedTown.getAccount().deposit(1000, "Raid chest"); this.raidedTown.getAccount().deposit(1000, "Raid chest");
} else if (factor <= 3.0) { } 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."); + " 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."); + " has recovered the attackers' raid chest, valued at $1000.");
Main.warLogger Main.warLogger
.log("The defenders from " + this.defenders + " have won the raid of " + this.raidedTown.getName() + "!"); .log("The defenders from " + this.defenders + " have won the raid of " + this.raidedTown.getName() + "!");
@@ -594,7 +594,7 @@ public class Raid {
public void noWinner() { public void noWinner() {
//TODO finalize payout //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."); + " didn't push back the raiders of " + this.raiders + ". Yet no loot was taken, raid considered a draw.");
Main.warLogger Main.warLogger
.log("No one won the raid of " + this.raidedTown.getName() + "!"); .log("No one won the raid of " + this.raidedTown.getName() + "!");
@@ -837,7 +837,7 @@ public class Raid {
if (Raid.this.phase == RaidPhase.GATHER) { if (Raid.this.phase == RaidPhase.GATHER) {
//Broadcast //Broadcast
if (raidTicks % 6000 == 0) { 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!"); + Raid.this.getRaidedTown().getName() + " will begin in " + (int) ((RaidPhase.TRAVEL.startTick - raidTicks) / 20 / 60) + " minutes!");
Bukkit.broadcastMessage( Bukkit.broadcastMessage(
"The Raiders are gathering at " + getGatherTown().getName() + " before making the journey over!"); "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 (!cluster.contains(WorldCoord.parseWorldCoord(p))) {
if (p.equals(owner)) { if (p.equals(owner)) {
p.teleport(gatherTown.getSpawn()); 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 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 have been teleported to the gather town's spawn.");
} else { } else {
Raid.this.removeActiveRaider(p.getName()); 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()) + "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()) + "To rejoin, do /raid join [war] [town]");
} }
} }
} }
@@ -873,7 +873,7 @@ public class Raid {
//Report //Report
if (raidTicks % 2400 == 0) { 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()) + (side1AreRaiders ? Raid.this.war.getSide1() : Raid.this.war.getSide2())
+ " are on their way to raid " + " are on their way to raid "
+ Raid.this.getRaidedTown().getName() + "!"); + Raid.this.getRaidedTown().getName() + "!");
@@ -908,7 +908,7 @@ public class Raid {
//Report //Report
if (Raid.this.raidTicks % 6000 == 0) { 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() + ":"); + Raid.this.getRaidedTown().getName() + ":");
Bukkit.broadcastMessage( Bukkit.broadcastMessage(
"Raider Score - " + Raid.this.raiderScore); "Raider Score - " + Raid.this.raiderScore);
@@ -928,7 +928,7 @@ public class Raid {
//Idk if thisll work but if it do then ye //Idk if thisll work but if it do then ye
if (Raid.this.lootedChunks.containsKey(wc)) { if (Raid.this.lootedChunks.containsKey(wc)) {
if (Raid.this.lootedChunks.get(wc).finished) { 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 { } else {
doLootAt(p, wc); doLootAt(p, wc);
} }
@@ -936,7 +936,7 @@ public class Raid {
if (Raid.this.getRaidedTown().hasTownBlock(wc)) { if (Raid.this.getRaidedTown().hasTownBlock(wc)) {
doLootAt(p, wc); doLootAt(p, wc);
} else { } 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.");
} }
} }
} }
@@ -134,14 +134,14 @@ public class Siege {
if (this.homeBlockControl != 1) { if (this.homeBlockControl != 1) {
for (final String playerName : Siege.this.attackerPlayers) { for (final String playerName : Siege.this.attackerPlayers) {
try { try {
Bukkit.getPlayer(playerName).sendMessage(String.valueOf(Helper.Chatlabel()) Bukkit.getPlayer(playerName).sendMessage(String.valueOf(Helper.chatLabel())
+ "HomeBlock at " + Siege.this.town.getName() + " contested!"); + "HomeBlock at " + Siege.this.town.getName() + " contested!");
} catch (NullPointerException ex5) { } catch (NullPointerException ex5) {
} }
} }
for (final String playerName : Siege.this.defenderPlayers) { for (final String playerName : Siege.this.defenderPlayers) {
try { try {
Bukkit.getPlayer(playerName).sendMessage(String.valueOf(Helper.Chatlabel()) Bukkit.getPlayer(playerName).sendMessage(String.valueOf(Helper.chatLabel())
+ "HomeBlock at " + Siege.this.town.getName() + " contested!"); + "HomeBlock at " + Siege.this.town.getName() + " contested!");
} catch (NullPointerException ex6) { } catch (NullPointerException ex6) {
} }
@@ -152,7 +152,7 @@ public class Siege {
if (this.homeBlockControl != 2) { if (this.homeBlockControl != 2) {
for (final String playerName : Siege.this.attackerPlayers) { for (final String playerName : Siege.this.attackerPlayers) {
try { try {
Bukkit.getPlayer(playerName).sendMessage(String.valueOf(Helper.Chatlabel()) Bukkit.getPlayer(playerName).sendMessage(String.valueOf(Helper.chatLabel())
+ "Attackers have captured the HomeBlock at " + "Attackers have captured the HomeBlock at "
+ Siege.this.town.getName() + "! +1 Attacker Points per second"); + Siege.this.town.getName() + "! +1 Attacker Points per second");
} catch (NullPointerException ex7) { } catch (NullPointerException ex7) {
@@ -160,7 +160,7 @@ public class Siege {
} }
for (final String playerName : Siege.this.defenderPlayers) { for (final String playerName : Siege.this.defenderPlayers) {
try { try {
Bukkit.getPlayer(playerName).sendMessage(String.valueOf(Helper.Chatlabel()) Bukkit.getPlayer(playerName).sendMessage(String.valueOf(Helper.chatLabel())
+ "Attackers have captured the HomeBlock at " + "Attackers have captured the HomeBlock at "
+ Siege.this.town.getName() + "! +1 Attacker Points per second"); + Siege.this.town.getName() + "! +1 Attacker Points per second");
} catch (NullPointerException ex8) { } catch (NullPointerException ex8) {
@@ -173,7 +173,7 @@ public class Siege {
if (this.homeBlockControl != 3) { if (this.homeBlockControl != 3) {
for (final String playerName : Siege.this.attackerPlayers) { for (final String playerName : Siege.this.attackerPlayers) {
try { try {
Bukkit.getPlayer(playerName).sendMessage(String.valueOf(Helper.Chatlabel()) Bukkit.getPlayer(playerName).sendMessage(String.valueOf(Helper.chatLabel())
+ "Defenders retain control of the HomeBlock at " + "Defenders retain control of the HomeBlock at "
+ Siege.this.town.getName() + "! +1 Defender Points per second"); + Siege.this.town.getName() + "! +1 Defender Points per second");
} catch (NullPointerException ex9) { } catch (NullPointerException ex9) {
@@ -181,7 +181,7 @@ public class Siege {
} }
for (final String playerName : Siege.this.defenderPlayers) { for (final String playerName : Siege.this.defenderPlayers) {
try { try {
Bukkit.getPlayer(playerName).sendMessage(String.valueOf(Helper.Chatlabel()) Bukkit.getPlayer(playerName).sendMessage(String.valueOf(Helper.chatLabel())
+ "Defenders retain control of the HomeBlock at " + "Defenders retain control of the HomeBlock at "
+ Siege.this.town.getName() + "! +1 Defender Points per second"); + Siege.this.town.getName() + "! +1 Defender Points per second");
} catch (NullPointerException ex10) { } catch (NullPointerException ex10) {
@@ -192,7 +192,7 @@ public class Siege {
this.homeBlockControl = 3; this.homeBlockControl = 3;
} }
if (Siege.this.siegeTicks % 6000 == 0) { // Updates every 5 minutes 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() + ":"); + Siege.this.town.getName() + ":");
Bukkit.broadcastMessage( Bukkit.broadcastMessage(
"Attacker Points - " + String.valueOf(Siege.this.attackerPoints)); "Attacker Points - " + String.valueOf(Siege.this.attackerPoints));
@@ -232,12 +232,12 @@ public class Siege {
public void attackersWin(final OfflinePlayer siegeLeader) { public void attackersWin(final OfflinePlayer siegeLeader) {
final Resident resident = TownyAPI.getInstance().getResident(siegeLeader.getUniqueId()); final Resident resident = TownyAPI.getInstance().getResident(siegeLeader.getUniqueId());
Nation nation = null; 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 { try {
nation = resident.getTown().getNation(); nation = resident.getTown().getNation();
} catch (Exception e) {} } catch (Exception e) {}
if (nation != null) { 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() + "!"); + " has been placed under occupation by " + nation.getName() + "!");
} }
Main.econ.depositPlayer(siegeLeader, 2500.0); Main.econ.depositPlayer(siegeLeader, 2500.0);
@@ -248,7 +248,7 @@ public class Siege {
} else { } else {
if (this.town.getAccount().getHoldingBalance() < 2500.0) { if (this.town.getAccount().getHoldingBalance() < 2500.0) {
amt = this.town.getAccount().getHoldingBalance(); 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() + "!"); + " has been destroyed by " + this.getAttackerSide() + "!");
TownyUniverse.getInstance().getDataSource().deleteTown(this.town); TownyUniverse.getInstance().getDataSource().deleteTown(this.town);
Main.econ.depositPlayer(siegeLeader, amt); Main.econ.depositPlayer(siegeLeader, amt);
@@ -275,8 +275,8 @@ public class Siege {
public void defendersWin() { public void defendersWin() {
this.town.getAccount().deposit(2500.0, "War chest"); 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()) + "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()) + this.town.getName()
+ " has recovered the attackers' war chest, valued at $2,500"); + " has recovered the attackers' war chest, valued at $2,500");
Main.warLogger Main.warLogger
.log(war.getName() + ": The defenders have won the siege of " + this.town.getName() + "!"); .log(war.getName() + ": The defenders have won the siege of " + this.town.getName() + "!");
@@ -295,8 +295,8 @@ public class Siege {
* No winnder declared * No winnder declared
*/ */
public void noWinner() { public void noWinner() {
Bukkit.broadcastMessage(String.valueOf(Helper.Chatlabel()) + "The siege of " + this.town.getName() + " was a draw!"); 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()) + "No money has been recovered.");
Main.warLogger Main.warLogger
.log(war.getName() + ": No one won the siege of " + this.town.getName() + "!"); .log(war.getName() + ": No one won the siege of " + this.town.getName() + "!");
stop(); stop();
File diff suppressed because it is too large. Load diff
@@ -92,7 +92,7 @@ public class RaidCommands implements CommandExecutor {
} else if (war.getSide2Players().contains(raidOwner.getName())) { } else if (war.getSide2Players().contains(raidOwner.getName())) {
side = war.getSide2(); side = war.getSide2();
} else { } 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; return;
} }
@@ -129,21 +129,21 @@ public class RaidCommands implements CommandExecutor {
} else if(TownyAPI.getInstance().getTown(args[4]) != null) { } else if(TownyAPI.getInstance().getTown(args[4]) != null) {
gatherTown = TownyAPI.getInstance().getTown(args[4]); gatherTown = TownyAPI.getInstance().getTown(args[4]);
} else { } else {
if (admin) p.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"); 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()); gatherTown = TownyAPI.getInstance().getTownOrNull(WorldCoord.parseWorldCoord(raidOwner.getLocation()).getTownBlock());
} }
} else { } else {
gatherTown = TownyAPI.getInstance().getTownOrNull(WorldCoord.parseWorldCoord(raidOwner.getLocation()).getTownBlock()); gatherTown = TownyAPI.getInstance().getTownOrNull(WorldCoord.parseWorldCoord(raidOwner.getLocation()).getTownBlock());
} }
} catch (NotRegisteredException e2) { } 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."); 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."); 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; return;
} }
if (gatherTown == null) { 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."); 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."); 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; return;
} }
@@ -157,20 +157,20 @@ public class RaidCommands implements CommandExecutor {
//check if the town were attempting to raid is in the war //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.getSide1Towns().contains(raidedTown.getName()) && !war.getSide2Towns().contains(raidedTown.getName())) {
if (war.getSurrenderedTowns().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!"); 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!"); raidOwner.sendMessage(String.valueOf(Helper.chatLabel()) + "The town you are trying to raid has already surrendered!");
return; return;
} }
if (admin) p.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!"); raidOwner.sendMessage(String.valueOf(Helper.chatLabel()) + "The town you are trying to raid is not part of the war!");
return; return;
} }
// Is being sieged check // Is being sieged check
for (Siege s : SiegeData.getSieges()) { for (Siege s : SiegeData.getSieges()) {
if(s.getTown().getName().equals(raidedTown.getName())) { 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!"); 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!"); 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 //if were admin, see if an owner arg exists, and if so then use it
raid2 = new Raid(war, raidedTown, gatherTown, true, raidOwner); raid2 = new Raid(war, raidedTown, gatherTown, true, raidOwner);
} else if (c == 1) { } else if (c == 1) {
if (admin) p.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!"); raidOwner.sendMessage(String.valueOf(Helper.chatLabel()) + "This town is already being raided at this time!");
return; return;
} else if (c == 0) { } else if (c == 0) {
if (admin) p.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!"); raidOwner.sendMessage(String.valueOf(Helper.chatLabel()) + "Your side has raided too recently!");
return; return;
} else if (c == -1) { } else if (c == -1) {
if (admin) p.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!"); raidOwner.sendMessage(String.valueOf(Helper.chatLabel()) + "This town was raided too recently!");
return; return;
} else if (c == -2) { } 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!"); 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!"); raidOwner.sendMessage(String.valueOf(Helper.chatLabel()) + "At least on member of the raided town must be online to defend it!");
return; return;
} else { } else {
throw new IllegalArgumentException(); throw new IllegalArgumentException();
@@ -213,20 +213,20 @@ public class RaidCommands implements CommandExecutor {
if (c == 2) { if (c == 2) {
raid2 = new Raid(war, raidedTown, gatherTown, false, raidOwner); raid2 = new Raid(war, raidedTown, gatherTown, false, raidOwner);
} else if (c == 1) { } else if (c == 1) {
if (admin) p.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!"); raidOwner.sendMessage(String.valueOf(Helper.chatLabel()) + "This town is already being raided at this time!");
return; return;
} else if (c == 0) { } else if (c == 0) {
if (admin) p.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!"); raidOwner.sendMessage(String.valueOf(Helper.chatLabel()) + "Your side has raided too recently!");
return; return;
} else if (c == -1) { } else if (c == -1) {
if (admin) p.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!"); raidOwner.sendMessage(String.valueOf(Helper.chatLabel()) + "This town was raided too recently!");
return; return;
} else if (c == -2) { } 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!"); 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!"); raidOwner.sendMessage(String.valueOf(Helper.chatLabel()) + "At least on member of the raided town must be online to defend it!");
return; return;
} else { } else {
throw new IllegalArgumentException(); throw new IllegalArgumentException();
@@ -237,27 +237,27 @@ public class RaidCommands implements CommandExecutor {
Town leaderTown = TownyAPI.getInstance().getResident(raidOwner).getTownOrNull(); Town leaderTown = TownyAPI.getInstance().getResident(raidOwner).getTownOrNull();
int sideR = war.getSide(leaderTown.getName()); int sideR = war.getSide(leaderTown.getName());
if (sideR == 0) { if (sideR == 0) {
if (admin) p.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."); raidOwner.sendMessage(Helper.chatLabel() + "You are not in this war.");
return; return;
} else if (sideR == -1) { } else if (sideR == -1) {
if (admin) p.sendMessage(Helper.Chatlabel() + "You have surrendered."); if (admin) p.sendMessage(Helper.chatLabel() + "You have surrendered.");
raidOwner.sendMessage(Helper.Chatlabel() + "You have surrendered."); raidOwner.sendMessage(Helper.chatLabel() + "You have surrendered.");
return; return;
} }
// Attacking own side // Attacking own side
if (war.getSide(raidedTown) == sideR) { if (war.getSide(raidedTown) == sideR) {
if (admin) p.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."); raidOwner.sendMessage(Helper.chatLabel() + "You cannot attack your own towns.");
return; return;
} }
//check player balance //check player balance
final OfflinePlayer offlinePlayer = Bukkit.getOfflinePlayer(raidOwner.getUniqueId()); final OfflinePlayer offlinePlayer = Bukkit.getOfflinePlayer(raidOwner.getUniqueId());
if (Main.econ.getBalance(offlinePlayer) <= 1000.0) { 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."); 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."); raidOwner.sendMessage(String.valueOf(Helper.chatLabel()) + "You must have at least $1000 to put up to start a raid.");
return; return;
} }
@@ -269,11 +269,11 @@ public class RaidCommands implements CommandExecutor {
WarData.saveWar(raid2.getWar()); WarData.saveWar(raid2.getWar());
//broadcast //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()) + "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(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(Helper.chatLabel() + "The raid of "
+ raidedTown.getName() + " will begin in " + (int) (RaidPhase.TRAVEL.startTick / 20 / 60) + " minutes!"); + 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!"); "The Raiders are gathering at " + gatherTown.getName() + " before making the journey over!");
Main.warLogger.log(raidOwner.getName() + " started a raid."); Main.warLogger.log(raidOwner.getName() + " started a raid.");
@@ -285,11 +285,11 @@ public class RaidCommands implements CommandExecutor {
} }
} }
if (!warFound) { 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; return;
} }
if (!townExists) { 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]); Raid raid = RaidData.getRaidOrNull(args[1] + "-" + args[2]);
if (raid != null) { if (raid != null) {
p.sendMessage(String.valueOf(Helper.Chatlabel()) + "raid cancelled"); 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"); 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 raid.stop(); //this purges itself from raids
} else { } else {
fail(p, args, "badName"); fail(p, args, "badName");
@@ -342,31 +342,31 @@ public class RaidCommands implements CommandExecutor {
if (args[4].equals(raid.getDefenderSide())) { if (args[4].equals(raid.getDefenderSide())) {
if (!raid.getDefenderPlayers().contains(joiner.getName())) if (!raid.getDefenderPlayers().contains(joiner.getName()))
raid.getDefenderPlayers().add(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."); 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; return;
} else { } else {
if (!raid.getRaiderPlayers().contains(joiner.getName())) if (!raid.getRaiderPlayers().contains(joiner.getName()))
raid.getRaiderPlayers().add(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."); 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 { } else {
p.sendMessage(String.valueOf(Helper.Chatlabel()) + "Player " + args[3] + " not found!"); p.sendMessage(String.valueOf(Helper.chatLabel()) + "Player " + args[3] + " not found!");
return; return;
} }
} }
if(joiner == null) { 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; return;
} }
if (!raid.getWar().getSide1Players().contains(joiner.getName()) && !raid.getWar().getSide2Players().contains(joiner.getName())) { 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 //Minutemen countermeasures, 86400 * 4 time. 86400 seconds in a day, 4 days min playtime
@@ -405,16 +405,16 @@ public class RaidCommands implements CommandExecutor {
ArrayList<WorldCoord> cluster = Helper.getCluster(raid.getGatherTown().getHomeBlock().getWorldCoord()); ArrayList<WorldCoord> cluster = Helper.getCluster(raid.getGatherTown().getHomeBlock().getWorldCoord());
if (cluster.contains(WorldCoord.parseWorldCoord(joiner))) { if (cluster.contains(WorldCoord.parseWorldCoord(joiner))) {
raid.addActiveRaider(joiner.getName()); 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()) + "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()) + "Leaving " + raid.getGatherTown().getName() + " will cause you to leave the raid party.");
} else { } 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) { } catch (TownyException e) {
throw new RuntimeException(e); throw new RuntimeException(e);
} }
} else { } 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 { } else {
try { try {
@@ -422,10 +422,10 @@ public class RaidCommands implements CommandExecutor {
ArrayList<WorldCoord> cluster = Helper.getCluster(raid.getGatherTown().getHomeBlock().getWorldCoord()); ArrayList<WorldCoord> cluster = Helper.getCluster(raid.getGatherTown().getHomeBlock().getWorldCoord());
if (cluster.contains(WorldCoord.parseWorldCoord(joiner))) { if (cluster.contains(WorldCoord.parseWorldCoord(joiner))) {
raid.addActiveRaider(joiner.getName()); 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()) + "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()) + "Leaving " + raid.getGatherTown().getName() + " will cause you to leave the raid party.");
} else { } 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) { } catch (TownyException e) {
throw new RuntimeException(e); throw new RuntimeException(e);
@@ -435,7 +435,7 @@ public class RaidCommands implements CommandExecutor {
raid.save(); raid.save();
} }
} else { } 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) { if (admin) {
p = Bukkit.getPlayer(args[3]); p = Bukkit.getPlayer(args[3]);
if (p == null) { if (p == null) {
player.sendMessage(String.valueOf(Helper.Chatlabel()) + "Error: player not found!"); player.sendMessage(String.valueOf(Helper.chatLabel()) + "Error: player not found!");
return; return;
} }
} }
@@ -457,8 +457,8 @@ public class RaidCommands implements CommandExecutor {
if (raid != null) { if (raid != null) {
if (raid.getWar().getName().equalsIgnoreCase(args[1])) { if (raid.getWar().getName().equalsIgnoreCase(args[1])) {
if (!raid.getWar().getSide1Players().contains(p.getName()) && !raid.getWar().getSide2Players().contains(p.getName())) { 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]");
if (admin) player.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 //check if gather phase
@@ -468,12 +468,12 @@ public class RaidCommands implements CommandExecutor {
ArrayList<WorldCoord> cluster = Helper.getCluster(raid.getGatherTown().getHomeBlock().getWorldCoord()); ArrayList<WorldCoord> cluster = Helper.getCluster(raid.getGatherTown().getHomeBlock().getWorldCoord());
if (cluster.contains(WorldCoord.parseWorldCoord(p))) { if (cluster.contains(WorldCoord.parseWorldCoord(p))) {
raid.removeActiveRaider(p.getName()); raid.removeActiveRaider(p.getName());
p.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() + "!"); if (admin) player.sendMessage(String.valueOf(Helper.chatLabel()) + "You have left the raid on " + raid.getRaidedTown().getName() + "!");
} else { } else {
p.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!"); if (admin) player.sendMessage(String.valueOf(Helper.chatLabel()) + "You cannot leave the raid on " + raid.getRaidedTown().getName() + "! It has already started!");
} }
} catch (TownyException e) { } catch (TownyException e) {
throw new RuntimeException(e); throw new RuntimeException(e);
@@ -483,8 +483,8 @@ public class RaidCommands implements CommandExecutor {
raid.save(); raid.save();
} else { } 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!");
if (admin) player.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 != null) {
if (raid.getWar().getName().equalsIgnoreCase(args[1])) { if (raid.getWar().getName().equalsIgnoreCase(args[1])) {
if (!raid.getWar().getSide1Players().contains(p.getName()) && !raid.getWar().getSide2Players().contains(p.getName())) { 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; return;
} }
@@ -508,11 +508,11 @@ public class RaidCommands implements CommandExecutor {
//check if gather phase //check if gather phase
if (raid.getPhase() == RaidPhase.GATHER || raid.getPhase() == RaidPhase.START || raid.getPhase() == RaidPhase.TRAVEL || raid.getPhase() == RaidPhase.COMBAT) { if (raid.getPhase() == RaidPhase.GATHER || raid.getPhase() == RaidPhase.START || raid.getPhase() == RaidPhase.TRAVEL || raid.getPhase() == RaidPhase.COMBAT) {
//force defender victory //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()); Main.warLogger.log(p.getName() + " abandoned the raid on " + raid.getRaidedTown().getName() + " they started at " + raid.getGatherTown().getName());
raid.defendersWin(raid.getRaiderScore(), raid.getDefenderScore()); raid.defendersWin(raid.getRaiderScore(), raid.getDefenderScore());
} else { } 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 { } else {
fail(p, args, "owner"); 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) { private static void listRaids(CommandSender p, String[] args) {
if (RaidData.getRaids().isEmpty()) { 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; 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()) { for (final Raid raid : RaidData.getRaids()) {
p.sendMessage("Name: " + raid.getName()); p.sendMessage("Name: " + raid.getName());
p.sendMessage("War: " + raid.getWar().getName()); p.sendMessage("War: " + raid.getWar().getName());
@@ -547,23 +547,23 @@ public class RaidCommands implements CommandExecutor {
private static void raidHelp(CommandSender p, String[] args) { private static void raidHelp(CommandSender p, String[] args) {
if (p.hasPermission("!AlathraWar.admin")) { 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 start [war] [town]");
p.sendMessage(Helper.Chatlabel() + "/raid join [war] [town]"); p.sendMessage(Helper.chatLabel() + "/raid join [war] [town]");
p.sendMessage(Helper.Chatlabel() + "/raid leave [war] [town]"); p.sendMessage(Helper.chatLabel() + "/raid leave [war] [town]");
p.sendMessage(Helper.Chatlabel() + "/raid abandon [war] [town]"); p.sendMessage(Helper.chatLabel() + "/raid abandon [war] [town]");
p.sendMessage(Helper.Chatlabel() + "/raid list"); p.sendMessage(Helper.chatLabel() + "/raid list");
} }
private static void fail(CommandSender p, String[] args, String type) { private static void fail(CommandSender p, String[] args, String type) {
switch (type) { switch (type) {
case "permissions" -> p.sendMessage(String.valueOf(Helper.Chatlabel()) + "&cYou do not have permission to do this"); 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 "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 "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 "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."); 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"); default -> p.sendMessage(String.valueOf(Helper.chatLabel()) + "Invalid Arguments. /raid help");
} }
} }
} }
@@ -24,7 +24,7 @@ public class SiegeCommands implements CommandExecutor {
public boolean onCommand(final CommandSender sender, final Command cmd, final String label, final String[] args) { public boolean onCommand(final CommandSender sender, final Command cmd, final String label, final String[] args) {
if (args.length == 0) { 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; return true;
} }
@@ -76,15 +76,15 @@ public class SiegeCommands implements CommandExecutor {
} }
if (args.length < 3) { if (args.length < 3) {
sender.sendMessage(Helper.Chatlabel() + "/war siege [war] [town]"); sender.sendMessage(Helper.chatLabel() + "/war siege [war] [town]");
return; return;
} }
// War check // War check
War war = WarData.getWar(args[1]); War war = WarData.getWar(args[1]);
if (war == null) { if (war == null) {
siegeOwner.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]"); if(admin) sender.sendMessage(String.valueOf(Helper.chatLabel()) + "That war does not exist! /siege start [war] [town]");
return; return;
} }
@@ -92,12 +92,12 @@ public class SiegeCommands implements CommandExecutor {
Town leaderTown = TownyAPI.getInstance().getResident(siegeOwner).getTownOrNull(); Town leaderTown = TownyAPI.getInstance().getResident(siegeOwner).getTownOrNull();
int side = war.getSide(leaderTown.getName()); int side = war.getSide(leaderTown.getName());
if (side == 0) { if (side == 0) {
siegeOwner.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."); if(admin) sender.sendMessage(Helper.chatLabel() + "You are not in this war.");
return; return;
} else if (side == -1) { } else if (side == -1) {
siegeOwner.sendMessage(Helper.Chatlabel() + "You have surrendered."); siegeOwner.sendMessage(Helper.chatLabel() + "You have surrendered.");
if(admin) sender.sendMessage(Helper.Chatlabel() + "You have surrendered."); if(admin) sender.sendMessage(Helper.chatLabel() + "You have surrendered.");
return; return;
} }
@@ -132,24 +132,24 @@ public class SiegeCommands implements CommandExecutor {
// Town check // Town check
Town town = TownyAPI.getInstance().getTown(args[2]); Town town = TownyAPI.getInstance().getTown(args[2]);
if (town == null) { if (town == null) {
siegeOwner.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]"); if(admin) sender.sendMessage(String.valueOf(Helper.chatLabel()) + "That town does not exist! /siege start [war] [town]");
return; return;
} }
// Is being raided check // Is being raided check
for ( Raid r : RaidData.getRaids()) { for ( Raid r : RaidData.getRaids()) {
if(r.getRaidedTown().getName().equals(town.getName())) { 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!"); 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!"); if(admin) sender.sendMessage(String.valueOf(Helper.chatLabel()) + "That town is already currently being raided! Cannot siege at this time!");
return; return;
} }
} }
// Attacking own side // Attacking own side
if (war.getSide(town) == side) { if (war.getSide(town) == side) {
siegeOwner.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."); if(admin) sender.sendMessage(Helper.chatLabel() + "You cannot attack your own towns.");
return; return;
} }
@@ -157,7 +157,7 @@ public class SiegeCommands implements CommandExecutor {
SiegeData.addSiege(siege); SiegeData.addSiege(siege);
war.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(); war.save();
siege.start(); siege.start();
@@ -165,37 +165,37 @@ public class SiegeCommands implements CommandExecutor {
private static void siegeStop(CommandSender sender, String[] args) { private static void siegeStop(CommandSender sender, String[] args) {
if (!sender.hasPermission("AlathraWar.admin")) { 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; return;
} }
HashSet<Siege> sieges = SiegeData.getSieges(); HashSet<Siege> sieges = SiegeData.getSieges();
if (sieges.isEmpty()) { 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; return;
} }
if (args.length < 3) { if (args.length < 3) {
sender.sendMessage(Helper.Chatlabel() + "/siege stop [town]"); sender.sendMessage(Helper.chatLabel() + "/siege stop [town]");
return; return;
} }
// War check // War check
War war = WarData.getWar(args[1]); War war = WarData.getWar(args[1]);
if (war == null) { 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; return;
} }
for (Siege siege : sieges) { for (Siege siege : sieges) {
if (siege.getTown().getName().equalsIgnoreCase(args[2])) { if (siege.getTown().getName().equalsIgnoreCase(args[2])) {
sender.sendMessage(String.valueOf(Helper.Chatlabel()) + "siege cancelled"); 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"); Bukkit.broadcastMessage(String.valueOf(Helper.chatLabel()) + "The siege at " + siege.getTown().getName() + " has been cancelled by an admin");
//siege.clearBeacon(); //siege.clearBeacon();
siege.stop(); siege.stop();
return; 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) { private static void siegeAbandon(CommandSender sender, String[] args) {
@@ -203,30 +203,30 @@ public class SiegeCommands implements CommandExecutor {
final Player p = (Player) sender; final Player p = (Player) sender;
if (args.length < 3) { if (args.length < 3) {
sender.sendMessage(Helper.Chatlabel() + "/siege abandon [town]"); sender.sendMessage(Helper.chatLabel() + "/siege abandon [town]");
return; return;
} }
// War check // War check
War war = WarData.getWar(args[1]); War war = WarData.getWar(args[1]);
if (war == null) { 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; return;
} }
Siege siege = SiegeData.getSiege(args[2]); Siege siege = SiegeData.getSiege(args[2]);
if (siege == null) { if (siege == null) {
p.sendMessage(Helper.Chatlabel() + "Invalid siege"); p.sendMessage(Helper.chatLabel() + "Invalid siege");
return; return;
} }
OfflinePlayer oPlayer = siege.getSiegeLeader(); OfflinePlayer oPlayer = siege.getSiegeLeader();
if (oPlayer != (OfflinePlayer) p) { 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; 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()); Main.warLogger.log(p.getName() + " abandoned the siege they started at " + siege.getTown().getName());
siege.defendersWin(); siege.defendersWin();
@@ -235,11 +235,11 @@ public class SiegeCommands implements CommandExecutor {
private static void siegeList(CommandSender sender, String[] args) { private static void siegeList(CommandSender sender, String[] args) {
HashSet<Siege> sieges = SiegeData.getSieges(); HashSet<Siege> sieges = SiegeData.getSieges();
if (sieges.isEmpty()) { 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; 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) { for (Siege siege : sieges) {
War war = siege.getWar(); War war = siege.getWar();
String color = (siege.getSide1AreAttackers() && (war.getSide(siege.getTown().getName()) == 1) ) ? "§c" : "§9"; 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) { private static void siegeHelp(CommandSender sender, String[] args) {
if (sender.hasPermission("AlathraWar.admin")) { 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 start [war] [town]");
sender.sendMessage(Helper.Chatlabel() + "/siege abandon [town]"); sender.sendMessage(Helper.chatLabel() + "/siege abandon [town]");
sender.sendMessage(Helper.Chatlabel() + "/siege list"); sender.sendMessage(Helper.chatLabel() + "/siege list");
} }
} }
@@ -32,7 +32,7 @@ public class WarCommands implements CommandExecutor {
final Player p = (Player) sender; final Player p = (Player) sender;
if (args.length == 0) { 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; return true;
} else if (args.length >= 1) { } else if (args.length >= 1) {
@@ -59,7 +59,7 @@ public class WarCommands implements CommandExecutor {
warHelp(p, args); warHelp(p, args);
return true; return true;
default: default:
p.sendMessage(String.valueOf(Helper.Chatlabel()) + "Invalid Arguments. /war help"); p.sendMessage(String.valueOf(Helper.chatLabel()) + "Invalid Arguments. /war help");
return true; return true;
} }
@@ -77,13 +77,13 @@ public class WarCommands implements CommandExecutor {
WarData.addWar(war); WarData.addWar(war);
war.save(); 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]); + args[2] + " vs. " + args[3]);
Main.warLogger.log(p.getName() + " created a new war with the name " + args[1] + ", " + args[2] Main.warLogger.log(p.getName() + " created a new war with the name " + args[1] + ", " + args[2]
+ " vs. " + args[3]); + " vs. " + args[3]);
return; return;
} else { } else {
p.sendMessage(String.valueOf(Helper.Chatlabel()) p.sendMessage(String.valueOf(Helper.chatLabel())
+ "Invalid Arguments. /war create [name] [side1] [side2]"); + "Invalid Arguments. /war create [name] [side1] [side2]");
} }
@@ -100,18 +100,18 @@ public class WarCommands implements CommandExecutor {
// War Check // War Check
if (war == null) { if (war == null) {
p.sendMessage(Helper.Chatlabel() p.sendMessage(Helper.chatLabel()
+ "War not found. Type /war list to view current wars."); + "War not found. Type /war list to view current wars.");
return; return;
} }
WarData.removeWar(war); 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]); Main.warLogger.log(p.getName() + " deleted " + args[1]);
return; return;
} else { } else {
p.sendMessage(String.valueOf(Helper.Chatlabel()) p.sendMessage(String.valueOf(Helper.chatLabel())
+ "Invalid Arguments. /war delete [name]"); + "Invalid Arguments. /war delete [name]");
} }
} }
@@ -125,7 +125,7 @@ public class WarCommands implements CommandExecutor {
protected static void warJoin(CommandSender p, String[] args, boolean admin) { protected static void warJoin(CommandSender p, String[] args, boolean admin) {
// Sufficient args check // Sufficient args check
if (args.length < 3) { if (args.length < 3) {
p.sendMessage(Helper.Chatlabel() p.sendMessage(Helper.chatLabel()
+ "/war join [name] [side], type /war list to view current wars"); + "/war join [name] [side], type /war list to view current wars");
return; return;
} }
@@ -133,7 +133,7 @@ public class WarCommands implements CommandExecutor {
// War check // War check
War war = WarData.getWar(args[1]); War war = WarData.getWar(args[1]);
if (war == null) { 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"); + "War not found. /war join [name] [side], type /war list to view current wars");
return; return;
} }
@@ -142,7 +142,7 @@ public class WarCommands implements CommandExecutor {
if (admin){ if (admin){
player = Bukkit.getPlayer(args[3]); player = Bukkit.getPlayer(args[3]);
if(player == null) { if(player == null) {
p.sendMessage(Helper.Chatlabel() + "Player " + args[3] + " not found!"); p.sendMessage(Helper.chatLabel() + "Player " + args[3] + " not found!");
return; return;
} }
} }
@@ -192,10 +192,10 @@ public class WarCommands implements CommandExecutor {
// Side checks // Side checks
int side = war.getSide(town.getName().toLowerCase()); int side = war.getSide(town.getName().toLowerCase());
if (side == -1) { if (side == -1) {
p.sendMessage(Helper.Chatlabel() + "You've already surrendered!"); p.sendMessage(Helper.chatLabel() + "You've already surrendered!");
return; return;
} else if (side > 0) { } 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; return;
} }
@@ -203,26 +203,26 @@ public class WarCommands implements CommandExecutor {
if(res.getPlayer().hasPermission("AlathraWar.nationjoin" )|| res.isKing()) { if(res.getPlayer().hasPermission("AlathraWar.nationjoin" )|| res.isKing()) {
// Has nation declaration permission // Has nation declaration permission
war.addNation(res.getNationOrNull(), args[2]); war.addNation(res.getNationOrNull(), args[2]);
res.getPlayer().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()); p.sendMessage(Helper.chatLabel() + "You have joined the war for " + res.getNationOrNull().getName());
war.save(); war.save();
return; return;
} else { } else {
// Cannot declare nation involvement // 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; return;
} }
} else if (res.hasTown()) { } else if (res.hasTown()) {
if (res.getPlayer().hasPermission("AlathraWar.townjoin") || res.isMayor()) { if (res.getPlayer().hasPermission("AlathraWar.townjoin") || res.isMayor()) {
// Is in indepdenent town & has declaration perms // Is in indepdenent town & has declaration perms
war.addTown(res.getTownOrNull(), args[2]); war.addTown(res.getTownOrNull(), args[2]);
res.getPlayer().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()); p.sendMessage(Helper.chatLabel() + "You have joined the war for " + res.getTownOrNull().getName());
war.save(); war.save();
return; return;
} else { } else {
// No perms // 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; return;
} }
} }
@@ -231,7 +231,7 @@ public class WarCommands implements CommandExecutor {
protected static void warSurrender(Player p, String[] args, boolean admin) { protected static void warSurrender(Player p, String[] args, boolean admin) {
// Sufficient args check // Sufficient args check
if (args.length < 2) { if (args.length < 2) {
p.sendMessage(Helper.Chatlabel() p.sendMessage(Helper.chatLabel()
+ "/war surrender [name], type /war list to view current wars"); + "/war surrender [name], type /war list to view current wars");
return; return;
} }
@@ -239,7 +239,7 @@ public class WarCommands implements CommandExecutor {
// War check // War check
War war = WarData.getWar(args[1]); War war = WarData.getWar(args[1]);
if (war == null) { if (war == null) {
p.sendMessage(Helper.Chatlabel() p.sendMessage(Helper.chatLabel()
+ "War not found. Type /war list to view current wars"); + "War not found. Type /war list to view current wars");
return; return;
} }
@@ -258,24 +258,24 @@ public class WarCommands implements CommandExecutor {
if(p.hasPermission("AlathraWar.nationsurrender" )|| res.isKing()) { if(p.hasPermission("AlathraWar.nationsurrender" )|| res.isKing()) {
// Has nation surrender permission // Has nation surrender permission
war.surrenderNation(res.getNationOrNull()); 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(); war.save();
return; return;
} else { } else {
// Cannot surrender nation involvement // 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; return;
} }
} else if (res.hasTown()) { } else if (res.hasTown()) {
if (p.hasPermission("AlathraWar.townsurrender") || res.isMayor()) { if (p.hasPermission("AlathraWar.townsurrender") || res.isMayor()) {
// Is in indepdenent town & has surrender perms // Is in indepdenent town & has surrender perms
war.surrenderTown(res.getTownOrNull().getName()); 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(); war.save();
return; return;
} else { } else {
// No perms // 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; return;
} }
} }
@@ -283,7 +283,7 @@ public class WarCommands implements CommandExecutor {
} }
private static void warList(Player p, String[] args) { private static void warList(Player p, String[] args) {
p.sendMessage(Helper.Chatlabel()+ "Wars:"); p.sendMessage(Helper.chatLabel()+ "Wars:");
ArrayList<War> wars = WarData.getWars(); ArrayList<War> wars = WarData.getWars();
if (wars.size() < 1) { if (wars.size() < 1) {
p.sendMessage("There are no current wars."); p.sendMessage("There are no current wars.");
@@ -296,15 +296,15 @@ public class WarCommands implements CommandExecutor {
private static void warInfo(Player p, String[] args) { private static void warInfo(Player p, String[] args) {
if (args.length < 2) { 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]); Resident res = TownyAPI.getInstance().getResident(args[1]);
if (res == null || res.getTownOrNull() == null) { 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()) { for (War war : WarData.getWars()) {
int side = war.getSide(args[1]); int side = war.getSide(args[1]);
if (side != 0) { if (side != 0) {
@@ -74,7 +74,7 @@ public class CommandsListener implements Listener {
//payment check //payment check
for (String cmd : blacklistedXLong) { for (String cmd : blacklistedXLong) {
if (parse.equals(prefix + (prefix.isEmpty() ? "" : ":") + cmd)) { 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); event.setCancelled(true);
return; return;
} }
@@ -90,7 +90,7 @@ public class CommandsListener implements Listener {
for (String cmd : payment) { for (String cmd : payment) {
//check for each prefix //check for each prefix
if (parse.equals(prefix + (prefix.isEmpty() ? "" : ":") + cmd)) { 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); event.setCancelled(true);
return; return;
} }
@@ -105,17 +105,17 @@ public class CommandsListener implements Listener {
|| parse.equals("t spawn") || parse.equals("town spawn") || 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:n spawn") || parse.equals("towny:nat spawn") || parse.equals("towny:nation spawn")
|| parse.equals("towny:t spawn") || parse.equals("towny:town 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; 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("&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("&eUse /t spawn, or /n spawn"));
event.setCancelled(true); event.setCancelled(true);
return; return;
} }
//else //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); event.setCancelled(true);
return; return;
} }
@@ -132,13 +132,13 @@ public class CommandsListener implements Listener {
if (parse.equals(prefix + (prefix.isEmpty() ? "" : ":") + cmd)) { if (parse.equals(prefix + (prefix.isEmpty() ? "" : ":") + cmd)) {
//spawn world check //spawn world check
if (p.getWorld().getName().equals("world")) { 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("&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("&eUse /t spawn, or /n spawn"));
event.setCancelled(true); event.setCancelled(true);
return; 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); event.setCancelled(true);
return; return;
} }
@@ -164,7 +164,7 @@ public class CommandsListener implements Listener {
//payment check //payment check
for (String cmd : blacklistedXLong) { for (String cmd : blacklistedXLong) {
if (parse.equals(prefix + (prefix.isEmpty() ? "" : ":") + cmd)) { 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); event.setCancelled(true);
return; return;
} }
@@ -180,7 +180,7 @@ public class CommandsListener implements Listener {
for (String cmd : payment) { for (String cmd : payment) {
//check for each prefix //check for each prefix
if (parse.equals(prefix + (prefix.isEmpty() ? "" : ":") + cmd)) { 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); event.setCancelled(true);
return; return;
} }
@@ -195,17 +195,17 @@ public class CommandsListener implements Listener {
|| parse.equals("t spawn") || parse.equals("town spawn") || 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:n spawn") || parse.equals("towny:nat spawn") || parse.equals("towny:nation spawn")
|| parse.equals("towny:t spawn") || parse.equals("towny:town 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; 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("&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("&eUse /t spawn, or /n spawn"));
event.setCancelled(true); event.setCancelled(true);
return; return;
} }
//else //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); event.setCancelled(true);
return; return;
} }
@@ -222,13 +222,13 @@ public class CommandsListener implements Listener {
if (parse.equals(prefix + (prefix.isEmpty() ? "" : ":") + cmd)) { if (parse.equals(prefix + (prefix.isEmpty() ? "" : ":") + cmd)) {
//spawn world check //spawn world check
if (p.getWorld().getName().equals("world")) { 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("&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("&eUse /t spawn, or /n spawn"));
event.setCancelled(true); event.setCancelled(true);
return; 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); event.setCancelled(true);
return; return;
} }
@@ -110,7 +110,7 @@ public final class KillsListener implements Listener
for (final String playerName : siege.getAttackerPlayers()) { for (final String playerName : siege.getAttackerPlayers()) {
try { try {
Player p = Bukkit.getPlayer(playerName); 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) { catch (NullPointerException ignored) {
ignored.printStackTrace(); ignored.printStackTrace();
@@ -119,7 +119,7 @@ public final class KillsListener implements Listener
for (final String playerName : siege.getDefenderPlayers()) { for (final String playerName : siege.getDefenderPlayers()) {
try { try {
Player p = Bukkit.getPlayer(playerName); 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) { catch (NullPointerException ignored) {
ignored.printStackTrace(); ignored.printStackTrace();
@@ -135,7 +135,7 @@ public final class KillsListener implements Listener
for (final String playerName : siege.getAttackerPlayers()) { for (final String playerName : siege.getAttackerPlayers()) {
try { try {
Player p = Bukkit.getPlayer(playerName); 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) { catch (NullPointerException ex3) {
ex3.printStackTrace(); ex3.printStackTrace();
@@ -144,7 +144,7 @@ public final class KillsListener implements Listener
for (final String playerName : siege.getDefenderPlayers()) { for (final String playerName : siege.getDefenderPlayers()) {
try { try {
Player p = Bukkit.getPlayer(playerName); 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) { catch (NullPointerException ex4) {
ex4.printStackTrace(); ex4.printStackTrace();
@@ -179,7 +179,7 @@ public final class KillsListener implements Listener
//do raider respawn //do raider respawn
try { try {
event.setRespawnLocation(raid.getGatherTown().getSpawn()); 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) { } catch (TownyException e) {
throw new RuntimeException(e); throw new RuntimeException(e);
} }