mirror of
https://github.com/darksaid98/HuskHomes.git
synced 2026-12-04 22:16:22 +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
|
@Override
|
||||||
public void onExecute(@NotNull OnlineUser onlineUser, @NotNull String[] args) {
|
public void onExecute(@NotNull OnlineUser onlineUser, @NotNull String[] args) {
|
||||||
|
CompletableFuture.runAsync(() -> {
|
||||||
if (args.length > 0) {
|
if (args.length > 0) {
|
||||||
plugin.getLocales().getLocale("error_invalid_syntax", "/setspawn")
|
plugin.getLocales().getLocale("error_invalid_syntax", "/setspawn")
|
||||||
.ifPresent(onlineUser::sendMessage);
|
.ifPresent(onlineUser::sendMessage);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
CompletableFuture.runAsync(() -> {
|
|
||||||
final Position position = onlineUser.getPosition();
|
final Position position = onlineUser.getPosition();
|
||||||
if (plugin.getSettings().crossServer && plugin.getSettings().globalSpawn) {
|
if (plugin.getSettings().crossServer && plugin.getSettings().globalSpawn) {
|
||||||
final Optional<Warp> warp = plugin.getDatabase().getWarp(plugin.getSettings().globalSpawnName).join();
|
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 net.william278.huskhomes.util.Permission;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
|
import java.util.concurrent.CompletableFuture;
|
||||||
|
|
||||||
public class SetWarpCommand extends CommandBase {
|
public class SetWarpCommand extends CommandBase {
|
||||||
|
|
||||||
protected SetWarpCommand(@NotNull HuskHomes implementor) {
|
protected SetWarpCommand(@NotNull HuskHomes implementor) {
|
||||||
@@ -15,7 +17,7 @@ public class SetWarpCommand extends CommandBase {
|
|||||||
@Override
|
@Override
|
||||||
public void onExecute(@NotNull OnlineUser onlineUser, @NotNull String[] args) {
|
public void onExecute(@NotNull OnlineUser onlineUser, @NotNull String[] args) {
|
||||||
if (args.length == 1) {
|
if (args.length == 1) {
|
||||||
setWarp(onlineUser, args[0]);
|
CompletableFuture.runAsync(() -> setWarp(onlineUser, args[0]));
|
||||||
} else {
|
} else {
|
||||||
plugin.getLocales().getLocale("error_invalid_syntax", "/setwarp <name>")
|
plugin.getLocales().getLocale("error_invalid_syntax", "/setwarp <name>")
|
||||||
.ifPresent(onlineUser::sendMessage);
|
.ifPresent(onlineUser::sendMessage);
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ import org.jetbrains.annotations.NotNull;
|
|||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
import java.util.concurrent.CompletableFuture;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
@@ -22,6 +23,7 @@ public class TpCommand extends CommandBase implements TabCompletable, ConsoleExe
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onExecute(@NotNull OnlineUser onlineUser, @NotNull String[] args) {
|
public void onExecute(@NotNull OnlineUser onlineUser, @NotNull String[] args) {
|
||||||
|
CompletableFuture.runAsync(() -> {
|
||||||
String teleportingUserName = onlineUser.username;
|
String teleportingUserName = onlineUser.username;
|
||||||
TeleportCommandTarget targetPosition;
|
TeleportCommandTarget targetPosition;
|
||||||
|
|
||||||
@@ -109,6 +111,10 @@ public class TpCommand extends CommandBase implements TabCompletable, ConsoleExe
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
throw new HuskHomesException("Attempted to execute invalid teleport command operation");
|
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) {
|
private boolean isCoordinate(@NotNull String coordinate) {
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ import org.jetbrains.annotations.Nullable;
|
|||||||
|
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.concurrent.CompletableFuture;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
public class TpHereCommand extends CommandBase implements TabCompletable {
|
public class TpHereCommand extends CommandBase implements TabCompletable {
|
||||||
@@ -18,6 +19,7 @@ public class TpHereCommand extends CommandBase implements TabCompletable {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onExecute(@NotNull OnlineUser onlineUser, @NotNull String[] args) {
|
public void onExecute(@NotNull OnlineUser onlineUser, @NotNull String[] args) {
|
||||||
|
CompletableFuture.runAsync(() -> {
|
||||||
if (args.length != 1) {
|
if (args.length != 1) {
|
||||||
plugin.getLocales().getLocale("error_invalid_syntax", "/tphere <player>")
|
plugin.getLocales().getLocale("error_invalid_syntax", "/tphere <player>")
|
||||||
.ifPresent(onlineUser::sendMessage);
|
.ifPresent(onlineUser::sendMessage);
|
||||||
@@ -37,6 +39,7 @@ public class TpHereCommand extends CommandBase implements TabCompletable {
|
|||||||
},
|
},
|
||||||
() -> plugin.getLocales().getLocale("error_player_not_found", targetPlayerName)
|
() -> plugin.getLocales().getLocale("error_player_not_found", targetPlayerName)
|
||||||
.ifPresent(onlineUser::sendMessage)));
|
.ifPresent(onlineUser::sendMessage)));
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
Reference in new issue
Block a user