mirror of
https://github.com/darksaid98/HuskHomes.git
synced 2026-12-04 22:16:22 +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
@@ -133,7 +133,7 @@ public class BukkitHuskHomes extends JavaPlugin implements HuskHomes {
|
|||||||
getLoggingAdapter().log(Level.INFO, "Successfully established a connection to the database");
|
getLoggingAdapter().log(Level.INFO, "Successfully established a connection to the database");
|
||||||
} else {
|
} else {
|
||||||
throw new HuskHomesInitializationException("Failed to establish a connection to the database. " +
|
throw new HuskHomesInitializationException("Failed to establish a connection to the database. " +
|
||||||
"Please check the supplied database credentials in the config file");
|
"Please check the supplied database credentials in the config file");
|
||||||
}
|
}
|
||||||
|
|
||||||
// Initialize the network messenger if proxy mode is enabled
|
// Initialize the network messenger if proxy mode is enabled
|
||||||
@@ -195,8 +195,8 @@ public class BukkitHuskHomes extends JavaPlugin implements HuskHomes {
|
|||||||
if (pluginHooks.size() > 0) {
|
if (pluginHooks.size() > 0) {
|
||||||
pluginHooks.forEach(PluginHook::initialize);
|
pluginHooks.forEach(PluginHook::initialize);
|
||||||
getLoggingAdapter().log(Level.INFO, "Registered " + pluginHooks.size() + " plugin hooks: " +
|
getLoggingAdapter().log(Level.INFO, "Registered " + pluginHooks.size() + " plugin hooks: " +
|
||||||
pluginHooks.stream().map(PluginHook::getHookName)
|
pluginHooks.stream().map(PluginHook::getHookName)
|
||||||
.collect(Collectors.joining(", ")));
|
.collect(Collectors.joining(", ")));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Register events
|
// Register events
|
||||||
@@ -226,8 +226,8 @@ public class BukkitHuskHomes extends JavaPlugin implements HuskHomes {
|
|||||||
if (settings.disabledCommands.stream().anyMatch(disabledCommand -> {
|
if (settings.disabledCommands.stream().anyMatch(disabledCommand -> {
|
||||||
final String command = (disabledCommand.startsWith("/") ? disabledCommand.substring(1) : disabledCommand);
|
final String command = (disabledCommand.startsWith("/") ? disabledCommand.substring(1) : disabledCommand);
|
||||||
return command.equalsIgnoreCase(commandType.commandBase.command) ||
|
return command.equalsIgnoreCase(commandType.commandBase.command) ||
|
||||||
Arrays.stream(commandType.commandBase.aliases)
|
Arrays.stream(commandType.commandBase.aliases)
|
||||||
.anyMatch(alias -> alias.equalsIgnoreCase(command));
|
.anyMatch(alias -> alias.equalsIgnoreCase(command));
|
||||||
})) {
|
})) {
|
||||||
new BukkitCommand(new DisabledCommand(this), this).register(pluginCommand);
|
new BukkitCommand(new DisabledCommand(this), this).register(pluginCommand);
|
||||||
return;
|
return;
|
||||||
@@ -258,7 +258,7 @@ public class BukkitHuskHomes extends JavaPlugin implements HuskHomes {
|
|||||||
getLatestVersionIfOutdated().thenAccept(newestVersion ->
|
getLatestVersionIfOutdated().thenAccept(newestVersion ->
|
||||||
newestVersion.ifPresent(newVersion -> getLoggingAdapter().log(Level.WARNING,
|
newestVersion.ifPresent(newVersion -> getLoggingAdapter().log(Level.WARNING,
|
||||||
"An update is available for HuskHomes, v" + newVersion
|
"An update is available for HuskHomes, v" + newVersion
|
||||||
+ " (Currently running v" + getPluginVersion() + ")")));
|
+ " (Currently running v" + getPluginVersion() + ")")));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Perform automatic upgrade if detected
|
// Perform automatic upgrade if detected
|
||||||
|
|||||||
@@ -32,9 +32,15 @@ public class NormalDistributionEngine extends RandomTeleportEngine {
|
|||||||
@Override
|
@Override
|
||||||
protected @NotNull CompletableFuture<Optional<Location>> generateRandomLocation(@NotNull Location origin,
|
protected @NotNull CompletableFuture<Optional<Location>> generateRandomLocation(@NotNull Location origin,
|
||||||
@NotNull String... args) {
|
@NotNull String... args) {
|
||||||
return CompletableFuture.supplyAsync(() -> plugin.getSafeGroundLocation(generateLocation(origin, mean,
|
return CompletableFuture.supplyAsync(() -> {
|
||||||
standardDeviation, spawnRadius, radius)).join())
|
Optional<Location> generated = plugin.getSafeGroundLocation(generateLocation(origin, mean,
|
||||||
.orTimeout(5, TimeUnit.SECONDS)
|
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());
|
.exceptionally(throwable -> Optional.empty());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user