mirror of
https://github.com/darksaid98/HuskHomes.git
synced 2026-12-01 22:16:08 +00:00
Add /rtp with normal distribution, economy hook, home limits, new tests, locales
This commit is contained in:
1 parent
0bb33c6f1e
commit
08e6569027
39 files changed
+1128
-188
No files matched your search
@@ -1,21 +1,31 @@
|
||||
package net.william278.huskhomes.command;
|
||||
|
||||
import net.william278.huskhomes.HuskHomes;
|
||||
import net.william278.huskhomes.config.Settings;
|
||||
import net.william278.huskhomes.player.OnlineUser;
|
||||
import net.william278.huskhomes.util.Permission;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class BackCommand extends CommandBase {
|
||||
|
||||
public BackCommand(@NotNull HuskHomes implementor) {
|
||||
protected BackCommand(@NotNull HuskHomes implementor) {
|
||||
super("back", Permission.COMMAND_BACK, implementor);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onExecute(@NotNull OnlineUser onlineUser, @NotNull String[] args) {
|
||||
plugin.getDatabase().getLastPosition(onlineUser).thenAccept(lastPosition ->
|
||||
lastPosition.ifPresentOrElse(position -> plugin.getTeleportManager().timedTeleport(onlineUser, position)
|
||||
.thenAccept(result -> plugin.getTeleportManager().finishTeleport(onlineUser, result)),
|
||||
lastPosition.ifPresentOrElse(position -> {
|
||||
// Validate the /back command economy action and that the user has sufficient funds if needed
|
||||
if (!plugin.validateEconomyCheck(onlineUser, Settings.EconomyAction.BACK_COMMAND)) {
|
||||
return;
|
||||
}
|
||||
plugin.performEconomyTransaction(onlineUser, Settings.EconomyAction.BACK_COMMAND);
|
||||
|
||||
// Teleport the player
|
||||
plugin.getTeleportManager().timedTeleport(onlineUser, position)
|
||||
.thenAccept(result -> plugin.getTeleportManager().finishTeleport(onlineUser, result));
|
||||
},
|
||||
() -> plugin.getLocales().getLocale("error_no_last_position").ifPresent(onlineUser::sendMessage)));
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user