Removal of legacy permission system support. SuperPerms only now.

This commit is contained in:
TheYeti 2012-02-06 10:48:02 -08:00
parent 44e954efeb
commit 5645c29dd8
4 changed files with 45 additions and 263 deletions

View File

@ -2,6 +2,7 @@ Changelog:
#Versions without changelogs probably had very small misc fixes, like tweaks to the source code #Versions without changelogs probably had very small misc fixes, like tweaks to the source code
Version 2.0-dev Version 2.0-dev
- Removed legacy Permission & PEX support. SuperPerms support only now.
Version 1.2.10 Version 1.2.10
- Fixed issue with receiving Woodcutting XP for all blocks broken (Issue #103) - Fixed issue with receiving Woodcutting XP for all blocks broken (Issue #103)

14
pom.xml
View File

@ -118,20 +118,6 @@
<type>jar</type> <type>jar</type>
<scope>compile</scope> <scope>compile</scope>
</dependency> </dependency>
<dependency>
<groupId>com.nijikokun.bukkit</groupId>
<artifactId>Permissions</artifactId>
<version>3.1.6</version>
<type>jar</type>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>ru.tehkode.permissions</groupId>
<artifactId>bukkit</artifactId>
<version>1.18</version>
<type>jar</type>
<scope>compile</scope>
</dependency>
<dependency> <dependency>
<groupId>org.getspout</groupId> <groupId>org.getspout</groupId>
<artifactId>spoutpluginapi</artifactId> <artifactId>spoutpluginapi</artifactId>

View File

@ -32,7 +32,6 @@ import com.gmail.nossr50.listeners.mcPlayerListener;
import com.gmail.nossr50.locale.mcLocale; import com.gmail.nossr50.locale.mcLocale;
import com.gmail.nossr50.party.Party; import com.gmail.nossr50.party.Party;
import com.gmail.nossr50.skills.*; import com.gmail.nossr50.skills.*;
import com.nijikokun.bukkit.Permissions.Permissions;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
@ -82,9 +81,6 @@ public class mcMMO extends JavaPlugin
private final mcPlayerListener playerListener = new mcPlayerListener(this); private final mcPlayerListener playerListener = new mcPlayerListener(this);
private final mcBlockListener blockListener = new mcBlockListener(this); private final mcBlockListener blockListener = new mcBlockListener(this);
private final mcEntityListener entityListener = new mcEntityListener(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 mcMMO_Timer = new mcTimer(this); //BLEED AND REGENERATION
private Runnable ChangeDataValueTimer = new ChangeDataValueTimer(this); //R2 block place workaround private Runnable ChangeDataValueTimer = new ChangeDataValueTimer(this); //R2 block place workaround
@ -249,9 +245,7 @@ public class mcMMO extends JavaPlugin
PlayerProfile PP = Users.getProfile(player); PlayerProfile PP = Users.getProfile(player);
return PP.inParty(); return PP.inParty();
} }
public Permissions getPermissions() {
return permissions;
}
public void onDisable() { public void onDisable() {
Bukkit.getServer().getScheduler().cancelTasks(this); Bukkit.getServer().getScheduler().cancelTasks(this);
System.out.println("mcMMO was disabled."); System.out.println("mcMMO was disabled.");

View File

@ -20,333 +20,134 @@ 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 ru.tehkode.permissions.PermissionManager;
import ru.tehkode.permissions.bukkit.PermissionsEx;
import com.nijiko.permissions.PermissionHandler;
import com.nijikokun.bukkit.Permissions.Permissions;
public class mcPermissions public class mcPermissions
{ {
private static volatile mcPermissions instance; 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) public static void initialize(Server server)
{ {
Logger log = Logger.getLogger("Minecraft"); 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){ public boolean admin(Player player){
if (permissionsEnabled) { return player.hasPermission("mcmmo.admin");
return permission(player, "mcmmo.admin");
} else {
return true;
}
} }
public boolean mcrefresh(Player player) { public boolean mcrefresh(Player player) {
if (permissionsEnabled) { return player.hasPermission("mcmmo.tools.mcrefresh");
return permission(player, "mcmmo.tools.mcrefresh");
} else {
return true;
}
} }
public boolean mmoedit(Player player) { public boolean mmoedit(Player player) {
if (permissionsEnabled) { return player.hasPermission("mcmmo.tools.mmoedit");
return permission(player, "mcmmo.tools.mmoedit");
} else {
return true;
}
} }
public boolean herbalismAbility(Player player){ public boolean herbalismAbility(Player player){
if (permissionsEnabled) { return player.hasPermission("mcmmo.ability.herbalism");
return permission(player, "mcmmo.ability.herbalism");
} else {
return true;
}
} }
public boolean excavationAbility(Player player){ public boolean excavationAbility(Player player){
if (permissionsEnabled) { return player.hasPermission("mcmmo.ability.excavation");
return permission(player, "mcmmo.ability.excavation");
} else {
return true;
}
} }
public boolean unarmedAbility(Player player){ public boolean unarmedAbility(Player player){
if (permissionsEnabled) { return player.hasPermission("mcmmo.ability.unarmed");
return permission(player, "mcmmo.ability.unarmed");
} else {
return true;
}
} }
public boolean chimaeraWing(Player player){ public boolean chimaeraWing(Player player){
if (permissionsEnabled) { return player.hasPermission("mcmmo.item.chimaerawing");
return permission(player, "mcmmo.item.chimaerawing");
} else {
return true;
}
} }
public boolean miningAbility(Player player){ public boolean miningAbility(Player player){
if (permissionsEnabled) { return player.hasPermission("mcmmo.ability.mining");
return permission(player, "mcmmo.ability.mining");
} else {
return true;
}
} }
public boolean axesAbility(Player player){ public boolean axesAbility(Player player){
if (permissionsEnabled) { return player.hasPermission("mcmmo.ability.axes");
return permission(player, "mcmmo.ability.axes");
} else {
return true;
}
} }
public boolean swordsAbility(Player player){ public boolean swordsAbility(Player player){
if (permissionsEnabled) { return player.hasPermission("mcmmo.ability.swords");
return permission(player, "mcmmo.ability.swords");
} else {
return true;
}
} }
public boolean woodCuttingAbility(Player player) { public boolean woodCuttingAbility(Player player) {
if (permissionsEnabled) { return player.hasPermission("mcmmo.ability.woodcutting");
return permission(player, "mcmmo.ability.woodcutting");
} else {
return true;
}
} }
public boolean mcgod(Player player) { public boolean mcgod(Player player) {
if (permissionsEnabled) { return player.hasPermission("mcmmo.tools.mcgod");
return permission(player, "mcmmo.tools.mcgod");
} else {
return true;
}
} }
public boolean regeneration(Player player){ public boolean regeneration(Player player){
if (permissionsEnabled) { return player.hasPermission("mcmmo.regeneration");
return permission(player, "mcmmo.regeneration");
} else {
return true;
}
} }
public boolean motd(Player player) { public boolean motd(Player player) {
if (permissionsEnabled) { return player.hasPermission("mcmmo.motd");
return permission(player, "mcmmo.motd");
} else {
return true;
}
} }
public boolean mcAbility(Player player) { public boolean mcAbility(Player player) {
if (permissionsEnabled) { return player.hasPermission("mcmmo.commands.ability");
return permission(player, "mcmmo.commands.ability");
} else {
return true;
}
} }
public boolean mySpawn(Player player) { public boolean mySpawn(Player player) {
if (permissionsEnabled) { return player.hasPermission("mcmmo.commands.myspawn");
return permission(player, "mcmmo.commands.myspawn");
} else {
return true;
}
} }
public boolean setMySpawn(Player player) { public boolean setMySpawn(Player player) {
if (permissionsEnabled) { return player.hasPermission("mcmmo.commands.setmyspawn");
return permission(player, "mcmmo.commands.setmyspawn");
} else {
return true;
}
} }
public boolean partyChat(Player player) { public boolean partyChat(Player player) {
if (permissionsEnabled) { return player.hasPermission("mcmmo.chat.partychat");
return permission(player, "mcmmo.chat.partychat");
} else {
return true;
}
} }
public boolean partyLock(Player player) { public boolean partyLock(Player player) {
if (permissionsEnabled) { return player.hasPermission("mcmmo.chat.partylock");
return permission(player, "mcmmo.chat.partylock");
} else {
return true;
}
} }
public boolean partyTeleport(Player player) { public boolean partyTeleport(Player player) {
if (permissionsEnabled) { return player.hasPermission("mcmmo.commands.ptp");
return permission(player, "mcmmo.commands.ptp");
} else {
return true;
}
} }
public boolean whois(Player player) { public boolean whois(Player player) {
if (permissionsEnabled) { return player.hasPermission("mcmmo.commands.whois");
return permission(player, "mcmmo.commands.whois");
} else {
return true;
}
} }
public boolean party(Player player) { public boolean party(Player player) {
if (permissionsEnabled) { return player.hasPermission("mcmmo.commands.party");
return permission(player, "mcmmo.commands.party");
} else {
return true;
}
} }
public boolean adminChat(Player player) { public boolean adminChat(Player player) {
if (permissionsEnabled) { return player.hasPermission("mcmmo.chat.adminchat");
return permission(player, "mcmmo.chat.adminchat");
} else {
return true;
}
} }
public static mcPermissions getInstance() { public static mcPermissions getInstance() {
if (instance == null) { if (instance == null) {
instance = new mcPermissions(); instance = new mcPermissions();
} }
return instance; return instance;
} }
public boolean taming(Player player) { public boolean taming(Player player) {
if (permissionsEnabled) { return player.hasPermission("mcmmo.skills.taming");
return permission(player, "mcmmo.skills.taming");
} else {
return true;
}
} }
public boolean mining(Player player) { public boolean mining(Player player) {
if (permissionsEnabled) { return player.hasPermission("mcmmo.skills.mining");
return permission(player, "mcmmo.skills.mining");
} else {
return true;
}
} }
public boolean fishing(Player player) { public boolean fishing(Player player) {
if (permissionsEnabled) { return player.hasPermission("mcmmo.skills.fishing");
return permission(player, "mcmmo.skills.fishing");
} else {
return true;
}
} }
public boolean alchemy(Player player) { public boolean alchemy(Player player) {
if (permissionsEnabled) { return player.hasPermission("mcmmo.skills.alchemy");
return permission(player, "mcmmo.skills.alchemy");
} else {
return true;
}
} }
public boolean enchanting(Player player) { public boolean enchanting(Player player) {
if (permissionsEnabled) { return player.hasPermission("mcmmo.skills.enchanting");
return permission(player, "mcmmo.skills.enchanting");
} else {
return true;
}
} }
public boolean woodcutting(Player player) { public boolean woodcutting(Player player) {
if (permissionsEnabled) { return player.hasPermission("mcmmo.skills.woodcutting");
return permission(player, "mcmmo.skills.woodcutting");
} else {
return true;
}
} }
public boolean repair(Player player) { public boolean repair(Player player) {
if (permissionsEnabled) { return player.hasPermission("mcmmo.skills.repair");
return permission(player, "mcmmo.skills.repair");
} else {
return true;
}
} }
public boolean unarmed(Player player) { public boolean unarmed(Player player) {
if (permissionsEnabled) { return player.hasPermission("mcmmo.skills.unarmed");
return permission(player, "mcmmo.skills.unarmed");
} else {
return true;
}
} }
public boolean archery(Player player) { public boolean archery(Player player) {
if (permissionsEnabled) { return player.hasPermission("mcmmo.skills.archery");
return permission(player, "mcmmo.skills.archery");
} else {
return true;
}
} }
public boolean herbalism(Player player) { public boolean herbalism(Player player) {
if (permissionsEnabled) { return player.hasPermission("mcmmo.skills.herbalism");
return permission(player, "mcmmo.skills.herbalism");
} else {
return true;
}
} }
public boolean excavation(Player player) { public boolean excavation(Player player) {
if (permissionsEnabled) { return player.hasPermission("mcmmo.skills.excavation");
return permission(player, "mcmmo.skills.excavation");
} else {
return true;
}
} }
public boolean swords(Player player) { public boolean swords(Player player) {
if (permissionsEnabled) { return player.hasPermission("mcmmo.skills.swords");
return permission(player, "mcmmo.skills.swords");
} else {
return true;
}
} }
public boolean axes(Player player) { public boolean axes(Player player) {
if (permissionsEnabled) { return player.hasPermission("mcmmo.skills.axes");
return permission(player, "mcmmo.skills.axes");
} else {
return true;
}
} }
public boolean acrobatics(Player player) { public boolean acrobatics(Player player) {
if (permissionsEnabled) { return player.hasPermission("mcmmo.skills.acrobatics");
return permission(player, "mcmmo.skills.acrobatics");
} else {
return true;
}
} }
} }