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

@ -49,28 +49,6 @@ public class MVPermissions implements PermissionsInterface{
return result; 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 * 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) { public void setPermissions(PermissionHandler handler) {
this.permissions = 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(); this.bank = this.banker.loadEconPlugin();
// Setup the command manager // Setup the command manager
this.commandHandler = new CommandHandler(this); this.commandHandler = new CommandHandler(this,this.ph);
// Setup the world purger // Setup the world purger
this.worldPurger = new PurgeWorlds(this); this.worldPurger = new PurgeWorlds(this);
// Call the Function to assign all the Commands to their Class. // Call the Function to assign all the Commands to their Class.