Add the teleport permissions to the teleport command... oops

This commit is contained in:
Eric Stokes 2011-09-18 11:45:06 -06:00
parent 74aba9d6e8
commit 17a519f961
4 changed files with 21 additions and 13 deletions

View File

@ -177,6 +177,7 @@ public class MVPermissions implements PermissionsInterface {
return "Bukkit Permissions" + opsfallback; return "Bukkit Permissions" + opsfallback;
} }
@Override
public boolean hasAnyPermission(CommandSender sender, List<String> nodes, boolean isOpRequired) { public boolean hasAnyPermission(CommandSender sender, List<String> nodes, boolean isOpRequired) {
for (String node : nodes) { for (String node : nodes) {
if (this.hasPermission(sender, node, isOpRequired)) { if (this.hasPermission(sender, node, isOpRequired)) {

View File

@ -136,8 +136,7 @@ public class MultiverseCore extends JavaPlugin implements LoggablePlugin {
// Output a little snippet to show it's enabled. // Output a little snippet to show it's enabled.
this.log(Level.INFO, "- Version " + this.getDescription().getVersion() + " Enabled - By " + getAuthors()); this.log(Level.INFO, "- Version " + this.getDescription().getVersion() + " Enabled - By " + getAuthors());
this.checkServerProps(); this.checkServerProps();
// Setup all the Events the plugin needs to Monitor.
this.initializeDestinationFactory();
this.registerEvents(); this.registerEvents();
// Setup Permissions, we'll do an initial check for the Permissions plugin then fall back on isOP(). // Setup Permissions, we'll do an initial check for the Permissions plugin then fall back on isOP().
this.ph = new MVPermissions(this); this.ph = new MVPermissions(this);
@ -149,6 +148,9 @@ public class MultiverseCore extends JavaPlugin implements LoggablePlugin {
// Call the Function to assign all the Commands to their Class. // Call the Function to assign all the Commands to their Class.
this.registerCommands(); this.registerCommands();
// Initialize the Destination factor AFTER the commands
this.initializeDestinationFactory();
this.playerSessions = new HashMap<String, MVPlayerSession>(); this.playerSessions = new HashMap<String, MVPlayerSession>();
// Start the Update Checker // Start the Update Checker

View File

@ -30,7 +30,7 @@ public class TeleportCommand extends MultiverseCommand {
public TeleportCommand(MultiverseCore plugin) { public TeleportCommand(MultiverseCore plugin) {
super(plugin); super(plugin);
Permission menu = new Permission("multiverse.teleport", "Allows you to display the teleport menu.", PermissionDefault.OP); Permission menu = new Permission("multiverse.teleport.*", "Allows you to display the teleport menu.", PermissionDefault.OP);
this.setName("Teleport"); this.setName("Teleport");
this.setCommandUsage("/mv tp " + ChatColor.GOLD + "[PLAYER]" + ChatColor.GREEN + " {WORLD}"); this.setCommandUsage("/mv tp " + ChatColor.GOLD + "[PLAYER]" + ChatColor.GREEN + " {WORLD}");

View File

@ -13,18 +13,25 @@ import java.util.List;
import java.util.Map; import java.util.Map;
import com.onarandombox.MultiverseCore.MultiverseCore; import com.onarandombox.MultiverseCore.MultiverseCore;
import com.onarandombox.MultiverseCore.commands.TeleportCommand;
import com.pneumaticraft.commandhandler.Command;
import org.bukkit.permissions.Permission; import org.bukkit.permissions.Permission;
import org.bukkit.permissions.PermissionDefault; import org.bukkit.permissions.PermissionDefault;
public class DestinationFactory { public class DestinationFactory {
private MultiverseCore plugin; private MultiverseCore plugin;
private Map<String, Class<? extends MVDestination>> destList; private Map<String, Class<? extends MVDestination>> destList;
private List<Permission> teleportPermissions; private Command teleportCommand;
public DestinationFactory(MultiverseCore plugin) { public DestinationFactory(MultiverseCore plugin) {
this.plugin = plugin; this.plugin = plugin;
this.destList = new HashMap<String, Class<? extends MVDestination>>(); this.destList = new HashMap<String, Class<? extends MVDestination>>();
this.teleportPermissions = new ArrayList<Permission>(); List<Command> cmds = this.plugin.getCommandHandler().getAllCommands();
for(Command c : cmds) {
if(c instanceof TeleportCommand) {
this.teleportCommand = c;
}
}
} }
public MVDestination getDestination(String destination) { public MVDestination getDestination(String destination) {
@ -62,19 +69,17 @@ public class DestinationFactory {
Permission other = this.plugin.getServer().getPluginManager().getPermission("multiverse.teleport.other."+identifier); Permission other = this.plugin.getServer().getPluginManager().getPermission("multiverse.teleport.other."+identifier);
PermissionTools pt = new PermissionTools(this.plugin); PermissionTools pt = new PermissionTools(this.plugin);
if(self == null) { if(self == null) {
this.plugin.getServer().getPluginManager().addPermission(new Permission("multiverse.teleport.self."+identifier,"Permission to teleport yourself for the " + identifier + " destination.", PermissionDefault.OP)); self = new Permission("multiverse.teleport.self."+identifier,"Permission to teleport yourself for the " + identifier + " destination.", PermissionDefault.OP);
this.plugin.getServer().getPluginManager().addPermission(self);
pt.addToParentPerms("multiverse.teleport.self."+identifier); pt.addToParentPerms("multiverse.teleport.self."+identifier);
} }
if(other == null) { if(other == null) {
this.plugin.getServer().getPluginManager().addPermission(new Permission("multiverse.teleport.other."+identifier,"Permission to teleport others for the " + identifier + " destination.", PermissionDefault.OP)); other = new Permission("multiverse.teleport.other."+identifier,"Permission to teleport others for the " + identifier + " destination.", PermissionDefault.OP);
this.plugin.getServer().getPluginManager().addPermission(other);
pt.addToParentPerms("multiverse.teleport.other."+identifier); pt.addToParentPerms("multiverse.teleport.other."+identifier);
} }
this.teleportPermissions.add(self); this.teleportCommand.addAdditonalPermission(self);
this.teleportPermissions.add(other); this.teleportCommand.addAdditonalPermission(other);
return true; return true;
} }
public List<Permission> getTeleportPermissions() {
return this.teleportPermissions;
}
} }