Add /bottom command (#5292)

Co-authored-by: Josh Roy <10731363+JRoy@users.noreply.github.com>
This commit is contained in:
Joel Otero 2023-04-09 23:05:53 +02:00 committed by GitHub
parent c716fc8236
commit 77dc87bb8e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 43 additions and 0 deletions

View File

@ -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);
}
}

View File

@ -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}
@ -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.

View File

@ -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>