2011-03-30 04:03:21 +00:00
|
|
|
package com.earth2me.essentials.commands;
|
|
|
|
|
2011-06-13 13:05:11 +00:00
|
|
|
import com.earth2me.essentials.Trade;
|
2011-03-30 04:03:21 +00:00
|
|
|
import com.earth2me.essentials.User;
|
2013-08-12 23:55:31 +00:00
|
|
|
import com.earth2me.essentials.utils.LocationUtil;
|
2011-11-18 17:42:26 +00:00
|
|
|
import org.bukkit.Location;
|
|
|
|
import org.bukkit.Server;
|
2011-12-07 01:12:36 +00:00
|
|
|
import org.bukkit.event.player.PlayerTeleportEvent.TeleportCause;
|
2011-03-30 04:03:21 +00:00
|
|
|
|
2020-06-24 08:52:25 +00:00
|
|
|
import java.util.concurrent.CompletableFuture;
|
|
|
|
|
2015-04-15 04:06:16 +00:00
|
|
|
import static com.earth2me.essentials.I18n.tl;
|
|
|
|
|
|
|
|
public class Commandtop extends EssentialsCommand {
|
|
|
|
public Commandtop() {
|
|
|
|
super("top");
|
|
|
|
}
|
2011-03-30 04:03:21 +00:00
|
|
|
|
2015-04-15 04:06:16 +00:00
|
|
|
@Override
|
|
|
|
public void run(final Server server, final User user, final String commandLabel, final String[] args) throws Exception {
|
|
|
|
final int topX = user.getLocation().getBlockX();
|
|
|
|
final int topZ = user.getLocation().getBlockZ();
|
|
|
|
final float pitch = user.getLocation().getPitch();
|
|
|
|
final float yaw = user.getLocation().getYaw();
|
|
|
|
final Location loc = LocationUtil.getSafeDestination(new Location(user.getWorld(), topX, user.getWorld().getMaxHeight(), topZ, yaw, pitch));
|
2020-10-03 17:46:05 +00:00
|
|
|
final CompletableFuture<Boolean> future = new CompletableFuture<>();
|
2020-06-24 08:52:25 +00:00
|
|
|
future.thenAccept(success -> {
|
2020-10-03 17:46:05 +00:00
|
|
|
if (success) {
|
|
|
|
user.sendMessage(tl("teleportTop", loc.getWorld().getName(), loc.getBlockX(), loc.getBlockY(), loc.getBlockZ()));
|
|
|
|
}
|
2020-06-24 08:52:25 +00:00
|
|
|
});
|
|
|
|
user.getAsyncTeleport().teleport(loc, new Trade(this.getName(), ess), TeleportCause.COMMAND, getNewExceptionFuture(user.getSource(), commandLabel));
|
2015-04-15 04:06:16 +00:00
|
|
|
}
|
2011-03-30 04:03:21 +00:00
|
|
|
}
|