Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
package com.earth2me.essentials.commands;

import com.earth2me.essentials.Trade;
import com.earth2me.essentials.User;
import com.earth2me.essentials.utils.LocationUtil;
import org.bukkit.Location;
import org.bukkit.Server;
import org.bukkit.event.player.PlayerTeleportEvent;

import java.util.concurrent.CompletableFuture;

import static com.earth2me.essentials.I18n.tl;

public class Commandbottom extends EssentialsCommand {

public Commandbottom() {
super("bottom");
}

@Override
public void run(final Server server, final User user, final String commandLabel, final String[] args) throws Exception {
final int bottomX = user.getLocation().getBlockX();
final int bottomZ = user.getLocation().getBlockZ();
final float pitch = user.getLocation().getPitch();
final float yaw = user.getLocation().getYaw();
final Location unsafe = new Location(user.getWorld(), bottomX, ess.getWorldInfoProvider().getMinHeight(user.getWorld()), bottomZ, yaw, pitch);
final Location safe = LocationUtil.getSafeDestination(ess, unsafe);
final CompletableFuture<Boolean> future = getNewExceptionFuture(user.getSource(), commandLabel);
future.thenAccept(success -> {
if (success) {
user.sendMessage(tl("teleportBottom", safe.getWorld().getName(), safe.getBlockX(), safe.getBlockY(), safe.getBlockZ()));
}
});
user.getAsyncTeleport().teleport(safe, new Trade(this.getName(), ess), PlayerTeleportEvent.TeleportCause.COMMAND, future);
}
}
3 changes: 3 additions & 0 deletions Essentials/src/main/resources/messages.properties
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,8 @@ bookCommandUsage3=/<command> title <title>
bookCommandUsage3Description=Sets the title of a signed book
bookLocked=\u00a76This book is now locked.
bookTitleSet=\u00a76Title of the book set to {0}.
bottomCommandDescription=Teleport to the lowest block at your current position.
bottomCommandUsage=/<command>
breakCommandDescription=Breaks the block you are looking at.
breakCommandUsage=/<command>
broadcast=\u00a76[\u00a74Broadcast\u00a76]\u00a7a {0}
Expand Down Expand Up @@ -1253,6 +1255,7 @@ teleportationDisabledWarning=\u00a76You must enable teleportation before other p
teleportationEnabled=\u00a76Teleportation \u00a7cenabled\u00a76.
teleportationEnabledFor=\u00a76Teleportation \u00a7cenabled \u00a76for \u00a7c{0}\u00a76.
teleportAtoB=\u00a7c{0}\u00a76 teleported you to \u00a7c{1}\u00a76.
teleportBottom=\u00a76Teleporting to bottom.
teleportDisabled=\u00a7c{0} \u00a74has teleportation disabled.
teleportHereRequest=\u00a7c{0}\u00a76 has requested that you teleport to them.
teleportHome=\u00a76Teleporting to \u00a7c{0}\u00a76.
Expand Down
4 changes: 4 additions & 0 deletions Essentials/src/main/resources/plugin.yml
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,10 @@ commands:
description: Allows reopening and editing of sealed books.
usage: /<command> [title|author [name]]
aliases: [ebook]
bottom:
description: Teleport to the lowest block at your current position.
usage: /<command>
aliases: [ ebottom ]
break:
description: Breaks the block you are looking at.
usage: /<command>
Expand Down