mirror of
https://github.com/Multiverse/Multiverse-Core.git
synced 2024-11-22 10:36:06 +01:00
Made DestinationType enum public
This commit is contained in:
parent
116b661b84
commit
599bbcd16c
@ -6,9 +6,11 @@ import org.bukkit.entity.Player;
|
||||
|
||||
import com.onarandombox.MultiverseCore.MultiverseCore;
|
||||
import com.onarandombox.MultiverseCore.command.BaseCommand;
|
||||
import com.onarandombox.utils.Destination;
|
||||
import com.onarandombox.utils.DestinationType;
|
||||
|
||||
public class TeleportCommand extends BaseCommand {
|
||||
|
||||
|
||||
public TeleportCommand(MultiverseCore plugin) {
|
||||
super(plugin);
|
||||
name = "Teleport";
|
||||
@ -18,22 +20,31 @@ public class TeleportCommand extends BaseCommand {
|
||||
maxArgs = 1;
|
||||
identifiers.add("mvtp");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(CommandSender sender, String[] args) {
|
||||
// Check if the command was sent from a Player.
|
||||
if(sender instanceof Player) {
|
||||
Player p = (Player) sender;
|
||||
|
||||
@Override
|
||||
public void execute(CommandSender sender, String[] args) {
|
||||
// Check if the command was sent from a Player.
|
||||
if (sender instanceof Player) {
|
||||
Player p = (Player) sender;
|
||||
// If this command was sent from a Player then we need to check Permissions
|
||||
if (!(plugin.ph.has((p), "multiverse.tp"))) {
|
||||
sender.sendMessage("You do not have access to this command.");
|
||||
p.sendMessage("You do not have access to this command.");
|
||||
return;
|
||||
}
|
||||
Destination d = Destination.parseDestination(args[1]);
|
||||
// TODO: I'd like to find a way to do these next bits inside Destination, so we're always valid --FF
|
||||
// TODO: Support portals, but I didn't see the portals list --FF
|
||||
if (this.plugin.worlds.containsKey(d.getName().toLowerCase())) {
|
||||
if(d.getType() == DestinationType.World) {
|
||||
|
||||
}
|
||||
} else {
|
||||
p.sendMessage("That was not a valid world (portals aren't yet supported)");
|
||||
}
|
||||
|
||||
|
||||
} else {
|
||||
sender.sendMessage("This command needs to be used from a Player.");
|
||||
}
|
||||
}
|
||||
|
||||
} else {
|
||||
sender.sendMessage("This command needs to be used from a Player.");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,10 +1,7 @@
|
||||
package com.onarandombox.utils;
|
||||
|
||||
enum DestinationType {
|
||||
World, Portal, Invalid
|
||||
}
|
||||
|
||||
public class Destination {
|
||||
|
||||
private String name;
|
||||
private DestinationType type;
|
||||
|
||||
@ -31,9 +28,16 @@ public class Destination {
|
||||
}
|
||||
|
||||
String[] items = dest.split(":");
|
||||
if (items.length != 2) {
|
||||
if (items.length > 1) {
|
||||
return getBadDestination();
|
||||
}
|
||||
|
||||
// If we only found one param, assume world
|
||||
// TODO: Check for a valid world
|
||||
if (items.length == 0) {
|
||||
return new Destination(items[0], DestinationType.World);
|
||||
}
|
||||
|
||||
if (items[0].equalsIgnoreCase("w")) {
|
||||
return new Destination(items[1], DestinationType.World);
|
||||
} else if (items[0].equalsIgnoreCase("p")) {
|
||||
|
5
src/com/onarandombox/utils/DestinationType.java
Normal file
5
src/com/onarandombox/utils/DestinationType.java
Normal file
@ -0,0 +1,5 @@
|
||||
package com.onarandombox.utils;
|
||||
|
||||
public enum DestinationType {
|
||||
World, Portal, Invalid
|
||||
}
|
Loading…
Reference in New Issue
Block a user