mirror of
https://github.com/darksaid98/AlathranWars.git
synced 2026-12-03 14:38:56 +00:00
refactor: cleanup
This commit is contained in:
27 files changed
+904
-880
No files matched your search
@@ -1,19 +1,15 @@
|
|||||||
package me.ShermansWorld.AlathraWar;
|
package me.ShermansWorld.AlathraWar;
|
||||||
|
|
||||||
import java.io.BufferedWriter;
|
|
||||||
import java.io.File;
|
|
||||||
import java.io.FileWriter;
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.io.PrintWriter;
|
|
||||||
import java.text.SimpleDateFormat;
|
|
||||||
import java.util.Date;
|
|
||||||
|
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
|
|
||||||
|
import java.io.*;
|
||||||
|
import java.text.SimpleDateFormat;
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
public class AlathraWarLogger {
|
public class AlathraWarLogger {
|
||||||
|
|
||||||
File logsFolder;
|
final File logsFolder;
|
||||||
File log;
|
final File log;
|
||||||
PrintWriter output = null;
|
PrintWriter output = null;
|
||||||
|
|
||||||
public AlathraWarLogger() {
|
public AlathraWarLogger() {
|
||||||
@@ -46,7 +42,6 @@ public class AlathraWarLogger {
|
|||||||
output = new PrintWriter(bw);
|
output = new PrintWriter(bw);
|
||||||
} catch (IOException e1) {
|
} catch (IOException e1) {
|
||||||
Bukkit.getLogger().warning("[AlathraWar] Error in AlathraWarLogger - could not initialize file writer");
|
Bukkit.getLogger().warning("[AlathraWar] Error in AlathraWarLogger - could not initialize file writer");
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -9,11 +9,11 @@ import org.bukkit.inventory.Inventory;
|
|||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
import org.bukkit.inventory.meta.Damageable;
|
import org.bukkit.inventory.meta.Damageable;
|
||||||
import org.bukkit.inventory.meta.ItemMeta;
|
import org.bukkit.inventory.meta.ItemMeta;
|
||||||
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
|
||||||
public class Helper
|
public class Helper {
|
||||||
{
|
|
||||||
public static String color(final String input) {
|
public static String color(final String input) {
|
||||||
return ChatColor.translateAlternateColorCodes('&', input);
|
return ChatColor.translateAlternateColorCodes('&', input);
|
||||||
}
|
}
|
||||||
@@ -37,41 +37,23 @@ public class Helper
|
|||||||
for (int i = 0; i < inv.getSize(); ++i) {
|
for (int i = 0; i < inv.getSize(); ++i) {
|
||||||
final ItemStack is = inv.getItem(i);
|
final ItemStack is = inv.getItem(i);
|
||||||
if (is != null && (is.getType() == Material.NETHERITE_AXE || is.getType() == Material.NETHERITE_SWORD || is.getType() == Material.DIAMOND_AXE || is.getType() == Material.DIAMOND_SWORD || is.getType() == Material.IRON_AXE || is.getType() == Material.IRON_SWORD)) {
|
if (is != null && (is.getType() == Material.NETHERITE_AXE || is.getType() == Material.NETHERITE_SWORD || is.getType() == Material.DIAMOND_AXE || is.getType() == Material.DIAMOND_SWORD || is.getType() == Material.IRON_AXE || is.getType() == Material.IRON_SWORD)) {
|
||||||
ItemMeta meta = is.getItemMeta();
|
final ItemMeta meta = getItemMeta(is);
|
||||||
final Damageable damageable = (Damageable)meta;
|
|
||||||
if (is.getType() == Material.NETHERITE_SWORD || is.getType() == Material.NETHERITE_AXE) {
|
|
||||||
damageable.setDamage(damageable.getDamage() + 507);
|
|
||||||
if (damageable.getDamage() > 2000) {
|
|
||||||
damageable.setDamage(2030);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if (is.getType() == Material.DIAMOND_SWORD || is.getType() == Material.DIAMOND_AXE) {
|
|
||||||
damageable.setDamage(damageable.getDamage() + 390);
|
|
||||||
if (damageable.getDamage() > 1500) {
|
|
||||||
damageable.setDamage(1560);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if (is.getType() == Material.IRON_SWORD || is.getType() == Material.IRON_AXE) {
|
|
||||||
damageable.setDamage(damageable.getDamage() + 62);
|
|
||||||
if (damageable.getDamage() > 200) {
|
|
||||||
damageable.setDamage(249);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if (is.getType() == Material.TRIDENT) {
|
|
||||||
damageable.setDamage(damageable.getDamage() + 62);
|
|
||||||
if (damageable.getDamage() > 200) {
|
|
||||||
damageable.setDamage(249);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
meta = (ItemMeta)damageable;
|
|
||||||
is.setItemMeta(meta);
|
is.setItemMeta(meta);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
final ItemStack[] armor = p.getInventory().getArmorContents();
|
final ItemStack[] armor = p.getInventory().getArmorContents();
|
||||||
for (int j = 0; j < armor.length; ++j) {
|
for (ItemStack itemStack : armor) {
|
||||||
if (armor[j] != null) {
|
if (itemStack != null) {
|
||||||
final ItemStack is2 = armor[j];
|
if (itemStack.getType() == Material.NETHERITE_HELMET || itemStack.getType() == Material.NETHERITE_CHESTPLATE || itemStack.getType() == Material.NETHERITE_LEGGINGS || itemStack.getType() == Material.NETHERITE_BOOTS || itemStack.getType() == Material.DIAMOND_HELMET || itemStack.getType() == Material.DIAMOND_CHESTPLATE || itemStack.getType() == Material.DIAMOND_LEGGINGS || itemStack.getType() == Material.NETHERITE_BOOTS || itemStack.getType() == Material.IRON_HELMET || itemStack.getType() == Material.IRON_CHESTPLATE || itemStack.getType() == Material.IRON_LEGGINGS || itemStack.getType() == Material.IRON_BOOTS) {
|
||||||
if (is2.getType() == Material.NETHERITE_HELMET || is2.getType() == Material.NETHERITE_CHESTPLATE || is2.getType() == Material.NETHERITE_LEGGINGS || is2.getType() == Material.NETHERITE_BOOTS || is2.getType() == Material.DIAMOND_HELMET || is2.getType() == Material.DIAMOND_CHESTPLATE || is2.getType() == Material.DIAMOND_LEGGINGS || is2.getType() == Material.NETHERITE_BOOTS || is2.getType() == Material.IRON_HELMET || is2.getType() == Material.IRON_CHESTPLATE || is2.getType() == Material.IRON_LEGGINGS || is2.getType() == Material.IRON_BOOTS) {
|
final ItemMeta meta2 = getItemMeta2(itemStack);
|
||||||
|
itemStack.setItemMeta(meta2);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
private static ItemMeta getItemMeta2(ItemStack is2) {
|
||||||
ItemMeta meta2 = is2.getItemMeta();
|
ItemMeta meta2 = is2.getItemMeta();
|
||||||
final Damageable damageable2 = (Damageable) meta2;
|
final Damageable damageable2 = (Damageable) meta2;
|
||||||
if (is2.getType() == Material.NETHERITE_HELMET) {
|
if (is2.getType() == Material.NETHERITE_HELMET) {
|
||||||
@@ -146,15 +128,40 @@ public class Helper
|
|||||||
damageable2.setDamage(194);
|
damageable2.setDamage(194);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
meta2 = (ItemMeta)damageable2;
|
meta2 = damageable2;
|
||||||
is2.setItemMeta(meta2);
|
return meta2;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
private static ItemMeta getItemMeta(ItemStack is) {
|
||||||
|
ItemMeta meta = is.getItemMeta();
|
||||||
|
final Damageable damageable = (Damageable) meta;
|
||||||
|
if (is.getType() == Material.NETHERITE_SWORD || is.getType() == Material.NETHERITE_AXE) {
|
||||||
|
damageable.setDamage(damageable.getDamage() + 507);
|
||||||
|
if (damageable.getDamage() > 2000) {
|
||||||
|
damageable.setDamage(2030);
|
||||||
|
}
|
||||||
|
} else if (is.getType() == Material.DIAMOND_SWORD || is.getType() == Material.DIAMOND_AXE) {
|
||||||
|
damageable.setDamage(damageable.getDamage() + 390);
|
||||||
|
if (damageable.getDamage() > 1500) {
|
||||||
|
damageable.setDamage(1560);
|
||||||
|
}
|
||||||
|
} else if (is.getType() == Material.IRON_SWORD || is.getType() == Material.IRON_AXE) {
|
||||||
|
damageable.setDamage(damageable.getDamage() + 62);
|
||||||
|
if (damageable.getDamage() > 200) {
|
||||||
|
damageable.setDamage(249);
|
||||||
|
}
|
||||||
|
} else if (is.getType() == Material.TRIDENT) {
|
||||||
|
damageable.setDamage(damageable.getDamage() + 62);
|
||||||
|
if (damageable.getDamage() > 200) {
|
||||||
|
damageable.setDamage(249);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
meta = damageable;
|
||||||
|
return meta;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @param worldCoord worldCoord
|
* @param worldCoord worldCoord
|
||||||
* @return List of connected chunks
|
* @return List of connected chunks
|
||||||
* @author NinjaMandalorian
|
* @author NinjaMandalorian
|
||||||
@@ -179,7 +186,9 @@ public class Helper
|
|||||||
return ReturnList;
|
return ReturnList;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Gets all adjacently connected townblocks
|
/**
|
||||||
|
* Gets all adjacently connected townblocks
|
||||||
|
*
|
||||||
* @param chunkCoord - WorldCoord to check at
|
* @param chunkCoord - WorldCoord to check at
|
||||||
* @return List of WorldCoords
|
* @return List of WorldCoords
|
||||||
* @author NinjaMandalorian
|
* @author NinjaMandalorian
|
||||||
@@ -191,7 +200,7 @@ public class Helper
|
|||||||
SearchList.add(chunkCoord); // Adds 1st chunk to list
|
SearchList.add(chunkCoord); // Adds 1st chunk to list
|
||||||
|
|
||||||
// Iterates through SearchList, to create a full list of every adjacent cell.
|
// Iterates through SearchList, to create a full list of every adjacent cell.
|
||||||
while (SearchList.size() > 0) {
|
while (!SearchList.isEmpty()) {
|
||||||
// Gets WorldCoord
|
// Gets WorldCoord
|
||||||
WorldCoord toSearch = SearchList.get(0);
|
WorldCoord toSearch = SearchList.get(0);
|
||||||
// Gets adjacent cells
|
// Gets adjacent cells
|
||||||
@@ -199,10 +208,8 @@ public class Helper
|
|||||||
for (WorldCoord cell : adjCells) {
|
for (WorldCoord cell : adjCells) {
|
||||||
// If in final list, ignore.
|
// If in final list, ignore.
|
||||||
if (WCoordList.contains(cell)) {
|
if (WCoordList.contains(cell)) {
|
||||||
continue;
|
|
||||||
// If in to-search list, ignore
|
// If in to-search list, ignore
|
||||||
} else if (SearchList.contains(cell)) {
|
} else if (SearchList.contains(cell)) {
|
||||||
continue;
|
|
||||||
// Otherwise, add to search-list.
|
// Otherwise, add to search-list.
|
||||||
} else {
|
} else {
|
||||||
SearchList.add(cell);
|
SearchList.add(cell);
|
||||||
|
|||||||
@@ -1,18 +1,17 @@
|
|||||||
package me.ShermansWorld.AlathraWar;
|
package me.ShermansWorld.AlathraWar;
|
||||||
|
|
||||||
import me.ShermansWorld.AlathraWar.commands.*;
|
import me.ShermansWorld.AlathraWar.commands.*;
|
||||||
import me.ShermansWorld.AlathraWar.items.WarItemRegistry;
|
|
||||||
import me.ShermansWorld.AlathraWar.listeners.*;
|
|
||||||
import org.bukkit.plugin.RegisteredServiceProvider;
|
|
||||||
import org.bukkit.plugin.Plugin;
|
|
||||||
import me.ShermansWorld.AlathraWar.data.WarData;
|
import me.ShermansWorld.AlathraWar.data.WarData;
|
||||||
import me.ShermansWorld.AlathraWar.hooks.TABHook;
|
import me.ShermansWorld.AlathraWar.hooks.TABHook;
|
||||||
|
import me.ShermansWorld.AlathraWar.items.WarItemRegistry;
|
||||||
|
import me.ShermansWorld.AlathraWar.listeners.*;
|
||||||
|
import net.milkbowl.vault.economy.Economy;
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.plugin.RegisteredServiceProvider;
|
||||||
|
import org.bukkit.plugin.java.JavaPlugin;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import org.bukkit.Bukkit;
|
|
||||||
import net.milkbowl.vault.economy.Economy;
|
|
||||||
import org.bukkit.plugin.java.JavaPlugin;
|
|
||||||
|
|
||||||
public class Main extends JavaPlugin {
|
public class Main extends JavaPlugin {
|
||||||
public static Main instance;
|
public static Main instance;
|
||||||
@@ -36,21 +35,6 @@ public class Main extends JavaPlugin {
|
|||||||
WarData.setWars(WarData.createWars());
|
WarData.setWars(WarData.createWars());
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("rawtypes")
|
|
||||||
private boolean setupEconomy() {
|
|
||||||
if (this.getServer().getPluginManager().getPlugin("Vault") == null) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
@SuppressWarnings("unchecked")
|
|
||||||
final RegisteredServiceProvider<Economy> rsp = (RegisteredServiceProvider<Economy>) this.getServer()
|
|
||||||
.getServicesManager().getRegistration((Class) Economy.class);
|
|
||||||
if (rsp == null) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
econ = (Economy) rsp.getProvider();
|
|
||||||
return econ != null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static Main getInstance() {
|
public static Main getInstance() {
|
||||||
return instance;
|
return instance;
|
||||||
}
|
}
|
||||||
@@ -76,6 +60,20 @@ public class Main extends JavaPlugin {
|
|||||||
TABHook.init();
|
TABHook.init();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("rawtypes")
|
||||||
|
private boolean setupEconomy() {
|
||||||
|
if (this.getServer().getPluginManager().getPlugin("Vault") == null) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
@SuppressWarnings("unchecked") final RegisteredServiceProvider<Economy> rsp = (RegisteredServiceProvider<Economy>) this.getServer()
|
||||||
|
.getServicesManager().getRegistration((Class) Economy.class);
|
||||||
|
if (rsp == null) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
econ = rsp.getProvider();
|
||||||
|
return econ != null;
|
||||||
|
}
|
||||||
|
|
||||||
public void onEnable() {
|
public void onEnable() {
|
||||||
instance = this;
|
instance = this;
|
||||||
this.saveDefaultConfig();
|
this.saveDefaultConfig();
|
||||||
@@ -91,10 +89,10 @@ public class Main extends JavaPlugin {
|
|||||||
getCommand("siege").setTabCompleter(new SiegeTabCompletion());
|
getCommand("siege").setTabCompleter(new SiegeTabCompletion());
|
||||||
getCommand("raid").setTabCompleter(new RaidTabCompletion());
|
getCommand("raid").setTabCompleter(new RaidTabCompletion());
|
||||||
getCommand("alathrawaradmin").setTabCompleter(new AdminTabCompletion());
|
getCommand("alathrawaradmin").setTabCompleter(new AdminTabCompletion());
|
||||||
getServer().getPluginManager().registerEvents(new KillsListener(), (Plugin) this);
|
getServer().getPluginManager().registerEvents(new KillsListener(), this);
|
||||||
getServer().getPluginManager().registerEvents(new CommandsListener(), (Plugin) this);
|
getServer().getPluginManager().registerEvents(new CommandsListener(), this);
|
||||||
getServer().getPluginManager().registerEvents(new JoinListener(), (Plugin) this);
|
getServer().getPluginManager().registerEvents(new JoinListener(), this);
|
||||||
getServer().getPluginManager().registerEvents(new BlockBreakListener(), (Plugin) this);
|
getServer().getPluginManager().registerEvents(new BlockBreakListener(), this);
|
||||||
getServer().getPluginManager().registerEvents(new PlayerInteractListener(), this);
|
getServer().getPluginManager().registerEvents(new PlayerInteractListener(), this);
|
||||||
|
|
||||||
// //run first
|
// //run first
|
||||||
|
|||||||
@@ -16,7 +16,6 @@ import org.bukkit.boss.BarStyle;
|
|||||||
import org.bukkit.boss.BossBar;
|
import org.bukkit.boss.BossBar;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.entity.PlayerDeathEvent;
|
import org.bukkit.event.entity.PlayerDeathEvent;
|
||||||
import org.bukkit.plugin.Plugin;
|
|
||||||
import org.bukkit.potion.PotionEffect;
|
import org.bukkit.potion.PotionEffect;
|
||||||
import org.bukkit.potion.PotionEffectType;
|
import org.bukkit.potion.PotionEffectType;
|
||||||
|
|
||||||
@@ -69,12 +68,18 @@ public class Raid {
|
|||||||
|
|
||||||
//Ticks between activity, this is lower than siege because more activity is occuring in a raid
|
//Ticks between activity, this is lower than siege because more activity is occuring in a raid
|
||||||
private static final int incremental = 40;
|
private static final int incremental = 40;
|
||||||
private War war;
|
|
||||||
private final String name;
|
private final String name;
|
||||||
|
public final NamespacedKey bossBarKey = new NamespacedKey(Main.getInstance(), "raidBar." + Raid.this.getName());
|
||||||
|
public ArrayList<String> activeRaiders = new ArrayList<>();
|
||||||
|
public ArrayList<String> raiderPlayers = new ArrayList<>();
|
||||||
|
public ArrayList<String> defenderPlayers = new ArrayList<>();
|
||||||
|
public Map<WorldCoord, LootBlock> lootedChunks;
|
||||||
|
final int[] bukkitId;
|
||||||
|
private War war;
|
||||||
private Town raidedTown;
|
private Town raidedTown;
|
||||||
private Town gatherTown;
|
private Town gatherTown;
|
||||||
private String raiders;
|
private String raiders;
|
||||||
private String defenders;
|
private final String defenders;
|
||||||
private boolean side1AreRaiders;
|
private boolean side1AreRaiders;
|
||||||
private int raiderScore;
|
private int raiderScore;
|
||||||
private int defenderScore;
|
private int defenderScore;
|
||||||
@@ -85,12 +90,6 @@ public class Raid {
|
|||||||
private RaidPhase phase;
|
private RaidPhase phase;
|
||||||
private Location townSpawnRaided;
|
private Location townSpawnRaided;
|
||||||
private Location townSpawnGather;
|
private Location townSpawnGather;
|
||||||
int[] bukkitId;
|
|
||||||
public ArrayList<String> activeRaiders = new ArrayList<>();
|
|
||||||
public ArrayList<String> raiderPlayers = new ArrayList<>();
|
|
||||||
public ArrayList<String> defenderPlayers = new ArrayList<>();
|
|
||||||
public Map<WorldCoord, LootBlock> lootedChunks;
|
|
||||||
public final NamespacedKey bossBarKey = new NamespacedKey(Main.getInstance(), "raidBar." + Raid.this.getName());
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructs raid for staging phase
|
* Constructs raid for staging phase
|
||||||
@@ -168,6 +167,10 @@ public class Raid {
|
|||||||
this.lootedChunks = new HashMap<>();
|
this.lootedChunks = new HashMap<>();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static /* synthetic */ void access$7(final Raid raid, final int raidTicks) {
|
||||||
|
raid.raidTicks = raidTicks;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Run when raid starts
|
* Run when raid starts
|
||||||
*/
|
*/
|
||||||
@@ -200,15 +203,13 @@ public class Raid {
|
|||||||
war.setLastRaidTimeSide1((int) (System.currentTimeMillis() / 1000));
|
war.setLastRaidTimeSide1((int) (System.currentTimeMillis() / 1000));
|
||||||
} else if (war.getSide2Players().contains(owner.getName())) {
|
} else if (war.getSide2Players().contains(owner.getName())) {
|
||||||
war.setLastRaidTimeSide2((int) (System.currentTimeMillis() / 1000));
|
war.setLastRaidTimeSide2((int) (System.currentTimeMillis() / 1000));
|
||||||
} else {
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
setupDisplayBar();
|
setupDisplayBar();
|
||||||
|
|
||||||
// Creates 10 second looping function for Raid
|
// Creates 10 second looping function for Raid
|
||||||
|
|
||||||
this.bukkitId[0] = Bukkit.getServer().getScheduler().scheduleSyncRepeatingTask((Plugin) Main.getInstance(),
|
this.bukkitId[0] = Bukkit.getServer().getScheduler().scheduleSyncRepeatingTask(Main.getInstance(),
|
||||||
getTickLoop(), 0L, incremental);
|
getTickLoop(), 0L, incremental);
|
||||||
|
|
||||||
this.getWar().addRaid(this);
|
this.getWar().addRaid(this);
|
||||||
@@ -216,7 +217,6 @@ public class Raid {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Resumes a Raid (after a server restart e.t.c.)
|
* Resumes a Raid (after a server restart e.t.c.)
|
||||||
*/
|
*/
|
||||||
@@ -242,12 +242,11 @@ public class Raid {
|
|||||||
setupDisplayBar();
|
setupDisplayBar();
|
||||||
|
|
||||||
// Creates 2 second looping function for Raid, restarting this!
|
// Creates 2 second looping function for Raid, restarting this!
|
||||||
this.bukkitId[0] = Bukkit.getServer().getScheduler().scheduleSyncRepeatingTask((Plugin) Main.getInstance(),
|
this.bukkitId[0] = Bukkit.getServer().getScheduler().scheduleSyncRepeatingTask(Main.getInstance(),
|
||||||
getTickLoop(), 0L, incremental);
|
getTickLoop(), 0L, incremental);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* End of raid
|
* End of raid
|
||||||
*/
|
*/
|
||||||
@@ -258,7 +257,6 @@ public class Raid {
|
|||||||
RaidData.removeRaid(this);
|
RaidData.removeRaid(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Do loot logic for a chunk, synchronized in case multiple players are looting at once and something breaks
|
* Do loot logic for a chunk, synchronized in case multiple players are looting at once and something breaks
|
||||||
*
|
*
|
||||||
@@ -286,11 +284,13 @@ public class Raid {
|
|||||||
//Broadcast to the whole raid
|
//Broadcast to the whole raid
|
||||||
for (String s : activeRaiders) {
|
for (String s : activeRaiders) {
|
||||||
Player pl = Bukkit.getPlayer(s);
|
Player pl = Bukkit.getPlayer(s);
|
||||||
if(pl != null) pl.sendMessage(Helper.chatLabel() + String.format("A townblock has been looted for $%.2f and +10 points. (Added to pool)", lb.value));
|
if (pl != null)
|
||||||
|
pl.sendMessage(Helper.chatLabel() + String.format("A townblock has been looted for $%.2f and +10 points. (Added to pool)", lb.value));
|
||||||
}
|
}
|
||||||
for (String s : defenderPlayers) {
|
for (String s : defenderPlayers) {
|
||||||
Player pl = Bukkit.getPlayer(s);
|
Player pl = Bukkit.getPlayer(s);
|
||||||
if(pl != null) pl.sendMessage(Helper.chatLabel() + String.format("A townblock has been looted for $%.2f and +10 points. (Added to pool)", lb.value));
|
if (pl != null)
|
||||||
|
pl.sendMessage(Helper.chatLabel() + String.format("A townblock has been looted for $%.2f and +10 points. (Added to pool)", lb.value));
|
||||||
}
|
}
|
||||||
|
|
||||||
this.save();
|
this.save();
|
||||||
@@ -300,11 +300,13 @@ public class Raid {
|
|||||||
this.addLootedChunk(wc);
|
this.addLootedChunk(wc);
|
||||||
for (String s : activeRaiders) {
|
for (String s : activeRaiders) {
|
||||||
Player pl = Bukkit.getPlayer(s);
|
Player pl = Bukkit.getPlayer(s);
|
||||||
if(pl != null) pl.sendMessage(String.valueOf(Helper.chatLabel()) + "Raiders have started looting a town block!");
|
if (pl != null)
|
||||||
|
pl.sendMessage(Helper.chatLabel() + "Raiders have started looting a town block!");
|
||||||
}
|
}
|
||||||
for (String s : defenderPlayers) {
|
for (String s : defenderPlayers) {
|
||||||
Player pl = Bukkit.getPlayer(s);
|
Player pl = Bukkit.getPlayer(s);
|
||||||
if(pl != null) pl.sendMessage(String.valueOf(Helper.chatLabel()) + "Raiders have started looting a town block!");
|
if (pl != null)
|
||||||
|
pl.sendMessage(Helper.chatLabel() + "Raiders have started looting a town block!");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -322,7 +324,7 @@ public class Raid {
|
|||||||
*/
|
*/
|
||||||
private void startTravel() {
|
private void startTravel() {
|
||||||
Raid.this.phase = RaidPhase.TRAVEL;
|
Raid.this.phase = RaidPhase.TRAVEL;
|
||||||
Bukkit.broadcastMessage(String.valueOf(Helper.chatLabel()) + "The Raiders of "
|
Bukkit.broadcastMessage(Helper.chatLabel() + "The Raiders of "
|
||||||
+ (side1AreRaiders ? Raid.this.war.getSide1() : Raid.this.war.getSide2())
|
+ (side1AreRaiders ? Raid.this.war.getSide1() : Raid.this.war.getSide2())
|
||||||
+ " are coming to raid "
|
+ " are coming to raid "
|
||||||
+ Raid.this.getRaidedTown().getName() + "!");
|
+ Raid.this.getRaidedTown().getName() + "!");
|
||||||
@@ -335,7 +337,7 @@ public class Raid {
|
|||||||
*/
|
*/
|
||||||
private void startCombat() {
|
private void startCombat() {
|
||||||
Raid.this.phase = RaidPhase.COMBAT;
|
Raid.this.phase = RaidPhase.COMBAT;
|
||||||
Bukkit.broadcastMessage(String.valueOf(Helper.chatLabel()) + "The Raiders of "
|
Bukkit.broadcastMessage(Helper.chatLabel() + "The Raiders of "
|
||||||
+ (side1AreRaiders ? Raid.this.war.getSide1() : Raid.this.war.getSide2())
|
+ (side1AreRaiders ? Raid.this.war.getSide1() : Raid.this.war.getSide2())
|
||||||
+ " have arrived at "
|
+ " have arrived at "
|
||||||
+ Raid.this.getRaidedTown().getName() + " and the fighting has begun!");
|
+ Raid.this.getRaidedTown().getName() + " and the fighting has begun!");
|
||||||
@@ -352,11 +354,11 @@ public class Raid {
|
|||||||
this.addPointsToDefenderScore(40);
|
this.addPointsToDefenderScore(40);
|
||||||
for (final String playerName : this.getActiveRaiders()) {
|
for (final String playerName : this.getActiveRaiders()) {
|
||||||
Player pl = Bukkit.getPlayer(playerName);
|
Player pl = Bukkit.getPlayer(playerName);
|
||||||
if(pl != null) pl.sendMessage(String.valueOf(Helper.chatLabel()) + "Raider killed! -40 Raid Score");
|
if (pl != null) pl.sendMessage(Helper.chatLabel() + "Raider killed! -40 Raid Score");
|
||||||
}
|
}
|
||||||
for (final String playerName : this.getDefenderPlayers()) {
|
for (final String playerName : this.getDefenderPlayers()) {
|
||||||
Player pl = Bukkit.getPlayer(playerName);
|
Player pl = Bukkit.getPlayer(playerName);
|
||||||
if(pl != null) pl.sendMessage(String.valueOf(Helper.chatLabel()) + "Raider killed! -40 Raid Score");
|
if (pl != null) pl.sendMessage(Helper.chatLabel() + "Raider killed! -40 Raid Score");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -367,11 +369,11 @@ public class Raid {
|
|||||||
this.addPointsToRaiderScore(20);
|
this.addPointsToRaiderScore(20);
|
||||||
for (final String playerName : this.getActiveRaiders()) {
|
for (final String playerName : this.getActiveRaiders()) {
|
||||||
Player pl = Bukkit.getPlayer(playerName);
|
Player pl = Bukkit.getPlayer(playerName);
|
||||||
if(pl != null) pl.sendMessage(String.valueOf(Helper.chatLabel()) + "Defender killed! +20 Raid Score");
|
if (pl != null) pl.sendMessage(Helper.chatLabel() + "Defender killed! +20 Raid Score");
|
||||||
}
|
}
|
||||||
for (final String playerName : this.getDefenderPlayers()) {
|
for (final String playerName : this.getDefenderPlayers()) {
|
||||||
Player pl = Bukkit.getPlayer(playerName);
|
Player pl = Bukkit.getPlayer(playerName);
|
||||||
if(pl != null) pl.sendMessage(String.valueOf(Helper.chatLabel()) + "Defender killed! +20 Raid Score");
|
if (pl != null) pl.sendMessage(Helper.chatLabel() + "Defender killed! +20 Raid Score");
|
||||||
}
|
}
|
||||||
|
|
||||||
// //tp to raid town spawn
|
// //tp to raid town spawn
|
||||||
@@ -390,11 +392,13 @@ public class Raid {
|
|||||||
//award negative score
|
//award negative score
|
||||||
for (final String playerName : this.getActiveRaiders()) {
|
for (final String playerName : this.getActiveRaiders()) {
|
||||||
Player pl = Bukkit.getPlayer(playerName);
|
Player pl = Bukkit.getPlayer(playerName);
|
||||||
if(pl != null) pl.sendMessage(String.valueOf(Helper.chatLabel()) + "Raider killed before combat, no points awarded and death treated normally.");
|
if (pl != null)
|
||||||
|
pl.sendMessage(Helper.chatLabel() + "Raider killed before combat, no points awarded and death treated normally.");
|
||||||
}
|
}
|
||||||
for (final String playerName : this.getDefenderPlayers()) {
|
for (final String playerName : this.getDefenderPlayers()) {
|
||||||
Player pl = Bukkit.getPlayer(playerName);
|
Player pl = Bukkit.getPlayer(playerName);
|
||||||
if(pl != null) pl.sendMessage(String.valueOf(Helper.chatLabel()) + "Raider killed before combat, no points awarded and death treated normally.");
|
if (pl != null)
|
||||||
|
pl.sendMessage(Helper.chatLabel() + "Raider killed before combat, no points awarded and death treated normally.");
|
||||||
}
|
}
|
||||||
//
|
//
|
||||||
// //tp to gather town spawn
|
// //tp to gather town spawn
|
||||||
@@ -411,7 +415,7 @@ public class Raid {
|
|||||||
if (this.getDefenderSide().contains(killed.getKiller().getName())) {
|
if (this.getDefenderSide().contains(killed.getKiller().getName())) {
|
||||||
try {
|
try {
|
||||||
killed.getKiller().teleport(this.getRaidedTown().getSpawn());
|
killed.getKiller().teleport(this.getRaidedTown().getSpawn());
|
||||||
killed.getKiller().sendMessage(String.valueOf(Helper.chatLabel()) + "You killed a raider before the raid began and have been teleported back to the defending town.");
|
killed.getKiller().sendMessage(Helper.chatLabel() + "You killed a raider before the raid began and have been teleported back to the defending town.");
|
||||||
} catch (TownyException e) {
|
} catch (TownyException e) {
|
||||||
throw new RuntimeException(e);
|
throw new RuntimeException(e);
|
||||||
}
|
}
|
||||||
@@ -425,11 +429,13 @@ public class Raid {
|
|||||||
public void defenderKilledOutofCombat(PlayerDeathEvent event) {
|
public void defenderKilledOutofCombat(PlayerDeathEvent event) {
|
||||||
for (final String playerName : this.getActiveRaiders()) {
|
for (final String playerName : this.getActiveRaiders()) {
|
||||||
Player pl = Bukkit.getPlayer(playerName);
|
Player pl = Bukkit.getPlayer(playerName);
|
||||||
if(pl != null) pl.sendMessage(String.valueOf(Helper.chatLabel()) + "Defender killed before combat, no points awarded and death treated normally.");
|
if (pl != null)
|
||||||
|
pl.sendMessage(Helper.chatLabel() + "Defender killed before combat, no points awarded and death treated normally.");
|
||||||
}
|
}
|
||||||
for (final String playerName : this.getDefenderPlayers()) {
|
for (final String playerName : this.getDefenderPlayers()) {
|
||||||
Player pl = Bukkit.getPlayer(playerName);
|
Player pl = Bukkit.getPlayer(playerName);
|
||||||
if(pl != null) pl.sendMessage(String.valueOf(Helper.chatLabel()) + "Defender killed before combat, no points awarded and death treated normally.");
|
if (pl != null)
|
||||||
|
pl.sendMessage(Helper.chatLabel() + "Defender killed before combat, no points awarded and death treated normally.");
|
||||||
}
|
}
|
||||||
|
|
||||||
//tp to raid town spawn
|
//tp to raid town spawn
|
||||||
@@ -444,7 +450,7 @@ public class Raid {
|
|||||||
if (this.getActiveRaiders().contains(killed.getKiller().getName())) {
|
if (this.getActiveRaiders().contains(killed.getKiller().getName())) {
|
||||||
try {
|
try {
|
||||||
killed.getKiller().teleport(this.getGatherTown().getSpawn());
|
killed.getKiller().teleport(this.getGatherTown().getSpawn());
|
||||||
killed.getKiller().sendMessage(String.valueOf(Helper.chatLabel()) + "You killed a defender before the raid began and have been teleported back to the gather town.");
|
killed.getKiller().sendMessage(Helper.chatLabel() + "You killed a defender before the raid began and have been teleported back to the gather town.");
|
||||||
} catch (TownyException e) {
|
} catch (TownyException e) {
|
||||||
throw new RuntimeException(e);
|
throw new RuntimeException(e);
|
||||||
}
|
}
|
||||||
@@ -454,7 +460,6 @@ public class Raid {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Raiders win, give payout and finalize raid
|
* Raiders win, give payout and finalize raid
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
public void raidersWin(final OfflinePlayer owner, int raiderScore, int defenderScore) {
|
public void raidersWin(final OfflinePlayer owner, int raiderScore, int defenderScore) {
|
||||||
//TODO finalize payout
|
//TODO finalize payout
|
||||||
@@ -467,7 +472,7 @@ public class Raid {
|
|||||||
if (factor > 3.0) factor = 3.0;
|
if (factor > 3.0) factor = 3.0;
|
||||||
if (factor < 0) factor = 0.0;
|
if (factor < 0) factor = 0.0;
|
||||||
|
|
||||||
Bukkit.broadcastMessage(String.valueOf(Helper.chatLabel()) + "The raiders from " + this.raiders
|
Bukkit.broadcastMessage(Helper.chatLabel() + "The raiders from " + this.raiders
|
||||||
+ " have successfully raided " + this.raidedTown.getName() + "!");
|
+ " have successfully raided " + this.raidedTown.getName() + "!");
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -537,7 +542,6 @@ public class Raid {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Defenders win, payout, and finalize raid
|
* Defenders win, payout, and finalize raid
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
public void defendersWin(int raiderScore, int defenderScore) {
|
public void defendersWin(int raiderScore, int defenderScore) {
|
||||||
//TODO finalize payout
|
//TODO finalize payout
|
||||||
@@ -595,7 +599,7 @@ public class Raid {
|
|||||||
public void noWinner() {
|
public void noWinner() {
|
||||||
//TODO finalize payout
|
//TODO finalize payout
|
||||||
|
|
||||||
Bukkit.broadcastMessage(String.valueOf(Helper.chatLabel()) + "The defenders from " + this.defenders
|
Bukkit.broadcastMessage(Helper.chatLabel() + "The defenders from " + this.defenders
|
||||||
+ " didn't push back the raiders of " + this.raiders + ". Yet no loot was taken, raid considered a draw.");
|
+ " didn't push back the raiders of " + this.raiders + ". Yet no loot was taken, raid considered a draw.");
|
||||||
Main.warLogger
|
Main.warLogger
|
||||||
.log("No one won the raid of " + this.raidedTown.getName() + "!");
|
.log("No one won the raid of " + this.raidedTown.getName() + "!");
|
||||||
@@ -642,7 +646,6 @@ public class Raid {
|
|||||||
return this.name;
|
return this.name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public War getWar() {
|
public War getWar() {
|
||||||
return this.war;
|
return this.war;
|
||||||
}
|
}
|
||||||
@@ -739,14 +742,21 @@ public class Raid {
|
|||||||
this.raidTicks = ticks;
|
this.raidTicks = ticks;
|
||||||
}
|
}
|
||||||
|
|
||||||
static /* synthetic */ void access$7(final Raid raid, final int raidTicks) {
|
|
||||||
raid.raidTicks = raidTicks;
|
|
||||||
}
|
|
||||||
|
|
||||||
public RaidPhase getPhase() {
|
public RaidPhase getPhase() {
|
||||||
return this.phase;
|
return this.phase;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setPhase(RaidPhase phase) {
|
||||||
|
this.phase = phase;
|
||||||
|
if (phase == RaidPhase.GATHER) {
|
||||||
|
startGather();
|
||||||
|
} else if (phase == RaidPhase.TRAVEL) {
|
||||||
|
startTravel();
|
||||||
|
} else if (phase == RaidPhase.COMBAT) {
|
||||||
|
startCombat();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void setRaidPhase(final RaidPhase phase) {
|
public void setRaidPhase(final RaidPhase phase) {
|
||||||
this.phase = phase;
|
this.phase = phase;
|
||||||
}
|
}
|
||||||
@@ -783,10 +793,7 @@ public class Raid {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private Runnable getTickLoop() {
|
private Runnable getTickLoop() {
|
||||||
return (Runnable) new Runnable() {
|
return () -> {
|
||||||
|
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
if (homeBlockRaided != null) {
|
if (homeBlockRaided != null) {
|
||||||
raidedTown.setHomeBlock(homeBlockRaided);
|
raidedTown.setHomeBlock(homeBlockRaided);
|
||||||
raidedTown.setSpawn(townSpawnRaided);
|
raidedTown.setSpawn(townSpawnRaided);
|
||||||
@@ -838,8 +845,8 @@ public class Raid {
|
|||||||
if (Raid.this.phase == RaidPhase.GATHER) {
|
if (Raid.this.phase == RaidPhase.GATHER) {
|
||||||
//Broadcast
|
//Broadcast
|
||||||
if (raidTicks % 6000 == 0) {
|
if (raidTicks % 6000 == 0) {
|
||||||
Bukkit.broadcastMessage(String.valueOf(Helper.chatLabel()) + "The raid of "
|
Bukkit.broadcastMessage(Helper.chatLabel() + "The raid of "
|
||||||
+ Raid.this.getRaidedTown().getName() + " will begin in " + (int) ((RaidPhase.TRAVEL.startTick - raidTicks) / 20 / 60) + " minutes!");
|
+ Raid.this.getRaidedTown().getName() + " will begin in " + ((RaidPhase.TRAVEL.startTick - raidTicks) / 20 / 60) + " minutes!");
|
||||||
Bukkit.broadcastMessage(
|
Bukkit.broadcastMessage(
|
||||||
"The Raiders are gathering at " + getGatherTown().getName() + " before making the journey over!");
|
"The Raiders are gathering at " + getGatherTown().getName() + " before making the journey over!");
|
||||||
}
|
}
|
||||||
@@ -854,12 +861,12 @@ public class Raid {
|
|||||||
if (!cluster.contains(WorldCoord.parseWorldCoord(p))) {
|
if (!cluster.contains(WorldCoord.parseWorldCoord(p))) {
|
||||||
if (p.equals(owner)) {
|
if (p.equals(owner)) {
|
||||||
p.teleport(gatherTown.getSpawn());
|
p.teleport(gatherTown.getSpawn());
|
||||||
p.sendMessage(String.valueOf(Helper.chatLabel()) + "You cannot leave the gather town. As raid party leader, you have remained in the party. To stop the raid type /raid abandon");
|
p.sendMessage(Helper.chatLabel() + "You cannot leave the gather town. As raid party leader, you have remained in the party. To stop the raid type /raid abandon");
|
||||||
p.sendMessage(String.valueOf(Helper.chatLabel()) + "You have been teleported to the gather town's spawn.");
|
p.sendMessage(Helper.chatLabel() + "You have been teleported to the gather town's spawn.");
|
||||||
} else {
|
} else {
|
||||||
Raid.this.removeActiveRaider(p.getName());
|
Raid.this.removeActiveRaider(p.getName());
|
||||||
p.sendMessage(String.valueOf(Helper.chatLabel()) + "By leaving the gathering town you have left the raid on " + Raid.this.getRaidedTown().getName() + "!");
|
p.sendMessage(Helper.chatLabel() + "By leaving the gathering town you have left the raid on " + Raid.this.getRaidedTown().getName() + "!");
|
||||||
p.sendMessage(String.valueOf(Helper.chatLabel()) + "To rejoin, do /raid join [war] [town]");
|
p.sendMessage(Helper.chatLabel() + "To rejoin, do /raid join [war] [town]");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -874,7 +881,7 @@ public class Raid {
|
|||||||
|
|
||||||
//Report
|
//Report
|
||||||
if (raidTicks % 2400 == 0) {
|
if (raidTicks % 2400 == 0) {
|
||||||
Bukkit.broadcastMessage(String.valueOf(Helper.chatLabel()) + "The Raiders of "
|
Bukkit.broadcastMessage(Helper.chatLabel() + "The Raiders of "
|
||||||
+ (side1AreRaiders ? Raid.this.war.getSide1() : Raid.this.war.getSide2())
|
+ (side1AreRaiders ? Raid.this.war.getSide1() : Raid.this.war.getSide2())
|
||||||
+ " are on their way to raid "
|
+ " are on their way to raid "
|
||||||
+ Raid.this.getRaidedTown().getName() + "!");
|
+ Raid.this.getRaidedTown().getName() + "!");
|
||||||
@@ -947,7 +954,6 @@ public class Raid {
|
|||||||
//refresh the existing display bar
|
//refresh the existing display bar
|
||||||
refreshDisplayBar();
|
refreshDisplayBar();
|
||||||
}
|
}
|
||||||
}
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -956,7 +962,7 @@ public class Raid {
|
|||||||
if (bossBar == null) bossBar = createNewDisplayBar();
|
if (bossBar == null) bossBar = createNewDisplayBar();
|
||||||
|
|
||||||
bossBar.setTitle(String.format("%d -- Raiders -Raid Score- Defenders -- %d", Raid.this.raiderScore, Raid.this.defenderScore));
|
bossBar.setTitle(String.format("%d -- Raiders -Raid Score- Defenders -- %d", Raid.this.raiderScore, Raid.this.defenderScore));
|
||||||
bossBar.setProgress((double) (Raid.this.raiderScore + 0.5D) / ((Raid.this.raiderScore + Raid.this.defenderScore) + 1.0D));
|
bossBar.setProgress((Raid.this.raiderScore + 0.5D) / ((Raid.this.raiderScore + Raid.this.defenderScore) + 1.0D));
|
||||||
|
|
||||||
for (String s : Raid.this.getActiveRaiders()) {
|
for (String s : Raid.this.getActiveRaiders()) {
|
||||||
Player p = Bukkit.getPlayer(s);
|
Player p = Bukkit.getPlayer(s);
|
||||||
@@ -1023,17 +1029,6 @@ public class Raid {
|
|||||||
this.homeBlockGather = homeBlockGather;
|
this.homeBlockGather = homeBlockGather;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setPhase(RaidPhase phase) {
|
|
||||||
this.phase = phase;
|
|
||||||
if(phase == RaidPhase.GATHER) {
|
|
||||||
startGather();
|
|
||||||
} else if(phase == RaidPhase.TRAVEL) {
|
|
||||||
startTravel();
|
|
||||||
} else if(phase == RaidPhase.COMBAT) {
|
|
||||||
startCombat();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public Location getTownSpawnRaided() {
|
public Location getTownSpawnRaided() {
|
||||||
return townSpawnRaided;
|
return townSpawnRaided;
|
||||||
}
|
}
|
||||||
@@ -1052,7 +1047,7 @@ public class Raid {
|
|||||||
|
|
||||||
public static class LootBlock {
|
public static class LootBlock {
|
||||||
|
|
||||||
public WorldCoord worldCoord;
|
public final WorldCoord worldCoord;
|
||||||
public int ticks;
|
public int ticks;
|
||||||
public double value;
|
public double value;
|
||||||
public boolean finished;
|
public boolean finished;
|
||||||
|
|||||||
@@ -1,30 +1,27 @@
|
|||||||
package me.ShermansWorld.AlathraWar;
|
package me.ShermansWorld.AlathraWar;
|
||||||
|
|
||||||
import com.palmergames.bukkit.towny.exceptions.TownyException;
|
|
||||||
import org.bukkit.*;
|
|
||||||
|
|
||||||
import com.palmergames.bukkit.towny.object.Nation;
|
|
||||||
import com.palmergames.bukkit.towny.object.Resident;
|
|
||||||
import com.palmergames.bukkit.towny.TownyUniverse;
|
|
||||||
import com.palmergames.bukkit.towny.TownyAPI;
|
import com.palmergames.bukkit.towny.TownyAPI;
|
||||||
|
import com.palmergames.bukkit.towny.TownyUniverse;
|
||||||
|
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 org.bukkit.*;
|
||||||
import org.bukkit.boss.BarColor;
|
import org.bukkit.boss.BarColor;
|
||||||
import org.bukkit.boss.BarStyle;
|
import org.bukkit.boss.BarStyle;
|
||||||
import org.bukkit.boss.BossBar;
|
import org.bukkit.boss.BossBar;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.plugin.Plugin;
|
|
||||||
import com.palmergames.bukkit.towny.exceptions.NotRegisteredException;
|
|
||||||
import com.palmergames.bukkit.towny.object.WorldCoord;
|
|
||||||
|
|
||||||
import me.ShermansWorld.AlathraWar.data.SiegeData;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import com.palmergames.bukkit.towny.object.Town;
|
|
||||||
import com.palmergames.bukkit.towny.object.TownBlock;
|
|
||||||
|
|
||||||
public class Siege {
|
public class Siege {
|
||||||
|
|
||||||
public static final int maxSiegeTicks = 72000; // 60 minute tick constant
|
public static final int maxSiegeTicks = 72000; // 60 minute tick constant
|
||||||
|
public final NamespacedKey bossBarKey;
|
||||||
|
public ArrayList<String> attackerPlayers;
|
||||||
|
public ArrayList<String> defenderPlayers;
|
||||||
|
public ArrayList<Location> beaconLocs;
|
||||||
|
int[] bukkitId;
|
||||||
private War war; // War which siege belongs to
|
private War war; // War which siege belongs to
|
||||||
private Town town; // Town of the siege
|
private Town town; // Town of the siege
|
||||||
private boolean side1AreAttackers; // bool of if side1 being attacker
|
private boolean side1AreAttackers; // bool of if side1 being attacker
|
||||||
@@ -34,30 +31,26 @@ public class Siege {
|
|||||||
private int siegeTicks;
|
private int siegeTicks;
|
||||||
private TownBlock homeBlock;
|
private TownBlock homeBlock;
|
||||||
private Location townSpawn;
|
private Location townSpawn;
|
||||||
int[] bukkitId;
|
|
||||||
public ArrayList<String> attackerPlayers;
|
|
||||||
public ArrayList<String> defenderPlayers;
|
|
||||||
public ArrayList<Location> beaconLocs;
|
|
||||||
public final NamespacedKey bossBarKey;
|
|
||||||
|
|
||||||
|
|
||||||
public Siege(final War war, final Town town, OfflinePlayer siegeLeader) {
|
public Siege(final War war, final Town town, OfflinePlayer siegeLeader) {
|
||||||
this.siegeTicks = 0;
|
this.siegeTicks = 0;
|
||||||
this.bukkitId = new int[1];
|
this.bukkitId = new int[1];
|
||||||
this.attackerPlayers = new ArrayList<String>();
|
this.attackerPlayers = new ArrayList<>();
|
||||||
this.defenderPlayers = new ArrayList<String>();
|
this.defenderPlayers = new ArrayList<>();
|
||||||
this.beaconLocs = new ArrayList<Location>();
|
this.beaconLocs = new ArrayList<>();
|
||||||
this.war = war;
|
this.war = war;
|
||||||
this.town = town;
|
this.town = town;
|
||||||
this.siegeLeader = siegeLeader;
|
this.siegeLeader = siegeLeader;
|
||||||
|
|
||||||
bossBarKey = new NamespacedKey(Main.getInstance(), "siegeBar." + this.getName());
|
bossBarKey = new NamespacedKey(Main.getInstance(), "siegeBar." + this.getName());
|
||||||
|
|
||||||
if (war.getSide(town.getName()) == 2) side1AreAttackers = true;
|
side1AreAttackers = war.getSide(town.getName()) == 2;
|
||||||
else side1AreAttackers = false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Starts a siege */
|
/**
|
||||||
|
* Starts a siege
|
||||||
|
*/
|
||||||
public void start() {
|
public void start() {
|
||||||
attackerPoints = 0;
|
attackerPoints = 0;
|
||||||
defenderPoints = 0;
|
defenderPoints = 0;
|
||||||
@@ -65,12 +58,14 @@ public class Siege {
|
|||||||
homeBlock = town.getHomeBlockOrNull();
|
homeBlock = town.getHomeBlockOrNull();
|
||||||
townSpawn = town.getSpawnOrNull();
|
townSpawn = town.getSpawnOrNull();
|
||||||
|
|
||||||
this.bukkitId[0] = Bukkit.getServer().getScheduler().scheduleSyncRepeatingTask((Plugin) Main.getInstance(), getTickLoop(), 0L, 200L);
|
this.bukkitId[0] = Bukkit.getServer().getScheduler().scheduleSyncRepeatingTask(Main.getInstance(), getTickLoop(), 0L, 200L);
|
||||||
|
|
||||||
setupDisplayBar();
|
setupDisplayBar();
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Resumes a siege (after a server restart e.t.c.)*/
|
/**
|
||||||
|
* Resumes a siege (after a server restart e.t.c.)
|
||||||
|
*/
|
||||||
public void resume(int resumeTick) {
|
public void resume(int resumeTick) {
|
||||||
|
|
||||||
siegeTicks = resumeTick;
|
siegeTicks = resumeTick;
|
||||||
@@ -78,12 +73,14 @@ public class Siege {
|
|||||||
homeBlock = town.getHomeBlockOrNull();
|
homeBlock = town.getHomeBlockOrNull();
|
||||||
townSpawn = town.getSpawnOrNull();
|
townSpawn = town.getSpawnOrNull();
|
||||||
|
|
||||||
this.bukkitId[0] = Bukkit.getServer().getScheduler().scheduleSyncRepeatingTask((Plugin) Main.getInstance(), getTickLoop(), 0L, 200L);
|
this.bukkitId[0] = Bukkit.getServer().getScheduler().scheduleSyncRepeatingTask(Main.getInstance(), getTickLoop(), 0L, 200L);
|
||||||
|
|
||||||
setupDisplayBar();
|
setupDisplayBar();
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Stops a siege */
|
/**
|
||||||
|
* Stops a siege
|
||||||
|
*/
|
||||||
public void stop() {
|
public void stop() {
|
||||||
deleteDisplayBar();
|
deleteDisplayBar();
|
||||||
Bukkit.getScheduler().cancelTask(this.bukkitId[0]);
|
Bukkit.getScheduler().cancelTask(this.bukkitId[0]);
|
||||||
@@ -140,7 +137,7 @@ public class Siege {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (NotRegisteredException ignored) {
|
} catch (NotRegisteredException ignored) {
|
||||||
Main.warLogger.log(Helper.chatLabel() + "Attempting to look for town at " + WorldCoord.parseWorldCoord(pl).toString());
|
Main.warLogger.log(Helper.chatLabel() + "Attempting to look for town at " + WorldCoord.parseWorldCoord(pl));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (final String playerName : Siege.this.defenderPlayers) {
|
for (final String playerName : Siege.this.defenderPlayers) {
|
||||||
@@ -162,21 +159,21 @@ public class Siege {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (NotRegisteredException ignored) {
|
} catch (NotRegisteredException ignored) {
|
||||||
Main.warLogger.log(Helper.chatLabel() + "Attempting to look for town at " + WorldCoord.parseWorldCoord(pl).toString());
|
Main.warLogger.log(Helper.chatLabel() + "Attempting to look for town at " + WorldCoord.parseWorldCoord(pl));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (attackersAreOnHomeBlock && defendersAreOnHomeBlock) { // Contested
|
if (attackersAreOnHomeBlock && defendersAreOnHomeBlock) { // Contested
|
||||||
if (this.homeBlockControl != 1) {
|
if (this.homeBlockControl != 1) {
|
||||||
for (final String playerName : Siege.this.attackerPlayers) {
|
for (final String playerName : Siege.this.attackerPlayers) {
|
||||||
try {
|
try {
|
||||||
Bukkit.getPlayer(playerName).sendMessage(String.valueOf(Helper.chatLabel())
|
Bukkit.getPlayer(playerName).sendMessage(Helper.chatLabel()
|
||||||
+ "HomeBlock at " + Siege.this.town.getName() + " contested!");
|
+ "HomeBlock at " + Siege.this.town.getName() + " contested!");
|
||||||
} catch (NullPointerException ex5) {
|
} catch (NullPointerException ex5) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (final String playerName : Siege.this.defenderPlayers) {
|
for (final String playerName : Siege.this.defenderPlayers) {
|
||||||
try {
|
try {
|
||||||
Bukkit.getPlayer(playerName).sendMessage(String.valueOf(Helper.chatLabel())
|
Bukkit.getPlayer(playerName).sendMessage(Helper.chatLabel()
|
||||||
+ "HomeBlock at " + Siege.this.town.getName() + " contested!");
|
+ "HomeBlock at " + Siege.this.town.getName() + " contested!");
|
||||||
} catch (NullPointerException ex6) {
|
} catch (NullPointerException ex6) {
|
||||||
}
|
}
|
||||||
@@ -187,7 +184,7 @@ public class Siege {
|
|||||||
if (this.homeBlockControl != 2) {
|
if (this.homeBlockControl != 2) {
|
||||||
for (final String playerName : Siege.this.attackerPlayers) {
|
for (final String playerName : Siege.this.attackerPlayers) {
|
||||||
try {
|
try {
|
||||||
Bukkit.getPlayer(playerName).sendMessage(String.valueOf(Helper.chatLabel())
|
Bukkit.getPlayer(playerName).sendMessage(Helper.chatLabel()
|
||||||
+ "Attackers have captured the HomeBlock at "
|
+ "Attackers have captured the HomeBlock at "
|
||||||
+ Siege.this.town.getName() + "! +1 Attacker Points per second");
|
+ Siege.this.town.getName() + "! +1 Attacker Points per second");
|
||||||
} catch (NullPointerException ex7) {
|
} catch (NullPointerException ex7) {
|
||||||
@@ -195,7 +192,7 @@ public class Siege {
|
|||||||
}
|
}
|
||||||
for (final String playerName : Siege.this.defenderPlayers) {
|
for (final String playerName : Siege.this.defenderPlayers) {
|
||||||
try {
|
try {
|
||||||
Bukkit.getPlayer(playerName).sendMessage(String.valueOf(Helper.chatLabel())
|
Bukkit.getPlayer(playerName).sendMessage(Helper.chatLabel()
|
||||||
+ "Attackers have captured the HomeBlock at "
|
+ "Attackers have captured the HomeBlock at "
|
||||||
+ Siege.this.town.getName() + "! +1 Attacker Points per second");
|
+ Siege.this.town.getName() + "! +1 Attacker Points per second");
|
||||||
} catch (NullPointerException ex8) {
|
} catch (NullPointerException ex8) {
|
||||||
@@ -208,7 +205,7 @@ public class Siege {
|
|||||||
if (this.homeBlockControl != 3) {
|
if (this.homeBlockControl != 3) {
|
||||||
for (final String playerName : Siege.this.attackerPlayers) {
|
for (final String playerName : Siege.this.attackerPlayers) {
|
||||||
try {
|
try {
|
||||||
Bukkit.getPlayer(playerName).sendMessage(String.valueOf(Helper.chatLabel())
|
Bukkit.getPlayer(playerName).sendMessage(Helper.chatLabel()
|
||||||
+ "Defenders retain control of the HomeBlock at "
|
+ "Defenders retain control of the HomeBlock at "
|
||||||
+ Siege.this.town.getName() + "! +1 Defender Points per second");
|
+ Siege.this.town.getName() + "! +1 Defender Points per second");
|
||||||
} catch (NullPointerException ex9) {
|
} catch (NullPointerException ex9) {
|
||||||
@@ -216,7 +213,7 @@ public class Siege {
|
|||||||
}
|
}
|
||||||
for (final String playerName : Siege.this.defenderPlayers) {
|
for (final String playerName : Siege.this.defenderPlayers) {
|
||||||
try {
|
try {
|
||||||
Bukkit.getPlayer(playerName).sendMessage(String.valueOf(Helper.chatLabel())
|
Bukkit.getPlayer(playerName).sendMessage(Helper.chatLabel()
|
||||||
+ "Defenders retain control of the HomeBlock at "
|
+ "Defenders retain control of the HomeBlock at "
|
||||||
+ Siege.this.town.getName() + "! +1 Defender Points per second");
|
+ Siege.this.town.getName() + "! +1 Defender Points per second");
|
||||||
} catch (NullPointerException ex10) {
|
} catch (NullPointerException ex10) {
|
||||||
@@ -227,12 +224,12 @@ public class Siege {
|
|||||||
this.homeBlockControl = 3;
|
this.homeBlockControl = 3;
|
||||||
}
|
}
|
||||||
if (Siege.this.siegeTicks % 6000 == 0) { // Updates every 5 minutes
|
if (Siege.this.siegeTicks % 6000 == 0) { // Updates every 5 minutes
|
||||||
Bukkit.broadcastMessage(String.valueOf(Helper.chatLabel()) + "Report on the siege of "
|
Bukkit.broadcastMessage(Helper.chatLabel() + "Report on the siege of "
|
||||||
+ Siege.this.town.getName() + ":");
|
+ Siege.this.town.getName() + ":");
|
||||||
Bukkit.broadcastMessage(
|
Bukkit.broadcastMessage(
|
||||||
"Attacker Points - " + String.valueOf(Siege.this.attackerPoints));
|
"Attacker Points - " + Siege.this.attackerPoints);
|
||||||
Bukkit.broadcastMessage(
|
Bukkit.broadcastMessage(
|
||||||
"Defender Points - " + String.valueOf(Siege.this.defenderPoints));
|
"Defender Points - " + Siege.this.defenderPoints);
|
||||||
}
|
}
|
||||||
if (siegeTicks % 1200 == 0) { // Saves every minute
|
if (siegeTicks % 1200 == 0) { // Saves every minute
|
||||||
save();
|
save();
|
||||||
@@ -243,19 +240,19 @@ public class Siege {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
public void attackersWin(final OfflinePlayer siegeLeader) {
|
public void attackersWin(final OfflinePlayer siegeLeader) {
|
||||||
final Resident resident = TownyAPI.getInstance().getResident(siegeLeader.getUniqueId());
|
final Resident resident = TownyAPI.getInstance().getResident(siegeLeader.getUniqueId());
|
||||||
Nation nation = null;
|
Nation nation = null;
|
||||||
Bukkit.broadcastMessage(String.valueOf(Helper.chatLabel()) + "The attackers have won the siege of " + this.town.getName() + "!");
|
Bukkit.broadcastMessage(Helper.chatLabel() + "The attackers have won the siege of " + this.town.getName() + "!");
|
||||||
try {
|
try {
|
||||||
nation = resident.getTown().getNation();
|
nation = resident.getTown().getNation();
|
||||||
} catch (Exception e) {}
|
} catch (Exception e) {
|
||||||
|
}
|
||||||
if (nation != null) {
|
if (nation != null) {
|
||||||
Bukkit.broadcastMessage(String.valueOf(Helper.chatLabel()) + "The town of " + this.town.getName()
|
Bukkit.broadcastMessage(Helper.chatLabel() + "The town of " + this.town.getName()
|
||||||
+ " has been placed under occupation by " + nation.getName() + "!");
|
+ " has been placed under occupation by " + nation.getName() + "!");
|
||||||
}
|
}
|
||||||
Main.econ.depositPlayer(siegeLeader, 2500.0);
|
Main.econ.depositPlayer(siegeLeader, 2500.0);
|
||||||
@@ -266,7 +263,7 @@ public class Siege {
|
|||||||
} else {
|
} else {
|
||||||
if (this.town.getAccount().getHoldingBalance() < 2500.0) {
|
if (this.town.getAccount().getHoldingBalance() < 2500.0) {
|
||||||
amt = this.town.getAccount().getHoldingBalance();
|
amt = this.town.getAccount().getHoldingBalance();
|
||||||
Bukkit.broadcastMessage(String.valueOf(Helper.chatLabel()) + "The town of " + this.town.getName()
|
Bukkit.broadcastMessage(Helper.chatLabel() + "The town of " + this.town.getName()
|
||||||
+ " has been destroyed by " + this.getAttackerSide() + "!");
|
+ " has been destroyed by " + this.getAttackerSide() + "!");
|
||||||
TownyUniverse.getInstance().getDataSource().deleteTown(this.town);
|
TownyUniverse.getInstance().getDataSource().deleteTown(this.town);
|
||||||
Main.econ.depositPlayer(siegeLeader, amt);
|
Main.econ.depositPlayer(siegeLeader, amt);
|
||||||
@@ -276,9 +273,9 @@ public class Siege {
|
|||||||
amt = 2500.0;
|
amt = 2500.0;
|
||||||
}
|
}
|
||||||
Bukkit.broadcastMessage("The town of " + this.town.getName() + " has been sacked by " + this.getAttackerSide()
|
Bukkit.broadcastMessage("The town of " + this.town.getName() + " has been sacked by " + this.getAttackerSide()
|
||||||
+ ", valuing $" + String.valueOf(amt));
|
+ ", valuing $" + amt);
|
||||||
Main.warLogger.log("The town of " + this.town.getName() + " has been sacked by " + this.getAttackerSide()
|
Main.warLogger.log("The town of " + this.town.getName() + " has been sacked by " + this.getAttackerSide()
|
||||||
+ ", valuing $" + String.valueOf(amt));
|
+ ", valuing $" + amt);
|
||||||
Main.econ.depositPlayer(siegeLeader, amt);
|
Main.econ.depositPlayer(siegeLeader, amt);
|
||||||
|
|
||||||
if (side1AreAttackers) {
|
if (side1AreAttackers) {
|
||||||
@@ -293,8 +290,8 @@ public class Siege {
|
|||||||
|
|
||||||
public void defendersWin() {
|
public void defendersWin() {
|
||||||
this.town.getAccount().deposit(2500.0, "War chest");
|
this.town.getAccount().deposit(2500.0, "War chest");
|
||||||
Bukkit.broadcastMessage(String.valueOf(Helper.chatLabel()) + "The defenders have won the siege of " + this.town.getName() + "!");
|
Bukkit.broadcastMessage(Helper.chatLabel() + "The defenders have won the siege of " + this.town.getName() + "!");
|
||||||
Bukkit.broadcastMessage(String.valueOf(Helper.chatLabel()) + 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
|
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() + "!");
|
||||||
@@ -313,8 +310,8 @@ public class Siege {
|
|||||||
* No winnder declared
|
* No winnder declared
|
||||||
*/
|
*/
|
||||||
public void noWinner() {
|
public void noWinner() {
|
||||||
Bukkit.broadcastMessage(String.valueOf(Helper.chatLabel()) + "The siege of " + this.town.getName() + " was a draw!");
|
Bukkit.broadcastMessage(Helper.chatLabel() + "The siege of " + this.town.getName() + " was a draw!");
|
||||||
Bukkit.broadcastMessage(String.valueOf(Helper.chatLabel()) + "No money has been recovered.");
|
Bukkit.broadcastMessage(Helper.chatLabel() + "No money has been recovered.");
|
||||||
Main.warLogger
|
Main.warLogger
|
||||||
.log(war.getName() + ": No one won the siege of " + this.town.getName() + "!");
|
.log(war.getName() + ": No one won the siege of " + this.town.getName() + "!");
|
||||||
stop();
|
stop();
|
||||||
@@ -339,34 +336,34 @@ public class Siege {
|
|||||||
homeBlockZ += 8;
|
homeBlockZ += 8;
|
||||||
}
|
}
|
||||||
int homeBlockY = 253;
|
int homeBlockY = 253;
|
||||||
final Location beaconLoc = new Location(this.town.getWorld(), (double) homeBlockX,
|
final Location beaconLoc = new Location(this.town.getWorld(), homeBlockX,
|
||||||
(double) (homeBlockY - 2), (double) homeBlockZ);
|
homeBlockY - 2, homeBlockZ);
|
||||||
while (beaconLoc.getBlock().getType().equals((Object) Material.AIR)) {
|
while (beaconLoc.getBlock().getType().equals(Material.AIR)) {
|
||||||
--homeBlockY;
|
--homeBlockY;
|
||||||
beaconLoc.setY((double) homeBlockY);
|
beaconLoc.setY(homeBlockY);
|
||||||
}
|
}
|
||||||
homeBlockY += 2;
|
homeBlockY += 2;
|
||||||
this.beaconLocs.add(new Location(world, (double) homeBlockX, (double) homeBlockY, (double) homeBlockZ));
|
this.beaconLocs.add(new Location(world, homeBlockX, homeBlockY, homeBlockZ));
|
||||||
this.beaconLocs
|
this.beaconLocs
|
||||||
.add(new Location(world, (double) homeBlockX, (double) (homeBlockY + 1), (double) homeBlockZ));
|
.add(new Location(world, homeBlockX, homeBlockY + 1, homeBlockZ));
|
||||||
this.beaconLocs
|
this.beaconLocs
|
||||||
.add(new Location(world, (double) homeBlockX, (double) (homeBlockY - 1), (double) homeBlockZ));
|
.add(new Location(world, homeBlockX, homeBlockY - 1, homeBlockZ));
|
||||||
this.beaconLocs.add(
|
this.beaconLocs.add(
|
||||||
new Location(world, (double) (homeBlockX + 1), (double) (homeBlockY - 1), (double) homeBlockZ));
|
new Location(world, homeBlockX + 1, homeBlockY - 1, homeBlockZ));
|
||||||
this.beaconLocs.add(
|
this.beaconLocs.add(
|
||||||
new Location(world, (double) (homeBlockX - 1), (double) (homeBlockY - 1), (double) homeBlockZ));
|
new Location(world, homeBlockX - 1, homeBlockY - 1, homeBlockZ));
|
||||||
this.beaconLocs.add(
|
this.beaconLocs.add(
|
||||||
new Location(world, (double) homeBlockX, (double) (homeBlockY - 1), (double) (homeBlockZ + 1)));
|
new Location(world, homeBlockX, homeBlockY - 1, homeBlockZ + 1));
|
||||||
this.beaconLocs.add(
|
this.beaconLocs.add(
|
||||||
new Location(world, (double) homeBlockX, (double) (homeBlockY - 1), (double) (homeBlockZ - 1)));
|
new Location(world, homeBlockX, homeBlockY - 1, homeBlockZ - 1));
|
||||||
this.beaconLocs.add(new Location(world, (double) (homeBlockX + 1), (double) (homeBlockY - 1),
|
this.beaconLocs.add(new Location(world, homeBlockX + 1, homeBlockY - 1,
|
||||||
(double) (homeBlockZ + 1)));
|
homeBlockZ + 1));
|
||||||
this.beaconLocs.add(new Location(world, (double) (homeBlockX + 1), (double) (homeBlockY - 1),
|
this.beaconLocs.add(new Location(world, homeBlockX + 1, homeBlockY - 1,
|
||||||
(double) (homeBlockZ - 1)));
|
homeBlockZ - 1));
|
||||||
this.beaconLocs.add(new Location(world, (double) (homeBlockX - 1), (double) (homeBlockY - 1),
|
this.beaconLocs.add(new Location(world, homeBlockX - 1, homeBlockY - 1,
|
||||||
(double) (homeBlockZ + 1)));
|
homeBlockZ + 1));
|
||||||
this.beaconLocs.add(new Location(world, (double) (homeBlockX - 1), (double) (homeBlockY - 1),
|
this.beaconLocs.add(new Location(world, homeBlockX - 1, homeBlockY - 1,
|
||||||
(double) (homeBlockZ - 1)));
|
homeBlockZ - 1));
|
||||||
for (int i = 2; i < this.beaconLocs.size(); ++i) {
|
for (int i = 2; i < this.beaconLocs.size(); ++i) {
|
||||||
if (this.beaconLocs.get(i).getBlock().getType() != Material.AIR) {
|
if (this.beaconLocs.get(i).getBlock().getType() != Material.AIR) {
|
||||||
i = 1;
|
i = 1;
|
||||||
@@ -387,25 +384,25 @@ public class Siege {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void resetBeacon(World world, int homeBlockX, int homeBlockY, int homeBlockZ) {
|
public void resetBeacon(World world, int homeBlockX, int homeBlockY, int homeBlockZ) {
|
||||||
this.beaconLocs.add(new Location(world, (double) homeBlockX, (double) homeBlockY, (double) homeBlockZ));
|
this.beaconLocs.add(new Location(world, homeBlockX, homeBlockY, homeBlockZ));
|
||||||
this.beaconLocs.add(new Location(world, (double) homeBlockX, (double) (homeBlockY + 1), (double) homeBlockZ));
|
this.beaconLocs.add(new Location(world, homeBlockX, homeBlockY + 1, homeBlockZ));
|
||||||
this.beaconLocs.add(new Location(world, (double) homeBlockX, (double) (homeBlockY - 1), (double) homeBlockZ));
|
this.beaconLocs.add(new Location(world, homeBlockX, homeBlockY - 1, homeBlockZ));
|
||||||
this.beaconLocs
|
this.beaconLocs
|
||||||
.add(new Location(world, (double) (homeBlockX + 1), (double) (homeBlockY - 1), (double) homeBlockZ));
|
.add(new Location(world, homeBlockX + 1, homeBlockY - 1, homeBlockZ));
|
||||||
this.beaconLocs
|
this.beaconLocs
|
||||||
.add(new Location(world, (double) (homeBlockX - 1), (double) (homeBlockY - 1), (double) homeBlockZ));
|
.add(new Location(world, homeBlockX - 1, homeBlockY - 1, homeBlockZ));
|
||||||
this.beaconLocs
|
this.beaconLocs
|
||||||
.add(new Location(world, (double) homeBlockX, (double) (homeBlockY - 1), (double) (homeBlockZ + 1)));
|
.add(new Location(world, homeBlockX, homeBlockY - 1, homeBlockZ + 1));
|
||||||
this.beaconLocs
|
this.beaconLocs
|
||||||
.add(new Location(world, (double) homeBlockX, (double) (homeBlockY - 1), (double) (homeBlockZ - 1)));
|
.add(new Location(world, homeBlockX, homeBlockY - 1, homeBlockZ - 1));
|
||||||
this.beaconLocs.add(
|
this.beaconLocs.add(
|
||||||
new Location(world, (double) (homeBlockX + 1), (double) (homeBlockY - 1), (double) (homeBlockZ + 1)));
|
new Location(world, homeBlockX + 1, homeBlockY - 1, homeBlockZ + 1));
|
||||||
this.beaconLocs.add(
|
this.beaconLocs.add(
|
||||||
new Location(world, (double) (homeBlockX + 1), (double) (homeBlockY - 1), (double) (homeBlockZ - 1)));
|
new Location(world, homeBlockX + 1, homeBlockY - 1, homeBlockZ - 1));
|
||||||
this.beaconLocs.add(
|
this.beaconLocs.add(
|
||||||
new Location(world, (double) (homeBlockX - 1), (double) (homeBlockY - 1), (double) (homeBlockZ + 1)));
|
new Location(world, homeBlockX - 1, homeBlockY - 1, homeBlockZ + 1));
|
||||||
this.beaconLocs.add(
|
this.beaconLocs.add(
|
||||||
new Location(world, (double) (homeBlockX - 1), (double) (homeBlockY - 1), (double) (homeBlockZ - 1)));
|
new Location(world, homeBlockX - 1, homeBlockY - 1, homeBlockZ - 1));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void clearBeacon() {
|
public void clearBeacon() {
|
||||||
@@ -446,7 +443,9 @@ public class Siege {
|
|||||||
this.siegeLeader = siegeOwner;
|
this.siegeLeader = siegeOwner;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Gets attacker name string */
|
/**
|
||||||
|
* Gets attacker name string
|
||||||
|
*/
|
||||||
public String getAttackerSide() {
|
public String getAttackerSide() {
|
||||||
if (side1AreAttackers) {
|
if (side1AreAttackers) {
|
||||||
return war.getSide1();
|
return war.getSide1();
|
||||||
@@ -455,7 +454,9 @@ public class Siege {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Gets defender name string */
|
/**
|
||||||
|
* Gets defender name string
|
||||||
|
*/
|
||||||
public String getDefenderSide() {
|
public String getDefenderSide() {
|
||||||
if (side1AreAttackers) {
|
if (side1AreAttackers) {
|
||||||
return war.getSide2();
|
return war.getSide2();
|
||||||
@@ -469,7 +470,7 @@ public class Siege {
|
|||||||
if (bossBar == null) bossBar = createNewDisplayBar();
|
if (bossBar == null) bossBar = createNewDisplayBar();
|
||||||
|
|
||||||
bossBar.setTitle(String.format("%d -- Attackers -Siege Score- Defenders -- %d", this.attackerPoints, this.defenderPoints));
|
bossBar.setTitle(String.format("%d -- Attackers -Siege Score- Defenders -- %d", this.attackerPoints, this.defenderPoints));
|
||||||
bossBar.setProgress((double) (this.attackerPoints + 0.5D) / ((this.attackerPoints + this.defenderPoints) + 1.0D));
|
bossBar.setProgress((this.attackerPoints + 0.5D) / ((this.attackerPoints + this.defenderPoints) + 1.0D));
|
||||||
|
|
||||||
for (String s : this.getAttackerPlayers()) {
|
for (String s : this.getAttackerPlayers()) {
|
||||||
Player p = Bukkit.getPlayer(s);
|
Player p = Bukkit.getPlayer(s);
|
||||||
@@ -521,16 +522,20 @@ public class Siege {
|
|||||||
return this.attackerPoints;
|
return this.attackerPoints;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setAttackerPoints(int points) {
|
||||||
|
this.attackerPoints = points;
|
||||||
|
}
|
||||||
|
|
||||||
public int getDefenderPoints() {
|
public int getDefenderPoints() {
|
||||||
return this.defenderPoints;
|
return this.defenderPoints;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getMaxSiegeTicks() {
|
public void setDefenderPoints(int points) {
|
||||||
return maxSiegeTicks;
|
this.defenderPoints = points;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setSiegeTicks(int siegeTicks) {
|
public int getMaxSiegeTicks() {
|
||||||
this.siegeTicks = siegeTicks;
|
return maxSiegeTicks;
|
||||||
}
|
}
|
||||||
|
|
||||||
public TownBlock getHomeBlock() {
|
public TownBlock getHomeBlock() {
|
||||||
@@ -549,14 +554,6 @@ public class Siege {
|
|||||||
this.townSpawn = townSpawn;
|
this.townSpawn = townSpawn;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setAttackerPoints(int points) {
|
|
||||||
this.attackerPoints = points;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setDefenderPoints(int points) {
|
|
||||||
this.defenderPoints = points;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean getSide1AreAttackers() {
|
public boolean getSide1AreAttackers() {
|
||||||
return this.side1AreAttackers;
|
return this.side1AreAttackers;
|
||||||
}
|
}
|
||||||
@@ -585,6 +582,10 @@ public class Siege {
|
|||||||
return siegeTicks;
|
return siegeTicks;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setSiegeTicks(int siegeTicks) {
|
||||||
|
this.siegeTicks = siegeTicks;
|
||||||
|
}
|
||||||
|
|
||||||
public OfflinePlayer getSiegeLeader() {
|
public OfflinePlayer getSiegeLeader() {
|
||||||
return siegeLeader;
|
return siegeLeader;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,37 +1,37 @@
|
|||||||
package me.ShermansWorld.AlathraWar;
|
package me.ShermansWorld.AlathraWar;
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
|
|
||||||
import com.palmergames.bukkit.towny.TownyAPI;
|
import com.palmergames.bukkit.towny.TownyAPI;
|
||||||
import com.palmergames.bukkit.towny.object.Nation;
|
import com.palmergames.bukkit.towny.object.Nation;
|
||||||
import com.palmergames.bukkit.towny.object.Resident;
|
import com.palmergames.bukkit.towny.object.Resident;
|
||||||
import com.palmergames.bukkit.towny.object.Town;
|
import com.palmergames.bukkit.towny.object.Town;
|
||||||
|
|
||||||
import me.ShermansWorld.AlathraWar.commands.CommandHelper;
|
import me.ShermansWorld.AlathraWar.commands.CommandHelper;
|
||||||
import me.ShermansWorld.AlathraWar.data.DataManager;
|
import me.ShermansWorld.AlathraWar.data.DataManager;
|
||||||
import me.ShermansWorld.AlathraWar.data.WarData;
|
import me.ShermansWorld.AlathraWar.data.WarData;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
|
||||||
public class War {
|
public class War {
|
||||||
|
|
||||||
// Object Fields
|
// Object Fields
|
||||||
private String name;
|
private String name;
|
||||||
private String side1;
|
private String side1;
|
||||||
private String side2;
|
private String side2;
|
||||||
private ArrayList<String> side1Towns = new ArrayList<String>();
|
private ArrayList<String> side1Towns = new ArrayList<>();
|
||||||
private ArrayList<String> side2Towns = new ArrayList<String>();
|
private ArrayList<String> side2Towns = new ArrayList<>();
|
||||||
private ArrayList<String> surrenderedTowns = new ArrayList<String>();
|
private ArrayList<String> surrenderedTowns = new ArrayList<>();
|
||||||
private int side1Points = 0;
|
private int side1Points = 0;
|
||||||
private int side2Points = 0;
|
private int side2Points = 0;
|
||||||
|
|
||||||
// References
|
// References
|
||||||
private ArrayList<Siege> sieges = new ArrayList<Siege>();
|
private final ArrayList<Siege> sieges = new ArrayList<>();
|
||||||
private ArrayList<Raid> raids = new ArrayList<Raid>();
|
private final ArrayList<Raid> raids = new ArrayList<>();
|
||||||
private int lastRaidTimeSide1 = 0;
|
private int lastRaidTimeSide1 = 0;
|
||||||
private int lastRaidTimeSide2 = 0;
|
private int lastRaidTimeSide2 = 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* War Constructor
|
* War Constructor
|
||||||
|
*
|
||||||
* @param name - Name of war
|
* @param name - Name of war
|
||||||
* @param side1 - Side 1 name
|
* @param side1 - Side 1 name
|
||||||
* @param side2 - Side 2 name
|
* @param side2 - Side 2 name
|
||||||
@@ -42,8 +42,25 @@ public class War {
|
|||||||
this.side2 = side2;
|
this.side2 = side2;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static ArrayList<String> townListToPlayers(ArrayList<String> townList) {
|
||||||
|
ArrayList<String> returnList = new ArrayList<>();
|
||||||
|
for (String townString : townList) {
|
||||||
|
Town town = TownyAPI.getInstance().getTown(townString);
|
||||||
|
if (town != null) {
|
||||||
|
for (Resident res : town.getResidents()) {
|
||||||
|
//Minuteman countermeasure! if they are they get skipped
|
||||||
|
if (CommandHelper.isPlayerMinuteman(res.getName()) == 0) {
|
||||||
|
returnList.add(res.getName());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return returnList;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add a nation to a side of the war
|
* Add a nation to a side of the war
|
||||||
|
*
|
||||||
* @param nation - Nation object
|
* @param nation - Nation object
|
||||||
* @param side - Side name
|
* @param side - Side name
|
||||||
*/
|
*/
|
||||||
@@ -55,6 +72,7 @@ public class War {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Add a town to a side of the war
|
* Add a town to a side of the war
|
||||||
|
*
|
||||||
* @param town - Town object
|
* @param town - Town object
|
||||||
* @param side - Side name
|
* @param side - Side name
|
||||||
*/
|
*/
|
||||||
@@ -64,6 +82,7 @@ public class War {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Add a town to a side of the war
|
* Add a town to a side of the war
|
||||||
|
*
|
||||||
* @param town - Town object
|
* @param town - Town object
|
||||||
* @param side - Side name
|
* @param side - Side name
|
||||||
*/
|
*/
|
||||||
@@ -86,6 +105,7 @@ public class War {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Surrenders town
|
* Surrenders town
|
||||||
|
*
|
||||||
* @param nation - Nation to surrender
|
* @param nation - Nation to surrender
|
||||||
*/
|
*/
|
||||||
public void surrenderNation(Nation nation) {
|
public void surrenderNation(Nation nation) {
|
||||||
@@ -98,6 +118,7 @@ public class War {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Surrenders town
|
* Surrenders town
|
||||||
|
*
|
||||||
* @param town - Town to surrender
|
* @param town - Town to surrender
|
||||||
*/
|
*/
|
||||||
public void surrenderTown(String town) {
|
public void surrenderTown(String town) {
|
||||||
@@ -108,6 +129,7 @@ public class War {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* unsurrender town, perfidy time
|
* unsurrender town, perfidy time
|
||||||
|
*
|
||||||
* @param nation - Nation to unsurrender
|
* @param nation - Nation to unsurrender
|
||||||
*/
|
*/
|
||||||
public void unSurrenderNation(Nation nation) {
|
public void unSurrenderNation(Nation nation) {
|
||||||
@@ -118,6 +140,7 @@ public class War {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* unsurrender town, perfidy time
|
* unsurrender town, perfidy time
|
||||||
|
*
|
||||||
* @param town - Town to unsurrender
|
* @param town - Town to unsurrender
|
||||||
*/
|
*/
|
||||||
public void unSurrenderTown(String town) {
|
public void unSurrenderTown(String town) {
|
||||||
@@ -130,6 +153,7 @@ public class War {
|
|||||||
* 0 - None
|
* 0 - None
|
||||||
* 1 - Side 1
|
* 1 - Side 1
|
||||||
* 2 - Side 2
|
* 2 - Side 2
|
||||||
|
*
|
||||||
* @param string town
|
* @param string town
|
||||||
* @return result
|
* @return result
|
||||||
*/
|
*/
|
||||||
@@ -156,14 +180,28 @@ public class War {
|
|||||||
return this.name;
|
return this.name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setName(String name) {
|
||||||
|
DataManager.deleteFile("wars" + File.separator + this.getName() + ".yml");
|
||||||
|
this.name = name;
|
||||||
|
this.save();
|
||||||
|
}
|
||||||
|
|
||||||
public String getSide1() {
|
public String getSide1() {
|
||||||
return this.side1;
|
return this.side1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setSide1(String side1) {
|
||||||
|
this.side1 = side1;
|
||||||
|
}
|
||||||
|
|
||||||
public String getSide2() {
|
public String getSide2() {
|
||||||
return this.side2;
|
return this.side2;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setSide2(String side2) {
|
||||||
|
this.side2 = side2;
|
||||||
|
}
|
||||||
|
|
||||||
public ArrayList<String> getSide1Towns() {
|
public ArrayList<String> getSide1Towns() {
|
||||||
return this.side1Towns;
|
return this.side1Towns;
|
||||||
}
|
}
|
||||||
@@ -204,20 +242,6 @@ public class War {
|
|||||||
raids.add(raid);
|
raids.add(raid);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setName(String name) {
|
|
||||||
DataManager.deleteFile("wars" + File.separator + this.getName() + ".yml");
|
|
||||||
this.name = name;
|
|
||||||
this.save();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setSide1(String side1) {
|
|
||||||
this.side1 = side1;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setSide2(String side2) {
|
|
||||||
this.side2 = side2;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Saves the war into .yml file folders.
|
* Saves the war into .yml file folders.
|
||||||
*/
|
*/
|
||||||
@@ -239,46 +263,38 @@ public class War {
|
|||||||
return townListToPlayers(side2Towns);
|
return townListToPlayers(side2Towns);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static ArrayList<String> townListToPlayers(ArrayList<String> townList) {
|
public int getLastRaidTimeSide1() {
|
||||||
ArrayList<String> returnList = new ArrayList<String>();
|
return this.lastRaidTimeSide1;
|
||||||
for (String townString : townList) {
|
|
||||||
Town town = TownyAPI.getInstance().getTown(townString);
|
|
||||||
if (town != null) {
|
|
||||||
for (Resident res : town.getResidents()) {
|
|
||||||
//Minuteman countermeasure! if they are they get skipped
|
|
||||||
if (CommandHelper.isPlayerMinuteman(res.getName()) == 0) {
|
|
||||||
returnList.add(res.getName());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return returnList;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setLastRaidTimeSide1(int lastRaidTime) {
|
public void setLastRaidTimeSide1(int lastRaidTime) {
|
||||||
this.lastRaidTimeSide1 = lastRaidTime;
|
this.lastRaidTimeSide1 = lastRaidTime;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getLastRaidTimeSide1() {
|
public int getLastRaidTimeSide2() {
|
||||||
return this.lastRaidTimeSide1;
|
return this.lastRaidTimeSide2;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setLastRaidTimeSide2(int lastRaidTime) {
|
public void setLastRaidTimeSide2(int lastRaidTime) {
|
||||||
this.lastRaidTimeSide2 = lastRaidTime;
|
this.lastRaidTimeSide2 = lastRaidTime;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getLastRaidTimeSide2() {
|
|
||||||
return this.lastRaidTimeSide2;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getSide1Points() {
|
public int getSide1Points() {
|
||||||
return this.side1Points;
|
return this.side1Points;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setSide1Points(int side1Points) {
|
||||||
|
this.side1Points = side1Points;
|
||||||
|
}
|
||||||
|
|
||||||
public int getSide2Points() {
|
public int getSide2Points() {
|
||||||
return this.side2Points;
|
return this.side2Points;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setSide2Points(int side2Points) {
|
||||||
|
this.side2Points = side2Points;
|
||||||
|
}
|
||||||
|
|
||||||
public void addSide1Points(int points) {
|
public void addSide1Points(int points) {
|
||||||
side1Points += points;
|
side1Points += points;
|
||||||
}
|
}
|
||||||
@@ -286,12 +302,4 @@ public class War {
|
|||||||
public void addSide2Points(int points) {
|
public void addSide2Points(int points) {
|
||||||
side2Points += points;
|
side2Points += points;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setSide1Points(int side1Points) {
|
|
||||||
this.side1Points = side1Points;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setSide2Points(int side2Points) {
|
|
||||||
this.side2Points = side2Points;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
@@ -21,6 +21,7 @@ import org.bukkit.command.CommandExecutor;
|
|||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
import java.sql.Timestamp;
|
import java.sql.Timestamp;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
@@ -35,122 +36,10 @@ public class AdminCommands implements CommandExecutor {
|
|||||||
plugin.getCommand("awa").setExecutor(this);
|
plugin.getCommand("awa").setExecutor(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* //done
|
|
||||||
* //edit war/event in real time, side can be "both" to effect both
|
|
||||||
* -modify raid score [war] [town] [value]
|
|
||||||
* -modify raid townspawn [war] [town] (x) (Z)
|
|
||||||
* -modify raid gather [war] [town] [town]
|
|
||||||
* -modify raid phase [war] [town] [phase] //"next" to move to next phase
|
|
||||||
* -modify raid loot [war] [town] (x) (z) [value,looted,ticks,reset] [amt] //no coords just does current chunk, reset deletes it from the list
|
|
||||||
* -modify raid time [war] [town] [add/set] [value]
|
|
||||||
* -modify raid owner [war] [town] [add/set] [value]
|
|
||||||
* -modify raid move [war] [town] [newWar] //low priority, moves raid to other war
|
|
||||||
* -modify raid clearActive [war] [town] //low priority
|
|
||||||
* <p>
|
|
||||||
* -modify siege score [war] [town] [side] [amt]
|
|
||||||
* -modify siege homeblock [war] [town] (x) (Z)
|
|
||||||
* -modify siege time [war] [town] [add/set/max] [value] //max modified the max length
|
|
||||||
* -modify siege owner [war] [town] [add/set] [value]
|
|
||||||
* -modify siege move [war] [town] [newWar] //low priority, moves siege to other war
|
|
||||||
* <p>
|
|
||||||
* -modify war score [war] [side] [amt]
|
|
||||||
* -modify war side [war] [side] [name]
|
|
||||||
* -modify war name [war] [name]
|
|
||||||
* -modify war add town [war] [town]
|
|
||||||
* -modify war add nation [war] [nation]
|
|
||||||
* -modify war surrender town [war] [town] //adds town to surrender list
|
|
||||||
* -modify war surrender nation [war] [town] //adds all towns to surrender list
|
|
||||||
* -modify war raidTime [add,set,reset] [war] [town] [amt] //set when last raid was
|
|
||||||
* <p>
|
|
||||||
* // low priority idea
|
|
||||||
* -info war score [war]
|
|
||||||
* -info war surrenderedTowns [war]
|
|
||||||
* -info war raids [war]
|
|
||||||
* -info war sieges [war]
|
|
||||||
* -info war towns [war]
|
|
||||||
* -info war lastRaidTime [war]
|
|
||||||
* <p>
|
|
||||||
* -info raid homeblock [war] [town]
|
|
||||||
* -info raid lootedTownBlocks [war] [town]
|
|
||||||
* -info raid timeSinceLastRaid [town]
|
|
||||||
* <p>
|
|
||||||
* -info siege homeblock [war] [town]
|
|
||||||
* <p>
|
|
||||||
* //done
|
|
||||||
* //force make event or war, if owner isnt defined, idk havent decided
|
|
||||||
* -create siege [war] [town] (owner)
|
|
||||||
* -create raid [war] [raidTown] (gatherTown) (owner)
|
|
||||||
* -create war [name] [side1] [side2]
|
|
||||||
* <p>
|
|
||||||
* //force end a war/event, can declare winner side, or no winner
|
|
||||||
* -force end war [war] (side/victor)
|
|
||||||
* -force end siege [war] [town] (side/victor)
|
|
||||||
* -force end raid [war] [town] (side/victor)
|
|
||||||
* <p>
|
|
||||||
* //done
|
|
||||||
* //force player into or out of a war/event
|
|
||||||
* -force join war [player] [war] [side]
|
|
||||||
* -force join siege [player] [war] [town] (side)
|
|
||||||
* -force join raid [player] [war] [town] (side)
|
|
||||||
* <p>
|
|
||||||
* //done
|
|
||||||
* -force leave raid [war] [player] (timeout) //kicks from raid party
|
|
||||||
* <p>
|
|
||||||
* // Ultra low priority idea
|
|
||||||
* -rule raidersRespawnAtGatherTown [true/false]
|
|
||||||
* -rule siegersRespawnAtTown [true/false]
|
|
||||||
* -rule anyoneCanJoinRaid [true/false]
|
|
||||||
*
|
|
||||||
* @param sender Source of the command
|
|
||||||
* @param command Command which was executed
|
|
||||||
* @param label Alias of the command which was used
|
|
||||||
* @param args Passed command arguments
|
|
||||||
* @return Valid command
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
|
||||||
CommandHelper.logCommand(sender, label, args);
|
|
||||||
if (!sender.hasPermission("AlathraWar.admin")) {
|
|
||||||
return fail(sender, args, "permissions");
|
|
||||||
}
|
|
||||||
|
|
||||||
if (args.length == 0) {
|
|
||||||
return fail(sender, args, "syntax");
|
|
||||||
} else if (args.length >= 1) {
|
|
||||||
if (args[0].equalsIgnoreCase("create")) {
|
|
||||||
return create(sender, args);
|
|
||||||
} else if (args[0].equalsIgnoreCase("force")) {
|
|
||||||
return force(sender, args);
|
|
||||||
} else if (args[0].equalsIgnoreCase("help")) {
|
|
||||||
return help(sender, args);
|
|
||||||
} else if (args[0].equalsIgnoreCase("info")) {
|
|
||||||
return info(sender, args);
|
|
||||||
} else if (args[0].equalsIgnoreCase("modify")) {
|
|
||||||
return modify(sender, args);
|
|
||||||
} else if (args[0].equalsIgnoreCase("awa")) {
|
|
||||||
return awa(sender, args);
|
|
||||||
} else if (args[0].equalsIgnoreCase("purgebars")) {
|
|
||||||
return purgebars(sender, args);
|
|
||||||
} else if (args[0].equalsIgnoreCase("save")) {
|
|
||||||
return save(sender, args);
|
|
||||||
} else if (args[0].equalsIgnoreCase("save-all")) {
|
|
||||||
return saveAll(sender, args);
|
|
||||||
} else if (args[0].equalsIgnoreCase("load")) {
|
|
||||||
return load(sender, args);
|
|
||||||
} else if (args[0].equalsIgnoreCase("load-all")) {
|
|
||||||
return loadAll(sender, args);
|
|
||||||
} else if (args[0].equalsIgnoreCase("item")) {
|
|
||||||
return item(sender, args);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
private static boolean item(CommandSender sender, String[] args) {
|
private static boolean item(CommandSender sender, String[] args) {
|
||||||
if (args.length >= 2) {
|
if (args.length >= 2) {
|
||||||
//find item
|
//find item
|
||||||
ItemStack stack = null;
|
ItemStack stack;
|
||||||
if (args[1].contains(Main.getInstance().getName().toLowerCase())) {
|
if (args[1].contains(Main.getInstance().getName().toLowerCase())) {
|
||||||
stack = WarItemRegistry.getInstance().getOrNullNamespace(args[1]);
|
stack = WarItemRegistry.getInstance().getOrNullNamespace(args[1]);
|
||||||
} else {
|
} else {
|
||||||
@@ -175,7 +64,7 @@ public class AdminCommands implements CommandExecutor {
|
|||||||
stack.setAmount(amt);
|
stack.setAmount(amt);
|
||||||
|
|
||||||
//determine who gets the item
|
//determine who gets the item
|
||||||
Player reciever = null;
|
Player reciever;
|
||||||
if (args.length >= 4) {
|
if (args.length >= 4) {
|
||||||
reciever = Bukkit.getPlayer(args[3]);
|
reciever = Bukkit.getPlayer(args[3]);
|
||||||
} else {
|
} else {
|
||||||
@@ -301,7 +190,6 @@ public class AdminCommands implements CommandExecutor {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* //force make event or war, if owner isn't defined, idk haven't decided
|
* //force make event or war, if owner isn't defined, idk haven't decided
|
||||||
* -create siege [war] [town] (owner)
|
* -create siege [war] [town] (owner)
|
||||||
@@ -316,12 +204,11 @@ public class AdminCommands implements CommandExecutor {
|
|||||||
//using same method so that this doesnt get fucked up if we go back and change original implementation
|
//using same method so that this doesnt get fucked up if we go back and change original implementation
|
||||||
RaidCommands.startRaid(p, args, true);
|
RaidCommands.startRaid(p, args, true);
|
||||||
p.sendMessage(Helper.color("&cForcefully started raid from the console."));
|
p.sendMessage(Helper.color("&cForcefully started raid from the console."));
|
||||||
return true;
|
|
||||||
} else {
|
} else {
|
||||||
//defaultCode will bypass the custom gather town to force set owner
|
//defaultCode will bypass the custom gather town to force set owner
|
||||||
p.sendMessage(Helper.color("&cUsage: /alathrawaradmin create raid [war] [raidTown] (gatherTown/\"defaultCode\") (owner) (override)"));
|
p.sendMessage(Helper.color("&cUsage: /alathrawaradmin create raid [war] [raidTown] (gatherTown/\"defaultCode\") (owner) (override)"));
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
return true;
|
||||||
} else if (args[1].equalsIgnoreCase("siege")) {
|
} else if (args[1].equalsIgnoreCase("siege")) {
|
||||||
//this exists to force a seige with a new owner
|
//this exists to force a seige with a new owner
|
||||||
if (args.length >= 4) {
|
if (args.length >= 4) {
|
||||||
@@ -334,11 +221,10 @@ public class AdminCommands implements CommandExecutor {
|
|||||||
SiegeCommands.siegeStart(p, l.toArray(new String[]{}), true);
|
SiegeCommands.siegeStart(p, l.toArray(new String[]{}), true);
|
||||||
// p.sendMessage(Helper.Chatlabel() + "Try again later!");
|
// p.sendMessage(Helper.Chatlabel() + "Try again later!");
|
||||||
p.sendMessage(Helper.color("&cForcefully started siege from the console."));
|
p.sendMessage(Helper.color("&cForcefully started siege from the console."));
|
||||||
return true;
|
|
||||||
} else {
|
} else {
|
||||||
p.sendMessage(Helper.color("&cUsage: /alathrawaradmin create siege [war] [town] (owner) (force)"));
|
p.sendMessage(Helper.color("&cUsage: /alathrawaradmin create siege [war] [town] (owner) (force)"));
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
return true;
|
||||||
} else if (args[1].equalsIgnoreCase("war")) {
|
} else if (args[1].equalsIgnoreCase("war")) {
|
||||||
//this command basically is a copy or /war create
|
//this command basically is a copy or /war create
|
||||||
if (args.length == 5) {
|
if (args.length == 5) {
|
||||||
@@ -351,11 +237,10 @@ public class AdminCommands implements CommandExecutor {
|
|||||||
};
|
};
|
||||||
WarCommands.warCreate(p, adjusted);
|
WarCommands.warCreate(p, adjusted);
|
||||||
p.sendMessage(Helper.color("&cForcefully started war from the console."));
|
p.sendMessage(Helper.color("&cForcefully started war from the console."));
|
||||||
return true;
|
|
||||||
} else {
|
} else {
|
||||||
p.sendMessage(Helper.color("&cUsage: /alathrawaradmin create war [name] [side1] [side2]"));
|
p.sendMessage(Helper.color("&cUsage: /alathrawaradmin create war [name] [side1] [side2]"));
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
return fail(p, args, "syntax");
|
return fail(p, args, "syntax");
|
||||||
@@ -541,11 +426,10 @@ public class AdminCommands implements CommandExecutor {
|
|||||||
WarCommands.warJoin(p, adjusted, true);
|
WarCommands.warJoin(p, adjusted, true);
|
||||||
p.sendMessage(Helper.color("&cForced " + args[3] + " to join the war " + args[4] + " on side " + args[5]));
|
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]);
|
Main.warLogger.log("Forced " + args[3] + " to join the war " + args[4] + " on side " + args[5]);
|
||||||
return true;
|
|
||||||
} else {
|
} else {
|
||||||
p.sendMessage(Helper.color("&cUsage: /alathrawaradmin force join war [player] [war] [side]"));
|
p.sendMessage(Helper.color("&cUsage: /alathrawaradmin force join war [player] [war] [side]"));
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
return true;
|
||||||
} else {
|
} else {
|
||||||
p.sendMessage(Helper.color("&cUsage: /alathrawaradmin force join [raid/siege/war]"));
|
p.sendMessage(Helper.color("&cUsage: /alathrawaradmin force join [raid/siege/war]"));
|
||||||
return true;
|
return true;
|
||||||
@@ -658,8 +542,10 @@ public class AdminCommands implements CommandExecutor {
|
|||||||
side1Players.append(", ");
|
side1Players.append(", ");
|
||||||
}
|
}
|
||||||
//cut off last two characters
|
//cut off last two characters
|
||||||
if(side1Towns.length() > 2) side1Towns = new StringBuilder(side1Towns.substring(0, side1Towns.length() - 2));
|
if (side1Towns.length() > 2)
|
||||||
if(side1Players.length() > 2) side1Players = new StringBuilder(side1Players.substring(0, side1Players.length() - 2));
|
side1Towns = new StringBuilder(side1Towns.substring(0, side1Towns.length() - 2));
|
||||||
|
if (side1Players.length() > 2)
|
||||||
|
side1Players = new StringBuilder(side1Players.substring(0, side1Players.length() - 2));
|
||||||
p.sendMessage(Helper.chatLabel() + w.getSide1() + " Towns: " + side1Towns);
|
p.sendMessage(Helper.chatLabel() + w.getSide1() + " Towns: " + side1Towns);
|
||||||
p.sendMessage(Helper.chatLabel() + w.getSide1() + " Players: " + side1Players);
|
p.sendMessage(Helper.chatLabel() + w.getSide1() + " Players: " + side1Players);
|
||||||
|
|
||||||
@@ -675,19 +561,15 @@ public class AdminCommands implements CommandExecutor {
|
|||||||
side2Players.append(", ");
|
side2Players.append(", ");
|
||||||
}
|
}
|
||||||
//cut off last two characters
|
//cut off last two characters
|
||||||
if(side2Towns.length() > 2) side2Towns = new StringBuilder(side2Towns.substring(0, side2Towns.length() - 2));
|
if (side2Towns.length() > 2)
|
||||||
if(side2Players.length() > 2) side2Players = new StringBuilder(side2Players.substring(0, side2Players.length() - 2));
|
side2Towns = new StringBuilder(side2Towns.substring(0, side2Towns.length() - 2));
|
||||||
|
if (side2Players.length() > 2)
|
||||||
|
side2Players = new StringBuilder(side2Players.substring(0, side2Players.length() - 2));
|
||||||
p.sendMessage(Helper.chatLabel() + w.getSide2() + " Towns: " + side2Towns);
|
p.sendMessage(Helper.chatLabel() + w.getSide2() + " Towns: " + side2Towns);
|
||||||
p.sendMessage(Helper.chatLabel() + w.getSide2() + " Players: " + side2Players);
|
p.sendMessage(Helper.chatLabel() + w.getSide2() + " Players: " + side2Players);
|
||||||
|
|
||||||
p.sendMessage(Helper.chatLabel() + "oOo------------===------------oOo");
|
p.sendMessage(Helper.chatLabel() + "oOo------------===------------oOo");
|
||||||
StringBuilder surrenderedTowns = new StringBuilder();
|
final StringBuilder surrenderedTowns = getSurrenderedTowns(w);
|
||||||
for (String t : w.getSurrenderedTowns()) {
|
|
||||||
surrenderedTowns.append(t);
|
|
||||||
surrenderedTowns.append(", ");
|
|
||||||
}
|
|
||||||
//cut off last two characters
|
|
||||||
if(surrenderedTowns.length() > 2) surrenderedTowns = new StringBuilder(surrenderedTowns.substring(0, surrenderedTowns.length() - 2));
|
|
||||||
p.sendMessage(Helper.chatLabel() + "Surrendered Towns: " + surrenderedTowns);
|
p.sendMessage(Helper.chatLabel() + "Surrendered Towns: " + surrenderedTowns);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -718,23 +600,11 @@ public class AdminCommands implements CommandExecutor {
|
|||||||
p.sendMessage(Helper.chatLabel() + "Gather Homeblock: " + (r.getHomeBlockGather() == null ? "NONE" : r.getHomeBlockGather().toString()));
|
p.sendMessage(Helper.chatLabel() + "Gather Homeblock: " + (r.getHomeBlockGather() == null ? "NONE" : r.getHomeBlockGather().toString()));
|
||||||
p.sendMessage(Helper.chatLabel() + "Raided Homeblock: " + (r.getHomeBlockRaided() == null ? "NONE" : r.getHomeBlockRaided().toString()));
|
p.sendMessage(Helper.chatLabel() + "Raided Homeblock: " + (r.getHomeBlockRaided() == null ? "NONE" : r.getHomeBlockRaided().toString()));
|
||||||
p.sendMessage(Helper.chatLabel() + "oOo------------===------------oOo");
|
p.sendMessage(Helper.chatLabel() + "oOo------------===------------oOo");
|
||||||
StringBuilder activeRaiders = new StringBuilder();
|
final StringBuilder activeRaiders = getActiveRaiders(r);
|
||||||
for (String pl : r.getActiveRaiders()) {
|
|
||||||
activeRaiders.append(pl);
|
|
||||||
activeRaiders.append(", ");
|
|
||||||
}
|
|
||||||
//cut off last two characters
|
|
||||||
if(activeRaiders.length() > 2) activeRaiders = new StringBuilder(activeRaiders.substring(0, activeRaiders.length() - 2));
|
|
||||||
p.sendMessage(Helper.chatLabel() + "Raiding Players: " + activeRaiders);
|
p.sendMessage(Helper.chatLabel() + "Raiding Players: " + activeRaiders);
|
||||||
|
|
||||||
p.sendMessage(Helper.chatLabel() + "oOo------------===------------oOo");
|
p.sendMessage(Helper.chatLabel() + "oOo------------===------------oOo");
|
||||||
StringBuilder defenderPlayers = new StringBuilder();
|
final StringBuilder defenderPlayers = getDefenderPlayers(r);
|
||||||
for (String pl : r.getDefenderPlayers()) {
|
|
||||||
defenderPlayers.append(pl);
|
|
||||||
defenderPlayers.append(", ");
|
|
||||||
}
|
|
||||||
//cut off last two characters
|
|
||||||
if(defenderPlayers.length() > 2) defenderPlayers = new StringBuilder(defenderPlayers.substring(0, defenderPlayers.length() - 2));
|
|
||||||
p.sendMessage(Helper.chatLabel() + "Defending Players: " + defenderPlayers);
|
p.sendMessage(Helper.chatLabel() + "Defending Players: " + defenderPlayers);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -768,7 +638,8 @@ public class AdminCommands implements CommandExecutor {
|
|||||||
attackers.append(", ");
|
attackers.append(", ");
|
||||||
}
|
}
|
||||||
//cut off last two characters
|
//cut off last two characters
|
||||||
if(attackers.length() > 2) attackers = new StringBuilder(attackers.substring(0, attackers.length() - 2));
|
if (attackers.length() > 2)
|
||||||
|
attackers = new StringBuilder(attackers.substring(0, attackers.length() - 2));
|
||||||
p.sendMessage(Helper.chatLabel() + "Attacking Players: " + attackers);
|
p.sendMessage(Helper.chatLabel() + "Attacking Players: " + attackers);
|
||||||
StringBuilder defenders = new StringBuilder();
|
StringBuilder defenders = new StringBuilder();
|
||||||
for (String pl : s.getDefenderPlayers()) {
|
for (String pl : s.getDefenderPlayers()) {
|
||||||
@@ -776,7 +647,8 @@ public class AdminCommands implements CommandExecutor {
|
|||||||
defenders.append(", ");
|
defenders.append(", ");
|
||||||
}
|
}
|
||||||
//cut off last two characters
|
//cut off last two characters
|
||||||
if(defenders.length() > 2) defenders = new StringBuilder(defenders.substring(0, defenders.length() - 2));
|
if (defenders.length() > 2)
|
||||||
|
defenders = new StringBuilder(defenders.substring(0, defenders.length() - 2));
|
||||||
p.sendMessage(Helper.chatLabel() + "Defending Players: " + defenders);
|
p.sendMessage(Helper.chatLabel() + "Defending Players: " + defenders);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -793,6 +665,45 @@ public class AdminCommands implements CommandExecutor {
|
|||||||
return fail(p, args, "syntax");
|
return fail(p, args, "syntax");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@NotNull
|
||||||
|
private static StringBuilder getDefenderPlayers(Raid r) {
|
||||||
|
StringBuilder defenderPlayers = new StringBuilder();
|
||||||
|
for (String pl : r.getDefenderPlayers()) {
|
||||||
|
defenderPlayers.append(pl);
|
||||||
|
defenderPlayers.append(", ");
|
||||||
|
}
|
||||||
|
//cut off last two characters
|
||||||
|
if (defenderPlayers.length() > 2)
|
||||||
|
defenderPlayers = new StringBuilder(defenderPlayers.substring(0, defenderPlayers.length() - 2));
|
||||||
|
return defenderPlayers;
|
||||||
|
}
|
||||||
|
|
||||||
|
@NotNull
|
||||||
|
private static StringBuilder getActiveRaiders(Raid r) {
|
||||||
|
StringBuilder activeRaiders = new StringBuilder();
|
||||||
|
for (String pl : r.getActiveRaiders()) {
|
||||||
|
activeRaiders.append(pl);
|
||||||
|
activeRaiders.append(", ");
|
||||||
|
}
|
||||||
|
//cut off last two characters
|
||||||
|
if (activeRaiders.length() > 2)
|
||||||
|
activeRaiders = new StringBuilder(activeRaiders.substring(0, activeRaiders.length() - 2));
|
||||||
|
return activeRaiders;
|
||||||
|
}
|
||||||
|
|
||||||
|
@NotNull
|
||||||
|
private static StringBuilder getSurrenderedTowns(War w) {
|
||||||
|
StringBuilder surrenderedTowns = new StringBuilder();
|
||||||
|
for (String t : w.getSurrenderedTowns()) {
|
||||||
|
surrenderedTowns.append(t);
|
||||||
|
surrenderedTowns.append(", ");
|
||||||
|
}
|
||||||
|
//cut off last two characters
|
||||||
|
if (surrenderedTowns.length() > 2)
|
||||||
|
surrenderedTowns = new StringBuilder(surrenderedTowns.substring(0, surrenderedTowns.length() - 2));
|
||||||
|
return surrenderedTowns;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* //edit war/event in real time, side can be "both" to effect both
|
* //edit war/event in real time, side can be "both" to effect both
|
||||||
* -modify raid score [add/set] [war] [town] [value]
|
* -modify raid score [add/set] [war] [town] [value]
|
||||||
@@ -949,7 +860,7 @@ public class AdminCommands implements CommandExecutor {
|
|||||||
t.setSpawn(new Location(runner.getWorld(), Double.parseDouble(args[5]), Double.parseDouble(args[6]), Double.parseDouble(args[7])));
|
t.setSpawn(new Location(runner.getWorld(), Double.parseDouble(args[5]), Double.parseDouble(args[6]), Double.parseDouble(args[7])));
|
||||||
r.setHomeBlockRaided(tb.getTownBlock());
|
r.setHomeBlockRaided(tb.getTownBlock());
|
||||||
r.setTownSpawnRaided(t.getSpawn());
|
r.setTownSpawnRaided(t.getSpawn());
|
||||||
p.sendMessage(Helper.chatLabel() + "Set town spawn for raided town " + args[4] + " in war " + args[3] + " to " + runner.getLocation().toString());
|
p.sendMessage(Helper.chatLabel() + "Set town spawn for raided town " + args[4] + " in war " + args[3] + " to " + runner.getLocation());
|
||||||
Main.warLogger.log("Set town spawn for raided town " + args[4] + " in war " + args[3] + " to [" + args[5] + "," + args[6] + "," + args[7] + "]");
|
Main.warLogger.log("Set town spawn for raided town " + args[4] + " in war " + args[3] + " to [" + args[5] + "," + args[6] + "," + args[7] + "]");
|
||||||
return finalizeRaid(r);
|
return finalizeRaid(r);
|
||||||
} else {
|
} else {
|
||||||
@@ -980,8 +891,8 @@ public class AdminCommands implements CommandExecutor {
|
|||||||
t.setSpawn(runner.getLocation());
|
t.setSpawn(runner.getLocation());
|
||||||
r.setHomeBlockRaided(tb.getTownBlock());
|
r.setHomeBlockRaided(tb.getTownBlock());
|
||||||
r.setTownSpawnRaided(t.getSpawn());
|
r.setTownSpawnRaided(t.getSpawn());
|
||||||
p.sendMessage(Helper.chatLabel() + "Set town spawn for raided town " + args[4] + " in war " + args[3] + " to " + runner.getLocation().toString());
|
p.sendMessage(Helper.chatLabel() + "Set town spawn for raided town " + args[4] + " in war " + args[3] + " to " + runner.getLocation());
|
||||||
Main.warLogger.log("Set town spawn for raided town " + args[4] + " in war " + args[3] + " to " + runner.getLocation().toString());
|
Main.warLogger.log("Set town spawn for raided town " + args[4] + " in war " + args[3] + " to " + runner.getLocation());
|
||||||
return finalizeRaid(r);
|
return finalizeRaid(r);
|
||||||
} else {
|
} else {
|
||||||
p.sendMessage(Helper.color("&cTown does not contain town block at your location [" + (int) runner.getLocation().getX() + "," + (int) runner.getLocation().getZ() + "]"));
|
p.sendMessage(Helper.color("&cTown does not contain town block at your location [" + (int) runner.getLocation().getX() + "," + (int) runner.getLocation().getZ() + "]"));
|
||||||
@@ -1329,7 +1240,7 @@ public class AdminCommands implements CommandExecutor {
|
|||||||
t.setSpawn(new Location(runner.getWorld(), (int) Double.parseDouble(args[5]), (int) Double.parseDouble(args[6]), (int) Double.parseDouble(args[7])));
|
t.setSpawn(new Location(runner.getWorld(), (int) Double.parseDouble(args[5]), (int) Double.parseDouble(args[6]), (int) Double.parseDouble(args[7])));
|
||||||
s.setHomeBlock(tb.getTownBlock());
|
s.setHomeBlock(tb.getTownBlock());
|
||||||
s.setTownSpawn(t.getSpawn());
|
s.setTownSpawn(t.getSpawn());
|
||||||
p.sendMessage(Helper.chatLabel() + "Set town spawn for sieged town " + args[4] + " in war " + args[3] + " to " + runner.getLocation().toString());
|
p.sendMessage(Helper.chatLabel() + "Set town spawn for sieged town " + args[4] + " in war " + args[3] + " to " + runner.getLocation());
|
||||||
Main.warLogger.log("Set town spawn for sieged town " + args[4] + " in war " + args[3] + " to [" + args[5] + "," + args[6] + "," + args[7] + "]");
|
Main.warLogger.log("Set town spawn for sieged town " + args[4] + " in war " + args[3] + " to [" + args[5] + "," + args[6] + "," + args[7] + "]");
|
||||||
return finalizeSiege(s);
|
return finalizeSiege(s);
|
||||||
} else {
|
} else {
|
||||||
@@ -1361,8 +1272,8 @@ public class AdminCommands implements CommandExecutor {
|
|||||||
t.setSpawn(runner.getLocation());
|
t.setSpawn(runner.getLocation());
|
||||||
s.setHomeBlock(tb.getTownBlock());
|
s.setHomeBlock(tb.getTownBlock());
|
||||||
s.setTownSpawn(t.getSpawn());
|
s.setTownSpawn(t.getSpawn());
|
||||||
p.sendMessage(Helper.chatLabel() + "Set town spawn for sieged town " + args[4] + " in war " + args[3] + " to " + runner.getLocation().toString());
|
p.sendMessage(Helper.chatLabel() + "Set town spawn for sieged town " + args[4] + " in war " + args[3] + " to " + runner.getLocation());
|
||||||
Main.warLogger.log("Set town spawn for sieged town " + args[4] + " in war " + args[3] + " to " + runner.getLocation().toString());
|
Main.warLogger.log("Set town spawn for sieged town " + args[4] + " in war " + args[3] + " to " + runner.getLocation());
|
||||||
return finalizeSiege(s);
|
return finalizeSiege(s);
|
||||||
} else {
|
} else {
|
||||||
p.sendMessage(Helper.color("&cTown does not contain town block at your location [" + (int) runner.getLocation().getX() + "," + (int) runner.getLocation().getZ() + "]"));
|
p.sendMessage(Helper.color("&cTown does not contain town block at your location [" + (int) runner.getLocation().getX() + "," + (int) runner.getLocation().getZ() + "]"));
|
||||||
@@ -1948,7 +1859,7 @@ public class AdminCommands implements CommandExecutor {
|
|||||||
private static boolean fail(CommandSender p, String[] args, String type) {
|
private static boolean fail(CommandSender p, String[] args, String type) {
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case "permissions" -> {
|
case "permissions" -> {
|
||||||
p.sendMessage(String.valueOf(Helper.chatLabel()) + Helper.color("&cYou do not have permission to do this."));
|
p.sendMessage(Helper.chatLabel() + Helper.color("&cYou do not have permission to do this."));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
case "syntax" -> {
|
case "syntax" -> {
|
||||||
@@ -1977,4 +1888,116 @@ public class AdminCommands implements CommandExecutor {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* //done
|
||||||
|
* //edit war/event in real time, side can be "both" to effect both
|
||||||
|
* -modify raid score [war] [town] [value]
|
||||||
|
* -modify raid townspawn [war] [town] (x) (Z)
|
||||||
|
* -modify raid gather [war] [town] [town]
|
||||||
|
* -modify raid phase [war] [town] [phase] //"next" to move to next phase
|
||||||
|
* -modify raid loot [war] [town] (x) (z) [value,looted,ticks,reset] [amt] //no coords just does current chunk, reset deletes it from the list
|
||||||
|
* -modify raid time [war] [town] [add/set] [value]
|
||||||
|
* -modify raid owner [war] [town] [add/set] [value]
|
||||||
|
* -modify raid move [war] [town] [newWar] //low priority, moves raid to other war
|
||||||
|
* -modify raid clearActive [war] [town] //low priority
|
||||||
|
* <p>
|
||||||
|
* -modify siege score [war] [town] [side] [amt]
|
||||||
|
* -modify siege homeblock [war] [town] (x) (Z)
|
||||||
|
* -modify siege time [war] [town] [add/set/max] [value] //max modified the max length
|
||||||
|
* -modify siege owner [war] [town] [add/set] [value]
|
||||||
|
* -modify siege move [war] [town] [newWar] //low priority, moves siege to other war
|
||||||
|
* <p>
|
||||||
|
* -modify war score [war] [side] [amt]
|
||||||
|
* -modify war side [war] [side] [name]
|
||||||
|
* -modify war name [war] [name]
|
||||||
|
* -modify war add town [war] [town]
|
||||||
|
* -modify war add nation [war] [nation]
|
||||||
|
* -modify war surrender town [war] [town] //adds town to surrender list
|
||||||
|
* -modify war surrender nation [war] [town] //adds all towns to surrender list
|
||||||
|
* -modify war raidTime [add,set,reset] [war] [town] [amt] //set when last raid was
|
||||||
|
* <p>
|
||||||
|
* // low priority idea
|
||||||
|
* -info war score [war]
|
||||||
|
* -info war surrenderedTowns [war]
|
||||||
|
* -info war raids [war]
|
||||||
|
* -info war sieges [war]
|
||||||
|
* -info war towns [war]
|
||||||
|
* -info war lastRaidTime [war]
|
||||||
|
* <p>
|
||||||
|
* -info raid homeblock [war] [town]
|
||||||
|
* -info raid lootedTownBlocks [war] [town]
|
||||||
|
* -info raid timeSinceLastRaid [town]
|
||||||
|
* <p>
|
||||||
|
* -info siege homeblock [war] [town]
|
||||||
|
* <p>
|
||||||
|
* //done
|
||||||
|
* //force make event or war, if owner isnt defined, idk havent decided
|
||||||
|
* -create siege [war] [town] (owner)
|
||||||
|
* -create raid [war] [raidTown] (gatherTown) (owner)
|
||||||
|
* -create war [name] [side1] [side2]
|
||||||
|
* <p>
|
||||||
|
* //force end a war/event, can declare winner side, or no winner
|
||||||
|
* -force end war [war] (side/victor)
|
||||||
|
* -force end siege [war] [town] (side/victor)
|
||||||
|
* -force end raid [war] [town] (side/victor)
|
||||||
|
* <p>
|
||||||
|
* //done
|
||||||
|
* //force player into or out of a war/event
|
||||||
|
* -force join war [player] [war] [side]
|
||||||
|
* -force join siege [player] [war] [town] (side)
|
||||||
|
* -force join raid [player] [war] [town] (side)
|
||||||
|
* <p>
|
||||||
|
* //done
|
||||||
|
* -force leave raid [war] [player] (timeout) //kicks from raid party
|
||||||
|
* <p>
|
||||||
|
* // Ultra low priority idea
|
||||||
|
* -rule raidersRespawnAtGatherTown [true/false]
|
||||||
|
* -rule siegersRespawnAtTown [true/false]
|
||||||
|
* -rule anyoneCanJoinRaid [true/false]
|
||||||
|
*
|
||||||
|
* @param sender Source of the command
|
||||||
|
* @param command Command which was executed
|
||||||
|
* @param label Alias of the command which was used
|
||||||
|
* @param args Passed command arguments
|
||||||
|
* @return Valid command
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||||
|
CommandHelper.logCommand(sender, label, args);
|
||||||
|
if (!sender.hasPermission("AlathraWar.admin")) {
|
||||||
|
return fail(sender, args, "permissions");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (args.length == 0) {
|
||||||
|
return fail(sender, args, "syntax");
|
||||||
|
} else {
|
||||||
|
if (args[0].equalsIgnoreCase("create")) {
|
||||||
|
return create(sender, args);
|
||||||
|
} else if (args[0].equalsIgnoreCase("force")) {
|
||||||
|
return force(sender, args);
|
||||||
|
} else if (args[0].equalsIgnoreCase("help")) {
|
||||||
|
return help(sender, args);
|
||||||
|
} else if (args[0].equalsIgnoreCase("info")) {
|
||||||
|
return info(sender, args);
|
||||||
|
} else if (args[0].equalsIgnoreCase("modify")) {
|
||||||
|
return modify(sender, args);
|
||||||
|
} else if (args[0].equalsIgnoreCase("awa")) {
|
||||||
|
return awa(sender, args);
|
||||||
|
} else if (args[0].equalsIgnoreCase("purgebars")) {
|
||||||
|
return purgebars(sender, args);
|
||||||
|
} else if (args[0].equalsIgnoreCase("save")) {
|
||||||
|
return save(sender, args);
|
||||||
|
} else if (args[0].equalsIgnoreCase("save-all")) {
|
||||||
|
return saveAll(sender, args);
|
||||||
|
} else if (args[0].equalsIgnoreCase("load")) {
|
||||||
|
return load(sender, args);
|
||||||
|
} else if (args[0].equalsIgnoreCase("load-all")) {
|
||||||
|
return loadAll(sender, args);
|
||||||
|
} else if (args[0].equalsIgnoreCase("item")) {
|
||||||
|
return item(sender, args);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -11,8 +11,7 @@ import java.util.List;
|
|||||||
|
|
||||||
public class AdminTabCompletion implements TabCompleter {
|
public class AdminTabCompletion implements TabCompleter {
|
||||||
|
|
||||||
List<String> base = List.of(new String[]{
|
List<String> base = List.of("create",
|
||||||
"create",
|
|
||||||
"force",
|
"force",
|
||||||
"help",
|
"help",
|
||||||
"info",
|
"info",
|
||||||
@@ -22,8 +21,7 @@ public class AdminTabCompletion implements TabCompleter {
|
|||||||
"load-all",
|
"load-all",
|
||||||
"save",
|
"save",
|
||||||
"save-all",
|
"save-all",
|
||||||
"item"
|
"item");
|
||||||
});
|
|
||||||
|
|
||||||
List<String> type = List.of(new String[]{
|
List<String> type = List.of(new String[]{
|
||||||
"raid",
|
"raid",
|
||||||
|
|||||||
@@ -25,6 +25,7 @@ public class CommandHelper {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Grabs list of all war names
|
* Grabs list of all war names
|
||||||
|
*
|
||||||
* @return list of wars
|
* @return list of wars
|
||||||
*/
|
*/
|
||||||
public static List<String> getWarNames() {
|
public static List<String> getWarNames() {
|
||||||
@@ -37,6 +38,7 @@ public class CommandHelper {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Grabs first matching war and lists the sides
|
* Grabs first matching war and lists the sides
|
||||||
|
*
|
||||||
* @param name name of war
|
* @param name name of war
|
||||||
* @return side of war
|
* @return side of war
|
||||||
*/
|
*/
|
||||||
@@ -130,6 +132,7 @@ public class CommandHelper {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* return list of all towns in a raid
|
* return list of all towns in a raid
|
||||||
|
*
|
||||||
* @return list of all towns involved in a raid
|
* @return list of all towns involved in a raid
|
||||||
*/
|
*/
|
||||||
public static List<String> getRaidTowns() {
|
public static List<String> getRaidTowns() {
|
||||||
@@ -142,6 +145,7 @@ public class CommandHelper {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* return list of all towns in a siege
|
* return list of all towns in a siege
|
||||||
|
*
|
||||||
* @return list of towns involved in a siege
|
* @return list of towns involved in a siege
|
||||||
*/
|
*/
|
||||||
public static List<String> getSiegeTowns() {
|
public static List<String> getSiegeTowns() {
|
||||||
@@ -172,6 +176,7 @@ public class CommandHelper {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* get a list of all online players
|
* get a list of all online players
|
||||||
|
*
|
||||||
* @return list of all players online
|
* @return list of all players online
|
||||||
*/
|
*/
|
||||||
public static List<String> getPlayers() {
|
public static List<String> getPlayers() {
|
||||||
@@ -185,6 +190,7 @@ public class CommandHelper {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* get a list of all raid phases
|
* get a list of all raid phases
|
||||||
|
*
|
||||||
* @return list of all raid phases
|
* @return list of all raid phases
|
||||||
*/
|
*/
|
||||||
public static List<String> getRaidPhases() {
|
public static List<String> getRaidPhases() {
|
||||||
@@ -196,7 +202,6 @@ public class CommandHelper {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @param player player to check
|
* @param player player to check
|
||||||
* @return 0, 1, 2 (good to go, insufficient join, insufficient playtime)
|
* @return 0, 1, 2 (good to go, insufficient join, insufficient playtime)
|
||||||
*/
|
*/
|
||||||
@@ -209,7 +214,8 @@ public class CommandHelper {
|
|||||||
int out = 0;
|
int out = 0;
|
||||||
if (Main.getInstance().getConfig().getInt("minimumPlayerAge") > 0) {
|
if (Main.getInstance().getConfig().getInt("minimumPlayerAge") > 0) {
|
||||||
//compare the join date, if they joined less that min age ago it is true
|
//compare the join date, if they joined less that min age ago it is true
|
||||||
if ((System.currentTimeMillis() - regTime) < 86400000L * Main.getInstance().getConfig().getInt("minimumPlayerAge")) out = 1;
|
if ((System.currentTimeMillis() - regTime) < 86400000L * Main.getInstance().getConfig().getInt("minimumPlayerAge"))
|
||||||
|
out = 1;
|
||||||
}
|
}
|
||||||
if (Main.getInstance().getConfig().getInt("minimumPlayTime") > 0) {
|
if (Main.getInstance().getConfig().getInt("minimumPlayTime") > 0) {
|
||||||
//check playtime, if its less than min its true
|
//check playtime, if its less than min its true
|
||||||
@@ -224,6 +230,7 @@ public class CommandHelper {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* log the command
|
* log the command
|
||||||
|
*
|
||||||
* @param sender sender
|
* @param sender sender
|
||||||
* @param label command
|
* @param label command
|
||||||
* @param args command args
|
* @param args command args
|
||||||
@@ -234,11 +241,12 @@ public class CommandHelper {
|
|||||||
for (String s : args) {
|
for (String s : args) {
|
||||||
log.append(" ").append(s);
|
log.append(" ").append(s);
|
||||||
}
|
}
|
||||||
Main.warLogger.log(Helper.chatLabel() + sender.getName() + " ran command: " + log.toString());
|
Main.warLogger.log(Helper.chatLabel() + sender.getName() + " ran command: " + log);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* return list of all alathrawar items with namespace
|
* return list of all alathrawar items with namespace
|
||||||
|
*
|
||||||
* @return list of all alathrawar items namespaced
|
* @return list of all alathrawar items namespaced
|
||||||
*/
|
*/
|
||||||
public static List<String> getWarItems() {
|
public static List<String> getWarItems() {
|
||||||
|
|||||||
@@ -3,12 +3,14 @@ package me.ShermansWorld.AlathraWar.commands;
|
|||||||
import com.palmergames.bukkit.towny.TownyAPI;
|
import com.palmergames.bukkit.towny.TownyAPI;
|
||||||
import com.palmergames.bukkit.towny.exceptions.NotRegisteredException;
|
import com.palmergames.bukkit.towny.exceptions.NotRegisteredException;
|
||||||
import com.palmergames.bukkit.towny.exceptions.TownyException;
|
import com.palmergames.bukkit.towny.exceptions.TownyException;
|
||||||
import com.palmergames.bukkit.towny.object.*;
|
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.*;
|
||||||
|
import me.ShermansWorld.AlathraWar.data.RaidData;
|
||||||
import me.ShermansWorld.AlathraWar.data.RaidPhase;
|
import me.ShermansWorld.AlathraWar.data.RaidPhase;
|
||||||
import me.ShermansWorld.AlathraWar.data.SiegeData;
|
import me.ShermansWorld.AlathraWar.data.SiegeData;
|
||||||
import me.ShermansWorld.AlathraWar.data.WarData;
|
import me.ShermansWorld.AlathraWar.data.WarData;
|
||||||
import me.ShermansWorld.AlathraWar.data.RaidData;
|
|
||||||
import net.md_5.bungee.api.ChatColor;
|
import net.md_5.bungee.api.ChatColor;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.OfflinePlayer;
|
import org.bukkit.OfflinePlayer;
|
||||||
@@ -22,40 +24,7 @@ import java.util.ArrayList;
|
|||||||
public class RaidCommands implements CommandExecutor {
|
public class RaidCommands implements CommandExecutor {
|
||||||
|
|
||||||
public RaidCommands(final Main plugin) {
|
public RaidCommands(final Main plugin) {
|
||||||
plugin.getCommand("raid").setExecutor((CommandExecutor)this);
|
plugin.getCommand("raid").setExecutor(this);
|
||||||
}
|
|
||||||
|
|
||||||
public boolean onCommand(final CommandSender sender, final Command cmd, final String label, final String[] args) {
|
|
||||||
// final Player p = (Player) sender;
|
|
||||||
CommandHelper.logCommand(sender, label, args);
|
|
||||||
if (args.length == 0) {
|
|
||||||
fail(sender, args, "syntax");
|
|
||||||
} else if (args.length == 1) {
|
|
||||||
if (args[0].equalsIgnoreCase("list")) {
|
|
||||||
listRaids(sender, args);
|
|
||||||
} else if (args[0].equalsIgnoreCase("help")) {
|
|
||||||
raidHelp(sender, args);
|
|
||||||
} else {
|
|
||||||
fail(sender, args, "syntax");
|
|
||||||
}
|
|
||||||
}else if (args.length == 3) {
|
|
||||||
if (args[0].equalsIgnoreCase("start")) {
|
|
||||||
startRaid(sender, args, false);
|
|
||||||
} else if (args[0].equalsIgnoreCase("stop")) {
|
|
||||||
stopRaid(sender, args);
|
|
||||||
} else if (args[0].equalsIgnoreCase("join")) {
|
|
||||||
joinRaid(sender, args, false);
|
|
||||||
} else if (args[0].equalsIgnoreCase("leave")) {
|
|
||||||
leaveRaid(sender, args, false);
|
|
||||||
} else if (args[0].equalsIgnoreCase("abandon")) {
|
|
||||||
abandonRaid(sender, args);
|
|
||||||
} else {
|
|
||||||
fail(sender, args, "syntax");
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
fail(sender, args, "syntax");
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -92,13 +61,13 @@ public class RaidCommands implements CommandExecutor {
|
|||||||
TownyWorld townyWorld;
|
TownyWorld townyWorld;
|
||||||
townyWorld = WorldCoord.parseWorldCoord(raidOwner.getLocation()).getTownyWorld();
|
townyWorld = WorldCoord.parseWorldCoord(raidOwner.getLocation()).getTownyWorld();
|
||||||
|
|
||||||
String side = "";
|
String side;
|
||||||
if (war.getSide1Players().contains(raidOwner.getName())) {
|
if (war.getSide1Players().contains(raidOwner.getName())) {
|
||||||
side = war.getSide1();
|
side = war.getSide1();
|
||||||
} else if (war.getSide2Players().contains(raidOwner.getName())) {
|
} else if (war.getSide2Players().contains(raidOwner.getName())) {
|
||||||
side = war.getSide2();
|
side = war.getSide2();
|
||||||
} else {
|
} else {
|
||||||
p.sendMessage(String.valueOf(Helper.chatLabel()) + "You are not in this war! Type /war join [war] [side]");
|
p.sendMessage(Helper.chatLabel() + "You are not in this war! Type /war join [war] [side]");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -119,12 +88,14 @@ public class RaidCommands implements CommandExecutor {
|
|||||||
if (minuteman != 0) {
|
if (minuteman != 0) {
|
||||||
if (minuteman == 1) {
|
if (minuteman == 1) {
|
||||||
//player has joined to recently
|
//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.");
|
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.");
|
||||||
raidOwner.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.");
|
raidOwner.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;
|
return;
|
||||||
} else if (minuteman == 2) {
|
} else if (minuteman == 2) {
|
||||||
//player has played too little
|
//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.");
|
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.");
|
||||||
raidOwner.sendMessage(ChatColor.RED + "You have not played enough! You can only join a raid after " + Main.getInstance().getConfig().getInt("minimumPlayTime") + " hours of play.");
|
raidOwner.sendMessage(ChatColor.RED + "You have not played enough! You can only join a raid after " + Main.getInstance().getConfig().getInt("minimumPlayTime") + " hours of play.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -133,7 +104,7 @@ public class RaidCommands implements CommandExecutor {
|
|||||||
|
|
||||||
//check if in a town
|
//check if in a town
|
||||||
//takes the command runners town as the gather point
|
//takes the command runners town as the gather point
|
||||||
Town gatherTown = null;
|
Town gatherTown;
|
||||||
try {
|
try {
|
||||||
//if admin, and we have a gather town argument, use it
|
//if admin, and we have a gather town argument, use it
|
||||||
if (admin && args.length >= 5) {
|
if (admin && args.length >= 5) {
|
||||||
@@ -143,21 +114,24 @@ public class RaidCommands implements CommandExecutor {
|
|||||||
} else if (TownyAPI.getInstance().getTown(args[4]) != null) {
|
} else if (TownyAPI.getInstance().getTown(args[4]) != null) {
|
||||||
gatherTown = TownyAPI.getInstance().getTown(args[4]);
|
gatherTown = TownyAPI.getInstance().getTown(args[4]);
|
||||||
} else {
|
} else {
|
||||||
if (admin) p.sendMessage(String.valueOf(Helper.chatLabel()) + "No valid town set for gather town, defaulting to current location");
|
if (admin)
|
||||||
raidOwner.sendMessage(String.valueOf(Helper.chatLabel()) + "No valid town set for gather town, defaulting to current location");
|
p.sendMessage(Helper.chatLabel() + "No valid town set for gather town, defaulting to current location");
|
||||||
|
raidOwner.sendMessage(Helper.chatLabel() + "No valid town set for gather town, defaulting to current location");
|
||||||
gatherTown = TownyAPI.getInstance().getTownOrNull(WorldCoord.parseWorldCoord(raidOwner.getLocation()).getTownBlock());
|
gatherTown = TownyAPI.getInstance().getTownOrNull(WorldCoord.parseWorldCoord(raidOwner.getLocation()).getTownBlock());
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
gatherTown = TownyAPI.getInstance().getTownOrNull(WorldCoord.parseWorldCoord(raidOwner.getLocation()).getTownBlock());
|
gatherTown = TownyAPI.getInstance().getTownOrNull(WorldCoord.parseWorldCoord(raidOwner.getLocation()).getTownBlock());
|
||||||
}
|
}
|
||||||
} catch (NotRegisteredException e2) {
|
} catch (NotRegisteredException e2) {
|
||||||
if (admin) p.sendMessage(String.valueOf(Helper.chatLabel()) + "You must be within a town's claim to begin a raid. That town you are in will be the gathering town.");
|
if (admin)
|
||||||
raidOwner.sendMessage(String.valueOf(Helper.chatLabel()) + "You must be within a town's claim to begin a raid. That town you are in will be the gathering town.");
|
p.sendMessage(Helper.chatLabel() + "You must be within a town's claim to begin a raid. That town you are in will be the gathering town.");
|
||||||
|
raidOwner.sendMessage(Helper.chatLabel() + "You must be within a town's claim to begin a raid. That town you are in will be the gathering town.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (gatherTown == null) {
|
if (gatherTown == null) {
|
||||||
if (admin) p.sendMessage(String.valueOf(Helper.chatLabel()) + "You must be within a town's claim to begin a raid. That town you are in will be the gathering town.");
|
if (admin)
|
||||||
raidOwner.sendMessage(String.valueOf(Helper.chatLabel()) + "You must be within a town's claim to begin a raid. That town you are in will be the gathering town.");
|
p.sendMessage(Helper.chatLabel() + "You must be within a town's claim to begin a raid. That town you are in will be the gathering town.");
|
||||||
|
raidOwner.sendMessage(Helper.chatLabel() + "You must be within a town's claim to begin a raid. That town you are in will be the gathering town.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -187,20 +161,23 @@ public class RaidCommands implements CommandExecutor {
|
|||||||
//check if the town were attempting to raid is in the war
|
//check if the town were attempting to raid is in the war
|
||||||
if (!war.getSide1Towns().contains(raidedTown.getName().toLowerCase()) && !war.getSide2Towns().contains(raidedTown.getName().toLowerCase())) {
|
if (!war.getSide1Towns().contains(raidedTown.getName().toLowerCase()) && !war.getSide2Towns().contains(raidedTown.getName().toLowerCase())) {
|
||||||
if (war.getSurrenderedTowns().contains(raidedTown.getName().toLowerCase())) {
|
if (war.getSurrenderedTowns().contains(raidedTown.getName().toLowerCase())) {
|
||||||
if (admin) p.sendMessage(String.valueOf(Helper.chatLabel()) + "The town you are trying to raid has already surrendered!");
|
if (admin)
|
||||||
raidOwner.sendMessage(String.valueOf(Helper.chatLabel()) + "The town you are trying to raid has already surrendered!");
|
p.sendMessage(Helper.chatLabel() + "The town you are trying to raid has already surrendered!");
|
||||||
|
raidOwner.sendMessage(Helper.chatLabel() + "The town you are trying to raid has already surrendered!");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (admin) p.sendMessage(String.valueOf(Helper.chatLabel()) + "The town you are trying to raid is not part of the war!");
|
if (admin)
|
||||||
raidOwner.sendMessage(String.valueOf(Helper.chatLabel()) + "The town you are trying to raid is not part of the war!");
|
p.sendMessage(Helper.chatLabel() + "The town you are trying to raid is not part of the war!");
|
||||||
|
raidOwner.sendMessage(Helper.chatLabel() + "The town you are trying to raid is not part of the war!");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Is being sieged check
|
// Is being sieged check
|
||||||
for (Siege s : SiegeData.getSieges()) {
|
for (Siege s : SiegeData.getSieges()) {
|
||||||
if (s.getTown().getName().equalsIgnoreCase(raidedTown.getName())) {
|
if (s.getTown().getName().equalsIgnoreCase(raidedTown.getName())) {
|
||||||
raidOwner.sendMessage(String.valueOf(Helper.chatLabel()) + "That town is already currently being sieged! Cannot raid at this time!");
|
raidOwner.sendMessage(Helper.chatLabel() + "That town is already currently being sieged! Cannot raid at this time!");
|
||||||
if(admin) p.sendMessage(String.valueOf(Helper.chatLabel()) + "That town is already currently being sieged! Cannot raid at this time!");
|
if (admin)
|
||||||
|
p.sendMessage(Helper.chatLabel() + "That town is already currently being sieged! Cannot raid at this time!");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -214,20 +191,24 @@ public class RaidCommands implements CommandExecutor {
|
|||||||
//if were admin, see if an owner arg exists, and if so then use it
|
//if were admin, see if an owner arg exists, and if so then use it
|
||||||
raid2 = new Raid(war, raidedTown, gatherTown, true, raidOwner);
|
raid2 = new Raid(war, raidedTown, gatherTown, true, raidOwner);
|
||||||
} else if (c == 1) {
|
} else if (c == 1) {
|
||||||
if (admin) p.sendMessage(String.valueOf(Helper.chatLabel()) + "This town is already being raided at this time!");
|
if (admin)
|
||||||
raidOwner.sendMessage(String.valueOf(Helper.chatLabel()) + "This town is already being raided at this time!");
|
p.sendMessage(Helper.chatLabel() + "This town is already being raided at this time!");
|
||||||
|
raidOwner.sendMessage(Helper.chatLabel() + "This town is already being raided at this time!");
|
||||||
return;
|
return;
|
||||||
} else if (c == 0) {
|
} else if (c == 0) {
|
||||||
if (admin) p.sendMessage(String.valueOf(Helper.chatLabel()) + "Your side has raided too recently!");
|
if (admin)
|
||||||
raidOwner.sendMessage(String.valueOf(Helper.chatLabel()) + "Your side has raided too recently!");
|
p.sendMessage(Helper.chatLabel() + "Your side has raided too recently!");
|
||||||
|
raidOwner.sendMessage(Helper.chatLabel() + "Your side has raided too recently!");
|
||||||
return;
|
return;
|
||||||
} else if (c == -1) {
|
} else if (c == -1) {
|
||||||
if (admin) p.sendMessage(String.valueOf(Helper.chatLabel()) + "This town was raided too recently!");
|
if (admin)
|
||||||
raidOwner.sendMessage(String.valueOf(Helper.chatLabel()) + "This town was raided too recently!");
|
p.sendMessage(Helper.chatLabel() + "This town was raided too recently!");
|
||||||
|
raidOwner.sendMessage(Helper.chatLabel() + "This town was raided too recently!");
|
||||||
return;
|
return;
|
||||||
} else if (c == -2) {
|
} else if (c == -2) {
|
||||||
if (admin) p.sendMessage(String.valueOf(Helper.chatLabel()) + "At least on member of the raided town must be online to defend it!");
|
if (admin)
|
||||||
raidOwner.sendMessage(String.valueOf(Helper.chatLabel()) + "At least on member of the raided town must be online to defend it!");
|
p.sendMessage(Helper.chatLabel() + "At least on member of the raided town must be online to defend it!");
|
||||||
|
raidOwner.sendMessage(Helper.chatLabel() + "At least on member of the raided town must be online to defend it!");
|
||||||
return;
|
return;
|
||||||
} else {
|
} else {
|
||||||
throw new IllegalArgumentException();
|
throw new IllegalArgumentException();
|
||||||
@@ -243,20 +224,24 @@ public class RaidCommands implements CommandExecutor {
|
|||||||
if (c == 2) {
|
if (c == 2) {
|
||||||
raid2 = new Raid(war, raidedTown, gatherTown, false, raidOwner);
|
raid2 = new Raid(war, raidedTown, gatherTown, false, raidOwner);
|
||||||
} else if (c == 1) {
|
} else if (c == 1) {
|
||||||
if (admin) p.sendMessage(String.valueOf(Helper.chatLabel()) + "This town is already being raided at this time!");
|
if (admin)
|
||||||
raidOwner.sendMessage(String.valueOf(Helper.chatLabel()) + "This town is already being raided at this time!");
|
p.sendMessage(Helper.chatLabel() + "This town is already being raided at this time!");
|
||||||
|
raidOwner.sendMessage(Helper.chatLabel() + "This town is already being raided at this time!");
|
||||||
return;
|
return;
|
||||||
} else if (c == 0) {
|
} else if (c == 0) {
|
||||||
if (admin) p.sendMessage(String.valueOf(Helper.chatLabel()) + "Your side has raided too recently!");
|
if (admin)
|
||||||
raidOwner.sendMessage(String.valueOf(Helper.chatLabel()) + "Your side has raided too recently!");
|
p.sendMessage(Helper.chatLabel() + "Your side has raided too recently!");
|
||||||
|
raidOwner.sendMessage(Helper.chatLabel() + "Your side has raided too recently!");
|
||||||
return;
|
return;
|
||||||
} else if (c == -1) {
|
} else if (c == -1) {
|
||||||
if (admin) p.sendMessage(String.valueOf(Helper.chatLabel()) + "This town was raided too recently!");
|
if (admin)
|
||||||
raidOwner.sendMessage(String.valueOf(Helper.chatLabel()) + "This town was raided too recently!");
|
p.sendMessage(Helper.chatLabel() + "This town was raided too recently!");
|
||||||
|
raidOwner.sendMessage(Helper.chatLabel() + "This town was raided too recently!");
|
||||||
return;
|
return;
|
||||||
} else if (c == -2) {
|
} else if (c == -2) {
|
||||||
if (admin) p.sendMessage(String.valueOf(Helper.chatLabel()) + "At least on member of the raided town must be online to defend it!");
|
if (admin)
|
||||||
raidOwner.sendMessage(String.valueOf(Helper.chatLabel()) + "At least on member of the raided town must be online to defend it!");
|
p.sendMessage(Helper.chatLabel() + "At least on member of the raided town must be online to defend it!");
|
||||||
|
raidOwner.sendMessage(Helper.chatLabel() + "At least on member of the raided town must be online to defend it!");
|
||||||
return;
|
return;
|
||||||
} else {
|
} else {
|
||||||
throw new IllegalArgumentException();
|
throw new IllegalArgumentException();
|
||||||
@@ -286,8 +271,9 @@ public class RaidCommands implements CommandExecutor {
|
|||||||
//check player balance
|
//check player balance
|
||||||
final OfflinePlayer offlinePlayer = Bukkit.getOfflinePlayer(raidOwner.getUniqueId());
|
final OfflinePlayer offlinePlayer = Bukkit.getOfflinePlayer(raidOwner.getUniqueId());
|
||||||
if (Main.econ.getBalance(offlinePlayer) <= 1000.0) {
|
if (Main.econ.getBalance(offlinePlayer) <= 1000.0) {
|
||||||
if (admin) p.sendMessage(String.valueOf(Helper.chatLabel()) + "You must have at least $1000 to put up to start a raid.");
|
if (admin)
|
||||||
raidOwner.sendMessage(String.valueOf(Helper.chatLabel()) + "You must have at least $1000 to put up to start a raid.");
|
p.sendMessage(Helper.chatLabel() + "You must have at least $1000 to put up to start a raid.");
|
||||||
|
raidOwner.sendMessage(Helper.chatLabel() + "You must have at least $1000 to put up to start a raid.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -299,10 +285,10 @@ public class RaidCommands implements CommandExecutor {
|
|||||||
WarData.saveWar(raid2.getWar());
|
WarData.saveWar(raid2.getWar());
|
||||||
|
|
||||||
//broadcast
|
//broadcast
|
||||||
Bukkit.broadcastMessage(String.valueOf(Helper.chatLabel()) + "As part of " + war.getName() + ", forces from " + raid2.getRaiderSide() + " are gathering to raid the town of " + raidedTown.getName() + "!");
|
Bukkit.broadcastMessage(Helper.chatLabel() + "As part of " + war.getName() + ", forces from " + raid2.getRaiderSide() + " are gathering to raid the town of " + raidedTown.getName() + "!");
|
||||||
Bukkit.broadcastMessage(String.valueOf(Helper.chatLabel()) + "All players from the defending side have been drafted for the town's defense.");
|
Bukkit.broadcastMessage(Helper.chatLabel() + "All players from the defending side have been drafted for the town's defense.");
|
||||||
Bukkit.broadcastMessage(Helper.chatLabel() + "The raid of "
|
Bukkit.broadcastMessage(Helper.chatLabel() + "The raid of "
|
||||||
+ raidedTown.getName() + " will begin in " + (int) (RaidPhase.TRAVEL.startTick / 20 / 60) + " minutes!");
|
+ raidedTown.getName() + " will begin in " + (RaidPhase.TRAVEL.startTick / 20 / 60) + " minutes!");
|
||||||
Bukkit.broadcastMessage(Helper.chatLabel() +
|
Bukkit.broadcastMessage(Helper.chatLabel() +
|
||||||
"The Raiders are gathering at " + gatherTown.getName() + " before making the journey over!");
|
"The Raiders are gathering at " + gatherTown.getName() + " before making the journey over!");
|
||||||
|
|
||||||
@@ -346,8 +332,8 @@ public class RaidCommands implements CommandExecutor {
|
|||||||
Raid raid = RaidData.getRaidOrNull(args[1] + "-" + args[2]);
|
Raid raid = RaidData.getRaidOrNull(args[1] + "-" + args[2]);
|
||||||
|
|
||||||
if (raid != null) {
|
if (raid != null) {
|
||||||
p.sendMessage(String.valueOf(Helper.chatLabel()) + "raid cancelled");
|
p.sendMessage(Helper.chatLabel() + "raid cancelled");
|
||||||
Bukkit.broadcastMessage(String.valueOf(Helper.chatLabel()) + "The raid of " + raid.getRaidedTown().getName() + " has been cancelled by an admin");
|
Bukkit.broadcastMessage(Helper.chatLabel() + "The raid of " + raid.getRaidedTown().getName() + " has been cancelled by an admin");
|
||||||
raid.stop(); //this purges itself from raids
|
raid.stop(); //this purges itself from raids
|
||||||
} else {
|
} else {
|
||||||
fail(p, args, "badName");
|
fail(p, args, "badName");
|
||||||
@@ -372,31 +358,31 @@ public class RaidCommands implements CommandExecutor {
|
|||||||
if (args[4].equalsIgnoreCase(raid.getDefenderSide())) {
|
if (args[4].equalsIgnoreCase(raid.getDefenderSide())) {
|
||||||
if (!raid.getDefenderPlayers().contains(joiner.getName()))
|
if (!raid.getDefenderPlayers().contains(joiner.getName()))
|
||||||
raid.getDefenderPlayers().add(joiner.getName());
|
raid.getDefenderPlayers().add(joiner.getName());
|
||||||
p.sendMessage(String.valueOf(Helper.chatLabel()) + "Player " + joiner.getName() + " added to defender side.");
|
p.sendMessage(Helper.chatLabel() + "Player " + joiner.getName() + " added to defender side.");
|
||||||
Main.warLogger.log("Player " + joiner.getName() + " added to defender side.");
|
Main.warLogger.log("Player " + joiner.getName() + " added to defender side.");
|
||||||
joiner.sendMessage(String.valueOf(Helper.chatLabel()) + "You were forcefully added to the defender side against the raid party on " + raid.getRaidedTown() + " by an admin.");
|
joiner.sendMessage(Helper.chatLabel() + "You were forcefully added to the defender side against the raid party on " + raid.getRaidedTown() + " by an admin.");
|
||||||
return;
|
return;
|
||||||
} else {
|
} else {
|
||||||
if (!raid.getRaiderPlayers().contains(joiner.getName()))
|
if (!raid.getRaiderPlayers().contains(joiner.getName()))
|
||||||
raid.getRaiderPlayers().add(joiner.getName());
|
raid.getRaiderPlayers().add(joiner.getName());
|
||||||
p.sendMessage(String.valueOf(Helper.chatLabel()) + "Player " + joiner.getName() + " added to raider side.");
|
p.sendMessage(Helper.chatLabel() + "Player " + joiner.getName() + " added to raider side.");
|
||||||
Main.warLogger.log("Player " + joiner.getName() + " added to raider side.");
|
Main.warLogger.log("Player " + joiner.getName() + " added to raider side.");
|
||||||
joiner.sendMessage(String.valueOf(Helper.chatLabel()) + "You were forcefully added to the raid party on " + raid.getRaidedTown() + " by an admin. Leaving the gather town will remove you from the raid party.");
|
joiner.sendMessage(Helper.chatLabel() + "You were forcefully added to the raid party on " + raid.getRaidedTown() + " by an admin. Leaving the gather town will remove you from the raid party.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
p.sendMessage(String.valueOf(Helper.chatLabel()) + "Player " + args[3] + " not found!");
|
p.sendMessage(Helper.chatLabel() + "Player " + args[3] + " not found!");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (joiner == null) {
|
if (joiner == null) {
|
||||||
p.sendMessage(String.valueOf(Helper.chatLabel()) + "Player not found! Is something broken?");
|
p.sendMessage(Helper.chatLabel() + "Player not found! Is something broken?");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!raid.getWar().getSide1Players().contains(joiner.getName()) && !raid.getWar().getSide2Players().contains(joiner.getName())) {
|
if (!raid.getWar().getSide1Players().contains(joiner.getName()) && !raid.getWar().getSide2Players().contains(joiner.getName())) {
|
||||||
joiner.sendMessage(String.valueOf(Helper.chatLabel()) + "You are not in this war! Type /war join [war] [side]");
|
joiner.sendMessage(Helper.chatLabel() + "You are not in this war! Type /war join [war] [side]");
|
||||||
}
|
}
|
||||||
|
|
||||||
//Minutemen countermeasures, 86400 * 4 time. 86400 seconds in a day, 4 days min playtime
|
//Minutemen countermeasures, 86400 * 4 time. 86400 seconds in a day, 4 days min playtime
|
||||||
@@ -416,12 +402,14 @@ public class RaidCommands implements CommandExecutor {
|
|||||||
if (minuteman != 0) {
|
if (minuteman != 0) {
|
||||||
if (minuteman == 1) {
|
if (minuteman == 1) {
|
||||||
//player has joined to recently
|
//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.");
|
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.");
|
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;
|
return;
|
||||||
} else if (minuteman == 2) {
|
} else if (minuteman == 2) {
|
||||||
//player has played too little
|
//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.");
|
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.");
|
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;
|
return;
|
||||||
}
|
}
|
||||||
@@ -436,16 +424,16 @@ public class RaidCommands implements CommandExecutor {
|
|||||||
ArrayList<WorldCoord> cluster = Helper.getCluster(raid.getGatherTown().getHomeBlock().getWorldCoord());
|
ArrayList<WorldCoord> cluster = Helper.getCluster(raid.getGatherTown().getHomeBlock().getWorldCoord());
|
||||||
if (cluster.contains(WorldCoord.parseWorldCoord(joiner))) {
|
if (cluster.contains(WorldCoord.parseWorldCoord(joiner))) {
|
||||||
raid.addActiveRaider(joiner.getName());
|
raid.addActiveRaider(joiner.getName());
|
||||||
joiner.sendMessage(String.valueOf(Helper.chatLabel()) + "You have joined the raid on " + raid.getRaidedTown().getName() + "!");
|
joiner.sendMessage(Helper.chatLabel() + "You have joined the raid on " + raid.getRaidedTown().getName() + "!");
|
||||||
joiner.sendMessage(String.valueOf(Helper.chatLabel()) + "Leaving " + raid.getGatherTown().getName() + " will cause you to leave the raid party.");
|
joiner.sendMessage(Helper.chatLabel() + "Leaving " + raid.getGatherTown().getName() + " will cause you to leave the raid party.");
|
||||||
} else {
|
} else {
|
||||||
joiner.sendMessage(String.valueOf(Helper.chatLabel()) + "You must be in the gathering town to join the raid on " + raid.getRaidedTown().getName() + ".");
|
joiner.sendMessage(Helper.chatLabel() + "You must be in the gathering town to join the raid on " + raid.getRaidedTown().getName() + ".");
|
||||||
}
|
}
|
||||||
} catch (TownyException e) {
|
} catch (TownyException e) {
|
||||||
throw new RuntimeException(e);
|
throw new RuntimeException(e);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
joiner.sendMessage(String.valueOf(Helper.chatLabel()) + "You cannot join the raid on " + raid.getRaidedTown().getName() + "! It has already started!");
|
joiner.sendMessage(Helper.chatLabel() + "You cannot join the raid on " + raid.getRaidedTown().getName() + "! It has already started!");
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
try {
|
try {
|
||||||
@@ -453,10 +441,10 @@ public class RaidCommands implements CommandExecutor {
|
|||||||
ArrayList<WorldCoord> cluster = Helper.getCluster(raid.getGatherTown().getHomeBlock().getWorldCoord());
|
ArrayList<WorldCoord> cluster = Helper.getCluster(raid.getGatherTown().getHomeBlock().getWorldCoord());
|
||||||
if (cluster.contains(WorldCoord.parseWorldCoord(joiner))) {
|
if (cluster.contains(WorldCoord.parseWorldCoord(joiner))) {
|
||||||
raid.addActiveRaider(joiner.getName());
|
raid.addActiveRaider(joiner.getName());
|
||||||
joiner.sendMessage(String.valueOf(Helper.chatLabel()) + "You have joined the raid on " + raid.getRaidedTown().getName() + "!");
|
joiner.sendMessage(Helper.chatLabel() + "You have joined the raid on " + raid.getRaidedTown().getName() + "!");
|
||||||
joiner.sendMessage(String.valueOf(Helper.chatLabel()) + "Leaving " + raid.getGatherTown().getName() + " will cause you to leave the raid party.");
|
joiner.sendMessage(Helper.chatLabel() + "Leaving " + raid.getGatherTown().getName() + " will cause you to leave the raid party.");
|
||||||
} else {
|
} else {
|
||||||
joiner.sendMessage(String.valueOf(Helper.chatLabel()) + "You must be in the gathering town to join the raid on " + raid.getRaidedTown().getName() + ".");
|
joiner.sendMessage(Helper.chatLabel() + "You must be in the gathering town to join the raid on " + raid.getRaidedTown().getName() + ".");
|
||||||
}
|
}
|
||||||
} catch (TownyException e) {
|
} catch (TownyException e) {
|
||||||
throw new RuntimeException(e);
|
throw new RuntimeException(e);
|
||||||
@@ -466,7 +454,7 @@ public class RaidCommands implements CommandExecutor {
|
|||||||
raid.save();
|
raid.save();
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
p.sendMessage(String.valueOf(Helper.chatLabel()) + "No raid is gathering in this town or this town does not exist!");
|
p.sendMessage(Helper.chatLabel() + "No raid is gathering in this town or this town does not exist!");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -476,7 +464,7 @@ public class RaidCommands implements CommandExecutor {
|
|||||||
if (admin) {
|
if (admin) {
|
||||||
p = Bukkit.getPlayer(args[3]);
|
p = Bukkit.getPlayer(args[3]);
|
||||||
if (p == null) {
|
if (p == null) {
|
||||||
player.sendMessage(String.valueOf(Helper.chatLabel()) + "Error: player not found!");
|
player.sendMessage(Helper.chatLabel() + "Error: player not found!");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -488,8 +476,9 @@ public class RaidCommands implements CommandExecutor {
|
|||||||
if (raid != null) {
|
if (raid != null) {
|
||||||
if (raid.getWar().getName().equalsIgnoreCase(args[1])) {
|
if (raid.getWar().getName().equalsIgnoreCase(args[1])) {
|
||||||
if (!raid.getWar().getSide1Players().contains(p.getName()) && !raid.getWar().getSide2Players().contains(p.getName())) {
|
if (!raid.getWar().getSide1Players().contains(p.getName()) && !raid.getWar().getSide2Players().contains(p.getName())) {
|
||||||
p.sendMessage(String.valueOf(Helper.chatLabel()) + "You are not in this war! Type /war join [war] [side]");
|
p.sendMessage(Helper.chatLabel() + "You are not in this war! Type /war join [war] [side]");
|
||||||
if (admin) player.sendMessage(String.valueOf(Helper.chatLabel()) + "You are not in this war! Type /war join [war] [side]");
|
if (admin)
|
||||||
|
player.sendMessage(Helper.chatLabel() + "You are not in this war! Type /war join [war] [side]");
|
||||||
}
|
}
|
||||||
|
|
||||||
//check if gather phase
|
//check if gather phase
|
||||||
@@ -499,12 +488,14 @@ public class RaidCommands implements CommandExecutor {
|
|||||||
ArrayList<WorldCoord> cluster = Helper.getCluster(raid.getGatherTown().getHomeBlock().getWorldCoord());
|
ArrayList<WorldCoord> cluster = Helper.getCluster(raid.getGatherTown().getHomeBlock().getWorldCoord());
|
||||||
if (cluster.contains(WorldCoord.parseWorldCoord(p))) {
|
if (cluster.contains(WorldCoord.parseWorldCoord(p))) {
|
||||||
raid.removeActiveRaider(p.getName());
|
raid.removeActiveRaider(p.getName());
|
||||||
p.sendMessage(String.valueOf(Helper.chatLabel()) + "You have left the raid on " + raid.getRaidedTown().getName() + "!");
|
p.sendMessage(Helper.chatLabel() + "You have left the raid on " + raid.getRaidedTown().getName() + "!");
|
||||||
if (admin) player.sendMessage(String.valueOf(Helper.chatLabel()) + "You have left the raid on " + raid.getRaidedTown().getName() + "!");
|
if (admin)
|
||||||
|
player.sendMessage(Helper.chatLabel() + "You have left the raid on " + raid.getRaidedTown().getName() + "!");
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
p.sendMessage(String.valueOf(Helper.chatLabel()) + "You cannot leave the raid on " + raid.getRaidedTown().getName() + "! It has already started!");
|
p.sendMessage(Helper.chatLabel() + "You cannot leave the raid on " + raid.getRaidedTown().getName() + "! It has already started!");
|
||||||
if (admin) player.sendMessage(String.valueOf(Helper.chatLabel()) + "You cannot leave the raid on " + raid.getRaidedTown().getName() + "! It has already started!");
|
if (admin)
|
||||||
|
player.sendMessage(Helper.chatLabel() + "You cannot leave the raid on " + raid.getRaidedTown().getName() + "! It has already started!");
|
||||||
}
|
}
|
||||||
} catch (TownyException e) {
|
} catch (TownyException e) {
|
||||||
throw new RuntimeException(e);
|
throw new RuntimeException(e);
|
||||||
@@ -514,8 +505,9 @@ public class RaidCommands implements CommandExecutor {
|
|||||||
|
|
||||||
raid.save();
|
raid.save();
|
||||||
} else {
|
} else {
|
||||||
p.sendMessage(String.valueOf(Helper.chatLabel()) + "No raid is gathering in this town or this town does not exist!");
|
p.sendMessage(Helper.chatLabel() + "No raid is gathering in this town or this town does not exist!");
|
||||||
if (admin) player.sendMessage(String.valueOf(Helper.chatLabel()) + "No raid is gathering in this town or this town does not exist!");
|
if (admin)
|
||||||
|
player.sendMessage(Helper.chatLabel() + "No raid is gathering in this town or this town does not exist!");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -531,7 +523,7 @@ public class RaidCommands implements CommandExecutor {
|
|||||||
if (raid != null) {
|
if (raid != null) {
|
||||||
if (raid.getWar().getName().equalsIgnoreCase(args[1])) {
|
if (raid.getWar().getName().equalsIgnoreCase(args[1])) {
|
||||||
if (!raid.getWar().getSide1Players().contains(p.getName()) && !raid.getWar().getSide2Players().contains(p.getName())) {
|
if (!raid.getWar().getSide1Players().contains(p.getName()) && !raid.getWar().getSide2Players().contains(p.getName())) {
|
||||||
p.sendMessage(String.valueOf(Helper.chatLabel()) + "You are not in this war! Type /war join [war] [side]");
|
p.sendMessage(Helper.chatLabel() + "You are not in this war! Type /war join [war] [side]");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -539,11 +531,11 @@ public class RaidCommands implements CommandExecutor {
|
|||||||
//check if gather phase
|
//check if gather phase
|
||||||
if (raid.getPhase() == RaidPhase.GATHER || raid.getPhase() == RaidPhase.START || raid.getPhase() == RaidPhase.TRAVEL || raid.getPhase() == RaidPhase.COMBAT) {
|
if (raid.getPhase() == RaidPhase.GATHER || raid.getPhase() == RaidPhase.START || raid.getPhase() == RaidPhase.TRAVEL || raid.getPhase() == RaidPhase.COMBAT) {
|
||||||
//force defender victory
|
//force defender victory
|
||||||
Bukkit.broadcastMessage(String.valueOf(Helper.chatLabel()) + "The raid on " + raid.getRaidedTown().getName() + " has been abandoned by " + raid.getRaiderSide());
|
Bukkit.broadcastMessage(Helper.chatLabel() + "The raid on " + raid.getRaidedTown().getName() + " has been abandoned by " + raid.getRaiderSide());
|
||||||
Main.warLogger.log(p.getName() + " abandoned the raid on " + raid.getRaidedTown().getName() + " they started at " + raid.getGatherTown().getName());
|
Main.warLogger.log(p.getName() + " abandoned the raid on " + raid.getRaidedTown().getName() + " they started at " + raid.getGatherTown().getName());
|
||||||
raid.defendersWin(raid.getRaiderScore(), raid.getDefenderScore());
|
raid.defendersWin(raid.getRaiderScore(), raid.getDefenderScore());
|
||||||
} else {
|
} else {
|
||||||
p.sendMessage(String.valueOf(Helper.chatLabel()) + "You cannot abandon the raid on " + raid.getRaidedTown().getName() + "! It has a problem!");
|
p.sendMessage(Helper.chatLabel() + "You cannot abandon the raid on " + raid.getRaidedTown().getName() + "! It has a problem!");
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
fail(p, args, "owner");
|
fail(p, args, "owner");
|
||||||
@@ -551,15 +543,15 @@ public class RaidCommands implements CommandExecutor {
|
|||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
p.sendMessage(String.valueOf(Helper.chatLabel()) + "This raid does not exist!");
|
p.sendMessage(Helper.chatLabel() + "This raid does not exist!");
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void listRaids(CommandSender p, String[] args) {
|
private static void listRaids(CommandSender p, String[] args) {
|
||||||
if (RaidData.getRaids().isEmpty()) {
|
if (RaidData.getRaids().isEmpty()) {
|
||||||
p.sendMessage(String.valueOf(Helper.chatLabel()) + "There are currently no Raids in progress");
|
p.sendMessage(Helper.chatLabel() + "There are currently no Raids in progress");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
p.sendMessage(String.valueOf(Helper.chatLabel()) + "Raids currently in progress:");
|
p.sendMessage(Helper.chatLabel() + "Raids currently in progress:");
|
||||||
for (final Raid raid : RaidData.getRaids()) {
|
for (final Raid raid : RaidData.getRaids()) {
|
||||||
p.sendMessage("Name: " + raid.getName());
|
p.sendMessage("Name: " + raid.getName());
|
||||||
p.sendMessage("War: " + raid.getWar().getName());
|
p.sendMessage("War: " + raid.getWar().getName());
|
||||||
@@ -589,12 +581,49 @@ public class RaidCommands implements CommandExecutor {
|
|||||||
|
|
||||||
private static void fail(CommandSender p, String[] args, String type) {
|
private static void fail(CommandSender p, String[] args, String type) {
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case "permissions" -> p.sendMessage(String.valueOf(Helper.chatLabel()) + "&cYou do not have permission to do this");
|
case "permissions" ->
|
||||||
case "syntax" -> p.sendMessage(String.valueOf(Helper.chatLabel()) + "Invalid Syntax. /raid help");
|
p.sendMessage(Helper.chatLabel() + "&cYou do not have permission to do this");
|
||||||
case "noRaids" -> p.sendMessage(String.valueOf(Helper.chatLabel()) + "There are currently no Raids in progress");
|
case "syntax" -> p.sendMessage(Helper.chatLabel() + "Invalid Syntax. /raid help");
|
||||||
case "badName" -> p.sendMessage(String.valueOf(Helper.chatLabel()) + "A raid could not be found with this Name! Type /raid list to view current raids");
|
case "noRaids" ->
|
||||||
case "owner" -> p.sendMessage(String.valueOf(Helper.chatLabel()) + "Only the player who started the raid can abandon it.");
|
p.sendMessage(Helper.chatLabel() + "There are currently no Raids in progress");
|
||||||
default -> p.sendMessage(String.valueOf(Helper.chatLabel()) + "Invalid Arguments. /raid help");
|
case "badName" ->
|
||||||
|
p.sendMessage(Helper.chatLabel() + "A raid could not be found with this Name! Type /raid list to view current raids");
|
||||||
|
case "owner" ->
|
||||||
|
p.sendMessage(Helper.chatLabel() + "Only the player who started the raid can abandon it.");
|
||||||
|
default -> p.sendMessage(Helper.chatLabel() + "Invalid Arguments. /raid help");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean onCommand(final CommandSender sender, final Command cmd, final String label, final String[] args) {
|
||||||
|
// final Player p = (Player) sender;
|
||||||
|
CommandHelper.logCommand(sender, label, args);
|
||||||
|
if (args.length == 0) {
|
||||||
|
fail(sender, args, "syntax");
|
||||||
|
} else if (args.length == 1) {
|
||||||
|
if (args[0].equalsIgnoreCase("list")) {
|
||||||
|
listRaids(sender, args);
|
||||||
|
} else if (args[0].equalsIgnoreCase("help")) {
|
||||||
|
raidHelp(sender, args);
|
||||||
|
} else {
|
||||||
|
fail(sender, args, "syntax");
|
||||||
|
}
|
||||||
|
} else if (args.length == 3) {
|
||||||
|
if (args[0].equalsIgnoreCase("start")) {
|
||||||
|
startRaid(sender, args, false);
|
||||||
|
} else if (args[0].equalsIgnoreCase("stop")) {
|
||||||
|
stopRaid(sender, args);
|
||||||
|
} else if (args[0].equalsIgnoreCase("join")) {
|
||||||
|
joinRaid(sender, args, false);
|
||||||
|
} else if (args[0].equalsIgnoreCase("leave")) {
|
||||||
|
leaveRaid(sender, args, false);
|
||||||
|
} else if (args[0].equalsIgnoreCase("abandon")) {
|
||||||
|
abandonRaid(sender, args);
|
||||||
|
} else {
|
||||||
|
fail(sender, args, "syntax");
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
fail(sender, args, "syntax");
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -1,63 +1,24 @@
|
|||||||
package me.ShermansWorld.AlathraWar.commands;
|
package me.ShermansWorld.AlathraWar.commands;
|
||||||
|
|
||||||
|
import com.palmergames.bukkit.towny.TownyAPI;
|
||||||
|
import com.palmergames.bukkit.towny.object.Town;
|
||||||
import me.ShermansWorld.AlathraWar.*;
|
import me.ShermansWorld.AlathraWar.*;
|
||||||
import me.ShermansWorld.AlathraWar.data.RaidData;
|
import me.ShermansWorld.AlathraWar.data.RaidData;
|
||||||
import net.md_5.bungee.api.ChatColor;
|
|
||||||
import org.bukkit.OfflinePlayer;
|
|
||||||
import com.palmergames.bukkit.towny.TownyAPI;
|
|
||||||
import me.ShermansWorld.AlathraWar.data.SiegeData;
|
import me.ShermansWorld.AlathraWar.data.SiegeData;
|
||||||
import me.ShermansWorld.AlathraWar.data.WarData;
|
import me.ShermansWorld.AlathraWar.data.WarData;
|
||||||
|
import net.md_5.bungee.api.ChatColor;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.OfflinePlayer;
|
||||||
import org.bukkit.command.Command;
|
import org.bukkit.command.Command;
|
||||||
|
import org.bukkit.command.CommandExecutor;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import com.palmergames.bukkit.towny.object.Town;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import org.bukkit.command.CommandExecutor;
|
|
||||||
|
|
||||||
public class SiegeCommands implements CommandExecutor {
|
public class SiegeCommands implements CommandExecutor {
|
||||||
public SiegeCommands(final Main plugin) {
|
public SiegeCommands(final Main plugin) {
|
||||||
plugin.getCommand("siege").setExecutor((CommandExecutor) this);
|
plugin.getCommand("siege").setExecutor(this);
|
||||||
}
|
|
||||||
|
|
||||||
public boolean onCommand(final CommandSender sender, final Command cmd, final String label, final String[] args) {
|
|
||||||
CommandHelper.logCommand(sender, label, args);
|
|
||||||
if (args.length == 0) {
|
|
||||||
sender.sendMessage(String.valueOf(Helper.chatLabel()) + "Invalid Arguments. /siege help");
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Start
|
|
||||||
// Stop
|
|
||||||
// Abandon
|
|
||||||
// List
|
|
||||||
// Help
|
|
||||||
|
|
||||||
switch (args[0].toLowerCase()) {
|
|
||||||
case "start" -> {
|
|
||||||
siegeStart(sender, args, false);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
case "stop" -> {
|
|
||||||
siegeStop(sender, args);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
case "abandon" -> {
|
|
||||||
siegeAbandon(sender, args);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
case "list" -> {
|
|
||||||
siegeList(sender, args);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
case "help" -> {
|
|
||||||
siegeHelp(sender, args);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected static void siegeStart(CommandSender sender, String[] args, boolean admin) {
|
protected static void siegeStart(CommandSender sender, String[] args, boolean admin) {
|
||||||
@@ -89,8 +50,9 @@ public class SiegeCommands implements CommandExecutor {
|
|||||||
// War check
|
// War check
|
||||||
War war = WarData.getWar(args[1]);
|
War war = WarData.getWar(args[1]);
|
||||||
if (war == null) {
|
if (war == null) {
|
||||||
siegeOwner.sendMessage(String.valueOf(Helper.chatLabel()) + "That war does not exist! /siege start [war] [town]");
|
siegeOwner.sendMessage(Helper.chatLabel() + "That war does not exist! /siege start [war] [town]");
|
||||||
if(admin) sender.sendMessage(String.valueOf(Helper.chatLabel()) + "That war does not exist! /siege start [war] [town]");
|
if (admin)
|
||||||
|
sender.sendMessage(Helper.chatLabel() + "That war does not exist! /siege start [war] [town]");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -142,12 +104,14 @@ public class SiegeCommands implements CommandExecutor {
|
|||||||
if (minuteman != 0) {
|
if (minuteman != 0) {
|
||||||
if (minuteman == 1) {
|
if (minuteman == 1) {
|
||||||
//player has joined to recently
|
//player has joined to recently
|
||||||
if (admin) sender.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.");
|
if (admin)
|
||||||
|
sender.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.");
|
||||||
siegeOwner.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.");
|
siegeOwner.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;
|
return;
|
||||||
} else if (minuteman == 2) {
|
} else if (minuteman == 2) {
|
||||||
//player has played too little
|
//player has played too little
|
||||||
if (admin) sender.sendMessage(ChatColor.RED + "You have not played enough! You can only join a raid after " + Main.getInstance().getConfig().getInt("minimumPlayTime") + " hours of play.");
|
if (admin)
|
||||||
|
sender.sendMessage(ChatColor.RED + "You have not played enough! You can only join a raid after " + Main.getInstance().getConfig().getInt("minimumPlayTime") + " hours of play.");
|
||||||
siegeOwner.sendMessage(ChatColor.RED + "You have not played enough! You can only join a raid after " + Main.getInstance().getConfig().getInt("minimumPlayTime") + " hours of play.");
|
siegeOwner.sendMessage(ChatColor.RED + "You have not played enough! You can only join a raid after " + Main.getInstance().getConfig().getInt("minimumPlayTime") + " hours of play.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -157,8 +121,9 @@ public class SiegeCommands implements CommandExecutor {
|
|||||||
// Town check
|
// Town check
|
||||||
Town town = TownyAPI.getInstance().getTown(args[2]);
|
Town town = TownyAPI.getInstance().getTown(args[2]);
|
||||||
if (town == null) {
|
if (town == null) {
|
||||||
siegeOwner.sendMessage(String.valueOf(Helper.chatLabel()) + "That town does not exist! /siege start [war] [town]");
|
siegeOwner.sendMessage(Helper.chatLabel() + "That town does not exist! /siege start [war] [town]");
|
||||||
if(admin) sender.sendMessage(String.valueOf(Helper.chatLabel()) + "That town does not exist! /siege start [war] [town]");
|
if (admin)
|
||||||
|
sender.sendMessage(Helper.chatLabel() + "That town does not exist! /siege start [war] [town]");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Main.warLogger.log("Attacked Town: " + town.getName().toLowerCase());
|
Main.warLogger.log("Attacked Town: " + town.getName().toLowerCase());
|
||||||
@@ -167,8 +132,9 @@ public class SiegeCommands implements CommandExecutor {
|
|||||||
// Is being raided check
|
// Is being raided check
|
||||||
for (Raid r : RaidData.getRaids()) {
|
for (Raid r : RaidData.getRaids()) {
|
||||||
if (r.getRaidedTown().getName().equalsIgnoreCase(town.getName())) {
|
if (r.getRaidedTown().getName().equalsIgnoreCase(town.getName())) {
|
||||||
siegeOwner.sendMessage(String.valueOf(Helper.chatLabel()) + "That town is already currently being raided! Cannot siege at this time!");
|
siegeOwner.sendMessage(Helper.chatLabel() + "That town is already currently being raided! Cannot siege at this time!");
|
||||||
if(admin) sender.sendMessage(String.valueOf(Helper.chatLabel()) + "That town is already currently being raided! Cannot siege at this time!");
|
if (admin)
|
||||||
|
sender.sendMessage(Helper.chatLabel() + "That town is already currently being raided! Cannot siege at this time!");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -192,12 +158,12 @@ public class SiegeCommands implements CommandExecutor {
|
|||||||
|
|
||||||
private static void siegeStop(CommandSender sender, String[] args) {
|
private static void siegeStop(CommandSender sender, String[] args) {
|
||||||
if (!sender.hasPermission("AlathraWar.admin")) {
|
if (!sender.hasPermission("AlathraWar.admin")) {
|
||||||
sender.sendMessage(String.valueOf(Helper.chatLabel()) + Helper.color("&cYou do not have permission to do this"));
|
sender.sendMessage(Helper.chatLabel() + Helper.color("&cYou do not have permission to do this"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
HashSet<Siege> sieges = SiegeData.getSieges();
|
HashSet<Siege> sieges = SiegeData.getSieges();
|
||||||
if (sieges.isEmpty()) {
|
if (sieges.isEmpty()) {
|
||||||
sender.sendMessage(String.valueOf(Helper.chatLabel()) + "There are currently no sieges in progress");
|
sender.sendMessage(Helper.chatLabel() + "There are currently no sieges in progress");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -209,25 +175,24 @@ public class SiegeCommands implements CommandExecutor {
|
|||||||
// War check
|
// War check
|
||||||
War war = WarData.getWar(args[1]);
|
War war = WarData.getWar(args[1]);
|
||||||
if (war == null) {
|
if (war == null) {
|
||||||
sender.sendMessage(String.valueOf(Helper.chatLabel()) + "That war does not exist! /siege stop [war] [town]");
|
sender.sendMessage(Helper.chatLabel() + "That war does not exist! /siege stop [war] [town]");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (Siege siege : sieges) {
|
for (Siege siege : sieges) {
|
||||||
if (siege.getTown().getName().equalsIgnoreCase(args[2])) {
|
if (siege.getTown().getName().equalsIgnoreCase(args[2])) {
|
||||||
sender.sendMessage(String.valueOf(Helper.chatLabel()) + "siege cancelled");
|
sender.sendMessage(Helper.chatLabel() + "siege cancelled");
|
||||||
Bukkit.broadcastMessage(String.valueOf(Helper.chatLabel()) + "The siege at " + siege.getTown().getName() + " has been cancelled by an admin");
|
Bukkit.broadcastMessage(Helper.chatLabel() + "The siege at " + siege.getTown().getName() + " has been cancelled by an admin");
|
||||||
//siege.clearBeacon();
|
//siege.clearBeacon();
|
||||||
siege.stop();
|
siege.stop();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
sender.sendMessage(String.valueOf(Helper.chatLabel()) + "A siege could not be found with this town name! Type /siege list to view current sieges");
|
sender.sendMessage(Helper.chatLabel() + "A siege could not be found with this town name! Type /siege list to view current sieges");
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void siegeAbandon(CommandSender sender, String[] args) {
|
private static void siegeAbandon(CommandSender sender, String[] args) {
|
||||||
if (!(sender instanceof Player)) return;
|
if (!(sender instanceof Player p)) return;
|
||||||
final Player p = (Player) sender;
|
|
||||||
|
|
||||||
if (args.length < 3) {
|
if (args.length < 3) {
|
||||||
sender.sendMessage(Helper.chatLabel() + "/siege abandon [town]");
|
sender.sendMessage(Helper.chatLabel() + "/siege abandon [town]");
|
||||||
@@ -237,7 +202,7 @@ public class SiegeCommands implements CommandExecutor {
|
|||||||
// War check
|
// War check
|
||||||
War war = WarData.getWar(args[1]);
|
War war = WarData.getWar(args[1]);
|
||||||
if (war == null) {
|
if (war == null) {
|
||||||
p.sendMessage(String.valueOf(Helper.chatLabel()) + "That war does not exist! /siege abandon [war] [town]");
|
p.sendMessage(Helper.chatLabel() + "That war does not exist! /siege abandon [war] [town]");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -248,12 +213,12 @@ public class SiegeCommands implements CommandExecutor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
OfflinePlayer oPlayer = siege.getSiegeLeader();
|
OfflinePlayer oPlayer = siege.getSiegeLeader();
|
||||||
if (oPlayer != (OfflinePlayer) p) {
|
if (oPlayer != p) {
|
||||||
p.sendMessage(Helper.chatLabel() + "You are not the leader of this siege.");
|
p.sendMessage(Helper.chatLabel() + "You are not the leader of this siege.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Bukkit.broadcastMessage(String.valueOf(Helper.chatLabel()) + "The siege at " + siege.getTown().getName() + " has been abandoned.");
|
Bukkit.broadcastMessage(Helper.chatLabel() + "The siege at " + siege.getTown().getName() + " has been abandoned.");
|
||||||
Main.warLogger.log(p.getName() + " abandoned the siege they started at " + siege.getTown().getName());
|
Main.warLogger.log(p.getName() + " abandoned the siege they started at " + siege.getTown().getName());
|
||||||
siege.defendersWin();
|
siege.defendersWin();
|
||||||
|
|
||||||
@@ -262,11 +227,11 @@ public class SiegeCommands implements CommandExecutor {
|
|||||||
private static void siegeList(CommandSender sender, String[] args) {
|
private static void siegeList(CommandSender sender, String[] args) {
|
||||||
HashSet<Siege> sieges = SiegeData.getSieges();
|
HashSet<Siege> sieges = SiegeData.getSieges();
|
||||||
if (sieges.isEmpty()) {
|
if (sieges.isEmpty()) {
|
||||||
sender.sendMessage(String.valueOf(Helper.chatLabel()) + "There are currently no sieges in progress");
|
sender.sendMessage(Helper.chatLabel() + "There are currently no sieges in progress");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
sender.sendMessage(String.valueOf(Helper.chatLabel()) + "Sieges currently in progress:");
|
sender.sendMessage(Helper.chatLabel() + "Sieges currently in progress:");
|
||||||
for (Siege siege : sieges) {
|
for (Siege siege : sieges) {
|
||||||
War war = siege.getWar();
|
War war = siege.getWar();
|
||||||
String color = (siege.getSide1AreAttackers() && (war.getSide(siege.getTown().getName().toLowerCase()) == 1)) ? "§c" : "§9";
|
String color = (siege.getSide1AreAttackers() && (war.getSide(siege.getTown().getName().toLowerCase()) == 1)) ? "§c" : "§9";
|
||||||
@@ -287,4 +252,42 @@ public class SiegeCommands implements CommandExecutor {
|
|||||||
sender.sendMessage(Helper.chatLabel() + "/siege abandon [war] [town]");
|
sender.sendMessage(Helper.chatLabel() + "/siege abandon [war] [town]");
|
||||||
sender.sendMessage(Helper.chatLabel() + "/siege list");
|
sender.sendMessage(Helper.chatLabel() + "/siege list");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean onCommand(final CommandSender sender, final Command cmd, final String label, final String[] args) {
|
||||||
|
CommandHelper.logCommand(sender, label, args);
|
||||||
|
if (args.length == 0) {
|
||||||
|
sender.sendMessage(Helper.chatLabel() + "Invalid Arguments. /siege help");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Start
|
||||||
|
// Stop
|
||||||
|
// Abandon
|
||||||
|
// List
|
||||||
|
// Help
|
||||||
|
|
||||||
|
switch (args[0].toLowerCase()) {
|
||||||
|
case "start" -> {
|
||||||
|
siegeStart(sender, args, false);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
case "stop" -> {
|
||||||
|
siegeStop(sender, args);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
case "abandon" -> {
|
||||||
|
siegeAbandon(sender, args);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
case "list" -> {
|
||||||
|
siegeList(sender, args);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
case "help" -> {
|
||||||
|
siegeHelp(sender, args);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -1,69 +1,23 @@
|
|||||||
package me.ShermansWorld.AlathraWar.commands;
|
package me.ShermansWorld.AlathraWar.commands;
|
||||||
|
|
||||||
import me.ShermansWorld.AlathraWar.*;
|
|
||||||
import org.bukkit.Bukkit;
|
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
|
|
||||||
import com.palmergames.bukkit.towny.TownyAPI;
|
import com.palmergames.bukkit.towny.TownyAPI;
|
||||||
import com.palmergames.bukkit.towny.object.Resident;
|
import com.palmergames.bukkit.towny.object.Resident;
|
||||||
import com.palmergames.bukkit.towny.object.Town;
|
import com.palmergames.bukkit.towny.object.Town;
|
||||||
|
import me.ShermansWorld.AlathraWar.*;
|
||||||
import me.ShermansWorld.AlathraWar.data.WarData;
|
import me.ShermansWorld.AlathraWar.data.WarData;
|
||||||
import net.md_5.bungee.api.ChatColor;
|
import net.md_5.bungee.api.ChatColor;
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.command.Command;
|
import org.bukkit.command.Command;
|
||||||
import org.bukkit.command.CommandSender;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import org.bukkit.command.CommandExecutor;
|
import org.bukkit.command.CommandExecutor;
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
|
||||||
public class WarCommands implements CommandExecutor {
|
public class WarCommands implements CommandExecutor {
|
||||||
|
|
||||||
public WarCommands(final Main plugin) {
|
public WarCommands(final Main plugin) {
|
||||||
plugin.getCommand("war").setExecutor((CommandExecutor) this);
|
plugin.getCommand("war").setExecutor(this);
|
||||||
}
|
|
||||||
|
|
||||||
public boolean onCommand(final CommandSender sender, final Command cmd, final String label, final String[] args) {
|
|
||||||
CommandHelper.logCommand(sender, label, args);
|
|
||||||
if (!(sender instanceof Player)) {
|
|
||||||
consoleCommand(sender, args);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
final Player p = (Player) sender;
|
|
||||||
if (args.length == 0) {
|
|
||||||
p.sendMessage(String.valueOf(Helper.chatLabel()) + "Invalid Arguments. /war help");
|
|
||||||
return true;
|
|
||||||
} else if (args.length >= 1) {
|
|
||||||
|
|
||||||
switch(args[0].toLowerCase()) {
|
|
||||||
case "create":
|
|
||||||
warCreate(p, args);
|
|
||||||
return true;
|
|
||||||
case "delete":
|
|
||||||
warDelete(p, args);
|
|
||||||
return true;
|
|
||||||
case "join":
|
|
||||||
warJoin(p, args, false);
|
|
||||||
return true;
|
|
||||||
case "surrender":
|
|
||||||
warSurrender(p, args, false);
|
|
||||||
return true;
|
|
||||||
case "list":
|
|
||||||
warList(p, args);
|
|
||||||
return true;
|
|
||||||
case "info":
|
|
||||||
warInfo(p, args);
|
|
||||||
return true;
|
|
||||||
case "help":
|
|
||||||
warHelp(p, args);
|
|
||||||
return true;
|
|
||||||
default:
|
|
||||||
p.sendMessage(String.valueOf(Helper.chatLabel()) + "Invalid Arguments. /war help");
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected static void warCreate(CommandSender p, String[] args) {
|
protected static void warCreate(CommandSender p, String[] args) {
|
||||||
@@ -76,13 +30,12 @@ public class WarCommands implements CommandExecutor {
|
|||||||
WarData.addWar(war);
|
WarData.addWar(war);
|
||||||
war.save();
|
war.save();
|
||||||
|
|
||||||
Bukkit.broadcastMessage(String.valueOf(Helper.chatLabel()) + "War created with the name " + args[1] + ", "
|
Bukkit.broadcastMessage(Helper.chatLabel() + "War created with the name " + args[1] + ", "
|
||||||
+ args[2] + " vs. " + args[3]);
|
+ args[2] + " vs. " + args[3]);
|
||||||
Main.warLogger.log(p.getName() + " created a new war with the name " + args[1] + ", " + args[2]
|
Main.warLogger.log(p.getName() + " created a new war with the name " + args[1] + ", " + args[2]
|
||||||
+ " vs. " + args[3]);
|
+ " vs. " + args[3]);
|
||||||
return;
|
|
||||||
} else {
|
} else {
|
||||||
p.sendMessage(String.valueOf(Helper.chatLabel())
|
p.sendMessage(Helper.chatLabel()
|
||||||
+ "Invalid Arguments. /war create [name] [side1] [side2]");
|
+ "Invalid Arguments. /war create [name] [side1] [side2]");
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -113,17 +66,15 @@ public class WarCommands implements CommandExecutor {
|
|||||||
|
|
||||||
WarData.removeWar(war);
|
WarData.removeWar(war);
|
||||||
|
|
||||||
Bukkit.broadcastMessage(String.valueOf(Helper.chatLabel()) + "War " + args[1] + " deleted.");
|
Bukkit.broadcastMessage(Helper.chatLabel() + "War " + args[1] + " deleted.");
|
||||||
Main.warLogger.log(p.getName() + " deleted " + args[1]);
|
Main.warLogger.log(p.getName() + " deleted " + args[1]);
|
||||||
return;
|
|
||||||
} else {
|
} else {
|
||||||
p.sendMessage(String.valueOf(Helper.chatLabel())
|
p.sendMessage(Helper.chatLabel()
|
||||||
+ "Invalid Arguments. /war delete [name]");
|
+ "Invalid Arguments. /war delete [name]");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @param p - executor
|
* @param p - executor
|
||||||
* @param args
|
* @param args
|
||||||
* @param admin - admin behavior
|
* @param admin - admin behavior
|
||||||
@@ -184,12 +135,14 @@ public class WarCommands implements CommandExecutor {
|
|||||||
if (minuteman != 0) {
|
if (minuteman != 0) {
|
||||||
if (minuteman == 1) {
|
if (minuteman == 1) {
|
||||||
//player has joined to recently
|
//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.");
|
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.");
|
||||||
player.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.");
|
player.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;
|
return;
|
||||||
} else if (minuteman == 2) {
|
} else if (minuteman == 2) {
|
||||||
//player has played too little
|
//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.");
|
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.");
|
||||||
player.sendMessage(ChatColor.RED + "You have not played enough! You can only join a raid after " + Main.getInstance().getConfig().getInt("minimumPlayTime") + " hours of play.");
|
player.sendMessage(ChatColor.RED + "You have not played enough! You can only join a raid after " + Main.getInstance().getConfig().getInt("minimumPlayTime") + " hours of play.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -214,11 +167,9 @@ public class WarCommands implements CommandExecutor {
|
|||||||
p.sendMessage(Helper.chatLabel() + "You have joined the war for " + res.getNationOrNull().getName());
|
p.sendMessage(Helper.chatLabel() + "You have joined the war for " + res.getNationOrNull().getName());
|
||||||
Bukkit.broadcastMessage(Helper.chatLabel() + "The nation of " + res.getNationOrNull().getName() + " has joined the war on the side of " + args[2] + "!");
|
Bukkit.broadcastMessage(Helper.chatLabel() + "The nation of " + res.getNationOrNull().getName() + " has joined the war on the side of " + args[2] + "!");
|
||||||
war.save();
|
war.save();
|
||||||
return;
|
|
||||||
} else {
|
} else {
|
||||||
// Cannot declare nation involvement
|
// Cannot declare nation involvement
|
||||||
p.sendMessage(Helper.chatLabel() + "You cannot declare war for your nation.");
|
p.sendMessage(Helper.chatLabel() + "You cannot declare war for your nation.");
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
} else if (res.hasTown()) {
|
} else if (res.hasTown()) {
|
||||||
if (res.getPlayer().hasPermission("AlathraWar.townjoin") || res.isMayor()) {
|
if (res.getPlayer().hasPermission("AlathraWar.townjoin") || res.isMayor()) {
|
||||||
@@ -228,11 +179,9 @@ public class WarCommands implements CommandExecutor {
|
|||||||
p.sendMessage(Helper.chatLabel() + "You have joined the war for " + res.getTownOrNull().getName());
|
p.sendMessage(Helper.chatLabel() + "You have joined the war for " + res.getTownOrNull().getName());
|
||||||
Bukkit.broadcastMessage(Helper.chatLabel() + "The town of " + res.getTownOrNull().getName() + " has joined the war on the side of " + args[2] + "!");
|
Bukkit.broadcastMessage(Helper.chatLabel() + "The town of " + res.getTownOrNull().getName() + " has joined the war on the side of " + args[2] + "!");
|
||||||
war.save();
|
war.save();
|
||||||
return;
|
|
||||||
} else {
|
} else {
|
||||||
// No perms
|
// No perms
|
||||||
p.sendMessage(Helper.chatLabel() + "You cannot declare war for your town.");
|
p.sendMessage(Helper.chatLabel() + "You cannot declare war for your town.");
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -270,11 +219,9 @@ public class WarCommands implements CommandExecutor {
|
|||||||
p.sendMessage(Helper.chatLabel() + "You have surrendered the war for " + res.getNationOrNull().getName());
|
p.sendMessage(Helper.chatLabel() + "You have surrendered the war for " + res.getNationOrNull().getName());
|
||||||
Bukkit.broadcastMessage(Helper.chatLabel() + "The nation of " + res.getNationOrNull().getName() + " has surrendered! They were fighting for " + args[2] + ".");
|
Bukkit.broadcastMessage(Helper.chatLabel() + "The nation of " + res.getNationOrNull().getName() + " has surrendered! They were fighting for " + args[2] + ".");
|
||||||
war.save();
|
war.save();
|
||||||
return;
|
|
||||||
} else {
|
} else {
|
||||||
// Cannot surrender nation involvement
|
// Cannot surrender nation involvement
|
||||||
p.sendMessage(Helper.chatLabel() + "You cannot surrender war for your nation.");
|
p.sendMessage(Helper.chatLabel() + "You cannot surrender war for your nation.");
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
} else if (res.hasTown()) {
|
} else if (res.hasTown()) {
|
||||||
if (p.hasPermission("AlathraWar.townsurrender") || res.isMayor()) {
|
if (p.hasPermission("AlathraWar.townsurrender") || res.isMayor()) {
|
||||||
@@ -283,11 +230,9 @@ public class WarCommands implements CommandExecutor {
|
|||||||
p.sendMessage(Helper.chatLabel() + "You have surrendered the war for " + res.getTownOrNull().getName());
|
p.sendMessage(Helper.chatLabel() + "You have surrendered the war for " + res.getTownOrNull().getName());
|
||||||
Bukkit.broadcastMessage(Helper.chatLabel() + "The town of " + res.getTownOrNull().getName() + " has surrendered! They were fighting for " + args[2] + ".");
|
Bukkit.broadcastMessage(Helper.chatLabel() + "The town of " + res.getTownOrNull().getName() + " has surrendered! They were fighting for " + args[2] + ".");
|
||||||
war.save();
|
war.save();
|
||||||
return;
|
|
||||||
} else {
|
} else {
|
||||||
// No perms
|
// No perms
|
||||||
p.sendMessage(Helper.chatLabel() + "You cannot surrender war for your town.");
|
p.sendMessage(Helper.chatLabel() + "You cannot surrender war for your town.");
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -296,7 +241,7 @@ public class WarCommands implements CommandExecutor {
|
|||||||
private static void warList(Player p, String[] args) {
|
private static void warList(Player p, String[] args) {
|
||||||
p.sendMessage(Helper.chatLabel() + "Wars:");
|
p.sendMessage(Helper.chatLabel() + "Wars:");
|
||||||
ArrayList<War> wars = WarData.getWars();
|
ArrayList<War> wars = WarData.getWars();
|
||||||
if (wars.size() < 1) {
|
if (wars.isEmpty()) {
|
||||||
p.sendMessage("There are no current wars.");
|
p.sendMessage("There are no current wars.");
|
||||||
} else {
|
} else {
|
||||||
for (War war : wars) {
|
for (War war : wars) {
|
||||||
@@ -336,6 +281,7 @@ public class WarCommands implements CommandExecutor {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Method for console access
|
* Method for console access
|
||||||
|
*
|
||||||
* @param sender
|
* @param sender
|
||||||
* @param args
|
* @param args
|
||||||
*/
|
*/
|
||||||
@@ -351,4 +297,30 @@ public class WarCommands implements CommandExecutor {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean onCommand(final CommandSender sender, final Command cmd, final String label, final String[] args) {
|
||||||
|
CommandHelper.logCommand(sender, label, args);
|
||||||
|
if (!(sender instanceof Player p)) {
|
||||||
|
consoleCommand(sender, args);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (args.length == 0) {
|
||||||
|
p.sendMessage(Helper.chatLabel() + "Invalid Arguments. /war help");
|
||||||
|
} else {
|
||||||
|
|
||||||
|
switch (args[0].toLowerCase()) {
|
||||||
|
case "create" -> warCreate(p, args);
|
||||||
|
case "delete" -> warDelete(p, args);
|
||||||
|
case "join" -> warJoin(p, args, false);
|
||||||
|
case "surrender" -> warSurrender(p, args, false);
|
||||||
|
case "list" -> warList(p, args);
|
||||||
|
case "info" -> warInfo(p, args);
|
||||||
|
case "help" -> warHelp(p, args);
|
||||||
|
default -> p.sendMessage(Helper.chatLabel() + "Invalid Arguments. /war help");
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -1,35 +1,29 @@
|
|||||||
package me.ShermansWorld.AlathraWar.data;
|
package me.ShermansWorld.AlathraWar.data;
|
||||||
|
|
||||||
import java.io.File;
|
import me.ShermansWorld.AlathraWar.Main;
|
||||||
import java.io.FileInputStream;
|
|
||||||
import java.io.FileNotFoundException;
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.io.InputStream;
|
|
||||||
import java.io.PrintWriter;
|
|
||||||
import java.nio.file.Files;
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.logging.Level;
|
|
||||||
|
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.yaml.snakeyaml.DumperOptions;
|
import org.yaml.snakeyaml.DumperOptions;
|
||||||
import org.yaml.snakeyaml.Yaml;
|
import org.yaml.snakeyaml.Yaml;
|
||||||
|
|
||||||
import me.ShermansWorld.AlathraWar.Main;
|
import java.io.*;
|
||||||
|
import java.nio.file.Files;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.logging.Level;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Manages file IO & Deletion for other data classes.
|
* Manages file IO & Deletion for other data classes.
|
||||||
*/
|
*/
|
||||||
public class DataManager {
|
public class DataManager {
|
||||||
private static DumperOptions options;
|
private static DumperOptions options;
|
||||||
|
private static final String dataFolder = "plugins" + File.separator + "AlathraWar" + File.separator + "data";
|
||||||
|
|
||||||
public DataManager() {
|
public DataManager() {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static String dataFolder = "plugins" + File.separator + "AlathraWar" + File.separator + "data";
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Saves data into a .yml format
|
* Saves data into a .yml format
|
||||||
|
*
|
||||||
* @param filePath - File's path after <PLUGIN>/Data/
|
* @param filePath - File's path after <PLUGIN>/Data/
|
||||||
* @param map - Map to be saved
|
* @param map - Map to be saved
|
||||||
*/
|
*/
|
||||||
@@ -45,7 +39,7 @@ public class DataManager {
|
|||||||
Bukkit.getLogger().log(Level.WARNING, "Error Print canRead: " + (file == null ? "" : file.canRead()));
|
Bukkit.getLogger().log(Level.WARNING, "Error Print canRead: " + (file == null ? "" : file.canRead()));
|
||||||
Bukkit.getLogger().log(Level.WARNING, "Error Print isHidden: " + (file == null ? "" : file.isHidden()));
|
Bukkit.getLogger().log(Level.WARNING, "Error Print isHidden: " + (file == null ? "" : file.isHidden()));
|
||||||
Bukkit.getLogger().log(Level.WARNING, "Error Print path: " + (file == null ? "" : file.getPath()));
|
Bukkit.getLogger().log(Level.WARNING, "Error Print path: " + (file == null ? "" : file.getPath()));
|
||||||
PrintWriter writer = null;
|
PrintWriter writer;
|
||||||
try {
|
try {
|
||||||
file.setWritable(true);
|
file.setWritable(true);
|
||||||
writer = new PrintWriter(file);
|
writer = new PrintWriter(file);
|
||||||
@@ -74,6 +68,7 @@ public class DataManager {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the data back as a HashMap
|
* Gets the data back as a HashMap
|
||||||
|
*
|
||||||
* @param filePath - FilePath of data
|
* @param filePath - FilePath of data
|
||||||
* @return HashMap of data or null
|
* @return HashMap of data or null
|
||||||
*/
|
*/
|
||||||
@@ -84,6 +79,7 @@ public class DataManager {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the data back as a HashMap
|
* Gets the data back as a HashMap
|
||||||
|
*
|
||||||
* @param file - Data file
|
* @param file - Data file
|
||||||
* @return HashMap of data or null
|
* @return HashMap of data or null
|
||||||
*/
|
*/
|
||||||
@@ -93,7 +89,7 @@ public class DataManager {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
InputStream inputStream = null;
|
InputStream inputStream;
|
||||||
try {
|
try {
|
||||||
inputStream = new FileInputStream(file);
|
inputStream = new FileInputStream(file);
|
||||||
} catch (FileNotFoundException e) {
|
} catch (FileNotFoundException e) {
|
||||||
@@ -113,6 +109,7 @@ public class DataManager {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Deletes the specified file
|
* Deletes the specified file
|
||||||
|
*
|
||||||
* @param filePath - FilePath of deletion
|
* @param filePath - FilePath of deletion
|
||||||
* @return Boolean of success
|
* @return Boolean of success
|
||||||
*/
|
*/
|
||||||
@@ -135,6 +132,7 @@ public class DataManager {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Converts filePath into File
|
* Converts filePath into File
|
||||||
|
*
|
||||||
* @param path - File's path within data folder
|
* @param path - File's path within data folder
|
||||||
* @return File or null
|
* @return File or null
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -11,21 +11,25 @@ import me.ShermansWorld.AlathraWar.Raid;
|
|||||||
import me.ShermansWorld.AlathraWar.War;
|
import me.ShermansWorld.AlathraWar.War;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.OfflinePlayer;
|
import org.bukkit.OfflinePlayer;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
import javax.annotation.Nonnull;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
|
||||||
public class RaidData {
|
public class RaidData {
|
||||||
// Static Raid list for all active raids
|
// Static Raid list for all active raids
|
||||||
private static ArrayList<Raid> raids = new ArrayList<Raid>();
|
private static final ArrayList<Raid> raids = new ArrayList<>();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public static ArrayList<Raid> getRaids() {
|
public static ArrayList<Raid> getRaids() {
|
||||||
return raids;
|
return raids;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void setRaids(ArrayList<Raid> raids) {
|
||||||
|
for (Raid raid : raids) {
|
||||||
|
addRaid(raid);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets a raid with a specific name
|
* Gets a raid with a specific name
|
||||||
@@ -40,12 +44,6 @@ public class RaidData {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void setRaids(ArrayList<Raid> raids) {
|
|
||||||
for (Raid raid : raids) {
|
|
||||||
addRaid(raid);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void addRaid(Raid raid) {
|
public static void addRaid(Raid raid) {
|
||||||
if (raid == null) {
|
if (raid == null) {
|
||||||
Main.warLogger.log("Attempted to add NULL to raid list.");
|
Main.warLogger.log("Attempted to add NULL to raid list.");
|
||||||
@@ -119,7 +117,7 @@ public class RaidData {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static ArrayList<Raid> createRaids(War war, Collection<HashMap<String, Object>> raidMaps) {
|
public static ArrayList<Raid> createRaids(War war, Collection<HashMap<String, Object>> raidMaps) {
|
||||||
ArrayList<Raid> returnList = new ArrayList<Raid>();
|
ArrayList<Raid> returnList = new ArrayList<>();
|
||||||
for (HashMap<String, Object> map : raidMaps) {
|
for (HashMap<String, Object> map : raidMaps) {
|
||||||
Town town = TownyAPI.getInstance().getTown((String) map.get("raidedTown"));
|
Town town = TownyAPI.getInstance().getTown((String) map.get("raidedTown"));
|
||||||
if (town == null) continue;
|
if (town == null) continue;
|
||||||
@@ -143,9 +141,9 @@ public class RaidData {
|
|||||||
war.save();
|
war.save();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
// /**
|
||||||
* deletes raid, unused
|
// * deletes raid, unused
|
||||||
*/
|
// */
|
||||||
// private static void deleteRaid(War war) {
|
// private static void deleteRaid(War war) {
|
||||||
// File[] files = new File(dataFolderPath + File.separator + "wars").listFiles(ymlFilter);
|
// File[] files = new File(dataFolderPath + File.separator + "wars").listFiles(ymlFilter);
|
||||||
//
|
//
|
||||||
@@ -163,7 +161,7 @@ public class RaidData {
|
|||||||
* @return Map
|
* @return Map
|
||||||
*/
|
*/
|
||||||
public static HashMap<String, Object> raidToMap(Raid raid) {
|
public static HashMap<String, Object> raidToMap(Raid raid) {
|
||||||
HashMap<String, Object> returnMap = new HashMap<String, Object>();
|
HashMap<String, Object> returnMap = new HashMap<>();
|
||||||
// Shoves everything into a map.
|
// Shoves everything into a map.
|
||||||
returnMap.put("name", raid.getName());
|
returnMap.put("name", raid.getName());
|
||||||
returnMap.put("raidedTown", raid.getRaidedTown().getName());
|
returnMap.put("raidedTown", raid.getRaidedTown().getName());
|
||||||
@@ -178,11 +176,20 @@ public class RaidData {
|
|||||||
returnMap.put("owner", raid.getOwner().getUniqueId().toString());
|
returnMap.put("owner", raid.getOwner().getUniqueId().toString());
|
||||||
|
|
||||||
//create a list from the looted chunks
|
//create a list from the looted chunks
|
||||||
List<Object> chunkList = new ArrayList<Object>();
|
final List<Object> chunkList = getChunkList(raid);
|
||||||
|
|
||||||
|
returnMap.put("lootedChunks", chunkList);
|
||||||
|
|
||||||
|
return returnMap;
|
||||||
|
}
|
||||||
|
|
||||||
|
@NotNull
|
||||||
|
private static List<Object> getChunkList(Raid raid) {
|
||||||
|
List<Object> chunkList = new ArrayList<>();
|
||||||
for (Raid.LootBlock b : raid.getLootedChunks().values()) {
|
for (Raid.LootBlock b : raid.getLootedChunks().values()) {
|
||||||
HashMap<String, Object> blockMap = new HashMap<String, Object>();
|
HashMap<String, Object> blockMap = new HashMap<>();
|
||||||
//worldcoord
|
//worldcoord
|
||||||
HashMap<String, Object> wcMap = new HashMap<String, Object>();
|
HashMap<String, Object> wcMap = new HashMap<>();
|
||||||
wcMap.put("world", b.worldCoord.getWorldName());
|
wcMap.put("world", b.worldCoord.getWorldName());
|
||||||
wcMap.put("x", b.worldCoord.getCoord().getX());
|
wcMap.put("x", b.worldCoord.getCoord().getX());
|
||||||
wcMap.put("z", b.worldCoord.getCoord().getZ());
|
wcMap.put("z", b.worldCoord.getCoord().getZ());
|
||||||
@@ -193,10 +200,7 @@ public class RaidData {
|
|||||||
blockMap.put("finished", b.finished);
|
blockMap.put("finished", b.finished);
|
||||||
chunkList.add(blockMap);
|
chunkList.add(blockMap);
|
||||||
}
|
}
|
||||||
|
return chunkList;
|
||||||
returnMap.put("lootedChunks", chunkList);
|
|
||||||
|
|
||||||
return returnMap;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -206,7 +210,7 @@ public class RaidData {
|
|||||||
* @return Map of Maps
|
* @return Map of Maps
|
||||||
*/
|
*/
|
||||||
public static HashMap<String, Object> getRaidMap(War war) {
|
public static HashMap<String, Object> getRaidMap(War war) {
|
||||||
HashMap<String, Object> returnMap = new HashMap<String, Object>();
|
HashMap<String, Object> returnMap = new HashMap<>();
|
||||||
for (Raid raid : war.getRaids()) {
|
for (Raid raid : war.getRaids()) {
|
||||||
returnMap.put(raid.getRaidedTown().getName(), raidToMap(raid));
|
returnMap.put(raid.getRaidedTown().getName(), raidToMap(raid));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,13 +16,14 @@ public enum RaidPhase {
|
|||||||
public final int id;
|
public final int id;
|
||||||
public final int startTick;
|
public final int startTick;
|
||||||
|
|
||||||
private RaidPhase(int id, int startTick) {
|
RaidPhase(int id, int startTick) {
|
||||||
this.id = id;
|
this.id = id;
|
||||||
this.startTick = startTick;
|
this.startTick = startTick;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Grabs the phase by name, ignores case
|
* Grabs the phase by name, ignores case
|
||||||
|
*
|
||||||
* @param name
|
* @param name
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
@@ -35,6 +36,7 @@ public enum RaidPhase {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Grabs phase by id number for easy storage reading
|
* Grabs phase by id number for easy storage reading
|
||||||
|
*
|
||||||
* @param id
|
* @param id
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
@@ -47,19 +49,19 @@ public enum RaidPhase {
|
|||||||
|
|
||||||
public static RaidPhase getNext(RaidPhase phase) {
|
public static RaidPhase getNext(RaidPhase phase) {
|
||||||
switch (phase) {
|
switch (phase) {
|
||||||
case START: {
|
case START -> {
|
||||||
return GATHER;
|
return GATHER;
|
||||||
}
|
}
|
||||||
case GATHER: {
|
case GATHER -> {
|
||||||
return TRAVEL;
|
return TRAVEL;
|
||||||
}
|
}
|
||||||
case TRAVEL: {
|
case TRAVEL -> {
|
||||||
return COMBAT;
|
return COMBAT;
|
||||||
}
|
}
|
||||||
case COMBAT: {
|
case COMBAT -> {
|
||||||
return END;
|
return END;
|
||||||
}
|
}
|
||||||
default: {
|
default -> {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,31 +1,33 @@
|
|||||||
package me.ShermansWorld.AlathraWar.data;
|
package me.ShermansWorld.AlathraWar.data;
|
||||||
|
|
||||||
import java.util.*;
|
|
||||||
|
|
||||||
import org.bukkit.Bukkit;
|
|
||||||
import org.bukkit.OfflinePlayer;
|
|
||||||
|
|
||||||
import com.palmergames.bukkit.towny.TownyAPI;
|
import com.palmergames.bukkit.towny.TownyAPI;
|
||||||
import com.palmergames.bukkit.towny.object.Town;
|
import com.palmergames.bukkit.towny.object.Town;
|
||||||
|
|
||||||
import me.ShermansWorld.AlathraWar.Main;
|
import me.ShermansWorld.AlathraWar.Main;
|
||||||
import me.ShermansWorld.AlathraWar.War;
|
|
||||||
import me.ShermansWorld.AlathraWar.Siege;
|
import me.ShermansWorld.AlathraWar.Siege;
|
||||||
|
import me.ShermansWorld.AlathraWar.War;
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.OfflinePlayer;
|
||||||
|
|
||||||
public class SiegeData
|
import java.util.*;
|
||||||
{
|
|
||||||
|
public class SiegeData {
|
||||||
|
|
||||||
// Static Siege list for all active sieges
|
// Static Siege list for all active sieges
|
||||||
private static HashSet<Siege> sieges = new HashSet<Siege>();
|
private static final HashSet<Siege> sieges = new HashSet<>();
|
||||||
|
|
||||||
public static HashSet<Siege> getSieges() {
|
public static HashSet<Siege> getSieges() {
|
||||||
return sieges;
|
return sieges;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void setSieges(ArrayList<Siege> sieges) {
|
||||||
|
for (Siege siege : sieges) {
|
||||||
|
addSiege(siege);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets a siege with a specific name
|
* Gets a siege with a specific name
|
||||||
|
*
|
||||||
* @param name - Name to check
|
* @param name - Name to check
|
||||||
* @return Siege or Null
|
* @return Siege or Null
|
||||||
*/
|
*/
|
||||||
@@ -36,12 +38,6 @@ public class SiegeData
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void setSieges(ArrayList<Siege> sieges) {
|
|
||||||
for (Siege siege : sieges) {
|
|
||||||
addSiege(siege);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void addSiege(Siege siege) {
|
public static void addSiege(Siege siege) {
|
||||||
if (siege == null) {
|
if (siege == null) {
|
||||||
Main.warLogger.log("Attempted to add NULL to siege list.");
|
Main.warLogger.log("Attempted to add NULL to siege list.");
|
||||||
@@ -57,6 +53,7 @@ public class SiegeData
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a siege object from a provided HashMap
|
* Creates a siege object from a provided HashMap
|
||||||
|
*
|
||||||
* @param fileData data
|
* @param fileData data
|
||||||
* @return Siege object
|
* @return Siege object
|
||||||
*/
|
*/
|
||||||
@@ -69,14 +66,12 @@ public class SiegeData
|
|||||||
Town town = TownyAPI.getInstance().getTown((String) fileData.get("town"));
|
Town town = TownyAPI.getInstance().getTown((String) fileData.get("town"));
|
||||||
OfflinePlayer offlinePlayer = Bukkit.getOfflinePlayer(UUID.fromString((String) fileData.get("siegeLeader")));
|
OfflinePlayer offlinePlayer = Bukkit.getOfflinePlayer(UUID.fromString((String) fileData.get("siegeLeader")));
|
||||||
|
|
||||||
Siege siege = new Siege(war, town, offlinePlayer);
|
return new Siege(war, town, offlinePlayer);
|
||||||
|
|
||||||
return siege;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Saves the war into files.
|
* Saves the war into files.
|
||||||
|
*
|
||||||
* @param siege - Siege to be saved.
|
* @param siege - Siege to be saved.
|
||||||
*/
|
*/
|
||||||
public static void saveSiege(Siege siege) {
|
public static void saveSiege(Siege siege) {
|
||||||
@@ -86,11 +81,12 @@ public class SiegeData
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Turns a siege into a map
|
* Turns a siege into a map
|
||||||
|
*
|
||||||
* @param siege - Siege
|
* @param siege - Siege
|
||||||
* @return Map
|
* @return Map
|
||||||
*/
|
*/
|
||||||
public static HashMap<String, Object> siegeToMap(Siege siege) {
|
public static HashMap<String, Object> siegeToMap(Siege siege) {
|
||||||
HashMap<String, Object> returnMap = new HashMap<String, Object>();
|
HashMap<String, Object> returnMap = new HashMap<>();
|
||||||
// Shoves everything into a map.
|
// Shoves everything into a map.
|
||||||
returnMap.put("town", siege.getTown().getName());
|
returnMap.put("town", siege.getTown().getName());
|
||||||
returnMap.put("siegeTicks", siege.getSiegeTicks());
|
returnMap.put("siegeTicks", siege.getSiegeTicks());
|
||||||
@@ -104,11 +100,12 @@ public class SiegeData
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a map of siege maps
|
* Creates a map of siege maps
|
||||||
|
*
|
||||||
* @param war - War to map
|
* @param war - War to map
|
||||||
* @return Map of Maps
|
* @return Map of Maps
|
||||||
*/
|
*/
|
||||||
public static HashMap<String, Object> getSiegeMap(War war) {
|
public static HashMap<String, Object> getSiegeMap(War war) {
|
||||||
HashMap<String, Object> returnMap = new HashMap<String, Object>();
|
HashMap<String, Object> returnMap = new HashMap<>();
|
||||||
for (Siege siege : war.getSieges()) {
|
for (Siege siege : war.getSieges()) {
|
||||||
returnMap.put(siege.getTown().getName(), siegeToMap(siege));
|
returnMap.put(siege.getTown().getName(), siegeToMap(siege));
|
||||||
}
|
}
|
||||||
@@ -116,7 +113,7 @@ public class SiegeData
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static ArrayList<Siege> createSieges(War war, Collection<HashMap<String, Object>> siegeMaps) {
|
public static ArrayList<Siege> createSieges(War war, Collection<HashMap<String, Object>> siegeMaps) {
|
||||||
ArrayList<Siege> returnList = new ArrayList<Siege>();
|
ArrayList<Siege> returnList = new ArrayList<>();
|
||||||
for (HashMap<String, Object> map : siegeMaps) {
|
for (HashMap<String, Object> map : siegeMaps) {
|
||||||
Town town = TownyAPI.getInstance().getTown((String) map.get("town"));
|
Town town = TownyAPI.getInstance().getTown((String) map.get("town"));
|
||||||
if (town == null) continue;
|
if (town == null) continue;
|
||||||
|
|||||||
@@ -1,9 +1,5 @@
|
|||||||
package me.ShermansWorld.AlathraWar.data;
|
package me.ShermansWorld.AlathraWar.data;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Collection;
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.List;
|
|
||||||
import me.ShermansWorld.AlathraWar.Main;
|
import me.ShermansWorld.AlathraWar.Main;
|
||||||
import me.ShermansWorld.AlathraWar.Raid;
|
import me.ShermansWorld.AlathraWar.Raid;
|
||||||
import me.ShermansWorld.AlathraWar.Siege;
|
import me.ShermansWorld.AlathraWar.Siege;
|
||||||
@@ -11,21 +7,17 @@ import me.ShermansWorld.AlathraWar.War;
|
|||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.FilenameFilter;
|
import java.io.FilenameFilter;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Collection;
|
||||||
|
import java.util.HashMap;
|
||||||
|
|
||||||
public class WarData
|
public class WarData {
|
||||||
{
|
|
||||||
|
|
||||||
// Static War list for all active wars
|
|
||||||
private static ArrayList<War> wars = new ArrayList<War>();
|
|
||||||
private final static String dataFolderPath = "plugins" + File.separator + "AlathraWar" + File.separator + "data";
|
private final static String dataFolderPath = "plugins" + File.separator + "AlathraWar" + File.separator + "data";
|
||||||
|
// Static War list for all active wars
|
||||||
|
private static ArrayList<War> wars = new ArrayList<>();
|
||||||
// Filter for only accessing yml files
|
// Filter for only accessing yml files
|
||||||
private static FilenameFilter ymlFilter = new FilenameFilter() {
|
private static final FilenameFilter ymlFilter = (dir, name) -> name.endsWith(".yml");
|
||||||
@Override
|
|
||||||
public boolean accept(File dir, String name) {
|
|
||||||
return name.endsWith(".yml");
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
// Constructor used to initialise folder.
|
// Constructor used to initialise folder.
|
||||||
public WarData(final Main plugin) {
|
public WarData(final Main plugin) {
|
||||||
@@ -39,8 +31,13 @@ public class WarData
|
|||||||
return wars;
|
return wars;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void setWars(ArrayList<War> wars) {
|
||||||
|
WarData.wars = wars;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets a war with a specific name
|
* Gets a war with a specific name
|
||||||
|
*
|
||||||
* @param name - Name to check
|
* @param name - Name to check
|
||||||
* @return War or Null
|
* @return War or Null
|
||||||
*/
|
*/
|
||||||
@@ -51,10 +48,6 @@ public class WarData
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void setWars(ArrayList<War> wars) {
|
|
||||||
WarData.wars = wars;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void addWar(War war) {
|
public static void addWar(War war) {
|
||||||
if (war == null) {
|
if (war == null) {
|
||||||
Main.warLogger.log("Attempted to add NULL to war list.");
|
Main.warLogger.log("Attempted to add NULL to war list.");
|
||||||
@@ -70,12 +63,13 @@ public class WarData
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the wars currently saved in files as an ArrayList of War Objects
|
* Gets the wars currently saved in files as an ArrayList of War Objects
|
||||||
|
*
|
||||||
* @return War Object ArrayList
|
* @return War Object ArrayList
|
||||||
*/
|
*/
|
||||||
public static ArrayList<War> createWars() {
|
public static ArrayList<War> createWars() {
|
||||||
File[] files = new File(dataFolderPath + File.separator + "wars").listFiles(ymlFilter);
|
File[] files = new File(dataFolderPath + File.separator + "wars").listFiles(ymlFilter);
|
||||||
|
|
||||||
ArrayList<War> returnList = new ArrayList<War>();
|
ArrayList<War> returnList = new ArrayList<>();
|
||||||
for (File file : files) {
|
for (File file : files) {
|
||||||
try {
|
try {
|
||||||
HashMap<String, Object> fileData = DataManager.getData(file);
|
HashMap<String, Object> fileData = DataManager.getData(file);
|
||||||
@@ -92,6 +86,7 @@ public class WarData
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a war object from a provided HashMap
|
* Creates a war object from a provided HashMap
|
||||||
|
*
|
||||||
* @param fileData
|
* @param fileData
|
||||||
* @return War object
|
* @return War object
|
||||||
*/
|
*/
|
||||||
@@ -136,18 +131,19 @@ public class WarData
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Saves the war into files.
|
* Saves the war into files.
|
||||||
|
*
|
||||||
* @param war - War to be saved.
|
* @param war - War to be saved.
|
||||||
*/
|
*/
|
||||||
public static void saveWar(War war) {
|
public static void saveWar(War war) {
|
||||||
HashMap<String, Object> sHashMap = new HashMap<String,Object>();
|
HashMap<String, Object> sHashMap = new HashMap<>();
|
||||||
|
|
||||||
// Shoves everything into a map.
|
// Shoves everything into a map.
|
||||||
sHashMap.put("name", war.getName());
|
sHashMap.put("name", war.getName());
|
||||||
sHashMap.put("side1", war.getSide1());
|
sHashMap.put("side1", war.getSide1());
|
||||||
sHashMap.put("side2", war.getSide2());
|
sHashMap.put("side2", war.getSide2());
|
||||||
sHashMap.put("side1Towns", (List<String>) war.getSide1Towns());
|
sHashMap.put("side1Towns", war.getSide1Towns());
|
||||||
sHashMap.put("side2Towns", (List<String>) war.getSide2Towns());
|
sHashMap.put("side2Towns", war.getSide2Towns());
|
||||||
sHashMap.put("surrenderedTowns", (List<String>) war.getSurrenderedTowns());
|
sHashMap.put("surrenderedTowns", war.getSurrenderedTowns());
|
||||||
sHashMap.put("side1Points", war.getSide1Points());
|
sHashMap.put("side1Points", war.getSide1Points());
|
||||||
sHashMap.put("side2Points", war.getSide2Points());
|
sHashMap.put("side2Points", war.getSide2Points());
|
||||||
|
|
||||||
|
|||||||
@@ -1,13 +1,12 @@
|
|||||||
package me.ShermansWorld.AlathraWar.hooks;
|
package me.ShermansWorld.AlathraWar.hooks;
|
||||||
|
|
||||||
import org.bukkit.Bukkit;
|
|
||||||
import org.bukkit.OfflinePlayer;
|
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
|
|
||||||
import me.ShermansWorld.AlathraWar.Helper;
|
import me.ShermansWorld.AlathraWar.Helper;
|
||||||
import me.ShermansWorld.AlathraWar.War;
|
import me.ShermansWorld.AlathraWar.War;
|
||||||
import me.neznamy.tab.api.TabAPI;
|
import me.neznamy.tab.api.TabAPI;
|
||||||
import me.neznamy.tab.api.TabPlayer;
|
import me.neznamy.tab.api.TabPlayer;
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.OfflinePlayer;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
public class TABHook {
|
public class TABHook {
|
||||||
|
|
||||||
@@ -57,7 +56,6 @@ public class TABHook {
|
|||||||
tabAPI.getTablistFormatManager().resetSuffix(tabPlayer);
|
tabAPI.getTablistFormatManager().resetSuffix(tabPlayer);
|
||||||
}
|
}
|
||||||
} catch (NullPointerException e) {
|
} catch (NullPointerException e) {
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -75,7 +73,6 @@ public class TABHook {
|
|||||||
tabAPI.getTablistFormatManager().resetPrefix(tabPlayer);
|
tabAPI.getTablistFormatManager().resetPrefix(tabPlayer);
|
||||||
}
|
}
|
||||||
} catch (NullPointerException e) {
|
} catch (NullPointerException e) {
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -83,8 +80,7 @@ public class TABHook {
|
|||||||
TabPlayer tabPlayer = tabAPI.getPlayer(p.getUniqueId());
|
TabPlayer tabPlayer = tabAPI.getPlayer(p.getUniqueId());
|
||||||
if (prefix.length() > 2) {
|
if (prefix.length() > 2) {
|
||||||
prefix = prefix.substring(0, prefix.length() - 2);
|
prefix = prefix.substring(0, prefix.length() - 2);
|
||||||
}
|
} else {
|
||||||
else{
|
|
||||||
Bukkit.getLogger().info("There is an error when removing a color prefix, prefix not long enough:");
|
Bukkit.getLogger().info("There is an error when removing a color prefix, prefix not long enough:");
|
||||||
Bukkit.getLogger().info("Player: " + p.getDisplayName());
|
Bukkit.getLogger().info("Player: " + p.getDisplayName());
|
||||||
Bukkit.getLogger().info("Prefix: " + prefix);
|
Bukkit.getLogger().info("Prefix: " + prefix);
|
||||||
|
|||||||
@@ -5,8 +5,8 @@ import org.bukkit.inventory.Recipe;
|
|||||||
|
|
||||||
public interface IWarItem {
|
public interface IWarItem {
|
||||||
|
|
||||||
public ItemStack getItemStack();
|
ItemStack getItemStack();
|
||||||
|
|
||||||
public Recipe getRecipe();
|
Recipe getRecipe();
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -4,17 +4,16 @@ import me.ShermansWorld.AlathraWar.Helper;
|
|||||||
import me.ShermansWorld.AlathraWar.Main;
|
import me.ShermansWorld.AlathraWar.Main;
|
||||||
import me.ShermansWorld.AlathraWar.items.item.RamItem;
|
import me.ShermansWorld.AlathraWar.items.item.RamItem;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
public class WarItemRegistry {
|
public class WarItemRegistry {
|
||||||
|
|
||||||
private static WarItemRegistry instance;
|
|
||||||
|
|
||||||
private static final HashMap<String, IWarItem> itemRegistry = new HashMap<>();
|
|
||||||
|
|
||||||
public static final String namespace = Main.getInstance().getName().toLowerCase();
|
public static final String namespace = Main.getInstance().getName().toLowerCase();
|
||||||
|
private static final HashMap<String, IWarItem> itemRegistry = new HashMap<>();
|
||||||
|
private static WarItemRegistry instance;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* loads all items into the plugin registry list
|
* loads all items into the plugin registry list
|
||||||
@@ -37,6 +36,7 @@ public class WarItemRegistry {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* generate a registry name
|
* generate a registry name
|
||||||
|
*
|
||||||
* @param item
|
* @param item
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
@@ -55,6 +55,7 @@ public class WarItemRegistry {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* returns the associated itemstack with the item key, use for finding without namespace
|
* returns the associated itemstack with the item key, use for finding without namespace
|
||||||
|
*
|
||||||
* @param registryName
|
* @param registryName
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
@@ -65,6 +66,7 @@ public class WarItemRegistry {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* returns the associated itemstack with the item key, use for finding with namespace
|
* returns the associated itemstack with the item key, use for finding with namespace
|
||||||
|
*
|
||||||
* @param registryName
|
* @param registryName
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
@@ -74,6 +76,7 @@ public class WarItemRegistry {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* returns the associated IWarItem with the item key, use for finding with namespace
|
* returns the associated IWarItem with the item key, use for finding with namespace
|
||||||
|
*
|
||||||
* @param registryName
|
* @param registryName
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -9,9 +9,8 @@ import java.util.Set;
|
|||||||
|
|
||||||
public class WarRecipeRegistry {
|
public class WarRecipeRegistry {
|
||||||
|
|
||||||
private static WarRecipeRegistry instance;
|
|
||||||
|
|
||||||
private static final HashMap<String, Recipe> recipeRegistry = new HashMap<>();
|
private static final HashMap<String, Recipe> recipeRegistry = new HashMap<>();
|
||||||
|
private static WarRecipeRegistry instance;
|
||||||
|
|
||||||
public WarRecipeRegistry() {
|
public WarRecipeRegistry() {
|
||||||
instance = this;
|
instance = this;
|
||||||
@@ -23,6 +22,10 @@ public class WarRecipeRegistry {
|
|||||||
Main.warLogger.log(Helper.chatLabel() + "Registered AlathraWar recipes.");
|
Main.warLogger.log(Helper.chatLabel() + "Registered AlathraWar recipes.");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static WarRecipeRegistry getInstance() {
|
||||||
|
return instance;
|
||||||
|
}
|
||||||
|
|
||||||
public void register(String name, Set<Recipe> recipes) {
|
public void register(String name, Set<Recipe> recipes) {
|
||||||
for (Recipe recipe : recipes) {
|
for (Recipe recipe : recipes) {
|
||||||
// Bukkit.getServer().addRecipe(recipe);
|
// Bukkit.getServer().addRecipe(recipe);
|
||||||
@@ -30,16 +33,13 @@ public class WarRecipeRegistry {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static WarRecipeRegistry getInstance() {
|
|
||||||
return instance;
|
|
||||||
}
|
|
||||||
|
|
||||||
public HashMap<String, Recipe> getRecipeRegistry() {
|
public HashMap<String, Recipe> getRecipeRegistry() {
|
||||||
return recipeRegistry;
|
return recipeRegistry;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* returns the associated itemstack with the item key, use for finding without namespace
|
* returns the associated itemstack with the item key, use for finding without namespace
|
||||||
|
*
|
||||||
* @param registryName recipe name without namespace
|
* @param registryName recipe name without namespace
|
||||||
* @return recipe
|
* @return recipe
|
||||||
*/
|
*/
|
||||||
@@ -50,6 +50,7 @@ public class WarRecipeRegistry {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* returns the associated itemstack with the item key, use for finding with namespace
|
* returns the associated itemstack with the item key, use for finding with namespace
|
||||||
|
*
|
||||||
* @param registryName registry name including namespace
|
* @param registryName registry name including namespace
|
||||||
* @return recipe
|
* @return recipe
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ public class RamItem implements IWarItem {
|
|||||||
ItemMeta meta = ram.getItemMeta();
|
ItemMeta meta = ram.getItemMeta();
|
||||||
|
|
||||||
meta.setDisplayName("Door Ram");
|
meta.setDisplayName("Door Ram");
|
||||||
ArrayList<String> lore = new ArrayList<String>();
|
ArrayList<String> lore = new ArrayList<>();
|
||||||
meta.setLore(lore);
|
meta.setLore(lore);
|
||||||
meta.setCustomModelData(14700);
|
meta.setCustomModelData(14700);
|
||||||
|
|
||||||
|
|||||||
@@ -1,25 +1,21 @@
|
|||||||
package me.ShermansWorld.AlathraWar.listeners;
|
package me.ShermansWorld.AlathraWar.listeners;
|
||||||
|
|
||||||
|
import com.palmergames.bukkit.towny.object.WorldCoord;
|
||||||
|
import me.ShermansWorld.AlathraWar.Helper;
|
||||||
import me.ShermansWorld.AlathraWar.Raid;
|
import me.ShermansWorld.AlathraWar.Raid;
|
||||||
|
import me.ShermansWorld.AlathraWar.Siege;
|
||||||
import me.ShermansWorld.AlathraWar.data.RaidData;
|
import me.ShermansWorld.AlathraWar.data.RaidData;
|
||||||
import org.bukkit.event.EventHandler;
|
import me.ShermansWorld.AlathraWar.data.SiegeData;
|
||||||
|
|
||||||
import java.util.HashSet;
|
|
||||||
import java.util.Set;
|
|
||||||
|
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.block.Block;
|
import org.bukkit.block.Block;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.event.EventHandler;
|
||||||
|
import org.bukkit.event.Listener;
|
||||||
import org.bukkit.event.block.BlockBreakEvent;
|
import org.bukkit.event.block.BlockBreakEvent;
|
||||||
import org.bukkit.event.block.BlockPlaceEvent;
|
import org.bukkit.event.block.BlockPlaceEvent;
|
||||||
|
|
||||||
import com.palmergames.bukkit.towny.object.WorldCoord;
|
import java.util.HashSet;
|
||||||
|
import java.util.Set;
|
||||||
import me.ShermansWorld.AlathraWar.Helper;
|
|
||||||
import me.ShermansWorld.AlathraWar.Siege;
|
|
||||||
import me.ShermansWorld.AlathraWar.data.SiegeData;
|
|
||||||
|
|
||||||
import org.bukkit.event.Listener;
|
|
||||||
|
|
||||||
public class BlockBreakListener implements Listener {
|
public class BlockBreakListener implements Listener {
|
||||||
|
|
||||||
|
|||||||
@@ -73,7 +73,7 @@ public class CommandsListener implements Listener {
|
|||||||
//payment check
|
//payment check
|
||||||
for (String cmd : blacklistedXLong) {
|
for (String cmd : blacklistedXLong) {
|
||||||
if (parse.equalsIgnoreCase(prefix + (prefix.isEmpty() ? "" : ":") + cmd)) {
|
if (parse.equalsIgnoreCase(prefix + (prefix.isEmpty() ? "" : ":") + cmd)) {
|
||||||
p.sendMessage(String.valueOf(Helper.chatLabel()) + Helper.color("&cYou cannot modify this property during a raid!"));
|
p.sendMessage(Helper.chatLabel() + Helper.color("&cYou cannot modify this property during a raid!"));
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -89,7 +89,7 @@ public class CommandsListener implements Listener {
|
|||||||
for (String cmd : payment) {
|
for (String cmd : payment) {
|
||||||
//check for each prefix
|
//check for each prefix
|
||||||
if (parse.equalsIgnoreCase(prefix + (prefix.isEmpty() ? "" : ":") + cmd)) {
|
if (parse.equalsIgnoreCase(prefix + (prefix.isEmpty() ? "" : ":") + cmd)) {
|
||||||
p.sendMessage(String.valueOf(Helper.chatLabel()) + Helper.color("&cYou cannot withdraw money whilst in a raid!"));
|
p.sendMessage(Helper.chatLabel() + Helper.color("&cYou cannot withdraw money whilst in a raid!"));
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -104,17 +104,17 @@ public class CommandsListener implements Listener {
|
|||||||
|| parse.equalsIgnoreCase("t spawn") || parse.equalsIgnoreCase("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:n spawn") || parse.equalsIgnoreCase("towny:nat spawn") || parse.equalsIgnoreCase("towny:nation spawn")
|
||||||
|| parse.equalsIgnoreCase("towny:t spawn") || parse.equalsIgnoreCase("towny:town spawn")) {
|
|| parse.equalsIgnoreCase("towny:t spawn") || parse.equalsIgnoreCase("towny:town spawn")) {
|
||||||
p.sendMessage(String.valueOf(Helper.chatLabel()) + Helper.color("&eYou are stuck in spawn and are allowed to teleport to your town or nation."));
|
p.sendMessage(Helper.chatLabel() + Helper.color("&eYou are stuck in spawn and are allowed to teleport to your town or nation."));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
p.sendMessage(String.valueOf(Helper.chatLabel()) + Helper.color("&eYou are stuck in spawn and are allowed to teleport to your town or nation."));
|
p.sendMessage(Helper.chatLabel() + Helper.color("&eYou are stuck in spawn and are allowed to teleport to your town or nation."));
|
||||||
p.sendMessage(String.valueOf(Helper.chatLabel()) + Helper.color("&eUse /t spawn, or /n spawn"));
|
p.sendMessage(Helper.chatLabel() + Helper.color("&eUse /t spawn, or /n spawn"));
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
//else
|
//else
|
||||||
p.sendMessage(String.valueOf(Helper.chatLabel()) + Helper.color("&cYou cannot teleport whilst in a raid!"));
|
p.sendMessage(Helper.chatLabel() + Helper.color("&cYou cannot teleport whilst in a raid!"));
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -131,13 +131,13 @@ public class CommandsListener implements Listener {
|
|||||||
if (parse.equalsIgnoreCase(prefix + (prefix.isEmpty() ? "" : ":") + cmd)) {
|
if (parse.equalsIgnoreCase(prefix + (prefix.isEmpty() ? "" : ":") + cmd)) {
|
||||||
//spawn world check
|
//spawn world check
|
||||||
if (p.getWorld().getName().equalsIgnoreCase("world")) {
|
if (p.getWorld().getName().equalsIgnoreCase("world")) {
|
||||||
p.sendMessage(String.valueOf(Helper.chatLabel()) + Helper.color("&eYou are stuck in spawn and are allowed to teleport to your town or nation."));
|
p.sendMessage(Helper.chatLabel() + Helper.color("&eYou are stuck in spawn and are allowed to teleport to your town or nation."));
|
||||||
p.sendMessage(String.valueOf(Helper.chatLabel()) + Helper.color("&eUse /t spawn, or /n spawn"));
|
p.sendMessage(Helper.chatLabel() + Helper.color("&eUse /t spawn, or /n spawn"));
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
p.sendMessage(String.valueOf(Helper.chatLabel()) + Helper.color("&cYou cannot teleport whilst in a raid!"));
|
p.sendMessage(Helper.chatLabel() + Helper.color("&cYou cannot teleport whilst in a raid!"));
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -163,7 +163,7 @@ public class CommandsListener implements Listener {
|
|||||||
//payment check
|
//payment check
|
||||||
for (String cmd : blacklistedXLong) {
|
for (String cmd : blacklistedXLong) {
|
||||||
if (parse.equalsIgnoreCase(prefix + (prefix.isEmpty() ? "" : ":") + cmd)) {
|
if (parse.equalsIgnoreCase(prefix + (prefix.isEmpty() ? "" : ":") + cmd)) {
|
||||||
p.sendMessage(String.valueOf(Helper.chatLabel()) + Helper.color("&cYou cannot modify this property during a siege!"));
|
p.sendMessage(Helper.chatLabel() + Helper.color("&cYou cannot modify this property during a siege!"));
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -221,13 +221,13 @@ public class CommandsListener implements Listener {
|
|||||||
if (parse.equalsIgnoreCase(prefix + (prefix.isEmpty() ? "" : ":") + cmd)) {
|
if (parse.equalsIgnoreCase(prefix + (prefix.isEmpty() ? "" : ":") + cmd)) {
|
||||||
//spawn world check
|
//spawn world check
|
||||||
if (p.getWorld().getName().equalsIgnoreCase("world")) {
|
if (p.getWorld().getName().equalsIgnoreCase("world")) {
|
||||||
p.sendMessage(String.valueOf(Helper.chatLabel()) + Helper.color("&eYou are stuck in spawn and are allowed to teleport to your town or nation."));
|
p.sendMessage(Helper.chatLabel() + Helper.color("&eYou are stuck in spawn and are allowed to teleport to your town or nation."));
|
||||||
p.sendMessage(String.valueOf(Helper.chatLabel()) + Helper.color("&eUse /t spawn, or /n spawn"));
|
p.sendMessage(Helper.chatLabel() + Helper.color("&eUse /t spawn, or /n spawn"));
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
p.sendMessage(String.valueOf(Helper.chatLabel()) + Helper.color("&cYou cannot teleport whilst in a siege!"));
|
p.sendMessage(Helper.chatLabel() + Helper.color("&cYou cannot teleport whilst in a siege!"));
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,27 +1,18 @@
|
|||||||
package me.ShermansWorld.AlathraWar.listeners;
|
package me.ShermansWorld.AlathraWar.listeners;
|
||||||
|
|
||||||
import org.bukkit.event.EventHandler;
|
|
||||||
import org.bukkit.Bukkit;
|
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
import org.bukkit.event.player.PlayerJoinEvent;
|
|
||||||
|
|
||||||
import com.palmergames.bukkit.towny.TownyAPI;
|
import com.palmergames.bukkit.towny.TownyAPI;
|
||||||
import com.palmergames.bukkit.towny.object.Town;
|
import com.palmergames.bukkit.towny.object.Town;
|
||||||
|
|
||||||
import me.ShermansWorld.AlathraWar.Main;
|
import me.ShermansWorld.AlathraWar.Main;
|
||||||
import me.ShermansWorld.AlathraWar.War;
|
import me.ShermansWorld.AlathraWar.War;
|
||||||
import me.ShermansWorld.AlathraWar.data.WarData;
|
import me.ShermansWorld.AlathraWar.data.WarData;
|
||||||
import me.ShermansWorld.AlathraWar.hooks.TABHook;
|
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;
|
import org.bukkit.event.Listener;
|
||||||
|
import org.bukkit.event.player.PlayerJoinEvent;
|
||||||
|
|
||||||
public class JoinListener implements Listener {
|
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
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void checkPlayer(Player p) {
|
public static void checkPlayer(Player p) {
|
||||||
Town town = TownyAPI.getInstance().getResident(p).getTownOrNull();
|
Town town = TownyAPI.getInstance().getResident(p).getTownOrNull();
|
||||||
if (town == null) return;
|
if (town == null) return;
|
||||||
@@ -40,4 +31,10 @@ public class JoinListener implements Listener {
|
|||||||
TABHook.resetPrefix(p);
|
TABHook.resetPrefix(p);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@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
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -21,8 +21,7 @@ import org.bukkit.event.player.PlayerRespawnEvent;
|
|||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
public final class KillsListener implements Listener
|
public final class KillsListener implements Listener {
|
||||||
{
|
|
||||||
|
|
||||||
public static final HashMap<UUID, Raid> respawnqueue = new HashMap<>();
|
public static final HashMap<UUID, Raid> respawnqueue = new HashMap<>();
|
||||||
|
|
||||||
@@ -34,8 +33,7 @@ public final class KillsListener implements Listener
|
|||||||
Town town = null;
|
Town town = null;
|
||||||
try {
|
try {
|
||||||
town = WorldCoord.parseWorldCoord(killed).getTownBlock().getTown();
|
town = WorldCoord.parseWorldCoord(killed).getTownBlock().getTown();
|
||||||
}
|
} catch (NotRegisteredException ex2) {
|
||||||
catch (NotRegisteredException ex2) {
|
|
||||||
ex2.printStackTrace();
|
ex2.printStackTrace();
|
||||||
}
|
}
|
||||||
boolean playerCloseToHomeBlockSiege = false;
|
boolean playerCloseToHomeBlockSiege = false;
|
||||||
@@ -110,18 +108,18 @@ public final class KillsListener implements Listener
|
|||||||
for (final String playerName : siege.getAttackerPlayers()) {
|
for (final String playerName : siege.getAttackerPlayers()) {
|
||||||
try {
|
try {
|
||||||
Player p = Bukkit.getPlayer(playerName);
|
Player p = Bukkit.getPlayer(playerName);
|
||||||
if (p != null) p.sendMessage(String.valueOf(Helper.chatLabel()) + "Defender killed! + 20 Attacker Points");
|
if (p != null)
|
||||||
}
|
p.sendMessage(Helper.chatLabel() + "Defender killed! + 20 Attacker Points");
|
||||||
catch (NullPointerException ignored) {
|
} catch (NullPointerException ignored) {
|
||||||
ignored.printStackTrace();
|
ignored.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (final String playerName : siege.getDefenderPlayers()) {
|
for (final String playerName : siege.getDefenderPlayers()) {
|
||||||
try {
|
try {
|
||||||
Player p = Bukkit.getPlayer(playerName);
|
Player p = Bukkit.getPlayer(playerName);
|
||||||
if (p != null) p.sendMessage(String.valueOf(Helper.chatLabel()) + "Defender killed! + 20 Attacker Points");
|
if (p != null)
|
||||||
}
|
p.sendMessage(Helper.chatLabel() + "Defender killed! + 20 Attacker Points");
|
||||||
catch (NullPointerException ignored) {
|
} catch (NullPointerException ignored) {
|
||||||
ignored.printStackTrace();
|
ignored.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -135,18 +133,18 @@ public final class KillsListener implements Listener
|
|||||||
for (final String playerName : siege.getAttackerPlayers()) {
|
for (final String playerName : siege.getAttackerPlayers()) {
|
||||||
try {
|
try {
|
||||||
Player p = Bukkit.getPlayer(playerName);
|
Player p = Bukkit.getPlayer(playerName);
|
||||||
if (p != null) p.sendMessage(String.valueOf(Helper.chatLabel()) + "Attacker killed! + 20 Defender Points");
|
if (p != null)
|
||||||
}
|
p.sendMessage(Helper.chatLabel() + "Attacker killed! + 20 Defender Points");
|
||||||
catch (NullPointerException ex3) {
|
} catch (NullPointerException ex3) {
|
||||||
ex3.printStackTrace();
|
ex3.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (final String playerName : siege.getDefenderPlayers()) {
|
for (final String playerName : siege.getDefenderPlayers()) {
|
||||||
try {
|
try {
|
||||||
Player p = Bukkit.getPlayer(playerName);
|
Player p = Bukkit.getPlayer(playerName);
|
||||||
if (p != null) p.sendMessage(String.valueOf(Helper.chatLabel()) + "Attacker killed! + 20 Defender Points");
|
if (p != null)
|
||||||
}
|
p.sendMessage(Helper.chatLabel() + "Attacker killed! + 20 Defender Points");
|
||||||
catch (NullPointerException ex4) {
|
} catch (NullPointerException ex4) {
|
||||||
ex4.printStackTrace();
|
ex4.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -159,8 +157,7 @@ public final class KillsListener implements Listener
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
} catch (NullPointerException | TownyException ignored) {
|
||||||
catch (NullPointerException | TownyException ignored) {
|
|
||||||
ignored.printStackTrace();
|
ignored.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -179,7 +176,7 @@ public final class KillsListener implements Listener
|
|||||||
//do raider respawn
|
//do raider respawn
|
||||||
try {
|
try {
|
||||||
event.setRespawnLocation(raid.getGatherTown().getSpawn());
|
event.setRespawnLocation(raid.getGatherTown().getSpawn());
|
||||||
event.getPlayer().sendMessage(String.valueOf(Helper.chatLabel()) + "You died " + (raid.getPhase().equals(RaidPhase.COMBAT) ? "raiding" : "before combat") + " and have been teleported back to the gather point.");
|
event.getPlayer().sendMessage(Helper.chatLabel() + "You died " + (raid.getPhase().equals(RaidPhase.COMBAT) ? "raiding" : "before combat") + " and have been teleported back to the gather point.");
|
||||||
} catch (TownyException e) {
|
} catch (TownyException e) {
|
||||||
throw new RuntimeException(e);
|
throw new RuntimeException(e);
|
||||||
}
|
}
|
||||||
@@ -196,6 +193,7 @@ public final class KillsListener implements Listener
|
|||||||
/**
|
/**
|
||||||
* Damage all gear held by the player (and then send them to spawn?)
|
* Damage all gear held by the player (and then send them to spawn?)
|
||||||
* They don't lose items from death.
|
* They don't lose items from death.
|
||||||
|
*
|
||||||
* @param killed killed player
|
* @param killed killed player
|
||||||
* @param event event
|
* @param event event
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -32,7 +32,7 @@ import java.util.Set;
|
|||||||
public class PlayerInteractListener implements Listener {
|
public class PlayerInteractListener implements Listener {
|
||||||
|
|
||||||
//predefined foor materials
|
//predefined foor materials
|
||||||
private static Set<Material> doors = new HashSet<Material>();
|
private static final Set<Material> doors = new HashSet<>();
|
||||||
|
|
||||||
static {
|
static {
|
||||||
doors.add(Material.ACACIA_DOOR);
|
doors.add(Material.ACACIA_DOOR);
|
||||||
@@ -48,7 +48,7 @@ public class PlayerInteractListener implements Listener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
//map of broken doors
|
//map of broken doors
|
||||||
public Map<Location, Long> brokenDoors = new HashMap<Location, Long>();
|
public Map<Location, Long> brokenDoors = new HashMap<>();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param event event
|
* @param event event
|
||||||
@@ -106,17 +106,17 @@ public class PlayerInteractListener implements Listener {
|
|||||||
door.setOpen(!door.isOpen());
|
door.setOpen(!door.isOpen());
|
||||||
clicked.setBlockData(door);
|
clicked.setBlockData(door);
|
||||||
player.getInventory().getItemInMainHand().setAmount(player.getInventory().getItemInMainHand().getAmount() - 1);
|
player.getInventory().getItemInMainHand().setAmount(player.getInventory().getItemInMainHand().getAmount() - 1);
|
||||||
Main.warLogger.log("User " + player.getName() + " has broken down door" + clicked.getLocation().toString());
|
Main.warLogger.log("User " + player.getName() + " has broken down door" + clicked.getLocation());
|
||||||
} else {
|
} else {
|
||||||
player.sendMessage(Helper.chatLabel() + Helper.color("&cThis item can only be used in a siege or raid!"));
|
player.sendMessage(Helper.chatLabel() + Helper.color("&cThis item can only be used in a siege or raid!"));
|
||||||
}
|
}
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.HIGHEST)
|
@EventHandler(priority = EventPriority.HIGHEST)
|
||||||
public void onPlayerRClick(final PlayerItemDamageEvent event) {
|
public void onPlayerRClick(final PlayerItemDamageEvent event) {
|
||||||
ItemStack item = event.getItem();
|
ItemStack item = event.getItem();
|
||||||
@@ -158,7 +158,6 @@ public class PlayerInteractListener implements Listener {
|
|||||||
|| clicked.getType().name().equals("ROOTED_DIRT")
|
|| clicked.getType().name().equals("ROOTED_DIRT")
|
||||||
|| clicked.getType().name().equals("DIRT_PATH")) {
|
|| clicked.getType().name().equals("DIRT_PATH")) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in new issue
Block a user