summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Essentials/nbproject/project.properties4
-rw-r--r--Essentials/src/com/earth2me/essentials/Essentials.java32
-rw-r--r--Essentials/src/com/earth2me/essentials/EssentialsPluginListener.java64
-rw-r--r--Essentials/src/com/earth2me/essentials/IEssentials.java4
-rw-r--r--Essentials/src/com/earth2me/essentials/PermissionsExHandler.java74
-rw-r--r--lib/PermissionsEx.jarbin0 -> 116307 bytes
6 files changed, 136 insertions, 42 deletions
diff --git a/Essentials/nbproject/project.properties b/Essentials/nbproject/project.properties
index f8b41cf41..b10c5e5b4 100644
--- a/Essentials/nbproject/project.properties
+++ b/Essentials/nbproject/project.properties
@@ -32,6 +32,7 @@ file.reference.iCo4.jar=../lib/iCo4.jar
file.reference.iCo5.jar=../lib/iCo5.jar
file.reference.junit-4.5.jar=..\\lib\\junit_4\\junit-4.5.jar
file.reference.Permissions3.jar=../lib/Permissions3.jar
+file.reference.PermissionsEx.jar=../lib/PermissionsEx.jar
includes=**
jar.compress=false
javac.classpath=\
@@ -39,7 +40,8 @@ javac.classpath=\
${file.reference.craftbukkit-0.0.1-SNAPSHOT.jar}:\
${file.reference.iCo4.jar}:\
${file.reference.iCo5.jar}:\
- ${file.reference.BOSEconomy7.jar}
+ ${file.reference.BOSEconomy7.jar}:\
+ ${file.reference.PermissionsEx.jar}
# Space-separated list of extra javac options
javac.compilerargs=
javac.deprecation=false
diff --git a/Essentials/src/com/earth2me/essentials/Essentials.java b/Essentials/src/com/earth2me/essentials/Essentials.java
index 4a1562eaf..7f85ab2c3 100644
--- a/Essentials/src/com/earth2me/essentials/Essentials.java
+++ b/Essentials/src/com/earth2me/essentials/Essentials.java
@@ -143,32 +143,7 @@ public class Essentials extends JavaPlugin implements IEssentials
LOGGER.log(Level.INFO, Util.i18n("bukkitFormatChanged"));
}
- final Plugin permissionsPlugin = pm.getPlugin("Permissions");
-
- if (permissionsPlugin != null)
- {
- if (permissionsPlugin.getDescription().getVersion().charAt(0) == '3')
- {
- this.permissionsHandler = new Permissions3Handler(permissionsPlugin);
- }
- else
- {
- this.permissionsHandler = new Permissions2Handler(permissionsPlugin);
- }
- }
- else
- {
- if (this.getSettings().useBukkitPermissions())
- {
- this.permissionsHandler = new BukkitPermissionsHandler();
- }
- else
- {
- this.permissionsHandler = new ConfigPermissionsHandler(this);
- }
- }
-
- final ServerListener serverListener = new EssentialsPluginListener(paymentMethod);
+ final ServerListener serverListener = new EssentialsPluginListener(this);
pm.registerEvent(Type.PLUGIN_ENABLE, serverListener, Priority.Low, this);
pm.registerEvent(Type.PLUGIN_DISABLE, serverListener, Priority.Low, this);
@@ -663,6 +638,11 @@ public class Essentials extends JavaPlugin implements IEssentials
{
return permissionsHandler;
}
+
+ public void setPermissionsHandler(IPermissionsHandler handler)
+ {
+ this.permissionsHandler = handler;
+ }
public BanWorkaround getBans()
{
diff --git a/Essentials/src/com/earth2me/essentials/EssentialsPluginListener.java b/Essentials/src/com/earth2me/essentials/EssentialsPluginListener.java
index b3b5ff1c1..34632dd40 100644
--- a/Essentials/src/com/earth2me/essentials/EssentialsPluginListener.java
+++ b/Essentials/src/com/earth2me/essentials/EssentialsPluginListener.java
@@ -6,40 +6,76 @@ import java.util.logging.Logger;
import org.bukkit.event.server.PluginDisableEvent;
import org.bukkit.event.server.PluginEnableEvent;
import org.bukkit.event.server.ServerListener;
+import org.bukkit.plugin.Plugin;
+import org.bukkit.plugin.PluginManager;
public class EssentialsPluginListener extends ServerListener
{
- private final Methods methods;
- private static final Logger logger = Logger.getLogger("Minecraft");
+ private final transient IEssentials ess;
+ private static final Logger LOGGER = Logger.getLogger("Minecraft");
- public EssentialsPluginListener(Methods methods)
+ public EssentialsPluginListener(final IEssentials ess)
{
- this.methods = methods;
+ this.ess = ess;
}
-
+
@Override
- public void onPluginEnable(PluginEnableEvent event)
+ public void onPluginEnable(final PluginEnableEvent event)
{
- if (!methods.hasMethod())
+ checkPermissions();
+ if (!ess.getPaymentMethod().hasMethod() && ess.getPaymentMethod().setMethod(event.getPlugin()))
{
- if (methods.setMethod(event.getPlugin()))
- {
- logger.log(Level.INFO, "[Essentials] Payment method found (" + methods.getMethod().getName() + " version: " + methods.getMethod().getVersion() + ")");
- }
+ LOGGER.log(Level.INFO, "[Essentials] Payment method found (" + ess.getPaymentMethod().getMethod().getName() + " version: " + ess.getPaymentMethod().getMethod().getVersion() + ")");
+
}
}
@Override
public void onPluginDisable(PluginDisableEvent event)
{
+ checkPermissions();
// Check to see if the plugin thats being disabled is the one we are using
- if (methods != null && methods.hasMethod())
+ if (ess.getPaymentMethod() != null && ess.getPaymentMethod().hasMethod() && ess.getPaymentMethod().checkDisabled(event.getPlugin()))
{
- if (methods.checkDisabled(event.getPlugin()))
+ LOGGER.log(Level.INFO, "[Essentials] Payment method was disabled. No longer accepting payments.");
+ }
+ }
+
+ private void checkPermissions()
+ {
+ final PluginManager pm = ess.getServer().getPluginManager();
+ final Plugin permissionsExPlugin = pm.getPlugin("PermissionsEx");
+
+ if (permissionsExPlugin == null || !permissionsExPlugin.isEnabled())
+ {
+ final Plugin permissionsPlugin = pm.getPlugin("Permissions");
+ if (permissionsPlugin == null || !permissionsPlugin.isEnabled())
{
- logger.log(Level.INFO, "[Essentials] Payment method was disabled. No longer accepting payments.");
+ if (ess.getSettings().useBukkitPermissions())
+ {
+ ess.setPermissionsHandler(new BukkitPermissionsHandler());
+ }
+ else
+ {
+ ess.setPermissionsHandler(new ConfigPermissionsHandler(ess));
+ }
}
+ else
+ {
+ if (permissionsPlugin.getDescription().getVersion().charAt(0) == '3')
+ {
+ ess.setPermissionsHandler(new Permissions3Handler(permissionsPlugin));
+ }
+ else
+ {
+ ess.setPermissionsHandler(new Permissions2Handler(permissionsPlugin));
+ }
+ }
+ }
+ else
+ {
+ ess.setPermissionsHandler(new PermissionsExHandler());
}
}
}
diff --git a/Essentials/src/com/earth2me/essentials/IEssentials.java b/Essentials/src/com/earth2me/essentials/IEssentials.java
index b1c420e7d..f867daea8 100644
--- a/Essentials/src/com/earth2me/essentials/IEssentials.java
+++ b/Essentials/src/com/earth2me/essentials/IEssentials.java
@@ -59,9 +59,11 @@ public interface IEssentials extends Plugin
IPermissionsHandler getPermissionsHandler();
+ void setPermissionsHandler(IPermissionsHandler handler);
+
void showError(final CommandSender sender, final Throwable exception, final String commandLabel);
Map<String, User> getAllUsers();
-
+
ItemDb getItemDb();
}
diff --git a/Essentials/src/com/earth2me/essentials/PermissionsExHandler.java b/Essentials/src/com/earth2me/essentials/PermissionsExHandler.java
new file mode 100644
index 000000000..f9151c77e
--- /dev/null
+++ b/Essentials/src/com/earth2me/essentials/PermissionsExHandler.java
@@ -0,0 +1,74 @@
+package com.earth2me.essentials;
+
+import org.bukkit.entity.Player;
+import ru.tehkode.permissions.PermissionManager;
+import ru.tehkode.permissions.PermissionUser;
+import ru.tehkode.permissions.bukkit.PermissionsEx;
+
+
+class PermissionsExHandler implements IPermissionsHandler
+{
+ private final transient PermissionManager manager;
+
+ public PermissionsExHandler()
+ {
+ manager = PermissionsEx.getPermissionManager();
+ }
+
+ public String getGroup(Player base)
+ {
+ final PermissionUser user = manager.getUser(base.getName());
+ if (user == null)
+ {
+ return "default";
+ }
+ return user.getGroupsNames()[0];
+ }
+
+ public boolean canBuild(Player base, String group)
+ {
+ final PermissionUser user = manager.getUser(base.getName());
+ if (user == null)
+ {
+ return true;
+ }
+
+ return user.getOptionBoolean("build", base.getWorld().getName(), true);
+ }
+
+ public boolean inGroup(Player base, String group)
+ {
+ final PermissionUser user = manager.getUser(base.getName());
+ if (user == null)
+ {
+ return false;
+ }
+
+ return user.inGroup(group);
+ }
+
+ public boolean hasPermission(Player base, String node)
+ {
+ return manager.has(base.getName(), node, base.getWorld().getName());
+ }
+
+ public String getPrefix(Player base)
+ {
+ final PermissionUser user = manager.getUser(base.getName());
+ if (user == null)
+ {
+ return "";
+ }
+ return user.getPrefix();
+ }
+
+ public String getSuffix(Player base)
+ {
+ final PermissionUser user = manager.getUser(base.getName());
+ if (user == null)
+ {
+ return "";
+ }
+ return user.getSuffix();
+ }
+}
diff --git a/lib/PermissionsEx.jar b/lib/PermissionsEx.jar
new file mode 100644
index 000000000..d2b1ad91e
--- /dev/null
+++ b/lib/PermissionsEx.jar
Binary files differ