Added siege capabilities

(cherry picked from commit 65dc1c9846)
This commit is contained in:
Isaac authored and Aubri Seebauer committed 2023-04-09 21:14:25 -04:00
1 parent 61e71cd9e7
commit 119a2f5e33
4 files changed
+220 -248

No files matched your search

@@ -28,10 +28,7 @@ import net.milkbowl.vault.economy.Economy;
import org.bukkit.plugin.java.JavaPlugin;
public class Main extends JavaPlugin {
public static WarData warData;
public static SiegeData siegeData;
public static RaidData raidData;
public static Main instance;
public static Economy econ;
public static AlathraWarLogger warLogger;
@@ -48,81 +45,6 @@ public class Main extends JavaPlugin {
}
WarData.setWars(WarData.createWars());
try {
Set<String> siegeSet = (Set<String>) siegeData.getConfig().getConfigurationSection("Sieges").getKeys(false);
Iterator<String> it2 = siegeSet.iterator();
ArrayList<String> siegesTempList = new ArrayList<String>();
while (it2.hasNext()) {
siegesTempList.add(it2.next());
}
for (int i = 0; i < siegesTempList.size(); ++i) {
War siegeWar = null;
Town siegeTown = null;
for (final War war2 : WarCommands.wars) {
if (siegeData.getConfig().getString("Sieges." + siegesTempList.get(i) + ".war")
.equalsIgnoreCase(war2.getName())) {
siegeWar = war2;
}
}
List<Town> townList = TownyAPI.getInstance().getTowns();
for (final Town town : townList) {
if (town.getName().equalsIgnoreCase(
siegeData.getConfig().getString("Sieges." + siegesTempList.get(i) + ".town"))) {
siegeTown = town;
}
}
Siege siege = new Siege(Integer.parseInt(siegesTempList.get(i)), siegeWar, siegeTown,
siegeData.getConfig().getString("Sieges." + siegesTempList.get(i) + ".attackers"),
siegeData.getConfig().getString("Sieges." + siegesTempList.get(i) + ".defenders"),
siegeData.getConfig().getBoolean("Sieges." + siegesTempList.get(i) + ".siege1areattackers"),
siegeData.getConfig().getBoolean("Sieges." + siegesTempList.get(i) + ".siege2areattackers"));
SiegeCommands.sieges.add(siege);
siege.start();
siege.resetBeacon(
Bukkit.getWorld(siegeData.getConfig().getString("Sieges." + siegesTempList.get(i) + ".world")),
siegeData.getConfig().getInt("Sieges." + siegesTempList.get(i) + ".homeblockx"),
siegeData.getConfig().getInt("Sieges." + siegesTempList.get(i) + ".homeblocky"),
siegeData.getConfig().getInt("Sieges." + siegesTempList.get(i) + ".homeblockz"));
}
} catch (NullPointerException e) {
Bukkit.getLogger().info("NULL when initializing sieges");
}
//TODO: Raids
try {
Set<String> raidSet = (Set<String>) raidData.getConfig().getConfigurationSection("Raids").getKeys(false);
Iterator<String> it2 = raidSet.iterator();
ArrayList<String> raidsTempList = new ArrayList<String>();
while (it2.hasNext()) {
raidsTempList.add(it2.next());
}
for (int i = 0; i < raidsTempList.size(); ++i) {
War raidWar = null;
Town raidTown = null;
for (final War war2 : WarCommands.wars) {
if (raidData.getConfig().getString("Raids." + raidsTempList.get(i) + ".war")
.equalsIgnoreCase(war2.getName())) {
raidWar = war2;
}
}
List<Town> townList = TownyAPI.getInstance().getTowns();
for (final Town town : townList) {
if (town.getName().equalsIgnoreCase(
raidData.getConfig().getString("Raids." + raidsTempList.get(i) + ".town"))) {
raidTown = town;
}
}
Raid raid = new Raid(Integer.parseInt(raidsTempList.get(i)), raidWar, raidTown,
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) {
Bukkit.getLogger().info("NULL when initializing raids");
}
}
@SuppressWarnings("rawtypes")
@@ -167,15 +89,15 @@ public class Main extends JavaPlugin {
public void onEnable() {
instance = this;
warData = new WarData(this);
siegeData = new SiegeData(this);
raidData = new RaidData(this);
initLogs();
new WarData(this);
new WarCommands(this);
new SiegeCommands(this);
new RaidCommands(this);
getCommand("war").setTabCompleter(new WarTabCompletion());
getCommand("siege").setTabCompleter(new SiegeTabCompletion());
getCommand("raid").setTabCompleter(new RaidTabCompletion());
//getCommand("raid").setTabCompleter(new RaidTabCompletion());
getServer().getPluginManager().registerEvents((Listener) new KillsListener(), (Plugin) this);
getServer().getPluginManager().registerEvents((Listener) new CommandsListener(), (Plugin) this);
getServer().getPluginManager().registerEvents((Listener) new JoinListener(), (Plugin) this);