mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2024-11-23 05:36:46 +01:00
Helpful logging!
This commit is contained in:
parent
6d9ef91315
commit
b554fb342a
@ -201,10 +201,10 @@ public class mcMMO extends JavaPlugin {
|
||||
//Old & Powerless User remover
|
||||
int purgeInterval = Config.getInstance().getPurgeInterval();
|
||||
if (purgeInterval == 0) {
|
||||
scheduler.runTask(this, new UserPurgeTask());
|
||||
scheduler.runTask(this, new UserPurgeTask(this));
|
||||
}
|
||||
else if (purgeInterval > 0) {
|
||||
scheduler.scheduleSyncRepeatingTask(this, new UserPurgeTask(), 0, purgeInterval * 60L * 60L * 20L);
|
||||
scheduler.scheduleSyncRepeatingTask(this, new UserPurgeTask(this), 0, purgeInterval * 60L * 60L * 20L);
|
||||
}
|
||||
|
||||
registerCommands();
|
||||
|
@ -4,17 +4,22 @@ import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.config.Config;
|
||||
import com.gmail.nossr50.util.Database;
|
||||
|
||||
public class UserPurgeTask implements Runnable {
|
||||
|
||||
private Plugin plugin;
|
||||
private Database database = mcMMO.getPlayerDatabase();
|
||||
private String tablePrefix = Config.getInstance().getMySQLTablePrefix();
|
||||
private String databaseName = Config.getInstance().getMySQLDatabaseName();
|
||||
|
||||
public UserPurgeTask(Plugin plugin) {
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
if (Config.getInstance().getUseMySQL()) {
|
||||
@ -28,9 +33,10 @@ public class UserPurgeTask implements Runnable {
|
||||
|
||||
private void purgePowerlessSQL() {
|
||||
String query = "taming+mining+woodcutting+repair+unarmed+herbalism+excavation+archery+swords+axes+acrobatics+fishing";
|
||||
|
||||
HashMap<Integer, ArrayList<String>> userslist = database.read("SELECT " + query + ", user_id FROM " + tablePrefix + "skills WHERE " + query + " > 0 ORDER BY " + query + " DESC ");
|
||||
|
||||
int purgedUsers = 0;
|
||||
|
||||
for (int i = 1; i <= userslist.size(); i++) {
|
||||
int userId = Integer.valueOf(userslist.get(i).get(1));
|
||||
HashMap<Integer, ArrayList<String>> username = database.read("SELECT user FROM " + tablePrefix + "users WHERE id = '" + userId + "'");
|
||||
@ -40,14 +46,18 @@ public class UserPurgeTask implements Runnable {
|
||||
}
|
||||
|
||||
deleteFromSQL(userId);
|
||||
purgedUsers++;
|
||||
}
|
||||
|
||||
plugin.getLogger().info("Purged " + purgedUsers + "users from the database.");
|
||||
}
|
||||
|
||||
private void purgeOldSQL() {
|
||||
String query = "taming+mining+woodcutting+repair+unarmed+herbalism+excavation+archery+swords+axes+acrobatics+fishing";
|
||||
|
||||
HashMap<Integer, ArrayList<String>> userslist = database.read("SELECT " + query + ", user_id FROM " + tablePrefix + "skills WHERE " + query + " > 0 ORDER BY " + query + " DESC ");
|
||||
|
||||
int purgedUsers = 0;
|
||||
|
||||
for (int i = 1; i <= userslist.size(); i++) {
|
||||
int userId = Integer.valueOf(userslist.get(i).get(1));
|
||||
long lastLoginTime = database.getInt("SELECT lastlogin FROM " + tablePrefix + "users WHERE id = '" + userId + "'") * 1000L;
|
||||
@ -55,8 +65,11 @@ public class UserPurgeTask implements Runnable {
|
||||
|
||||
if (loginDifference > 2630000000L) {
|
||||
deleteFromSQL(userId);
|
||||
purgedUsers++;
|
||||
}
|
||||
}
|
||||
|
||||
plugin.getLogger().info("Purged " + purgedUsers + "users from the database.");
|
||||
}
|
||||
|
||||
private void deleteFromSQL(int userId) {
|
||||
|
Loading…
Reference in New Issue
Block a user