mirror of
https://github.com/darksaid98/AlathranWars.git
synced 2026-12-03 14:38:56 +00:00
Minuteman updates to include playtime clause
This commit is contained in:
1 parent
392ff18aaa
commit
a01b7e909d
6 files changed
+119
-80
No files matched your search
@@ -1,4 +1,8 @@
|
|||||||
#Minimum time in days a player must have joined ago to join any war or event.
|
#Minimum time in days a player must have joined ago to join any war or event.
|
||||||
|
#Set to 0 to disable check
|
||||||
minimumPlayerAge: 4
|
minimumPlayerAge: 4
|
||||||
#how long should a bettering ram open a door (in seconds)
|
#Minimum playtime in hours a player must have in hours to join a war/siege/raid
|
||||||
batteringRamEffectiveness: 600
|
#Set to 0 to disable check
|
||||||
|
minimumPlayTime: 12
|
||||||
|
#How long should a bettering ram open a door (in seconds)
|
||||||
|
batteringRamEffectiveness: 10
|
||||||
@@ -245,8 +245,8 @@ public class War {
|
|||||||
Town town = TownyAPI.getInstance().getTown(townString);
|
Town town = TownyAPI.getInstance().getTown(townString);
|
||||||
if (town != null) {
|
if (town != null) {
|
||||||
for (Resident res : town.getResidents()) {
|
for (Resident res : town.getResidents()) {
|
||||||
//Minuteman countermeasure!
|
//Minuteman countermeasure! if they are they get skipped
|
||||||
if (System.currentTimeMillis() - CommandHelper.getPlayerJoinDate(res.getName()) > 86400000L * Main.getInstance().getConfig().getInt("minimumPlayerAge") ) {
|
if (CommandHelper.isPlayerMinuteman(res.getName()) == 0) {
|
||||||
returnList.add(res.getName());
|
returnList.add(res.getName());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ import me.ShermansWorld.AlathraWar.data.SiegeData;
|
|||||||
import me.ShermansWorld.AlathraWar.data.WarData;
|
import me.ShermansWorld.AlathraWar.data.WarData;
|
||||||
import me.ShermansWorld.AlathraWar.items.WarItems;
|
import me.ShermansWorld.AlathraWar.items.WarItems;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.Statistic;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
@@ -194,9 +195,31 @@ public class CommandHelper {
|
|||||||
return out;
|
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);
|
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 true;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected static boolean logCommand(CommandSender sender, String label, String[] args) {
|
protected static boolean logCommand(CommandSender sender, String label, String[] args) {
|
||||||
|
|||||||
@@ -97,24 +97,32 @@ public class RaidCommands implements CommandExecutor {
|
|||||||
return;
|
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 (admin) {
|
||||||
if (System.currentTimeMillis() - CommandHelper.getPlayerJoinDate(raidOwner.getName()) < 86400000L * Main.getInstance().getConfig().getInt("minimumPlayerAge") ) {
|
if (args.length >= 6) {
|
||||||
if(args.length >= 5) {
|
if (Boolean.parseBoolean(args[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!");
|
||||||
} else {
|
override = true;
|
||||||
//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(raidOwner.getName()) < 86400000L * Main.getInstance().getConfig().getInt("minimumPlayerAge") ) {
|
//override?
|
||||||
//player has joined to recently
|
if(!override) {
|
||||||
p.sendMessage(ChatColor.RED + "You have joined the server too recently! You can only join a war after 4 days from joining.");
|
if (minuteman != 0) {
|
||||||
return;
|
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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -387,30 +395,31 @@ 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
|
||||||
|
//also 12 hours min platim by default
|
||||||
|
int minuteman = CommandHelper.isPlayerMinuteman(joiner.getName());
|
||||||
|
boolean override = false;
|
||||||
if (admin) {
|
if (admin) {
|
||||||
if (System.currentTimeMillis() - CommandHelper.getPlayerJoinDate(args[3]) < 86400000L * Main.getInstance().getConfig().getInt("minimumPlayerAge") ) {
|
if (args.length >= 6) {
|
||||||
if(args.length >= 6) {
|
if (Boolean.parseBoolean(args[5])) {
|
||||||
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
|
//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 + "Warning! Ignoring Minuteman Countermeasure!");
|
||||||
joiner.getPlayer().sendMessage(ChatColor.RED + "You have joined the server too recently! You can only join a war after 4 days from joining.");
|
override = true;
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
}
|
||||||
if (System.currentTimeMillis() - CommandHelper.getPlayerJoinDate(joiner.getName()) < 86400000L * Main.getInstance().getConfig().getInt("minimumPlayerAge") ) {
|
if(!override) {
|
||||||
//player has joined to recently
|
if (minuteman != 0) {
|
||||||
p.sendMessage(ChatColor.RED + "You have joined the server too recently! You can only join a war after 4 days from joining.");
|
if (minuteman == 1) {
|
||||||
return;
|
//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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -120,30 +120,32 @@ public class SiegeCommands 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
|
||||||
|
//Minuteman countermeasures
|
||||||
|
int minuteman = CommandHelper.isPlayerMinuteman(siegeOwner.getName());
|
||||||
|
boolean override = false;
|
||||||
if (admin) {
|
if (admin) {
|
||||||
if (System.currentTimeMillis() - CommandHelper.getPlayerJoinDate(siegeOwner.getName()) < 86400000L * Main.getInstance().getConfig().getInt("minimumPlayerAge") ) {
|
if (args.length >= 6) {
|
||||||
if(args.length >= 5) {
|
if (Boolean.parseBoolean(args[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 {
|
|
||||||
//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 + "Warning! Ignoring Minuteman Countermeasure!");
|
||||||
siegeOwner.getPlayer().sendMessage(ChatColor.RED + "You have joined the server too recently! You can only join a war after 4 days from joining.");
|
override = true;
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
}
|
||||||
if (System.currentTimeMillis() - CommandHelper.getPlayerJoinDate(siegeOwner.getName()) < 86400000L * Main.getInstance().getConfig().getInt("minimumPlayerAge") ) {
|
//override?
|
||||||
//player has joined to recently
|
if(!override) {
|
||||||
siegeOwner.sendMessage(ChatColor.RED + "You have joined the server too recently! You can only join a war after 4 days from joining.");
|
if (minuteman != 0) {
|
||||||
return;
|
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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -167,31 +167,32 @@ public class WarCommands implements CommandExecutor {
|
|||||||
return;
|
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 (admin) {
|
||||||
if (System.currentTimeMillis() - CommandHelper.getPlayerJoinDate(args[3]) < 86400000L * Main.getInstance().getConfig().getInt("minimumPlayerAge") ) {
|
if (args.length >= 6) {
|
||||||
if(args.length >= 5) {
|
if (Boolean.parseBoolean(args[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
|
//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 + "Warning! Ignoring Minuteman Countermeasure!");
|
||||||
res.getPlayer().sendMessage(ChatColor.RED + "You have joined the server too recently! You can only join a war after 4 days from joining.");
|
override = true;
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
}
|
||||||
if (System.currentTimeMillis() - CommandHelper.getPlayerJoinDate(p.getName()) < 86400000L * Main.getInstance().getConfig().getInt("minimumPlayerAge") ) {
|
//override?
|
||||||
//player has joined to recently
|
if(!override) {
|
||||||
p.sendMessage(ChatColor.RED + "You have joined the server too recently! You can only join a war after 4 days from joining.");
|
if (minuteman != 0) {
|
||||||
return;
|
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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user