From 5645c29dd8f4e17811e80bf076963d98e99acfbc Mon Sep 17 00:00:00 2001 From: TheYeti Date: Mon, 6 Feb 2012 10:48:02 -0800 Subject: [PATCH] Removal of legacy permission system support. SuperPerms only now. --- Changelog.txt | 1 + pom.xml | 14 - src/main/java/com/gmail/nossr50/mcMMO.java | 8 +- .../java/com/gmail/nossr50/mcPermissions.java | 285 +++--------------- 4 files changed, 45 insertions(+), 263 deletions(-) diff --git a/Changelog.txt b/Changelog.txt index b3be75e8d..3f3f7314e 100644 --- a/Changelog.txt +++ b/Changelog.txt @@ -2,6 +2,7 @@ Changelog: #Versions without changelogs probably had very small misc fixes, like tweaks to the source code Version 2.0-dev + - Removed legacy Permission & PEX support. SuperPerms support only now. Version 1.2.10 - Fixed issue with receiving Woodcutting XP for all blocks broken (Issue #103) diff --git a/pom.xml b/pom.xml index e462537d1..78ef56cfa 100644 --- a/pom.xml +++ b/pom.xml @@ -118,20 +118,6 @@ jar compile - - com.nijikokun.bukkit - Permissions - 3.1.6 - jar - compile - - - ru.tehkode.permissions - bukkit - 1.18 - jar - compile - org.getspout spoutpluginapi diff --git a/src/main/java/com/gmail/nossr50/mcMMO.java b/src/main/java/com/gmail/nossr50/mcMMO.java index a3c22d8db..e26edf6b4 100644 --- a/src/main/java/com/gmail/nossr50/mcMMO.java +++ b/src/main/java/com/gmail/nossr50/mcMMO.java @@ -32,7 +32,6 @@ import com.gmail.nossr50.listeners.mcPlayerListener; import com.gmail.nossr50.locale.mcLocale; import com.gmail.nossr50.party.Party; import com.gmail.nossr50.skills.*; -import com.nijikokun.bukkit.Permissions.Permissions; import org.bukkit.Bukkit; @@ -82,9 +81,6 @@ public class mcMMO extends JavaPlugin private final mcPlayerListener playerListener = new mcPlayerListener(this); private final mcBlockListener blockListener = new mcBlockListener(this); private final mcEntityListener entityListener = new mcEntityListener(this); - - public static mcPermissions permissionHandler = new mcPermissions(); - private Permissions permissions; private Runnable mcMMO_Timer = new mcTimer(this); //BLEED AND REGENERATION private Runnable ChangeDataValueTimer = new ChangeDataValueTimer(this); //R2 block place workaround @@ -249,9 +245,7 @@ public class mcMMO extends JavaPlugin PlayerProfile PP = Users.getProfile(player); return PP.inParty(); } - public Permissions getPermissions() { - return permissions; - } + public void onDisable() { Bukkit.getServer().getScheduler().cancelTasks(this); System.out.println("mcMMO was disabled."); diff --git a/src/main/java/com/gmail/nossr50/mcPermissions.java b/src/main/java/com/gmail/nossr50/mcPermissions.java index a5bcb42fa..7c89c7375 100644 --- a/src/main/java/com/gmail/nossr50/mcPermissions.java +++ b/src/main/java/com/gmail/nossr50/mcPermissions.java @@ -20,333 +20,134 @@ 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 volatile mcPermissions instance; - - private enum PermissionType { - PEX, PERMISSIONS, BUKKIT - } - - private static PermissionType permissionType; - private static Object PHandle; - public static boolean permissionsEnabled = false; + public static void initialize(Server server) { Logger log = Logger.getLogger("Minecraft"); - - if(permissionsEnabled && permissionType != PermissionType.PERMISSIONS) return; - - Plugin PEXtest = server.getPluginManager().getPlugin("PermissionsEx"); - Plugin test = server.getPluginManager().getPlugin("Permissions"); - if(PEXtest != null) { - PHandle = (PermissionManager) PermissionsEx.getPermissionManager(); - permissionType = PermissionType.PEX; - permissionsEnabled = true; - log.info("[mcMMO] PermissionsEx found, using PermissionsEx."); - } else if(test != null) { - PHandle = (PermissionHandler) ((Permissions) test).getHandler(); - permissionType = PermissionType.PERMISSIONS; - permissionsEnabled = true; - log.info("[mcMMO] Permissions version "+test.getDescription().getVersion()+" found, using Permissions."); - } else { - permissionType = PermissionType.BUKKIT; - permissionsEnabled = true; - log.info("[mcMMO] Using Bukkit Permissions."); - } } - - public static boolean getEnabled() - { - return permissionsEnabled; - } - - public static boolean permission(Player player, String permission) - { - if(!permissionsEnabled) return player.isOp(); - switch(permissionType) { - case PEX: - return ((PermissionManager) PHandle).has(player, permission); - case PERMISSIONS: - return ((PermissionHandler) PHandle).has(player, permission); - case BUKKIT: - return player.hasPermission(permission); - default: - return true; - } - } + public boolean admin(Player player){ - if (permissionsEnabled) { - return permission(player, "mcmmo.admin"); - } else { - return true; - } + return player.hasPermission("mcmmo.admin"); } public boolean mcrefresh(Player player) { - if (permissionsEnabled) { - return permission(player, "mcmmo.tools.mcrefresh"); - } else { - return true; - } + return player.hasPermission("mcmmo.tools.mcrefresh"); } public boolean mmoedit(Player player) { - if (permissionsEnabled) { - return permission(player, "mcmmo.tools.mmoedit"); - } else { - return true; - } + return player.hasPermission("mcmmo.tools.mmoedit"); } public boolean herbalismAbility(Player player){ - if (permissionsEnabled) { - return permission(player, "mcmmo.ability.herbalism"); - } else { - return true; - } + return player.hasPermission("mcmmo.ability.herbalism"); } public boolean excavationAbility(Player player){ - if (permissionsEnabled) { - return permission(player, "mcmmo.ability.excavation"); - } else { - return true; - } + return player.hasPermission("mcmmo.ability.excavation"); } public boolean unarmedAbility(Player player){ - if (permissionsEnabled) { - return permission(player, "mcmmo.ability.unarmed"); - } else { - return true; - } + return player.hasPermission("mcmmo.ability.unarmed"); } public boolean chimaeraWing(Player player){ - if (permissionsEnabled) { - return permission(player, "mcmmo.item.chimaerawing"); - } else { - return true; - } + return player.hasPermission("mcmmo.item.chimaerawing"); } public boolean miningAbility(Player player){ - if (permissionsEnabled) { - return permission(player, "mcmmo.ability.mining"); - } else { - return true; - } + return player.hasPermission("mcmmo.ability.mining"); } public boolean axesAbility(Player player){ - if (permissionsEnabled) { - return permission(player, "mcmmo.ability.axes"); - } else { - return true; - } + return player.hasPermission("mcmmo.ability.axes"); } + public boolean swordsAbility(Player player){ - if (permissionsEnabled) { - return permission(player, "mcmmo.ability.swords"); - } else { - return true; - } + return player.hasPermission("mcmmo.ability.swords"); } public boolean woodCuttingAbility(Player player) { - if (permissionsEnabled) { - return permission(player, "mcmmo.ability.woodcutting"); - } else { - return true; - } + return player.hasPermission("mcmmo.ability.woodcutting"); } public boolean mcgod(Player player) { - if (permissionsEnabled) { - return permission(player, "mcmmo.tools.mcgod"); - } else { - return true; - } + return player.hasPermission("mcmmo.tools.mcgod"); } public boolean regeneration(Player player){ - if (permissionsEnabled) { - return permission(player, "mcmmo.regeneration"); - } else { - return true; - } + return player.hasPermission("mcmmo.regeneration"); } public boolean motd(Player player) { - if (permissionsEnabled) { - return permission(player, "mcmmo.motd"); - } else { - return true; - } + return player.hasPermission("mcmmo.motd"); } public boolean mcAbility(Player player) { - if (permissionsEnabled) { - return permission(player, "mcmmo.commands.ability"); - } else { - return true; - } + return player.hasPermission("mcmmo.commands.ability"); } public boolean mySpawn(Player player) { - if (permissionsEnabled) { - return permission(player, "mcmmo.commands.myspawn"); - } else { - return true; - } + return player.hasPermission("mcmmo.commands.myspawn"); } public boolean setMySpawn(Player player) { - if (permissionsEnabled) { - return permission(player, "mcmmo.commands.setmyspawn"); - } else { - return true; - } + return player.hasPermission("mcmmo.commands.setmyspawn"); } public boolean partyChat(Player player) { - if (permissionsEnabled) { - return permission(player, "mcmmo.chat.partychat"); - } else { - return true; - } + return player.hasPermission("mcmmo.chat.partychat"); } public boolean partyLock(Player player) { - if (permissionsEnabled) { - return permission(player, "mcmmo.chat.partylock"); - } else { - return true; - } + return player.hasPermission("mcmmo.chat.partylock"); } public boolean partyTeleport(Player player) { - if (permissionsEnabled) { - return permission(player, "mcmmo.commands.ptp"); - } else { - return true; - } + return player.hasPermission("mcmmo.commands.ptp"); } public boolean whois(Player player) { - if (permissionsEnabled) { - return permission(player, "mcmmo.commands.whois"); - } else { - return true; - } + return player.hasPermission("mcmmo.commands.whois"); } public boolean party(Player player) { - if (permissionsEnabled) { - return permission(player, "mcmmo.commands.party"); - } else { - return true; - } + return player.hasPermission("mcmmo.commands.party"); } public boolean adminChat(Player player) { - if (permissionsEnabled) { - return permission(player, "mcmmo.chat.adminchat"); - } else { - return true; - } + return player.hasPermission("mcmmo.chat.adminchat"); } public static mcPermissions getInstance() { if (instance == null) { - instance = new mcPermissions(); + instance = new mcPermissions(); } return instance; - } + } + public boolean taming(Player player) { - if (permissionsEnabled) { - return permission(player, "mcmmo.skills.taming"); - } else { - return true; - } + return player.hasPermission("mcmmo.skills.taming"); } public boolean mining(Player player) { - if (permissionsEnabled) { - return permission(player, "mcmmo.skills.mining"); - } else { - return true; - } + return player.hasPermission("mcmmo.skills.mining"); } public boolean fishing(Player player) { - if (permissionsEnabled) { - return permission(player, "mcmmo.skills.fishing"); - } else { - return true; - } + return player.hasPermission("mcmmo.skills.fishing"); } public boolean alchemy(Player player) { - if (permissionsEnabled) { - return permission(player, "mcmmo.skills.alchemy"); - } else { - return true; - } + return player.hasPermission("mcmmo.skills.alchemy"); } public boolean enchanting(Player player) { - if (permissionsEnabled) { - return permission(player, "mcmmo.skills.enchanting"); - } else { - return true; - } + return player.hasPermission("mcmmo.skills.enchanting"); } public boolean woodcutting(Player player) { - if (permissionsEnabled) { - return permission(player, "mcmmo.skills.woodcutting"); - } else { - return true; - } + return player.hasPermission("mcmmo.skills.woodcutting"); } public boolean repair(Player player) { - if (permissionsEnabled) { - return permission(player, "mcmmo.skills.repair"); - } else { - return true; - } + return player.hasPermission("mcmmo.skills.repair"); } public boolean unarmed(Player player) { - if (permissionsEnabled) { - return permission(player, "mcmmo.skills.unarmed"); - } else { - return true; - } + return player.hasPermission("mcmmo.skills.unarmed"); } public boolean archery(Player player) { - if (permissionsEnabled) { - return permission(player, "mcmmo.skills.archery"); - } else { - return true; - } + return player.hasPermission("mcmmo.skills.archery"); } public boolean herbalism(Player player) { - if (permissionsEnabled) { - return permission(player, "mcmmo.skills.herbalism"); - } else { - return true; - } + return player.hasPermission("mcmmo.skills.herbalism"); } public boolean excavation(Player player) { - if (permissionsEnabled) { - return permission(player, "mcmmo.skills.excavation"); - } else { - return true; - } + return player.hasPermission("mcmmo.skills.excavation"); } public boolean swords(Player player) { - if (permissionsEnabled) { - return permission(player, "mcmmo.skills.swords"); - } else { - return true; - } + return player.hasPermission("mcmmo.skills.swords"); } public boolean axes(Player player) { - if (permissionsEnabled) { - return permission(player, "mcmmo.skills.axes"); - } else { - return true; - } + return player.hasPermission("mcmmo.skills.axes"); } public boolean acrobatics(Player player) { - if (permissionsEnabled) { - return permission(player, "mcmmo.skills.acrobatics"); - } else { - return true; - } + return player.hasPermission("mcmmo.skills.acrobatics"); } }