major refactor of the purging process
This commit is contained in:
+3
-11
@@ -3,6 +3,7 @@ package fr.xephi.authme.command.executable.authme;
|
||||
import fr.xephi.authme.AuthMe;
|
||||
import fr.xephi.authme.command.ExecutableCommand;
|
||||
import fr.xephi.authme.datasource.DataSource;
|
||||
import fr.xephi.authme.process.purge.PurgeService;
|
||||
import fr.xephi.authme.task.PurgeTask;
|
||||
import fr.xephi.authme.util.BukkitService;
|
||||
import org.bukkit.ChatColor;
|
||||
@@ -21,10 +22,7 @@ import java.util.Set;
|
||||
public class PurgeBannedPlayersCommand implements ExecutableCommand {
|
||||
|
||||
@Inject
|
||||
private DataSource dataSource;
|
||||
|
||||
@Inject
|
||||
private AuthMe plugin;
|
||||
private PurgeService purgeService;
|
||||
|
||||
@Inject
|
||||
private BukkitService bukkitService;
|
||||
@@ -38,12 +36,6 @@ public class PurgeBannedPlayersCommand implements ExecutableCommand {
|
||||
namedBanned.add(offlinePlayer.getName().toLowerCase());
|
||||
}
|
||||
|
||||
//todo: note this should may run async because it may executes a SQL-Query
|
||||
// Purge the banned players
|
||||
dataSource.purgeBanned(namedBanned);
|
||||
|
||||
// Show a status message
|
||||
sender.sendMessage(ChatColor.GOLD + "Purging user accounts...");
|
||||
new PurgeTask(plugin, sender, namedBanned, bannedPlayers).runTaskTimer(plugin, 0, 1);
|
||||
purgeService.purgeBanned(sender, namedBanned, bannedPlayers);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@ package fr.xephi.authme.command.executable.authme;
|
||||
import fr.xephi.authme.AuthMe;
|
||||
import fr.xephi.authme.command.ExecutableCommand;
|
||||
import fr.xephi.authme.datasource.DataSource;
|
||||
import fr.xephi.authme.process.purge.PurgeService;
|
||||
import fr.xephi.authme.task.PurgeTask;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
@@ -21,7 +22,7 @@ public class PurgeCommand implements ExecutableCommand {
|
||||
private static final int MINIMUM_LAST_SEEN_DAYS = 30;
|
||||
|
||||
@Inject
|
||||
private DataSource dataSource;
|
||||
private PurgeService purgeService;
|
||||
|
||||
@Inject
|
||||
private AuthMe plugin;
|
||||
@@ -52,13 +53,7 @@ public class PurgeCommand implements ExecutableCommand {
|
||||
calendar.add(Calendar.DATE, -days);
|
||||
long until = calendar.getTimeInMillis();
|
||||
|
||||
//todo: note this should may run async because it may executes a SQL-Query
|
||||
// Purge the data, get the purged values
|
||||
Set<String> purged = dataSource.autoPurgeDatabase(until);
|
||||
|
||||
// Show a status message
|
||||
sender.sendMessage(ChatColor.GOLD + "Deleted " + purged.size() + " user accounts");
|
||||
sender.sendMessage(ChatColor.GOLD + "Purging user accounts...");
|
||||
new PurgeTask(plugin, sender, purged).runTaskTimer(plugin, 0, 1);
|
||||
// Run the purge
|
||||
purgeService.runPurge(sender, until);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user