Add /back

This commit is contained in:
William committed 2022-05-29 10:22:43 +01:00
1 parent 0e33fb8014
commit 5b8352411e
7 files changed
+31 -108

No files matched your search

@@ -0,0 +1,24 @@
package net.william278.huskhomes.command;
import net.william278.huskhomes.HuskHomes;
import net.william278.huskhomes.player.Player;
import net.william278.huskhomes.player.User;
import org.jetbrains.annotations.NotNull;
public class BackCommand extends CommandBase {
private final static String PERMISSION = "huskhomes.command.back";
public BackCommand(@NotNull HuskHomes implementor) {
super("back", PERMISSION, implementor);
}
@Override
public void onExecute(@NotNull Player player, @NotNull String[] args) {
plugin.getDatabase().getLastPosition(new User(player)).thenAccept(lastPosition ->
lastPosition.ifPresentOrElse(position -> plugin.getTeleportManager().teleport(player, position)
.thenAccept(result -> plugin.getTeleportManager().finishTeleport(player, result)),
() -> plugin.getLocales().getLocale("error_no_last_position").ifPresent(player::sendMessage)));
}
}