mirror of
https://github.com/darksaid98/HuskHomes.git
synced 2026-12-01 22:16:08 +00:00
Add /back
This commit is contained in:
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)));
|
||||
}
|
||||
|
||||
}
|
||||
Reference in new issue
Block a user