mirror of
https://github.com/darksaid98/AlathranWars.git
synced 2026-12-01 14:38:55 +00:00
Raid leave and tp on death
This commit is contained in:
1 parent
d6e5518c1e
commit
aca1a685aa
3 files changed
+60
-5
No files matched your search
@@ -130,15 +130,15 @@ public class Main extends JavaPlugin {
|
||||
List<Town> townList = TownyAPI.getInstance().getTowns();
|
||||
for (final Town town : townList) {
|
||||
if (town.getName().equalsIgnoreCase(
|
||||
siegeData.getConfig().getString("Raids." + raidsTempList.get(i) + ".town"))) {
|
||||
raidData.getConfig().getString("Raids." + raidsTempList.get(i) + ".town"))) {
|
||||
raidTown = town;
|
||||
}
|
||||
}
|
||||
Raid raid = new Raid(Integer.parseInt(raidsTempList.get(i)), raidWar, raidTown,
|
||||
siegeData.getConfig().getString("Raids." + raidsTempList.get(i) + ".raiders"),
|
||||
siegeData.getConfig().getString("Raids." + raidsTempList.get(i) + ".defenders"),
|
||||
siegeData.getConfig().getBoolean("Raids." + raidsTempList.get(i) + ".side1areraiders"),
|
||||
siegeData.getConfig().getBoolean("Raids." + raidsTempList.get(i) + ".side2areraiders"));
|
||||
raidData.getConfig().getString("Raids." + raidsTempList.get(i) + ".raiders"),
|
||||
raidData.getConfig().getString("Raids." + raidsTempList.get(i) + ".defenders"),
|
||||
raidData.getConfig().getBoolean("Raids." + raidsTempList.get(i) + ".side1areraiders"),
|
||||
raidData.getConfig().getBoolean("Raids." + raidsTempList.get(i) + ".side2areraiders"));
|
||||
raid.start();
|
||||
}
|
||||
} catch (NullPointerException e) {
|
||||
|
||||
@@ -514,4 +514,8 @@ public class Raid {
|
||||
public void addActiveRaider(String player) {
|
||||
this.activeRaiders.add(player);
|
||||
}
|
||||
|
||||
public void removeActiveRaider(String name) {
|
||||
this.activeRaiders.remove(name);
|
||||
}
|
||||
}
|
||||
@@ -63,6 +63,7 @@ public class RaidCommands implements CommandExecutor
|
||||
}
|
||||
p.sendMessage(Helper.Chatlabel() + "/raid start [war] [town]");
|
||||
p.sendMessage(Helper.Chatlabel() + "/raid join [war] [town]");
|
||||
p.sendMessage(Helper.Chatlabel() + "/raid leave [war] [town]");
|
||||
p.sendMessage(Helper.Chatlabel() + "/raid abandon [id]");
|
||||
p.sendMessage(Helper.Chatlabel() + "/raid list");
|
||||
} else {
|
||||
@@ -316,6 +317,56 @@ public class RaidCommands implements CommandExecutor
|
||||
p.sendMessage(String.valueOf(Helper.Chatlabel()) + "No raid is gathering in this town!");
|
||||
return false;
|
||||
}
|
||||
} else if (args[0].equalsIgnoreCase("leave")) {
|
||||
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) {
|
||||
//check if gather phase
|
||||
if(raid.getPhase() == RaidPhase.GATHER || raid.getPhase() == RaidPhase.START) {
|
||||
if(raid.getGatherTown().hasTownBlock(WorldCoord.parseWorldCoord(p))) {
|
||||
raid.removeActiveRaider(p.getName());
|
||||
p.sendMessage(String.valueOf(Helper.Chatlabel()) + "You have left the raid on " + raid.getRaidedTown().getName() + "!");
|
||||
}
|
||||
} else {
|
||||
p.sendMessage(String.valueOf(Helper.Chatlabel()) + "You cannot leave the raid on " + raid.getRaidedTown().getName() + "! It has already started!");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!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");
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user