From 1975cce13b20fd7ff1ed78502d1db016977ea975 Mon Sep 17 00:00:00 2001 From: taoneill Date: Sun, 5 Jun 2011 00:58:27 -0400 Subject: [PATCH] Closes gh-217. Now building against Permissions. Tested with GroupManager and Permissions 3.1.4. --- war/.classpath | 2 +- war/pom.xml | 7 ++++ .../main/java/bukkit/tommytony/war/War.java | 39 ++++++++++--------- 3 files changed, 28 insertions(+), 20 deletions(-) diff --git a/war/.classpath b/war/.classpath index fa17e5a..21e4d33 100644 --- a/war/.classpath +++ b/war/.classpath @@ -8,6 +8,6 @@ - + diff --git a/war/pom.xml b/war/pom.xml index 190179e..fbed02c 100644 --- a/war/pom.xml +++ b/war/pom.xml @@ -45,5 +45,12 @@ 0.0.1-SNAPSHOT compile + + com.nijikokun.bukkit + Permissions + 2.7.4 + jar + compile + diff --git a/war/src/main/java/bukkit/tommytony/war/War.java b/war/src/main/java/bukkit/tommytony/war/War.java index 1692aa2..e6f4821 100644 --- a/war/src/main/java/bukkit/tommytony/war/War.java +++ b/war/src/main/java/bukkit/tommytony/war/War.java @@ -24,6 +24,7 @@ import org.bukkit.plugin.PluginDescriptionFile; import org.bukkit.plugin.PluginManager; import org.bukkit.plugin.java.JavaPlugin; +import com.nijiko.permissions.PermissionHandler; import com.nijikokun.bukkit.Permissions.Permissions; import com.tommytony.war.Monument; import com.tommytony.war.Team; @@ -46,7 +47,7 @@ import com.tommytony.war.utils.InventoryStash; * */ public class War extends JavaPlugin { - public static Permissions Permissions = null; + public static PermissionHandler permissionHandler; public War(){ super(); @@ -1381,12 +1382,12 @@ public class War extends JavaPlugin { } public boolean canPlayWar(Player player) { - if(Permissions != null - && (Permissions.Security.permission(player, "war.player") - || Permissions.Security.permission(player, "War.player"))) { + if(War.permissionHandler != null + && (War.permissionHandler.has(player, "war.player") + || War.permissionHandler.has(player, "War.player"))) { return true; } - if(Permissions == null) { + if(War.permissionHandler == null) { // w/o Permissions, everyone can play return true; } @@ -1394,12 +1395,12 @@ public class War extends JavaPlugin { } public boolean canWarp(Player player) { - if(Permissions != null - && (Permissions.Security.permission(player, "war.warp") - || Permissions.Security.permission(player, "War.warp"))) { + if(War.permissionHandler != null + && (War.permissionHandler.has(player, "war.warp") + || War.permissionHandler.has(player, "War.warp"))) { return true; } - if(Permissions == null) { + if(War.permissionHandler == null) { // w/o Permissions, everyone can warp return true; } @@ -1408,9 +1409,9 @@ public class War extends JavaPlugin { public boolean canBuildOutsideZone(Player player) { if(isBuildInZonesOnly()) { - if(Permissions != null - && (Permissions.Security.permission(player, "war.build") - || Permissions.Security.permission(player, "War.build"))) { + if(War.permissionHandler != null + && (War.permissionHandler.has(player, "war.build") + || War.permissionHandler.has(player, "War.build"))) { return true; } // w/o Permissions, if buildInZonesOnly, no one can build outside the zone @@ -1430,9 +1431,9 @@ public class War extends JavaPlugin { for(String zoneMaker : zoneMakerNames) { if(zoneMaker.equals(player.getName())) return true; } - if(Permissions != null - && (Permissions.Security.permission(player, "war.*") - || Permissions.Security.permission(player, "War.*"))) { + if(War.permissionHandler != null + && (War.permissionHandler.has(player, "war.*") + || War.permissionHandler.has(player, "War.*"))) { return true; } } @@ -1524,10 +1525,10 @@ public class War extends JavaPlugin { } public void setupPermissions() { - Plugin test = this.getServer().getPluginManager().getPlugin("Permissions"); - if(Permissions == null) { - if(test != null) { - Permissions = (Permissions)test; + Plugin permissionsPlugin = this.getServer().getPluginManager().getPlugin("Permissions"); + if(this.permissionHandler == null) { + if(permissionsPlugin != null) { + this.permissionHandler = ((Permissions) permissionsPlugin).getHandler(); } else { logInfo("Permissions system not enabled. Defaulting to regular War config."); }