Merge branch 'perms' into perf

This commit is contained in:
taoneill 2011-06-05 00:59:39 -04:00
commit ab576e09da
3 changed files with 28 additions and 20 deletions

View File

@ -8,6 +8,6 @@
<classpathentry combineaccessrules="false" kind="src" path="/craftbukkit"/>
<classpathentry kind="con" path="org.eclipse.jdt.junit.JUNIT_CONTAINER/4"/>
<classpathentry kind="lib" path="C:/dev/war/war/lib/mockito-all-1.8.5.jar"/>
<classpathentry kind="lib" path="C:/dev/war/war/lib/EssentialsGroupBridge.jar"/>
<classpathentry combineaccessrules="false" kind="src" path="/Permissions"/>
<classpathentry kind="output" path="target/classes"/>
</classpath>

View File

@ -45,5 +45,12 @@
<version>0.0.1-SNAPSHOT</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.nijikokun.bukkit</groupId>
<artifactId>Permissions</artifactId>
<version>2.7.4</version>
<type>jar</type>
<scope>compile</scope>
</dependency>
</dependencies>
</project>

View File

@ -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();
@ -1384,12 +1385,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;
}
@ -1397,12 +1398,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;
}
@ -1411,9 +1412,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
@ -1433,9 +1434,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;
}
}
@ -1527,10 +1528,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.");
}