mirror of
https://github.com/darksaid98/AlathranWars.git
synced 2026-12-01 14:38:55 +00:00
Raid Commands Creation
This commit is contained in:
1 parent
d1a46ba2e0
commit
e65bae6f67
3 files changed
+190
-52
No files matched your search
@@ -54,7 +54,8 @@ TODO LIST:
|
||||
public class Raid {
|
||||
|
||||
private War war;
|
||||
private Town town;
|
||||
private Town raidedTown;
|
||||
private Town gatherTown;
|
||||
private String raiders;
|
||||
private String defenders;
|
||||
private boolean side1AreRaiders;
|
||||
@@ -64,23 +65,28 @@ public class Raid {
|
||||
private int MAXRAIDTICKS;
|
||||
private Player owner;
|
||||
private int raidTicks;
|
||||
private TownBlock homeBlock;
|
||||
private TownBlock homeBlockRaided;
|
||||
private TownBlock homeBlockGather;
|
||||
private RaidPhase phase;
|
||||
private Location townSpawn;
|
||||
private Location townSpawnRaided;
|
||||
private Location townSpawnGather;
|
||||
int[] bukkitId;
|
||||
public ArrayList<String> raiderPlayers;
|
||||
public ArrayList<String> defenderPlayers;
|
||||
public ArrayList<String> activeRaiders;
|
||||
|
||||
// Constructs raid for staging phase
|
||||
public Raid(final int id, final War war, final Town town, final String raiders, final String defenders,
|
||||
public Raid(final int id, final War war, final Town raidedTown, final Town gatherTown, final String raiders, final String defenders,
|
||||
final boolean side1AreRaiders, final boolean side2AreRaiders) {
|
||||
|
||||
this.raidTicks = 0;
|
||||
this.bukkitId = new int[1];
|
||||
this.raiderPlayers = new ArrayList<String>();
|
||||
this.defenderPlayers = new ArrayList<String>();
|
||||
this.activeRaiders = new ArrayList<String>();
|
||||
this.war = war;
|
||||
this.town = town;
|
||||
this.raidedTown = raidedTown;
|
||||
this.gatherTown = gatherTown;
|
||||
this.raiders = raiders;
|
||||
this.id = id;
|
||||
|
||||
@@ -110,8 +116,10 @@ public class Raid {
|
||||
|
||||
// Sets homeBlock and spawn for town. (So no mid-raid changes.)
|
||||
try {
|
||||
homeBlock = town.getHomeBlock();
|
||||
townSpawn = town.getSpawn();
|
||||
homeBlockRaided = raidedTown.getHomeBlock();
|
||||
townSpawnRaided = raidedTown.getSpawn();
|
||||
homeBlockGather = gatherTown.getHomeBlock();
|
||||
townSpawnGather = gatherTown.getSpawn();
|
||||
} catch (TownyException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
@@ -122,9 +130,13 @@ public class Raid {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
if (homeBlock != null) {
|
||||
town.setHomeBlock(homeBlock);
|
||||
town.setSpawn(townSpawn);
|
||||
if (homeBlockRaided != null) {
|
||||
raidedTown.setHomeBlock(homeBlockRaided);
|
||||
raidedTown.setSpawn(townSpawnRaided);
|
||||
}
|
||||
if (homeBlockGather != null) {
|
||||
gatherTown.setHomeBlock(homeBlockGather);
|
||||
gatherTown.setSpawn(townSpawnGather);
|
||||
}
|
||||
if (Raid.this.side1AreRaiders) {
|
||||
Raid.this.raiderPlayers = Raid.this.war.getSide1Players();
|
||||
@@ -161,22 +173,31 @@ public class Raid {
|
||||
|
||||
|
||||
//Raid start phase behavior
|
||||
if (Raid.this.phase == RaidPhase.START) {
|
||||
//update
|
||||
if (Raid.this.raidTicks % 6000 == 0) {
|
||||
if (Raid.this.phase == RaidPhase.GATHER) {
|
||||
//Broadcast
|
||||
if(raidTicks % 6000 == 0) {
|
||||
Bukkit.broadcastMessage(String.valueOf(Helper.Chatlabel()) + "The raid of "
|
||||
+ Raid.this.town.getName() + " will begin in " + (RaidPhase.TRAVEL.startTick / 20 / 60) + " minutes!");
|
||||
+ Raid.this.getRaidedTown().getName() + " will begin in " + (int) (RaidPhase.TRAVEL.startTick / 20 / 60) + " minutes!");
|
||||
Bukkit.broadcastMessage(
|
||||
"The Raiders are gathering at " + TownyAPI.getInstance().getTownName(Raid.this.owner.getLocation()) + " before making the journey over!");
|
||||
"The Raiders are gathering at " + getGatherTown().getName() + " before making the journey over!");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//Raid Travel phase behavior
|
||||
else if (Raid.this.phase == RaidPhase.TRAVEL) {
|
||||
//Check if a player has arrived at the town (in it) and if so start combat
|
||||
|
||||
if(raidTicks % 2400 == 0) {
|
||||
Bukkit.broadcastMessage(String.valueOf(Helper.Chatlabel()) + "The Raiders of "
|
||||
+ (side1AreRaiders ? Raid.this.war.getSide1() : Raid.this.war.getSide2())
|
||||
+ " are on their way to raid "
|
||||
+ Raid.this.getRaidedTown().getName() + "!");
|
||||
}
|
||||
|
||||
//Check if a player has arrived at the town (in it) and if so start combat
|
||||
for (String player : raiderPlayers) {
|
||||
WorldCoord playercoord = WorldCoord.parseWorldCoord(Bukkit.getPlayer(player));
|
||||
if (Raid.this.town.hasTownBlock(playercoord)) {
|
||||
if (Raid.this.getRaidedTown().hasTownBlock(playercoord)) {
|
||||
startCombat();
|
||||
}
|
||||
}
|
||||
@@ -188,7 +209,7 @@ public class Raid {
|
||||
//Report
|
||||
if (Raid.this.raidTicks % 6000 == 0) {
|
||||
Bukkit.broadcastMessage(String.valueOf(Helper.Chatlabel()) + "Report on the raid of "
|
||||
+ Raid.this.town.getName() + ":");
|
||||
+ Raid.this.getRaidedTown().getName() + ":");
|
||||
Bukkit.broadcastMessage(
|
||||
"Raid Score - " + String.valueOf(Raid.this.raidScore));
|
||||
}
|
||||
@@ -221,7 +242,7 @@ public class Raid {
|
||||
Bukkit.broadcastMessage(String.valueOf(Helper.Chatlabel()) + "The Raiders of "
|
||||
+ (side1AreRaiders ? Raid.this.war.getSide1() : Raid.this.war.getSide2())
|
||||
+ " are coming to raid "
|
||||
+ Raid.this.town.getName() + "!");
|
||||
+ 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;
|
||||
}
|
||||
@@ -234,7 +255,7 @@ public class Raid {
|
||||
Bukkit.broadcastMessage(String.valueOf(Helper.Chatlabel()) + "The Raiders of "
|
||||
+ (side1AreRaiders ? Raid.this.war.getSide1() : Raid.this.war.getSide2())
|
||||
+ " have arrived at "
|
||||
+ Raid.this.town.getName() + " and the fighting has begun!");
|
||||
+ Raid.this.getRaidedTown().getName() + " and the fighting has begun!");
|
||||
//in the case were not at that stage already
|
||||
Raid.this.raidTicks = RaidPhase.COMBAT.startTick;
|
||||
}
|
||||
@@ -292,12 +313,20 @@ public class Raid {
|
||||
this.war = war;
|
||||
}
|
||||
|
||||
public Town getTown() {
|
||||
return this.town;
|
||||
public Town getRaidedTown() {
|
||||
return this.raidedTown;
|
||||
}
|
||||
|
||||
public void setTown(final Town town) {
|
||||
this.town = town;
|
||||
public void setRaidedTown(final Town town) {
|
||||
this.raidedTown = town;
|
||||
}
|
||||
|
||||
public Town getGatherTown() {
|
||||
return this.gatherTown;
|
||||
}
|
||||
|
||||
public void setGatherTown(final Town town) {
|
||||
this.gatherTown = town;
|
||||
}
|
||||
|
||||
public String getRaiders() {
|
||||
@@ -359,4 +388,24 @@ public class Raid {
|
||||
static /* synthetic */ void access$7(final Raid raid, final int raidTicks) {
|
||||
raid.raidTicks = raidTicks;
|
||||
}
|
||||
|
||||
public RaidPhase getPhase() {
|
||||
return this.phase;
|
||||
}
|
||||
|
||||
public void setRaidPhase(final RaidPhase phase) {
|
||||
this.phase = phase;
|
||||
}
|
||||
|
||||
public ArrayList<String> getActiveRaiders() {
|
||||
return this.activeRaiders;
|
||||
}
|
||||
|
||||
public void setActiveRaiders(ArrayList<String> activeRaiders) {
|
||||
this.activeRaiders = activeRaiders;
|
||||
}
|
||||
|
||||
public void addActiveRaider(String player) {
|
||||
this.activeRaiders.add(player);
|
||||
}
|
||||
}
|
||||
@@ -1,11 +1,13 @@
|
||||
package me.ShermansWorld.AlathraWar.commands;
|
||||
|
||||
import com.palmergames.bukkit.towny.TownyAPI;
|
||||
import com.palmergames.bukkit.towny.exceptions.NotRegisteredException;
|
||||
import com.palmergames.bukkit.towny.object.Resident;
|
||||
import com.palmergames.bukkit.towny.object.Town;
|
||||
import com.palmergames.bukkit.towny.object.TownyWorld;
|
||||
import com.palmergames.bukkit.towny.object.WorldCoord;
|
||||
import me.ShermansWorld.AlathraWar.*;
|
||||
import me.ShermansWorld.AlathraWar.data.RaidPhase;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.command.Command;
|
||||
@@ -46,10 +48,12 @@ public class RaidCommands implements CommandExecutor
|
||||
for (final Raid raid : RaidCommands.raids) {
|
||||
p.sendMessage("ID: " + String.valueOf(raid.getID()));
|
||||
p.sendMessage("War: " + raid.getWar().getName());
|
||||
p.sendMessage("Town: " + raid.getTown().getName());
|
||||
p.sendMessage("Raiding: " + raid.getRaidedTown().getName());
|
||||
p.sendMessage("Gathering In: " + raid.getGatherTown().getName());
|
||||
p.sendMessage("Raiders: " + raid.getRaiders());
|
||||
p.sendMessage("Defenders: " + raid.getDefenders());
|
||||
p.sendMessage("Raid Score: " + String.valueOf(raid.getRaidScore()));
|
||||
p.sendMessage("Raid Phase: " + raid.getPhase().name());
|
||||
p.sendMessage("Time Left: " + String.valueOf((72000 - Main.raidData.getConfig().getInt("Raids." + String.valueOf(String.valueOf(raid.getID()) + ".raidticks"))) / 1200) + " minutes");
|
||||
p.sendMessage("-=-=-=-=-=-=-=-=-=-=-=-");
|
||||
}
|
||||
@@ -58,6 +62,7 @@ public class RaidCommands implements CommandExecutor
|
||||
p.sendMessage(Helper.Chatlabel() + "/raid stop [id]");
|
||||
}
|
||||
p.sendMessage(Helper.Chatlabel() + "/raid start [war] [town]");
|
||||
p.sendMessage(Helper.Chatlabel() + "/raid join [war] [town]");
|
||||
p.sendMessage(Helper.Chatlabel() + "/raid abandon [id]");
|
||||
p.sendMessage(Helper.Chatlabel() + "/raid list");
|
||||
} else {
|
||||
@@ -80,7 +85,7 @@ public class RaidCommands implements CommandExecutor
|
||||
if (String.valueOf(RaidCommands.raids.get(i).getID()).equalsIgnoreCase(args[1])) {
|
||||
found = true;
|
||||
p.sendMessage(String.valueOf(Helper.Chatlabel()) + "raid cancelled");
|
||||
Bukkit.broadcastMessage(String.valueOf(Helper.Chatlabel()) + "The raid at " + RaidCommands.raids.get(i).getTown().getName() + " has been cancelled by an admin");
|
||||
Bukkit.broadcastMessage(String.valueOf(Helper.Chatlabel()) + "The raid of " + RaidCommands.raids.get(i).getRaidedTown().getName() + " has been cancelled by an admin");
|
||||
RaidCommands.raids.get(i).stop();
|
||||
break;
|
||||
}
|
||||
@@ -101,8 +106,8 @@ public class RaidCommands implements CommandExecutor
|
||||
for (int j = 0; j < RaidCommands.raids.size(); ++j) {
|
||||
if (String.valueOf(RaidCommands.raids.get(j).getID()).equalsIgnoreCase(args[1])) {
|
||||
found2 = true;
|
||||
Bukkit.broadcastMessage(String.valueOf(Helper.Chatlabel()) + "The raid at " + RaidCommands.raids.get(j).getTown().getName() + " has been abandoned by " + RaidCommands.raids.get(j).getRaiders());
|
||||
Main.warLogger.log(p.getName() + " abandoned the raid they started at " + RaidCommands.raids.get(j).getTown().getName());
|
||||
Bukkit.broadcastMessage(String.valueOf(Helper.Chatlabel()) + "The raid on " + RaidCommands.raids.get(j).getRaidedTown().getName() + " has been abandoned by " + RaidCommands.raids.get(j).getRaiders());
|
||||
Main.warLogger.log(p.getName() + " abandoned the raid on " + RaidCommands.raids.get(j).getRaidedTown().getName() + " they started at " + RaidCommands.raids.get(j).getGatherTown().getName());
|
||||
RaidCommands.raids.get(j).defendersWin();
|
||||
break;
|
||||
}
|
||||
@@ -131,13 +136,12 @@ public class RaidCommands implements CommandExecutor
|
||||
RaidCommands.towns.clear();
|
||||
}
|
||||
|
||||
//TODO: This needs to change
|
||||
//needs to have be in raiders town to delcare raid added
|
||||
//so that surprise raids arent a thing, ill leave that to someone else
|
||||
for (final String entry : townyWorld.getTowns().keySet()) {
|
||||
final Town town = townyWorld.getTowns().get(entry);
|
||||
RaidCommands.towns.add(town);
|
||||
if (town.getName().equalsIgnoreCase(args[2])) {
|
||||
final Town raidedTown = townyWorld.getTowns().get(entry);
|
||||
//takes the command runners town
|
||||
final Town gatherTown = TownyAPI.getInstance().getTown(p.getLocation());
|
||||
RaidCommands.towns.add(raidedTown);
|
||||
if (raidedTown.getName().equalsIgnoreCase(args[2]) && gatherTown != null) {
|
||||
townExists = true;
|
||||
boolean attackingOwnSide = false;
|
||||
++RaidCommands.maxID;
|
||||
@@ -145,16 +149,17 @@ public class RaidCommands implements CommandExecutor
|
||||
Main.raidData.saveConfig();
|
||||
Raid raid2;
|
||||
if (war.getSide1Players().contains(p.getName())) {
|
||||
raid2 = new Raid(RaidCommands.maxID, war, town, war.getSide1(), war.getSide2(), true, false);
|
||||
raid2 = new Raid(RaidCommands.maxID, war, raidedTown, gatherTown, war.getSide1(), war.getSide2(), true, false);
|
||||
Main.raidData.getConfig().set("Raids." + String.valueOf(RaidCommands.maxID) + ".war", (Object)war.getName());
|
||||
Main.raidData.getConfig().set("Raids." + String.valueOf(RaidCommands.maxID) + ".town", (Object)town.getName());
|
||||
Main.raidData.getConfig().set("Raids." + String.valueOf(RaidCommands.maxID) + ".raidedTown", (Object)raidedTown.getName());
|
||||
Main.raidData.getConfig().set("Raids." + String.valueOf(RaidCommands.maxID) + ".gatherTown", (Object)gatherTown.getName());
|
||||
Main.raidData.getConfig().set("Raids." + String.valueOf(RaidCommands.maxID) + ".raiders", (Object)war.getSide1());
|
||||
Main.raidData.getConfig().set("Raids." + String.valueOf(RaidCommands.maxID) + ".activeRaiders", raid2.getActiveRaiders());
|
||||
Main.raidData.getConfig().set("Raids." + String.valueOf(RaidCommands.maxID) + ".defenders", (Object)war.getSide2());
|
||||
Main.raidData.getConfig().set("Raids." + String.valueOf(RaidCommands.maxID) + ".side1areraiders", (Object)true);
|
||||
Main.raidData.getConfig().set("Raids." + String.valueOf(RaidCommands.maxID) + ".side2areraiders", (Object)false);
|
||||
Main.raidData.getConfig().set("Raids." + String.valueOf(RaidCommands.maxID) + ".raidticks", (Object)0);
|
||||
Main.raidData.getConfig().set("Raids." + String.valueOf(RaidCommands.maxID) + ".raiderpoints", (Object)0);
|
||||
Main.raidData.getConfig().set("Raids." + String.valueOf(RaidCommands.maxID) + ".defenderpoints", (Object)0);
|
||||
Main.raidData.getConfig().set("Raids." + String.valueOf(RaidCommands.maxID) + ".raidScore", (Object)0);
|
||||
Main.raidData.getConfig().set("Raids." + String.valueOf(RaidCommands.maxID) + ".owner", (Object)p.getName());
|
||||
Main.raidData.saveConfig();
|
||||
}
|
||||
@@ -163,21 +168,21 @@ public class RaidCommands implements CommandExecutor
|
||||
Bukkit.getLogger().info("Unable to find player declaring raid in the war");
|
||||
return false;
|
||||
}
|
||||
raid2 = new Raid(RaidCommands.maxID, war, town, war.getSide2(), war.getSide1(), false, true);
|
||||
raid2 = new Raid(RaidCommands.maxID, war, raidedTown, gatherTown, war.getSide2(), war.getSide1(), false, true);
|
||||
Main.raidData.getConfig().set("Raids." + String.valueOf(RaidCommands.maxID) + ".war", (Object)war.getName());
|
||||
Main.raidData.getConfig().set("Raids." + String.valueOf(RaidCommands.maxID) + ".town", (Object)town.getName());
|
||||
Main.raidData.getConfig().set("Raids." + String.valueOf(RaidCommands.maxID) + ".raidedTown", (Object)raidedTown.getName());
|
||||
Main.raidData.getConfig().set("Raids." + String.valueOf(RaidCommands.maxID) + ".gatherTown", (Object)gatherTown.getName());
|
||||
Main.raidData.getConfig().set("Raids." + String.valueOf(RaidCommands.maxID) + ".raiders", (Object)war.getSide2());
|
||||
Main.raidData.getConfig().set("Raids." + String.valueOf(RaidCommands.maxID) + ".defenders", (Object)war.getSide1());
|
||||
Main.raidData.getConfig().set("Raids." + String.valueOf(RaidCommands.maxID) + ".side1areraiders", (Object)false);
|
||||
Main.raidData.getConfig().set("Raids." + String.valueOf(RaidCommands.maxID) + ".side2areraiders", (Object)true);
|
||||
Main.raidData.getConfig().set("Raids." + String.valueOf(RaidCommands.maxID) + ".raidticks", (Object)0);
|
||||
Main.raidData.getConfig().set("Raids." + String.valueOf(RaidCommands.maxID) + ".raiderpoints", (Object)0);
|
||||
Main.raidData.getConfig().set("Raids." + String.valueOf(RaidCommands.maxID) + ".defenderpoints", (Object)0);
|
||||
Main.raidData.getConfig().set("Raids." + String.valueOf(RaidCommands.maxID) + ".raidScore", (Object)0);
|
||||
Main.raidData.getConfig().set("Raids." + String.valueOf(RaidCommands.maxID) + ".owner", (Object)p.getName());
|
||||
Main.raidData.saveConfig();
|
||||
}
|
||||
final ArrayList<String> residentNames = new ArrayList<String>();
|
||||
for (final Resident resident : town.getResidents()) {
|
||||
for (final Resident resident : raidedTown.getResidents()) {
|
||||
residentNames.add(resident.getName());
|
||||
}
|
||||
if (raid2.getSide1AreRaiders()) {
|
||||
@@ -203,38 +208,52 @@ public class RaidCommands implements CommandExecutor
|
||||
currentTown = WorldCoord.parseWorldCoord(p.getLocation()).getTownBlock().getTown();
|
||||
}
|
||||
catch (NotRegisteredException e2) {
|
||||
p.sendMessage(String.valueOf(Helper.Chatlabel()) + "You must be within the town's claim to begin a raid");
|
||||
p.sendMessage(String.valueOf(Helper.Chatlabel()) + "You must be within a town's claim to begin a raid. That town you are in will be the gathering town.");
|
||||
Main.raidData.getConfig().set("Raids." + String.valueOf(RaidCommands.maxID), (Object)null);
|
||||
Main.raidData.saveConfig();
|
||||
return false;
|
||||
}
|
||||
if (!currentTown.equals(town)) {
|
||||
p.sendMessage(String.valueOf(Helper.Chatlabel()) + "You must be within the town's claim to begin a raid");
|
||||
if (!currentTown.equals(gatherTown)) {
|
||||
p.sendMessage(String.valueOf(Helper.Chatlabel()) + "You must be within a town's claim to begin a raid. That town you are in will be the gathering town.");
|
||||
Main.raidData.getConfig().set("Raids." + String.valueOf(RaidCommands.maxID), (Object)null);
|
||||
Main.raidData.saveConfig();
|
||||
return false;
|
||||
}
|
||||
for (final Raid raidEntry : RaidCommands.raids) {
|
||||
if (raidEntry.getTown().getName().equalsIgnoreCase(town.getName())) {
|
||||
if (raidEntry.getRaidedTown().getName().equalsIgnoreCase(raidedTown.getName())) {
|
||||
p.sendMessage(String.valueOf(Helper.Chatlabel()) + "This town is already under raid by your side!");
|
||||
Main.raidData.getConfig().set("Raids." + String.valueOf(RaidCommands.maxID), (Object)null);
|
||||
Main.raidData.saveConfig();
|
||||
return false;
|
||||
}
|
||||
//TODO check when last raid was
|
||||
int valid = Main.raidData.isValidRaid(raidEntry.getRaidedTown());
|
||||
if (valid <= -1) {
|
||||
p.sendMessage(String.valueOf(Helper.Chatlabel()) + "This town has been raided too recently! (24 hour cooldown)");
|
||||
Main.raidData.getConfig().set("Raids." + String.valueOf(RaidCommands.maxID), (Object)null);
|
||||
Main.raidData.saveConfig();
|
||||
return false;
|
||||
} else if (valid == 0) {
|
||||
p.sendMessage(String.valueOf(Helper.Chatlabel()) + "Your side has raided too recently! (6 hour cooldown)");
|
||||
Main.raidData.getConfig().set("Raids." + String.valueOf(RaidCommands.maxID), (Object)null);
|
||||
Main.raidData.saveConfig();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
final OfflinePlayer offlinePlayer = Bukkit.getOfflinePlayer(p.getUniqueId());
|
||||
if (Main.econ.getBalance(offlinePlayer) <= 2500.0) {
|
||||
p.sendMessage(String.valueOf(Helper.Chatlabel()) + "You must have at least $20,000 to put up to start a raid");
|
||||
//TODO check econ values, and if this costs money to begin with
|
||||
if (Main.econ.getBalance(offlinePlayer) <= 4000.0) {
|
||||
p.sendMessage(String.valueOf(Helper.Chatlabel()) + "You must have at least $4,000 to put up to start a raid");
|
||||
Main.raidData.getConfig().set("Raids." + String.valueOf(RaidCommands.maxID), (Object)null);
|
||||
Main.raidData.saveConfig();
|
||||
return false;
|
||||
}
|
||||
Main.econ.withdrawPlayer(offlinePlayer, 2500.0);
|
||||
Main.econ.withdrawPlayer(offlinePlayer, 4000.0);
|
||||
RaidCommands.raids.add(raid2);
|
||||
raid2.start();
|
||||
Bukkit.broadcastMessage(String.valueOf(Helper.Chatlabel()) + "As part of " + war.getName() + ", forces from " + raid2.getRaiders() + " are raiding the town of " + town.getName() + "!");
|
||||
Bukkit.broadcastMessage(String.valueOf(Helper.Chatlabel()) + "As part of " + war.getName() + ", forces from " + raid2.getRaiders() + " are gathering to raid the town of " + raidedTown.getName() + "!");
|
||||
Main.warLogger.log(p.getName() + " started a raid.");
|
||||
Main.warLogger.log("As part of " + war.getName() + ", forces from " + raid2.getRaiders() + " are raiding the town of " + town.getName() + "!");
|
||||
Main.warLogger.log("As part of " + war.getName() + ", forces from " + raid2.getRaiders() + " are raiding the town of " + raidedTown.getName() + "!");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -246,6 +265,54 @@ public class RaidCommands implements CommandExecutor
|
||||
if (!townExists) {
|
||||
p.sendMessage(String.valueOf(Helper.Chatlabel()) + "That town does not exist! /raid start [war] [town]");
|
||||
}
|
||||
} else if (args[0].equalsIgnoreCase("join")) {
|
||||
boolean warFound = false;
|
||||
boolean townExists = false;
|
||||
boolean raidFound = false;
|
||||
for (final War war : WarCommands.wars) {
|
||||
if (war.getName().equalsIgnoreCase(args[1])) {
|
||||
warFound = true;
|
||||
if (!war.getSide1Players().contains(p.getName()) && !war.getSide2Players().contains(p.getName())) {
|
||||
p.sendMessage(String.valueOf(Helper.Chatlabel()) + "You are not in this war! Type /war join [war] [side]");
|
||||
}
|
||||
TownyWorld townyWorld;
|
||||
townyWorld = WorldCoord.parseWorldCoord(p.getLocation()).getTownyWorld();
|
||||
if (!RaidCommands.towns.isEmpty()) {
|
||||
RaidCommands.towns.clear();
|
||||
}
|
||||
|
||||
//find the associated raid
|
||||
Raid raid = null;
|
||||
for(Raid r : raids) {
|
||||
if(r.getWar().getId() == war.getId()) {
|
||||
raidFound = true;
|
||||
raid = r;
|
||||
}
|
||||
}
|
||||
|
||||
//if we find the raid
|
||||
if(raidFound) {
|
||||
if(raid.getPhase() == RaidPhase.GATHER) {
|
||||
if(raid.getGatherTown().hasTownBlock(WorldCoord.parseWorldCoord(p))) {
|
||||
raid.addActiveRaider(p.getName());
|
||||
p.sendMessage(String.valueOf(Helper.Chatlabel()) + "You have joined the raid on " + raid.getRaidedTown().getName() + "!");
|
||||
p.sendMessage(String.valueOf(Helper.Chatlabel()) + "Leaving " + raid.getGatherTown().getName() + " will cause you to leave the raid party.");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!warFound) {
|
||||
p.sendMessage(String.valueOf(Helper.Chatlabel()) + "That war does not exist! /raid start [war] [town]");
|
||||
return false;
|
||||
}
|
||||
if (!townExists) {
|
||||
p.sendMessage(String.valueOf(Helper.Chatlabel()) + "That town does not exist! /raid start [war] [town]");
|
||||
}
|
||||
if (!raidFound) {
|
||||
p.sendMessage(String.valueOf(Helper.Chatlabel()) + "No raid is gathering in this town!");
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
p.sendMessage(String.valueOf(Helper.Chatlabel()) + "Invalid Arguments. /raid help");
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package me.ShermansWorld.AlathraWar.data;
|
||||
|
||||
import com.palmergames.bukkit.towny.object.Town;
|
||||
import me.ShermansWorld.AlathraWar.Main;
|
||||
import org.bukkit.configuration.Configuration;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
@@ -58,4 +59,25 @@ public class RaidData {
|
||||
this.plugin.saveResource("raids.yml", false);
|
||||
}
|
||||
}
|
||||
|
||||
//TODO raid time check
|
||||
/**
|
||||
* @Isaac this is for getting when the last raid was on a town
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public int whenTownLastRaided() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
//TODO raid validity check
|
||||
/**
|
||||
* @Isaac this is for getting if a town can be raided, return (-1, 0, 1) based on status
|
||||
* (24 hours town cooldown, 6 hour nation cooldown, valid time to raid)
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public int isValidRaid(Town t) {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user