mirror of
https://github.com/darksaid98/AlathranWars.git
synced 2026-12-04 06:28:51 +00:00
finalize creation of events through console
This commit is contained in:
1 parent
6c6828f7fa
commit
95175f1057
4 files changed
+63
-45
No files matched your search
@@ -144,6 +144,7 @@ public class AdminCommands implements CommandExecutor {
|
|||||||
//specific behavior exists if an admin ran this
|
//specific behavior exists if an admin ran this
|
||||||
//using same method so that this doesnt get fucked up if we go back and change original implementation
|
//using same method so that this doesnt get fucked up if we go back and change original implementation
|
||||||
RaidCommands.startRaid(p, args, true);
|
RaidCommands.startRaid(p, args, true);
|
||||||
|
p.sendMessage(Helper.color("&cForcefully started raid from the console."));
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
//defaultCode will bypass the custom gather town to force set owner
|
//defaultCode will bypass the custom gather town to force set owner
|
||||||
@@ -157,10 +158,12 @@ public class AdminCommands implements CommandExecutor {
|
|||||||
"start",
|
"start",
|
||||||
args[2],
|
args[2],
|
||||||
args[3],
|
args[3],
|
||||||
args[4]
|
args[4],
|
||||||
|
args[5]
|
||||||
};
|
};
|
||||||
SiegeCommands.siegeStart(p, adjusted, true);
|
SiegeCommands.siegeStart(p, adjusted, true);
|
||||||
p.sendMessage(Helper.Chatlabel() + "Try again later!");
|
// p.sendMessage(Helper.Chatlabel() + "Try again later!");
|
||||||
|
p.sendMessage(Helper.color("&cForcefully started siege from the console."));
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
p.sendMessage(Helper.color("&cUsage: /alathrawaradmin create siege [war] [town] (owner)"));
|
p.sendMessage(Helper.color("&cUsage: /alathrawaradmin create siege [war] [town] (owner)"));
|
||||||
@@ -177,6 +180,7 @@ public class AdminCommands implements CommandExecutor {
|
|||||||
args[4]
|
args[4]
|
||||||
};
|
};
|
||||||
WarCommands.warCreate(p, adjusted);
|
WarCommands.warCreate(p, adjusted);
|
||||||
|
p.sendMessage(Helper.color("&cForcefully started war from the console."));
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
p.sendMessage(Helper.color("&cUsage: /alathrawaradmin create war [name] [side1] [side2]"));
|
p.sendMessage(Helper.color("&cUsage: /alathrawaradmin create war [name] [side1] [side2]"));
|
||||||
|
|||||||
@@ -26,33 +26,33 @@ public class RaidCommands implements CommandExecutor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public boolean onCommand(final CommandSender sender, final Command cmd, final String label, final String[] args) {
|
public boolean onCommand(final CommandSender sender, final Command cmd, final String label, final String[] args) {
|
||||||
final Player p = (Player) sender;
|
// final Player p = (Player) sender;
|
||||||
if (args.length == 0) {
|
if (args.length == 0) {
|
||||||
fail(p, args, "syntax");
|
fail(sender, args, "syntax");
|
||||||
} else if (args.length == 1) {
|
} else if (args.length == 1) {
|
||||||
if (args[0].equalsIgnoreCase("list")) {
|
if (args[0].equalsIgnoreCase("list")) {
|
||||||
listRaids(p, args);
|
listRaids(sender, args);
|
||||||
} else if (args[0].equalsIgnoreCase("help")) {
|
} else if (args[0].equalsIgnoreCase("help")) {
|
||||||
raidHelp(p, args);
|
raidHelp(sender, args);
|
||||||
} else {
|
} else {
|
||||||
fail(p, args, "syntax");
|
fail(sender, args, "syntax");
|
||||||
}
|
}
|
||||||
}else if (args.length == 3) {
|
}else if (args.length == 3) {
|
||||||
if (args[0].equalsIgnoreCase("start")) {
|
if (args[0].equalsIgnoreCase("start")) {
|
||||||
startRaid(p, args, false);
|
startRaid(sender, args, false);
|
||||||
} else if (args[0].equalsIgnoreCase("stop")) {
|
} else if (args[0].equalsIgnoreCase("stop")) {
|
||||||
stopRaid(p, args);
|
stopRaid(sender, args);
|
||||||
} else if (args[0].equalsIgnoreCase("join")) {
|
} else if (args[0].equalsIgnoreCase("join")) {
|
||||||
joinRaid(p, args, false);
|
joinRaid(sender, args, false);
|
||||||
} else if (args[0].equalsIgnoreCase("leave")) {
|
} else if (args[0].equalsIgnoreCase("leave")) {
|
||||||
leaveRaid(p, args, false);
|
leaveRaid(sender, args, false);
|
||||||
} else if (args[0].equalsIgnoreCase("abandon")) {
|
} else if (args[0].equalsIgnoreCase("abandon")) {
|
||||||
abandonRaid(p, args);
|
abandonRaid(sender, args);
|
||||||
} else {
|
} else {
|
||||||
fail(p, args, "syntax");
|
fail(sender, args, "syntax");
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
fail(p, args, "syntax");
|
fail(sender, args, "syntax");
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -72,14 +72,9 @@ public class RaidCommands implements CommandExecutor {
|
|||||||
warFound = true;
|
warFound = true;
|
||||||
|
|
||||||
Player raidOwner = null;
|
Player raidOwner = null;
|
||||||
if(p instanceof Player) {
|
if((p instanceof Player)) {
|
||||||
raidOwner = (Player) p;
|
raidOwner = (Player) p;
|
||||||
} else {
|
|
||||||
p.sendMessage("Running this from the console requires a Player Argument!");
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
TownyWorld townyWorld;
|
|
||||||
townyWorld = WorldCoord.parseWorldCoord(raidOwner.getLocation()).getTownyWorld();
|
|
||||||
if(admin && args.length >= 6) {
|
if(admin && args.length >= 6) {
|
||||||
raidOwner = Bukkit.getPlayer(args[5]);
|
raidOwner = Bukkit.getPlayer(args[5]);
|
||||||
if(raidOwner == null) {
|
if(raidOwner == null) {
|
||||||
@@ -88,10 +83,13 @@ public class RaidCommands implements CommandExecutor {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TownyWorld townyWorld;
|
||||||
|
townyWorld = WorldCoord.parseWorldCoord(raidOwner.getLocation()).getTownyWorld();
|
||||||
|
|
||||||
String side = "";
|
String side = "";
|
||||||
if (war.getSide1Players().contains(p.getName())) {
|
if (war.getSide1Players().contains(raidOwner.getName())) {
|
||||||
side = war.getSide1();
|
side = war.getSide1();
|
||||||
} else if (war.getSide2Players().contains(p.getName())) {
|
} else if (war.getSide2Players().contains(raidOwner.getName())) {
|
||||||
side = war.getSide2();
|
side = war.getSide2();
|
||||||
} else {
|
} else {
|
||||||
p.sendMessage(String.valueOf(Helper.Chatlabel()) + "You are not in this war! Type /war join [war] [side]");
|
p.sendMessage(String.valueOf(Helper.Chatlabel()) + "You are not in this war! Type /war join [war] [side]");
|
||||||
@@ -100,7 +98,7 @@ public class RaidCommands implements CommandExecutor {
|
|||||||
|
|
||||||
//Minutemen countermeasures, 86400 * 4 time. 86400 seconds in a day, 4 days min playtime
|
//Minutemen countermeasures, 86400 * 4 time. 86400 seconds in a day, 4 days min playtime
|
||||||
if (admin) {
|
if (admin) {
|
||||||
if (System.currentTimeMillis() - CommandHelper.getPlayerJoinDate(args[3]) < 86400000L * Main.getInstance().getConfig().getInt("minimumPlayerAge") ) {
|
if (System.currentTimeMillis() - CommandHelper.getPlayerJoinDate(raidOwner.getName()) < 86400000L * Main.getInstance().getConfig().getInt("minimumPlayerAge") ) {
|
||||||
if(args.length >= 5) {
|
if(args.length >= 5) {
|
||||||
//player has joined to recently
|
//player has joined to recently
|
||||||
p.sendMessage(ChatColor.RED + "Warning! Ignoring Minuteman Countermeasure!");
|
p.sendMessage(ChatColor.RED + "Warning! Ignoring Minuteman Countermeasure!");
|
||||||
@@ -112,7 +110,7 @@ public class RaidCommands implements CommandExecutor {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (System.currentTimeMillis() - CommandHelper.getPlayerJoinDate(p.getName()) < 86400000 * Main.getInstance().getConfig().getInt("minimumPlayerAge") ) {
|
if (System.currentTimeMillis() - CommandHelper.getPlayerJoinDate(raidOwner.getName()) < 86400000L * Main.getInstance().getConfig().getInt("minimumPlayerAge") ) {
|
||||||
//player has joined to recently
|
//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.");
|
p.sendMessage(ChatColor.RED + "You have joined the server too recently! You can only join a war after 4 days from joining.");
|
||||||
return;
|
return;
|
||||||
@@ -179,7 +177,7 @@ public class RaidCommands implements CommandExecutor {
|
|||||||
townExists = true;
|
townExists = true;
|
||||||
|
|
||||||
Raid raid2;
|
Raid raid2;
|
||||||
if (war.getSide1Players().contains(p.getName())) {
|
if (war.getSide1Players().contains(raidOwner.getName())) {
|
||||||
//Time and raid activity validity check
|
//Time and raid activity validity check
|
||||||
int c = RaidData.isValidRaid(war, side, raidedTown);
|
int c = RaidData.isValidRaid(war, side, raidedTown);
|
||||||
if (c == 2) {
|
if (c == 2) {
|
||||||
@@ -206,7 +204,7 @@ public class RaidCommands implements CommandExecutor {
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
//Something broke if this runs
|
//Something broke if this runs
|
||||||
if (!war.getSide2Players().contains(p.getName())) {
|
if (!war.getSide2Players().contains(raidOwner.getName())) {
|
||||||
Bukkit.getLogger().info("Unable to find player declaring raid in the war");
|
Bukkit.getLogger().info("Unable to find player declaring raid in the war");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -392,7 +390,7 @@ public class RaidCommands implements CommandExecutor {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (System.currentTimeMillis() - CommandHelper.getPlayerJoinDate(p.getName()) < 86400000L * Main.getInstance().getConfig().getInt("minimumPlayerAge") ) {
|
if (System.currentTimeMillis() - CommandHelper.getPlayerJoinDate(joiner.getName()) < 86400000L * Main.getInstance().getConfig().getInt("minimumPlayerAge") ) {
|
||||||
//player has joined to recently
|
//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.");
|
p.sendMessage(ChatColor.RED + "You have joined the server too recently! You can only join a war after 4 days from joining.");
|
||||||
return;
|
return;
|
||||||
|
|||||||
@@ -60,13 +60,19 @@ public class SiegeCommands implements CommandExecutor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected static void siegeStart(CommandSender sender, String[] args, boolean admin) {
|
protected static void siegeStart(CommandSender sender, String[] args, boolean admin) {
|
||||||
if (!(sender instanceof Player)) return;
|
// if (!(sender instanceof Player)) return;
|
||||||
//if this is admin mode use the forth arg instad of sender.
|
//if this is admin mode use the forth arg instad of sender.
|
||||||
//if player is null after this then force end
|
//if player is null after this then force end
|
||||||
Player player = !admin ? (Player) sender : args.length >= 4 ? Bukkit.getPlayer(args[3]) : null;
|
Player siegeOwner = null;
|
||||||
if(player == null) {
|
if((sender instanceof Player)) {
|
||||||
sender.sendMessage("Forced owner not found!");
|
siegeOwner = (Player) sender;
|
||||||
return;
|
}
|
||||||
|
if(admin && args.length >= 5) {
|
||||||
|
siegeOwner = Bukkit.getPlayer(args[3]);
|
||||||
|
if(siegeOwner == null) {
|
||||||
|
sender.sendMessage("Player Does not exist");
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (args.length < 3) {
|
if (args.length < 3) {
|
||||||
@@ -77,27 +83,27 @@ public class SiegeCommands implements CommandExecutor {
|
|||||||
// War check
|
// War check
|
||||||
War war = WarData.getWar(args[1]);
|
War war = WarData.getWar(args[1]);
|
||||||
if (war == null) {
|
if (war == null) {
|
||||||
player.sendMessage(String.valueOf(Helper.Chatlabel()) + "That war does not exist! /siege start [war] [town]");
|
siegeOwner.sendMessage(String.valueOf(Helper.Chatlabel()) + "That war does not exist! /siege start [war] [town]");
|
||||||
if(admin) sender.sendMessage(String.valueOf(Helper.Chatlabel()) + "That war does not exist! /siege start [war] [town]");
|
if(admin) sender.sendMessage(String.valueOf(Helper.Chatlabel()) + "That war does not exist! /siege start [war] [town]");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Player participance check
|
// Player participance check
|
||||||
Town leaderTown = TownyAPI.getInstance().getResident(player).getTownOrNull();
|
Town leaderTown = TownyAPI.getInstance().getResident(siegeOwner).getTownOrNull();
|
||||||
int side = war.getSide(leaderTown.getName());
|
int side = war.getSide(leaderTown.getName());
|
||||||
if (side == 0) {
|
if (side == 0) {
|
||||||
player.sendMessage(Helper.Chatlabel() + "You are not in this war.");
|
siegeOwner.sendMessage(Helper.Chatlabel() + "You are not in this war.");
|
||||||
if(admin) sender.sendMessage(Helper.Chatlabel() + "You are not in this war.");
|
if(admin) sender.sendMessage(Helper.Chatlabel() + "You are not in this war.");
|
||||||
return;
|
return;
|
||||||
} else if (side == -1) {
|
} else if (side == -1) {
|
||||||
player.sendMessage(Helper.Chatlabel() + "You have surrendered.");
|
siegeOwner.sendMessage(Helper.Chatlabel() + "You have surrendered.");
|
||||||
if(admin) sender.sendMessage(Helper.Chatlabel() + "You have surrendered.");
|
if(admin) sender.sendMessage(Helper.Chatlabel() + "You have surrendered.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
//Minutemen countermeasures, 86400 * 4 time. 86400 seconds in a day, 4 days min playtime
|
//Minutemen countermeasures, 86400 * 4 time. 86400 seconds in a day, 4 days min playtime
|
||||||
if (admin) {
|
if (admin) {
|
||||||
if (System.currentTimeMillis() - CommandHelper.getPlayerJoinDate(args[3]) < 86400000L * Main.getInstance().getConfig().getInt("minimumPlayerAge") ) {
|
if (System.currentTimeMillis() - CommandHelper.getPlayerJoinDate(siegeOwner.getName()) < 86400000L * Main.getInstance().getConfig().getInt("minimumPlayerAge") ) {
|
||||||
if(args.length >= 5) {
|
if(args.length >= 5) {
|
||||||
if (Boolean.parseBoolean(args[4])) {
|
if (Boolean.parseBoolean(args[4])) {
|
||||||
//player has joined to recently
|
//player has joined to recently
|
||||||
@@ -105,20 +111,20 @@ public class SiegeCommands implements CommandExecutor {
|
|||||||
} else {
|
} else {
|
||||||
//player has joined to recently
|
//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.");
|
sender.sendMessage(ChatColor.RED + "You have joined the server too recently! You can only join a war after 4 days from joining.");
|
||||||
player.getPlayer().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;
|
return;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
//player has joined to recently
|
//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.");
|
sender.sendMessage(ChatColor.RED + "You have joined the server too recently! You can only join a war after 4 days from joining.");
|
||||||
player.getPlayer().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;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (System.currentTimeMillis() - CommandHelper.getPlayerJoinDate(player.getName()) < 86400000L * Main.getInstance().getConfig().getInt("minimumPlayerAge") ) {
|
if (System.currentTimeMillis() - CommandHelper.getPlayerJoinDate(siegeOwner.getName()) < 86400000L * Main.getInstance().getConfig().getInt("minimumPlayerAge") ) {
|
||||||
//player has joined to recently
|
//player has joined to recently
|
||||||
player.sendMessage(ChatColor.RED + "You have joined the server too recently! You can only join a war after 4 days from joining.");
|
siegeOwner.sendMessage(ChatColor.RED + "You have joined the server too recently! You can only join a war after 4 days from joining.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -126,7 +132,7 @@ public class SiegeCommands implements CommandExecutor {
|
|||||||
// Town check
|
// Town check
|
||||||
Town town = TownyAPI.getInstance().getTown(args[2]);
|
Town town = TownyAPI.getInstance().getTown(args[2]);
|
||||||
if (town == null) {
|
if (town == null) {
|
||||||
player.sendMessage(String.valueOf(Helper.Chatlabel()) + "That town does not exist! /siege start [war] [town]");
|
siegeOwner.sendMessage(String.valueOf(Helper.Chatlabel()) + "That town does not exist! /siege start [war] [town]");
|
||||||
if(admin) sender.sendMessage(String.valueOf(Helper.Chatlabel()) + "That town does not exist! /siege start [war] [town]");
|
if(admin) sender.sendMessage(String.valueOf(Helper.Chatlabel()) + "That town does not exist! /siege start [war] [town]");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -134,19 +140,20 @@ public class SiegeCommands implements CommandExecutor {
|
|||||||
// Is being raided check
|
// Is being raided check
|
||||||
for ( Raid r : RaidData.getRaids()) {
|
for ( Raid r : RaidData.getRaids()) {
|
||||||
if(r.getRaidedTown().getName().equals(town.getName())) {
|
if(r.getRaidedTown().getName().equals(town.getName())) {
|
||||||
player.sendMessage(String.valueOf(Helper.Chatlabel()) + "That town is already currently being raided! Cannot siege at this time!");
|
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!");
|
if(admin) sender.sendMessage(String.valueOf(Helper.Chatlabel()) + "That town is already currently being raided! Cannot siege at this time!");
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Attacking own side
|
// Attacking own side
|
||||||
if (war.getSide(town) == side) {
|
if (war.getSide(town) == side) {
|
||||||
player.sendMessage(Helper.Chatlabel() + "You cannot attack your own towns.");
|
siegeOwner.sendMessage(Helper.Chatlabel() + "You cannot attack your own towns.");
|
||||||
if(admin) sender.sendMessage(Helper.Chatlabel() + "You cannot attack your own towns.");
|
if(admin) sender.sendMessage(Helper.Chatlabel() + "You cannot attack your own towns.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Siege siege = new Siege(war, town, player);
|
Siege siege = new Siege(war, town, siegeOwner);
|
||||||
SiegeData.addSiege(siege);
|
SiegeData.addSiege(siege);
|
||||||
war.addSiege(siege);
|
war.addSiege(siege);
|
||||||
|
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ import me.ShermansWorld.AlathraWar.Main;
|
|||||||
import me.ShermansWorld.AlathraWar.Raid;
|
import me.ShermansWorld.AlathraWar.Raid;
|
||||||
import me.ShermansWorld.AlathraWar.War;
|
import me.ShermansWorld.AlathraWar.War;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.NamespacedKey;
|
||||||
import org.bukkit.OfflinePlayer;
|
import org.bukkit.OfflinePlayer;
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
import javax.annotation.Nonnull;
|
||||||
@@ -19,10 +20,18 @@ public class RaidData {
|
|||||||
// Static Raid list for all active raids
|
// Static Raid list for all active raids
|
||||||
private static ArrayList<Raid> raids = new ArrayList<Raid>();
|
private static ArrayList<Raid> raids = new ArrayList<Raid>();
|
||||||
|
|
||||||
|
|
||||||
|
private static Set<NamespacedKey> raidBars = new HashSet<>();
|
||||||
|
|
||||||
|
public static Set<NamespacedKey> getRaidBars() {
|
||||||
|
return raidBars;
|
||||||
|
}
|
||||||
|
|
||||||
public static ArrayList<Raid> getRaids() {
|
public static ArrayList<Raid> getRaids() {
|
||||||
return raids;
|
return raids;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets a raid with a specific name
|
* Gets a raid with a specific name
|
||||||
*
|
*
|
||||||
|
|||||||
Reference in new issue
Block a user