mirror of
https://github.com/darksaid98/AlathranWars.git
synced 2026-12-01 14:38:55 +00:00
Minuteman command changes and overrides
This commit is contained in:
1 parent
2aa106b29c
commit
d5bf05e0ec
7 files changed
+144
-11
No files matched your search
@@ -0,0 +1,2 @@
|
||||
#Minimum time in days a player must have joined ago to join any war or event.
|
||||
minimumPlayerAge: 4
|
||||
@@ -20,6 +20,8 @@ import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.sql.Timestamp;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
public class AdminCommands implements CommandExecutor {
|
||||
@@ -321,16 +323,17 @@ public class AdminCommands implements CommandExecutor {
|
||||
} else if (args[1].equalsIgnoreCase("join")) {
|
||||
if (args.length >= 3) {
|
||||
if (args[2].equalsIgnoreCase("raid")) {
|
||||
if (args.length >= 6) {
|
||||
if (args.length >= 8) {
|
||||
//fix args
|
||||
String[] adjusted = new String[]{
|
||||
List<String> adjusted = List.of(new String[]{
|
||||
args[1], //join
|
||||
args[4], //war
|
||||
args[5], //town
|
||||
args[3], //player
|
||||
args.length >= 7 ? args[6] : null //side
|
||||
};
|
||||
RaidCommands.joinRaid(p, adjusted, true);
|
||||
args[3], //player // override
|
||||
});
|
||||
adjusted.add(args[6]);
|
||||
adjusted.add(args[7]);
|
||||
RaidCommands.joinRaid(p, (String[]) adjusted.toArray(), true);
|
||||
return true;
|
||||
} else {
|
||||
p.sendMessage(Helper.color("&cUsage: /alathrawaradmin force join raid [player] [war] [town] (side)"));
|
||||
@@ -338,19 +341,21 @@ public class AdminCommands implements CommandExecutor {
|
||||
return true;
|
||||
} else if (args[2].equalsIgnoreCase("siege")) {
|
||||
if (args.length >= 6) {
|
||||
//TODO
|
||||
p.sendMessage(Helper.color("&cError! Unimplemented!"));
|
||||
} else {
|
||||
p.sendMessage(Helper.color("&cUsage: /alathrawaradmin force join siege [player] [war] [town] (side)"));
|
||||
}
|
||||
return true;
|
||||
} else if (args[2].equalsIgnoreCase("war")) {
|
||||
if (args.length >= 6) {
|
||||
if (args.length >= 7) {
|
||||
//fix args to match
|
||||
String[] adjusted = new String[]{
|
||||
args[1],
|
||||
args[4],
|
||||
args[5],
|
||||
args[3]
|
||||
args[3],
|
||||
args[6]
|
||||
};
|
||||
if (Bukkit.getPlayer(args[3]) != null) {
|
||||
} else {
|
||||
|
||||
@@ -278,7 +278,11 @@ public class AdminTabCompletion implements TabCompleter {
|
||||
if (args.length > 5) {
|
||||
if (args.length > 6) {
|
||||
if (args.length > 7) {
|
||||
return empty;
|
||||
if (args.length > 8) {
|
||||
return empty;
|
||||
} else {
|
||||
return NameUtil.filterByStart(List.of(new String[] { "true","false" }), args[6]);
|
||||
}
|
||||
} else {
|
||||
return NameUtil.filterByStart(CommandHelper.getWarSides(args[4]), args[6]);
|
||||
}
|
||||
@@ -296,7 +300,11 @@ public class AdminTabCompletion implements TabCompleter {
|
||||
if (args.length > 5) {
|
||||
if (args.length > 6) {
|
||||
if (args.length > 7) {
|
||||
return empty;
|
||||
if (args.length > 8) {
|
||||
return empty;
|
||||
} else {
|
||||
return NameUtil.filterByStart(List.of(new String[] { "true","false" }), args[6]);
|
||||
}
|
||||
} else {
|
||||
return NameUtil.filterByStart(CommandHelper.getWarSides(args[4]), args[6]);
|
||||
}
|
||||
@@ -313,7 +321,11 @@ public class AdminTabCompletion implements TabCompleter {
|
||||
if (args.length > 4) {
|
||||
if (args.length > 5) {
|
||||
if (args.length > 6) {
|
||||
return empty;
|
||||
if (args.length > 7) {
|
||||
return empty;
|
||||
} else {
|
||||
return NameUtil.filterByStart(List.of(new String[] { "true","false" }), args[6]);
|
||||
}
|
||||
} else {
|
||||
return NameUtil.filterByStart(CommandHelper.getWarSides(args[4]), args[5]);
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@ package me.ShermansWorld.AlathraWar.commands;
|
||||
import com.palmergames.bukkit.towny.TownyAPI;
|
||||
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;
|
||||
@@ -192,4 +193,9 @@ public class CommandHelper {
|
||||
}
|
||||
return out;
|
||||
}
|
||||
|
||||
public static long getPlayerJoinDate(String player) {
|
||||
Resident res = TownyAPI.getInstance().getResident(player);
|
||||
return res.getRegistered();
|
||||
}
|
||||
}
|
||||
@@ -8,6 +8,7 @@ import me.ShermansWorld.AlathraWar.*;
|
||||
import me.ShermansWorld.AlathraWar.data.RaidPhase;
|
||||
import me.ShermansWorld.AlathraWar.data.WarData;
|
||||
import me.ShermansWorld.AlathraWar.data.RaidData;
|
||||
import net.md_5.bungee.api.ChatColor;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.command.Command;
|
||||
@@ -93,6 +94,27 @@ public class RaidCommands implements CommandExecutor {
|
||||
return;
|
||||
}
|
||||
|
||||
//Minutemen countermeasures, 86400 * 4 time. 86400 seconds in a day, 4 days min playtime
|
||||
if (admin) {
|
||||
if (System.currentTimeMillis() - CommandHelper.getPlayerJoinDate(args[3]) < 86400000L * Main.getInstance().getConfig().getInt("minimumPlayerAge") ) {
|
||||
if(args.length >= 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.");
|
||||
raidOwner.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 (System.currentTimeMillis() - CommandHelper.getPlayerJoinDate(p.getName()) < 86400000 * 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;
|
||||
}
|
||||
}
|
||||
|
||||
//check if in a town
|
||||
//takes the command runners town as the gather point
|
||||
Town gatherTown = null;
|
||||
@@ -321,10 +343,39 @@ public class RaidCommands implements CommandExecutor {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (!raid.getWar().getSide1Players().contains(joiner.getName()) && !raid.getWar().getSide2Players().contains(joiner.getName())) {
|
||||
joiner.sendMessage(String.valueOf(Helper.Chatlabel()) + "You are not in this war! Type /war join [war] [side]");
|
||||
}
|
||||
|
||||
//Minutemen countermeasures, 86400 * 4 time. 86400 seconds in a day, 4 days min playtime
|
||||
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 {
|
||||
//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 (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;
|
||||
}
|
||||
}
|
||||
|
||||
//check if gather phase
|
||||
if (raid.getPhase() == RaidPhase.GATHER || raid.getPhase() == RaidPhase.START) {
|
||||
try {
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package me.ShermansWorld.AlathraWar.commands;
|
||||
|
||||
import net.md_5.bungee.api.ChatColor;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import com.palmergames.bukkit.towny.TownyAPI;
|
||||
import me.ShermansWorld.AlathraWar.Helper;
|
||||
@@ -96,6 +97,34 @@ public class SiegeCommands implements CommandExecutor {
|
||||
return;
|
||||
}
|
||||
|
||||
//Minutemen countermeasures, 86400 * 4 time. 86400 seconds in a day, 4 days min playtime
|
||||
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
|
||||
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.");
|
||||
player.getPlayer().sendMessage(ChatColor.RED + "You have joined the server too recently! You can only join a war after 4 days from joining.");
|
||||
return;
|
||||
}
|
||||
} 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.");
|
||||
player.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 (System.currentTimeMillis() - CommandHelper.getPlayerJoinDate(player.getName()) < 86400000L * Main.getInstance().getConfig().getInt("minimumPlayerAge") ) {
|
||||
//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.");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// Town check
|
||||
Town town = TownyAPI.getInstance().getTown(args[2]);
|
||||
if (town == null) {
|
||||
|
||||
@@ -148,6 +148,34 @@ public class WarCommands implements CommandExecutor {
|
||||
return;
|
||||
}
|
||||
|
||||
//Minutemen countermeasures, 86400 * 4 time. 86400 seconds in a day, 4 days min playtime
|
||||
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 {
|
||||
//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 (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;
|
||||
}
|
||||
}
|
||||
|
||||
// Side checks
|
||||
int side = war.getSide(town.getName().toLowerCase());
|
||||
if (side == -1) {
|
||||
|
||||
Reference in new issue
Block a user