Implement permissions

This commit is contained in:
Eric Stokes 2011-07-09 20:21:22 -06:00
parent a8999ee5a1
commit 8adf06f247
2 changed files with 41 additions and 40 deletions

View File

@ -10,7 +10,7 @@ import org.bukkit.entity.Player;
import com.nijiko.permissions.PermissionHandler;
import com.pneumaticraft.commandhandler.PermissionsInterface;
public class MVPermissions implements PermissionsInterface{
public class MVPermissions implements PermissionsInterface {
private MultiverseCore plugin;
public PermissionHandler permissions = null;
@ -23,8 +23,8 @@ public class MVPermissions implements PermissionsInterface{
public MVPermissions(MultiverseCore plugin) {
this.plugin = plugin;
// We have to see if permissions was loaded before MV was
if(this.plugin.getServer().getPluginManager().getPlugin("Permissions") != null) {
this.setPermissions(((com.nijikokun.bukkit.Permissions.Permissions)this.plugin.getServer().getPluginManager().getPlugin("Permissions")).getHandler());
if (this.plugin.getServer().getPluginManager().getPlugin("Permissions") != null) {
this.setPermissions(((com.nijikokun.bukkit.Permissions.Permissions) this.plugin.getServer().getPluginManager().getPlugin("Permissions")).getHandler());
this.plugin.log(Level.INFO, "- Attached to Permissions");
}
}
@ -49,28 +49,6 @@ public class MVPermissions implements PermissionsInterface{
return result;
}
public boolean hasPermission(CommandSender sender, String node, boolean isOpRequired) {
if (!(sender instanceof Player)) {
return true;
}
Player player = (Player) sender;
boolean opFallback = this.plugin.configMV.getBoolean("opfallback", true);
if (player.isOp() && opFallback) {
// If Player is Op we always let them use it if they have the fallback enabled!
return true;
} else if (this.permissions != null && this.permissions.has(player, node)) {
// If Permissions is enabled we check against them.
return true;
}
// If the Player doesn't have Permissions and isn't an Op then
// we return true if OP is not required, otherwise we return false
// This allows us to act as a default permission guidance
// If they have the op fallback disabled, NO commands will work without a permissions plugin.
return !isOpRequired && opFallback;
}
/**
* Check if a Player can teleport to the Destination world from there current world. This checks against the Worlds Blacklist
*
@ -160,4 +138,27 @@ public class MVPermissions implements PermissionsInterface{
public void setPermissions(PermissionHandler handler) {
this.permissions = handler;
}
public boolean hasPermission(CommandSender sender, String node, boolean isOpRequired) {
if (!(sender instanceof Player)) {
return true;
}
Player player = (Player) sender;
boolean opFallback = this.plugin.configMV.getBoolean("opfallback", true);
if (player.isOp() && opFallback) {
// If Player is Op we always let them use it if they have the fallback enabled!
return true;
} else if (this.permissions != null && this.permissions.has(player, node)) {
// If Permissions is enabled we check against them.
return true;
}
// If the Player doesn't have Permissions and isn't an Op then
// we return true if OP is not required, otherwise we return false
// This allows us to act as a default permission guidance
// If they have the op fallback disabled, NO commands will work without a permissions plugin.
return !isOpRequired && opFallback;
}
}

View File

@ -92,7 +92,7 @@ public class MultiverseCore extends JavaPlugin {
this.bank = this.banker.loadEconPlugin();
// Setup the command manager
this.commandHandler = new CommandHandler(this);
this.commandHandler = new CommandHandler(this,this.ph);
// Setup the world purger
this.worldPurger = new PurgeWorlds(this);
// Call the Function to assign all the Commands to their Class.