mirror of
https://github.com/Multiverse/Multiverse-Core.git
synced 2024-11-25 12:05:14 +01:00
Add opfallback to config; Permissions cleanup
This commit is contained in:
parent
46ed043104
commit
ea45d2675e
@ -45,9 +45,9 @@ public class MVPermissions {
|
||||
return true;
|
||||
}
|
||||
Player player = (Player) sender;
|
||||
// TODO:
|
||||
if (player.isOp()) {
|
||||
// If Player is Op we always let them use it.
|
||||
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 (MultiverseCore.Permissions != null && MultiverseCore.Permissions.has(player, node)) {
|
||||
// If Permissions is enabled we check against them.
|
||||
@ -55,7 +55,10 @@ public class MVPermissions {
|
||||
}
|
||||
// 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
|
||||
return !isOpRequired;
|
||||
// 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;
|
||||
}
|
||||
|
||||
|
||||
|
@ -28,15 +28,15 @@ public class MVPluginListener extends ServerListener {
|
||||
* Check to see if Permissions was just enabled, we only wan't to perform the following if GroupManager is not found.
|
||||
*/
|
||||
if (event.getPlugin().getDescription().getName().equals("Permissions")) {
|
||||
MultiverseCore.Permissions = ((Permissions) plugin.getServer().getPluginManager().getPlugin("Permissions")).getHandler();
|
||||
plugin.log(Level.INFO, "- Attached to Permissions");
|
||||
MultiverseCore.Permissions = ((Permissions) this.plugin.getServer().getPluginManager().getPlugin("Permissions")).getHandler();
|
||||
this.plugin.log(Level.INFO, "- Attached to Permissions");
|
||||
}
|
||||
|
||||
// TODO: Use AllPay
|
||||
/**
|
||||
* Use the METHOD supplied by iConomy to register it etc...
|
||||
*/
|
||||
if (MultiverseCore.getiConomy() == null) {
|
||||
Plugin iConomy = plugin.getServer().getPluginManager().getPlugin("iConomy");
|
||||
if(event.getPlugin().getDescription().getName().equals("iConomy")) {
|
||||
Plugin iConomy = this.plugin.getServer().getPluginManager().getPlugin("iConomy");
|
||||
|
||||
if (iConomy != null) {
|
||||
if (iConomy.isEnabled()) {
|
||||
|
@ -61,7 +61,7 @@ public class MultiverseCore extends JavaPlugin {
|
||||
private boolean debug;
|
||||
|
||||
// Setup our Map for our Commands using the CommandHandler.
|
||||
private CommandManager commandManager = new CommandManager();
|
||||
private CommandManager commandManager;
|
||||
|
||||
private final String tag = "[Multiverse-Core]";
|
||||
|
||||
@ -117,6 +117,8 @@ public class MultiverseCore extends JavaPlugin {
|
||||
this.registerEvents();
|
||||
// Setup Permissions, we'll do an initial check for the Permissions plugin then fall back on isOP().
|
||||
this.setupPermissions();
|
||||
// Setup thte command manager
|
||||
this.commandManager = new CommandManager(this);
|
||||
// Setup iConomy.
|
||||
this.setupEconomy();
|
||||
// Call the Function to assign all the Commands to their Class.
|
||||
|
@ -21,9 +21,11 @@ import com.onarandombox.MultiverseCore.MultiverseCore;
|
||||
public class CommandManager {
|
||||
|
||||
protected List<BaseCommand> commands;
|
||||
private MultiverseCore plugin;
|
||||
|
||||
public CommandManager() {
|
||||
public CommandManager(MultiverseCore plugin) {
|
||||
this.commands = new ArrayList<BaseCommand>();
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
public boolean dispatch(CommandSender sender, Command command, String label, String[] args) {
|
||||
@ -46,7 +48,7 @@ public class CommandManager {
|
||||
}
|
||||
|
||||
if (match != null) {
|
||||
if (this.hasPermission(sender, match.getPermission(), match.isOpRequired())) {
|
||||
if (this.plugin.ph.hasPermission(sender, match.getPermission(), match.isOpRequired())) {
|
||||
if (trimmedArgs != null) {
|
||||
match.execute(sender, trimmedArgs);
|
||||
} else {
|
||||
@ -77,7 +79,7 @@ public class CommandManager {
|
||||
public List<BaseCommand> getCommands(CommandSender sender) {
|
||||
ArrayList<BaseCommand> playerCommands = new ArrayList<BaseCommand>();
|
||||
for(BaseCommand c : this.commands) {
|
||||
if(this.hasPermission(sender, c.permission, c.isOpRequired())) {
|
||||
if(this.plugin.ph.hasPermission(sender, c.permission, c.isOpRequired())) {
|
||||
playerCommands.add(c);
|
||||
}
|
||||
}
|
||||
@ -138,23 +140,4 @@ public class CommandManager {
|
||||
}
|
||||
return returnVal.replace("\"", "");
|
||||
}
|
||||
|
||||
public boolean hasPermission(CommandSender sender, String node, boolean isOpRequired) {
|
||||
|
||||
if (!(sender instanceof Player)) {
|
||||
return true;
|
||||
}
|
||||
Player player = (Player) sender;
|
||||
|
||||
if (player.isOp()) {
|
||||
// If Player is Op we always let them use it.
|
||||
return true;
|
||||
} else if (MultiverseCore.Permissions != null && MultiverseCore.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
|
||||
return !isOpRequired;
|
||||
}
|
||||
}
|
||||
|
@ -24,4 +24,4 @@ worldnameprefix: true
|
||||
# people defined in ops.txt? Remember, if you use ops based permissions
|
||||
# the awesome Multiverse devs get to decide which commands require op!
|
||||
# (Which is why we highly recomend a permissions plugin! You shouldn't trust us this much...)
|
||||
fallbacktoops: true
|
||||
opfallback: true
|
Loading…
Reference in New Issue
Block a user