Add multiverse.* and all other recursive perms

This commit is contained in:
Eric Stokes 2011-07-20 21:44:43 -06:00
parent e374a97257
commit a3e27da978
4 changed files with 69 additions and 11 deletions

@ -1 +1 @@
Subproject commit c82805a10708224cd9e2eae41e6d28b7f0604b7f
Subproject commit 1261045daa106a084a6883d88524c57844cdb135

View File

@ -133,7 +133,8 @@ public class MVWorld {
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);
this.plugin.getServer().getPluginManager().addPermission(this.permission);
addToUpperLists(this.permission);
} catch (IllegalArgumentException e) {
}
// The following 3 lines will add some sample data to new worlds created.
@ -142,6 +143,23 @@ public class MVWorld {
// }
}
private void addToUpperLists(Permission permission2) {
Permission all = this.plugin.getServer().getPluginManager().getPermission("multiverse.*");
Permission allWorlds = this.plugin.getServer().getPluginManager().getPermission("multiverse.access.*");
if(all == null) {
all = new Permission("multiverse.*");
this.plugin.getServer().getPluginManager().addPermission(all);
}
if(allWorlds == null) {
allWorlds = new Permission("multiverse.access.*");
this.plugin.getServer().getPluginManager().addPermission(allWorlds);
}
all.getChildren().put(this.permission.getName(), true);
allWorlds.getChildren().put(this.permission.getName(), true);
this.plugin.getServer().getPluginManager().recalculatePermissionDefaults(all);
this.plugin.getServer().getPluginManager().recalculatePermissionDefaults(allWorlds);
}
private void translateTempSpawn(Configuration config) {
String tempspawn = config.getString("worlds." + this.name + ".tempspawn", "");
if (tempspawn.length() > 0) {
@ -344,7 +362,7 @@ public class MVWorld {
/**
* This is the one people have access to. It'll handle the rest.
*
*
* @param name
* @param value
* @return
@ -486,7 +504,7 @@ public class MVWorld {
/**
* Sets the chat color from a string.
*
*
* @param aliasColor
*/
public void setAliasColor(String aliasColor) {
@ -533,6 +551,10 @@ public class MVWorld {
public void setRespawnToWorld(String respawnToWorld) {
this.respawnWorld = respawnToWorld;
this.config.setProperty("worlds."+this.name+".respawnworld", respawnToWorld);
this.config.setProperty("worlds." + this.name + ".respawnworld", respawnToWorld);
}
public Permission getPermission() {
return this.permission;
}
}

View File

@ -18,6 +18,7 @@ import org.bukkit.entity.Player;
import org.bukkit.event.Event;
import org.bukkit.event.Event.Priority;
import org.bukkit.generator.ChunkGenerator;
import org.bukkit.permissions.Permission;
import org.bukkit.plugin.Plugin;
import org.bukkit.plugin.PluginManager;
import org.bukkit.plugin.java.JavaPlugin;
@ -25,7 +26,30 @@ import org.bukkit.util.config.Configuration;
import com.fernferret.allpay.AllPay;
import com.fernferret.allpay.GenericBank;
import com.onarandombox.MultiverseCore.commands.*;
import com.onarandombox.MultiverseCore.commands.ConfirmCommand;
import com.onarandombox.MultiverseCore.commands.CoordCommand;
import com.onarandombox.MultiverseCore.commands.CreateCommand;
import com.onarandombox.MultiverseCore.commands.DeleteCommand;
import com.onarandombox.MultiverseCore.commands.EnvironmentCommand;
import com.onarandombox.MultiverseCore.commands.HelpCommand;
import com.onarandombox.MultiverseCore.commands.ImportCommand;
import com.onarandombox.MultiverseCore.commands.InfoCommand;
import com.onarandombox.MultiverseCore.commands.ListCommand;
import com.onarandombox.MultiverseCore.commands.ModifyAddCommand;
import com.onarandombox.MultiverseCore.commands.ModifyClearCommand;
import com.onarandombox.MultiverseCore.commands.ModifyCommand;
import com.onarandombox.MultiverseCore.commands.ModifyRemoveCommand;
import com.onarandombox.MultiverseCore.commands.ModifySetCommand;
import com.onarandombox.MultiverseCore.commands.PurgeCommand;
import com.onarandombox.MultiverseCore.commands.ReloadCommand;
import com.onarandombox.MultiverseCore.commands.RemoveCommand;
import com.onarandombox.MultiverseCore.commands.SetSpawnCommand;
import com.onarandombox.MultiverseCore.commands.SleepCommand;
import com.onarandombox.MultiverseCore.commands.SpawnCommand;
import com.onarandombox.MultiverseCore.commands.TeleportCommand;
import com.onarandombox.MultiverseCore.commands.UnloadCommand;
import com.onarandombox.MultiverseCore.commands.VersionCommand;
import com.onarandombox.MultiverseCore.commands.WhoCommand;
import com.onarandombox.MultiverseCore.configuration.DefaultConfiguration;
import com.onarandombox.utils.DebugLog;
import com.onarandombox.utils.PurgeWorlds;
@ -81,11 +105,11 @@ public class MultiverseCore extends JavaPlugin {
debugLog = new DebugLog("Multiverse-Core", getDataFolder() + File.separator + "debug.log");
}
public Configuration getConfig() {
return this.configMV;
}
public GenericBank getBank() {
return this.bank;
}
@ -100,7 +124,7 @@ public class MultiverseCore extends JavaPlugin {
this.ph = new MVPermissions(this);
this.bank = this.banker.loadEconPlugin();
// Setup the command manager
this.commandHandler = new CommandHandler(this, this.ph);
// Setup the world purger
@ -224,6 +248,18 @@ public class MultiverseCore extends JavaPlugin {
// Force the worlds to be loaded, ie don't just load new worlds.
if (forceLoad) {
// Remove all world permissions.
Permission all = this.getServer().getPluginManager().getPermission("multiverse.*");
for (MVWorld w : this.worlds.values()) {
// Remove this world from the master list
if (all != null) {
all.getChildren().remove(w.getPermission().getName());
}
this.getServer().getPluginManager().removePermission(w.getPermission().getName());
}
// Recalc the all permission
this.getServer().getPluginManager().recalculatePermissionDefaults(all);
this.getServer().getPluginManager().removePermission("multiverse.access.*");
this.worlds.clear();
}

View File

@ -37,8 +37,8 @@ public class VersionCommand extends MultiverseCommand {
this.plugin.log(Level.INFO, "Dumping Config Values: (version " + this.plugin.getConfig().getString("version", "NOT SET") + ")");
this.plugin.log(Level.INFO, "messagecooldown: " + this.plugin.getConfig().getString("messagecooldown", "NOT SET"));
this.plugin.log(Level.INFO, "teleportcooldown: " + this.plugin.getConfig().getString("teleportcooldown", "NOT SET"));
this.plugin.log(Level.INFO, "worldnameprefix: " + this.plugin.getConfig().getString("messagecooldown", "NOT SET"));
this.plugin.log(Level.INFO, "opfallback: " + this.plugin.getConfig().getString("worldnameprefix", "NOT SET"));
this.plugin.log(Level.INFO, "worldnameprefix: " + this.plugin.getConfig().getString("worldnameprefix", "NOT SET"));
this.plugin.log(Level.INFO, "opfallback: " + this.plugin.getConfig().getString("opfallback", "NOT SET"));
this.plugin.log(Level.INFO, "disableautoheal: " + this.plugin.getConfig().getString("disableautoheal", "NOT SET"));
this.plugin.log(Level.INFO, "fakepvp: " + this.plugin.getConfig().getString("fakepvp", "NOT SET"));
}