use of com.massivecraft.massivecore.teleport.DestinationPlayer 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;
}
Aggregations