Bump to v3.1, rewrite Teleport/TimedTeleport and add TeleportBuilder, expose new Teleport API, remove TeleportManager, minor database utility refactoring

This commit is contained in:
William committed 2022-10-18 17:45:44 +01:00
1 parent e7f8298b12
commit 9630e53613
35 files changed
+1070 -881

No files matched your search

@@ -3,6 +3,8 @@ 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.teleport.Teleport;
import net.william278.huskhomes.teleport.TimedTeleport;
import net.william278.huskhomes.util.Permission;
import org.jetbrains.annotations.NotNull;
@@ -15,17 +17,11 @@ public class BackCommand extends CommandBase {
@Override
public void onExecute(@NotNull OnlineUser onlineUser, @NotNull String[] args) {
plugin.getDatabase().getLastPosition(onlineUser).thenAccept(lastPosition ->
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;
}
// Teleport the player
plugin.getTeleportManager().timedTeleport(onlineUser, position, Settings.EconomyAction.BACK_COMMAND)
.thenAccept(result -> plugin.getTeleportManager()
.finishTeleport(onlineUser, result, Settings.EconomyAction.BACK_COMMAND));
},
lastPosition.ifPresentOrElse(position -> Teleport.builder(plugin, onlineUser)
.setTarget(position)
.setEconomyActions(Settings.EconomyAction.BACK_COMMAND)
.toTimedTeleport()
.thenApply(TimedTeleport::execute),
() -> plugin.getLocales().getLocale("error_no_last_position").ifPresent(onlineUser::sendMessage)));
}