Final updates to work with Bukkit Permissions. Yes. MV2 works with the built in Bukkit Permissions system NOW!

The other plugins, however, do not :P Yet.
This commit is contained in:
Eric Stokes 2011-07-17 13:37:49 -06:00
parent 3c4135236d
commit 2d48cda537
3 changed files with 23 additions and 12 deletions

View File

@ -95,17 +95,19 @@ public class MVPermissions implements PermissionsInterface {
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 (this.permissions != null && this.permissions.has(player, node)) {
// If Permissions is enabled we check against them.
return true;
} else if(sender.hasPermission(node)) {
} else if (sender.hasPermission(node) && !opFallback) {
// If Now check the bukkit permissions
// OpFallback must be disabled for this to work
return true;
} else if (player.isOp() && opFallback) {
// If Player is Op we always let them use it if they have the fallback enabled!
return true;
}
// If the Player doesn't have Permissions and isn't an Op then

View File

@ -8,6 +8,8 @@ import java.util.logging.Level;
import org.bukkit.ChatColor;
import org.bukkit.World;
import org.bukkit.World.Environment;
import org.bukkit.permissions.Permission;
import org.bukkit.permissions.PermissionDefault;
import org.bukkit.util.config.Configuration;
enum EnglishChatColor {
@ -88,6 +90,7 @@ public class MVWorld {
* The generator as a string. This is used only for reporting. ex: BukkitFullOfMoon:GenID
*/
private String generator;
private Permission permission;
public MVWorld(World world, Configuration config, MultiverseCore instance, Long seed, String generatorString) {
this.config = config;
@ -128,6 +131,11 @@ public class MVWorld {
this.translateTempSpawn(config);
config.save();
this.permission = new Permission("multiverse.access." + this.getName(), "Allows access to " + this.getName(), PermissionDefault.TRUE);
try {
this.plugin.getServer().getPluginManager().addPermission(this.permission);
} catch (IllegalArgumentException e) {
}
// The following 3 lines will add some sample data to new worlds created.
// if (config.getIntList("worlds." + name + ".blockBlacklist", new ArrayList<Integer>()).size() == 0) {
// addSampleData();

View File

@ -23,7 +23,7 @@ public class TeleportCommand extends MultiverseCommand {
public TeleportCommand(MultiverseCore plugin) {
super(plugin);
Permission self = new Permission("multiverse.core.tp.self", "Allows you to teleport yourself to other worlds.", PermissionDefault.OP);
Permission other = new Permission("multiverse.core.tp.self", "Allows you to teleport yourself to other worlds.", PermissionDefault.OP);
Permission other = new Permission("multiverse.core.tp.other", "Allows you to teleport yourself to other worlds.", PermissionDefault.OP);
this.plugin.getServer().getPluginManager().addPermission(self);
this.plugin.getServer().getPluginManager().addPermission(other);
Map<String, Boolean> children = new HashMap<String, Boolean>();
@ -37,6 +37,7 @@ public class TeleportCommand extends MultiverseCommand {
this.addKey("mvtp");
this.addKey("mv tp");
this.setPermission(tp);
this.playerTeleporter = new MVTeleport(this.plugin);
}
@Override
@ -51,8 +52,8 @@ public class TeleportCommand extends MultiverseCommand {
String worldName;
if (args.size() == 2) {
if (teleporter != null && !this.plugin.getPermissions().hasPermission(sender, "multiverse.world.tp.other", true)) {
sender.sendMessage("You don't have permission to teleport another player. (multiverse.world.tp.other)");
if (teleporter != null && !this.plugin.getPermissions().hasPermission(sender, "multiverse.core.tp.other", true)) {
sender.sendMessage("You don't have permission to teleport another player. (multiverse.core.tp.other)");
return;
}
teleportee = this.plugin.getServer().getPlayer(args.get(0));
@ -64,8 +65,8 @@ public class TeleportCommand extends MultiverseCommand {
} else {
worldName = args.get(0);
if (teleporter != null && !this.plugin.getPermissions().hasPermission(sender, "multiverse.world.tp.self", true)) {
sender.sendMessage("You don't have permission to teleport yourself between worlds. (multiverse.world.tp.self)");
if (teleporter != null && !this.plugin.getPermissions().hasPermission(sender, "multiverse.core.tp.self", true)) {
sender.sendMessage("You don't have permission to teleport yourself between worlds. (multiverse.core.tp.self)");
return;
}