From 94451647f33c933f6826dc134c589ac10f3d11ce Mon Sep 17 00:00:00 2001 From: ljacqu Date: Thu, 16 Jun 2016 22:06:49 +0200 Subject: [PATCH] #674 #656 Delete DataManager - Replaced with PurgeService --- src/main/java/fr/xephi/authme/AuthMe.java | 3 - .../java/fr/xephi/authme/DataManager.java | 145 ------------------ 2 files changed, 148 deletions(-) delete mode 100644 src/main/java/fr/xephi/authme/DataManager.java diff --git a/src/main/java/fr/xephi/authme/AuthMe.java b/src/main/java/fr/xephi/authme/AuthMe.java index d9f9bd879..a5f329cfe 100644 --- a/src/main/java/fr/xephi/authme/AuthMe.java +++ b/src/main/java/fr/xephi/authme/AuthMe.java @@ -107,8 +107,6 @@ public class AuthMe extends JavaPlugin { public NewAPI api; // TODO #655: Encapsulate mail public SendMailSSL mail; - // TODO #656: Encapsulate data manager - public DataManager dataManager; /* * Private instances */ @@ -249,7 +247,6 @@ public class AuthMe extends JavaPlugin { commandHandler = initializer.get(CommandHandler.class); api = initializer.get(NewAPI.class); management = initializer.get(Management.class); - dataManager = initializer.get(DataManager.class); initializer.get(API.class); // Set up Metrics diff --git a/src/main/java/fr/xephi/authme/DataManager.java b/src/main/java/fr/xephi/authme/DataManager.java deleted file mode 100644 index feaa69d49..000000000 --- a/src/main/java/fr/xephi/authme/DataManager.java +++ /dev/null @@ -1,145 +0,0 @@ -package fr.xephi.authme; - -import fr.xephi.authme.hooks.PluginHooks; -import fr.xephi.authme.permission.PermissionsManager; -import fr.xephi.authme.settings.NewSetting; -import fr.xephi.authme.settings.properties.PurgeSettings; -import fr.xephi.authme.util.BukkitService; -import fr.xephi.authme.util.Utils; -import org.bukkit.OfflinePlayer; -import org.bukkit.Server; - -import javax.inject.Inject; -import java.io.File; - -import static fr.xephi.authme.util.StringUtils.makePath; -import java.util.Set; - -/** - */ -public class DataManager { - - @Inject - private Server server; - @Inject - private PluginHooks pluginHooks; - @Inject - private BukkitService bukkitService; - @Inject - private NewSetting settings; - @Inject - private PermissionsManager permissionsManager; - - DataManager() { } - - public void purgeAntiXray(Set cleared) { - int i = 0; - File dataFolder = new File("." + File.separator + "plugins" + File.separator + "AntiXRayData" - + File.separator + "PlayerData"); - if (!dataFolder.exists() || !dataFolder.isDirectory()) { - return; - } - - for (String file : dataFolder.list()) { - if (cleared.contains(file.toLowerCase())) { - File playerFile = new File(dataFolder, file); - if (playerFile.exists() && playerFile.delete()) { - i++; - } - } - } - - ConsoleLogger.info("AutoPurge: Removed " + i + " AntiXRayData Files"); - } - - public synchronized void purgeLimitedCreative(Set cleared) { - int i = 0; - File dataFolder = new File("." + File.separator + "plugins" + File.separator + "LimitedCreative" - + File.separator + "inventories"); - if (!dataFolder.exists() || !dataFolder.isDirectory()) { - return; - } - for (String file : dataFolder.list()) { - String name = file; - int idx; - idx = file.lastIndexOf("_creative.yml"); - if (idx != -1) { - name = name.substring(0, idx); - } else { - idx = file.lastIndexOf("_adventure.yml"); - if (idx != -1) { - name = name.substring(0, idx); - } else { - idx = file.lastIndexOf(".yml"); - if (idx != -1) { - name = name.substring(0, idx); - } - } - } - if (name.equals(file)) { - continue; - } - if (cleared.contains(name.toLowerCase())) { - File dataFile = new File(dataFolder, file); - if (dataFile.exists() && dataFile.delete()) { - i++; - } - } - } - ConsoleLogger.info("AutoPurge: Removed " + i + " LimitedCreative Survival, Creative and Adventure files"); - } - - public synchronized void purgeDat(Set cleared) { - int i = 0; - File dataFolder = new File(server.getWorldContainer() - , makePath(settings.getProperty(PurgeSettings.DEFAULT_WORLD), "players")); - - for (OfflinePlayer offlinePlayer : cleared) { - File playerFile = new File(dataFolder, Utils.getUUIDorName(offlinePlayer) + ".dat"); - if (playerFile.delete()) { - i++; - } - } - - ConsoleLogger.info("AutoPurge: Removed " + i + " .dat Files"); - } - - /** - * Method purgeEssentials. - * - * @param cleared List of String - */ - public void purgeEssentials(Set cleared) { - int i = 0; - File essentialsDataFolder = pluginHooks.getEssentialsDataFolder(); - if (essentialsDataFolder == null) { - ConsoleLogger.info("Cannot purge Essentials: plugin is not loaded"); - return; - } - - final File userDataFolder = new File(essentialsDataFolder, "userdata"); - if (!userDataFolder.exists() || !userDataFolder.isDirectory()) { - return; - } - - for (OfflinePlayer offlinePlayer : cleared) { - File playerFile = new File(userDataFolder, Utils.getUUIDorName(offlinePlayer) + ".yml"); - if (playerFile.exists() && playerFile.delete()) { - i++; - } - } - - ConsoleLogger.info("AutoPurge: Removed " + i + " EssentialsFiles"); - } - - // TODO: What is this method for? Is it correct? - // TODO: Make it work with OfflinePlayers group data. - public synchronized void purgePermissions(Set cleared) { - for (OfflinePlayer offlinePlayer : cleared) { - String name = offlinePlayer.getName(); - permissionsManager.removeAllGroups(bukkitService.getPlayerExact(name)); - } - - ConsoleLogger.info("AutoPurge: Removed permissions from " + cleared.size() + " player(s)."); - } -}