mirror of
https://github.com/darksaid98/HuskHomes.git
synced 2026-12-01 22:16:08 +00:00
Start refactor work
This commit is contained in:
1 parent
6a8851a446
commit
3e1ec09487
51 files changed
+2397
-2474
No files matched your search
@@ -41,7 +41,7 @@ public class RtpCommand extends CommandBase implements ConsoleExecutable {
|
||||
}
|
||||
final Position userPosition = target.getPosition();
|
||||
final String[] rtpArguments = args.length >= 1 ? ArrayUtils.subarray(args, 1, args.length) : args;
|
||||
if (plugin.getSettings().rtpRestrictedWorlds.stream()
|
||||
if (plugin.getSettings().getRtpRestrictedWorlds().stream()
|
||||
.anyMatch(worldName -> worldName.equals(userPosition.world.name))) {
|
||||
plugin.getLocales().getLocale("error_rtp_restricted_world")
|
||||
.ifPresent(onlineUser::sendMessage);
|
||||
@@ -62,7 +62,7 @@ public class RtpCommand extends CommandBase implements ConsoleExecutable {
|
||||
}
|
||||
final Instant currentTime = Instant.now();
|
||||
if (isExecutorTeleporting && !currentTime.isAfter(userData.get().rtpCooldown())
|
||||
&& !onlineUser.hasPermission(Permission.BYPASS_RTP_COOLDOWN.node)) {
|
||||
&& !onlineUser.hasPermission(Permission.BYPASS_RTP_COOLDOWN.node)) {
|
||||
plugin.getLocales().getLocale("error_rtp_cooldown",
|
||||
Long.toString(currentTime.until(userData.get().rtpCooldown(), ChronoUnit.MINUTES) + 1))
|
||||
.ifPresent(onlineUser::sendMessage);
|
||||
@@ -72,29 +72,29 @@ public class RtpCommand extends CommandBase implements ConsoleExecutable {
|
||||
// Get a random position and teleport
|
||||
plugin.getLocales().getLocale("teleporting_random_generation")
|
||||
.ifPresent(onlineUser::sendMessage);
|
||||
plugin.getRandomTeleportEngine().getRandomPosition(onlineUser.getPosition().world, rtpArguments).thenAccept(position -> {
|
||||
if (position.isEmpty()) {
|
||||
plugin.getLocales().getLocale("error_rtp_randomization_timeout")
|
||||
.ifPresent(onlineUser::sendMessage);
|
||||
return;
|
||||
}
|
||||
|
||||
final TeleportBuilder builder = Teleport.builder(plugin, userToTeleport)
|
||||
.setTarget(position.get());
|
||||
final CompletableFuture<? extends Teleport> teleportFuture = isExecutorTeleporting
|
||||
? builder.setEconomyActions(Settings.EconomyAction.RANDOM_TELEPORT).toTimedTeleport()
|
||||
: builder.toTeleport();
|
||||
final Optional<Position> position = plugin.getRandomTeleportEngine().getRandomPosition(onlineUser.getPosition().world, rtpArguments);
|
||||
if (position.isEmpty()) {
|
||||
plugin.getLocales().getLocale("error_rtp_randomization_timeout")
|
||||
.ifPresent(onlineUser::sendMessage);
|
||||
return;
|
||||
}
|
||||
|
||||
teleportFuture.thenAccept(teleport -> teleport.execute()
|
||||
.thenAccept(result -> {
|
||||
if (isExecutorTeleporting &&
|
||||
final TeleportBuilder builder = Teleport.builder(plugin, userToTeleport)
|
||||
.setTarget(position.get());
|
||||
final CompletableFuture<? extends Teleport> teleportFuture = isExecutorTeleporting
|
||||
? builder.setEconomyActions(Settings.EconomyAction.RANDOM_TELEPORT).toTimedTeleport()
|
||||
: builder.toTeleport();
|
||||
|
||||
teleportFuture.thenAccept(teleport -> teleport.execute()
|
||||
.thenAccept(result -> {
|
||||
if (isExecutorTeleporting &&
|
||||
result.successful() && !onlineUser.hasPermission(Permission.BYPASS_RTP_COOLDOWN.node)) {
|
||||
plugin.getDatabase().updateUserData(new UserData(onlineUser,
|
||||
userData.get().homeSlots(), userData.get().ignoringTeleports(),
|
||||
Instant.now().plus(plugin.getSettings().rtpCooldownLength, ChronoUnit.MINUTES)));
|
||||
}
|
||||
}));
|
||||
});
|
||||
plugin.getDatabase().updateUserData(new UserData(onlineUser,
|
||||
userData.get().homeSlots(), userData.get().ignoringTeleports(),
|
||||
Instant.now().plus(plugin.getSettings().getRtpCooldownLength(), ChronoUnit.MINUTES)));
|
||||
}
|
||||
}));
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user