mirror of
https://github.com/Multiverse/Multiverse-Core.git
synced 2024-11-07 03:11:02 +01:00
Add the teleport permissions to the teleport command... oops
This commit is contained in:
parent
74aba9d6e8
commit
17a519f961
@ -177,6 +177,7 @@ public class MVPermissions implements PermissionsInterface {
|
||||
return "Bukkit Permissions" + opsfallback;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasAnyPermission(CommandSender sender, List<String> nodes, boolean isOpRequired) {
|
||||
for (String node : nodes) {
|
||||
if (this.hasPermission(sender, node, isOpRequired)) {
|
||||
|
@ -136,8 +136,7 @@ public class MultiverseCore extends JavaPlugin implements LoggablePlugin {
|
||||
// Output a little snippet to show it's enabled.
|
||||
this.log(Level.INFO, "- Version " + this.getDescription().getVersion() + " Enabled - By " + getAuthors());
|
||||
this.checkServerProps();
|
||||
// Setup all the Events the plugin needs to Monitor.
|
||||
this.initializeDestinationFactory();
|
||||
|
||||
this.registerEvents();
|
||||
// Setup Permissions, we'll do an initial check for the Permissions plugin then fall back on isOP().
|
||||
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.
|
||||
this.registerCommands();
|
||||
|
||||
// Initialize the Destination factor AFTER the commands
|
||||
this.initializeDestinationFactory();
|
||||
|
||||
this.playerSessions = new HashMap<String, MVPlayerSession>();
|
||||
|
||||
// Start the Update Checker
|
||||
|
@ -30,7 +30,7 @@ public class TeleportCommand extends MultiverseCommand {
|
||||
|
||||
public TeleportCommand(MultiverseCore 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.setCommandUsage("/mv tp " + ChatColor.GOLD + "[PLAYER]" + ChatColor.GREEN + " {WORLD}");
|
||||
|
@ -13,18 +13,25 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
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.PermissionDefault;
|
||||
|
||||
public class DestinationFactory {
|
||||
private MultiverseCore plugin;
|
||||
private Map<String, Class<? extends MVDestination>> destList;
|
||||
private List<Permission> teleportPermissions;
|
||||
private Command teleportCommand;
|
||||
|
||||
public DestinationFactory(MultiverseCore plugin) {
|
||||
this.plugin = plugin;
|
||||
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) {
|
||||
@ -62,19 +69,17 @@ public class DestinationFactory {
|
||||
Permission other = this.plugin.getServer().getPluginManager().getPermission("multiverse.teleport.other."+identifier);
|
||||
PermissionTools pt = new PermissionTools(this.plugin);
|
||||
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);
|
||||
}
|
||||
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);
|
||||
}
|
||||
this.teleportPermissions.add(self);
|
||||
this.teleportPermissions.add(other);
|
||||
this.teleportCommand.addAdditonalPermission(self);
|
||||
this.teleportCommand.addAdditonalPermission(other);
|
||||
return true;
|
||||
}
|
||||
|
||||
public List<Permission> getTeleportPermissions() {
|
||||
return this.teleportPermissions;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user