diff --git a/.classpath b/.classpath
index cea07fc..4d8e104 100644
--- a/.classpath
+++ b/.classpath
@@ -15,5 +15,6 @@
+
diff --git a/lib/PermissionsEx.jar b/lib/PermissionsEx.jar
new file mode 100644
index 0000000..8711b8e
Binary files /dev/null and b/lib/PermissionsEx.jar differ
diff --git a/make_jar.jardesc b/make_jar.jardesc
index 70e1eef..037dd73 100644
--- a/make_jar.jardesc
+++ b/make_jar.jardesc
@@ -1,6 +1,6 @@
-
+
diff --git a/resources/config.yml b/resources/config.yml
index d71553e..60275ed 100644
--- a/resources/config.yml
+++ b/resources/config.yml
@@ -33,3 +33,8 @@ cubos:
# séparé avec des point-virgules
worlds: Survival
+
+
+
+cleaner:
+ users_cleaner_group: default
diff --git a/resources/plugin.yml b/resources/plugin.yml
index 09c4738..7cf5903 100644
--- a/resources/plugin.yml
+++ b/resources/plugin.yml
@@ -1,6 +1,6 @@
name: PandacraftUtils
main: net.mc_pandacraft.java.plugin.pandacraftutils.PandacraftUtils
-version: 2.10
+version: 2.11
diff --git a/src/net/mc_pandacraft/java/plugin/pandacraftutils/ConfigManager.java b/src/net/mc_pandacraft/java/plugin/pandacraftutils/ConfigManager.java
index 322f3b1..9fa0e5c 100644
--- a/src/net/mc_pandacraft/java/plugin/pandacraftutils/ConfigManager.java
+++ b/src/net/mc_pandacraft/java/plugin/pandacraftutils/ConfigManager.java
@@ -81,6 +81,8 @@ public class ConfigManager {
CuboCommand_worlds = Arrays.asList(configFile.getString("cubos.worlds").split(";"));
+ UsersCleaner_users_cleaner_group = configFile.getString("cleaner.users_cleaner_group");
+
initChatAnalysisBadWord();
initCommandAlias();
@@ -105,6 +107,15 @@ public class ConfigManager {
+ /*
+ * Users cleaner
+ */
+ public String UsersCleaner_users_cleaner_group;
+
+
+
+
+
/*
* Configuration AFK
*/
diff --git a/src/net/mc_pandacraft/java/plugin/pandacraftutils/PandacraftUtils.java b/src/net/mc_pandacraft/java/plugin/pandacraftutils/PandacraftUtils.java
index 61aeca1..6efeaa7 100644
--- a/src/net/mc_pandacraft/java/plugin/pandacraftutils/PandacraftUtils.java
+++ b/src/net/mc_pandacraft/java/plugin/pandacraftutils/PandacraftUtils.java
@@ -92,6 +92,13 @@ public class PandacraftUtils extends JavaPlugin {
calculatorManager = new CalculatorManager(this);
serverPingListener = new PacketOutServerInfoListener(this);
+
+
+ getServer().getScheduler().runTaskLater(this, new Runnable() {
+ @Override public void run() { new PlayerDataCleaner(instance); }
+ }, 1);
+
+
}
diff --git a/src/net/mc_pandacraft/java/plugin/pandacraftutils/PlayerDataCleaner.java b/src/net/mc_pandacraft/java/plugin/pandacraftutils/PlayerDataCleaner.java
new file mode 100644
index 0000000..18f73a9
--- /dev/null
+++ b/src/net/mc_pandacraft/java/plugin/pandacraftutils/PlayerDataCleaner.java
@@ -0,0 +1,76 @@
+package net.mc_pandacraft.java.plugin.pandacraftutils;
+
+import java.util.Set;
+
+import net.mc_pandacraft.java.plugin.pandacraftutils.plugin_interface.EssentialsInterface;
+import ru.tehkode.permissions.PermissionUser;
+import ru.tehkode.permissions.bukkit.PermissionsEx;
+
+import com.earth2me.essentials.User;
+import com.earth2me.essentials.UserMap;
+
+public class PlayerDataCleaner {
+
+ private PandacraftUtils plugin;
+
+ public PlayerDataCleaner(PandacraftUtils pl) {
+ plugin = pl;
+
+
+ try {
+ clean();
+ } catch (Throwable e) {
+ e.printStackTrace();
+ }
+
+
+ }
+
+
+
+ private void clean() {
+
+
+ String group_to_remove = ConfigManager.getInstance().UsersCleaner_users_cleaner_group;
+
+
+ // essentials players
+
+ UserMap players = EssentialsInterface.getPlugin().getUserMap();
+ plugin.getLogger().info("Group to remove : "+group_to_remove);
+ plugin.getLogger().info("Running Essentials players autoremove ..");
+ if (players == null) return;
+ plugin.getLogger().info("There are "+players.getUniqueUsers()+" players files in Essentials/userdata");
+ Set users = players.getAllUniqueUsers();
+
+ for (String su : users) {
+ User u = players.getUser(su);
+ if (u.getBase() != null && u.getBase().isOnline()) continue;
+ if (!group_to_remove.equalsIgnoreCase(u.getGroup())) continue;
+ plugin.getLogger().info("Essentials players autoremove : "+su);
+ players.getUserFile(su).delete();
+ }
+ players.reloadConfig();
+
+
+ // permissions_ex players
+ PermissionUser[] pUsers = PermissionsEx.getPermissionManager().getUsers(group_to_remove);
+ plugin.getLogger().info("Running PermissionsEx players autoremove ..");
+ plugin.getLogger().info("There are "+pUsers.length+" players in 'default' group");
+
+ for (PermissionUser pUser : pUsers) {
+ if (pUser == null) continue;
+ if (pUser.getGroupsNames().length != 1) continue;
+ if (!pUser.getGroupsNames()[0].equalsIgnoreCase(group_to_remove)) continue;
+ plugin.getLogger().info("PermissionsEx players autoremove : "+pUser.getName());
+ pUser.remove();
+ }
+ PermissionsEx.getPlugin().reloadConfig();
+
+
+
+ }
+
+
+
+}