mirror of
https://github.com/darksaid98/HuskHomes.git
synced 2026-12-05 06:28:48 +00:00
Fixed blocking calls to #getPosition causing crashes in rare cases
This commit is contained in:
1 parent
25d90530d3
commit
46c36f3b34
4 files changed
+13
-3
No files matched your search
@@ -19,13 +19,12 @@ public class SetSpawnCommand extends CommandBase {
|
||||
|
||||
@Override
|
||||
public void onExecute(@NotNull OnlineUser onlineUser, @NotNull String[] args) {
|
||||
CompletableFuture.runAsync(() -> {
|
||||
if (args.length > 0) {
|
||||
plugin.getLocales().getLocale("error_invalid_syntax", "/setspawn")
|
||||
.ifPresent(onlineUser::sendMessage);
|
||||
return;
|
||||
}
|
||||
|
||||
CompletableFuture.runAsync(() -> {
|
||||
final Position position = onlineUser.getPosition();
|
||||
if (plugin.getSettings().crossServer && plugin.getSettings().globalSpawn) {
|
||||
final Optional<Warp> warp = plugin.getDatabase().getWarp(plugin.getSettings().globalSpawnName).join();
|
||||
|
||||
@@ -6,6 +6,8 @@ import net.william278.huskhomes.position.PositionMeta;
|
||||
import net.william278.huskhomes.util.Permission;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
|
||||
public class SetWarpCommand extends CommandBase {
|
||||
|
||||
protected SetWarpCommand(@NotNull HuskHomes implementor) {
|
||||
@@ -15,7 +17,7 @@ public class SetWarpCommand extends CommandBase {
|
||||
@Override
|
||||
public void onExecute(@NotNull OnlineUser onlineUser, @NotNull String[] args) {
|
||||
if (args.length == 1) {
|
||||
setWarp(onlineUser, args[0]);
|
||||
CompletableFuture.runAsync(() -> setWarp(onlineUser, args[0]));
|
||||
} else {
|
||||
plugin.getLocales().getLocale("error_invalid_syntax", "/setwarp <name>")
|
||||
.ifPresent(onlineUser::sendMessage);
|
||||
|
||||
@@ -11,6 +11,7 @@ import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
import java.util.logging.Level;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@@ -22,6 +23,7 @@ public class TpCommand extends CommandBase implements TabCompletable, ConsoleExe
|
||||
|
||||
@Override
|
||||
public void onExecute(@NotNull OnlineUser onlineUser, @NotNull String[] args) {
|
||||
CompletableFuture.runAsync(() -> {
|
||||
String teleportingUserName = onlineUser.username;
|
||||
TeleportCommandTarget targetPosition;
|
||||
|
||||
@@ -109,6 +111,10 @@ public class TpCommand extends CommandBase implements TabCompletable, ConsoleExe
|
||||
return;
|
||||
}
|
||||
throw new HuskHomesException("Attempted to execute invalid teleport command operation");
|
||||
}).exceptionally(throwable -> {
|
||||
plugin.getLoggingAdapter().log(Level.SEVERE, "An error occurred whilst executing a teleport command", throwable);
|
||||
return null;
|
||||
});
|
||||
}
|
||||
|
||||
private boolean isCoordinate(@NotNull String coordinate) {
|
||||
|
||||
@@ -8,6 +8,7 @@ import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class TpHereCommand extends CommandBase implements TabCompletable {
|
||||
@@ -18,6 +19,7 @@ public class TpHereCommand extends CommandBase implements TabCompletable {
|
||||
|
||||
@Override
|
||||
public void onExecute(@NotNull OnlineUser onlineUser, @NotNull String[] args) {
|
||||
CompletableFuture.runAsync(() -> {
|
||||
if (args.length != 1) {
|
||||
plugin.getLocales().getLocale("error_invalid_syntax", "/tphere <player>")
|
||||
.ifPresent(onlineUser::sendMessage);
|
||||
@@ -37,6 +39,7 @@ public class TpHereCommand extends CommandBase implements TabCompletable {
|
||||
},
|
||||
() -> plugin.getLocales().getLocale("error_player_not_found", targetPlayerName)
|
||||
.ifPresent(onlineUser::sendMessage)));
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in new issue
Block a user