mirror of
https://github.com/darksaid98/AlathranWars.git
synced 2026-12-01 14:38:55 +00:00
refactor: wip update 2
This commit is contained in:
26 files changed
+1918
-654
No files matched your search
@@ -15,7 +15,7 @@ public class AlathraWarLogger {
|
||||
public AlathraWarLogger() {
|
||||
logsFolder = new File("plugins" + File.separator + "AlathraWar" + File.separator + "logs");
|
||||
log = new File(
|
||||
"plugins" + File.separator + "AlathraWar" + File.separator + "logs" + File.separator + "log.txt");
|
||||
"plugins" + File.separator + "AlathraWar" + File.separator + "logs" + File.separator + "log.txt");
|
||||
}
|
||||
|
||||
public boolean checkFiles() {
|
||||
@@ -36,8 +36,8 @@ public class AlathraWarLogger {
|
||||
// init file writer
|
||||
try {
|
||||
FileWriter fw = new FileWriter(
|
||||
"plugins" + File.separator + "AlathraWar" + File.separator + "logs" + File.separator + "log.txt",
|
||||
true);
|
||||
"plugins" + File.separator + "AlathraWar" + File.separator + "logs" + File.separator + "log.txt",
|
||||
true);
|
||||
BufferedWriter bw = new BufferedWriter(fw);
|
||||
output = new PrintWriter(bw);
|
||||
} catch (IOException e1) {
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package me.ShermansWorld.AlathraWar;
|
||||
|
||||
import com.palmergames.bukkit.towny.object.WorldCoord;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
||||
@@ -22,10 +21,6 @@ public class Helper {
|
||||
return color("&6[&4AlathraWar&6]&r ");
|
||||
}
|
||||
|
||||
public static void testMsg() {
|
||||
Bukkit.broadcastMessage("test message");
|
||||
}
|
||||
|
||||
/**
|
||||
* Damages all gear in a players inventory
|
||||
*
|
||||
@@ -170,10 +165,10 @@ public class Helper {
|
||||
ArrayList<WorldCoord> ReturnList = new ArrayList<>();
|
||||
|
||||
int[][] XZarray = new int[][]{
|
||||
{-1, 0},
|
||||
{1, 0},
|
||||
{0, -1},
|
||||
{0, 1}
|
||||
{-1, 0},
|
||||
{1, 0},
|
||||
{0, -1},
|
||||
{0, 1}
|
||||
}; // Array that contains relative orthogonal shifts from origin
|
||||
for (int[] pair : XZarray) {
|
||||
// Constructs new WorldCoord for comparison
|
||||
|
||||
@@ -49,7 +49,7 @@ public class Main extends JavaPlugin {
|
||||
logsFolder.mkdirs();
|
||||
}
|
||||
File log = new File(
|
||||
"plugins" + File.separator + "AlathraWar" + File.separator + "logs" + File.separator + "log.txt");
|
||||
"plugins" + File.separator + "AlathraWar" + File.separator + "logs" + File.separator + "log.txt");
|
||||
if (!log.exists()) {
|
||||
try {
|
||||
log.createNewFile();
|
||||
@@ -70,7 +70,7 @@ public class Main extends JavaPlugin {
|
||||
return false;
|
||||
}
|
||||
@SuppressWarnings("unchecked") final RegisteredServiceProvider<Economy> rsp = (RegisteredServiceProvider<Economy>) this.getServer()
|
||||
.getServicesManager().getRegistration((Class) Economy.class);
|
||||
.getServicesManager().getRegistration((Class) Economy.class);
|
||||
if (rsp == null) {
|
||||
return false;
|
||||
}
|
||||
@@ -92,7 +92,6 @@ public class Main extends JavaPlugin {
|
||||
new WarData(this);
|
||||
// new TimeoutData(this);
|
||||
|
||||
|
||||
getServer().getPluginManager().registerEvents(new KillsListener(), this);
|
||||
getServer().getPluginManager().registerEvents(new CommandsListener(), this);
|
||||
getServer().getPluginManager().registerEvents(new JoinListener(), this);
|
||||
|
||||
@@ -210,7 +210,7 @@ public class Raid {
|
||||
// Creates 10 second looping function for Raid
|
||||
|
||||
this.bukkitId[0] = Bukkit.getServer().getScheduler().scheduleSyncRepeatingTask(Main.getInstance(),
|
||||
getTickLoop(), 0L, incremental);
|
||||
getTickLoop(), 0L, incremental);
|
||||
|
||||
this.getWar().addRaid(this);
|
||||
this.save();
|
||||
@@ -243,7 +243,7 @@ public class Raid {
|
||||
|
||||
// Creates 2 second looping function for Raid, restarting this!
|
||||
this.bukkitId[0] = Bukkit.getServer().getScheduler().scheduleSyncRepeatingTask(Main.getInstance(),
|
||||
getTickLoop(), 0L, incremental);
|
||||
getTickLoop(), 0L, incremental);
|
||||
|
||||
}
|
||||
|
||||
@@ -325,9 +325,9 @@ public class Raid {
|
||||
private void startTravel() {
|
||||
Raid.this.phase = RaidPhase.TRAVEL;
|
||||
Bukkit.broadcastMessage(Helper.chatLabel() + "The Raiders of "
|
||||
+ (side1AreRaiders ? Raid.this.war.getSide1() : Raid.this.war.getSide2())
|
||||
+ " are coming to raid "
|
||||
+ Raid.this.getRaidedTown().getName() + "!");
|
||||
+ (side1AreRaiders ? Raid.this.war.getSide1() : Raid.this.war.getSide2())
|
||||
+ " are coming to raid "
|
||||
+ Raid.this.getRaidedTown().getName() + "!");
|
||||
//in the case were not at that stage already, if this happens we have an issue
|
||||
Raid.this.raidTicks = RaidPhase.TRAVEL.startTick;
|
||||
}
|
||||
@@ -338,9 +338,9 @@ public class Raid {
|
||||
private void startCombat() {
|
||||
Raid.this.phase = RaidPhase.COMBAT;
|
||||
Bukkit.broadcastMessage(Helper.chatLabel() + "The Raiders of "
|
||||
+ (side1AreRaiders ? Raid.this.war.getSide1() : Raid.this.war.getSide2())
|
||||
+ " have arrived at "
|
||||
+ Raid.this.getRaidedTown().getName() + " and the fighting has begun!");
|
||||
+ (side1AreRaiders ? Raid.this.war.getSide1() : Raid.this.war.getSide2())
|
||||
+ " have arrived at "
|
||||
+ Raid.this.getRaidedTown().getName() + " and the fighting has begun!");
|
||||
//in the case were not at that stage already
|
||||
Raid.this.raidTicks = RaidPhase.COMBAT.startTick;
|
||||
}
|
||||
@@ -473,7 +473,7 @@ public class Raid {
|
||||
if (factor < 0) factor = 0.0;
|
||||
|
||||
Bukkit.broadcastMessage(Helper.chatLabel() + "The raiders from " + this.raiders
|
||||
+ " have successfully raided " + this.raidedTown.getName() + "!");
|
||||
+ " have successfully raided " + this.raidedTown.getName() + "!");
|
||||
|
||||
/*
|
||||
if town has more than 10k, 1/10th of its valuables times the factor is taken
|
||||
@@ -526,9 +526,9 @@ public class Raid {
|
||||
}
|
||||
|
||||
Bukkit.broadcastMessage("The town of " + this.raidedTown.getName() + " has been " + statement + " by " + this.getRaiderSide()
|
||||
+ " in a raid for " + String.format("$%.2f", amt));
|
||||
+ " in a raid for " + String.format("$%.2f", amt));
|
||||
Main.warLogger.log("The town of " + this.raidedTown.getName() + " has been " + statement + " by " + this.getRaiderSide()
|
||||
+ " in a raid for " + String.format("$%.2f", amt));
|
||||
+ " in a raid for " + String.format("$%.2f", amt));
|
||||
Main.econ.depositPlayer(offlinePlayer, amt);
|
||||
|
||||
if (this.side1AreRaiders) {
|
||||
@@ -560,27 +560,27 @@ public class Raid {
|
||||
|
||||
if (factor <= 0.5) {
|
||||
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()
|
||||
+ " has recovered part of the attackers' raid chest, valued at $500");
|
||||
+ " has recovered part of the attackers' raid chest, valued at $500");
|
||||
Main.warLogger
|
||||
.log("The defenders from " + this.defenders + " have won the raid of " + this.raidedTown.getName() + "!");
|
||||
.log("The defenders from " + this.defenders + " have won the raid of " + this.raidedTown.getName() + "!");
|
||||
this.raidedTown.getAccount().deposit(500, "Raid chest");
|
||||
} else if (factor <= 1.5) {
|
||||
Bukkit.broadcastMessage(Helper.chatLabel() + "The defenders from " + this.defenders
|
||||
+ " have fended off the raiders of " + this.raiders + "!");
|
||||
+ " have fended off the raiders of " + this.raiders + "!");
|
||||
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
|
||||
.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");
|
||||
} else if (factor <= 3.0) {
|
||||
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()
|
||||
+ " has recovered the attackers' raid chest, valued at $1000.");
|
||||
+ " has recovered the attackers' raid chest, valued at $1000.");
|
||||
Main.warLogger
|
||||
.log("The defenders from " + this.defenders + " have won the raid of " + this.raidedTown.getName() + "!");
|
||||
.log("The defenders from " + this.defenders + " have won the raid of " + this.raidedTown.getName() + "!");
|
||||
this.raidedTown.getAccount().deposit(1000, "Raid chest");
|
||||
}
|
||||
|
||||
@@ -600,9 +600,9 @@ public class Raid {
|
||||
//TODO finalize payout
|
||||
|
||||
Bukkit.broadcastMessage(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
|
||||
.log("No one won the raid of " + this.raidedTown.getName() + "!");
|
||||
.log("No one won the raid of " + this.raidedTown.getName() + "!");
|
||||
|
||||
stop();
|
||||
}
|
||||
@@ -846,9 +846,9 @@ public class Raid {
|
||||
//Broadcast
|
||||
if (raidTicks % 6000 == 0) {
|
||||
Bukkit.broadcastMessage(Helper.chatLabel() + "The raid of "
|
||||
+ Raid.this.getRaidedTown().getName() + " will begin in " + ((RaidPhase.TRAVEL.startTick - raidTicks) / 20 / 60) + " minutes!");
|
||||
+ Raid.this.getRaidedTown().getName() + " will begin in " + ((RaidPhase.TRAVEL.startTick - raidTicks) / 20 / 60) + " minutes!");
|
||||
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!");
|
||||
}
|
||||
|
||||
|
||||
@@ -882,9 +882,9 @@ public class Raid {
|
||||
//Report
|
||||
if (raidTicks % 2400 == 0) {
|
||||
Bukkit.broadcastMessage(Helper.chatLabel() + "The Raiders of "
|
||||
+ (side1AreRaiders ? Raid.this.war.getSide1() : Raid.this.war.getSide2())
|
||||
+ " are on their way to raid "
|
||||
+ Raid.this.getRaidedTown().getName() + "!");
|
||||
+ (side1AreRaiders ? Raid.this.war.getSide1() : Raid.this.war.getSide2())
|
||||
+ " are on their way to raid "
|
||||
+ Raid.this.getRaidedTown().getName() + "!");
|
||||
}
|
||||
|
||||
//Check if a player has arrived at the town (in it, or within 200 blocks) and if so start combat
|
||||
@@ -917,13 +917,13 @@ public class Raid {
|
||||
//Report
|
||||
if (Raid.this.raidTicks % 6000 == 0) {
|
||||
Bukkit.broadcastMessage(Helper.chatLabel() + "Report on the raid of "
|
||||
+ Raid.this.getRaidedTown().getName() + ":");
|
||||
+ Raid.this.getRaidedTown().getName() + ":");
|
||||
Bukkit.broadcastMessage(
|
||||
"Raider Score - " + Raid.this.raiderScore);
|
||||
"Raider Score - " + Raid.this.raiderScore);
|
||||
Bukkit.broadcastMessage(
|
||||
"Defender Score - " + Raid.this.defenderScore);
|
||||
"Defender Score - " + Raid.this.defenderScore);
|
||||
Bukkit.broadcastMessage(
|
||||
"Chunks Looted - " + Raid.this.lootedChunks.size() + "/" + raidedTown.getTownBlocks().size());
|
||||
"Chunks Looted - " + Raid.this.lootedChunks.size() + "/" + raidedTown.getTownBlocks().size());
|
||||
}
|
||||
|
||||
//Looting chunks
|
||||
|
||||
@@ -6,6 +6,7 @@ import com.palmergames.bukkit.towny.exceptions.NotRegisteredException;
|
||||
import com.palmergames.bukkit.towny.exceptions.TownyException;
|
||||
import com.palmergames.bukkit.towny.object.*;
|
||||
import me.ShermansWorld.AlathraWar.data.SiegeData;
|
||||
import me.ShermansWorld.AlathraWar.enums.TownWarState;
|
||||
import org.bukkit.*;
|
||||
import org.bukkit.boss.BarColor;
|
||||
import org.bukkit.boss.BarStyle;
|
||||
@@ -45,7 +46,7 @@ public class Siege {
|
||||
|
||||
bossBarKey = new NamespacedKey(Main.getInstance(), "siegeBar." + this.getName());
|
||||
|
||||
side1AreAttackers = war.getSide(town.getName()) == 2;
|
||||
side1AreAttackers = war.getState(town.getName()) == TownWarState.SIDE2;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -167,14 +168,14 @@ public class Siege {
|
||||
for (final String playerName : Siege.this.attackerPlayers) {
|
||||
try {
|
||||
Bukkit.getPlayer(playerName).sendMessage(Helper.chatLabel()
|
||||
+ "HomeBlock at " + Siege.this.town.getName() + " contested!");
|
||||
+ "HomeBlock at " + Siege.this.town.getName() + " contested!");
|
||||
} catch (NullPointerException ex5) {
|
||||
}
|
||||
}
|
||||
for (final String playerName : Siege.this.defenderPlayers) {
|
||||
try {
|
||||
Bukkit.getPlayer(playerName).sendMessage(Helper.chatLabel()
|
||||
+ "HomeBlock at " + Siege.this.town.getName() + " contested!");
|
||||
+ "HomeBlock at " + Siege.this.town.getName() + " contested!");
|
||||
} catch (NullPointerException ex6) {
|
||||
}
|
||||
}
|
||||
@@ -185,16 +186,16 @@ public class Siege {
|
||||
for (final String playerName : Siege.this.attackerPlayers) {
|
||||
try {
|
||||
Bukkit.getPlayer(playerName).sendMessage(Helper.chatLabel()
|
||||
+ "Attackers have captured the HomeBlock at "
|
||||
+ Siege.this.town.getName() + "! +1 Attacker Points per second");
|
||||
+ "Attackers have captured the HomeBlock at "
|
||||
+ Siege.this.town.getName() + "! +1 Attacker Points per second");
|
||||
} catch (NullPointerException ex7) {
|
||||
}
|
||||
}
|
||||
for (final String playerName : Siege.this.defenderPlayers) {
|
||||
try {
|
||||
Bukkit.getPlayer(playerName).sendMessage(Helper.chatLabel()
|
||||
+ "Attackers have captured the HomeBlock at "
|
||||
+ Siege.this.town.getName() + "! +1 Attacker Points per second");
|
||||
+ "Attackers have captured the HomeBlock at "
|
||||
+ Siege.this.town.getName() + "! +1 Attacker Points per second");
|
||||
} catch (NullPointerException ex8) {
|
||||
}
|
||||
}
|
||||
@@ -206,16 +207,16 @@ public class Siege {
|
||||
for (final String playerName : Siege.this.attackerPlayers) {
|
||||
try {
|
||||
Bukkit.getPlayer(playerName).sendMessage(Helper.chatLabel()
|
||||
+ "Defenders retain control of the HomeBlock at "
|
||||
+ Siege.this.town.getName() + "! +1 Defender Points per second");
|
||||
+ "Defenders retain control of the HomeBlock at "
|
||||
+ Siege.this.town.getName() + "! +1 Defender Points per second");
|
||||
} catch (NullPointerException ex9) {
|
||||
}
|
||||
}
|
||||
for (final String playerName : Siege.this.defenderPlayers) {
|
||||
try {
|
||||
Bukkit.getPlayer(playerName).sendMessage(Helper.chatLabel()
|
||||
+ "Defenders retain control of the HomeBlock at "
|
||||
+ Siege.this.town.getName() + "! +1 Defender Points per second");
|
||||
+ "Defenders retain control of the HomeBlock at "
|
||||
+ Siege.this.town.getName() + "! +1 Defender Points per second");
|
||||
} catch (NullPointerException ex10) {
|
||||
}
|
||||
}
|
||||
@@ -225,11 +226,11 @@ public class Siege {
|
||||
}
|
||||
if (Siege.this.siegeTicks % 6000 == 0) { // Updates every 5 minutes
|
||||
Bukkit.broadcastMessage(Helper.chatLabel() + "Report on the siege of "
|
||||
+ Siege.this.town.getName() + ":");
|
||||
+ Siege.this.town.getName() + ":");
|
||||
Bukkit.broadcastMessage(
|
||||
"Attacker Points - " + Siege.this.attackerPoints);
|
||||
"Attacker Points - " + Siege.this.attackerPoints);
|
||||
Bukkit.broadcastMessage(
|
||||
"Defender Points - " + Siege.this.defenderPoints);
|
||||
"Defender Points - " + Siege.this.defenderPoints);
|
||||
}
|
||||
if (siegeTicks % 1200 == 0) { // Saves every minute
|
||||
save();
|
||||
@@ -253,7 +254,7 @@ public class Siege {
|
||||
}
|
||||
if (nation != null) {
|
||||
Bukkit.broadcastMessage(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);
|
||||
double amt = 0.0;
|
||||
@@ -264,7 +265,7 @@ public class Siege {
|
||||
if (this.town.getAccount().getHoldingBalance() < 2500.0) {
|
||||
amt = this.town.getAccount().getHoldingBalance();
|
||||
Bukkit.broadcastMessage(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);
|
||||
Main.econ.depositPlayer(siegeLeader, amt);
|
||||
return;
|
||||
@@ -273,9 +274,9 @@ public class Siege {
|
||||
amt = 2500.0;
|
||||
}
|
||||
Bukkit.broadcastMessage("The town of " + this.town.getName() + " has been sacked by " + this.getAttackerSide()
|
||||
+ ", valuing $" + amt);
|
||||
+ ", valuing $" + amt);
|
||||
Main.warLogger.log("The town of " + this.town.getName() + " has been sacked by " + this.getAttackerSide()
|
||||
+ ", valuing $" + amt);
|
||||
+ ", valuing $" + amt);
|
||||
Main.econ.depositPlayer(siegeLeader, amt);
|
||||
|
||||
if (side1AreAttackers) {
|
||||
@@ -292,9 +293,9 @@ public class Siege {
|
||||
this.town.getAccount().deposit(2500.0, "War chest");
|
||||
Bukkit.broadcastMessage(Helper.chatLabel() + "The defenders have won the siege of " + this.town.getName() + "!");
|
||||
Bukkit.broadcastMessage(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
|
||||
.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() + "!");
|
||||
|
||||
if (side1AreAttackers) {
|
||||
war.addSide2Points(50);
|
||||
@@ -313,7 +314,7 @@ public class Siege {
|
||||
Bukkit.broadcastMessage(Helper.chatLabel() + "The siege of " + this.town.getName() + " was a draw!");
|
||||
Bukkit.broadcastMessage(Helper.chatLabel() + "No money has been recovered.");
|
||||
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();
|
||||
clearBeacon();
|
||||
}
|
||||
@@ -337,7 +338,7 @@ public class Siege {
|
||||
}
|
||||
int homeBlockY = 253;
|
||||
final Location beaconLoc = new Location(this.town.getWorld(), homeBlockX,
|
||||
homeBlockY - 2, homeBlockZ);
|
||||
homeBlockY - 2, homeBlockZ);
|
||||
while (beaconLoc.getBlock().getType().equals(Material.AIR)) {
|
||||
--homeBlockY;
|
||||
beaconLoc.setY(homeBlockY);
|
||||
@@ -345,25 +346,25 @@ public class Siege {
|
||||
homeBlockY += 2;
|
||||
this.beaconLocs.add(new Location(world, homeBlockX, homeBlockY, homeBlockZ));
|
||||
this.beaconLocs
|
||||
.add(new Location(world, homeBlockX, homeBlockY + 1, homeBlockZ));
|
||||
.add(new Location(world, homeBlockX, homeBlockY + 1, homeBlockZ));
|
||||
this.beaconLocs
|
||||
.add(new Location(world, homeBlockX, homeBlockY - 1, homeBlockZ));
|
||||
.add(new Location(world, homeBlockX, homeBlockY - 1, homeBlockZ));
|
||||
this.beaconLocs.add(
|
||||
new Location(world, homeBlockX + 1, homeBlockY - 1, homeBlockZ));
|
||||
new Location(world, homeBlockX + 1, homeBlockY - 1, homeBlockZ));
|
||||
this.beaconLocs.add(
|
||||
new Location(world, homeBlockX - 1, homeBlockY - 1, homeBlockZ));
|
||||
new Location(world, homeBlockX - 1, homeBlockY - 1, homeBlockZ));
|
||||
this.beaconLocs.add(
|
||||
new Location(world, homeBlockX, homeBlockY - 1, homeBlockZ + 1));
|
||||
new Location(world, homeBlockX, homeBlockY - 1, homeBlockZ + 1));
|
||||
this.beaconLocs.add(
|
||||
new Location(world, homeBlockX, homeBlockY - 1, homeBlockZ - 1));
|
||||
new Location(world, homeBlockX, homeBlockY - 1, homeBlockZ - 1));
|
||||
this.beaconLocs.add(new Location(world, homeBlockX + 1, homeBlockY - 1,
|
||||
homeBlockZ + 1));
|
||||
homeBlockZ + 1));
|
||||
this.beaconLocs.add(new Location(world, homeBlockX + 1, homeBlockY - 1,
|
||||
homeBlockZ - 1));
|
||||
homeBlockZ - 1));
|
||||
this.beaconLocs.add(new Location(world, homeBlockX - 1, homeBlockY - 1,
|
||||
homeBlockZ + 1));
|
||||
homeBlockZ + 1));
|
||||
this.beaconLocs.add(new Location(world, homeBlockX - 1, homeBlockY - 1,
|
||||
homeBlockZ - 1));
|
||||
homeBlockZ - 1));
|
||||
for (int i = 2; i < this.beaconLocs.size(); ++i) {
|
||||
if (this.beaconLocs.get(i).getBlock().getType() != Material.AIR) {
|
||||
i = 1;
|
||||
@@ -388,21 +389,21 @@ public class Siege {
|
||||
this.beaconLocs.add(new Location(world, homeBlockX, homeBlockY + 1, homeBlockZ));
|
||||
this.beaconLocs.add(new Location(world, homeBlockX, homeBlockY - 1, homeBlockZ));
|
||||
this.beaconLocs
|
||||
.add(new Location(world, homeBlockX + 1, homeBlockY - 1, homeBlockZ));
|
||||
.add(new Location(world, homeBlockX + 1, homeBlockY - 1, homeBlockZ));
|
||||
this.beaconLocs
|
||||
.add(new Location(world, homeBlockX - 1, homeBlockY - 1, homeBlockZ));
|
||||
.add(new Location(world, homeBlockX - 1, homeBlockY - 1, homeBlockZ));
|
||||
this.beaconLocs
|
||||
.add(new Location(world, homeBlockX, homeBlockY - 1, homeBlockZ + 1));
|
||||
.add(new Location(world, homeBlockX, homeBlockY - 1, homeBlockZ + 1));
|
||||
this.beaconLocs
|
||||
.add(new Location(world, homeBlockX, homeBlockY - 1, homeBlockZ - 1));
|
||||
.add(new Location(world, homeBlockX, homeBlockY - 1, homeBlockZ - 1));
|
||||
this.beaconLocs.add(
|
||||
new Location(world, homeBlockX + 1, homeBlockY - 1, homeBlockZ + 1));
|
||||
new Location(world, homeBlockX + 1, homeBlockY - 1, homeBlockZ + 1));
|
||||
this.beaconLocs.add(
|
||||
new Location(world, homeBlockX + 1, homeBlockY - 1, homeBlockZ - 1));
|
||||
new Location(world, homeBlockX + 1, homeBlockY - 1, homeBlockZ - 1));
|
||||
this.beaconLocs.add(
|
||||
new Location(world, homeBlockX - 1, homeBlockY - 1, homeBlockZ + 1));
|
||||
new Location(world, homeBlockX - 1, homeBlockY - 1, homeBlockZ + 1));
|
||||
this.beaconLocs.add(
|
||||
new Location(world, homeBlockX - 1, homeBlockY - 1, homeBlockZ - 1));
|
||||
new Location(world, homeBlockX - 1, homeBlockY - 1, homeBlockZ - 1));
|
||||
}
|
||||
|
||||
public void clearBeacon() {
|
||||
|
||||
@@ -7,6 +7,7 @@ import com.palmergames.bukkit.towny.object.Town;
|
||||
import me.ShermansWorld.AlathraWar.commands.CommandHelper;
|
||||
import me.ShermansWorld.AlathraWar.data.DataManager;
|
||||
import me.ShermansWorld.AlathraWar.data.WarData;
|
||||
import me.ShermansWorld.AlathraWar.enums.TownWarState;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
@@ -174,23 +175,27 @@ public class War {
|
||||
* @param string town
|
||||
* @return result
|
||||
*/
|
||||
public int getSide(String string) {
|
||||
public TownWarState getState(String string) {
|
||||
for (String str : surrenderedTowns) {
|
||||
if (str.equalsIgnoreCase(string)) return -1;
|
||||
if (str.equalsIgnoreCase(string)) return TownWarState.SURRENDERED;
|
||||
}
|
||||
|
||||
for (String str : side1Towns) {
|
||||
if (str.equalsIgnoreCase(string)) return 1;
|
||||
if (str.equalsIgnoreCase(string)) return TownWarState.SIDE1;
|
||||
}
|
||||
|
||||
for (String str : side2Towns) {
|
||||
if (str.equalsIgnoreCase(string)) return 2;
|
||||
if (str.equalsIgnoreCase(string)) return TownWarState.SIDE2;
|
||||
}
|
||||
return 0;
|
||||
return TownWarState.NOT_PARTICIPANT;
|
||||
}
|
||||
|
||||
public int getSide(Town town) {
|
||||
return getSide(town.getName());
|
||||
public TownWarState getState(Town town) {
|
||||
return getState(town.getName());
|
||||
}
|
||||
|
||||
public boolean isSideValid(String side) {
|
||||
return getSides().contains(side);
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
@@ -272,8 +277,8 @@ public class War {
|
||||
|
||||
public String toString() {
|
||||
return name + "[" + side1 + "." + side2 + "]("
|
||||
+ side1Towns.size() + "/" + side2Towns.size() + "/" +
|
||||
surrenderedTowns.size() + ")";
|
||||
+ side1Towns.size() + "/" + side2Towns.size() + "/" +
|
||||
surrenderedTowns.size() + ")";
|
||||
}
|
||||
|
||||
public ArrayList<String> getSide1Players() {
|
||||
|
||||
File diff suppressed because it is too large.
Load diff
@@ -12,6 +12,7 @@ import me.ShermansWorld.AlathraWar.data.RaidData;
|
||||
import me.ShermansWorld.AlathraWar.data.RaidPhase;
|
||||
import me.ShermansWorld.AlathraWar.data.SiegeData;
|
||||
import me.ShermansWorld.AlathraWar.data.WarData;
|
||||
import me.ShermansWorld.AlathraWar.enums.TownWarState;
|
||||
import me.ShermansWorld.AlathraWar.items.WarItemRegistry;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
@@ -202,7 +203,7 @@ public class AdminCommands implements CommandExecutor {
|
||||
if (args.length >= 4) {
|
||||
//specific behavior exists if an admin ran this
|
||||
//using same method so that this doesnt get fucked up if we go back and change original implementation
|
||||
RaidCommands.startRaid(p, args, true);
|
||||
RaidCommand.raidStart(p, args, true);
|
||||
p.sendMessage(Helper.color("&cForcefully started raid from the console."));
|
||||
} else {
|
||||
//defaultCode will bypass the custom gather town to force set owner
|
||||
@@ -218,7 +219,7 @@ public class AdminCommands implements CommandExecutor {
|
||||
l.add(args[3]);
|
||||
if (args.length >= 5) l.add(args[4]);
|
||||
if (args.length >= 6) l.add(args[5]);
|
||||
SiegeCommands.siegeStart(p, l.toArray(new String[]{}), true);
|
||||
SiegeCommand.siegeStart(p, l.toArray(new String[]{}), true);
|
||||
// p.sendMessage(Helper.Chatlabel() + "Try again later!");
|
||||
p.sendMessage(Helper.color("&cForcefully started siege from the console."));
|
||||
} else {
|
||||
@@ -230,12 +231,12 @@ public class AdminCommands implements CommandExecutor {
|
||||
if (args.length == 5) {
|
||||
//should purge the first argument;
|
||||
String[] adjusted = new String[]{
|
||||
args[1],
|
||||
args[2],
|
||||
args[3],
|
||||
args[4]
|
||||
args[1],
|
||||
args[2],
|
||||
args[3],
|
||||
args[4]
|
||||
};
|
||||
WarCommands.warCreate(p, adjusted);
|
||||
WarCommand.warCreate(p, adjusted);
|
||||
p.sendMessage(Helper.color("&cForcefully started war from the console."));
|
||||
} else {
|
||||
p.sendMessage(Helper.color("&cUsage: /alathrawaradmin create war [name] [side1] [side2]"));
|
||||
@@ -393,7 +394,7 @@ public class AdminCommands implements CommandExecutor {
|
||||
adjusted.add(args[3]);
|
||||
adjusted.add(args[6]);
|
||||
adjusted.add(args[7]);
|
||||
RaidCommands.joinRaid(p, adjusted.toArray(new String[6]), true);
|
||||
RaidCommand.raidJoin(p, adjusted.toArray(new String[6]), true);
|
||||
return true;
|
||||
} else {
|
||||
p.sendMessage(Helper.color("&cUsage: /alathrawaradmin force join raid [player] [war] [town] [side] (ignoreIssues)"));
|
||||
@@ -411,11 +412,11 @@ public class AdminCommands implements CommandExecutor {
|
||||
if (args.length >= 7) {
|
||||
//fix args to match
|
||||
String[] adjusted = new String[]{
|
||||
args[1],
|
||||
args[4],
|
||||
args[5],
|
||||
args[3],
|
||||
args[6]
|
||||
args[1],
|
||||
args[4],
|
||||
args[5],
|
||||
args[3],
|
||||
args[6]
|
||||
};
|
||||
if (Bukkit.getPlayer(args[3]) != null) {
|
||||
} else {
|
||||
@@ -423,7 +424,7 @@ public class AdminCommands implements CommandExecutor {
|
||||
p.sendMessage(Helper.color("&cUsage: /alathrawaradmin force join war [player] [war] [side]"));
|
||||
return true;
|
||||
}
|
||||
WarCommands.warJoin(p, adjusted, true);
|
||||
WarCommand.warJoin(p, adjusted, true);
|
||||
p.sendMessage(Helper.color("&cForced " + args[3] + " to join the war " + args[4] + " on side " + args[5]));
|
||||
Main.warLogger.log("Forced " + args[3] + " to join the war " + args[4] + " on side " + args[5]);
|
||||
} else {
|
||||
@@ -446,12 +447,12 @@ public class AdminCommands implements CommandExecutor {
|
||||
if (r.getWar().getName().equalsIgnoreCase(args[3]) && r.getRaidedTown().getName().equalsIgnoreCase(args[4])) {
|
||||
if (Bukkit.getPlayer(args[5]) != null) {
|
||||
String[] fixed = new String[]{
|
||||
args[1],
|
||||
args[3],
|
||||
args[4],
|
||||
args[5]
|
||||
args[1],
|
||||
args[3],
|
||||
args[4],
|
||||
args[5]
|
||||
};
|
||||
RaidCommands.leaveRaid(p, fixed, true);
|
||||
RaidCommand.raidLeave(p, fixed, true);
|
||||
p.sendMessage(Helper.chatLabel() + "Forced player " + args[5] + " to leave raid on " + args[4] + " in war " + args[3]);
|
||||
Main.warLogger.log("Forced player " + args[5] + " to leave raid on " + args[4] + " in war " + args[3]);
|
||||
return finalizeRaid(r);
|
||||
@@ -1497,11 +1498,11 @@ public class AdminCommands implements CommandExecutor {
|
||||
}
|
||||
}
|
||||
// Side checks
|
||||
int side = w.getSide(t.getName().toLowerCase());
|
||||
if (side == -1) {
|
||||
TownWarState side = w.getState(t.getName().toLowerCase());
|
||||
if (side == TownWarState.SURRENDERED) {
|
||||
p.sendMessage(Helper.chatLabel() + "Town already surrendered!");
|
||||
return true;
|
||||
} else if (side > 0) {
|
||||
} else if (side != TownWarState.NOT_PARTICIPANT) {
|
||||
p.sendMessage(Helper.chatLabel() + "Town already in this war!");
|
||||
return true;
|
||||
}
|
||||
@@ -1544,11 +1545,11 @@ public class AdminCommands implements CommandExecutor {
|
||||
|
||||
for (Town t : n.getTowns()) {
|
||||
// Side checks
|
||||
int side = w.getSide(t.getName().toLowerCase());
|
||||
if (side == -1) {
|
||||
TownWarState side = w.getState(t.getName().toLowerCase());
|
||||
if (side == TownWarState.SURRENDERED) {
|
||||
p.sendMessage(Helper.chatLabel() + "Town " + t.getName() + " already surrendered!");
|
||||
continue;
|
||||
} else if (side > 0) {
|
||||
} else if (side != TownWarState.NOT_PARTICIPANT) {
|
||||
p.sendMessage(Helper.chatLabel() + "Town " + t.getName() + " already in this war!");
|
||||
continue;
|
||||
}
|
||||
@@ -1873,19 +1874,16 @@ public class AdminCommands implements CommandExecutor {
|
||||
}
|
||||
}
|
||||
|
||||
private static boolean finalizeRaid(Raid r) {
|
||||
private static void finalizeRaid(Raid r) {
|
||||
r.save();
|
||||
return true;
|
||||
}
|
||||
|
||||
private static boolean finalizeSiege(Siege s) {
|
||||
private static void finalizeSiege(Siege s) {
|
||||
s.save();
|
||||
return true;
|
||||
}
|
||||
|
||||
private static boolean finalizeWar(War w) {
|
||||
private static void finalizeWar(War w) {
|
||||
w.save();
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -12,31 +12,31 @@ import java.util.List;
|
||||
public class AdminTabCompletion implements TabCompleter {
|
||||
|
||||
List<String> base = List.of("create",
|
||||
"force",
|
||||
"help",
|
||||
"info",
|
||||
"modify",
|
||||
"purgebars",
|
||||
"load",
|
||||
"load-all",
|
||||
"save",
|
||||
"save-all",
|
||||
"item");
|
||||
"force",
|
||||
"help",
|
||||
"info",
|
||||
"modify",
|
||||
"purgebars",
|
||||
"load",
|
||||
"load-all",
|
||||
"save",
|
||||
"save-all",
|
||||
"item");
|
||||
|
||||
List<String> type = List.of(new String[]{
|
||||
"raid",
|
||||
"siege",
|
||||
"war"
|
||||
"raid",
|
||||
"siege",
|
||||
"war"
|
||||
});
|
||||
|
||||
List<String> raidModify = List.of(new String[]{
|
||||
"score",
|
||||
"townspawn",
|
||||
"gather",
|
||||
"phase",
|
||||
"loot",
|
||||
"time",
|
||||
"owner"
|
||||
"score",
|
||||
"townspawn",
|
||||
"gather",
|
||||
"phase",
|
||||
"loot",
|
||||
"time",
|
||||
"owner"
|
||||
// ,
|
||||
// "move"
|
||||
// ,
|
||||
@@ -44,64 +44,64 @@ public class AdminTabCompletion implements TabCompleter {
|
||||
});
|
||||
|
||||
List<String> siegeModify = List.of(new String[]{
|
||||
"score",
|
||||
"townspawn",
|
||||
"time",
|
||||
"owner"
|
||||
"score",
|
||||
"townspawn",
|
||||
"time",
|
||||
"owner"
|
||||
// ,
|
||||
// "move"
|
||||
});
|
||||
|
||||
List<String> warModify = List.of(new String[]{
|
||||
"score",
|
||||
"side",
|
||||
"name",
|
||||
"add",
|
||||
"surrender",
|
||||
"unsurrender",
|
||||
"raidTimeWar",
|
||||
"raidTimeTown"
|
||||
"score",
|
||||
"side",
|
||||
"name",
|
||||
"add",
|
||||
"surrender",
|
||||
"unsurrender",
|
||||
"raidTimeWar",
|
||||
"raidTimeTown"
|
||||
});
|
||||
|
||||
List<String> force = List.of(new String[]{
|
||||
"end",
|
||||
"join",
|
||||
"leave"
|
||||
"end",
|
||||
"join",
|
||||
"leave"
|
||||
});
|
||||
|
||||
List<String> addSet = List.of(new String[]{
|
||||
"add",
|
||||
"set"
|
||||
"add",
|
||||
"set"
|
||||
});
|
||||
|
||||
List<String> addSubSet = List.of(new String[]{
|
||||
"add",
|
||||
"subtract",
|
||||
"set"
|
||||
"add",
|
||||
"subtract",
|
||||
"set"
|
||||
});
|
||||
|
||||
List<String> boolSet = List.of(new String[]{
|
||||
"true",
|
||||
"false"
|
||||
"true",
|
||||
"false"
|
||||
});
|
||||
|
||||
|
||||
List<String> addSetReset = List.of(new String[]{
|
||||
"add",
|
||||
"set",
|
||||
"reset"
|
||||
"add",
|
||||
"set",
|
||||
"reset"
|
||||
});
|
||||
|
||||
List<String> nationTown = List.of(new String[]{
|
||||
"town",
|
||||
"nation"
|
||||
"town",
|
||||
"nation"
|
||||
});
|
||||
|
||||
List<String> lootSet = List.of(new String[]{
|
||||
"value",
|
||||
"looted",
|
||||
"ticks",
|
||||
"reset"
|
||||
"value",
|
||||
"looted",
|
||||
"ticks",
|
||||
"reset"
|
||||
});
|
||||
|
||||
List<String> empty = Collections.emptyList();
|
||||
|
||||
@@ -36,6 +36,32 @@ public class CommandHelper {
|
||||
return out;
|
||||
}
|
||||
|
||||
/**
|
||||
* Grabs list of all sieges
|
||||
*
|
||||
* @return list of wars
|
||||
*/
|
||||
public static List<String> getSieges() {
|
||||
List<String> out = new ArrayList<>();
|
||||
for (Siege s : SiegeData.getSieges()) {
|
||||
out.add(s.getName());
|
||||
}
|
||||
return out;
|
||||
}
|
||||
|
||||
/**
|
||||
* Grabs list of all raids
|
||||
*
|
||||
* @return list of wars
|
||||
*/
|
||||
public static List<String> getRaids() {
|
||||
List<String> out = new ArrayList<>();
|
||||
for (Raid r : RaidData.getRaids()) {
|
||||
out.add(r.getName());
|
||||
}
|
||||
return out;
|
||||
}
|
||||
|
||||
/**
|
||||
* Grabs first matching war and lists the sides
|
||||
*
|
||||
|
||||
@@ -22,8 +22,7 @@ public class CommandManager {
|
||||
new WarCommand();
|
||||
new SiegeCommand();
|
||||
new RaidCommand();
|
||||
new AdminCommands(instance);
|
||||
// getCommand("alathrawaradmin").setTabCompleter(new AdminTabCompletion());
|
||||
new AdminCommand();
|
||||
}
|
||||
|
||||
public void onDisable() {
|
||||
|
||||
@@ -20,6 +20,7 @@ import me.ShermansWorld.AlathraWar.data.RaidData;
|
||||
import me.ShermansWorld.AlathraWar.data.RaidPhase;
|
||||
import me.ShermansWorld.AlathraWar.data.SiegeData;
|
||||
import me.ShermansWorld.AlathraWar.data.WarData;
|
||||
import me.ShermansWorld.AlathraWar.enums.TownWarState;
|
||||
import net.md_5.bungee.api.ChatColor;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
@@ -29,177 +30,170 @@ import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
public class RaidCommand {
|
||||
|
||||
public RaidCommand() {
|
||||
new CommandAPICommand("raid")
|
||||
.withSubcommands(
|
||||
commandRaid(),
|
||||
commandStop(),
|
||||
commandJoin(),
|
||||
commandLeave(),
|
||||
commandAbandon(),
|
||||
commandList(),
|
||||
commandHelp()
|
||||
)
|
||||
.executesPlayer((sender, args) -> {
|
||||
if (args.count() == 0)
|
||||
throw CommandAPIBukkit.failWithAdventureComponent(new ColorParser(Helper.chatLabel() + "Invalid Arguments. /siege help").build());
|
||||
})
|
||||
.register();
|
||||
.withSubcommands(
|
||||
commandRaid(),
|
||||
commandStop(),
|
||||
commandJoin(),
|
||||
commandLeave(),
|
||||
commandAbandon(),
|
||||
commandList(),
|
||||
commandHelp()
|
||||
)
|
||||
.executesPlayer((sender, args) -> {
|
||||
if (args.count() == 0)
|
||||
throw CommandAPIBukkit.failWithAdventureComponent(new ColorParser(Helper.chatLabel() + "Invalid Arguments. /siege help").build());
|
||||
})
|
||||
.register();
|
||||
}
|
||||
|
||||
public static CommandAPICommand commandRaid() {
|
||||
return new CommandAPICommand("raid")
|
||||
.withArguments(
|
||||
new StringArgument("warname")
|
||||
.replaceSuggestions(
|
||||
ArgumentSuggestions.strings(
|
||||
WarData.getWarsNames()
|
||||
)
|
||||
),
|
||||
new StringArgument("target")
|
||||
.replaceSuggestions(
|
||||
ArgumentSuggestions.stringCollection(info -> {
|
||||
final String warname = (String) info.previousArgs().get("warname");
|
||||
return CommandHelper.getTownyWarTowns(warname);
|
||||
}
|
||||
)
|
||||
),
|
||||
new StringArgument("gathertown")
|
||||
.setOptional(true)
|
||||
.withPermission("AlathraWar.admin")
|
||||
.replaceSuggestions(
|
||||
ArgumentSuggestions.stringCollection(info -> { // TODO Make getHostileTowns method where we reverse from list
|
||||
final String warname = (String) info.previousArgs().get("warname");
|
||||
return CommandHelper.getTownyWarTowns(warname);
|
||||
}
|
||||
)
|
||||
),
|
||||
new PlayerArgument("leader")
|
||||
.setOptional(true)
|
||||
.withPermission("AlathraWar.admin"),
|
||||
new BooleanArgument("minutemen")
|
||||
.setOptional(true)
|
||||
.withPermission("AlathraWar.admin")
|
||||
.withArguments(
|
||||
new StringArgument("warname")
|
||||
.replaceSuggestions(
|
||||
ArgumentSuggestions.strings(
|
||||
WarData.getWarsNames()
|
||||
)
|
||||
),
|
||||
new StringArgument("target")
|
||||
.replaceSuggestions(
|
||||
ArgumentSuggestions.stringCollection(info -> {
|
||||
final String warname = (String) info.previousArgs().get("warname");
|
||||
return CommandHelper.getTownyWarTowns(warname);
|
||||
}
|
||||
)
|
||||
),
|
||||
new StringArgument("gathertown")
|
||||
.setOptional(true)
|
||||
.withPermission("AlathraWar.admin")
|
||||
.replaceSuggestions(
|
||||
ArgumentSuggestions.stringCollection(info -> { // TODO Make getHostileTowns method where we reverse from list
|
||||
final String warname = (String) info.previousArgs().get("warname");
|
||||
return CommandHelper.getTownyWarTowns(warname);
|
||||
}
|
||||
)
|
||||
),
|
||||
new PlayerArgument("leader")
|
||||
.setOptional(true)
|
||||
.withPermission("AlathraWar.admin"),
|
||||
new BooleanArgument("minutemen")
|
||||
.setOptional(true)
|
||||
.withPermission("AlathraWar.admin")
|
||||
|
||||
)
|
||||
.executesPlayer((Player p, CommandArguments args) -> raidStart(p, args, false));
|
||||
)
|
||||
.executesPlayer((Player p, CommandArguments args) -> raidStart(p, args, false));
|
||||
}
|
||||
|
||||
public static CommandAPICommand commandStop() {
|
||||
return new CommandAPICommand("stop")
|
||||
.withPermission("AlathraWar.admin")
|
||||
.withArguments(
|
||||
new StringArgument("warname")
|
||||
.replaceSuggestions(
|
||||
ArgumentSuggestions.stringCollection(info ->
|
||||
WarData.getWarsNames()
|
||||
)
|
||||
),
|
||||
new StringArgument("town")
|
||||
.replaceSuggestions(
|
||||
ArgumentSuggestions.stringCollection(info -> {
|
||||
final String warname = (String) info.previousArgs().get("warname");
|
||||
return CommandHelper.getTownyWarTowns(warname);
|
||||
})
|
||||
)
|
||||
)
|
||||
.executesPlayer(RaidCommand::raidStop);
|
||||
.withPermission("AlathraWar.admin")
|
||||
.withArguments(
|
||||
new StringArgument("warname")
|
||||
.replaceSuggestions(
|
||||
ArgumentSuggestions.stringCollection(info ->
|
||||
WarData.getWarsNames()
|
||||
)
|
||||
),
|
||||
new StringArgument("town")
|
||||
.replaceSuggestions(
|
||||
ArgumentSuggestions.stringCollection(info -> {
|
||||
final String warname = (String) info.previousArgs().get("warname");
|
||||
return CommandHelper.getTownyWarTowns(warname);
|
||||
})
|
||||
)
|
||||
)
|
||||
.executesPlayer(RaidCommand::raidStop);
|
||||
}
|
||||
|
||||
public static CommandAPICommand commandJoin() {
|
||||
return new CommandAPICommand("join")
|
||||
.withArguments(
|
||||
new StringArgument("warname")
|
||||
.replaceSuggestions(
|
||||
ArgumentSuggestions.stringCollection(info ->
|
||||
WarData.getWarsNames()
|
||||
)
|
||||
),
|
||||
new StringArgument("town")
|
||||
.replaceSuggestions(
|
||||
ArgumentSuggestions.stringCollection(info -> {
|
||||
final String warname = (String) info.previousArgs().get("warname");
|
||||
return CommandHelper.getTownyWarTowns(warname);
|
||||
})
|
||||
),
|
||||
new PlayerArgument("player")
|
||||
.setOptional(true)
|
||||
.withPermission("AlathraWar.admin"),
|
||||
new StringArgument("side")
|
||||
.replaceSuggestions(
|
||||
ArgumentSuggestions.stringCollection(info -> {
|
||||
String warName = (String) info.previousArgs().get("warname");
|
||||
.withArguments(
|
||||
new StringArgument("raidname")
|
||||
.replaceSuggestions(
|
||||
ArgumentSuggestions.strings(
|
||||
CommandHelper.getRaids()
|
||||
)
|
||||
),
|
||||
new StringArgument("side")
|
||||
.replaceSuggestions(
|
||||
ArgumentSuggestions.stringCollection(info -> {
|
||||
final String raidname = (String) info.previousArgs().get("raidname");
|
||||
|
||||
War war = WarData.getWar(warName);
|
||||
if (war != null) {
|
||||
return war.getSides();
|
||||
}
|
||||
final Raid raid = RaidData.getRaid(raidname);
|
||||
|
||||
return Collections.emptyList();
|
||||
})
|
||||
),
|
||||
new BooleanArgument("minutemen")
|
||||
.setOptional(true)
|
||||
.withPermission("AlathraWar.admin")
|
||||
if (raid == null) return Collections.emptyList();
|
||||
|
||||
)
|
||||
.executesPlayer((Player p, CommandArguments args) -> raidJoin(p, args, false));
|
||||
return List.of(raid.getRaiderSide(), raid.getDefenderSide());
|
||||
})
|
||||
),
|
||||
new PlayerArgument("player")
|
||||
.setOptional(true)
|
||||
.withPermission("AlathraWar.admin"),
|
||||
new BooleanArgument("minutemen")
|
||||
.setOptional(true)
|
||||
.withPermission("AlathraWar.admin")
|
||||
|
||||
)
|
||||
.executesPlayer((Player p, CommandArguments args) -> raidJoin(p, args, false));
|
||||
}
|
||||
|
||||
public static CommandAPICommand commandLeave() {
|
||||
return new CommandAPICommand("leave")
|
||||
.withArguments(
|
||||
new StringArgument("warname")
|
||||
.replaceSuggestions(
|
||||
ArgumentSuggestions.stringCollection(info ->
|
||||
WarData.getWarsNames()
|
||||
)
|
||||
),
|
||||
new StringArgument("town")
|
||||
.replaceSuggestions(
|
||||
ArgumentSuggestions.stringCollection(info -> {
|
||||
final String warname = (String) info.previousArgs().get("warname");
|
||||
return CommandHelper.getTownyWarTowns(warname);
|
||||
})
|
||||
),
|
||||
new PlayerArgument("player")
|
||||
.setOptional(true)
|
||||
.withPermission("AlathraWar.admin")
|
||||
)
|
||||
.executesPlayer((Player p, CommandArguments args) -> raidLeave(p, args, false));
|
||||
.withArguments(
|
||||
new StringArgument("warname")
|
||||
.replaceSuggestions(
|
||||
ArgumentSuggestions.stringCollection(info ->
|
||||
WarData.getWarsNames()
|
||||
)
|
||||
),
|
||||
new StringArgument("town")
|
||||
.replaceSuggestions(
|
||||
ArgumentSuggestions.stringCollection(info -> {
|
||||
final String warname = (String) info.previousArgs().get("warname");
|
||||
return CommandHelper.getTownyWarTowns(warname);
|
||||
})
|
||||
),
|
||||
new PlayerArgument("player")
|
||||
.setOptional(true)
|
||||
.withPermission("AlathraWar.admin")
|
||||
)
|
||||
.executesPlayer((Player p, CommandArguments args) -> raidLeave(p, args, false));
|
||||
}
|
||||
|
||||
public static CommandAPICommand commandAbandon() {
|
||||
return new CommandAPICommand("abandon")
|
||||
.withArguments(
|
||||
new StringArgument("warname")
|
||||
.replaceSuggestions(
|
||||
ArgumentSuggestions.stringCollection(info ->
|
||||
WarData.getWarsNames()
|
||||
)
|
||||
),
|
||||
new StringArgument("town")
|
||||
.replaceSuggestions(
|
||||
ArgumentSuggestions.stringCollection(info -> {
|
||||
final String warname = (String) info.previousArgs().get("warname");
|
||||
return CommandHelper.getTownyWarTowns(warname);
|
||||
})
|
||||
)
|
||||
)
|
||||
.executesPlayer(RaidCommand::raidAbandon);
|
||||
.withArguments(
|
||||
new StringArgument("warname")
|
||||
.replaceSuggestions(
|
||||
ArgumentSuggestions.stringCollection(info ->
|
||||
WarData.getWarsNames()
|
||||
)
|
||||
),
|
||||
new StringArgument("town")
|
||||
.replaceSuggestions(
|
||||
ArgumentSuggestions.stringCollection(info -> {
|
||||
final String warname = (String) info.previousArgs().get("warname");
|
||||
return CommandHelper.getTownyWarTowns(warname);
|
||||
})
|
||||
)
|
||||
)
|
||||
.executesPlayer(RaidCommand::raidAbandon);
|
||||
}
|
||||
|
||||
public static CommandAPICommand commandList() {
|
||||
return new CommandAPICommand("list")
|
||||
.executesPlayer(RaidCommand::raidsList);
|
||||
.executesPlayer(RaidCommand::raidsList);
|
||||
}
|
||||
|
||||
public static CommandAPICommand commandHelp() {
|
||||
return new CommandAPICommand("help")
|
||||
.executesPlayer(RaidCommand::raidHelp);
|
||||
.executesPlayer(RaidCommand::raidHelp);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -213,7 +207,7 @@ public class RaidCommand {
|
||||
boolean townExists = false;
|
||||
|
||||
if (!(args.get("warname") instanceof final String argWarName))
|
||||
throw CommandAPIBukkit.failWithAdventureComponent(new ColorParser(Helper.chatLabel() + "&cYou need to specify a war name.").build());
|
||||
throw CommandAPIBukkit.failWithAdventureComponent(new ColorParser(Helper.chatLabel() + "&cUsage: /alathrawaradmin create raid [war] [raidTown] (gatherTown/\"defaultCode\") (owner) (override)").build());
|
||||
|
||||
for (final War war : WarData.getWars()) {
|
||||
if (war.getName().equalsIgnoreCase(argWarName)) {
|
||||
@@ -413,19 +407,19 @@ public class RaidCommand {
|
||||
|
||||
// Player participance check
|
||||
Town leaderTown = TownyAPI.getInstance().getResident(raidOwner).getTownOrNull();
|
||||
int sideR = war.getSide(leaderTown.getName().toLowerCase());
|
||||
if (sideR == 0) {
|
||||
TownWarState sideR = war.getState(leaderTown.getName().toLowerCase());
|
||||
if (sideR == TownWarState.NOT_PARTICIPANT) {
|
||||
if (admin) p.sendMessage(Helper.chatLabel() + "You are not in this war.");
|
||||
raidOwner.sendMessage(Helper.chatLabel() + "You are not in this war.");
|
||||
return;
|
||||
} else if (sideR == -1) {
|
||||
} else if (sideR == TownWarState.SURRENDERED) {
|
||||
if (admin) p.sendMessage(Helper.chatLabel() + "You have surrendered.");
|
||||
raidOwner.sendMessage(Helper.chatLabel() + "You have surrendered.");
|
||||
return;
|
||||
}
|
||||
|
||||
// Attacking own side
|
||||
if (war.getSide(raidedTown) == sideR) {
|
||||
if (war.getState(raidedTown) == sideR) {
|
||||
if (admin) p.sendMessage(Helper.chatLabel() + "You cannot attack your own towns.");
|
||||
raidOwner.sendMessage(Helper.chatLabel() + "You cannot attack your own towns.");
|
||||
return;
|
||||
@@ -451,12 +445,15 @@ public class RaidCommand {
|
||||
Bukkit.broadcastMessage(Helper.chatLabel() + "As part of " + war.getName() + ", forces from " + raid2.getRaiderSide() + " are gathering to raid the town of " + raidedTown.getName() + "!");
|
||||
Bukkit.broadcastMessage(Helper.chatLabel() + "All players from the defending side have been drafted for the town's defense.");
|
||||
Bukkit.broadcastMessage(Helper.chatLabel() + "The raid of "
|
||||
+ raidedTown.getName() + " will begin in " + (RaidPhase.TRAVEL.startTick / 20 / 60) + " minutes!");
|
||||
+ raidedTown.getName() + " will begin in " + (RaidPhase.TRAVEL.startTick / 20 / 60) + " minutes!");
|
||||
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.");
|
||||
if (admin) Main.warLogger.log(raidOwner.getName() + " started a raid from admin interference.");
|
||||
if (admin) {
|
||||
Main.warLogger.log(raidOwner.getName() + " started a raid from admin interference.");
|
||||
p.sendMessage(Helper.color("&cForcefully started raid from the console."));
|
||||
}
|
||||
Main.warLogger.log("As part of " + war.getName() + ", forces from " + raid2.getRaiderSide() + " are raiding the town of " + raidedTown.getName() + "!");
|
||||
Main.warLogger.log("The Raiders are gathering at " + gatherTown.getName() + " before making the journey over!");
|
||||
}
|
||||
@@ -492,7 +489,7 @@ public class RaidCommand {
|
||||
}
|
||||
|
||||
//find our desired raid and stop it
|
||||
Raid raid = RaidData.getRaidOrNull(argWarName + "-" + argTown);
|
||||
Raid raid = RaidData.getRaid(argWarName + "-" + argTown);
|
||||
|
||||
if (raid != null) {
|
||||
p.sendMessage(Helper.chatLabel() + "raid cancelled");
|
||||
@@ -504,101 +501,81 @@ public class RaidCommand {
|
||||
}
|
||||
|
||||
protected static void raidJoin(Player p, CommandArguments args, boolean admin) throws WrapperCommandSyntaxException {
|
||||
if (!(args.get("warname") instanceof final String argWarName))
|
||||
throw CommandAPIBukkit.failWithAdventureComponent(new ColorParser(Helper.chatLabel() + "&cYou need to specify a war name!").build());
|
||||
if (!(args.get("raidname") instanceof final String argRaidName))
|
||||
throw CommandAPIBukkit.failWithAdventureComponent(new ColorParser(Helper.chatLabel() + "&cYou need to specify a raid name!").build());
|
||||
|
||||
if (!(args.get("town") instanceof final String argTown))
|
||||
throw CommandAPIBukkit.failWithAdventureComponent(new ColorParser(Helper.chatLabel() + "&cYou need to specify a town name!").build());
|
||||
|
||||
//Grab raid!
|
||||
Raid raid = RaidData.getRaidOrNull(argWarName + "-" + argTown);
|
||||
if (!(args.get("side") instanceof final String argSide))
|
||||
throw CommandAPIBukkit.failWithAdventureComponent(new ColorParser(Helper.chatLabel() + "&cYou need to specify a side!").build());
|
||||
|
||||
final Raid raid = RaidData.getRaid(argRaidName);
|
||||
if (raid == null)
|
||||
throw CommandAPIBukkit.failWithAdventureComponent(new ColorParser(Helper.chatLabel() + "No raid is gathering in this town or this town does not exist!").build());
|
||||
throw CommandAPIBukkit.failWithAdventureComponent(new ColorParser(Helper.chatLabel() + "&cThat raid does not exist!").build());
|
||||
|
||||
if (raid.getWar().getName().equalsIgnoreCase(argWarName)) {
|
||||
final Player joiner = (Player) args.getOptional("player").orElse(p);
|
||||
final War war = raid.getWar();
|
||||
if (war == null)
|
||||
throw CommandAPIBukkit.failWithAdventureComponent(new ColorParser(Helper.chatLabel() + "&cThe war does not exist!").build());
|
||||
|
||||
if (joiner == null) {
|
||||
throw CommandAPIBukkit.failWithAdventureComponent(new ColorParser("Joiner is Null").build());
|
||||
}
|
||||
final Player joiner = (Player) args.getOptional("player").orElse(p);
|
||||
if (joiner == null)
|
||||
throw CommandAPIBukkit.failWithAdventureComponent(new ColorParser("Joiner is Null").build());
|
||||
|
||||
if (!(args.get("side") instanceof final String argSide))
|
||||
throw CommandAPIBukkit.failWithAdventureComponent(new ColorParser(Helper.chatLabel() + "&cYou need to specify a side!").build());
|
||||
|
||||
if (admin) {
|
||||
if (argSide != null) {
|
||||
if (argSide.equalsIgnoreCase(raid.getDefenderSide())) {
|
||||
if (!raid.getDefenderPlayers().contains(joiner.getName()))
|
||||
raid.getDefenderPlayers().add(joiner.getName());
|
||||
if (admin) {
|
||||
if (argSide != null) {
|
||||
if (argSide.equalsIgnoreCase(raid.getDefenderSide())) {
|
||||
if (!raid.getDefenderPlayers().contains(joiner.getName()))
|
||||
raid.getDefenderPlayers().add(joiner.getName());
|
||||
|
||||
p.sendMessage(Helper.chatLabel() + "Player " + joiner.getName() + " added to defender side.");
|
||||
Main.warLogger.log("Player " + joiner.getName() + " added to defender side.");
|
||||
joiner.sendMessage(Helper.chatLabel() + "You were forcefully added to the defender side against the raid party on " + raid.getRaidedTown() + " by an admin.");
|
||||
return;
|
||||
} else {
|
||||
if (!raid.getRaiderPlayers().contains(joiner.getName()))
|
||||
raid.getRaiderPlayers().add(joiner.getName());
|
||||
|
||||
p.sendMessage(Helper.chatLabel() + "Player " + joiner.getName() + " added to raider side.");
|
||||
Main.warLogger.log("Player " + joiner.getName() + " added to raider side.");
|
||||
joiner.sendMessage(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.");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (!raid.getWar().getSide1Players().contains(joiner.getName()) && !raid.getWar().getSide2Players().contains(joiner.getName())) {
|
||||
joiner.sendMessage(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
|
||||
//also 12 hours min platim by default
|
||||
int minuteman = CommandHelper.isPlayerMinuteman(joiner.getName());
|
||||
boolean minuteManOverride = (boolean) args.getOptional("minutemen").orElse(false);
|
||||
|
||||
if (minuteManOverride) {
|
||||
p.sendMessage(ChatColor.RED + "Warning! Ignoring Minuteman Countermeasure!");
|
||||
}
|
||||
|
||||
if (!minuteManOverride) {
|
||||
if (minuteman != 0) {
|
||||
if (minuteman == 1) {
|
||||
//player has joined to recently
|
||||
if (admin)
|
||||
p.sendMessage(ChatColor.RED + "You have joined the server too recently! You can only join a raid after " + Main.getInstance().getConfig().getInt("minimumPlayerAge") + " days from joining.");
|
||||
joiner.sendMessage(ChatColor.RED + "You have joined the server too recently! You can only join a raid after " + Main.getInstance().getConfig().getInt("minimumPlayerAge") + " days from joining.");
|
||||
return;
|
||||
} else if (minuteman == 2) {
|
||||
//player has played too little
|
||||
if (admin)
|
||||
p.sendMessage(ChatColor.RED + "You have not played enough! You can only join a raid after " + Main.getInstance().getConfig().getInt("minimumPlayTime") + " hours of play.");
|
||||
joiner.sendMessage(ChatColor.RED + "You have not played enough! You can only join a raid after " + Main.getInstance().getConfig().getInt("minimumPlayTime") + " hours of play.");
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//check if gather phase
|
||||
if (!admin) {
|
||||
if (raid.getPhase() == RaidPhase.GATHER || raid.getPhase() == RaidPhase.START) {
|
||||
try {
|
||||
//check if the player is in the gather town
|
||||
ArrayList<WorldCoord> cluster = Helper.getCluster(raid.getGatherTown().getHomeBlock().getWorldCoord());
|
||||
if (cluster.contains(WorldCoord.parseWorldCoord(joiner))) {
|
||||
raid.addActiveRaider(joiner.getName());
|
||||
joiner.sendMessage(Helper.chatLabel() + "You have joined the raid on " + raid.getRaidedTown().getName() + "!");
|
||||
joiner.sendMessage(Helper.chatLabel() + "Leaving " + raid.getGatherTown().getName() + " will cause you to leave the raid party.");
|
||||
} else {
|
||||
joiner.sendMessage(Helper.chatLabel() + "You must be in the gathering town to join the raid on " + raid.getRaidedTown().getName() + ".");
|
||||
}
|
||||
} catch (TownyException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
p.sendMessage(Helper.chatLabel() + "Player " + joiner.getName() + " added to defender side.");
|
||||
Main.warLogger.log("Player " + joiner.getName() + " added to defender side.");
|
||||
joiner.sendMessage(Helper.chatLabel() + "You were forcefully added to the defender side against the raid party on " + raid.getRaidedTown() + " by an admin.");
|
||||
return;
|
||||
} else {
|
||||
joiner.sendMessage(Helper.chatLabel() + "You cannot join the raid on " + raid.getRaidedTown().getName() + "! It has already started!");
|
||||
if (!raid.getRaiderPlayers().contains(joiner.getName()))
|
||||
raid.getRaiderPlayers().add(joiner.getName());
|
||||
|
||||
p.sendMessage(Helper.chatLabel() + "Player " + joiner.getName() + " added to raider side.");
|
||||
Main.warLogger.log("Player " + joiner.getName() + " added to raider side.");
|
||||
joiner.sendMessage(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 {
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (!raid.getWar().getSide1Players().contains(joiner.getName()) && !raid.getWar().getSide2Players().contains(joiner.getName())) {
|
||||
joiner.sendMessage(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
|
||||
//also 12 hours min platim by default
|
||||
int minuteman = CommandHelper.isPlayerMinuteman(joiner.getName());
|
||||
boolean minuteManOverride = (boolean) args.getOptional("minutemen").orElse(false);
|
||||
|
||||
if (minuteManOverride) {
|
||||
p.sendMessage(ChatColor.RED + "Warning! Ignoring Minuteman Countermeasure!");
|
||||
}
|
||||
|
||||
if (!minuteManOverride) {
|
||||
if (minuteman != 0) {
|
||||
if (minuteman == 1) {
|
||||
//player has joined to recently
|
||||
if (admin)
|
||||
p.sendMessage(ChatColor.RED + "You have joined the server too recently! You can only join a raid after " + Main.getInstance().getConfig().getInt("minimumPlayerAge") + " days from joining.");
|
||||
joiner.sendMessage(ChatColor.RED + "You have joined the server too recently! You can only join a raid after " + Main.getInstance().getConfig().getInt("minimumPlayerAge") + " days from joining.");
|
||||
return;
|
||||
} else if (minuteman == 2) {
|
||||
//player has played too little
|
||||
if (admin)
|
||||
p.sendMessage(ChatColor.RED + "You have not played enough! You can only join a raid after " + Main.getInstance().getConfig().getInt("minimumPlayTime") + " hours of play.");
|
||||
joiner.sendMessage(ChatColor.RED + "You have not played enough! You can only join a raid after " + Main.getInstance().getConfig().getInt("minimumPlayTime") + " hours of play.");
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//check if gather phase
|
||||
if (!admin) {
|
||||
if (raid.getPhase() == RaidPhase.GATHER || raid.getPhase() == RaidPhase.START) {
|
||||
try {
|
||||
//check if the player is in the gather town
|
||||
ArrayList<WorldCoord> cluster = Helper.getCluster(raid.getGatherTown().getHomeBlock().getWorldCoord());
|
||||
@@ -612,18 +589,34 @@ public class RaidCommand {
|
||||
} catch (TownyException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
} else {
|
||||
joiner.sendMessage(Helper.chatLabel() + "You cannot join the raid on " + raid.getRaidedTown().getName() + "! It has already started!");
|
||||
}
|
||||
} else {
|
||||
try {
|
||||
//check if the player is in the gather town
|
||||
ArrayList<WorldCoord> cluster = Helper.getCluster(raid.getGatherTown().getHomeBlock().getWorldCoord());
|
||||
if (cluster.contains(WorldCoord.parseWorldCoord(joiner))) {
|
||||
raid.addActiveRaider(joiner.getName());
|
||||
joiner.sendMessage(Helper.chatLabel() + "You have joined the raid on " + raid.getRaidedTown().getName() + "!");
|
||||
joiner.sendMessage(Helper.chatLabel() + "Leaving " + raid.getGatherTown().getName() + " will cause you to leave the raid party.");
|
||||
} else {
|
||||
joiner.sendMessage(Helper.chatLabel() + "You must be in the gathering town to join the raid on " + raid.getRaidedTown().getName() + ".");
|
||||
}
|
||||
} catch (TownyException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
|
||||
raid.save();
|
||||
}
|
||||
|
||||
raid.save();
|
||||
}
|
||||
|
||||
protected static void raidLeave(Player player, CommandArguments args, boolean admin) throws WrapperCommandSyntaxException {
|
||||
//Get raid!
|
||||
final Player p = (Player) args.getOptional("leader").orElse(player);
|
||||
final Player p = (Player) args.getOptional("player").orElse(player);
|
||||
|
||||
if (p == null) {
|
||||
throw CommandAPIBukkit.failWithAdventureComponent(new ColorParser("Raided is Null").build());
|
||||
throw CommandAPIBukkit.failWithAdventureComponent(new ColorParser("Raider is Null").build());
|
||||
}
|
||||
|
||||
if (!(args.get("warname") instanceof final String argWarName))
|
||||
@@ -633,7 +626,7 @@ public class RaidCommand {
|
||||
throw CommandAPIBukkit.failWithAdventureComponent(new ColorParser(Helper.chatLabel() + "&cYou need to specify a town name!").build());
|
||||
|
||||
|
||||
Raid raid = RaidData.getRaidOrNull(argWarName + "-" + argTown);
|
||||
Raid raid = RaidData.getRaid(argWarName + "-" + argTown);
|
||||
if (raid == null) {
|
||||
p.sendMessage(Helper.chatLabel() + "No raid is gathering in this town or this town does not exist!");
|
||||
if (admin)
|
||||
@@ -667,6 +660,11 @@ public class RaidCommand {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
if (admin) {
|
||||
player.sendMessage(Helper.chatLabel() + "Forced player " + p.getName() + " to leave raid on " + raid.getRaidedTown().getName() + " in war " + argWarName);
|
||||
Main.warLogger.log("Forced player " + p.getName() + " to leave raid on " + raid.getRaidedTown().getName() + " in war " + argWarName);
|
||||
}
|
||||
}
|
||||
|
||||
raid.save();
|
||||
@@ -687,7 +685,7 @@ public class RaidCommand {
|
||||
|
||||
|
||||
//Get raid
|
||||
Raid raid = RaidData.getRaidOrNull(argWarName + "-" + argTown);
|
||||
Raid raid = RaidData.getRaid(argWarName + "-" + argTown);
|
||||
|
||||
if (raid == null)
|
||||
throw CommandAPIBukkit.failWithAdventureComponent(new ColorParser(Helper.chatLabel() + "&cThis raid does not exist!").build());
|
||||
@@ -751,17 +749,17 @@ public class RaidCommand {
|
||||
private static void fail(CommandSender p, CommandArguments args, String type) throws WrapperCommandSyntaxException {
|
||||
switch (type) {
|
||||
case "permissions" ->
|
||||
throw CommandAPIBukkit.failWithAdventureComponent(new ColorParser(Helper.chatLabel() + "&cYou do not have permission to do this.").build());
|
||||
throw CommandAPIBukkit.failWithAdventureComponent(new ColorParser(Helper.chatLabel() + "&cYou do not have permission to do this.").build());
|
||||
case "syntax" ->
|
||||
throw CommandAPIBukkit.failWithAdventureComponent(new ColorParser(Helper.chatLabel() + "&cInvalid Syntax. /raid help").build());
|
||||
throw CommandAPIBukkit.failWithAdventureComponent(new ColorParser(Helper.chatLabel() + "&cInvalid Syntax. /raid help").build());
|
||||
case "noRaids" ->
|
||||
throw CommandAPIBukkit.failWithAdventureComponent(new ColorParser(Helper.chatLabel() + "&cThere are currently no Raids in progress.").build());
|
||||
throw CommandAPIBukkit.failWithAdventureComponent(new ColorParser(Helper.chatLabel() + "&cThere are currently no Raids in progress.").build());
|
||||
case "badName" ->
|
||||
throw CommandAPIBukkit.failWithAdventureComponent(new ColorParser(Helper.chatLabel() + "&cA raid could not be found with this Name! Type /raid list to view current raids.").build());
|
||||
throw CommandAPIBukkit.failWithAdventureComponent(new ColorParser(Helper.chatLabel() + "&cA raid could not be found with this Name! Type /raid list to view current raids.").build());
|
||||
case "owner" ->
|
||||
throw CommandAPIBukkit.failWithAdventureComponent(new ColorParser(Helper.chatLabel() + "&cOnly the player who started the raid can abandon it.").build());
|
||||
throw CommandAPIBukkit.failWithAdventureComponent(new ColorParser(Helper.chatLabel() + "&cOnly the player who started the raid can abandon it.").build());
|
||||
default ->
|
||||
throw CommandAPIBukkit.failWithAdventureComponent(new ColorParser(Helper.chatLabel() + "&cInvalid Arguments. /raid help").build());
|
||||
throw CommandAPIBukkit.failWithAdventureComponent(new ColorParser(Helper.chatLabel() + "&cInvalid Arguments. /raid help").build());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -15,6 +15,7 @@ import me.ShermansWorld.AlathraWar.*;
|
||||
import me.ShermansWorld.AlathraWar.data.RaidData;
|
||||
import me.ShermansWorld.AlathraWar.data.SiegeData;
|
||||
import me.ShermansWorld.AlathraWar.data.WarData;
|
||||
import me.ShermansWorld.AlathraWar.enums.TownWarState;
|
||||
import net.md_5.bungee.api.ChatColor;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
@@ -25,111 +26,109 @@ import java.util.HashSet;
|
||||
public class SiegeCommand {
|
||||
public SiegeCommand() {
|
||||
new CommandAPICommand("siege")
|
||||
.withSubcommands(
|
||||
commandStart(),
|
||||
commandStop(),
|
||||
commandAbandon(),
|
||||
commandList(),
|
||||
commandHelp()
|
||||
)
|
||||
.executesPlayer((sender, args) -> {
|
||||
if (args.count() == 0)
|
||||
throw CommandAPIBukkit.failWithAdventureComponent(new ColorParser(Helper.chatLabel() + "Invalid Arguments. /siege help").build());
|
||||
})
|
||||
.register();
|
||||
.withSubcommands(
|
||||
commandStart(),
|
||||
commandStop(),
|
||||
commandAbandon(),
|
||||
commandList(),
|
||||
commandHelp()
|
||||
)
|
||||
.executesPlayer((sender, args) -> {
|
||||
if (args.count() == 0)
|
||||
throw CommandAPIBukkit.failWithAdventureComponent(new ColorParser(Helper.chatLabel() + "Invalid Arguments. /siege help").build());
|
||||
})
|
||||
.register();
|
||||
}
|
||||
|
||||
public static CommandAPICommand commandStart() {
|
||||
return new CommandAPICommand("start")
|
||||
.withArguments(
|
||||
new StringArgument("warname")
|
||||
.replaceSuggestions(
|
||||
ArgumentSuggestions.strings(
|
||||
WarData.getWarsNames()
|
||||
)
|
||||
),
|
||||
new StringArgument("target")
|
||||
.replaceSuggestions(
|
||||
ArgumentSuggestions.stringCollection(info -> {
|
||||
final String warname = (String) info.previousArgs().get("warname");
|
||||
return CommandHelper.getTownyWarTowns(warname);
|
||||
})
|
||||
),
|
||||
new PlayerArgument("leader")
|
||||
.setOptional(true)
|
||||
.withPermission("AlathraWar.admin"),
|
||||
new BooleanArgument("minutemen")
|
||||
.setOptional(true)
|
||||
.withPermission("AlathraWar.admin")
|
||||
)
|
||||
.executesPlayer((Player p, CommandArguments args) -> siegeStart(p, args, false));
|
||||
.withArguments(
|
||||
new StringArgument("warname")
|
||||
.replaceSuggestions(
|
||||
ArgumentSuggestions.strings(
|
||||
WarData.getWarsNames()
|
||||
)
|
||||
),
|
||||
new StringArgument("town")
|
||||
.replaceSuggestions(
|
||||
ArgumentSuggestions.stringCollection(info -> {
|
||||
final String warname = (String) info.previousArgs().get("warname");
|
||||
return CommandHelper.getTownyWarTowns(warname);
|
||||
})
|
||||
),
|
||||
new PlayerArgument("leader")
|
||||
.setOptional(true)
|
||||
.withPermission("AlathraWar.admin"),
|
||||
new BooleanArgument("minutemen")
|
||||
.setOptional(true)
|
||||
.withPermission("AlathraWar.admin")
|
||||
)
|
||||
.executesPlayer((Player p, CommandArguments args) -> siegeStart(p, args, false));
|
||||
}
|
||||
|
||||
public static CommandAPICommand commandStop() {
|
||||
return new CommandAPICommand("stop")
|
||||
.withPermission("AlathraWar.admin")
|
||||
.withArguments(
|
||||
new StringArgument("warname")
|
||||
.replaceSuggestions(
|
||||
ArgumentSuggestions.stringCollection(info ->
|
||||
WarData.getWarsNames()
|
||||
)
|
||||
),
|
||||
new StringArgument("town")
|
||||
.replaceSuggestions(
|
||||
ArgumentSuggestions.stringCollection(info -> {
|
||||
final String warname = (String) info.previousArgs().get("warname");
|
||||
return CommandHelper.getTownyWarTowns(warname);
|
||||
})
|
||||
)
|
||||
)
|
||||
.executesPlayer(SiegeCommand::siegeStop);
|
||||
.withPermission("AlathraWar.admin")
|
||||
.withArguments(
|
||||
new StringArgument("warname")
|
||||
.replaceSuggestions(
|
||||
ArgumentSuggestions.stringCollection(info ->
|
||||
WarData.getWarsNames()
|
||||
)
|
||||
),
|
||||
new StringArgument("town")
|
||||
.replaceSuggestions(
|
||||
ArgumentSuggestions.stringCollection(info -> {
|
||||
final String warname = (String) info.previousArgs().get("warname");
|
||||
return CommandHelper.getTownyWarTowns(warname);
|
||||
})
|
||||
)
|
||||
)
|
||||
.executesPlayer(SiegeCommand::siegeStop);
|
||||
}
|
||||
|
||||
public static CommandAPICommand commandAbandon() {
|
||||
return new CommandAPICommand("abandon")
|
||||
.withArguments(
|
||||
new StringArgument("warname")
|
||||
.replaceSuggestions(
|
||||
ArgumentSuggestions.stringCollection(info ->
|
||||
WarData.getWarsNames()
|
||||
)
|
||||
),
|
||||
new StringArgument("town")
|
||||
.replaceSuggestions(
|
||||
ArgumentSuggestions.stringCollection(info -> {
|
||||
final String warname = (String) info.previousArgs().get("warname");
|
||||
return CommandHelper.getTownyWarTowns(warname);
|
||||
})
|
||||
)
|
||||
)
|
||||
.executesPlayer(SiegeCommand::siegeAbandon);
|
||||
.withArguments(
|
||||
new StringArgument("warname")
|
||||
.replaceSuggestions(
|
||||
ArgumentSuggestions.stringCollection(info ->
|
||||
WarData.getWarsNames()
|
||||
)
|
||||
),
|
||||
new StringArgument("town")
|
||||
.replaceSuggestions(
|
||||
ArgumentSuggestions.stringCollection(info -> {
|
||||
final String warname = (String) info.previousArgs().get("warname");
|
||||
return CommandHelper.getTownyWarTowns(warname);
|
||||
})
|
||||
)
|
||||
)
|
||||
.executesPlayer(SiegeCommand::siegeAbandon);
|
||||
}
|
||||
|
||||
public static CommandAPICommand commandList() {
|
||||
return new CommandAPICommand("list")
|
||||
.executesPlayer(SiegeCommand::siegeList);
|
||||
.executesPlayer(SiegeCommand::siegeList);
|
||||
}
|
||||
|
||||
public static CommandAPICommand commandHelp() {
|
||||
return new CommandAPICommand("help")
|
||||
.executesPlayer(SiegeCommand::siegeHelp);
|
||||
.executesPlayer(SiegeCommand::siegeHelp);
|
||||
}
|
||||
|
||||
|
||||
protected static void siegeStart(Player sender, CommandArguments args, boolean admin) throws WrapperCommandSyntaxException {
|
||||
// if (!(sender instanceof Player)) return;
|
||||
|
||||
if (!(args.get("warname") instanceof final String argWarName))
|
||||
throw CommandAPIBukkit.failWithAdventureComponent(new ColorParser(Helper.chatLabel() + "&cYou need to specify a war name.").build());
|
||||
throw CommandAPIBukkit.failWithAdventureComponent(new ColorParser(Helper.chatLabel() + "&cUsage: /alathrawaradmin create siege [war] [town] (owner) (force).").build());
|
||||
|
||||
//if this is admin mode use the forth arg instad of sender.
|
||||
//if player is null after this then force end
|
||||
final Player siegeOwner = (Player) args.getOptional("leader").orElse(sender);
|
||||
|
||||
if (siegeOwner == null) {
|
||||
throw CommandAPIBukkit.failWithAdventureComponent(new ColorParser("Owner is Null").build());
|
||||
}
|
||||
if (siegeOwner == null)
|
||||
throw CommandAPIBukkit.failWithAdventureComponent(new ColorParser("You need to pick a valid leader.").build());
|
||||
|
||||
|
||||
/*if (args.length < 3) {
|
||||
throw CommandAPIBukkit.failWithAdventureComponent(new ColorParser(Helper.chatLabel() + "/war siege [war] [town]").build());
|
||||
@@ -147,14 +146,15 @@ public class SiegeCommand {
|
||||
|
||||
// Player participance check
|
||||
Town leaderTown = TownyAPI.getInstance().getResident(siegeOwner).getTownOrNull();
|
||||
int side = war.getSide(leaderTown.getName().toLowerCase());
|
||||
TownWarState side = war.getState(leaderTown.getName().toLowerCase());
|
||||
|
||||
//DEBUG PRINT
|
||||
// TODO DEBUG PRINT
|
||||
Main.warLogger.log("Leader Town: " + leaderTown.getName());
|
||||
Main.warLogger.log("Siege Owner: " + siegeOwner.getName());
|
||||
sender.sendMessage("Leader Town: " + leaderTown.getName());
|
||||
sender.sendMessage("Siege Owner: " + siegeOwner.getName());
|
||||
//DEBUG PRINT
|
||||
// TODO DEBUG PRINT
|
||||
|
||||
for (String t : war.getSide1Towns()) {
|
||||
Main.warLogger.log("Side1 town: " + t);
|
||||
sender.sendMessage("Side1 town: " + t);
|
||||
@@ -164,11 +164,11 @@ public class SiegeCommand {
|
||||
sender.sendMessage("Side2 town: " + t);
|
||||
}
|
||||
|
||||
if (side == 0) {
|
||||
if (side == TownWarState.NOT_PARTICIPANT) {
|
||||
siegeOwner.sendMessage(Helper.chatLabel() + "You are not in this war.");
|
||||
if (admin) sender.sendMessage(Helper.chatLabel() + "You are not in this war.");
|
||||
return;
|
||||
} else if (side == -1) {
|
||||
} else if (side == TownWarState.SURRENDERED) {
|
||||
siegeOwner.sendMessage(Helper.chatLabel() + "You have surrendered.");
|
||||
if (admin) sender.sendMessage(Helper.chatLabel() + "You have surrendered.");
|
||||
return;
|
||||
@@ -202,7 +202,7 @@ public class SiegeCommand {
|
||||
}
|
||||
}
|
||||
|
||||
if (!(args.get("target") instanceof final String argTownName))
|
||||
if (!(args.get("town") instanceof final String argTownName))
|
||||
throw CommandAPIBukkit.failWithAdventureComponent(new ColorParser(Helper.chatLabel() + "Specify a town! /siege start [war] [town]").build());
|
||||
|
||||
// Town check
|
||||
@@ -213,8 +213,6 @@ public class SiegeCommand {
|
||||
sender.sendMessage(Helper.chatLabel() + "That town does not exist! /siege start [war] [town]");
|
||||
return;
|
||||
}
|
||||
Main.warLogger.log("Attacked Town: " + town.getName().toLowerCase());
|
||||
sender.sendMessage("Attacked Town: " + town.getName().toLowerCase());
|
||||
|
||||
// Is being raided check
|
||||
for (Raid r : RaidData.getRaids()) {
|
||||
@@ -227,7 +225,7 @@ public class SiegeCommand {
|
||||
}
|
||||
|
||||
// Attacking own side
|
||||
if (war.getSide(town) == side) {
|
||||
if (war.getState(town) == side) {
|
||||
siegeOwner.sendMessage(Helper.chatLabel() + "You cannot attack your own towns.");
|
||||
if (admin) sender.sendMessage(Helper.chatLabel() + "You cannot attack your own towns.");
|
||||
return;
|
||||
@@ -237,7 +235,14 @@ public class SiegeCommand {
|
||||
SiegeData.addSiege(siege);
|
||||
war.addSiege(siege);
|
||||
|
||||
Bukkit.broadcastMessage(Helper.chatLabel() + "A siege has been laid on " + siege.getTown() + " by " + siege.getAttackerSide() + "!");
|
||||
Bukkit.broadcastMessage(Helper.chatLabel() + siege.getTown() + " has been put to siege by " + siege.getAttackerSide() + "!");
|
||||
|
||||
if (admin)
|
||||
sender.sendMessage(Helper.color("&cForcefully started siege from the console."));
|
||||
|
||||
// TODO Debug logs...
|
||||
Main.warLogger.log("Attacked Town: " + town.getName().toLowerCase());
|
||||
sender.sendMessage("Attacked Town: " + town.getName().toLowerCase());
|
||||
|
||||
war.save();
|
||||
siege.start();
|
||||
@@ -319,7 +324,7 @@ public class SiegeCommand {
|
||||
sender.sendMessage(new ColorParser(Helper.chatLabel() + "Sieges currently in progress:").build());
|
||||
for (Siege siege : sieges) {
|
||||
War war = siege.getWar();
|
||||
String color = (siege.getSide1AreAttackers() && (war.getSide(siege.getTown().getName().toLowerCase()) == 1)) ? "&c" : "&9";
|
||||
String color = (siege.getSide1AreAttackers() && (war.getState(siege.getTown().getName().toLowerCase()) == TownWarState.SIDE1)) ? "&c" : "&9";
|
||||
sender.sendMessage(new ColorParser(war.getName() + " - " + color + siege.getTown().getName().toLowerCase()).build());
|
||||
sender.sendMessage(new ColorParser(war.getSide1() + " - " + (siege.getSide1AreAttackers() ? siege.getAttackerPoints() : siege.getDefenderPoints())).build());
|
||||
sender.sendMessage(new ColorParser(war.getSide2() + " - " + (siege.getSide1AreAttackers() ? siege.getDefenderPoints() : siege.getAttackerPoints())).build());
|
||||
|
||||
@@ -13,6 +13,7 @@ import dev.jorel.commandapi.exceptions.WrapperCommandSyntaxException;
|
||||
import dev.jorel.commandapi.executors.CommandArguments;
|
||||
import me.ShermansWorld.AlathraWar.*;
|
||||
import me.ShermansWorld.AlathraWar.data.WarData;
|
||||
import me.ShermansWorld.AlathraWar.enums.TownWarState;
|
||||
import net.md_5.bungee.api.ChatColor;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.command.CommandSender;
|
||||
@@ -26,126 +27,125 @@ import java.util.List;
|
||||
public class WarCommand {
|
||||
public WarCommand() {
|
||||
new CommandAPICommand("war")
|
||||
.withSubcommands(
|
||||
commandCreate(),
|
||||
commandDelete(),
|
||||
commandJoin(),
|
||||
commandSurrender(),
|
||||
commandList(),
|
||||
commandInfo(),
|
||||
commandHelp()
|
||||
)
|
||||
.executesPlayer((sender, args) -> {
|
||||
if (args.count() == 0)
|
||||
throw CommandAPIBukkit.failWithAdventureComponent(new ColorParser(Helper.chatLabel() + "Invalid Arguments. /war help").build());
|
||||
})
|
||||
.register();
|
||||
.withSubcommands(
|
||||
commandCreate(),
|
||||
commandDelete(),
|
||||
commandJoin(),
|
||||
commandSurrender(),
|
||||
commandList(),
|
||||
commandInfo(),
|
||||
commandHelp()
|
||||
)
|
||||
.executesPlayer((sender, args) -> {
|
||||
if (args.count() == 0)
|
||||
throw CommandAPIBukkit.failWithAdventureComponent(new ColorParser(Helper.chatLabel() + "Invalid Arguments. /war help").build());
|
||||
})
|
||||
.register();
|
||||
}
|
||||
|
||||
public static CommandAPICommand commandCreate() {
|
||||
return new CommandAPICommand("create")
|
||||
.withPermission("AlathraWar.admin")
|
||||
.withArguments(
|
||||
new StringArgument("warname"),
|
||||
new StringArgument("side1")
|
||||
.replaceSuggestions(
|
||||
ArgumentSuggestions.stringCollection(info -> {
|
||||
final List<String> nations = CommandHelper.getTownyNations();
|
||||
final List<String> towns = CommandHelper.getTownyTowns();
|
||||
.withPermission("AlathraWar.admin")
|
||||
.withArguments(
|
||||
new StringArgument("warname"),
|
||||
new StringArgument("side1")
|
||||
.replaceSuggestions(
|
||||
ArgumentSuggestions.stringCollection(info -> {
|
||||
final List<String> nations = CommandHelper.getTownyNations();
|
||||
final List<String> towns = CommandHelper.getTownyTowns();
|
||||
|
||||
Collections.sort(nations);
|
||||
Collections.sort(towns);
|
||||
Collections.sort(nations);
|
||||
Collections.sort(towns);
|
||||
|
||||
nations.addAll(towns);
|
||||
nations.addAll(towns);
|
||||
|
||||
return nations;
|
||||
})
|
||||
),
|
||||
new StringArgument("side2")
|
||||
.replaceSuggestions(
|
||||
ArgumentSuggestions.stringCollection(info -> {
|
||||
final List<String> nations = CommandHelper.getTownyNations();
|
||||
final List<String> towns = CommandHelper.getTownyTowns();
|
||||
return nations;
|
||||
})
|
||||
),
|
||||
new StringArgument("side2")
|
||||
.replaceSuggestions(
|
||||
ArgumentSuggestions.stringCollection(info -> {
|
||||
final List<String> nations = CommandHelper.getTownyNations();
|
||||
final List<String> towns = CommandHelper.getTownyTowns();
|
||||
|
||||
Collections.sort(nations);
|
||||
Collections.sort(towns);
|
||||
Collections.sort(nations);
|
||||
Collections.sort(towns);
|
||||
|
||||
nations.addAll(towns);
|
||||
nations.addAll(towns);
|
||||
|
||||
return nations;
|
||||
})
|
||||
)
|
||||
)
|
||||
.executesPlayer(WarCommand::warCreate);
|
||||
return nations;
|
||||
})
|
||||
)
|
||||
)
|
||||
.executesPlayer(WarCommand::warCreate);
|
||||
}
|
||||
|
||||
public static CommandAPICommand commandDelete() {
|
||||
return new CommandAPICommand("delete")
|
||||
.withPermission("AlathraWar.admin")
|
||||
.withArguments(
|
||||
new StringArgument("warname")
|
||||
.replaceSuggestions(
|
||||
ArgumentSuggestions.stringCollection(info -> WarData.getWarsNames())
|
||||
)
|
||||
)
|
||||
.executesPlayer(WarCommand::warDelete);
|
||||
.withPermission("AlathraWar.admin")
|
||||
.withArguments(
|
||||
new StringArgument("warname")
|
||||
.replaceSuggestions(
|
||||
ArgumentSuggestions.stringCollection(info -> WarData.getWarsNames())
|
||||
)
|
||||
)
|
||||
.executesPlayer(WarCommand::warDelete);
|
||||
}
|
||||
|
||||
public static CommandAPICommand commandJoin() {
|
||||
return new CommandAPICommand("join")
|
||||
.withArguments(
|
||||
new StringArgument("warname")
|
||||
.replaceSuggestions(
|
||||
ArgumentSuggestions.stringCollection(info -> CommandHelper.getWarNames())
|
||||
),
|
||||
new StringArgument("side")
|
||||
.replaceSuggestions(
|
||||
ArgumentSuggestions.stringCollection(info -> {
|
||||
String warName = (String) info.previousArgs().get("warname");
|
||||
.withArguments(
|
||||
new StringArgument("warname")
|
||||
.replaceSuggestions(
|
||||
ArgumentSuggestions.stringCollection(info -> CommandHelper.getWarNames())
|
||||
),
|
||||
new StringArgument("side")
|
||||
.replaceSuggestions(
|
||||
ArgumentSuggestions.stringCollection(info -> {
|
||||
final String warname = (String) info.previousArgs().get("warname");
|
||||
|
||||
War war = WarData.getWar(warName);
|
||||
if (war != null) {
|
||||
return war.getSides();
|
||||
}
|
||||
final War war = WarData.getWar(warname);
|
||||
|
||||
return Collections.emptyList();
|
||||
})
|
||||
),
|
||||
new PlayerArgument("player").setOptional(true).withPermission("AlathraWar.admin")
|
||||
)
|
||||
.executesPlayer((Player p, CommandArguments args) -> warJoin(p, args, false));
|
||||
if (war == null) return Collections.emptyList();
|
||||
|
||||
return war.getSides();
|
||||
})
|
||||
),
|
||||
new PlayerArgument("player").setOptional(true).withPermission("AlathraWar.admin")
|
||||
)
|
||||
.executesPlayer((Player p, CommandArguments args) -> warJoin(p, args, false));
|
||||
}
|
||||
|
||||
public static CommandAPICommand commandSurrender() {
|
||||
return new CommandAPICommand("surrender")
|
||||
.withArguments(
|
||||
new StringArgument("warname")
|
||||
.replaceSuggestions(
|
||||
ArgumentSuggestions.stringCollection(info -> CommandHelper.getWarNames())
|
||||
),
|
||||
new PlayerArgument("player")
|
||||
.setOptional(true)
|
||||
.withPermission("AlathraWar.admin")
|
||||
)
|
||||
.executesPlayer((Player p, CommandArguments args) -> warSurrender(p, args, false));
|
||||
.withArguments(
|
||||
new StringArgument("warname")
|
||||
.replaceSuggestions(
|
||||
ArgumentSuggestions.stringCollection(info -> CommandHelper.getWarNames())
|
||||
),
|
||||
new PlayerArgument("player")
|
||||
.setOptional(true)
|
||||
.withPermission("AlathraWar.admin")
|
||||
)
|
||||
.executesPlayer((Player p, CommandArguments args) -> warSurrender(p, args, false));
|
||||
}
|
||||
|
||||
public static CommandAPICommand commandList() {
|
||||
return new CommandAPICommand("list")
|
||||
.executesPlayer(WarCommand::warList);
|
||||
.executesPlayer(WarCommand::warList);
|
||||
}
|
||||
|
||||
public static CommandAPICommand commandInfo() {
|
||||
return new CommandAPICommand("info")
|
||||
.withArguments(
|
||||
new PlayerArgument("player")
|
||||
)
|
||||
.executesPlayer(WarCommand::warInfo);
|
||||
.withArguments(
|
||||
new PlayerArgument("player")
|
||||
)
|
||||
.executesPlayer(WarCommand::warInfo);
|
||||
}
|
||||
|
||||
public static CommandAPICommand commandHelp() {
|
||||
return new CommandAPICommand("help")
|
||||
.executesPlayer(WarCommand::warHelp);
|
||||
.executesPlayer(WarCommand::warHelp);
|
||||
}
|
||||
|
||||
protected static void warCreate(CommandSender p, CommandArguments args) throws WrapperCommandSyntaxException {
|
||||
@@ -175,12 +175,12 @@ public class WarCommand {
|
||||
war.save();
|
||||
|
||||
Bukkit.broadcastMessage(Helper.chatLabel() + "War created with the name " + argWarName + ", "
|
||||
+ argSide1 + " vs. " + argSide2);
|
||||
+ argSide1 + " vs. " + argSide2);
|
||||
Main.warLogger.log(p.getName() + " created a new war with the name " + argWarName + ", " + argSide1
|
||||
+ " vs. " + argSide2);
|
||||
+ " vs. " + argSide2);
|
||||
} else {
|
||||
throw CommandAPIBukkit.failWithAdventureComponent(new ColorParser(Helper.chatLabel()
|
||||
+ "Invalid Arguments. /war create [name] [side1] [side2]").build());
|
||||
+ "Invalid Arguments. /war create [name] [side1] [side2]").build());
|
||||
}
|
||||
|
||||
}
|
||||
@@ -208,7 +208,7 @@ public class WarCommand {
|
||||
Main.warLogger.log(p.getName() + " deleted " + argWarName);
|
||||
} else {
|
||||
throw CommandAPIBukkit.failWithAdventureComponent(new ColorParser(Helper.chatLabel()
|
||||
+ "Invalid Arguments. /war delete [name]").build());
|
||||
+ "Invalid Arguments. /war delete [name]").build());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -221,7 +221,7 @@ public class WarCommand {
|
||||
// Sufficient args check
|
||||
if (args.count() < 2)
|
||||
throw CommandAPIBukkit.failWithAdventureComponent(new ColorParser(Helper.chatLabel()
|
||||
+ "/war join [name] [side], type /war list to view current wars").build());
|
||||
+ "/war join [name] [side], type /war list to view current wars").build());
|
||||
|
||||
if (!(args.get("warname") instanceof final String argWarName))
|
||||
throw CommandAPIBukkit.failWithAdventureComponent(new ColorParser(Helper.chatLabel() + "&cYou need to specify a war name.").build());
|
||||
@@ -234,6 +234,9 @@ public class WarCommand {
|
||||
if (!(args.get("side") instanceof final String argSide))
|
||||
throw CommandAPIBukkit.failWithAdventureComponent(new ColorParser(Helper.chatLabel() + "&cYou need to specify a side.").build());
|
||||
|
||||
if (!war.isSideValid(argSide))
|
||||
throw CommandAPIBukkit.failWithAdventureComponent(new ColorParser(Helper.chatLabel() + "&cThat side does not exist in that war.").build());
|
||||
|
||||
if (!(args.getOptional("player").orElse(null) instanceof @Nullable Player argPlayer))
|
||||
throw CommandAPIBukkit.failWithAdventureComponent(new ColorParser(Helper.chatLabel() + "&cPlayer not found.").build());
|
||||
|
||||
@@ -278,11 +281,11 @@ public class WarCommand {
|
||||
}
|
||||
|
||||
// Side checks
|
||||
final int side = war.getSide(town.getName().toLowerCase());
|
||||
if (side == -1) {
|
||||
final TownWarState side = war.getState(town.getName().toLowerCase());
|
||||
if (side == TownWarState.SURRENDERED) {
|
||||
argPlayer.sendMessage(Helper.chatLabel() + "You've already surrendered!");
|
||||
return;
|
||||
} else if (side > 0) {
|
||||
} else if (side != TownWarState.NOT_PARTICIPANT) {
|
||||
argPlayer.sendMessage(Helper.chatLabel() + "You're already in this war!");
|
||||
return;
|
||||
}
|
||||
@@ -318,7 +321,7 @@ public class WarCommand {
|
||||
// Sufficient args check
|
||||
if (args.count() < 1) {
|
||||
throw CommandAPIBukkit.failWithAdventureComponent(new ColorParser(Helper.chatLabel()
|
||||
+ "/war surrender [name], type /war list to view current wars").build());
|
||||
+ "/war surrender [name], type /war list to view current wars").build());
|
||||
}
|
||||
|
||||
if (!(args.get("warname") instanceof final String argWarName))
|
||||
@@ -328,7 +331,7 @@ public class WarCommand {
|
||||
War war = WarData.getWar(argWarName);
|
||||
if (war == null) {
|
||||
throw CommandAPIBukkit.failWithAdventureComponent(new ColorParser(Helper.chatLabel()
|
||||
+ "War not found. Type /war list to view current wars").build());
|
||||
+ "War not found. Type /war list to view current wars").build());
|
||||
}
|
||||
|
||||
if (!(args.get("reason") instanceof final String argReason))
|
||||
@@ -405,13 +408,13 @@ public class WarCommand {
|
||||
|
||||
p.sendMessage(new ColorParser(Helper.chatLabel() + p.getName() + "'s wars:").build());
|
||||
for (War war : WarData.getWars()) {
|
||||
int side = war.getSide(res.getTownOrNull());
|
||||
if (side != 0) {
|
||||
if (side == -1) {
|
||||
TownWarState side = war.getState(res.getTownOrNull());
|
||||
if (side != TownWarState.NOT_PARTICIPANT) {
|
||||
if (side == TownWarState.SURRENDERED) {
|
||||
p.sendMessage(war.getName() + " - Surrendered");
|
||||
} else if (side == 1) {
|
||||
} else if (side == TownWarState.SIDE1) {
|
||||
p.sendMessage(war.getName() + " - " + war.getSide1());
|
||||
} else if (side == 2) {
|
||||
} else if (side == TownWarState.SIDE2) {
|
||||
p.sendMessage(war.getName() + " - " + war.getSide2());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -38,7 +38,7 @@ public class RaidData {
|
||||
* @param name - Name to check
|
||||
* @return Raid or Null
|
||||
*/
|
||||
public static @Nullable Raid getRaidOrNull(String name) {
|
||||
public static @Nullable Raid getRaid(String name) {
|
||||
for (Raid raid : raids) {
|
||||
if (raid.getName().equalsIgnoreCase(name)) return raid;
|
||||
}
|
||||
|
||||
@@ -111,8 +111,8 @@ public class WarData {
|
||||
public static War fromMap(HashMap<String, Object> fileData) {
|
||||
|
||||
War war = new War((String) fileData.get("name"),
|
||||
(String) fileData.get("side1"),
|
||||
(String) fileData.get("side2")
|
||||
(String) fileData.get("side1"),
|
||||
(String) fileData.get("side2")
|
||||
);
|
||||
|
||||
war.setSide1Towns((ArrayList<String>) fileData.get("side1Towns"));
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
package me.ShermansWorld.AlathraWar.enums;
|
||||
|
||||
public enum AdminCommandFailEnum {
|
||||
PERMISSIONS,
|
||||
SYNTAX,
|
||||
HELP
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
package me.ShermansWorld.AlathraWar.enums;
|
||||
|
||||
public enum TownWarState {
|
||||
NOT_PARTICIPANT,
|
||||
SURRENDERED,
|
||||
SIDE1,
|
||||
SIDE2,
|
||||
}
|
||||
@@ -2,8 +2,11 @@ package me.ShermansWorld.AlathraWar.hooks;
|
||||
|
||||
import me.ShermansWorld.AlathraWar.Helper;
|
||||
import me.ShermansWorld.AlathraWar.War;
|
||||
import me.ShermansWorld.AlathraWar.listeners.JoinListener;
|
||||
import me.neznamy.tab.api.TabAPI;
|
||||
import me.neznamy.tab.api.TabPlayer;
|
||||
import me.neznamy.tab.api.event.EventBus;
|
||||
import me.neznamy.tab.api.event.player.PlayerLoadEvent;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.entity.Player;
|
||||
@@ -17,6 +20,21 @@ public class TABHook {
|
||||
|
||||
tabAPI = TabAPI.getInstance();
|
||||
enabled = true;
|
||||
|
||||
registerPlayerLoadListener();
|
||||
}
|
||||
|
||||
private static void registerPlayerLoadListener() {
|
||||
if (!enabled) return;
|
||||
|
||||
EventBus eventBus = tabAPI.getEventBus();
|
||||
if (eventBus == null) return;
|
||||
|
||||
eventBus.register(PlayerLoadEvent.class, e -> {
|
||||
TabPlayer tabPlayer = e.getPlayer();
|
||||
if (tabPlayer.getPlayer() instanceof Player p)
|
||||
JoinListener.checkPlayer(p);
|
||||
});
|
||||
}
|
||||
|
||||
public static void assignSide1WarSuffix(Player p, War war) {
|
||||
@@ -27,7 +45,7 @@ public class TABHook {
|
||||
if (tabAPI.getTabListFormatManager() == null) return;
|
||||
|
||||
tabAPI.getTabListFormatManager().setSuffix(tabPlayer,
|
||||
Helper.color(" &c[") + war.getSide1() + "]&r");
|
||||
Helper.color(" &c[") + war.getSide1() + "]&r");
|
||||
}
|
||||
|
||||
public static void assignSide2WarSuffix(Player p, War war) {
|
||||
@@ -38,7 +56,7 @@ public class TABHook {
|
||||
if (tabAPI.getTabListFormatManager() == null) return;
|
||||
|
||||
tabAPI.getTabListFormatManager().setSuffix(tabPlayer,
|
||||
Helper.color(" &9[") + war.getSide2() + "]&r");
|
||||
Helper.color(" &9[") + war.getSide2() + "]&r");
|
||||
}
|
||||
|
||||
public static void assignSide1WarSuffixMerc(Player p, War war) {
|
||||
@@ -49,7 +67,7 @@ public class TABHook {
|
||||
if (tabAPI.getTabListFormatManager() == null) return;
|
||||
|
||||
tabAPI.getTabListFormatManager().setSuffix(tabPlayer,
|
||||
Helper.color(" &a[M]&c[") + war.getSide1() + "]&r");
|
||||
Helper.color(" &a[M]&c[") + war.getSide1() + "]&r");
|
||||
}
|
||||
|
||||
public static void assignSide2WarSuffixMerc(Player p, War war) {
|
||||
@@ -60,7 +78,7 @@ public class TABHook {
|
||||
if (tabAPI.getTabListFormatManager() == null) return;
|
||||
|
||||
tabAPI.getTabListFormatManager().setSuffix(tabPlayer,
|
||||
Helper.color(" &a[M]&9[") + war.getSide2() + "]&r");
|
||||
Helper.color(" &a[M]&9[") + war.getSide2() + "]&r");
|
||||
}
|
||||
|
||||
public static void resetSuffix(Player p) {
|
||||
|
||||
@@ -47,11 +47,11 @@ public class WarItemRegistry {
|
||||
|
||||
public Map<String, ItemStack> getItemRegistry() {
|
||||
return itemRegistry.entrySet()
|
||||
.stream()
|
||||
.filter(v -> v.getValue() != null)
|
||||
.collect(Collectors.toMap(
|
||||
Map.Entry::getKey,
|
||||
v -> v.getValue().getItemStack()));
|
||||
.stream()
|
||||
.filter(v -> v.getValue() != null)
|
||||
.collect(Collectors.toMap(
|
||||
Map.Entry::getKey,
|
||||
v -> v.getValue().getItemStack()));
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -14,33 +14,33 @@ import org.bukkit.event.player.PlayerCommandPreprocessEvent;
|
||||
public class CommandsListener implements Listener {
|
||||
|
||||
final static String[] prefixes = new String[]{
|
||||
"", "towny", "essentials", "wild", "minecraft"
|
||||
"", "towny", "essentials", "wild", "minecraft"
|
||||
};
|
||||
final static String[] prefixesTowny = new String[]{
|
||||
"", "towny"
|
||||
"", "towny"
|
||||
};
|
||||
final static String[] blacklistedXLong = new String[]{
|
||||
"n set spawn", "nat set spawn", "nation set spawn",
|
||||
"t set spawn", "town set spawn",
|
||||
"t set homeblock", "town set homeblock",
|
||||
"t set name", "town set name",
|
||||
"n set name", "nat set name", "nation set name"
|
||||
"n set spawn", "nat set spawn", "nation set spawn",
|
||||
"t set spawn", "town set spawn",
|
||||
"t set homeblock", "town set homeblock",
|
||||
"t set name", "town set name",
|
||||
"n set name", "nat set name", "nation set name"
|
||||
};
|
||||
final static String[] blacklistedLong = new String[]{
|
||||
"n spawn", "nat spawn", "nation spawn",
|
||||
"t spawn", "town spawn",
|
||||
"t outpost", "town outpost"
|
||||
"n spawn", "nat spawn", "nation spawn",
|
||||
"t spawn", "town spawn",
|
||||
"t outpost", "town outpost"
|
||||
};
|
||||
final static String[] payment = new String[]{
|
||||
"n withdraw", "nat withdraw", "nation withdraw",
|
||||
"t withdraw", "town withdraw"
|
||||
"n withdraw", "nat withdraw", "nation withdraw",
|
||||
"t withdraw", "town withdraw"
|
||||
};
|
||||
final static String[] blacklistedShort = new String[]{
|
||||
"home", "homes", "warp", "warps",
|
||||
"wild", "rtp", "spawn", "wilderness", "wildtp",
|
||||
"tpa", "tpahere", "tpaccept", "tpacancel",
|
||||
"etpa", "etpahere", "etpaccept", "etpacancel",
|
||||
"ehome", "ehomes", "ewarp", "ewarps"
|
||||
"home", "homes", "warp", "warps",
|
||||
"wild", "rtp", "spawn", "wilderness", "wildtp",
|
||||
"tpa", "tpahere", "tpaccept", "tpacancel",
|
||||
"etpa", "etpahere", "etpaccept", "etpacancel",
|
||||
"ehome", "ehomes", "ewarp", "ewarps"
|
||||
|
||||
};
|
||||
|
||||
@@ -101,9 +101,9 @@ public class CommandsListener implements Listener {
|
||||
//check if in spawn
|
||||
if (p.getWorld().getName().equalsIgnoreCase("world")) {
|
||||
if (parse.equalsIgnoreCase("n spawn") || parse.equalsIgnoreCase("nat spawn") || parse.equalsIgnoreCase("nation spawn")
|
||||
|| parse.equalsIgnoreCase("t spawn") || parse.equalsIgnoreCase("town spawn")
|
||||
|| parse.equalsIgnoreCase("towny:n spawn") || parse.equalsIgnoreCase("towny:nat spawn") || parse.equalsIgnoreCase("towny:nation spawn")
|
||||
|| parse.equalsIgnoreCase("towny:t spawn") || parse.equalsIgnoreCase("towny:town spawn")) {
|
||||
|| parse.equalsIgnoreCase("t spawn") || parse.equalsIgnoreCase("town spawn")
|
||||
|| parse.equalsIgnoreCase("towny:n spawn") || parse.equalsIgnoreCase("towny:nat spawn") || parse.equalsIgnoreCase("towny:nation spawn")
|
||||
|| parse.equalsIgnoreCase("towny:t spawn") || parse.equalsIgnoreCase("towny:town spawn")) {
|
||||
p.sendMessage(Helper.chatLabel() + Helper.color("&eYou are stuck in spawn and are allowed to teleport to your town or nation."));
|
||||
return;
|
||||
}
|
||||
@@ -191,9 +191,9 @@ public class CommandsListener implements Listener {
|
||||
//check if in spawn
|
||||
if (p.getWorld().getName().equalsIgnoreCase("world")) {
|
||||
if (parse.equalsIgnoreCase("n spawn") || parse.equalsIgnoreCase("nat spawn") || parse.equalsIgnoreCase("nation spawn")
|
||||
|| parse.equalsIgnoreCase("t spawn") || parse.equalsIgnoreCase("town spawn")
|
||||
|| parse.equalsIgnoreCase("towny:n spawn") || parse.equalsIgnoreCase("towny:nat spawn") || parse.equalsIgnoreCase("towny:nation spawn")
|
||||
|| parse.equalsIgnoreCase("towny:t spawn") || parse.equalsIgnoreCase("towny:town spawn")) {
|
||||
|| parse.equalsIgnoreCase("t spawn") || parse.equalsIgnoreCase("town spawn")
|
||||
|| parse.equalsIgnoreCase("towny:n spawn") || parse.equalsIgnoreCase("towny:nat spawn") || parse.equalsIgnoreCase("towny:nation spawn")
|
||||
|| parse.equalsIgnoreCase("towny:t spawn") || parse.equalsIgnoreCase("towny:town spawn")) {
|
||||
p.sendMessage(Helper.chatLabel() + Helper.color("&eYou are stuck in spawn and are allowed to teleport to your town or nation."));
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -1,12 +1,11 @@
|
||||
package me.ShermansWorld.AlathraWar.listeners;
|
||||
|
||||
import com.palmergames.bukkit.towny.TownyAPI;
|
||||
import com.palmergames.bukkit.towny.object.Resident;
|
||||
import com.palmergames.bukkit.towny.object.Town;
|
||||
import me.ShermansWorld.AlathraWar.Main;
|
||||
import me.ShermansWorld.AlathraWar.War;
|
||||
import me.ShermansWorld.AlathraWar.data.WarData;
|
||||
import me.ShermansWorld.AlathraWar.hooks.TABHook;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
@@ -14,10 +13,15 @@ import org.bukkit.event.player.PlayerJoinEvent;
|
||||
|
||||
public class JoinListener implements Listener {
|
||||
public static void checkPlayer(Player p) {
|
||||
Town town = TownyAPI.getInstance().getResident(p).getTownOrNull();
|
||||
Resident resident = TownyAPI.getInstance().getResident(p);
|
||||
if (resident == null) return;
|
||||
|
||||
Town town = resident.getTownOrNull();
|
||||
if (town == null) return;
|
||||
|
||||
String townName = town.getName();
|
||||
boolean inWar = false;
|
||||
|
||||
for (final War war : WarData.getWars()) {
|
||||
if (war.getSide1Towns().contains(townName.toLowerCase())) {
|
||||
TABHook.assignSide1WarSuffix(p, war);
|
||||
@@ -27,6 +31,7 @@ public class JoinListener implements Listener {
|
||||
inWar = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (!inWar) {
|
||||
TABHook.resetPrefix(p);
|
||||
}
|
||||
@@ -35,6 +40,5 @@ public class JoinListener implements Listener {
|
||||
@EventHandler
|
||||
public void onPlayerJoin(final PlayerJoinEvent event) {
|
||||
final Player p = event.getPlayer();
|
||||
Bukkit.getScheduler().scheduleSyncDelayedTask(Main.getInstance(), () -> checkPlayer(p), 60L); // 20 Tick (1 Second) delay before run() is called
|
||||
}
|
||||
}
|
||||
@@ -23,7 +23,7 @@ import java.util.UUID;
|
||||
|
||||
public final class KillsListener implements Listener {
|
||||
|
||||
public static final HashMap<UUID, Raid> respawnqueue = new HashMap<>();
|
||||
public static final HashMap<UUID, Raid> respawnQueue = new HashMap<>();
|
||||
|
||||
@EventHandler
|
||||
public void onPlayerKilled(final PlayerDeathEvent event) {
|
||||
@@ -71,20 +71,20 @@ public final class KillsListener implements Listener {
|
||||
if (raid.getDefenderPlayers().contains(killer.getName())) {
|
||||
this.raidKill(killed, event);
|
||||
raid.raiderKilledInCombat(event);
|
||||
respawnqueue.put(killed.getUniqueId(), raid);
|
||||
respawnQueue.put(killed.getUniqueId(), raid);
|
||||
return;
|
||||
}
|
||||
} else if (raid.getPhase() != RaidPhase.COMBAT && killer != null) {
|
||||
this.oocKill(killed, event);
|
||||
raid.raiderKilledOutofCombat(event);
|
||||
respawnqueue.put(killed.getUniqueId(), raid);
|
||||
respawnQueue.put(killed.getUniqueId(), raid);
|
||||
return;
|
||||
}
|
||||
//teleport back to gather town spawn, without damaged gear
|
||||
//this is to disincentive people prekilling
|
||||
this.oocKill(killed, event);
|
||||
raid.raiderKilledOutofCombat(event);
|
||||
respawnqueue.put(killed.getUniqueId(), raid);
|
||||
respawnQueue.put(killed.getUniqueId(), raid);
|
||||
return;
|
||||
}
|
||||
if ((town != null && town.equals(raid.getRaidedTown()) || playerCloseToHomeBlockRaid)) {
|
||||
@@ -169,8 +169,8 @@ public final class KillsListener implements Listener {
|
||||
*/
|
||||
@EventHandler(priority = EventPriority.HIGHEST)
|
||||
public void onRespawn(PlayerRespawnEvent event) {
|
||||
if (respawnqueue.containsKey(event.getPlayer().getUniqueId())) {
|
||||
Raid raid = respawnqueue.get(event.getPlayer().getUniqueId());
|
||||
if (respawnQueue.containsKey(event.getPlayer().getUniqueId())) {
|
||||
Raid raid = respawnQueue.get(event.getPlayer().getUniqueId());
|
||||
if (raid == null) return;
|
||||
if (raid.getActiveRaiders().contains(event.getPlayer().getName())) {
|
||||
//do raider respawn
|
||||
@@ -185,7 +185,7 @@ public final class KillsListener implements Listener {
|
||||
} else {
|
||||
//invalid code
|
||||
}
|
||||
respawnqueue.remove(event.getPlayer().getUniqueId());
|
||||
respawnQueue.remove(event.getPlayer().getUniqueId());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
package me.ShermansWorld.AlathraWar.listeners;
|
||||
|
||||
import com.palmergames.bukkit.towny.event.nation.NationKingChangeEvent;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
|
||||
public class NationListener implements Listener {
|
||||
/*
|
||||
* NationPreTownLeaveEvent, NationPreTownKickEvent, NationPreMergeEvent
|
||||
*
|
||||
* NationKingChangeEvent
|
||||
* NationPreRenameEvent
|
||||
*
|
||||
*
|
||||
*
|
||||
* */
|
||||
|
||||
// TODO Prevent nation rename during war, siege, raid
|
||||
|
||||
@EventHandler
|
||||
private void onNationKingChange(NationKingChangeEvent e) {
|
||||
e.setCancelMessage("");
|
||||
e.setCancelled(true);
|
||||
}
|
||||
}
|
||||
@@ -153,10 +153,10 @@ public class PlayerInteractListener implements Listener {
|
||||
if (item.equals(WarItemRegistry.getInstance().getOrNull("ram"))) {
|
||||
if (clicked != null) {
|
||||
if (clicked.getType().name().equals("GRASS_BLOCK")
|
||||
|| clicked.getType().name().equals("DIRT")
|
||||
|| clicked.getType().name().equals("COARSE_DIRT")
|
||||
|| clicked.getType().name().equals("ROOTED_DIRT")
|
||||
|| clicked.getType().name().equals("DIRT_PATH")) {
|
||||
|| clicked.getType().name().equals("DIRT")
|
||||
|| clicked.getType().name().equals("COARSE_DIRT")
|
||||
|| clicked.getType().name().equals("ROOTED_DIRT")
|
||||
|| clicked.getType().name().equals("DIRT_PATH")) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
package me.ShermansWorld.AlathraWar.listeners;
|
||||
|
||||
import org.bukkit.event.Listener;
|
||||
|
||||
public class TownListener implements Listener {
|
||||
// TODO On town ruin, bow town out of any active wars, if leader of war surrender
|
||||
// TODO On town ruin, leave or cancel sieges where the town is present
|
||||
// TODO On town ruin, leave or cancel raids where the town is present
|
||||
// TODO Prevent town rename during war, siege, raid
|
||||
|
||||
/*
|
||||
TownMayorChangeEvent
|
||||
TownLeaveEvent
|
||||
TownPreMergeEvent
|
||||
TownPreRuinedEvent
|
||||
TownPreRenameEvent
|
||||
TownRemoveResidentEvent
|
||||
*/
|
||||
}
|
||||
Reference in new issue
Block a user