Search in sources :

Example 1 with DestinationThat

use of com.massivecraft.massivecore.teleport.DestinationThat in project MassiveCore by MassiveCraft.

the class EngineMassiveCoreDestination method destinationArg.

public Destination destinationArg(String arg, CommandSender sender) throws MassiveException {
    // Prepare
    arg = arg.toLowerCase();
    List<String> parts = Arrays.asList(arg.split("[\\s\\,\\:]+", 2));
    String first = parts.get(0);
    String rest = null;
    if (parts.size() > 1)
        rest = parts.get(1);
    arg = arg.replace("\\s+", "");
    // TOP
    if (ALIASES_TOP.contains(arg)) {
        Player player = DestinationUtil.getPlayer(sender);
        return new DestinationTop(player);
    }
    // THERE
    if (ALIASES_THERE.contains(arg)) {
        Player player = DestinationUtil.getPlayer(sender);
        return new DestinationThere(player);
    }
    // THAT
    if (ALIASES_THAT.contains(arg)) {
        Player player = DestinationUtil.getPlayer(sender);
        return new DestinationThat(player);
    }
    // JUMP
    if (ALIASES_JUMP.contains(arg)) {
        Player player = DestinationUtil.getPlayer(sender);
        return new DestinationJump(player);
    }
    // World Explicit
    if (ALIASES_WORLD.contains(first)) {
        String worldId;
        if (rest != null) {
            worldId = TypeWorldId.get().read(rest, sender);
        } else {
            Player player = DestinationUtil.getPlayer(sender);
            World world = player.getWorld();
            worldId = world.getName();
        }
        return new DestinationWorld(worldId);
    }
    // World Implicit
    try {
        String worldId = TypeWorldId.get().read(arg, sender);
        return new DestinationWorld(worldId);
    } catch (Exception e) {
    }
    // Player Explicit
    if (ALIASES_PLAYER.contains(first)) {
        String playerId;
        if (rest != null) {
            playerId = TypeSenderId.get().read(rest, sender);
        } else {
            Player player = DestinationUtil.getPlayer(sender);
            playerId = IdUtil.getId(player);
        }
        return new DestinationPlayer(playerId);
    }
    // Player Implicit
    try {
        String playerId = TypeSenderId.get().read(arg, sender);
        return new DestinationPlayer(playerId);
    } catch (Exception e) {
    }
    // Null
    return null;
}
Also used : DestinationThat(com.massivecraft.massivecore.teleport.DestinationThat) Player(org.bukkit.entity.Player) DestinationPlayer(com.massivecraft.massivecore.teleport.DestinationPlayer) DestinationJump(com.massivecraft.massivecore.teleport.DestinationJump) DestinationTop(com.massivecraft.massivecore.teleport.DestinationTop) DestinationThere(com.massivecraft.massivecore.teleport.DestinationThere) DestinationWorld(com.massivecraft.massivecore.teleport.DestinationWorld) World(org.bukkit.World) DestinationPlayer(com.massivecraft.massivecore.teleport.DestinationPlayer) DestinationWorld(com.massivecraft.massivecore.teleport.DestinationWorld) MassiveException(com.massivecraft.massivecore.MassiveException)

Aggregations

MassiveException (com.massivecraft.massivecore.MassiveException)1 DestinationJump (com.massivecraft.massivecore.teleport.DestinationJump)1 DestinationPlayer (com.massivecraft.massivecore.teleport.DestinationPlayer)1 DestinationThat (com.massivecraft.massivecore.teleport.DestinationThat)1 DestinationThere (com.massivecraft.massivecore.teleport.DestinationThere)1 DestinationTop (com.massivecraft.massivecore.teleport.DestinationTop)1 DestinationWorld (com.massivecraft.massivecore.teleport.DestinationWorld)1 World (org.bukkit.World)1 Player (org.bukkit.entity.Player)1