mirror of
https://github.com/darksaid98/AlathranWars.git
synced 2026-12-02 06:28:52 +00:00
Merge pull request #20 from Alathra/feature/battering-ram
Feature/battering-ram
This commit is contained in:
26 files changed
+972
-325
No files matched your search
@@ -1,2 +1,8 @@
|
||||
#Minimum time in days a player must have joined ago to join any war or event.
|
||||
minimumPlayerAge: 4
|
||||
#Set to 0 to disable check
|
||||
minimumPlayerAge: 4
|
||||
#Minimum playtime in hours a player must have in hours to join a war/siege/raid
|
||||
#Set to 0 to disable check
|
||||
minimumPlayTime: 12
|
||||
#How long should a bettering ram open a door (in seconds)
|
||||
batteringRamEffectiveness: 10
|
||||
@@ -57,6 +57,12 @@ public class Helper
|
||||
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);
|
||||
}
|
||||
|
||||
@@ -1,15 +1,13 @@
|
||||
package me.ShermansWorld.AlathraWar;
|
||||
|
||||
import me.ShermansWorld.AlathraWar.commands.*;
|
||||
import me.ShermansWorld.AlathraWar.listeners.CommandsListener;
|
||||
import org.bukkit.event.Listener;
|
||||
import me.ShermansWorld.AlathraWar.items.WarItemRegistry;
|
||||
import me.ShermansWorld.AlathraWar.items.WarRecipeRegistry;
|
||||
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.hooks.TABHook;
|
||||
import me.ShermansWorld.AlathraWar.listeners.BlockBreakListener;
|
||||
import me.ShermansWorld.AlathraWar.listeners.JoinListener;
|
||||
import me.ShermansWorld.AlathraWar.listeners.KillsListener;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
@@ -27,7 +25,10 @@ public class Main extends JavaPlugin {
|
||||
econ = null;
|
||||
}
|
||||
|
||||
private static void initData() {
|
||||
/**
|
||||
* Dangerous if done at the wrong time!
|
||||
*/
|
||||
public static void initData() {
|
||||
File userDataFolder = new File("plugins" + File.separator + "AlathraWar" + File.separator + "userdata");
|
||||
if (!userDataFolder.exists()) {
|
||||
userDataFolder.mkdirs();
|
||||
@@ -78,6 +79,7 @@ public class Main extends JavaPlugin {
|
||||
|
||||
public void onEnable() {
|
||||
instance = this;
|
||||
this.saveDefaultConfig();
|
||||
initLogs();
|
||||
|
||||
new WarData(this);
|
||||
@@ -90,10 +92,17 @@ public class Main extends JavaPlugin {
|
||||
getCommand("siege").setTabCompleter(new SiegeTabCompletion());
|
||||
getCommand("raid").setTabCompleter(new RaidTabCompletion());
|
||||
getCommand("alathrawaradmin").setTabCompleter(new AdminTabCompletion());
|
||||
getServer().getPluginManager().registerEvents((Listener) new KillsListener(), (Plugin) this);
|
||||
getServer().getPluginManager().registerEvents((Listener) new CommandsListener(), (Plugin) this);
|
||||
getServer().getPluginManager().registerEvents((Listener) new JoinListener(), (Plugin) this);
|
||||
getServer().getPluginManager().registerEvents((Listener) new BlockBreakListener(), (Plugin) this);
|
||||
getServer().getPluginManager().registerEvents(new KillsListener(), (Plugin) this);
|
||||
getServer().getPluginManager().registerEvents(new CommandsListener(), (Plugin) this);
|
||||
getServer().getPluginManager().registerEvents(new JoinListener(), (Plugin) this);
|
||||
getServer().getPluginManager().registerEvents(new BlockBreakListener(), (Plugin) this);
|
||||
getServer().getPluginManager().registerEvents(new PlayerInteractListener(), this);
|
||||
|
||||
// //run first
|
||||
new WarItemRegistry();
|
||||
// //run second
|
||||
// new WarRecipeRegistry();
|
||||
|
||||
initData();
|
||||
initAPIs();
|
||||
setupEconomy();
|
||||
|
||||
@@ -254,6 +254,7 @@ public class Raid {
|
||||
public void stop() {
|
||||
deleteDisplayBar();
|
||||
Bukkit.getScheduler().cancelTask(this.bukkitId[0]);
|
||||
this.getWar().getRaids().remove(this);
|
||||
RaidData.removeRaid(this);
|
||||
}
|
||||
|
||||
@@ -520,9 +521,9 @@ public class Raid {
|
||||
}
|
||||
|
||||
Bukkit.broadcastMessage("The town of " + this.raidedTown.getName() + " has been " + statement + " by " + this.getRaiderSide()
|
||||
+ " in a raid for $" + amt);
|
||||
+ " in a raid for " + String.format("$%.2f", amt));
|
||||
Main.warLogger.log("The town of " + this.raidedTown.getName() + " has been " + statement + " by " + this.getRaiderSide()
|
||||
+ " in a raid for $" + amt);
|
||||
+ " in a raid for " + String.format("$%.2f", amt));
|
||||
Main.econ.depositPlayer(offlinePlayer, amt);
|
||||
|
||||
if (this.side1AreRaiders) {
|
||||
|
||||
@@ -87,6 +87,7 @@ public class Siege {
|
||||
public void stop() {
|
||||
deleteDisplayBar();
|
||||
Bukkit.getScheduler().cancelTask(this.bukkitId[0]);
|
||||
this.war.getSieges().remove(this);
|
||||
SiegeData.removeSiege(this);
|
||||
|
||||
}
|
||||
|
||||
@@ -69,13 +69,13 @@ public class War {
|
||||
*/
|
||||
public void addTown(final String town, String side) {
|
||||
if (side1.equalsIgnoreCase(side)) {
|
||||
if (!side1Towns.contains(town)) {
|
||||
if (!side1Towns.contains(town.toLowerCase())) {
|
||||
side1Towns.add(town.toLowerCase());
|
||||
Main.warLogger.log("Town "+ town + " joined " + this.name + " on " + side);
|
||||
return;
|
||||
}
|
||||
} else if(side2.equalsIgnoreCase(side)) {
|
||||
if (!side2Towns.contains(town)) {
|
||||
if (!side2Towns.contains(town.toLowerCase())) {
|
||||
side2Towns.add(town.toLowerCase());
|
||||
Main.warLogger.log("Town "+ town + " joined " + this.name + " on " + side);
|
||||
return;
|
||||
@@ -130,8 +130,8 @@ public class War {
|
||||
* 0 - None
|
||||
* 1 - Side 1
|
||||
* 2 - Side 2
|
||||
* @param string
|
||||
* @return
|
||||
* @param string town
|
||||
* @return result
|
||||
*/
|
||||
public int getSide(String string) {
|
||||
for (String str : surrenderedTowns) {
|
||||
@@ -245,8 +245,8 @@ public class War {
|
||||
Town town = TownyAPI.getInstance().getTown(townString);
|
||||
if (town != null) {
|
||||
for (Resident res : town.getResidents()) {
|
||||
//Minuteman countermeasure!
|
||||
if (System.currentTimeMillis() - CommandHelper.getPlayerJoinDate(res.getName()) > 86400000L * Main.getInstance().getConfig().getInt("minimumPlayerAge") ) {
|
||||
//Minuteman countermeasure! if they are they get skipped
|
||||
if (CommandHelper.isPlayerMinuteman(res.getName()) == 0) {
|
||||
returnList.add(res.getName());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,16 +12,15 @@ import me.ShermansWorld.AlathraWar.data.RaidData;
|
||||
import me.ShermansWorld.AlathraWar.data.RaidPhase;
|
||||
import me.ShermansWorld.AlathraWar.data.SiegeData;
|
||||
import me.ShermansWorld.AlathraWar.data.WarData;
|
||||
import me.ShermansWorld.AlathraWar.items.WarItemRegistry;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.NamespacedKey;
|
||||
import org.bukkit.boss.BossBar;
|
||||
import org.bukkit.boss.KeyedBossBar;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Boss;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import java.sql.Timestamp;
|
||||
import java.util.ArrayList;
|
||||
@@ -111,6 +110,7 @@ public class AdminCommands implements CommandExecutor {
|
||||
*/
|
||||
@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");
|
||||
}
|
||||
@@ -140,11 +140,71 @@ public class AdminCommands implements CommandExecutor {
|
||||
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) {
|
||||
if(args.length >= 2) {
|
||||
//find item
|
||||
ItemStack stack = null;
|
||||
if(args[1].contains(Main.getInstance().getName().toLowerCase())) {
|
||||
stack = WarItemRegistry.getInstance().getOrNullNamespace(args[1]);
|
||||
} else {
|
||||
stack = WarItemRegistry.getInstance().getOrNull(args[1]);
|
||||
}
|
||||
// item not real!
|
||||
if(stack == null) {
|
||||
sender.sendMessage(Helper.chatLabel() + Helper.color("&cNot an AlathraWar item."));
|
||||
return true;
|
||||
}
|
||||
|
||||
//amount parameter
|
||||
int amt = stack.getAmount();
|
||||
if(args.length >= 3) {
|
||||
try {
|
||||
amt = Integer.parseInt(args[2]);
|
||||
} catch (NumberFormatException ex) {
|
||||
sender.sendMessage(Helper.chatLabel() + Helper.color("&cNot a number!"));
|
||||
return true;
|
||||
}
|
||||
}
|
||||
stack.setAmount(amt);
|
||||
|
||||
//determine who gets the item
|
||||
Player reciever = null;
|
||||
if(args.length >= 4) {
|
||||
reciever = Bukkit.getPlayer(args[3]);
|
||||
} else {
|
||||
//console cant get item
|
||||
if (!(sender instanceof Player)) {
|
||||
sender.sendMessage(Helper.chatLabel() + Helper.color("&cNo, you don't have arms. Define a player."));
|
||||
return true;
|
||||
}
|
||||
reciever = (Player) sender;
|
||||
}
|
||||
|
||||
// player is invilid
|
||||
if (reciever == null) {
|
||||
sender.sendMessage(Helper.chatLabel() + Helper.color("&cPlayer not found!"));
|
||||
return true;
|
||||
}
|
||||
|
||||
//give
|
||||
reciever.getInventory().addItem(stack);
|
||||
|
||||
String name = stack.getItemMeta() == null ? stack.toString() : stack.getItemMeta().getDisplayName();
|
||||
//log
|
||||
sender.sendMessage(Helper.chatLabel() + Helper.color("Gave " + stack.getAmount() + "x " + name + " to " + reciever.getName()));
|
||||
Main.warLogger.log(Helper.chatLabel() + Helper.color("Gave " + stack.getAmount() + "x " + name + " to " + reciever.getName()));
|
||||
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private static boolean purgebars(CommandSender sender, String[] args) {
|
||||
for (Iterator<KeyedBossBar> it = Bukkit.getBossBars(); it.hasNext(); ) {
|
||||
KeyedBossBar b = it.next();
|
||||
@@ -162,26 +222,82 @@ public class AdminCommands implements CommandExecutor {
|
||||
}
|
||||
|
||||
private static boolean save(CommandSender sender, String[] args) {
|
||||
//TODO save
|
||||
sender.sendMessage(Helper.chatLabel() + Helper.color("&csave Unimplemented!"));
|
||||
if(args.length >= 2) {
|
||||
for (War w : WarData.getWars()) {
|
||||
if(w.getName().equalsIgnoreCase(args[2])) {
|
||||
WarData.saveWar(w);
|
||||
sender.sendMessage(Helper.chatLabel() + Helper.color("&cForced Save of war: " + w.getName()));
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
sender.sendMessage(Helper.chatLabel() + Helper.color("&cWar does not exist!"));
|
||||
return true;
|
||||
}
|
||||
|
||||
private static boolean saveAll(CommandSender sender, String[] args) {
|
||||
//TODO save-all
|
||||
sender.sendMessage(Helper.chatLabel() + Helper.color("&csave-all Unimplemented!"));
|
||||
for (War w : WarData.getWars()) WarData.saveWar(w);
|
||||
sender.sendMessage(Helper.chatLabel() + Helper.color("&cForced Save of all wars"));
|
||||
return true;
|
||||
}
|
||||
|
||||
private static boolean load(CommandSender sender, String[] args) {
|
||||
//TODO load
|
||||
sender.sendMessage(Helper.chatLabel() + Helper.color("&cload Unimplemented!"));
|
||||
// if (args.length >= 3) {
|
||||
// if(Boolean.parseBoolean(args[2])) {
|
||||
// for (War w : WarData.getWars()) {
|
||||
// int index = -1;
|
||||
// if(w.getName().equalsIgnoreCase(args[1])) {
|
||||
// //kill raids
|
||||
// for (Raid raid : w.getRaids()) {
|
||||
// raid.stop();
|
||||
// }
|
||||
// //kill sieges
|
||||
// for (Siege siege : w.getSieges()) {
|
||||
// siege.stop();
|
||||
// }
|
||||
// //delete wars
|
||||
// index = WarData.getWars().lastIndexOf(w);
|
||||
// WarData.getWars().remove(w);
|
||||
// }
|
||||
// if(index < 0) {
|
||||
// sender.sendMessage(Helper.chatLabel() + Helper.color("&cError! Failed to delete war, forcing end."));
|
||||
// return true;
|
||||
// }
|
||||
// //reload data
|
||||
// ;
|
||||
// sender.sendMessage(Helper.chatLabel() + Helper.color("&cForcefully Reloaded all Wars!"));
|
||||
// return true;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
sender.sendMessage(Helper.chatLabel() + Helper.color("&cSupport for loading wars individually is currently unimplemented. Use /awa load-all instead"));
|
||||
return true;
|
||||
}
|
||||
|
||||
private static boolean loadAll(CommandSender sender, String[] args) {
|
||||
//TODO load-all
|
||||
sender.sendMessage(Helper.chatLabel() + Helper.color("&cload-all Unimplemented!"));
|
||||
if (args.length >= 2) {
|
||||
if(Boolean.parseBoolean(args[1])) {
|
||||
for (War w : WarData.getWars()) {
|
||||
//kill raids
|
||||
for (Raid raid : w.getRaids()) {
|
||||
raid.stop();
|
||||
}
|
||||
//kill sieges
|
||||
for (Siege siege : w.getSieges()) {
|
||||
siege.stop();
|
||||
}
|
||||
//delete wars
|
||||
WarData.getWars().remove(w);
|
||||
}
|
||||
//reload data
|
||||
Main.initData();
|
||||
sender.sendMessage(Helper.chatLabel() + Helper.color("&cForcefully Reloaded all Wars!"));
|
||||
return true;
|
||||
}
|
||||
}
|
||||
sender.sendMessage(Helper.chatLabel() + Helper.color("Are you sure you want to do this?"));
|
||||
sender.sendMessage(Helper.chatLabel() + Helper.color("Doing this will forcefully stop and reload every war live. It can be very dangerous and may not work as intended."));
|
||||
sender.sendMessage(Helper.chatLabel() + Helper.color("To confirm do /awa load-all true"));
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -203,25 +319,24 @@ public class AdminCommands implements CommandExecutor {
|
||||
return true;
|
||||
} else {
|
||||
//defaultCode will bypass the custom gather town to force set owner
|
||||
p.sendMessage(Helper.color("&cUsage: /alathrawaradmin create raid [war] [raidTown] (gatherTown/\"defaultCode\") (owner)"));
|
||||
p.sendMessage(Helper.color("&cUsage: /alathrawaradmin create raid [war] [raidTown] (gatherTown/\"defaultCode\") (owner) (override)"));
|
||||
return true;
|
||||
}
|
||||
} else if (args[1].equalsIgnoreCase("siege")) {
|
||||
//this exists to force a seige with a new owner
|
||||
if (args.length >= 4) {
|
||||
String[] adjusted = new String[]{
|
||||
"start",
|
||||
args[2],
|
||||
args[3],
|
||||
args[4],
|
||||
args[5]
|
||||
};
|
||||
SiegeCommands.siegeStart(p, adjusted, true);
|
||||
List<String> l = new ArrayList<>();
|
||||
l.add("start");
|
||||
l.add(args[2]);
|
||||
l.add(args[3]);
|
||||
if(args.length >= 5) l.add(args[4]);
|
||||
if(args.length >= 6) l.add(args[5]);
|
||||
SiegeCommands.siegeStart(p, l.toArray(new String[]{}), true);
|
||||
// p.sendMessage(Helper.Chatlabel() + "Try again later!");
|
||||
p.sendMessage(Helper.color("&cForcefully started siege from the console."));
|
||||
return true;
|
||||
} else {
|
||||
p.sendMessage(Helper.color("&cUsage: /alathrawaradmin create siege [war] [town] (owner)"));
|
||||
p.sendMessage(Helper.color("&cUsage: /alathrawaradmin create siege [war] [town] (owner) (force)"));
|
||||
return true;
|
||||
}
|
||||
} else if (args[1].equalsIgnoreCase("war")) {
|
||||
@@ -271,14 +386,14 @@ public class AdminCommands implements CommandExecutor {
|
||||
if (args[2].equalsIgnoreCase("raid")) {
|
||||
for (Raid r : RaidData.getRaids()) {
|
||||
if (args.length >= 6) {
|
||||
if (r.getWar().getName().equals(args[3]) && r.getRaidedTown().getName().equals(args[4])) {
|
||||
if (r.getWar().getName().equalsIgnoreCase(args[3]) && r.getRaidedTown().getName().equals(args[4])) {
|
||||
if (r.getSide1AreRaiders()) {
|
||||
if (args[5].equals(r.getWar().getSide1())) {
|
||||
if (args[5].equalsIgnoreCase(r.getWar().getSide1())) {
|
||||
r.raidersWin(r.getOwner(), r.getRaiderScore(), r.getDefenderScore());
|
||||
p.sendMessage(Helper.chatLabel() + "Raid forcefully ended on " + args[4] + " in war " + args[3] + " with " + args[5] + " (raiders) declared as victor.");
|
||||
Main.warLogger.log("Raid forcefully ended on " + args[4] + " in war " + args[3] + " with " + args[5] + " (raiders) declared as victor.");
|
||||
return true;
|
||||
} else if (args[5].equals(r.getWar().getSide2())) {
|
||||
} else if (args[5].equalsIgnoreCase(r.getWar().getSide2())) {
|
||||
r.defendersWin(r.getRaiderScore(), r.getDefenderScore());
|
||||
p.sendMessage(Helper.chatLabel() + "Raid forcefully ended on " + args[4] + " in war " + args[3] + " with " + args[5] + " (defenders) declared as victor.");
|
||||
Main.warLogger.log("Raid forcefully ended on " + args[4] + " in war " + args[3] + " with " + args[5] + " (defenders) declared as victor.");
|
||||
@@ -288,12 +403,12 @@ public class AdminCommands implements CommandExecutor {
|
||||
return true;
|
||||
}
|
||||
} else {
|
||||
if (args[5].equals(r.getWar().getSide1())) {
|
||||
if (args[5].equalsIgnoreCase(r.getWar().getSide1())) {
|
||||
r.defendersWin(r.getRaiderScore(), r.getDefenderScore());
|
||||
p.sendMessage(Helper.chatLabel() + "Raid forcefully ended on " + args[4] + " in war " + args[3] + " with " + args[5] + " (defenders) declared as victor.");
|
||||
Main.warLogger.log("Raid forcefully ended on " + args[4] + " in war " + args[3] + " with " + args[5] + " (defenders) declared as victor.");
|
||||
return true;
|
||||
} else if (args[5].equals(r.getWar().getSide2())) {
|
||||
} else if (args[5].equalsIgnoreCase(r.getWar().getSide2())) {
|
||||
r.raidersWin(r.getOwner(), r.getRaiderScore(), r.getDefenderScore());
|
||||
p.sendMessage(Helper.chatLabel() + "Raid forcefully ended on " + args[4] + " in war " + args[3] + " with " + args[5] + " (raiders) declared as victor.");
|
||||
Main.warLogger.log("Raid forcefully ended on " + args[4] + " in war " + args[3] + " with " + args[5] + " (raiders) declared as victor.");
|
||||
@@ -305,7 +420,7 @@ public class AdminCommands implements CommandExecutor {
|
||||
}
|
||||
}
|
||||
} else if (args.length == 5) {
|
||||
if (r.getWar().getName().equals(args[3]) && r.getRaidedTown().getName().equals(args[4])) {
|
||||
if (r.getWar().getName().equalsIgnoreCase(args[3]) && r.getRaidedTown().getName().equalsIgnoreCase(args[4])) {
|
||||
r.noWinner();
|
||||
p.sendMessage(Helper.chatLabel() + "Raid forcefully ended on " + args[4] + " in war " + args[3] + " with no victor.");
|
||||
Main.warLogger.log("Raid forcefully ended on " + args[4] + " in war " + args[3] + " with no victor.");
|
||||
@@ -322,14 +437,14 @@ public class AdminCommands implements CommandExecutor {
|
||||
} else if (args[2].equalsIgnoreCase("siege")) {
|
||||
for (Siege s : SiegeData.getSieges()) {
|
||||
if (args.length >= 6) {
|
||||
if (s.getWar().getName().equals(args[3]) && s.getTown().getName().equals(args[4])) {
|
||||
if (s.getWar().getName().equalsIgnoreCase(args[3]) && s.getTown().getName().equalsIgnoreCase(args[4])) {
|
||||
if (s.getSide1AreAttackers()) {
|
||||
if (args[5].equals(s.getWar().getSide1())) {
|
||||
if (args[5].equalsIgnoreCase(s.getWar().getSide1())) {
|
||||
s.attackersWin(s.getSiegeOwner());
|
||||
p.sendMessage(Helper.chatLabel() + "Siege forcefully ended on " + args[4] + " in war " + args[3] + " with " + args[6] + " (attackers) declared as victor.");
|
||||
Main.warLogger.log("Siege forcefully ended on " + args[4] + " in war " + args[3] + " with " + args[6] + " (attackers) declared as victor.");
|
||||
return true;
|
||||
} else if (args[5].equals(s.getWar().getSide2())) {
|
||||
} else if (args[5].equalsIgnoreCase(s.getWar().getSide2())) {
|
||||
s.defendersWin();
|
||||
p.sendMessage(Helper.chatLabel() + "Siege forcefully ended on " + args[4] + " in war " + args[3] + " with " + args[6] + " (defenders) declared as victor.");
|
||||
Main.warLogger.log("Siege forcefully ended on " + args[4] + " in war " + args[3] + " with " + args[6] + " (defenders) declared as victor.");
|
||||
@@ -339,12 +454,12 @@ public class AdminCommands implements CommandExecutor {
|
||||
return true;
|
||||
}
|
||||
} else {
|
||||
if (args[5].equals(s.getWar().getSide1())) {
|
||||
if (args[5].equalsIgnoreCase(s.getWar().getSide1())) {
|
||||
s.defendersWin();
|
||||
p.sendMessage(Helper.chatLabel() + "Siege forcefully ended on " + args[4] + " in war " + args[3] + " with " + args[6] + " (defenders) declared as victor.");
|
||||
Main.warLogger.log("Siege forcefully ended on " + args[4] + " in war " + args[3] + " with " + args[6] + " (defenders) declared as victor.");
|
||||
return true;
|
||||
} else if (args[5].equals(s.getWar().getSide2())) {
|
||||
} else if (args[5].equalsIgnoreCase(s.getWar().getSide2())) {
|
||||
s.attackersWin(s.getSiegeOwner());
|
||||
p.sendMessage(Helper.chatLabel() + "Siege forcefully ended on " + args[4] + " in war " + args[3] + " with " + args[6] + " (attackers) declared as victor.");
|
||||
Main.warLogger.log("Siege forcefully ended on " + args[4] + " in war " + args[3] + " with " + args[6] + " (attackers) declared as victor.");
|
||||
@@ -356,7 +471,7 @@ public class AdminCommands implements CommandExecutor {
|
||||
}
|
||||
}
|
||||
} else if (args.length == 5) {
|
||||
if (s.getWar().getName().equals(args[3]) && s.getTown().getName().equals(args[4])) {
|
||||
if (s.getWar().getName().equalsIgnoreCase(args[3]) && s.getTown().getName().equalsIgnoreCase(args[4])) {
|
||||
s.noWinner();
|
||||
p.sendMessage(Helper.chatLabel() + "Siege forcefully ended on " + args[4] + " in war " + args[3] + " with no victor.");
|
||||
Main.warLogger.log("Siege forcefully ended on " + args[4] + " in war " + args[3] + " with no victor.");
|
||||
@@ -444,7 +559,7 @@ public class AdminCommands implements CommandExecutor {
|
||||
if (args[2].equalsIgnoreCase("raid")) {
|
||||
if (args.length >= 6) {
|
||||
for (Raid r : RaidData.getRaids()) {
|
||||
if (r.getWar().getName().equals(args[3]) && r.getRaidedTown().getName().equals(args[4])) {
|
||||
if (r.getWar().getName().equalsIgnoreCase(args[3]) && r.getRaidedTown().getName().equalsIgnoreCase(args[4])) {
|
||||
if (Bukkit.getPlayer(args[5]) != null) {
|
||||
String[] fixed = new String[]{
|
||||
args[1],
|
||||
@@ -464,7 +579,7 @@ public class AdminCommands implements CommandExecutor {
|
||||
}
|
||||
p.sendMessage(Helper.color("&cRaid not found!"));
|
||||
} else {
|
||||
p.sendMessage(Helper.color("&cUsage: /alathrawaradmin force leave raid [war] [town] [player] (timeout)"));
|
||||
p.sendMessage(Helper.color("&cUsage: /alathrawaradmin force leave raid [war] [town] [player]"));
|
||||
}
|
||||
return true;
|
||||
} else if (args[2].equalsIgnoreCase("siege")) {
|
||||
@@ -497,10 +612,10 @@ public class AdminCommands implements CommandExecutor {
|
||||
p.sendMessage(Helper.chatLabel() + "/alathrawaradmin info");
|
||||
p.sendMessage(Helper.chatLabel() + "/alathrawaradmin modify");
|
||||
p.sendMessage(Helper.chatLabel() + "/alathrawaradmin purgebars");
|
||||
// p.sendMessage(Helper.chatLabel() + "/alathrawaradmin save");
|
||||
// p.sendMessage(Helper.chatLabel() + "/alathrawaradmin save-all");
|
||||
// p.sendMessage(Helper.chatLabel() + "/alathrawaradmin load");
|
||||
// p.sendMessage(Helper.chatLabel() + "/alathrawaradmin load-all");
|
||||
p.sendMessage(Helper.chatLabel() + "/alathrawaradmin save");
|
||||
p.sendMessage(Helper.chatLabel() + "/alathrawaradmin save-all");
|
||||
p.sendMessage(Helper.chatLabel() + "/alathrawaradmin load-all");
|
||||
p.sendMessage(Helper.chatLabel() + "/alathrawaradmin item");
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -521,7 +636,7 @@ public class AdminCommands implements CommandExecutor {
|
||||
if (args[1].equalsIgnoreCase("war")) {
|
||||
if (args.length >= 3) {
|
||||
for (War w : WarData.getWars()) {
|
||||
if (w.getName().equals(args[2])) {
|
||||
if (w.getName().equalsIgnoreCase(args[2])) {
|
||||
p.sendMessage(Helper.chatLabel() + "Info dump for war: " + w.getName());
|
||||
p.sendMessage(Helper.chatLabel() + "oOo------------===------------oOo");
|
||||
p.sendMessage(Helper.chatLabel() + "Name: " + w.getName());
|
||||
@@ -585,7 +700,7 @@ public class AdminCommands implements CommandExecutor {
|
||||
} else if (args[1].equalsIgnoreCase("raid")) {
|
||||
if (args.length >= 4) {
|
||||
for (Raid r : RaidData.getRaids()) {
|
||||
if (r.getWar().getName().equals(args[2]) && r.getRaidedTown().getName().equals(args[3])) {
|
||||
if (r.getWar().getName().equalsIgnoreCase(args[2]) && r.getRaidedTown().getName().equalsIgnoreCase(args[3])) {
|
||||
p.sendMessage(Helper.chatLabel() + "Info dump for raid: " + r.getName());
|
||||
p.sendMessage(Helper.chatLabel() + "oOo------------===------------oOo");
|
||||
p.sendMessage(Helper.chatLabel() + "Name: " + r.getName());
|
||||
@@ -632,7 +747,7 @@ public class AdminCommands implements CommandExecutor {
|
||||
} else if (args[1].equalsIgnoreCase("siege")) {
|
||||
if (args.length >= 4) {
|
||||
for (Siege s : SiegeData.getSieges()) {
|
||||
if (s.getWar().getName().equals(args[2]) && s.getTown().getName().equals(args[3])) {
|
||||
if (s.getWar().getName().equalsIgnoreCase(args[2]) && s.getTown().getName().equalsIgnoreCase(args[3])) {
|
||||
p.sendMessage(Helper.chatLabel() + "Info dump for siege: " + s.getName());
|
||||
p.sendMessage(Helper.chatLabel() + "oOo------------===------------oOo");
|
||||
p.sendMessage(Helper.chatLabel() + "Name: " + s.getName());
|
||||
@@ -716,8 +831,8 @@ public class AdminCommands implements CommandExecutor {
|
||||
if (args[2].equalsIgnoreCase("score")) {
|
||||
if (args.length >= 8) {
|
||||
for (Raid r : RaidData.getRaids()) {
|
||||
if (r.getWar().getName().equals(args[3]) && r.getRaidedTown().getName().equals(args[4])) {
|
||||
if(args[6].equals(r.getWar().getSide1())) {
|
||||
if (r.getWar().getName().equalsIgnoreCase(args[3]) && r.getRaidedTown().getName().equalsIgnoreCase(args[4])) {
|
||||
if(args[6].equalsIgnoreCase(r.getWar().getSide1())) {
|
||||
if(r.getSide1AreRaiders()) {
|
||||
if (args[5].equalsIgnoreCase("add")) {
|
||||
r.addPointsToRaiderScore(Integer.parseInt(args[7]));
|
||||
@@ -759,7 +874,7 @@ public class AdminCommands implements CommandExecutor {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
} else if(args[6].equals(r.getWar().getSide2())) {
|
||||
} else if(args[6].equalsIgnoreCase(r.getWar().getSide2())) {
|
||||
if(!r.getSide1AreRaiders()) {
|
||||
if (args[5].equalsIgnoreCase("add")) {
|
||||
r.addPointsToRaiderScore(Integer.parseInt(args[7]));
|
||||
@@ -815,9 +930,9 @@ public class AdminCommands implements CommandExecutor {
|
||||
} else if (args[2].equalsIgnoreCase("townspawn")) {
|
||||
if (args.length >= 5) {
|
||||
for (Raid r : RaidData.getRaids()) {
|
||||
if (r.getWar().getName().equals(args[3]) && r.getRaidedTown().getName().equals(args[4])) {
|
||||
if (r.getWar().getName().equalsIgnoreCase(args[3]) && r.getRaidedTown().getName().equalsIgnoreCase(args[4])) {
|
||||
if (args.length == 6 || args.length == 7) {
|
||||
p.sendMessage(Helper.color("&cUsage: /alathrawaradmin modify raid townspawn [war] [town] (x) (Z)"));
|
||||
p.sendMessage(Helper.color("&cUsage: /alathrawaradmin modify raid townspawn [war] [town] (x) (y) (Z)"));
|
||||
return true;
|
||||
}
|
||||
Town t = r.getRaidedTown();
|
||||
@@ -887,13 +1002,13 @@ public class AdminCommands implements CommandExecutor {
|
||||
}
|
||||
p.sendMessage(Helper.chatLabel() + Helper.color("&cRaid cannot be found."));
|
||||
} else {
|
||||
p.sendMessage(Helper.color("&cUsage: /alathrawaradmin modify raid homeblock [war] [town] (x) (Z)"));
|
||||
p.sendMessage(Helper.color("&cUsage: /alathrawaradmin modify raid townspawn [war] [town] (x) (y) (Z)"));
|
||||
}
|
||||
return true;
|
||||
} else if (args[2].equalsIgnoreCase("gather")) {
|
||||
if (args.length >= 6) {
|
||||
for (Raid r : RaidData.getRaids()) {
|
||||
if (r.getWar().getName().equals(args[3]) && r.getRaidedTown().getName().equals(args[4])) {
|
||||
if (r.getWar().getName().equalsIgnoreCase(args[3]) && r.getRaidedTown().getName().equalsIgnoreCase(args[4])) {
|
||||
Town t = TownyAPI.getInstance().getTown(args[5]);
|
||||
if (t != null) {
|
||||
r.setRaidedTown(t);
|
||||
@@ -921,7 +1036,7 @@ public class AdminCommands implements CommandExecutor {
|
||||
} else if (args[2].equalsIgnoreCase("phase")) {
|
||||
if (args.length >= 6) {
|
||||
for (Raid r : RaidData.getRaids()) {
|
||||
if (r.getWar().getName().equals(args[3]) && r.getRaidedTown().getName().equals(args[4])) {
|
||||
if (r.getWar().getName().equalsIgnoreCase(args[3]) && r.getRaidedTown().getName().equalsIgnoreCase(args[4])) {
|
||||
//parse phase
|
||||
RaidPhase ph;
|
||||
if (args[5].equalsIgnoreCase("next")) {
|
||||
@@ -952,7 +1067,7 @@ public class AdminCommands implements CommandExecutor {
|
||||
} else if (args[2].equalsIgnoreCase("loot")) {
|
||||
if (args.length >= 5) {
|
||||
for (Raid r : RaidData.getRaids()) {
|
||||
if (r.getWar().getName().equals(args[3]) && r.getRaidedTown().getName().equals(args[4])) {
|
||||
if (r.getWar().getName().equalsIgnoreCase(args[3]) && r.getRaidedTown().getName().equalsIgnoreCase(args[4])) {
|
||||
//parse phase
|
||||
if(!(p instanceof Player runner)) {
|
||||
p.sendMessage(Helper.chatLabel() + "This command cannot be run through console!");
|
||||
@@ -1055,7 +1170,7 @@ public class AdminCommands implements CommandExecutor {
|
||||
} else if (args[2].equalsIgnoreCase("time")) {
|
||||
if (args.length >= 7) {
|
||||
for (Raid r : RaidData.getRaids()) {
|
||||
if (r.getWar().getName().equals(args[3]) && r.getRaidedTown().getName().equals(args[4])) {
|
||||
if (r.getWar().getName().equalsIgnoreCase(args[3]) && r.getRaidedTown().getName().equalsIgnoreCase(args[4])) {
|
||||
//parse phase
|
||||
if (args[5].equalsIgnoreCase("add")) {
|
||||
r.setRaidTicks(r.getRaidTicks() + Integer.parseInt(args[6]));
|
||||
@@ -1087,7 +1202,7 @@ public class AdminCommands implements CommandExecutor {
|
||||
} else if (args[2].equalsIgnoreCase("owner")) {
|
||||
if (args.length >= 6) {
|
||||
for (Raid r : RaidData.getRaids()) {
|
||||
if (r.getWar().getName().equals(args[3]) && r.getRaidedTown().getName().equals(args[4])) {
|
||||
if (r.getWar().getName().equalsIgnoreCase(args[3]) && r.getRaidedTown().getName().equalsIgnoreCase(args[4])) {
|
||||
Player own = Bukkit.getPlayer(args[5]);
|
||||
if (own != null) {
|
||||
if(r.getActiveRaiders().contains(own.getName())) {
|
||||
@@ -1131,9 +1246,9 @@ public class AdminCommands implements CommandExecutor {
|
||||
if (args[2].equalsIgnoreCase("score")) {
|
||||
if (args.length >= 8) {
|
||||
for (Siege s : SiegeData.getSieges()) {
|
||||
if (s.getWar().getName().equals(args[3]) && s.getTown().getName().equals(args[4])) {
|
||||
if (s.getWar().getName().equalsIgnoreCase(args[3]) && s.getTown().getName().equalsIgnoreCase(args[4])) {
|
||||
if (args[5].equalsIgnoreCase("add")) {
|
||||
if (s.getWar().getSide1().equals(args[6])) {
|
||||
if (s.getWar().getSide1().equalsIgnoreCase(args[6])) {
|
||||
if (s.getSide1AreAttackers()) {
|
||||
s.addPointsToAttackers(Integer.parseInt(args[7]));
|
||||
} else {
|
||||
@@ -1142,7 +1257,7 @@ public class AdminCommands implements CommandExecutor {
|
||||
p.sendMessage(Helper.chatLabel() + "Added " + args[7] + " points to side " + args[6] + " in sige on " + args[4] + " in war " + args[3]);
|
||||
Main.warLogger.log("Added " + args[7] + " points to side " + args[6] + " in sige on " + args[4] + " in war " + args[3]);
|
||||
return finalizeSiege(s);
|
||||
} else if (s.getWar().getSide2().equals(args[6])) {
|
||||
} else if (s.getWar().getSide2().equalsIgnoreCase(args[6])) {
|
||||
if (s.getSide1AreAttackers()) {
|
||||
s.addPointsToDefenders(Integer.parseInt(args[7]));
|
||||
} else {
|
||||
@@ -1156,7 +1271,7 @@ public class AdminCommands implements CommandExecutor {
|
||||
return true;
|
||||
}
|
||||
} else if (args[5].equalsIgnoreCase("set")) {
|
||||
if (s.getWar().getSide1().equals(args[6])) {
|
||||
if (s.getWar().getSide1().equalsIgnoreCase(args[6])) {
|
||||
if (s.getSide1AreAttackers()) {
|
||||
s.setAttackerPoints(Integer.parseInt(args[7]));
|
||||
} else {
|
||||
@@ -1165,7 +1280,7 @@ public class AdminCommands implements CommandExecutor {
|
||||
p.sendMessage(Helper.chatLabel() + "Set " + args[7] + " points for side " + args[6] + " in sige on " + args[4] + " in war " + args[3]);
|
||||
Main.warLogger.log("Set " + args[7] + " points for side " + args[6] + " in sige on " + args[4] + " in war " + args[3]);
|
||||
return finalizeSiege(s);
|
||||
} else if (s.getWar().getSide2().equals(args[6])) {
|
||||
} else if (s.getWar().getSide2().equalsIgnoreCase(args[6])) {
|
||||
if (s.getSide1AreAttackers()) {
|
||||
s.setDefenderPoints(Integer.parseInt(args[7]));
|
||||
} else {
|
||||
@@ -1195,7 +1310,7 @@ public class AdminCommands implements CommandExecutor {
|
||||
} else if (args[2].equalsIgnoreCase("townspawn")) {
|
||||
if (args.length >= 5) {
|
||||
for (Siege s : SiegeData.getSieges()) {
|
||||
if (s.getWar().getName().equals(args[3]) && s.getTown().getName().equals(args[4])) {
|
||||
if (s.getWar().getName().equalsIgnoreCase(args[3]) && s.getTown().getName().equalsIgnoreCase(args[4])) {
|
||||
if (args.length == 6 || args.length == 7) {
|
||||
p.sendMessage(Helper.color("&cUsage: /alathrawaradmin modify siege townspawn [war] [town] (x) (y) (Z)"));
|
||||
return true;
|
||||
@@ -1275,7 +1390,7 @@ public class AdminCommands implements CommandExecutor {
|
||||
} else if (args[2].equalsIgnoreCase("time")) {
|
||||
if (args.length >= 7) {
|
||||
for (Siege s : SiegeData.getSieges()) {
|
||||
if (s.getWar().getName().equals(args[3]) && s.getTown().getName().equals(args[4])) {
|
||||
if (s.getWar().getName().equalsIgnoreCase(args[3]) && s.getTown().getName().equalsIgnoreCase(args[4])) {
|
||||
//parse phase
|
||||
if (args[5].equalsIgnoreCase("add")) {
|
||||
s.setSiegeTicks(s.getSiegeTicks() + Integer.parseInt(args[6]));
|
||||
@@ -1295,13 +1410,13 @@ public class AdminCommands implements CommandExecutor {
|
||||
}
|
||||
p.sendMessage(Helper.chatLabel() + Helper.color("&cSiege cannot be found."));
|
||||
} else {
|
||||
p.sendMessage(Helper.color("&cUsage: /alathrawaradmin modify siege time [war] [town] [add/set/max] [value]"));
|
||||
p.sendMessage(Helper.color("&cUsage: /alathrawaradmin modify siege time [war] [town] [add/set] [value]"));
|
||||
}
|
||||
return true;
|
||||
} else if (args[2].equalsIgnoreCase("owner")) {
|
||||
if (args.length >= 7) {
|
||||
for (Siege s : SiegeData.getSieges()) {
|
||||
if (s.getWar().getName().equals(args[3]) && s.getTown().getName().equals(args[4])) {
|
||||
if (s.getWar().getName().equalsIgnoreCase(args[3]) && s.getTown().getName().equalsIgnoreCase(args[4])) {
|
||||
Player own = Bukkit.getPlayer(args[5]);
|
||||
if (own != null) {
|
||||
if (s.attackerPlayers.contains(own.getName())) {
|
||||
@@ -1341,8 +1456,8 @@ public class AdminCommands implements CommandExecutor {
|
||||
if (args[2].equalsIgnoreCase("score")) {
|
||||
if (args.length >= 7) {
|
||||
for (War w : WarData.getWars()) {
|
||||
if (w.getName().equals(args[3])) {
|
||||
if(args[4].equals(w.getSide1())) {
|
||||
if (w.getName().equalsIgnoreCase(args[3])) {
|
||||
if(args[4].equalsIgnoreCase(w.getSide1())) {
|
||||
if (args[5].equalsIgnoreCase("add")) {
|
||||
w.addSide1Points(Integer.parseInt(args[6]));
|
||||
p.sendMessage(Helper.chatLabel() + "Added " + args[6] + " points to the raid war in the war " + args[3] + " on side " + args[4]);
|
||||
@@ -1362,7 +1477,7 @@ public class AdminCommands implements CommandExecutor {
|
||||
p.sendMessage(Helper.color("&cUsage: /alathrawaradmin modify war score [war] [side] [add/subtract/set] [amt]"));
|
||||
return true;
|
||||
}
|
||||
} else if(args[4].equals(w.getSide2())) {
|
||||
} else if(args[4].equalsIgnoreCase(w.getSide2())) {
|
||||
if (args[5].equalsIgnoreCase("add")) {
|
||||
w.addSide2Points(Integer.parseInt(args[6]));
|
||||
p.sendMessage(Helper.chatLabel() + "Added " + args[6] + " points to the war score in the war " + args[3] + " on side " + args[4]);
|
||||
@@ -1396,14 +1511,14 @@ public class AdminCommands implements CommandExecutor {
|
||||
} else if (args[2].equalsIgnoreCase("side")) {
|
||||
if (args.length >= 6) {
|
||||
for (War w : WarData.getWars()) {
|
||||
if (w.getName().equals(args[3])) {
|
||||
if (w.getSide1().equals(args[4])) {
|
||||
if (w.getName().equalsIgnoreCase(args[3])) {
|
||||
if (w.getSide1().equalsIgnoreCase(args[4])) {
|
||||
w.setSide1(args[5]);
|
||||
w.save();
|
||||
p.sendMessage(Helper.chatLabel() + "Set side " + args[4] + " to " + args[5] + " in war " + args[3]);
|
||||
Main.warLogger.log(Helper.chatLabel() + "Set side " + args[4] + " to " + args[5] + " in war " + args[3]);
|
||||
return finalizeWar(w);
|
||||
} else if (w.getSide2().equals(args[4])) {
|
||||
} else if (w.getSide2().equalsIgnoreCase(args[4])) {
|
||||
w.setSide2(args[5]);
|
||||
w.save();
|
||||
p.sendMessage(Helper.chatLabel() + "Set side " + args[4] + " to " + args[5] + " in war " + args[3]);
|
||||
@@ -1423,7 +1538,7 @@ public class AdminCommands implements CommandExecutor {
|
||||
} else if (args[2].equalsIgnoreCase("name")) {
|
||||
if (args.length >= 5) {
|
||||
for (War w : WarData.getWars()) {
|
||||
if (w.getName().equals(args[3])) {
|
||||
if (w.getName().equalsIgnoreCase(args[3])) {
|
||||
w.setName(args[4]);
|
||||
p.sendMessage(Helper.chatLabel() + "Set name of war " + args[3] + " to " + args[4]);
|
||||
Main.warLogger.log(Helper.chatLabel() + "Set name of war " + args[3] + " to " + args[4]);
|
||||
@@ -1440,8 +1555,8 @@ public class AdminCommands implements CommandExecutor {
|
||||
else if (args[2].equalsIgnoreCase("add")) {
|
||||
if (args.length >= 7) {
|
||||
for (War w : WarData.getWars()) {
|
||||
if (w.getName().equals(args[3])) {
|
||||
if (!w.getSide1().equals(args[4]) && !w.getSide2().equals(args[4])) {
|
||||
if (w.getName().equalsIgnoreCase(args[3])) {
|
||||
if (!w.getSide1().equalsIgnoreCase(args[4]) && !w.getSide2().equalsIgnoreCase(args[4])) {
|
||||
p.sendMessage(Helper.color("&cError: Side not found!"));
|
||||
return true;
|
||||
}
|
||||
@@ -1452,17 +1567,17 @@ public class AdminCommands implements CommandExecutor {
|
||||
//forceful add, ignore surrender and override it if the town is
|
||||
if(Boolean.parseBoolean(args[7])) {
|
||||
//if we already have surrendered
|
||||
if(w.getSurrenderedTowns().contains(args[6])) {
|
||||
if(w.getSurrenderedTowns().contains(args[6].toLowerCase())) {
|
||||
w.unSurrenderTown(args[6]);
|
||||
p.sendMessage(Helper.chatLabel() + "Un-surrendered town " + args[6]);
|
||||
Main.warLogger.log(Helper.chatLabel() + "Un-surrendered town " + args[6]);
|
||||
}
|
||||
if(w.getSide1().equals(args[4])) {
|
||||
if(w.getSide1().equalsIgnoreCase(args[4])) {
|
||||
if(w.getSide2Towns().remove(args[6])) {
|
||||
p.sendMessage(Helper.chatLabel() + "Removed town " + args[6] + " from side " + w.getSide2());
|
||||
Main.warLogger.log(Helper.chatLabel() + "Un-surrendered town " + args[6]);
|
||||
}
|
||||
} else if(w.getSide2().equals(args[4])) {
|
||||
} else if(w.getSide2().equalsIgnoreCase(args[4])) {
|
||||
if(w.getSide1Towns().remove(args[6])) {
|
||||
p.sendMessage(Helper.chatLabel() + "Removed town " + args[6] + " from side " + w.getSide2());
|
||||
Main.warLogger.log(Helper.chatLabel() + "Un-surrendered town " + args[6]);
|
||||
@@ -1496,17 +1611,17 @@ public class AdminCommands implements CommandExecutor {
|
||||
if(Boolean.parseBoolean(args[7])) {
|
||||
//if we already have surrendered
|
||||
for(Town t : n.getTowns()) {
|
||||
if(w.getSurrenderedTowns().contains(t.getName())) {
|
||||
if(w.getSurrenderedTowns().contains(t.getName().toLowerCase())) {
|
||||
w.unSurrenderTown(t.getName());
|
||||
p.sendMessage(Helper.chatLabel() + "Unsurrendered town " + t.getName());
|
||||
Main.warLogger.log(Helper.chatLabel() + "Unsurrendered town " + t.getName());
|
||||
}
|
||||
if(w.getSide1().equals(args[4])) {
|
||||
if(w.getSide1().equalsIgnoreCase(args[4])) {
|
||||
if(w.getSide2Towns().remove(t.getName())) {
|
||||
p.sendMessage(Helper.chatLabel() + "Removed town " + t.getName() + " from side " + w.getSide2());
|
||||
Main.warLogger.log(Helper.chatLabel() + "Un-surrendered town " + t.getName());
|
||||
}
|
||||
} else if(w.getSide2().equals(args[4])) {
|
||||
} else if(w.getSide2().equalsIgnoreCase(args[4])) {
|
||||
if(w.getSide1Towns().remove(t.getName())) {
|
||||
p.sendMessage(Helper.chatLabel() + "Removed town " + t.getName() + " from side " + w.getSide2());
|
||||
Main.warLogger.log(Helper.chatLabel() + "Un-surrendered town " + t.getName());
|
||||
@@ -1552,11 +1667,11 @@ public class AdminCommands implements CommandExecutor {
|
||||
else if (args[2].equalsIgnoreCase("unsurrender")) {
|
||||
if (args.length >= 6) {
|
||||
for (War w : WarData.getWars()) {
|
||||
if (w.getName().equals(args[3])) {
|
||||
if (w.getName().equalsIgnoreCase(args[3])) {
|
||||
if (args[4].equalsIgnoreCase("town")) {
|
||||
Town t = TownyAPI.getInstance().getTown(args[5]);
|
||||
if (t != null) {
|
||||
if(w.getSurrenderedTowns().contains(args[5])) {
|
||||
if(w.getSurrenderedTowns().contains(args[5].toLowerCase())) {
|
||||
w.unSurrenderTown(args[5]);
|
||||
p.sendMessage(Helper.chatLabel() + "Un-surrendered town " + args[5]);
|
||||
Main.warLogger.log(Helper.chatLabel() + "Un-surrendered town " + args[5]);
|
||||
@@ -1574,7 +1689,7 @@ public class AdminCommands implements CommandExecutor {
|
||||
Nation n = TownyAPI.getInstance().getNation(args[5]);
|
||||
if (n != null) {
|
||||
for(Town t : n.getTowns()) {
|
||||
if (w.getSurrenderedTowns().contains(t.getName())) {
|
||||
if (w.getSurrenderedTowns().contains(t.getName().toLowerCase())) {
|
||||
w.unSurrenderTown(t.getName());
|
||||
p.sendMessage(Helper.chatLabel() + "Un-surrendered town " + t.getName());
|
||||
Main.warLogger.log(Helper.chatLabel() + "Un-surrendered town " + t.getName());
|
||||
@@ -1606,26 +1721,26 @@ public class AdminCommands implements CommandExecutor {
|
||||
else if (args[2].equalsIgnoreCase("surrender")) {
|
||||
if (args.length >= 7) {
|
||||
for (War w : WarData.getWars()) {
|
||||
if (w.getName().equals(args[3])) {
|
||||
if (!w.getSide1().equals(args[4]) && !w.getSide2().equals(args[4])) {
|
||||
if (w.getName().equalsIgnoreCase(args[3])) {
|
||||
if (!w.getSide1().equalsIgnoreCase(args[4]) && !w.getSide2().equalsIgnoreCase(args[4])) {
|
||||
p.sendMessage(Helper.color("&cError: Side not found!"));
|
||||
return true;
|
||||
}
|
||||
if (args[5].equalsIgnoreCase("town")) {
|
||||
Town t = TownyAPI.getInstance().getTown(args[6]);
|
||||
if (t != null) {
|
||||
if(w.getSide1Towns().contains(t.getName()) && w.getSide1().equals(args[4])) {
|
||||
if(w.getSide1Towns().contains(t.getName().toLowerCase()) && w.getSide1().equalsIgnoreCase(args[4])) {
|
||||
w.surrenderTown(t.getName());
|
||||
p.sendMessage(Helper.chatLabel() + "Forcefully surrendered town " + args[6] + " war " + args[3] + " on side " + args[4]);
|
||||
Main.warLogger.log(Helper.chatLabel() + "Forcefully surrendered town " + args[6] + " war " + args[3] + " on side " + args[4]);
|
||||
return finalizeWar(w);
|
||||
} else if(w.getSide2Towns().contains(t.getName()) && w.getSide2().equals(args[4])) {
|
||||
} else if(w.getSide2Towns().contains(t.getName().toLowerCase()) && w.getSide2().equalsIgnoreCase(args[4])) {
|
||||
w.surrenderTown(t.getName());
|
||||
p.sendMessage(Helper.chatLabel() + "Forcefully surrendered town " + args[6] + " war " + args[3] + " on side " + args[4]);
|
||||
Main.warLogger.log(Helper.chatLabel() + "Forcefully surrendered town " + args[6] + " war " + args[3] + " on side " + args[4]);
|
||||
return finalizeWar(w);
|
||||
} else {
|
||||
if (w.getSide1().equals(args[4]) || w.getSide2().equals(args[4])) {
|
||||
if (w.getSide1().equalsIgnoreCase(args[4]) || w.getSide2().equalsIgnoreCase(args[4])) {
|
||||
p.sendMessage(Helper.chatLabel() + "Town " + args[5] + " is not on either side of the war!");
|
||||
Main.warLogger.log(Helper.chatLabel() + "Town " + args[5] + " is not on either side of the war!");
|
||||
return true;
|
||||
@@ -1642,18 +1757,18 @@ public class AdminCommands implements CommandExecutor {
|
||||
Nation n = TownyAPI.getInstance().getNation(args[6]);
|
||||
if (n != null) {
|
||||
for (Town t : n.getTowns()) {
|
||||
if(w.getSide1Towns().contains(t.getName()) && w.getSide1().equals(args[4])) {
|
||||
if(w.getSide1Towns().contains(t.getName().toLowerCase()) && w.getSide1().equalsIgnoreCase(args[4])) {
|
||||
w.surrenderTown(t.getName());
|
||||
p.sendMessage(Helper.chatLabel() + "Forcefully surrendered town " + t.getName() + " war " + args[3] + " on side " + args[4]);
|
||||
Main.warLogger.log(Helper.chatLabel() + "Forcefully surrendered town " + t.getName() + " war " + args[3] + " on side " + args[4]);
|
||||
|
||||
} else if(w.getSide2Towns().contains(t.getName()) && w.getSide2().equals(args[4])) {
|
||||
} else if(w.getSide2Towns().contains(t.getName().toLowerCase()) && w.getSide2().equalsIgnoreCase(args[4])) {
|
||||
w.surrenderTown(t.getName());
|
||||
p.sendMessage(Helper.chatLabel() + "Forcefully surrendered town " + t.getName() + " war " + args[3] + " on side " + args[4]);
|
||||
Main.warLogger.log(Helper.chatLabel() + "Forcefully surrendered town " + t.getName() + " war " + args[3] + " on side " + args[4]);
|
||||
|
||||
} else {
|
||||
if (w.getSide1().equals(args[4]) || w.getSide2().equals(args[4])) {
|
||||
if (w.getSide1().equalsIgnoreCase(args[4]) || w.getSide2().equalsIgnoreCase(args[4])) {
|
||||
p.sendMessage(Helper.chatLabel() + "Town " + t.getName() + " is not on either side of the war!");
|
||||
Main.warLogger.log(Helper.chatLabel() + "Town " + t.getName() + " is not on either side of the war!");
|
||||
return true;
|
||||
@@ -1684,15 +1799,15 @@ public class AdminCommands implements CommandExecutor {
|
||||
} else if (args[2].equalsIgnoreCase("raidTimeWar")) {
|
||||
if (args.length >= 5) {
|
||||
for (War w : WarData.getWars()) {
|
||||
if (w.getName().equals(args[4])) {
|
||||
if (w.getName().equalsIgnoreCase(args[4])) {
|
||||
if (args[3].equalsIgnoreCase("add")) {
|
||||
if (args.length >= 7) {
|
||||
if (args[6].equals(w.getSide1())) {
|
||||
if (args[6].equalsIgnoreCase(w.getSide1())) {
|
||||
w.setLastRaidTimeSide1(w.getLastRaidTimeSide1() + Integer.parseInt(args[5]));
|
||||
p.sendMessage(Helper.chatLabel() + "Added " + args[6] + " to last raid time in war " + args[4]);
|
||||
Main.warLogger.log(Helper.chatLabel() + "Added " + args[6] + " to last raid time in war " + args[4]);
|
||||
return finalizeWar(w);
|
||||
} else if (args[6].equals(w.getSide2())) {
|
||||
} else if (args[6].equalsIgnoreCase(w.getSide2())) {
|
||||
w.setLastRaidTimeSide2(w.getLastRaidTimeSide2() + Integer.parseInt(args[5]));
|
||||
p.sendMessage(Helper.chatLabel() + "Added " + args[6] + " to last raid time in war " + args[4]);
|
||||
Main.warLogger.log(Helper.chatLabel() + "Added " + args[6] + " to last raid time in war " + args[4]);
|
||||
@@ -1707,12 +1822,12 @@ public class AdminCommands implements CommandExecutor {
|
||||
}
|
||||
} else if (args[3].equalsIgnoreCase("set")) {
|
||||
if (args.length >= 7) {
|
||||
if (args[6].equals(w.getSide1())) {
|
||||
if (args[6].equalsIgnoreCase(w.getSide1())) {
|
||||
w.setLastRaidTimeSide1(Integer.parseInt(args[5]));
|
||||
p.sendMessage(Helper.chatLabel() + "Set last raid time in war " + args[4] + " to " + args[6]);
|
||||
Main.warLogger.log(Helper.chatLabel() + "Set last raid time in war " + args[4] + " to " + args[6]);
|
||||
return finalizeWar(w);
|
||||
} else if (args[6].equals(w.getSide2())) {
|
||||
} else if (args[6].equalsIgnoreCase(w.getSide2())) {
|
||||
w.setLastRaidTimeSide2(Integer.parseInt(args[5]));
|
||||
p.sendMessage(Helper.chatLabel() + "Set last raid time in war " + args[4] + " to " + args[6]);
|
||||
Main.warLogger.log(Helper.chatLabel() + "Set last raid time in war " + args[4] + " to " + args[6]);
|
||||
@@ -1728,12 +1843,12 @@ public class AdminCommands implements CommandExecutor {
|
||||
} else if (args[3].equalsIgnoreCase("reset")) {
|
||||
|
||||
if (args.length >= 6) {
|
||||
if (args[5].equals(w.getSide1())) {
|
||||
if (args[5].equalsIgnoreCase(w.getSide1())) {
|
||||
w.setLastRaidTimeSide1(0);
|
||||
p.sendMessage(Helper.chatLabel() + "Reset last raid time in war " + args[4]);
|
||||
Main.warLogger.log(Helper.chatLabel() + "Reset last raid time in war " + args[4]);
|
||||
return finalizeWar(w);
|
||||
} else if (args[5].equals(w.getSide2())) {
|
||||
} else if (args[5].equalsIgnoreCase(w.getSide2())) {
|
||||
w.setLastRaidTimeSide2(0);
|
||||
p.sendMessage(Helper.chatLabel() + "Reset last raid time in war " + args[4]);
|
||||
Main.warLogger.log(Helper.chatLabel() + "Reset last raid time in war " + args[4]);
|
||||
@@ -1760,7 +1875,7 @@ public class AdminCommands implements CommandExecutor {
|
||||
} else if (args[2].equalsIgnoreCase("raidTimeTown")) {
|
||||
if (args.length >= 5) {
|
||||
for (Town t : TownyAPI.getInstance().getTowns()) {
|
||||
if (t.getName().equals(args[4])) {
|
||||
if (t.getName().equalsIgnoreCase(args[4])) {
|
||||
if (args[3].equalsIgnoreCase("add")) {
|
||||
if (args.length >= 6) {
|
||||
LongDataField last = (LongDataField) t.getMetadata("lastRaided");
|
||||
@@ -1861,4 +1976,5 @@ public class AdminCommands implements CommandExecutor {
|
||||
w.save();
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -21,7 +21,8 @@ public class AdminTabCompletion implements TabCompleter {
|
||||
"load",
|
||||
"load-all",
|
||||
"save",
|
||||
"save-all"
|
||||
"save-all",
|
||||
"item"
|
||||
});
|
||||
|
||||
List<String> type = List.of(new String[]{
|
||||
@@ -190,14 +191,13 @@ public class AdminTabCompletion implements TabCompleter {
|
||||
} else if (args.length == 1) {
|
||||
return NameUtil.filterByStart(base, args[0]);
|
||||
} else {
|
||||
|
||||
if (args[0].equalsIgnoreCase("purgebars")) {
|
||||
return empty;
|
||||
} else if (args[0].equalsIgnoreCase("save")) {
|
||||
if(args.length > 2) {
|
||||
return empty;
|
||||
} else {
|
||||
return CommandHelper.getWarNames();
|
||||
return NameUtil.filterByStart(CommandHelper.getWarNames(), args[1]);
|
||||
}
|
||||
} else if (args[0].equalsIgnoreCase("save-all")) {
|
||||
return empty;
|
||||
@@ -205,11 +205,25 @@ public class AdminTabCompletion implements TabCompleter {
|
||||
if(args.length > 2) {
|
||||
return empty;
|
||||
} else {
|
||||
return CommandHelper.getWarNames();
|
||||
return NameUtil.filterByStart(CommandHelper.getWarNames(), args[1]);
|
||||
}
|
||||
} else if (args[0].equalsIgnoreCase("load-all")) {
|
||||
return empty;
|
||||
} else if (args[0].equalsIgnoreCase("create")) {
|
||||
} else if (args[0].equalsIgnoreCase("item")) {
|
||||
if(args.length > 2) {
|
||||
if(args.length > 3) {
|
||||
if(args.length > 4) {
|
||||
return empty;
|
||||
} else {
|
||||
return NameUtil.filterByStart(CommandHelper.getPlayers(), args[3]);
|
||||
}
|
||||
} else {
|
||||
return empty;
|
||||
}
|
||||
} else {
|
||||
return NameUtil.filterByStart(CommandHelper.getWarItems(), args[1]);
|
||||
}
|
||||
} else if (args[0].equalsIgnoreCase("create")) {
|
||||
if (args.length > 2) {
|
||||
switch (args[1]) {
|
||||
case "raid" -> {
|
||||
|
||||
@@ -5,14 +5,15 @@ import com.palmergames.bukkit.towny.exceptions.NotRegisteredException;
|
||||
import com.palmergames.bukkit.towny.object.Nation;
|
||||
import com.palmergames.bukkit.towny.object.Resident;
|
||||
import com.palmergames.bukkit.towny.object.Town;
|
||||
import me.ShermansWorld.AlathraWar.Raid;
|
||||
import me.ShermansWorld.AlathraWar.Siege;
|
||||
import me.ShermansWorld.AlathraWar.War;
|
||||
import me.ShermansWorld.AlathraWar.*;
|
||||
import me.ShermansWorld.AlathraWar.data.RaidData;
|
||||
import me.ShermansWorld.AlathraWar.data.RaidPhase;
|
||||
import me.ShermansWorld.AlathraWar.data.SiegeData;
|
||||
import me.ShermansWorld.AlathraWar.data.WarData;
|
||||
import me.ShermansWorld.AlathraWar.items.WarItemRegistry;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Statistic;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.ArrayList;
|
||||
@@ -24,7 +25,7 @@ public class CommandHelper {
|
||||
|
||||
/**
|
||||
* Grabs list of all war names
|
||||
* @return
|
||||
* @return list of wars
|
||||
*/
|
||||
public static List<String> getWarNames() {
|
||||
List<String> out = new ArrayList<>();
|
||||
@@ -36,13 +37,13 @@ public class CommandHelper {
|
||||
|
||||
/**
|
||||
* Grabs first matching war and lists the sides
|
||||
* @param name
|
||||
* @return
|
||||
* @param name name of war
|
||||
* @return side of war
|
||||
*/
|
||||
public static List<String> getWarSides(String name) {
|
||||
List<String> out = new ArrayList<>();
|
||||
for (War w : WarData.getWars()) {
|
||||
if(w.getName().equals(name)) {
|
||||
if(w.getName().equalsIgnoreCase(name)) {
|
||||
out.add(w.getSide1());
|
||||
out.add(w.getSide2());
|
||||
break;
|
||||
@@ -54,7 +55,7 @@ public class CommandHelper {
|
||||
/**
|
||||
* get list of all towny towns
|
||||
*
|
||||
* @return
|
||||
* @return list of all towns
|
||||
*/
|
||||
public static List<String> getTownyTowns() {
|
||||
List<String> out = new ArrayList<>();
|
||||
@@ -67,14 +68,14 @@ public class CommandHelper {
|
||||
/**
|
||||
* get list of all towny towns in a war
|
||||
*
|
||||
* @return
|
||||
* @return list of all towns in a war
|
||||
*/
|
||||
public static List<String> getTownyWarTowns(String war) {
|
||||
List<String> out = new ArrayList<>();
|
||||
War w = WarData.getWar(war);
|
||||
if(w == null) return Collections.emptyList();
|
||||
for (Town t : TownyAPI.getInstance().getTowns()) {
|
||||
if(w.getSide2Towns().contains(t.getName()) || w.getSide1Towns().contains(t.getName())) {
|
||||
if(w.getSide2Towns().contains(t.getName().toLowerCase()) || w.getSide1Towns().contains(t.getName().toLowerCase())) {
|
||||
out.add(t.getName());
|
||||
}
|
||||
}
|
||||
@@ -84,14 +85,14 @@ public class CommandHelper {
|
||||
/**
|
||||
* get list of all towny towns in a war
|
||||
*
|
||||
* @return
|
||||
* @return list of all nations in a war
|
||||
*/
|
||||
public static List<String> getTownyWarNations(String war) {
|
||||
List<String> out = new ArrayList<>();
|
||||
War w = WarData.getWar(war);
|
||||
if(w == null) return Collections.emptyList();
|
||||
for (Town t : TownyAPI.getInstance().getTowns()) {
|
||||
if(w.getSide2Towns().contains(t.getName()) || w.getSide1Towns().contains(t.getName())) {
|
||||
if(w.getSide2Towns().contains(t.getName().toLowerCase()) || w.getSide1Towns().contains(t.getName().toLowerCase())) {
|
||||
if(t.hasNation()) {
|
||||
try {
|
||||
out.add(t.getNation().getName());
|
||||
@@ -107,19 +108,19 @@ public class CommandHelper {
|
||||
/**
|
||||
* get list of all towny towns on a side in a war
|
||||
*
|
||||
* @return
|
||||
* @return list of all towns in a side of a war
|
||||
*/
|
||||
public static List<String> getTownyWarTowns(String war, String side) {
|
||||
List<String> out = new ArrayList<>();
|
||||
War w = WarData.getWar(war);
|
||||
if(w == null) return Collections.emptyList();
|
||||
for (Town t : TownyAPI.getInstance().getTowns()) {
|
||||
if(side.equals(w.getSide1())) {
|
||||
if(w.getSide1Towns().contains(t.getName())) {
|
||||
if(side.equalsIgnoreCase(w.getSide1())) {
|
||||
if(w.getSide1Towns().contains(t.getName().toLowerCase())) {
|
||||
out.add(t.getName());
|
||||
}
|
||||
} else if(side.equals(w.getSide2())) {
|
||||
if(w.getSide2Towns().contains(t.getName())) {
|
||||
} else if(side.equalsIgnoreCase(w.getSide2())) {
|
||||
if(w.getSide2Towns().contains(t.getName().toLowerCase())) {
|
||||
out.add(t.getName());
|
||||
}
|
||||
}
|
||||
@@ -129,7 +130,7 @@ public class CommandHelper {
|
||||
|
||||
/**
|
||||
* return list of all towns in a raid
|
||||
* @return
|
||||
* @return list of all towns involved in a raid
|
||||
*/
|
||||
public static List<String> getRaidTowns() {
|
||||
List<String> out = new ArrayList<>();
|
||||
@@ -140,8 +141,8 @@ public class CommandHelper {
|
||||
}
|
||||
|
||||
/**
|
||||
* return list of all towns in a raid
|
||||
* @return
|
||||
* return list of all towns in a siege
|
||||
* @return list of towns involved in a siege
|
||||
*/
|
||||
public static List<String> getSiegeTowns() {
|
||||
List<String> out = new ArrayList<>();
|
||||
@@ -154,7 +155,7 @@ public class CommandHelper {
|
||||
/**
|
||||
* get list of all towny nations
|
||||
*
|
||||
* @return
|
||||
* @return list of all nations
|
||||
*/
|
||||
public static List<String> getTownyNations() {
|
||||
List<String> out = new ArrayList<>();
|
||||
@@ -171,7 +172,7 @@ public class CommandHelper {
|
||||
|
||||
/**
|
||||
* get a list of all online players
|
||||
* @return
|
||||
* @return list of all players online
|
||||
*/
|
||||
public static List<String> getPlayers() {
|
||||
Collection<? extends Player> players = Bukkit.getOnlinePlayers();
|
||||
@@ -184,7 +185,7 @@ public class CommandHelper {
|
||||
|
||||
/**
|
||||
* get a list of all raid phases
|
||||
* @return
|
||||
* @return list of all raid phases
|
||||
*/
|
||||
public static List<String> getRaidPhases() {
|
||||
List<String> out = new ArrayList<>();
|
||||
@@ -194,8 +195,53 @@ public class CommandHelper {
|
||||
return out;
|
||||
}
|
||||
|
||||
public static long getPlayerJoinDate(String player) {
|
||||
/**
|
||||
*
|
||||
* @param player player to check
|
||||
* @return 0, 1, 2 (good to go, insufficient join, insufficient playtime)
|
||||
*/
|
||||
public static int isPlayerMinuteman(String player) {
|
||||
Resident res = TownyAPI.getInstance().getResident(player);
|
||||
return res.getRegistered();
|
||||
if(res != null) {
|
||||
//get registration time
|
||||
long regTime = res.getRegistered();
|
||||
int playTicks = Bukkit.getPlayer(res.getUUID()).getStatistic(Statistic.PLAY_ONE_MINUTE);
|
||||
int out = 0;
|
||||
if(Main.getInstance().getConfig().getInt("minimumPlayerAge") > 0) {
|
||||
//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(Main.getInstance().getConfig().getInt("minimumPlayTime") > 0) {
|
||||
//check playtime, if its less than min its true
|
||||
if(playTicks < (Main.getInstance().getConfig().getInt("minimumPlayTime") * (60 * 60 * 20))) out = 2;
|
||||
}
|
||||
|
||||
return out;
|
||||
}
|
||||
//if the player doesnt exist just return true
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* log the command
|
||||
* @param sender sender
|
||||
* @param label command
|
||||
* @param args command args
|
||||
* @return success
|
||||
*/
|
||||
protected static void logCommand(CommandSender sender, String label, String[] args) {
|
||||
StringBuilder log = new StringBuilder(label);
|
||||
for (String s : args) {
|
||||
log.append(" ").append(s);
|
||||
}
|
||||
Main.warLogger.log(Helper.chatLabel() + sender.getName() + " ran command: " + log.toString());
|
||||
}
|
||||
|
||||
/**
|
||||
* return list of all alathrawar items with namespace
|
||||
* @return list of all alathrawar items namespaced
|
||||
*/
|
||||
public static List<String> getWarItems() {
|
||||
return new ArrayList<>(WarItemRegistry.getInstance().getItemRegistry().keySet());
|
||||
}
|
||||
}
|
||||
@@ -27,6 +27,7 @@ public class RaidCommands implements CommandExecutor {
|
||||
|
||||
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) {
|
||||
@@ -83,6 +84,11 @@ public class RaidCommands implements CommandExecutor {
|
||||
}
|
||||
}
|
||||
|
||||
if (raidOwner == null) {
|
||||
p.sendMessage("Raid Owner is Null");
|
||||
return;
|
||||
}
|
||||
|
||||
TownyWorld townyWorld;
|
||||
townyWorld = WorldCoord.parseWorldCoord(raidOwner.getLocation()).getTownyWorld();
|
||||
|
||||
@@ -96,24 +102,32 @@ public class RaidCommands implements CommandExecutor {
|
||||
return;
|
||||
}
|
||||
|
||||
//Minutemen countermeasures, 86400 * 4 time. 86400 seconds in a day, 4 days min playtime
|
||||
//Minuteman countermeasures
|
||||
int minuteman = CommandHelper.isPlayerMinuteman(raidOwner.getName());
|
||||
boolean override = false;
|
||||
if (admin) {
|
||||
if (System.currentTimeMillis() - CommandHelper.getPlayerJoinDate(raidOwner.getName()) < 86400000L * Main.getInstance().getConfig().getInt("minimumPlayerAge") ) {
|
||||
if(args.length >= 5) {
|
||||
if (args.length >= 7) {
|
||||
if (Boolean.parseBoolean(args[6])) {
|
||||
//player has joined to recently
|
||||
p.sendMessage(ChatColor.RED + "Warning! Ignoring Minuteman Countermeasure!");
|
||||
} else {
|
||||
//player has joined to recently
|
||||
p.sendMessage(ChatColor.RED + "You have joined the server too recently! You can only join a war after 4 days from joining.");
|
||||
raidOwner.getPlayer().sendMessage(ChatColor.RED + "You have joined the server too recently! You can only join a war after 4 days from joining.");
|
||||
return;
|
||||
override = true;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (System.currentTimeMillis() - CommandHelper.getPlayerJoinDate(raidOwner.getName()) < 86400000L * Main.getInstance().getConfig().getInt("minimumPlayerAge") ) {
|
||||
//player has joined to recently
|
||||
p.sendMessage(ChatColor.RED + "You have joined the server too recently! You can only join a war after 4 days from joining.");
|
||||
return;
|
||||
}
|
||||
//override?
|
||||
if(!override) {
|
||||
if (minuteman != 0) {
|
||||
if (minuteman == 1) {
|
||||
//player has joined to recently
|
||||
if (admin) p.sendMessage(ChatColor.RED + "You have joined the server too recently! You can only join a raid after " + Main.getInstance().getConfig().getInt("minimumPlayerAge") + " days from joining.");
|
||||
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;
|
||||
} else if (minuteman == 2) {
|
||||
//player has played too little
|
||||
if (admin) p.sendMessage(ChatColor.RED + "You have not played enough! You can only join a raid after " + Main.getInstance().getConfig().getInt("minimumPlayTime") + " hours of play.");
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -154,9 +168,25 @@ public class RaidCommands implements CommandExecutor {
|
||||
//if this is run as admin, shift our check forward a slot
|
||||
if (raidedTown.getName().equalsIgnoreCase(args[2 + (admin ? 1 : 0)]) && gatherTown != null) {
|
||||
|
||||
Main.warLogger.log("Raided town: " + raidedTown.getName());
|
||||
Main.warLogger.log("Gather town: " + gatherTown.getName());
|
||||
Main.warLogger.log("Raid Owner: " + raidOwner.getName());
|
||||
p.sendMessage("Raided town: " + raidedTown.getName());
|
||||
p.sendMessage("Gather town: " + gatherTown.getName());
|
||||
p.sendMessage("Raid Owner: " + raidOwner.getName());
|
||||
//DEBUG PRINT
|
||||
for (String t : war.getSide1Towns()) {
|
||||
Main.warLogger.log("Side1 town: " + t);
|
||||
p.sendMessage("Side1 town: " + t);
|
||||
}
|
||||
for (String t : war.getSide2Towns()) {
|
||||
Main.warLogger.log("Side2 town: " + t);
|
||||
p.sendMessage("Side2 town: " + t);
|
||||
}
|
||||
|
||||
//check if the town were attempting to raid is in the war
|
||||
if(!war.getSide1Towns().contains(raidedTown.getName()) && !war.getSide2Towns().contains(raidedTown.getName())) {
|
||||
if (war.getSurrenderedTowns().contains(raidedTown.getName())) {
|
||||
if(!war.getSide1Towns().contains(raidedTown.getName().toLowerCase()) && !war.getSide2Towns().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!");
|
||||
raidOwner.sendMessage(String.valueOf(Helper.chatLabel()) + "The town you are trying to raid has already surrendered!");
|
||||
return;
|
||||
@@ -168,7 +198,7 @@ public class RaidCommands implements CommandExecutor {
|
||||
|
||||
// Is being sieged check
|
||||
for (Siege s : SiegeData.getSieges()) {
|
||||
if(s.getTown().getName().equals(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!");
|
||||
if(admin) p.sendMessage(String.valueOf(Helper.chatLabel()) + "That town is already currently being sieged! Cannot raid at this time!");
|
||||
}
|
||||
@@ -235,7 +265,7 @@ public class RaidCommands implements CommandExecutor {
|
||||
|
||||
// Player participance check
|
||||
Town leaderTown = TownyAPI.getInstance().getResident(raidOwner).getTownOrNull();
|
||||
int sideR = war.getSide(leaderTown.getName());
|
||||
int sideR = war.getSide(leaderTown.getName().toLowerCase());
|
||||
if (sideR == 0) {
|
||||
if (admin) p.sendMessage(Helper.chatLabel() + "You are not in this war.");
|
||||
raidOwner.sendMessage(Helper.chatLabel() + "You are not in this war.");
|
||||
@@ -339,7 +369,7 @@ public class RaidCommands implements CommandExecutor {
|
||||
|
||||
if(joiner != null) {
|
||||
if (args[4] != null) {
|
||||
if (args[4].equals(raid.getDefenderSide())) {
|
||||
if (args[4].equalsIgnoreCase(raid.getDefenderSide())) {
|
||||
if (!raid.getDefenderPlayers().contains(joiner.getName()))
|
||||
raid.getDefenderPlayers().add(joiner.getName());
|
||||
p.sendMessage(String.valueOf(Helper.chatLabel()) + "Player " + joiner.getName() + " added to defender side.");
|
||||
@@ -370,30 +400,31 @@ public class RaidCommands implements CommandExecutor {
|
||||
}
|
||||
|
||||
//Minutemen countermeasures, 86400 * 4 time. 86400 seconds in a day, 4 days min playtime
|
||||
//also 12 hours min platim by default
|
||||
int minuteman = CommandHelper.isPlayerMinuteman(joiner.getName());
|
||||
boolean override = false;
|
||||
if (admin) {
|
||||
if (System.currentTimeMillis() - CommandHelper.getPlayerJoinDate(args[3]) < 86400000L * Main.getInstance().getConfig().getInt("minimumPlayerAge") ) {
|
||||
if(args.length >= 6) {
|
||||
if (Boolean.parseBoolean(args[5])) {
|
||||
//player has joined to recently
|
||||
p.sendMessage(ChatColor.RED + "Warning! Ignoring Minuteman Countermeasure!");
|
||||
} else {
|
||||
//player has joined to recently
|
||||
p.sendMessage(ChatColor.RED + "You have joined the server too recently! You can only join a war after 4 days from joining.");
|
||||
joiner.getPlayer().sendMessage(ChatColor.RED + "You have joined the server too recently! You can only join a war after 4 days from joining.");
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
if (args.length >= 6) {
|
||||
if (Boolean.parseBoolean(args[5])) {
|
||||
//player has joined to recently
|
||||
p.sendMessage(ChatColor.RED + "You have joined the server too recently! You can only join a war after 4 days from joining.");
|
||||
joiner.getPlayer().sendMessage(ChatColor.RED + "You have joined the server too recently! You can only join a war after 4 days from joining.");
|
||||
return;
|
||||
p.sendMessage(ChatColor.RED + "Warning! Ignoring Minuteman Countermeasure!");
|
||||
override = true;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (System.currentTimeMillis() - CommandHelper.getPlayerJoinDate(joiner.getName()) < 86400000L * Main.getInstance().getConfig().getInt("minimumPlayerAge") ) {
|
||||
//player has joined to recently
|
||||
p.sendMessage(ChatColor.RED + "You have joined the server too recently! You can only join a war after 4 days from joining.");
|
||||
return;
|
||||
}
|
||||
if(!override) {
|
||||
if (minuteman != 0) {
|
||||
if (minuteman == 1) {
|
||||
//player has joined to recently
|
||||
if (admin) p.sendMessage(ChatColor.RED + "You have joined the server too recently! You can only join a raid after " + Main.getInstance().getConfig().getInt("minimumPlayerAge") + " days from joining.");
|
||||
joiner.sendMessage(ChatColor.RED + "You have joined the server too recently! You can only join a raid after " + Main.getInstance().getConfig().getInt("minimumPlayerAge") + " days from joining.");
|
||||
return;
|
||||
} else if (minuteman == 2) {
|
||||
//player has played too little
|
||||
if (admin) p.sendMessage(ChatColor.RED + "You have not played enough! You can only join a raid after " + Main.getInstance().getConfig().getInt("minimumPlayTime") + " hours of play.");
|
||||
joiner.sendMessage(ChatColor.RED + "You have not played enough! You can only join a raid after " + Main.getInstance().getConfig().getInt("minimumPlayTime") + " hours of play.");
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -504,7 +535,7 @@ public class RaidCommands implements CommandExecutor {
|
||||
return;
|
||||
}
|
||||
|
||||
if (raid.getOwner().getName().equals(p.getName())) {
|
||||
if (raid.getOwner().getName().equalsIgnoreCase(p.getName())) {
|
||||
//check if gather phase
|
||||
if (raid.getPhase() == RaidPhase.GATHER || raid.getPhase() == RaidPhase.START || raid.getPhase() == RaidPhase.TRAVEL || raid.getPhase() == RaidPhase.COMBAT) {
|
||||
//force defender victory
|
||||
@@ -533,8 +564,8 @@ public class RaidCommands implements CommandExecutor {
|
||||
p.sendMessage("Name: " + raid.getName());
|
||||
p.sendMessage("War: " + raid.getWar().getName());
|
||||
p.sendMessage("Owner: " + raid.getOwner().getName());
|
||||
p.sendMessage("Raiding: " + raid.getRaidedTown().getName());
|
||||
p.sendMessage("Gathering In: " + raid.getGatherTown().getName());
|
||||
p.sendMessage("Raiding: " + raid.getRaidedTown().getName().toLowerCase());
|
||||
p.sendMessage("Gathering In: " + raid.getGatherTown().getName().toLowerCase());
|
||||
p.sendMessage("Raiders: " + raid.getRaiderSide());
|
||||
p.sendMessage("Defenders: " + raid.getDefenderSide());
|
||||
p.sendMessage("Raider Score: " + raid.getRaiderScore());
|
||||
|
||||
@@ -1,18 +1,10 @@
|
||||
package me.ShermansWorld.AlathraWar.commands;
|
||||
|
||||
import com.palmergames.bukkit.towny.TownyAPI;
|
||||
import com.palmergames.bukkit.towny.object.Town;
|
||||
import com.palmergames.bukkit.towny.utils.NameUtil;
|
||||
import me.ShermansWorld.AlathraWar.Raid;
|
||||
import me.ShermansWorld.AlathraWar.War;
|
||||
import me.ShermansWorld.AlathraWar.data.RaidData;
|
||||
import me.ShermansWorld.AlathraWar.data.WarData;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.command.TabCompleter;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
@@ -23,6 +23,7 @@ public class SiegeCommands implements CommandExecutor {
|
||||
}
|
||||
|
||||
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;
|
||||
@@ -75,6 +76,11 @@ public class SiegeCommands implements CommandExecutor {
|
||||
}
|
||||
}
|
||||
|
||||
if (siegeOwner == null) {
|
||||
sender.sendMessage("Owner is Null");
|
||||
return;
|
||||
}
|
||||
|
||||
if (args.length < 3) {
|
||||
sender.sendMessage(Helper.chatLabel() + "/war siege [war] [town]");
|
||||
return;
|
||||
@@ -88,9 +94,26 @@ public class SiegeCommands implements CommandExecutor {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
// Player participance check
|
||||
Town leaderTown = TownyAPI.getInstance().getResident(siegeOwner).getTownOrNull();
|
||||
int side = war.getSide(leaderTown.getName());
|
||||
int side = war.getSide(leaderTown.getName().toLowerCase());
|
||||
|
||||
//DEBUG PRINT
|
||||
Main.warLogger.log("Leader Town: " + leaderTown.getName());
|
||||
Main.warLogger.log("Siege Owner: " + siegeOwner.getName());
|
||||
sender.sendMessage("Leader Town: " + leaderTown.getName());
|
||||
sender.sendMessage("Siege Owner: " + siegeOwner.getName());
|
||||
//DEBUG PRINT
|
||||
for (String t : war.getSide1Towns()) {
|
||||
Main.warLogger.log("Side1 town: " + t);
|
||||
sender.sendMessage("Side1 town: " + t);
|
||||
}
|
||||
for (String t : war.getSide2Towns()) {
|
||||
Main.warLogger.log("Side2 town: " + t);
|
||||
sender.sendMessage("Side2 town: " + t);
|
||||
}
|
||||
|
||||
if (side == 0) {
|
||||
siegeOwner.sendMessage(Helper.chatLabel() + "You are not in this war.");
|
||||
if(admin) sender.sendMessage(Helper.chatLabel() + "You are not in this war.");
|
||||
@@ -102,30 +125,32 @@ public class SiegeCommands implements CommandExecutor {
|
||||
}
|
||||
|
||||
//Minutemen countermeasures, 86400 * 4 time. 86400 seconds in a day, 4 days min playtime
|
||||
//Minuteman countermeasures
|
||||
int minuteman = CommandHelper.isPlayerMinuteman(siegeOwner.getName());
|
||||
boolean override = false;
|
||||
if (admin) {
|
||||
if (System.currentTimeMillis() - CommandHelper.getPlayerJoinDate(siegeOwner.getName()) < 86400000L * Main.getInstance().getConfig().getInt("minimumPlayerAge") ) {
|
||||
if(args.length >= 5) {
|
||||
if (Boolean.parseBoolean(args[4])) {
|
||||
//player has joined to recently
|
||||
sender.sendMessage(ChatColor.RED + "Warning! Ignoring Minuteman Countermeasure!");
|
||||
} else {
|
||||
//player has joined to recently
|
||||
sender.sendMessage(ChatColor.RED + "You have joined the server too recently! You can only join a war after 4 days from joining.");
|
||||
siegeOwner.getPlayer().sendMessage(ChatColor.RED + "You have joined the server too recently! You can only join a war after 4 days from joining.");
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
if (args.length >= 6) {
|
||||
if (Boolean.parseBoolean(args[5])) {
|
||||
//player has joined to recently
|
||||
sender.sendMessage(ChatColor.RED + "You have joined the server too recently! You can only join a war after 4 days from joining.");
|
||||
siegeOwner.getPlayer().sendMessage(ChatColor.RED + "You have joined the server too recently! You can only join a war after 4 days from joining.");
|
||||
return;
|
||||
sender.sendMessage(ChatColor.RED + "Warning! Ignoring Minuteman Countermeasure!");
|
||||
override = true;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (System.currentTimeMillis() - CommandHelper.getPlayerJoinDate(siegeOwner.getName()) < 86400000L * Main.getInstance().getConfig().getInt("minimumPlayerAge") ) {
|
||||
//player has joined to recently
|
||||
siegeOwner.sendMessage(ChatColor.RED + "You have joined the server too recently! You can only join a war after 4 days from joining.");
|
||||
return;
|
||||
}
|
||||
//override?
|
||||
if(!override) {
|
||||
if (minuteman != 0) {
|
||||
if (minuteman == 1) {
|
||||
//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.");
|
||||
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;
|
||||
} else if (minuteman == 2) {
|
||||
//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.");
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -136,10 +161,12 @@ public class SiegeCommands implements CommandExecutor {
|
||||
if(admin) sender.sendMessage(String.valueOf(Helper.chatLabel()) + "That town does not exist! /siege start [war] [town]");
|
||||
return;
|
||||
}
|
||||
Main.warLogger.log("Attacked Town: " + town.getName().toLowerCase());
|
||||
sender.sendMessage("Attacked Town: " + town.getName().toLowerCase());
|
||||
|
||||
// Is being raided check
|
||||
for ( Raid r : RaidData.getRaids()) {
|
||||
if(r.getRaidedTown().getName().equals(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!");
|
||||
if(admin) sender.sendMessage(String.valueOf(Helper.chatLabel()) + "That town is already currently being raided! Cannot siege at this time!");
|
||||
return;
|
||||
@@ -242,8 +269,8 @@ public class SiegeCommands implements CommandExecutor {
|
||||
sender.sendMessage(String.valueOf(Helper.chatLabel()) + "Sieges currently in progress:");
|
||||
for (Siege siege : sieges) {
|
||||
War war = siege.getWar();
|
||||
String color = (siege.getSide1AreAttackers() && (war.getSide(siege.getTown().getName()) == 1) ) ? "§c" : "§9";
|
||||
sender.sendMessage(war.getName() + " - " + color + siege.getTown().getName());
|
||||
String color = (siege.getSide1AreAttackers() && (war.getSide(siege.getTown().getName().toLowerCase()) == 1) ) ? "§c" : "§9";
|
||||
sender.sendMessage(war.getName() + " - " + color + siege.getTown().getName().toLowerCase());
|
||||
sender.sendMessage(war.getSide1() + " - " + (siege.getSide1AreAttackers() ? siege.getAttackerPoints() : siege.getDefenderPoints()));
|
||||
sender.sendMessage(war.getSide2() + " - " + (siege.getSide1AreAttackers() ? siege.getDefenderPoints() : siege.getAttackerPoints()));
|
||||
sender.sendMessage("Time Left: " + (Siege.maxSiegeTicks - siege.getSiegeTicks())/1200 + " minutes");
|
||||
@@ -254,10 +281,10 @@ public class SiegeCommands implements CommandExecutor {
|
||||
|
||||
private static void siegeHelp(CommandSender sender, String[] args) {
|
||||
if (sender.hasPermission("AlathraWar.admin")) {
|
||||
sender.sendMessage(Helper.chatLabel() + "/siege stop [town]");
|
||||
sender.sendMessage(Helper.chatLabel() + "/siege stop [war] [town]");
|
||||
}
|
||||
sender.sendMessage(Helper.chatLabel() + "/siege start [war] [town]");
|
||||
sender.sendMessage(Helper.chatLabel() + "/siege abandon [town]");
|
||||
sender.sendMessage(Helper.chatLabel() + "/siege abandon [war] [town]");
|
||||
sender.sendMessage(Helper.chatLabel() + "/siege list");
|
||||
}
|
||||
}
|
||||
@@ -1,22 +1,12 @@
|
||||
package me.ShermansWorld.AlathraWar.commands;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import com.palmergames.bukkit.towny.utils.NameUtil;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.command.TabCompleter;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.palmergames.bukkit.towny.TownyAPI;
|
||||
import com.palmergames.bukkit.towny.object.Town;
|
||||
|
||||
import me.ShermansWorld.AlathraWar.Siege;
|
||||
import me.ShermansWorld.AlathraWar.War;
|
||||
import me.ShermansWorld.AlathraWar.data.SiegeData;
|
||||
import me.ShermansWorld.AlathraWar.data.WarData;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
public class SiegeTabCompletion implements TabCompleter {
|
||||
|
||||
@@ -47,8 +37,9 @@ public class SiegeTabCompletion implements TabCompleter {
|
||||
if (args.length > 2) {
|
||||
if (args.length > 3) {
|
||||
return Collections.emptyList();
|
||||
} else {
|
||||
return NameUtil.filterByStart(CommandHelper.getTownyWarTowns(args[1]), args[2]);
|
||||
}
|
||||
return NameUtil.filterByStart(CommandHelper.getTownyWarTowns(args[1]), args[2]);
|
||||
} else {
|
||||
return NameUtil.filterByStart(CommandHelper.getWarNames(), args[1]);
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package me.ShermansWorld.AlathraWar.commands;
|
||||
|
||||
import me.ShermansWorld.AlathraWar.*;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@@ -7,9 +8,6 @@ import com.palmergames.bukkit.towny.TownyAPI;
|
||||
import com.palmergames.bukkit.towny.object.Resident;
|
||||
import com.palmergames.bukkit.towny.object.Town;
|
||||
|
||||
import me.ShermansWorld.AlathraWar.Helper;
|
||||
import me.ShermansWorld.AlathraWar.Main;
|
||||
import me.ShermansWorld.AlathraWar.War;
|
||||
import me.ShermansWorld.AlathraWar.data.WarData;
|
||||
import net.md_5.bungee.api.ChatColor;
|
||||
|
||||
@@ -25,6 +23,7 @@ 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)) {
|
||||
consoleCommand(sender, args);
|
||||
return true;
|
||||
@@ -105,6 +104,13 @@ public class WarCommands implements CommandExecutor {
|
||||
return;
|
||||
}
|
||||
|
||||
for(Siege s : war.getSieges()) {
|
||||
s.stop();
|
||||
}
|
||||
for(Raid r : war.getRaids()) {
|
||||
r.stop();
|
||||
}
|
||||
|
||||
WarData.removeWar(war);
|
||||
|
||||
p.sendMessage(String.valueOf(Helper.chatLabel()) + "War " + args[1] + " deleted.");
|
||||
@@ -161,31 +167,32 @@ public class WarCommands implements CommandExecutor {
|
||||
return;
|
||||
}
|
||||
|
||||
//Minutemen countermeasures, 86400 * 4 time. 86400 seconds in a day, 4 days min playtime
|
||||
//Minuteman countermeasures
|
||||
int minuteman = CommandHelper.isPlayerMinuteman(player.getName());
|
||||
boolean override = false;
|
||||
if (admin) {
|
||||
if (System.currentTimeMillis() - CommandHelper.getPlayerJoinDate(args[3]) < 86400000L * Main.getInstance().getConfig().getInt("minimumPlayerAge") ) {
|
||||
if(args.length >= 5) {
|
||||
if (Boolean.parseBoolean(args[4])) {
|
||||
//player has joined to recently
|
||||
p.sendMessage(ChatColor.RED + "Warning! Ignoring Minuteman Countermeasure!");
|
||||
} else {
|
||||
//player has joined to recently
|
||||
p.sendMessage(ChatColor.RED + "You have joined the server too recently! You can only join a war after 4 days from joining.");
|
||||
res.getPlayer().sendMessage(ChatColor.RED + "You have joined the server too recently! You can only join a war after 4 days from joining.");
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
if (args.length >= 6) {
|
||||
if (Boolean.parseBoolean(args[5])) {
|
||||
//player has joined to recently
|
||||
p.sendMessage(ChatColor.RED + "You have joined the server too recently! You can only join a war after 4 days from joining.");
|
||||
res.getPlayer().sendMessage(ChatColor.RED + "You have joined the server too recently! You can only join a war after 4 days from joining.");
|
||||
return;
|
||||
p.sendMessage(ChatColor.RED + "Warning! Ignoring Minuteman Countermeasure!");
|
||||
override = true;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (System.currentTimeMillis() - CommandHelper.getPlayerJoinDate(p.getName()) < 86400000L * Main.getInstance().getConfig().getInt("minimumPlayerAge") ) {
|
||||
//player has joined to recently
|
||||
p.sendMessage(ChatColor.RED + "You have joined the server too recently! You can only join a war after 4 days from joining.");
|
||||
return;
|
||||
}
|
||||
//override?
|
||||
if(!override) {
|
||||
if (minuteman != 0) {
|
||||
if (minuteman == 1) {
|
||||
//player has joined to recently
|
||||
if (admin) p.sendMessage(ChatColor.RED + "You have joined the server too recently! You can only join a raid after " + Main.getInstance().getConfig().getInt("minimumPlayerAge") + " days from joining.");
|
||||
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;
|
||||
} else if (minuteman == 2) {
|
||||
//player has played too little
|
||||
if (admin) p.sendMessage(ChatColor.RED + "You have not played enough! You can only join a raid after " + Main.getInstance().getConfig().getInt("minimumPlayTime") + " hours of play.");
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,18 +1,12 @@
|
||||
package me.ShermansWorld.AlathraWar.commands;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import com.palmergames.bukkit.towny.utils.NameUtil;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.command.TabCompleter;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import me.ShermansWorld.AlathraWar.War;
|
||||
import me.ShermansWorld.AlathraWar.data.WarData;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
public class WarTabCompletion implements TabCompleter{
|
||||
|
||||
|
||||
@@ -8,7 +8,9 @@ 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.yaml.snakeyaml.DumperOptions;
|
||||
import org.yaml.snakeyaml.Yaml;
|
||||
|
||||
@@ -33,11 +35,27 @@ public class DataManager {
|
||||
*/
|
||||
public static void saveData(String filePath, HashMap<String,Object> map) {
|
||||
File file = getFile(filePath);
|
||||
if (file == null) return;
|
||||
|
||||
Bukkit.getLogger().log(Level.WARNING, "scoreboard.yml printout");
|
||||
Bukkit.getLogger().log(Level.WARNING, "Error Print isAbsolute: " + (file == null ? "" : file.isAbsolute()));
|
||||
Bukkit.getLogger().log(Level.WARNING, "Error Print isFile: " + (file == null ? "" : file.isFile()));
|
||||
Bukkit.getLogger().log(Level.WARNING, "Error Print canWrite: " + (file == null ? "" : file.canWrite()));
|
||||
Bukkit.getLogger().log(Level.WARNING, "Error Print exists: " + (file == null ? "" : file.exists()));
|
||||
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 path: " + (file == null ? "" : file.getPath()));
|
||||
PrintWriter writer = null;
|
||||
try {
|
||||
file.setWritable(true);
|
||||
writer = new PrintWriter(file);
|
||||
} catch (FileNotFoundException e) {
|
||||
Main.warLogger.log("Encountered error when creating PrintWriter for " + filePath);
|
||||
Main.warLogger.log("Encountered FileNotFound error when creating PrintWriter for " + filePath);
|
||||
e.printStackTrace();
|
||||
return;
|
||||
} catch (NullPointerException e) {
|
||||
Main.warLogger.log("Encountered NullPointer error when creating PrintWriter for " + filePath);
|
||||
e.printStackTrace();
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -50,6 +68,7 @@ public class DataManager {
|
||||
|
||||
Yaml yaml = new Yaml(options);
|
||||
yaml.dump(map, writer);
|
||||
writer.flush();
|
||||
writer.close();
|
||||
}
|
||||
|
||||
|
||||
@@ -10,7 +10,6 @@ import me.ShermansWorld.AlathraWar.Main;
|
||||
import me.ShermansWorld.AlathraWar.Raid;
|
||||
import me.ShermansWorld.AlathraWar.War;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.NamespacedKey;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
@@ -36,7 +35,7 @@ public class RaidData {
|
||||
*/
|
||||
public static Raid getRaidOrNull(String name) {
|
||||
for (Raid raid : raids) {
|
||||
if (raid.getName().equals(name)) return raid;
|
||||
if (raid.getName().equalsIgnoreCase(name)) return raid;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
@@ -248,7 +247,7 @@ public class RaidData {
|
||||
}
|
||||
|
||||
//6 hour raid cooldown for war
|
||||
if ((System.currentTimeMillis() / 1000) - (side.equals(war.getSide1()) ? war.getLastRaidTimeSide1() : war.getLastRaidTimeSide2()) <= 21600) {
|
||||
if ((System.currentTimeMillis() / 1000) - (side.equalsIgnoreCase(war.getSide1()) ? war.getLastRaidTimeSide1() : war.getLastRaidTimeSide2()) <= 21600) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -263,7 +262,7 @@ public class RaidData {
|
||||
|
||||
//check if being raided
|
||||
for (Raid raid : war.getRaids()) {
|
||||
if (raid.getRaidedTown().getName().equals(town.getName())) {
|
||||
if (raid.getRaidedTown().getName().equalsIgnoreCase(town.getName())) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
@@ -3,7 +3,6 @@ package me.ShermansWorld.AlathraWar.data;
|
||||
import java.util.*;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.NamespacedKey;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
|
||||
import com.palmergames.bukkit.towny.TownyAPI;
|
||||
@@ -58,7 +57,7 @@ public class SiegeData
|
||||
|
||||
/**
|
||||
* Creates a siege object from a provided HashMap
|
||||
* @param fileData
|
||||
* @param fileData data
|
||||
* @return Siege object
|
||||
*/
|
||||
private static Siege fromMap(War war, HashMap<String, Object> fileData) {
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
package me.ShermansWorld.AlathraWar.items;
|
||||
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.Recipe;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
public interface IWarItem {
|
||||
|
||||
public ItemStack getItemStack();
|
||||
|
||||
public Recipe getRecipe();
|
||||
|
||||
}
|
||||
@@ -0,0 +1,90 @@
|
||||
package me.ShermansWorld.AlathraWar.items;
|
||||
|
||||
import me.ShermansWorld.AlathraWar.Helper;
|
||||
import me.ShermansWorld.AlathraWar.Main;
|
||||
import me.ShermansWorld.AlathraWar.items.item.RamItem;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.ItemMeta;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
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();
|
||||
|
||||
/**
|
||||
* loads all items into the plugin registry list
|
||||
*/
|
||||
public WarItemRegistry() {
|
||||
instance = this;
|
||||
|
||||
Main.warLogger.log(Helper.chatLabel() + "Registering AlathraWar items.");
|
||||
|
||||
itemRegistry.put(registryName("ram"), new RamItem());
|
||||
//THIS BREAKS EVERYTHING???? TODO
|
||||
// Bukkit.getServer().addRecipe(new RamItem().getRecipe());
|
||||
|
||||
Main.warLogger.log(Helper.chatLabel() + "Registered AlathraWar items.");
|
||||
}
|
||||
|
||||
public static WarItemRegistry getInstance() {
|
||||
return instance;
|
||||
}
|
||||
|
||||
/**
|
||||
* generate a registry name
|
||||
* @param item
|
||||
* @return
|
||||
*/
|
||||
public static String registryName(String item) {
|
||||
return namespace + ":" + item;
|
||||
}
|
||||
|
||||
public Map<String, ItemStack> getItemRegistry() {
|
||||
return itemRegistry.entrySet()
|
||||
.stream()
|
||||
.filter(v -> v.getValue() != null)
|
||||
.collect(Collectors.toMap(
|
||||
Map.Entry::getKey,
|
||||
v -> v.getValue().getItemStack()));
|
||||
}
|
||||
|
||||
/**
|
||||
* returns the associated itemstack with the item key, use for finding without namespace
|
||||
* @param registryName
|
||||
* @return
|
||||
*/
|
||||
public ItemStack getOrNull(String registryName) {
|
||||
return itemRegistry.get(registryName(registryName)).getItemStack().clone();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* returns the associated itemstack with the item key, use for finding with namespace
|
||||
* @param registryName
|
||||
* @return
|
||||
*/
|
||||
public ItemStack getOrNullNamespace(String registryName) {
|
||||
return itemRegistry.get(registryName).getItemStack().clone();
|
||||
}
|
||||
|
||||
/**
|
||||
* returns the associated IWarItem with the item key, use for finding with namespace
|
||||
* @param registryName
|
||||
* @return
|
||||
*/
|
||||
public IWarItem getWarItem(String registryName) {
|
||||
return itemRegistry.get(registryName);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,62 @@
|
||||
package me.ShermansWorld.AlathraWar.items;
|
||||
|
||||
import me.ShermansWorld.AlathraWar.AlathraWarLogger;
|
||||
import me.ShermansWorld.AlathraWar.Helper;
|
||||
import me.ShermansWorld.AlathraWar.Main;
|
||||
import me.ShermansWorld.AlathraWar.War;
|
||||
import me.ShermansWorld.AlathraWar.items.item.RamItem;
|
||||
import org.bukkit.inventory.Recipe;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Set;
|
||||
|
||||
public class WarRecipeRegistry {
|
||||
|
||||
private static WarRecipeRegistry instance;
|
||||
|
||||
private static final HashMap<String, Recipe> recipeRegistry = new HashMap<>();
|
||||
|
||||
public WarRecipeRegistry() {
|
||||
instance = this;
|
||||
|
||||
Main.warLogger.log(Helper.chatLabel() + "Registering AlathraWar recipes.");
|
||||
|
||||
// register(WarItemRegistry.registryName("ram"), new RamItem().getRecipes());
|
||||
|
||||
Main.warLogger.log(Helper.chatLabel() + "Registered AlathraWar recipes.");
|
||||
}
|
||||
|
||||
public void register(String name, Set<Recipe> recipes) {
|
||||
for (Recipe recipe : recipes) {
|
||||
// Bukkit.getServer().addRecipe(recipe);
|
||||
recipeRegistry.put(name, recipe);
|
||||
}
|
||||
}
|
||||
|
||||
public static WarRecipeRegistry getInstance() {
|
||||
return instance;
|
||||
}
|
||||
|
||||
public HashMap<String, Recipe> getRecipeRegistry() {
|
||||
return recipeRegistry;
|
||||
}
|
||||
|
||||
/**
|
||||
* returns the associated itemstack with the item key, use for finding without namespace
|
||||
* @param registryName recipe name without namespace
|
||||
* @return recipe
|
||||
*/
|
||||
public Recipe getOrNull(String registryName) {
|
||||
return recipeRegistry.get(WarItemRegistry.registryName(registryName));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* returns the associated itemstack with the item key, use for finding with namespace
|
||||
* @param registryName registry name including namespace
|
||||
* @return recipe
|
||||
*/
|
||||
public Recipe getOrNullNamespace(String registryName) {
|
||||
return recipeRegistry.get(registryName);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
package me.ShermansWorld.AlathraWar.items.item;
|
||||
|
||||
import me.ShermansWorld.AlathraWar.Main;
|
||||
import me.ShermansWorld.AlathraWar.items.IWarItem;
|
||||
import me.ShermansWorld.AlathraWar.items.WarItemRegistry;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.NamespacedKey;
|
||||
import org.bukkit.Tag;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.Recipe;
|
||||
import org.bukkit.inventory.RecipeChoice;
|
||||
import org.bukkit.inventory.ShapedRecipe;
|
||||
import org.bukkit.inventory.meta.ItemMeta;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Set;
|
||||
|
||||
public class RamItem implements IWarItem {
|
||||
|
||||
public ItemStack getItemStack() {
|
||||
|
||||
ItemStack ram = new ItemStack(Material.WOODEN_HOE);
|
||||
ItemMeta meta = ram.getItemMeta();
|
||||
|
||||
meta.setDisplayName("Door Ram");
|
||||
ArrayList<String> lore = new ArrayList<String>();
|
||||
meta.setLore(lore);
|
||||
meta.setCustomModelData(14700);
|
||||
|
||||
ram.setItemMeta(meta);
|
||||
|
||||
return ram;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Recipe getRecipe() {
|
||||
ItemStack output = WarItemRegistry.getInstance().getOrNull("ram");
|
||||
NamespacedKey key = new NamespacedKey(Main.getInstance(), "ram");
|
||||
ShapedRecipe recipe = new ShapedRecipe(key, output);
|
||||
recipe.shape("$@$", "B##");
|
||||
recipe.setIngredient('@', Material.STICK);
|
||||
recipe.setIngredient('$', Material.IRON_INGOT);
|
||||
recipe.setIngredient('B', Material.IRON_BLOCK);
|
||||
recipe.setIngredient('%', new RecipeChoice.MaterialChoice(Tag.LOGS));
|
||||
return recipe;
|
||||
}
|
||||
}
|
||||
@@ -31,6 +31,7 @@ public class BlockBreakListener implements Listener {
|
||||
|
||||
@EventHandler
|
||||
public void onBlockBreak(final BlockBreakEvent event) {
|
||||
|
||||
final Block block = event.getBlock();
|
||||
if (SiegeData.getSieges().isEmpty() && RaidData.getRaids().isEmpty()) {
|
||||
return;
|
||||
@@ -45,6 +46,9 @@ public class BlockBreakListener implements Listener {
|
||||
return;
|
||||
}
|
||||
Player p = event.getPlayer();
|
||||
if(p.hasPermission("AlathraWar.break")) {
|
||||
return;
|
||||
}
|
||||
if (WorldCoord.parseWorldCoord(block).getTownOrNull() != null) {
|
||||
for (final Siege siege : SiegeData.getSieges()) {
|
||||
if (siege.getTown() == WorldCoord.parseWorldCoord(block).getTownOrNull()) {
|
||||
@@ -74,6 +78,9 @@ public class BlockBreakListener implements Listener {
|
||||
return;
|
||||
}
|
||||
Player p = event.getPlayer();
|
||||
if(p.hasPermission("AlathraWar.place")) {
|
||||
return;
|
||||
}
|
||||
if (WorldCoord.parseWorldCoord(block).getTownOrNull() != null) {
|
||||
for (final Siege siege : SiegeData.getSieges()) {
|
||||
if (siege.getTown() == WorldCoord.parseWorldCoord(block).getTownOrNull()) {
|
||||
|
||||
@@ -3,9 +3,9 @@ package me.ShermansWorld.AlathraWar.listeners;
|
||||
import me.ShermansWorld.AlathraWar.Helper;
|
||||
import me.ShermansWorld.AlathraWar.Raid;
|
||||
import me.ShermansWorld.AlathraWar.Siege;
|
||||
import me.ShermansWorld.AlathraWar.War;
|
||||
import me.ShermansWorld.AlathraWar.data.RaidData;
|
||||
import me.ShermansWorld.AlathraWar.data.RaidPhase;
|
||||
import me.ShermansWorld.AlathraWar.data.WarData;
|
||||
import me.ShermansWorld.AlathraWar.data.SiegeData;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
@@ -61,19 +61,18 @@ public class CommandsListener implements Listener {
|
||||
|
||||
allow n spawn and t spawn for defenders trapped in spawn
|
||||
*/
|
||||
for (War war : WarData.getWars()) {
|
||||
for (Raid raid : war.getRaids()) {
|
||||
//Only do this during regular phases, start and end ignored in case something breaks
|
||||
if (raid.getPhase() == RaidPhase.COMBAT || raid.getPhase() == RaidPhase.TRAVEL || raid.getPhase() == RaidPhase.GATHER) {
|
||||
//only do for active raiders and any defenders
|
||||
if (raid.getActiveRaiders().contains(p.getName()) || raid.getDefenderPlayers().contains(p.getName())) {
|
||||
//set spawn and properties
|
||||
if (args.length >= 3) {
|
||||
String parse = (args[0].charAt(0) == '/' ? args[0].substring(1) : args[0]) + " " + args[1] + " " + args[2];
|
||||
for (String prefix : prefixesTowny) {
|
||||
//payment check
|
||||
for (String cmd : blacklistedXLong) {
|
||||
if (parse.equals(prefix + (prefix.isEmpty() ? "" : ":") + cmd)) {
|
||||
for (Raid raid : RaidData.getRaids()) {
|
||||
//Only do this during regular phases, start and end ignored in case something breaks
|
||||
if (raid.getPhase() == RaidPhase.COMBAT || raid.getPhase() == RaidPhase.TRAVEL || raid.getPhase() == RaidPhase.GATHER) {
|
||||
//only do for active raiders and any defenders
|
||||
if (raid.getActiveRaiders().contains(p.getName()) || raid.getDefenderPlayers().contains(p.getName())) {
|
||||
//set spawn and properties
|
||||
if (args.length >= 3) {
|
||||
String parse = (args[0].charAt(0) == '/' ? args[0].substring(1) : args[0]) + " " + args[1] + " " + args[2];
|
||||
for (String prefix : prefixesTowny) {
|
||||
//payment check
|
||||
for (String cmd : blacklistedXLong) {
|
||||
if (parse.equalsIgnoreCase(prefix + (prefix.isEmpty() ? "" : ":") + cmd)) {
|
||||
p.sendMessage(String.valueOf(Helper.chatLabel()) + Helper.color("&cYou cannot modify this property during a raid!"));
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
@@ -89,7 +88,7 @@ public class CommandsListener implements Listener {
|
||||
//payment check
|
||||
for (String cmd : payment) {
|
||||
//check for each prefix
|
||||
if (parse.equals(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!"));
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
@@ -98,13 +97,13 @@ public class CommandsListener implements Listener {
|
||||
|
||||
for (String cmd : blacklistedLong) {
|
||||
//check for each prefix
|
||||
if (parse.equals(prefix + (prefix.isEmpty() ? "" : ":") + cmd)) {
|
||||
if (parse.equalsIgnoreCase(prefix + (prefix.isEmpty() ? "" : ":") + cmd)) {
|
||||
//check if in spawn
|
||||
if (p.getWorld().getName().equals("world")) {
|
||||
if (parse.equals("n spawn") || parse.equals("nat spawn") || parse.equals("nation spawn")
|
||||
|| parse.equals("t spawn") || parse.equals("town spawn")
|
||||
|| parse.equals("towny:n spawn") || parse.equals("towny:nat spawn") || parse.equals("towny:nation spawn")
|
||||
|| parse.equals("towny:t spawn") || parse.equals("towny:town spawn")) {
|
||||
if (p.getWorld().getName().equalsIgnoreCase("world")) {
|
||||
if (parse.equalsIgnoreCase("n spawn") || parse.equalsIgnoreCase("nat spawn") || parse.equalsIgnoreCase("nation spawn")
|
||||
|| parse.equalsIgnoreCase("t spawn") || parse.equalsIgnoreCase("town spawn")
|
||||
|| parse.equalsIgnoreCase("towny:n spawn") || parse.equalsIgnoreCase("towny:nat spawn") || parse.equalsIgnoreCase("towny:nation spawn")
|
||||
|| parse.equalsIgnoreCase("towny:t spawn") || parse.equalsIgnoreCase("towny:town spawn")) {
|
||||
p.sendMessage(String.valueOf(Helper.chatLabel()) + Helper.color("&eYou are stuck in spawn and are allowed to teleport to your town or nation."));
|
||||
return;
|
||||
}
|
||||
@@ -129,9 +128,9 @@ public class CommandsListener implements Listener {
|
||||
for (String prefix : prefixes) {
|
||||
for (String cmd : blacklistedShort) {
|
||||
//check for each prefix
|
||||
if (parse.equals(prefix + (prefix.isEmpty() ? "" : ":") + cmd)) {
|
||||
if (parse.equalsIgnoreCase(prefix + (prefix.isEmpty() ? "" : ":") + cmd)) {
|
||||
//spawn world check
|
||||
if (p.getWorld().getName().equals("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(String.valueOf(Helper.chatLabel()) + Helper.color("&eUse /t spawn, or /n spawn"));
|
||||
event.setCancelled(true);
|
||||
@@ -152,18 +151,18 @@ public class CommandsListener implements Listener {
|
||||
/*
|
||||
Prevent players from teleporting during a siege
|
||||
*/
|
||||
for (Siege siege : war.getSieges()) {
|
||||
//Only do this during regular phases, start and end ignored in case something breaks
|
||||
if (siege.getSiegeTicks() > 0) {
|
||||
//only do for active raiders and any defenders
|
||||
if (siege.getAttackerPlayers().contains(p.getName()) || siege.getDefenderPlayers().contains(p.getName())) {
|
||||
//set spawn and properties
|
||||
if (args.length >= 3) {
|
||||
String parse = (args[0].charAt(0) == '/' ? args[0].substring(1) : args[0]) + " " + args[1] + " " + args[2];
|
||||
for (String prefix : prefixesTowny) {
|
||||
//payment check
|
||||
for (String cmd : blacklistedXLong) {
|
||||
if (parse.equals(prefix + (prefix.isEmpty() ? "" : ":") + cmd)) {
|
||||
for (Siege siege : SiegeData.getSieges()) {
|
||||
//Only do this during regular phases, start and end ignored in case something breaks
|
||||
if (siege.getSiegeTicks() > 0) {
|
||||
//only do for active raiders and any defenders
|
||||
if (siege.getAttackerPlayers().contains(p.getName()) || siege.getDefenderPlayers().contains(p.getName())) {
|
||||
//set spawn and properties
|
||||
if (args.length >= 3) {
|
||||
String parse = (args[0].charAt(0) == '/' ? args[0].substring(1) : args[0]) + " " + args[1] + " " + args[2];
|
||||
for (String prefix : prefixesTowny) {
|
||||
//payment check
|
||||
for (String cmd : blacklistedXLong) {
|
||||
if (parse.equalsIgnoreCase(prefix + (prefix.isEmpty() ? "" : ":") + cmd)) {
|
||||
p.sendMessage(String.valueOf(Helper.chatLabel()) + Helper.color("&cYou cannot modify this property during a siege!"));
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
@@ -179,8 +178,8 @@ public class CommandsListener implements Listener {
|
||||
//payment check
|
||||
for (String cmd : payment) {
|
||||
//check for each prefix
|
||||
if (parse.equals(prefix + (prefix.isEmpty() ? "" : ":") + cmd)) {
|
||||
p.sendMessage(String.valueOf(Helper.chatLabel()) + Helper.color("&cYou cannot withdraw money whilst in a siege!"));
|
||||
if (parse.equalsIgnoreCase(prefix + (prefix.isEmpty() ? "" : ":") + cmd)) {
|
||||
p.sendMessage(Helper.chatLabel() + Helper.color("&cYou cannot withdraw money whilst in a siege!"));
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
@@ -188,24 +187,24 @@ public class CommandsListener implements Listener {
|
||||
|
||||
for (String cmd : blacklistedLong) {
|
||||
//check for each prefix
|
||||
if (parse.equals(prefix + (prefix.isEmpty() ? "" : ":") + cmd)) {
|
||||
if (parse.equalsIgnoreCase(prefix + (prefix.isEmpty() ? "" : ":") + cmd)) {
|
||||
//check if in spawn
|
||||
if (p.getWorld().getName().equals("world")) {
|
||||
if (parse.equals("n spawn") || parse.equals("nat spawn") || parse.equals("nation spawn")
|
||||
|| parse.equals("t spawn") || parse.equals("town spawn")
|
||||
|| parse.equals("towny:n spawn") || parse.equals("towny:nat spawn") || parse.equals("towny:nation spawn")
|
||||
|| parse.equals("towny:t spawn") || parse.equals("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."));
|
||||
if (p.getWorld().getName().equalsIgnoreCase("world")) {
|
||||
if (parse.equalsIgnoreCase("n spawn") || parse.equalsIgnoreCase("nat spawn") || parse.equalsIgnoreCase("nation spawn")
|
||||
|| parse.equalsIgnoreCase("t spawn") || parse.equalsIgnoreCase("town spawn")
|
||||
|| parse.equalsIgnoreCase("towny:n spawn") || parse.equalsIgnoreCase("towny:nat spawn") || parse.equalsIgnoreCase("towny:nation spawn")
|
||||
|| parse.equalsIgnoreCase("towny:t spawn") || parse.equalsIgnoreCase("towny:town spawn")) {
|
||||
p.sendMessage(Helper.chatLabel() + Helper.color("&eYou are stuck in spawn and are allowed to teleport to your town or nation."));
|
||||
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(String.valueOf(Helper.chatLabel()) + Helper.color("&eUse /t spawn, or /n spawn"));
|
||||
p.sendMessage(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("&eUse /t spawn, or /n spawn"));
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
|
||||
//else
|
||||
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);
|
||||
return;
|
||||
}
|
||||
@@ -219,9 +218,9 @@ public class CommandsListener implements Listener {
|
||||
for (String prefix : prefixes) {
|
||||
for (String cmd : blacklistedShort) {
|
||||
//check for each prefix
|
||||
if (parse.equals(prefix + (prefix.isEmpty() ? "" : ":") + cmd)) {
|
||||
if (parse.equalsIgnoreCase(prefix + (prefix.isEmpty() ? "" : ":") + cmd)) {
|
||||
//spawn world check
|
||||
if (p.getWorld().getName().equals("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(String.valueOf(Helper.chatLabel()) + Helper.color("&eUse /t spawn, or /n spawn"));
|
||||
event.setCancelled(true);
|
||||
@@ -237,7 +236,7 @@ public class CommandsListener implements Listener {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -28,10 +28,10 @@ public class JoinListener implements Listener {
|
||||
String townName = town.getName();
|
||||
boolean inWar = false;
|
||||
for (final War war : WarData.getWars()) {
|
||||
if (war.getSide1Towns().contains(townName)) {
|
||||
if (war.getSide1Towns().contains(townName.toLowerCase())) {
|
||||
TABHook.assignSide1WarSuffix(p, war);
|
||||
inWar = true;
|
||||
} else if (war.getSide2Towns().contains(townName)) {
|
||||
} else if (war.getSide2Towns().contains(townName.toLowerCase())) {
|
||||
TABHook.assignSide2WarSuffix(p, war);
|
||||
inWar = true;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,170 @@
|
||||
package me.ShermansWorld.AlathraWar.listeners;
|
||||
|
||||
import com.palmergames.bukkit.towny.object.TownBlock;
|
||||
import com.palmergames.bukkit.towny.object.WorldCoord;
|
||||
import me.ShermansWorld.AlathraWar.Helper;
|
||||
import me.ShermansWorld.AlathraWar.Main;
|
||||
import me.ShermansWorld.AlathraWar.Raid;
|
||||
import me.ShermansWorld.AlathraWar.Siege;
|
||||
import me.ShermansWorld.AlathraWar.data.RaidData;
|
||||
import me.ShermansWorld.AlathraWar.data.SiegeData;
|
||||
import me.ShermansWorld.AlathraWar.items.WarItemRegistry;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.data.Bisected;
|
||||
import org.bukkit.block.data.type.Door;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.block.Action;
|
||||
import org.bukkit.event.player.PlayerInteractEvent;
|
||||
import org.bukkit.event.player.PlayerItemDamageEvent;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public class PlayerInteractListener implements Listener {
|
||||
|
||||
//map of broken doors
|
||||
public Map<Location, Long> brokenDoors = new HashMap<Location, Long>();
|
||||
|
||||
/**
|
||||
* @param event event
|
||||
* @author DunnoConz
|
||||
* @author AubriTheHuman
|
||||
*/
|
||||
@EventHandler(priority = EventPriority.LOWEST)
|
||||
public void onPlayerInteract(final PlayerInteractEvent event) {
|
||||
Player player = event.getPlayer();
|
||||
Action action = event.getAction();
|
||||
|
||||
if (action == Action.LEFT_CLICK_BLOCK) {
|
||||
Block clicked = event.getClickedBlock();
|
||||
ItemStack item = player.getInventory().getItemInMainHand();
|
||||
if (clicked != null) {
|
||||
if (clicked.getType().toString().contains("DOOR")) { // left click + any door types
|
||||
Door door = (Door) clicked.getBlockData();
|
||||
// lock door in the opposite position
|
||||
if (item.equals(WarItemRegistry.getInstance().getOrNull("ram"))) {
|
||||
boolean inSiegeOrRaid = false;
|
||||
//siege check
|
||||
for (Siege s : SiegeData.getSieges()) {
|
||||
for (TownBlock townBlock : s.getTown().getTownBlocks()) {
|
||||
if (WorldCoord.parseWorldCoord(clicked).equals(townBlock.getWorldCoord())) {
|
||||
// if we find one, just end no need to continue
|
||||
inSiegeOrRaid = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//if it wasnt in a siege, then
|
||||
if (!inSiegeOrRaid) {
|
||||
for (Raid r : RaidData.getRaids()) {
|
||||
for (TownBlock townBlock : r.getRaidedTown().getTownBlocks()) {
|
||||
if (WorldCoord.parseWorldCoord(clicked).equals(townBlock.getWorldCoord())) {
|
||||
// if we find one, just end no need to continue
|
||||
inSiegeOrRaid = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (inSiegeOrRaid) {
|
||||
|
||||
// Returns if already broken.
|
||||
if (doorBroken(clicked, door)) {
|
||||
player.sendMessage(Helper.chatLabel() + Helper.color("&cThe door is already broken!"));
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
player.sendMessage(Helper.chatLabel() + Helper.color("&eBreak it down alright!"));
|
||||
brokenDoors.put(getDoorPos(clicked, door), System.currentTimeMillis() + (1000L * Main.getInstance().getConfig().getInt("batteringRamEffectiveness")));
|
||||
door.setOpen(!door.isOpen());
|
||||
clicked.setBlockData(door);
|
||||
player.getInventory().getItemInMainHand().setAmount(player.getInventory().getItemInMainHand().getAmount() - 1);
|
||||
Main.warLogger.log("User " + player.getName() + " has broken down door" + clicked.getLocation().toString());
|
||||
} else {
|
||||
player.sendMessage(Helper.chatLabel() + Helper.color("&cThis item can only be used in a siege or raid!"));
|
||||
}
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@EventHandler(priority = EventPriority.HIGHEST)
|
||||
public void onPlayerRClick(final PlayerItemDamageEvent event) {
|
||||
ItemStack item = event.getItem();
|
||||
if (item.equals(WarItemRegistry.getInstance().getOrNull("ram"))) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param event event
|
||||
* @author DunnoConz
|
||||
* @author AubriTheHuman
|
||||
*/
|
||||
@EventHandler(priority = EventPriority.LOWEST)
|
||||
public void onPlayerRClick(final PlayerInteractEvent event) {
|
||||
Player player = event.getPlayer();
|
||||
Action action = event.getAction();
|
||||
Block clicked = event.getClickedBlock();
|
||||
ItemStack item = player.getInventory().getItemInMainHand();
|
||||
if (action == Action.RIGHT_CLICK_BLOCK) {
|
||||
if (clicked != null) {
|
||||
if (clicked.getType().toString().contains("DOOR")) {
|
||||
Door door = (Door) clicked.getBlockData();
|
||||
if (doorBroken(clicked, door)) {
|
||||
player.sendMessage(Helper.chatLabel() + Helper.color("Door is broken!"));
|
||||
event.setCancelled(true);
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (item.equals(WarItemRegistry.getInstance().getOrNull("ram"))) {
|
||||
if (clicked != null) {
|
||||
if (clicked.getType().name().equals("GRASS_BLOCK")
|
||||
|| clicked.getType().name().equals("DIRT")
|
||||
|| clicked.getType().name().equals("COARSE_DIRT")
|
||||
|| clicked.getType().name().equals("ROOTED_DIRT")
|
||||
|| clicked.getType().name().equals("DIRT_PATH")) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private Location getDoorPos(Block clicked, Door door) {
|
||||
if(door.getHalf() == Bisected.Half.BOTTOM) {
|
||||
return clicked.getLocation().clone();
|
||||
} else if(door.getHalf() == Bisected.Half.TOP) {
|
||||
return clicked.getLocation().subtract(0.0, 1.0, 0.0).clone();
|
||||
}
|
||||
return clicked.getLocation().clone();
|
||||
}
|
||||
|
||||
private boolean doorBroken(@Nonnull Block clicked, Door door) {
|
||||
if(door.getHalf() == Bisected.Half.BOTTOM) {
|
||||
if(brokenDoors.get(clicked.getLocation()) != null) {
|
||||
return brokenDoors.get(clicked.getLocation()) > System.currentTimeMillis();
|
||||
}
|
||||
} else if(door.getHalf() == Bisected.Half.TOP) {
|
||||
if(brokenDoors.get(clicked.getLocation().subtract(0.0, 1.0D, 0.0)) != null) {
|
||||
return brokenDoors.get(clicked.getLocation().subtract(0.0, 1.0D, 0.0)) > System.currentTimeMillis();
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user