mirror of
https://github.com/Multiverse/Multiverse-Core.git
synced 2024-11-04 18:02:36 +01:00
Add Per-Destination perms, Closes #61
This commit is contained in:
parent
10d6a7e1dc
commit
bef22ba534
@ -1 +1 @@
|
||||
Subproject commit ad5c57e56cb44061b1b0f6429ada625da26d434d
|
||||
Subproject commit 50ecf6af450d138a9bc562c1c5664b31be6ffd2f
|
@ -1,11 +1,10 @@
|
||||
package com.onarandombox.MultiverseCore.commands;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.onarandombox.MultiverseCore.MultiverseCore;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.permissions.PermissionDefault;
|
||||
|
||||
import com.onarandombox.MultiverseCore.MultiverseCore;
|
||||
import java.util.List;
|
||||
|
||||
public class ConfirmCommand extends MultiverseCommand {
|
||||
|
||||
|
@ -1,8 +1,9 @@
|
||||
package com.onarandombox.MultiverseCore.commands;
|
||||
|
||||
import java.text.DecimalFormat;
|
||||
import java.util.List;
|
||||
|
||||
import com.onarandombox.MultiverseCore.MVWorld;
|
||||
import com.onarandombox.MultiverseCore.MultiverseCore;
|
||||
import com.onarandombox.utils.LocationManipulation;
|
||||
import com.onarandombox.utils.WorldManager;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.World;
|
||||
@ -10,10 +11,8 @@ import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.permissions.PermissionDefault;
|
||||
|
||||
import com.onarandombox.MultiverseCore.MVWorld;
|
||||
import com.onarandombox.MultiverseCore.MultiverseCore;
|
||||
import com.onarandombox.utils.LocationManipulation;
|
||||
import com.onarandombox.utils.WorldManager;
|
||||
import java.text.DecimalFormat;
|
||||
import java.util.List;
|
||||
|
||||
public class CoordCommand extends MultiverseCommand {
|
||||
private WorldManager worldManager;
|
||||
|
@ -1,16 +1,15 @@
|
||||
package com.onarandombox.MultiverseCore.commands;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.List;
|
||||
|
||||
import com.onarandombox.MultiverseCore.MultiverseCore;
|
||||
import com.onarandombox.utils.WorldManager;
|
||||
import com.pneumaticraft.commandhandler.CommandHandler;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.World.Environment;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.permissions.PermissionDefault;
|
||||
|
||||
import com.onarandombox.MultiverseCore.MultiverseCore;
|
||||
import com.onarandombox.utils.WorldManager;
|
||||
import com.pneumaticraft.commandhandler.CommandHandler;
|
||||
import java.io.File;
|
||||
import java.util.List;
|
||||
|
||||
public class CreateCommand extends MultiverseCommand {
|
||||
private WorldManager worldManager;
|
||||
|
@ -1,13 +1,12 @@
|
||||
package com.onarandombox.MultiverseCore.commands;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.logging.Level;
|
||||
|
||||
import com.onarandombox.MultiverseCore.MultiverseCore;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.permissions.PermissionDefault;
|
||||
|
||||
import com.onarandombox.MultiverseCore.MultiverseCore;
|
||||
import java.util.List;
|
||||
import java.util.logging.Level;
|
||||
|
||||
public class DebugCommand extends MultiverseCommand {
|
||||
|
||||
|
@ -1,13 +1,12 @@
|
||||
package com.onarandombox.MultiverseCore.commands;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import com.onarandombox.MultiverseCore.MultiverseCore;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.permissions.PermissionDefault;
|
||||
|
||||
import com.onarandombox.MultiverseCore.MultiverseCore;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class DeleteCommand extends MultiverseCommand {
|
||||
|
||||
|
@ -1,12 +1,11 @@
|
||||
package com.onarandombox.MultiverseCore.commands;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.onarandombox.MultiverseCore.MultiverseCore;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.permissions.PermissionDefault;
|
||||
|
||||
import com.onarandombox.MultiverseCore.MultiverseCore;
|
||||
import java.util.List;
|
||||
|
||||
public class EnvironmentCommand extends MultiverseCommand {
|
||||
|
||||
|
@ -1,15 +1,14 @@
|
||||
package com.onarandombox.MultiverseCore.commands;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.logging.Level;
|
||||
|
||||
import com.onarandombox.MultiverseCore.MultiverseCore;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.permissions.PermissionDefault;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
|
||||
import com.onarandombox.MultiverseCore.MultiverseCore;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.logging.Level;
|
||||
|
||||
public class GeneratorCommand extends MultiverseCommand {
|
||||
|
||||
|
@ -1,16 +1,15 @@
|
||||
// This file is no longer licensed under that silly CC license. I have blanked it out and will start implementaiton of my own in a few days. For now there is no help.
|
||||
package com.onarandombox.MultiverseCore.commands;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import com.onarandombox.MultiverseCore.MultiverseCore;
|
||||
import com.pneumaticraft.commandhandler.Command;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.permissions.PermissionDefault;
|
||||
|
||||
import com.onarandombox.MultiverseCore.MultiverseCore;
|
||||
import com.pneumaticraft.commandhandler.Command;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class HelpCommand extends MultiverseCommand {
|
||||
private static final int CMDS_PER_PAGE = 7;
|
||||
|
@ -1,15 +1,14 @@
|
||||
package com.onarandombox.MultiverseCore.commands;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.List;
|
||||
|
||||
import com.onarandombox.MultiverseCore.MultiverseCore;
|
||||
import com.onarandombox.utils.WorldManager;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.World.Environment;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.permissions.PermissionDefault;
|
||||
|
||||
import com.onarandombox.MultiverseCore.MultiverseCore;
|
||||
import com.onarandombox.utils.WorldManager;
|
||||
import java.io.File;
|
||||
import java.util.List;
|
||||
|
||||
public class ImportCommand extends MultiverseCommand {
|
||||
private WorldManager worldManager;
|
||||
|
@ -1,8 +1,8 @@
|
||||
package com.onarandombox.MultiverseCore.commands;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import com.onarandombox.MultiverseCore.MVWorld;
|
||||
import com.onarandombox.MultiverseCore.MultiverseCore;
|
||||
import com.onarandombox.utils.*;
|
||||
import com.sun.xml.internal.ws.util.StringUtils;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Location;
|
||||
@ -10,14 +10,8 @@ import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.permissions.PermissionDefault;
|
||||
|
||||
import com.onarandombox.MultiverseCore.MVWorld;
|
||||
import com.onarandombox.MultiverseCore.MultiverseCore;
|
||||
import com.onarandombox.utils.FancyColorScheme;
|
||||
import com.onarandombox.utils.FancyHeader;
|
||||
import com.onarandombox.utils.FancyMessage;
|
||||
import com.onarandombox.utils.FancyText;
|
||||
import com.onarandombox.utils.LocationManipulation;
|
||||
import com.onarandombox.utils.WorldManager;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class InfoCommand extends MultiverseCommand {
|
||||
private WorldManager worldManager;
|
||||
|
@ -1,15 +1,14 @@
|
||||
package com.onarandombox.MultiverseCore.commands;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.onarandombox.MultiverseCore.MVWorld;
|
||||
import com.onarandombox.MultiverseCore.MultiverseCore;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.World.Environment;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.permissions.PermissionDefault;
|
||||
|
||||
import com.onarandombox.MultiverseCore.MVWorld;
|
||||
import com.onarandombox.MultiverseCore.MultiverseCore;
|
||||
import java.util.List;
|
||||
|
||||
public class ListCommand extends MultiverseCommand {
|
||||
|
||||
|
@ -1,15 +1,14 @@
|
||||
package com.onarandombox.MultiverseCore.commands;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.onarandombox.MultiverseCore.MVWorld;
|
||||
import com.onarandombox.MultiverseCore.MultiverseCore;
|
||||
import com.onarandombox.utils.WorldManager;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.permissions.PermissionDefault;
|
||||
|
||||
import com.onarandombox.MultiverseCore.MVWorld;
|
||||
import com.onarandombox.MultiverseCore.MultiverseCore;
|
||||
import com.onarandombox.utils.WorldManager;
|
||||
import java.util.List;
|
||||
|
||||
// This will contain all the properties that support the ADD/REMOVE
|
||||
// Anything not in here will only support the SET action
|
||||
|
@ -1,15 +1,14 @@
|
||||
package com.onarandombox.MultiverseCore.commands;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.onarandombox.MultiverseCore.MVWorld;
|
||||
import com.onarandombox.MultiverseCore.MultiverseCore;
|
||||
import com.onarandombox.utils.WorldManager;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.permissions.PermissionDefault;
|
||||
|
||||
import com.onarandombox.MultiverseCore.MVWorld;
|
||||
import com.onarandombox.MultiverseCore.MultiverseCore;
|
||||
import com.onarandombox.utils.WorldManager;
|
||||
import java.util.List;
|
||||
|
||||
public class ModifyClearCommand extends MultiverseCommand {
|
||||
private WorldManager worldManager;
|
||||
|
@ -1,15 +1,14 @@
|
||||
package com.onarandombox.MultiverseCore.commands;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import com.onarandombox.MultiverseCore.MultiverseCore;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.permissions.Permission;
|
||||
import org.bukkit.permissions.PermissionDefault;
|
||||
|
||||
import com.onarandombox.MultiverseCore.MultiverseCore;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
enum AddProperties {
|
||||
blockblacklist, playerwhitelist, playerblacklist, worldblacklist, animals, monsters
|
||||
|
@ -1,15 +1,14 @@
|
||||
package com.onarandombox.MultiverseCore.commands;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.onarandombox.MultiverseCore.MVWorld;
|
||||
import com.onarandombox.MultiverseCore.MultiverseCore;
|
||||
import com.onarandombox.utils.WorldManager;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.permissions.PermissionDefault;
|
||||
|
||||
import com.onarandombox.MultiverseCore.MVWorld;
|
||||
import com.onarandombox.MultiverseCore.MultiverseCore;
|
||||
import com.onarandombox.utils.WorldManager;
|
||||
import java.util.List;
|
||||
|
||||
public class ModifyRemoveCommand extends MultiverseCommand {
|
||||
private WorldManager worldManager;
|
||||
|
@ -1,15 +1,14 @@
|
||||
package com.onarandombox.MultiverseCore.commands;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.onarandombox.MultiverseCore.MVWorld;
|
||||
import com.onarandombox.MultiverseCore.MultiverseCore;
|
||||
import com.onarandombox.utils.WorldManager;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.permissions.PermissionDefault;
|
||||
|
||||
import com.onarandombox.MultiverseCore.MVWorld;
|
||||
import com.onarandombox.MultiverseCore.MultiverseCore;
|
||||
import com.onarandombox.utils.WorldManager;
|
||||
import java.util.List;
|
||||
|
||||
public class ModifySetCommand extends MultiverseCommand {
|
||||
private WorldManager worldManager;
|
||||
|
@ -1,11 +1,10 @@
|
||||
package com.onarandombox.MultiverseCore.commands;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
import com.onarandombox.MultiverseCore.MultiverseCore;
|
||||
import com.pneumaticraft.commandhandler.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public abstract class MultiverseCommand extends Command {
|
||||
|
||||
|
@ -1,18 +1,17 @@
|
||||
package com.onarandombox.MultiverseCore.commands;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.permissions.PermissionDefault;
|
||||
|
||||
import com.onarandombox.MultiverseCore.MVWorld;
|
||||
import com.onarandombox.MultiverseCore.MultiverseCore;
|
||||
import com.onarandombox.utils.PurgeWorlds;
|
||||
import com.onarandombox.utils.WorldManager;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.permissions.PermissionDefault;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
public class PurgeCommand extends MultiverseCommand {
|
||||
private WorldManager worldManager;
|
||||
|
@ -1,14 +1,13 @@
|
||||
package com.onarandombox.MultiverseCore.commands;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import com.onarandombox.MultiverseCore.MultiverseCore;
|
||||
import com.onarandombox.MultiverseCore.event.MVConfigReloadEvent;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.permissions.PermissionDefault;
|
||||
|
||||
import com.onarandombox.MultiverseCore.MultiverseCore;
|
||||
import com.onarandombox.MultiverseCore.event.MVConfigReloadEvent;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class ReloadCommand extends MultiverseCommand {
|
||||
|
||||
|
@ -1,12 +1,11 @@
|
||||
package com.onarandombox.MultiverseCore.commands;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.onarandombox.MultiverseCore.MultiverseCore;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.permissions.PermissionDefault;
|
||||
|
||||
import com.onarandombox.MultiverseCore.MultiverseCore;
|
||||
import java.util.List;
|
||||
|
||||
public class RemoveCommand extends MultiverseCommand {
|
||||
|
||||
|
@ -1,16 +1,15 @@
|
||||
package com.onarandombox.MultiverseCore.commands;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.onarandombox.MultiverseCore.MVWorld;
|
||||
import com.onarandombox.MultiverseCore.MultiverseCore;
|
||||
import com.onarandombox.utils.LocationManipulation;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.permissions.PermissionDefault;
|
||||
|
||||
import com.onarandombox.MultiverseCore.MVWorld;
|
||||
import com.onarandombox.MultiverseCore.MultiverseCore;
|
||||
import com.onarandombox.utils.LocationManipulation;
|
||||
import java.util.List;
|
||||
|
||||
public class SetSpawnCommand extends MultiverseCommand {
|
||||
|
||||
|
@ -1,12 +1,11 @@
|
||||
package com.onarandombox.MultiverseCore.commands;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.onarandombox.MultiverseCore.MultiverseCore;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.permissions.PermissionDefault;
|
||||
|
||||
import com.onarandombox.MultiverseCore.MultiverseCore;
|
||||
import java.util.List;
|
||||
|
||||
public class SleepCommand extends MultiverseCommand {
|
||||
|
||||
|
@ -1,15 +1,14 @@
|
||||
package com.onarandombox.MultiverseCore.commands;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.onarandombox.MultiverseCore.MVWorld;
|
||||
import com.onarandombox.MultiverseCore.MultiverseCore;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.permissions.Permission;
|
||||
import org.bukkit.permissions.PermissionDefault;
|
||||
|
||||
import com.onarandombox.MultiverseCore.MVWorld;
|
||||
import com.onarandombox.MultiverseCore.MultiverseCore;
|
||||
import java.util.List;
|
||||
|
||||
public class SpawnCommand extends MultiverseCommand {
|
||||
|
||||
|
@ -1,7 +1,6 @@
|
||||
package com.onarandombox.MultiverseCore.commands;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.onarandombox.MultiverseCore.MultiverseCore;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
@ -11,7 +10,7 @@ import org.getspout.spoutapi.gui.GenericPopup;
|
||||
import org.getspout.spoutapi.gui.PopupScreen;
|
||||
import org.getspout.spoutapi.player.SpoutPlayer;
|
||||
|
||||
import com.onarandombox.MultiverseCore.MultiverseCore;
|
||||
import java.util.List;
|
||||
|
||||
public class SpoutCommand extends MultiverseCommand {
|
||||
|
||||
|
@ -1,16 +1,5 @@
|
||||
package com.onarandombox.MultiverseCore.commands;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.logging.Level;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.permissions.Permission;
|
||||
import org.bukkit.permissions.PermissionDefault;
|
||||
|
||||
import com.onarandombox.MultiverseCore.MVTeleport;
|
||||
import com.onarandombox.MultiverseCore.MultiverseCore;
|
||||
import com.onarandombox.MultiverseCore.event.MVTeleportEvent;
|
||||
@ -18,14 +7,23 @@ import com.onarandombox.utils.DestinationFactory;
|
||||
import com.onarandombox.utils.InvalidDestination;
|
||||
import com.onarandombox.utils.LocationManipulation;
|
||||
import com.onarandombox.utils.MVDestination;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.permissions.Permission;
|
||||
import org.bukkit.permissions.PermissionDefault;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.logging.Level;
|
||||
|
||||
public class TeleportCommand extends MultiverseCommand {
|
||||
private MVTeleport playerTeleporter;
|
||||
|
||||
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.other", "Allows you to teleport others to other worlds.", 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}");
|
||||
@ -33,9 +31,7 @@ public class TeleportCommand extends MultiverseCommand {
|
||||
this.addKey("mvtp");
|
||||
this.addKey("mv tp");
|
||||
this.playerTeleporter = new MVTeleport(this.plugin);
|
||||
// setPermission in some for is REQUIRED
|
||||
this.setPermission(self);
|
||||
this.addAdditonalPermission(other);
|
||||
this.setPermission(menu);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -50,10 +46,6 @@ public class TeleportCommand extends MultiverseCommand {
|
||||
String destinationName;
|
||||
|
||||
if (args.size() == 2) {
|
||||
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));
|
||||
if (teleportee == null) {
|
||||
sender.sendMessage("Sorry, I couldn't find player: " + args.get(0));
|
||||
@ -63,13 +55,8 @@ public class TeleportCommand extends MultiverseCommand {
|
||||
|
||||
} else {
|
||||
destinationName = args.get(0);
|
||||
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;
|
||||
}
|
||||
|
||||
if (!(sender instanceof Player)) {
|
||||
sender.sendMessage("From the console, you must specifiy a player to teleport");
|
||||
sender.sendMessage("From the console, you must specify a player to teleport");
|
||||
return;
|
||||
}
|
||||
teleporter = (Player) sender;
|
||||
@ -88,9 +75,13 @@ public class TeleportCommand extends MultiverseCommand {
|
||||
}
|
||||
DestinationFactory df = this.plugin.getDestinationFactory();
|
||||
MVDestination d = df.getDestination(destinationName);
|
||||
|
||||
|
||||
|
||||
MVTeleportEvent teleportEvent = new MVTeleportEvent(d, teleportee, teleporter);
|
||||
this.plugin.getServer().getPluginManager().callEvent(teleportEvent);
|
||||
if (teleportEvent.isCancelled()) {
|
||||
this.plugin.log(Level.FINE, "Someone else cancelled the MVTeleport Event!!!");
|
||||
return;
|
||||
}
|
||||
|
||||
@ -99,6 +90,10 @@ public class TeleportCommand extends MultiverseCommand {
|
||||
return;
|
||||
}
|
||||
|
||||
if(!this.checkSendPermissions(teleporter,teleportee,d)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (teleporter != null && !this.plugin.getPermissions().canEnterDestination(teleporter, d)) {
|
||||
if (teleportee.equals(teleporter)) {
|
||||
teleporter.sendMessage("Doesn't look like you're allowed to go " + ChatColor.RED + "there...");
|
||||
@ -135,4 +130,21 @@ public class TeleportCommand extends MultiverseCommand {
|
||||
teleportee.setVelocity(d.getVelocity());
|
||||
}
|
||||
}
|
||||
|
||||
private boolean checkSendPermissions(CommandSender teleporter, Player teleportee, MVDestination destination) {
|
||||
if(teleporter.equals(teleportee)) {
|
||||
if(!this.plugin.getPermissions().hasPermission(teleporter, "multiverse.teleport.self."+destination.getIdentifier(),true)) {
|
||||
teleporter.sendMessage("You don't have permission to teleport yourself to a " + ChatColor.GREEN + destination.getType() + " Destination.");
|
||||
teleporter.sendMessage(ChatColor.RED + " (multiverse.teleport.self."+destination.getIdentifier()+")");
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
if(!this.plugin.getPermissions().hasPermission(teleporter, "multiverse.teleport.other."+destination.getIdentifier(),true)) {
|
||||
teleporter.sendMessage("You don't have permission to teleport another player to a " + ChatColor.GREEN + destination.getType() + " Destination.");
|
||||
teleporter.sendMessage(ChatColor.RED + " (multiverse.teleport.other."+destination.getIdentifier()+")");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -1,12 +1,11 @@
|
||||
package com.onarandombox.MultiverseCore.commands;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.onarandombox.MultiverseCore.MultiverseCore;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.permissions.PermissionDefault;
|
||||
|
||||
import com.onarandombox.MultiverseCore.MultiverseCore;
|
||||
import java.util.List;
|
||||
|
||||
public class UnloadCommand extends MultiverseCommand {
|
||||
|
||||
|
@ -1,5 +1,12 @@
|
||||
package com.onarandombox.MultiverseCore.commands;
|
||||
|
||||
import com.onarandombox.MultiverseCore.MultiverseCore;
|
||||
import com.onarandombox.MultiverseCore.event.MVVersionRequestEvent;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.permissions.PermissionDefault;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.InputStreamReader;
|
||||
import java.io.OutputStreamWriter;
|
||||
@ -12,14 +19,6 @@ import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.logging.Level;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.permissions.PermissionDefault;
|
||||
|
||||
import com.onarandombox.MultiverseCore.MultiverseCore;
|
||||
import com.onarandombox.MultiverseCore.event.MVVersionRequestEvent;
|
||||
|
||||
public class VersionCommand extends MultiverseCommand {
|
||||
|
||||
public VersionCommand(MultiverseCore plugin) {
|
||||
|
@ -1,16 +1,15 @@
|
||||
package com.onarandombox.MultiverseCore.commands;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import com.onarandombox.MultiverseCore.MVWorld;
|
||||
import com.onarandombox.MultiverseCore.MultiverseCore;
|
||||
import com.onarandombox.utils.WorldManager;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.permissions.PermissionDefault;
|
||||
|
||||
import com.onarandombox.MultiverseCore.MVWorld;
|
||||
import com.onarandombox.MultiverseCore.MultiverseCore;
|
||||
import com.onarandombox.utils.WorldManager;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class WhoCommand extends MultiverseCommand {
|
||||
|
||||
|
@ -1,33 +1,39 @@
|
||||
package com.onarandombox.utils;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import com.onarandombox.MultiverseCore.MultiverseCore;
|
||||
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;
|
||||
|
||||
public DestinationFactory(MultiverseCore plugin) {
|
||||
this.plugin = plugin;
|
||||
this.destList = new HashMap<String, Class<? extends MVDestination>>();
|
||||
this.teleportPermissions = new ArrayList<Permission>();
|
||||
}
|
||||
|
||||
public MVDestination getDestination(String dest) {
|
||||
public MVDestination getDestination(String destination) {
|
||||
String idenChar = "";
|
||||
if (dest.split(":").length > 1) {
|
||||
idenChar = dest.split(":")[0];
|
||||
if (destination.split(":").length > 1) {
|
||||
idenChar = destination.split(":")[0];
|
||||
}
|
||||
|
||||
if (this.destList.containsKey(idenChar)) {
|
||||
Class<? extends MVDestination> myClass = this.destList.get(idenChar);
|
||||
try {
|
||||
MVDestination mydest = myClass.newInstance();
|
||||
if (!mydest.isThisType((MultiverseCore) this.plugin, dest)) {
|
||||
if (!mydest.isThisType((MultiverseCore) this.plugin, destination)) {
|
||||
return new InvalidDestination();
|
||||
}
|
||||
mydest.setDestination(this.plugin, dest);
|
||||
mydest.setDestination(this.plugin, destination);
|
||||
return mydest;
|
||||
} catch (InstantiationException e) {
|
||||
} catch (IllegalAccessException e) {
|
||||
@ -41,6 +47,27 @@ public class DestinationFactory {
|
||||
return false;
|
||||
}
|
||||
this.destList.put(identifier, c);
|
||||
// Special case for world defaults:
|
||||
if(identifier.equals("")) {
|
||||
identifier = "w";
|
||||
}
|
||||
Permission self = this.plugin.getServer().getPluginManager().getPermission("multiverse.teleport.self."+identifier);
|
||||
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));
|
||||
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));
|
||||
pt.addToParentPerms("multiverse.teleport.other."+identifier);
|
||||
}
|
||||
this.teleportPermissions.add(self);
|
||||
this.teleportPermissions.add(other);
|
||||
return true;
|
||||
}
|
||||
|
||||
public List<Permission> getTeleportPermissions() {
|
||||
return this.teleportPermissions;
|
||||
}
|
||||
}
|
||||
|
70
src/main/java/com/onarandombox/utils/PermissionTools.java
Normal file
70
src/main/java/com/onarandombox/utils/PermissionTools.java
Normal file
@ -0,0 +1,70 @@
|
||||
package com.onarandombox.utils;
|
||||
|
||||
import com.onarandombox.MultiverseCore.MultiverseCore;
|
||||
import org.bukkit.permissions.Permission;
|
||||
|
||||
public class PermissionTools {
|
||||
private MultiverseCore plugin;
|
||||
|
||||
public PermissionTools(MultiverseCore plugin) {
|
||||
this.plugin = plugin;
|
||||
}
|
||||
public void addToParentPerms(String permString) {
|
||||
String permStringChopped = permString.replace(".*", "");
|
||||
|
||||
String[] seperated = permStringChopped.split("\\.");
|
||||
String parentPermString = getParentPerm(seperated);
|
||||
if (parentPermString == null) {
|
||||
addToRootPermission("*", permStringChopped);
|
||||
addToRootPermission("*.*", permStringChopped);
|
||||
return;
|
||||
}
|
||||
Permission parentPermission = this.plugin.getServer().getPluginManager().getPermission(parentPermString);
|
||||
// Creat parent and grandparents
|
||||
if (parentPermission == null) {
|
||||
parentPermission = new Permission(parentPermString);
|
||||
this.plugin.getServer().getPluginManager().addPermission(parentPermission);
|
||||
|
||||
this.addToParentPerms(parentPermString);
|
||||
}
|
||||
// Create actual perm.
|
||||
Permission actualPermission = this.plugin.getServer().getPluginManager().getPermission(permString);
|
||||
// Extra check just to make sure the actual one is added
|
||||
if (actualPermission == null) {
|
||||
|
||||
actualPermission = new Permission(permString);
|
||||
this.plugin.getServer().getPluginManager().addPermission(actualPermission);
|
||||
}
|
||||
if (!parentPermission.getChildren().containsKey(permString)) {
|
||||
parentPermission.getChildren().put(actualPermission.getName(), true);
|
||||
this.plugin.getServer().getPluginManager().recalculatePermissionDefaults(parentPermission);
|
||||
}
|
||||
}
|
||||
|
||||
private void addToRootPermission(String rootPerm, String permStringChopped) {
|
||||
Permission rootPermission = this.plugin.getServer().getPluginManager().getPermission(rootPerm);
|
||||
if (rootPermission == null) {
|
||||
rootPermission = new Permission(rootPerm);
|
||||
this.plugin.getServer().getPluginManager().addPermission(rootPermission);
|
||||
}
|
||||
rootPermission.getChildren().put(permStringChopped + ".*", true);
|
||||
this.plugin.getServer().getPluginManager().recalculatePermissionDefaults(rootPermission);
|
||||
}
|
||||
|
||||
/**
|
||||
* If the given permission was 'multiverse.core.tp.self', this would return 'multiverse.core.tp.*'.
|
||||
*
|
||||
* @param separatedPermissionString The array of a dot separated perm string.
|
||||
* @return The dot separated parent permission string.
|
||||
*/
|
||||
private String getParentPerm(String[] separatedPermissionString) {
|
||||
if (separatedPermissionString.length == 1) {
|
||||
return null;
|
||||
}
|
||||
String returnString = "";
|
||||
for (int i = 0; i < separatedPermissionString.length - 1; i++) {
|
||||
returnString += separatedPermissionString[i] + ".";
|
||||
}
|
||||
return returnString + "*";
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user