summaryrefslogtreecommitdiffstats
path: root/EssentialsGroupBridge
diff options
context:
space:
mode:
authorsnowleo <schneeleo@gmail.com>2011-06-25 15:00:08 +0200
committersnowleo <schneeleo@gmail.com>2011-06-25 15:00:08 +0200
commit8bb3a76366a701ac7283813e2c30b3ef129ddf60 (patch)
tree6805e2dc10b96e7e737f1697075f99a73d4d6f21 /EssentialsGroupBridge
parent22ea5b0f8be07abdd72372ddfcbe1b8267e903b8 (diff)
parent5e2f4bcbb2f6981dec23e75013e44b27b4751999 (diff)
downloadEssentials-8bb3a76366a701ac7283813e2c30b3ef129ddf60.tar
Essentials-8bb3a76366a701ac7283813e2c30b3ef129ddf60.tar.gz
Essentials-8bb3a76366a701ac7283813e2c30b3ef129ddf60.tar.lz
Essentials-8bb3a76366a701ac7283813e2c30b3ef129ddf60.tar.xz
Essentials-8bb3a76366a701ac7283813e2c30b3ef129ddf60.zip
Merge branch 'bukkitupdate'
Diffstat (limited to 'EssentialsGroupBridge')
-rw-r--r--EssentialsGroupBridge/src/com/nijikokun/bukkit/Permissions/Permissions.java64
-rw-r--r--EssentialsGroupBridge/src/org/anjocaido/groupmanager/permissions/NijikoPermissionsProxy.java6
2 files changed, 51 insertions, 19 deletions
diff --git a/EssentialsGroupBridge/src/com/nijikokun/bukkit/Permissions/Permissions.java b/EssentialsGroupBridge/src/com/nijikokun/bukkit/Permissions/Permissions.java
index bca7a89ed..cf0d09a35 100644
--- a/EssentialsGroupBridge/src/com/nijikokun/bukkit/Permissions/Permissions.java
+++ b/EssentialsGroupBridge/src/com/nijikokun/bukkit/Permissions/Permissions.java
@@ -7,8 +7,12 @@ import java.util.logging.Logger;
import org.anjocaido.groupmanager.GroupManager;
import org.anjocaido.groupmanager.permissions.NijikoPermissionsProxy;
import org.bukkit.Server;
+import org.bukkit.event.Event.Priority;
+import org.bukkit.event.Event.Type;
import org.bukkit.event.player.PlayerChatEvent;
import org.bukkit.event.player.PlayerListener;
+import org.bukkit.event.server.PluginEnableEvent;
+import org.bukkit.event.server.ServerListener;
import org.bukkit.plugin.Plugin;
import org.bukkit.plugin.PluginDescriptionFile;
import org.bukkit.plugin.java.JavaPlugin;
@@ -55,23 +59,32 @@ public class Permissions extends JavaPlugin {
PluginDescriptionFile pdfFile = this.getDescription();
if (Security == null) {//make sure we have only one instance
- Plugin p = (Plugin)(this.getServer() == null ? new GroupManager() : this.getServer().getPluginManager().getPlugin("GroupManager"));
- if (p != null) {
- if (!p.isEnabled()) {
- if (this.getServer() == null) {
- p.onEnable();
- } else {
- this.getServer().getPluginManager().enablePlugin(p);
- }
- }
- GroupManager gm = (GroupManager) p;
- groupManager = gm;
- Security = new NijikoPermissionsProxy(gm);
- } else {
- System.err.println("OOOPS! Fake " + pdfFile.getName() + " version " + pdfFile.getVersion() + " couldn't find GroupManager!");
- this.getPluginLoader().disablePlugin(this);
- }
- }
+ Security = new NijikoPermissionsProxy(null);
+ }
+
+ Plugin p = (this.getServer() == null) ? null : this.getServer().getPluginManager().getPlugin("GroupManager");
+ if (p != null) {
+ if (p.isEnabled()) {
+ setGM(p);
+ } else {
+ if (this.getServer() != null) {
+ this.getServer().getPluginManager().registerEvent(Type.PLUGIN_ENABLE, new ServerListener() {
+
+ @Override
+ public void onPluginEnable(PluginEnableEvent event)
+ {
+ if (event.getPlugin().getDescription().getName().equals("GroupManager")) {
+ Permissions.this.setGM(event.getPlugin());
+ }
+ }
+
+ }, Priority.Normal, this);
+ }
+ }
+ } else {
+ System.err.println("OOOPS! Fake " + pdfFile.getName() + " version " + pdfFile.getVersion() + " couldn't find GroupManager!");
+ this.getPluginLoader().disablePlugin(this);
+ }
// EXAMPLE: Custom code, here we just output some info so we can check all is well
if (pdfFile != null)
System.out.println("Fake " + pdfFile.getName() + " version " + pdfFile.getVersion() + " is enabled!");
@@ -81,17 +94,30 @@ public class Permissions extends JavaPlugin {
//compiled code
//throw new RuntimeException("Compiled Code");
}
+
+ private void setGM(Plugin p) {
+ groupManager = (GroupManager)p;
+ ((NijikoPermissionsProxy)Security).setGM(p);
+ }
public PermissionHandler getHandler() {
//compiled code
//throw new RuntimeException("Compiled Code");
//System.out.println("Alguem chamou o handler");
- checkEnable();
+ if (Security == null)
+ {
+ Security = new NijikoPermissionsProxy(null);
+ }
+ //checkEnable();
return Security;
}
public void setupPermissions() {
- checkEnable();
+ if (Security == null)
+ {
+ Security = new NijikoPermissionsProxy(null);
+ }
+ //checkEnable();
}
private void checkEnable() {
diff --git a/EssentialsGroupBridge/src/org/anjocaido/groupmanager/permissions/NijikoPermissionsProxy.java b/EssentialsGroupBridge/src/org/anjocaido/groupmanager/permissions/NijikoPermissionsProxy.java
index 18da0cd56..e26c10711 100644
--- a/EssentialsGroupBridge/src/org/anjocaido/groupmanager/permissions/NijikoPermissionsProxy.java
+++ b/EssentialsGroupBridge/src/org/anjocaido/groupmanager/permissions/NijikoPermissionsProxy.java
@@ -9,6 +9,7 @@ import java.io.File;
import java.util.Map;
import org.anjocaido.groupmanager.GroupManager;
import org.bukkit.entity.Player;
+import org.bukkit.plugin.Plugin;
import org.bukkit.util.config.Configuration;
/**
@@ -425,4 +426,9 @@ public class NijikoPermissionsProxy extends Control {
return plugin.getWorldsHolder().getDefaultWorld().getPermissionsHandler().getPermissionDouble(name,permission);
}
+ public void setGM(Plugin p)
+ {
+ this.plugin = (GroupManager)p;
+ }
+
}