From ada991904bdc2a52c68639c97c06c47e46737780 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tim=20Vis=C3=A9e?= Date: Sat, 21 Nov 2015 21:07:32 +0100 Subject: [PATCH] Improved purgePermissions method --- .../java/fr/xephi/authme/DataManager.java | 26 +++++++++++++++---- 1 file changed, 21 insertions(+), 5 deletions(-) diff --git a/src/main/java/fr/xephi/authme/DataManager.java b/src/main/java/fr/xephi/authme/DataManager.java index edc96eee7..3d74da41e 100644 --- a/src/main/java/fr/xephi/authme/DataManager.java +++ b/src/main/java/fr/xephi/authme/DataManager.java @@ -7,6 +7,7 @@ import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; import java.util.concurrent.Future; +import fr.xephi.authme.permission.PermissionsManager; import org.bukkit.Bukkit; import org.bukkit.OfflinePlayer; import org.bukkit.entity.Player; @@ -172,13 +173,28 @@ public class DataManager { ConsoleLogger.info("AutoPurgeDatabase : Remove " + i + " EssentialsFiles"); } + // TODO: What is this method for? Is it correct? /** - * Method purgePermissions. - * @param cleared List - * @param permission Permission + * @param cleared Cleared players. */ - public synchronized void purgePermissions(List cleared, Permission permission) { + public synchronized void purgePermissions(List cleared) { + // Get the permissions manager, and make sure it's valid + PermissionsManager permsMan = this.plugin.getPermissionsManager(); + if(permsMan == null) + ConsoleLogger.showError("Unable to access permissions manager instance!"); + assert permsMan != null; + int i = 0; + for (String name : cleared) { + try { + permsMan.removeAllGroups(this.getOnlinePlayerLower(name.toLowerCase())); + i++; + } catch(Exception e) { + } + } + ConsoleLogger.info("AutoPurgeDatabase : Removed " + i + " permissions"); + + /*int i = 0; for (String name : cleared) { try { OfflinePlayer p = this.getOfflinePlayer(name); @@ -189,7 +205,7 @@ public class DataManager { } catch (Exception e) { } } - ConsoleLogger.info("AutoPurgeDatabase : Remove " + i + " Permissions"); + ConsoleLogger.info("AutoPurgeDatabase : Remove " + i + " Permissions");*/ } /**