From 32f5a31ea53d119d301a1fb0871c347ac27088cf Mon Sep 17 00:00:00 2001 From: ElgarL Date: Sat, 24 Sep 2011 19:10:55 +0100 Subject: Added a BukkitPermsUpdateTask to only update superperms once on a load/reload. --- .../org/anjocaido/groupmanager/GroupManager.java | 24 +++++++++++++++++++--- .../permissions/BukkitPermissions.java | 8 +++++++- 2 files changed, 28 insertions(+), 4 deletions(-) (limited to 'EssentialsGroupManager/src/org/anjocaido') diff --git a/EssentialsGroupManager/src/org/anjocaido/groupmanager/GroupManager.java b/EssentialsGroupManager/src/org/anjocaido/groupmanager/GroupManager.java index 2b0a493d4..cc7f1de50 100644 --- a/EssentialsGroupManager/src/org/anjocaido/groupmanager/GroupManager.java +++ b/EssentialsGroupManager/src/org/anjocaido/groupmanager/GroupManager.java @@ -7,6 +7,7 @@ package org.anjocaido.groupmanager; import org.anjocaido.groupmanager.permissions.AnjoPermissionsHandler; import org.anjocaido.groupmanager.permissions.BukkitPermissions; import org.anjocaido.groupmanager.utils.GroupManagerPermissions; +import org.anjocaido.groupmanager.Tasks.BukkitPermsUpdateTask; import org.anjocaido.groupmanager.data.Variables; import org.anjocaido.groupmanager.data.User; import org.anjocaido.groupmanager.data.Group; @@ -62,7 +63,7 @@ public class GroupManager extends JavaPlugin { @Override public void onDisable() { - isLoaded = false; + setLoaded(false); if (worldsHolder != null) { worldsHolder.saveChanges(); @@ -96,11 +97,28 @@ public class GroupManager extends JavaPlugin { BukkitPermissions = new BukkitPermissions(this); enableScheduler(); - isLoaded = true; + + /* + * Schedule a Bukiit Permissions update for 1 tick later. + * All plugins will be loaded by then + */ + + if (getServer().getScheduler().scheduleSyncDelayedTask(this, new BukkitPermsUpdateTask(),1) == -1) + GroupManager.logger.severe("Could not schedule superperms Update."); + + //setLoaded(true); System.out.println(pdfFile.getName() + " version " + pdfFile.getVersion() + " is enabled!"); } - public InputStream getResourceAsStream(String fileName) { + public static boolean isLoaded() { + return isLoaded; + } + + public static void setLoaded(boolean isLoaded) { + GroupManager.isLoaded = isLoaded; + } + + public InputStream getResourceAsStream(String fileName) { return this.getClassLoader().getResourceAsStream(fileName); } diff --git a/EssentialsGroupManager/src/org/anjocaido/groupmanager/permissions/BukkitPermissions.java b/EssentialsGroupManager/src/org/anjocaido/groupmanager/permissions/BukkitPermissions.java index 02a1f4d5c..d3fbdbe55 100644 --- a/EssentialsGroupManager/src/org/anjocaido/groupmanager/permissions/BukkitPermissions.java +++ b/EssentialsGroupManager/src/org/anjocaido/groupmanager/permissions/BukkitPermissions.java @@ -107,7 +107,7 @@ public class BukkitPermissions { } public void updatePermissions(Player player, String world) { - if (player == null || !GroupManager.isLoaded) { + if (player == null || !GroupManager.isLoaded()) { return; } @@ -237,6 +237,9 @@ public class BukkitPermissions { @Override public void onPlayerQuit(PlayerQuitEvent event) { + if (!GroupManager.isLoaded()) + return; + attachments.remove(event.getPlayer()); } @@ -250,6 +253,9 @@ public class BukkitPermissions { @Override public void onPluginEnable(PluginEnableEvent event) { + if (!GroupManager.isLoaded()) + return; + collectPermissions(); updateAllPlayers(); } -- cgit v1.2.3 From a2ca381bbd2f0621d7da444fceac1d7c720b34ac Mon Sep 17 00:00:00 2001 From: ElgarL Date: Sat, 24 Sep 2011 19:11:59 +0100 Subject: Forgot to push task --- .../groupmanager/Tasks/BukkitPermsUpdateTask.java | 27 ++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 EssentialsGroupManager/src/org/anjocaido/groupmanager/Tasks/BukkitPermsUpdateTask.java (limited to 'EssentialsGroupManager/src/org/anjocaido') diff --git a/EssentialsGroupManager/src/org/anjocaido/groupmanager/Tasks/BukkitPermsUpdateTask.java b/EssentialsGroupManager/src/org/anjocaido/groupmanager/Tasks/BukkitPermsUpdateTask.java new file mode 100644 index 000000000..27951112d --- /dev/null +++ b/EssentialsGroupManager/src/org/anjocaido/groupmanager/Tasks/BukkitPermsUpdateTask.java @@ -0,0 +1,27 @@ +package org.anjocaido.groupmanager.Tasks; + +import org.anjocaido.groupmanager.GroupManager; + +/* + * + * Created by ElgarL + * + */ + +public class BukkitPermsUpdateTask implements Runnable { + + public BukkitPermsUpdateTask() { + super(); + } + + @Override + public void run() { + // Signal loaded and update BukkitPermissions. + GroupManager.setLoaded(true); + GroupManager.BukkitPermissions.updateAllPlayers(); + + GroupManager.logger.info("Bukkit Permissions Updated!"); + + } + +} \ No newline at end of file -- cgit v1.2.3 From 2db256678ec1412a0e76bae88bd07a44f21a8139 Mon Sep 17 00:00:00 2001 From: ElgarL Date: Sat, 24 Sep 2011 19:18:22 +0100 Subject: Fix for if the scheduler fails --- EssentialsGroupManager/src/org/anjocaido/groupmanager/GroupManager.java | 2 ++ 1 file changed, 2 insertions(+) (limited to 'EssentialsGroupManager/src/org/anjocaido') diff --git a/EssentialsGroupManager/src/org/anjocaido/groupmanager/GroupManager.java b/EssentialsGroupManager/src/org/anjocaido/groupmanager/GroupManager.java index cc7f1de50..13d99ddc1 100644 --- a/EssentialsGroupManager/src/org/anjocaido/groupmanager/GroupManager.java +++ b/EssentialsGroupManager/src/org/anjocaido/groupmanager/GroupManager.java @@ -105,6 +105,8 @@ public class GroupManager extends JavaPlugin { if (getServer().getScheduler().scheduleSyncDelayedTask(this, new BukkitPermsUpdateTask(),1) == -1) GroupManager.logger.severe("Could not schedule superperms Update."); + else + setLoaded(true); //setLoaded(true); System.out.println(pdfFile.getName() + " version " + pdfFile.getVersion() + " is enabled!"); -- cgit v1.2.3