mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2024-11-29 16:46:46 +01:00
NuclearW pull request 2: Electric Boogaloo (Permissions alterations, updated for 1.0.35 wip, locally
untested)
This commit is contained in:
parent
25940bf5cf
commit
35c80da928
@ -6,27 +6,47 @@ import java.util.logging.Logger;
|
|||||||
import org.bukkit.Server;
|
import org.bukkit.Server;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.plugin.Plugin;
|
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;
|
import com.nijikokun.bukkit.Permissions.Permissions;
|
||||||
|
|
||||||
public class mcPermissions
|
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;
|
public static boolean permissionsEnabled = false;
|
||||||
private static volatile mcPermissions instance;
|
private static volatile mcPermissions instance;
|
||||||
|
|
||||||
public static void initialize(Server server)
|
public static void initialize(Server server)
|
||||||
{
|
{
|
||||||
|
Plugin PEXtest = server.getPluginManager().getPlugin("PermissionsEx");
|
||||||
Plugin test = server.getPluginManager().getPlugin("Permissions");
|
Plugin test = server.getPluginManager().getPlugin("Permissions");
|
||||||
if (test != null)
|
Logger log = Logger.getLogger("Minecraft");
|
||||||
{
|
if (PEXtest != null) {
|
||||||
Logger log = Logger.getLogger("Minecraft");
|
PHandle = (PermissionManager) PermissionsEx.getPermissionManager();
|
||||||
permissionsPlugin = ((Permissions) test);
|
permissionType = PermissionType.PEX;
|
||||||
permissionsEnabled = true;
|
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
|
} else
|
||||||
{
|
{
|
||||||
Logger log = Logger.getLogger("Minecraft");
|
|
||||||
log.log(Level.SEVERE, "[mcMMO] Permissions isn't loaded, there are no restrictions.");
|
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)
|
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){
|
public boolean admin(Player player){
|
||||||
if (permissionsEnabled) {
|
if (permissionsEnabled) {
|
||||||
|
Loading…
Reference in New Issue
Block a user