Fixed blocking calls to #getPosition causing crashes in rare cases

This commit is contained in:
William committed 2022-08-26 16:54:40 +01:00
1 parent 25d90530d3
commit 46c36f3b34
4 files changed
+114 -104

No files matched your search

@@ -19,13 +19,12 @@ public class SetSpawnCommand extends CommandBase {
@Override
public void onExecute(@NotNull OnlineUser onlineUser, @NotNull String[] args) {
if (args.length > 0) {
plugin.getLocales().getLocale("error_invalid_syntax", "/setspawn")
.ifPresent(onlineUser::sendMessage);
return;
}
CompletableFuture.runAsync(() -> {
if (args.length > 0) {
plugin.getLocales().getLocale("error_invalid_syntax", "/setspawn")
.ifPresent(onlineUser::sendMessage);
return;
}
final Position position = onlineUser.getPosition();
if (plugin.getSettings().crossServer && plugin.getSettings().globalSpawn) {
final Optional<Warp> warp = plugin.getDatabase().getWarp(plugin.getSettings().globalSpawnName).join();