Add Support to 1.7.9/1.7.10 (remove lag spikes)
This commit is contained in:
parent
0b55e48b85
commit
b8fbd30bfe
@ -110,6 +110,7 @@ public class AuthMe extends JavaPlugin {
|
|||||||
public boolean antibotMod = false;
|
public boolean antibotMod = false;
|
||||||
public boolean delayedAntiBot = true;
|
public boolean delayedAntiBot = true;
|
||||||
protected static String vgUrl = "http://monitor-1.verygames.net/api/?action=ipclean-real-ip&out=raw&ip=%IP%&port=%PORT%";
|
protected static String vgUrl = "http://monitor-1.verygames.net/api/?action=ipclean-real-ip&out=raw&ip=%IP%&port=%PORT%";
|
||||||
|
public DataManager dataManager;
|
||||||
|
|
||||||
public Settings getSettings() {
|
public Settings getSettings() {
|
||||||
return settings;
|
return settings;
|
||||||
@ -328,6 +329,9 @@ public class AuthMe extends JavaPlugin {
|
|||||||
// Start Email recall task if needed
|
// Start Email recall task if needed
|
||||||
recallEmail();
|
recallEmail();
|
||||||
|
|
||||||
|
dataManager = new DataManager(this, database);
|
||||||
|
dataManager.start();
|
||||||
|
|
||||||
ConsoleLogger.info("Authme " + this.getDescription().getVersion() + " enabled");
|
ConsoleLogger.info("Authme " + this.getDescription().getVersion() + " enabled");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -485,7 +489,13 @@ public class AuthMe extends JavaPlugin {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (databaseThread != null) {
|
if (databaseThread != null) {
|
||||||
databaseThread.interrupt();
|
if (databaseThread.isAlive())
|
||||||
|
databaseThread.interrupt();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (dataManager != null) {
|
||||||
|
if (dataManager.isAlive())
|
||||||
|
dataManager.interrupt();
|
||||||
}
|
}
|
||||||
|
|
||||||
if(Settings.isBackupActivated && Settings.isBackupOnStop) {
|
if(Settings.isBackupActivated && Settings.isBackupOnStop) {
|
||||||
@ -620,80 +630,13 @@ public class AuthMe extends JavaPlugin {
|
|||||||
if (cleared.isEmpty())
|
if (cleared.isEmpty())
|
||||||
return;
|
return;
|
||||||
if (Settings.purgeEssentialsFile && this.ess != null)
|
if (Settings.purgeEssentialsFile && this.ess != null)
|
||||||
purgeEssentials(cleared);
|
dataManager.purgeEssentials(cleared);
|
||||||
if (Settings.purgePlayerDat)
|
if (Settings.purgePlayerDat)
|
||||||
purgeDat(cleared);
|
dataManager.purgeDat(cleared);
|
||||||
if (Settings.purgeLimitedCreative)
|
if (Settings.purgeLimitedCreative)
|
||||||
purgeLimitedCreative(cleared);
|
dataManager.purgeLimitedCreative(cleared);
|
||||||
if (Settings.purgeAntiXray)
|
if (Settings.purgeAntiXray)
|
||||||
purgeAntiXray(cleared);
|
dataManager.purgeAntiXray(cleared);
|
||||||
}
|
|
||||||
|
|
||||||
public void purgeAntiXray(List<String> cleared) {
|
|
||||||
int i = 0;
|
|
||||||
for (String name : cleared) {
|
|
||||||
org.bukkit.OfflinePlayer player = Bukkit.getOfflinePlayer(name);
|
|
||||||
if (player == null) continue;
|
|
||||||
String playerName = player.getName();
|
|
||||||
File playerFile = new File("." + File.separator + "plugins" + File.separator + "AntiXRayData" + File.separator + "PlayerData" + File.separator + playerName);
|
|
||||||
if (playerFile.exists()) {
|
|
||||||
playerFile.delete();
|
|
||||||
i++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
ConsoleLogger.info("AutoPurgeDatabase : Remove " + i + " AntiXRayData Files");
|
|
||||||
}
|
|
||||||
|
|
||||||
public void purgeLimitedCreative(List<String> cleared) {
|
|
||||||
int i = 0;
|
|
||||||
for (String name : cleared) {
|
|
||||||
org.bukkit.OfflinePlayer player = Bukkit.getOfflinePlayer(name);
|
|
||||||
if (player == null) continue;
|
|
||||||
String playerName = player.getName();
|
|
||||||
File playerFile = new File("." + File.separator + "plugins" + File.separator + "LimitedCreative" + File.separator + "inventories" + File.separator + playerName + ".yml");
|
|
||||||
if (playerFile.exists()) {
|
|
||||||
playerFile.delete();
|
|
||||||
i++;
|
|
||||||
}
|
|
||||||
playerFile = new File("." + File.separator + "plugins" + File.separator + "LimitedCreative" + File.separator + "inventories" + File.separator + playerName + "_creative.yml");
|
|
||||||
if (playerFile.exists()) {
|
|
||||||
playerFile.delete();
|
|
||||||
i++;
|
|
||||||
}
|
|
||||||
playerFile = new File("." + File.separator + "plugins" + File.separator + "LimitedCreative" + File.separator + "inventories" + File.separator + playerName + "_adventure.yml");
|
|
||||||
if (playerFile.exists()) {
|
|
||||||
playerFile.delete();
|
|
||||||
i++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
ConsoleLogger.info("AutoPurgeDatabase : Remove " + i + " LimitedCreative Survival, Creative and Adventure files");
|
|
||||||
}
|
|
||||||
|
|
||||||
public void purgeDat(List<String> cleared) {
|
|
||||||
int i = 0;
|
|
||||||
for (String name : cleared) {
|
|
||||||
org.bukkit.OfflinePlayer player = Bukkit.getOfflinePlayer(name);
|
|
||||||
if (player == null) continue;
|
|
||||||
String playerName = player.getName();
|
|
||||||
File playerFile = new File (this.getServer().getWorldContainer() + File.separator + Settings.defaultWorld + File.separator + "players" + File.separator + playerName + ".dat");
|
|
||||||
if (playerFile.exists()) {
|
|
||||||
playerFile.delete();
|
|
||||||
i++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
ConsoleLogger.info("AutoPurgeDatabase : Remove " + i + " .dat Files");
|
|
||||||
}
|
|
||||||
|
|
||||||
public void purgeEssentials(List<String> cleared) {
|
|
||||||
int i = 0;
|
|
||||||
for (String name : cleared) {
|
|
||||||
File playerFile = new File(this.ess.getDataFolder() + File.separator + "userdata" + File.separator + name + ".yml");
|
|
||||||
if (playerFile.exists()) {
|
|
||||||
playerFile.delete();
|
|
||||||
i++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
ConsoleLogger.info("AutoPurgeDatabase : Remove " + i + " EssentialsFiles");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public Location getSpawnLocation(Player player) {
|
public Location getSpawnLocation(Player player) {
|
||||||
|
|||||||
108
src/main/java/fr/xephi/authme/DataManager.java
Normal file
108
src/main/java/fr/xephi/authme/DataManager.java
Normal file
@ -0,0 +1,108 @@
|
|||||||
|
package fr.xephi.authme;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.OfflinePlayer;
|
||||||
|
|
||||||
|
import fr.xephi.authme.datasource.DataSource;
|
||||||
|
import fr.xephi.authme.settings.Settings;
|
||||||
|
|
||||||
|
public class DataManager extends Thread {
|
||||||
|
|
||||||
|
public AuthMe plugin;
|
||||||
|
public DataSource database;
|
||||||
|
|
||||||
|
public DataManager(AuthMe plugin, DataSource database) {
|
||||||
|
this.plugin = plugin;
|
||||||
|
this.database = database;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void run() {}
|
||||||
|
|
||||||
|
public OfflinePlayer getOfflinePlayer(String name) {
|
||||||
|
OfflinePlayer result = null;
|
||||||
|
try {
|
||||||
|
if (org.bukkit.Bukkit.class.getMethod("getOfflinePlayer", new Class[]{String.class}).isAnnotationPresent(Deprecated.class)) {
|
||||||
|
for (OfflinePlayer op : Bukkit.getOfflinePlayers())
|
||||||
|
if (op.getName().equalsIgnoreCase(name)) {
|
||||||
|
result = op;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
result = Bukkit.getOfflinePlayer(name);
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
result = Bukkit.getOfflinePlayer(name);
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void purgeAntiXray(List<String> cleared) {
|
||||||
|
int i = 0;
|
||||||
|
for (String name : cleared) {
|
||||||
|
org.bukkit.OfflinePlayer player = getOfflinePlayer(name);
|
||||||
|
if (player == null) continue;
|
||||||
|
String playerName = player.getName();
|
||||||
|
File playerFile = new File("." + File.separator + "plugins" + File.separator + "AntiXRayData" + File.separator + "PlayerData" + File.separator + playerName);
|
||||||
|
if (playerFile.exists()) {
|
||||||
|
playerFile.delete();
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
ConsoleLogger.info("AutoPurgeDatabase : Remove " + i + " AntiXRayData Files");
|
||||||
|
}
|
||||||
|
|
||||||
|
public void purgeLimitedCreative(List<String> cleared) {
|
||||||
|
int i = 0;
|
||||||
|
for (String name : cleared) {
|
||||||
|
org.bukkit.OfflinePlayer player = getOfflinePlayer(name);
|
||||||
|
if (player == null) continue;
|
||||||
|
String playerName = player.getName();
|
||||||
|
File playerFile = new File("." + File.separator + "plugins" + File.separator + "LimitedCreative" + File.separator + "inventories" + File.separator + playerName + ".yml");
|
||||||
|
if (playerFile.exists()) {
|
||||||
|
playerFile.delete();
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
playerFile = new File("." + File.separator + "plugins" + File.separator + "LimitedCreative" + File.separator + "inventories" + File.separator + playerName + "_creative.yml");
|
||||||
|
if (playerFile.exists()) {
|
||||||
|
playerFile.delete();
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
playerFile = new File("." + File.separator + "plugins" + File.separator + "LimitedCreative" + File.separator + "inventories" + File.separator + playerName + "_adventure.yml");
|
||||||
|
if (playerFile.exists()) {
|
||||||
|
playerFile.delete();
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
ConsoleLogger.info("AutoPurgeDatabase : Remove " + i + " LimitedCreative Survival, Creative and Adventure files");
|
||||||
|
}
|
||||||
|
|
||||||
|
public void purgeDat(List<String> cleared) {
|
||||||
|
int i = 0;
|
||||||
|
for (String name : cleared) {
|
||||||
|
org.bukkit.OfflinePlayer player = getOfflinePlayer(name);
|
||||||
|
if (player == null) continue;
|
||||||
|
String playerName = player.getName();
|
||||||
|
File playerFile = new File (plugin.getServer().getWorldContainer() + File.separator + Settings.defaultWorld + File.separator + "players" + File.separator + playerName + ".dat");
|
||||||
|
if (playerFile.exists()) {
|
||||||
|
playerFile.delete();
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
ConsoleLogger.info("AutoPurgeDatabase : Remove " + i + " .dat Files");
|
||||||
|
}
|
||||||
|
|
||||||
|
public void purgeEssentials(List<String> cleared) {
|
||||||
|
int i = 0;
|
||||||
|
for (String name : cleared) {
|
||||||
|
File playerFile = new File(plugin.ess.getDataFolder() + File.separator + "userdata" + File.separator + name + ".yml");
|
||||||
|
if (playerFile.exists()) {
|
||||||
|
playerFile.delete();
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
ConsoleLogger.info("AutoPurgeDatabase : Remove " + i + " EssentialsFiles");
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -161,7 +161,7 @@ public class API {
|
|||||||
*/
|
*/
|
||||||
public static String getPlayerRealName(String nickname) {
|
public static String getPlayerRealName(String nickname) {
|
||||||
try {
|
try {
|
||||||
String realName = Bukkit.getOfflinePlayer(nickname).getName();
|
String realName = instance.dataManager.getOfflinePlayer(nickname).getName();
|
||||||
if (realName != null && !realName.isEmpty())
|
if (realName != null && !realName.isEmpty())
|
||||||
return realName;
|
return realName;
|
||||||
} catch (NullPointerException npe) {}
|
} catch (NullPointerException npe) {}
|
||||||
|
|||||||
@ -111,13 +111,13 @@ public class AdminCommand implements CommandExecutor {
|
|||||||
List<String> purged = database.autoPurgeDatabase(until);
|
List<String> purged = database.autoPurgeDatabase(until);
|
||||||
sender.sendMessage("Deleted " + purged.size() + " user accounts");
|
sender.sendMessage("Deleted " + purged.size() + " user accounts");
|
||||||
if (Settings.purgeEssentialsFile && plugin.ess != null)
|
if (Settings.purgeEssentialsFile && plugin.ess != null)
|
||||||
plugin.purgeEssentials(purged);
|
plugin.dataManager.purgeEssentials(purged);
|
||||||
if (Settings.purgePlayerDat)
|
if (Settings.purgePlayerDat)
|
||||||
plugin.purgeDat(purged);
|
plugin.dataManager.purgeDat(purged);
|
||||||
if (Settings.purgeLimitedCreative)
|
if (Settings.purgeLimitedCreative)
|
||||||
plugin.purgeLimitedCreative(purged);
|
plugin.dataManager.purgeLimitedCreative(purged);
|
||||||
if (Settings.purgeAntiXray)
|
if (Settings.purgeAntiXray)
|
||||||
plugin.purgeAntiXray(purged);
|
plugin.dataManager.purgeAntiXray(purged);
|
||||||
return true;
|
return true;
|
||||||
} catch (NumberFormatException e) {
|
} catch (NumberFormatException e) {
|
||||||
sender.sendMessage("Usage: /authme purge <DAYS>");
|
sender.sendMessage("Usage: /authme purge <DAYS>");
|
||||||
@ -369,13 +369,13 @@ public class AdminCommand implements CommandExecutor {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
if (Settings.purgeEssentialsFile && plugin.ess != null)
|
if (Settings.purgeEssentialsFile && plugin.ess != null)
|
||||||
plugin.purgeEssentials(bannedPlayers);
|
plugin.dataManager.purgeEssentials(bannedPlayers);
|
||||||
if (Settings.purgePlayerDat)
|
if (Settings.purgePlayerDat)
|
||||||
plugin.purgeDat(bannedPlayers);
|
plugin.dataManager.purgeDat(bannedPlayers);
|
||||||
if (Settings.purgeLimitedCreative)
|
if (Settings.purgeLimitedCreative)
|
||||||
plugin.purgeLimitedCreative(bannedPlayers);
|
plugin.dataManager.purgeLimitedCreative(bannedPlayers);
|
||||||
if (Settings.purgeAntiXray)
|
if (Settings.purgeAntiXray)
|
||||||
plugin.purgeAntiXray(bannedPlayers);
|
plugin.dataManager.purgeAntiXray(bannedPlayers);
|
||||||
return true;
|
return true;
|
||||||
} else if (args[0].equalsIgnoreCase("spawn")) {
|
} else if (args[0].equalsIgnoreCase("spawn")) {
|
||||||
try {
|
try {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user