mirror of
https://github.com/darksaid98/HuskHomes.git
synced 2026-12-02 14:38:52 +00:00
Tweak #generateRandomLocation behaviour for reliability
This commit is contained in:
1 parent
e0096fbf7e
commit
8442934dd9
2 files changed
+15
-9
No files matched your search
@@ -32,9 +32,15 @@ public class NormalDistributionEngine extends RandomTeleportEngine {
|
||||
@Override
|
||||
protected @NotNull CompletableFuture<Optional<Location>> generateRandomLocation(@NotNull Location origin,
|
||||
@NotNull String... args) {
|
||||
return CompletableFuture.supplyAsync(() -> plugin.getSafeGroundLocation(generateLocation(origin, mean,
|
||||
standardDeviation, spawnRadius, radius)).join())
|
||||
.orTimeout(5, TimeUnit.SECONDS)
|
||||
return CompletableFuture.supplyAsync(() -> {
|
||||
Optional<Location> generated = plugin.getSafeGroundLocation(generateLocation(origin, mean,
|
||||
standardDeviation, spawnRadius, radius)).join();
|
||||
while (generated.isEmpty()) {
|
||||
generated = plugin.getSafeGroundLocation(generateLocation(origin, mean, standardDeviation,
|
||||
spawnRadius, radius)).join();
|
||||
}
|
||||
return generated;
|
||||
}).orTimeout(5, TimeUnit.SECONDS)
|
||||
.exceptionally(throwable -> Optional.empty());
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user