From 35c80da9287e0a7e84d4f08c58ad29683bd854b2 Mon Sep 17 00:00:00 2001 From: Benjamin Diskmaster Lierman Date: Sat, 16 Jul 2011 02:32:23 -0500 Subject: [PATCH 1/2] NuclearW pull request 2: Electric Boogaloo (Permissions alterations, updated for 1.0.35 wip, locally untested) --- mcMMO/com/gmail/nossr50/mcPermissions.java | 45 ++++++++++++++++++---- 1 file changed, 37 insertions(+), 8 deletions(-) diff --git a/mcMMO/com/gmail/nossr50/mcPermissions.java b/mcMMO/com/gmail/nossr50/mcPermissions.java index d9ebbb622..4143cf03d 100644 --- a/mcMMO/com/gmail/nossr50/mcPermissions.java +++ b/mcMMO/com/gmail/nossr50/mcPermissions.java @@ -6,27 +6,47 @@ import java.util.logging.Logger; import org.bukkit.Server; import org.bukkit.entity.Player; import org.bukkit.plugin.Plugin; + +import ru.tehkode.permissions.PermissionManager; +import ru.tehkode.permissions.bukkit.PermissionsEx; + +import com.nijiko.permissions.PermissionHandler; import com.nijikokun.bukkit.Permissions.Permissions; public class mcPermissions { - private static Permissions permissionsPlugin; + private enum PermissionType { + PEX, PERMISSIONS, BUKKIT + } + + private static PermissionType permissionType; + private static Object PHandle; public static boolean permissionsEnabled = false; private static volatile mcPermissions instance; public static void initialize(Server server) { + Plugin PEXtest = server.getPluginManager().getPlugin("PermissionsEx"); Plugin test = server.getPluginManager().getPlugin("Permissions"); - if (test != null) - { - Logger log = Logger.getLogger("Minecraft"); - permissionsPlugin = ((Permissions) test); + Logger log = Logger.getLogger("Minecraft"); + if (PEXtest != null) { + PHandle = (PermissionManager) PermissionsEx.getPermissionManager(); + permissionType = PermissionType.PEX; permissionsEnabled = true; - log.log(Level.INFO, "[mcMMO] Permissions enabled."); + log.log(Level.INFO, "[mcMMO] PermissionsEx enabled."); + } else if (test != null) { + PHandle = (PermissionHandler) ((Permissions) test).getHandler(); + permissionType = PermissionType.PERMISSIONS; + permissionsEnabled = true; + log.log(Level.INFO, "[mcMMO] Permissions "+test.getDescription().getVersion()+" enabled."); } else { - Logger log = Logger.getLogger("Minecraft"); log.log(Level.SEVERE, "[mcMMO] Permissions isn't loaded, there are no restrictions."); + /* + permissionType = PermissionType.BUKKIT; + permissionsEnabled = true; + log.info("[mcMMO] Using Bukkit Permissions.") + */ } } @@ -37,7 +57,16 @@ public class mcPermissions private static boolean permission(Player player, String string) { - return permissionsPlugin.getHandler().has(player, string); + switch (permissionType) { + case PEX: + return ((PermissionManager) PHandle).has(player, string); + case PERMISSIONS: + return ((PermissionHandler) PHandle).has(player, string); + case BUKKIT: + //return player.hasPermission(string); + default: + return true; + } } public boolean admin(Player player){ if (permissionsEnabled) { From 3ac0f1455c9d4318f7b5aa213d791a4187c7a39f Mon Sep 17 00:00:00 2001 From: Ben Diskmaster L Date: Mon, 18 Jul 2011 13:35:56 -0500 Subject: [PATCH 2/2] Actually fix this specific string. --- mcMMO/com/gmail/nossr50/mcMMO.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mcMMO/com/gmail/nossr50/mcMMO.java b/mcMMO/com/gmail/nossr50/mcMMO.java index 3b04027cf..915f770c9 100644 --- a/mcMMO/com/gmail/nossr50/mcMMO.java +++ b/mcMMO/com/gmail/nossr50/mcMMO.java @@ -46,7 +46,7 @@ public class mcMMO extends JavaPlugin * Donate via paypal to nossr50@gmail.com (A million thanks to anyone that does!) */ - public static String maindirectory = "plugins + File.separator + mcMMO"; + public static String maindirectory = "plugins" + File.separator + "mcMMO"; File file = new File(maindirectory + File.separator + "config.yml"); public static final Logger log = Logger.getLogger("Minecraft"); private final mcPlayerListener playerListener = new mcPlayerListener(this);