mirror of
https://github.com/Multiverse/Multiverse-Core.git
synced 2024-09-09 22:18:16 +02:00
Implement permissions
This commit is contained in:
parent
a8999ee5a1
commit
8adf06f247
@ -10,7 +10,7 @@ import org.bukkit.entity.Player;
|
|||||||
import com.nijiko.permissions.PermissionHandler;
|
import com.nijiko.permissions.PermissionHandler;
|
||||||
import com.pneumaticraft.commandhandler.PermissionsInterface;
|
import com.pneumaticraft.commandhandler.PermissionsInterface;
|
||||||
|
|
||||||
public class MVPermissions implements PermissionsInterface{
|
public class MVPermissions implements PermissionsInterface {
|
||||||
|
|
||||||
private MultiverseCore plugin;
|
private MultiverseCore plugin;
|
||||||
public PermissionHandler permissions = null;
|
public PermissionHandler permissions = null;
|
||||||
@ -23,8 +23,8 @@ public class MVPermissions implements PermissionsInterface{
|
|||||||
public MVPermissions(MultiverseCore plugin) {
|
public MVPermissions(MultiverseCore plugin) {
|
||||||
this.plugin = plugin;
|
this.plugin = plugin;
|
||||||
// We have to see if permissions was loaded before MV was
|
// We have to see if permissions was loaded before MV was
|
||||||
if(this.plugin.getServer().getPluginManager().getPlugin("Permissions") != null) {
|
if (this.plugin.getServer().getPluginManager().getPlugin("Permissions") != null) {
|
||||||
this.setPermissions(((com.nijikokun.bukkit.Permissions.Permissions)this.plugin.getServer().getPluginManager().getPlugin("Permissions")).getHandler());
|
this.setPermissions(((com.nijikokun.bukkit.Permissions.Permissions) this.plugin.getServer().getPluginManager().getPlugin("Permissions")).getHandler());
|
||||||
this.plugin.log(Level.INFO, "- Attached to Permissions");
|
this.plugin.log(Level.INFO, "- Attached to Permissions");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -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;
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -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.
|
||||||
|
Loading…
Reference in New Issue
Block a user