#886 Do not include players with lastlogin = 0 in autopurge or default purge

This commit is contained in:
ljacqu
2016-09-18 16:49:34 +02:00
parent 405bd563d8
commit ff9f50f63f
12 changed files with 97 additions and 54 deletions
@@ -16,6 +16,9 @@ import java.util.Calendar;
import java.util.Collection;
import java.util.Set;
/**
* Initiates purge tasks.
*/
public class PurgeService {
@Inject
@@ -33,6 +36,7 @@ public class PurgeService {
@Inject
private PurgeExecutor purgeExecutor;
/** Keeps track of whether a purge task is currently running. */
private boolean isPurging = false;
PurgeService() {
@@ -55,7 +59,7 @@ public class PurgeService {
calendar.add(Calendar.DATE, -daysBeforePurge);
long until = calendar.getTimeInMillis();
runPurge(null, until);
runPurge(null, until, false);
}
/**
@@ -64,10 +68,11 @@ public class PurgeService {
*
* @param sender Sender running the command
* @param until The last login threshold in milliseconds
* @param includeEntriesWithLastLoginZero True to also purge players with lastlogin = 0, false otherwise
*/
public void runPurge(CommandSender sender, long until) {
public void runPurge(CommandSender sender, long until, boolean includeEntriesWithLastLoginZero) {
//todo: note this should may run async because it may executes a SQL-Query
Set<String> toPurge = dataSource.getRecordsToPurge(until);
Set<String> toPurge = dataSource.getRecordsToPurge(until, includeEntriesWithLastLoginZero);
if (CollectionUtils.isEmpty(toPurge)) {
logAndSendMessage(sender, "No players to purge");
return;