mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2026-12-01 02:04:51 +00:00
Report stopped river searches
- A timed-out hydrology search throws HydrologySearchTimeoutException carrying the nearest feature found so far - nearestRiver answers RiverSearch.Stopped with the nearer of that feature and recorded water, and a message saying a nearer one may exist - Bukkit and modded find river print the stopped message and never teleport on a stopped search - Both commands catch every throwable while delivering a result and log it before telling the player - Modded logs a result that cannot reach the server thread instead of dropping it - The four-argument nearestFeature is removed; tests call the six-argument form
This commit is contained in:
1 parent
474b1e873a
commit
9afd70e69f
11 files changed
+247
-76
No files matched your search
+30
-12
@@ -153,28 +153,46 @@ final class ModdedLocateCommands {
|
||||
RiverRequest request = new RiverRequest(source, level, player, featureType);
|
||||
IrisModdedCommands.ok(source, GenerationSemanticQueries.riverSearchMessage(featureType, GenerationSemanticQueries.RIVER_SEARCH_DISTANCE));
|
||||
GenerationSemanticQueries.startRiverSearch(player.id(), MultiBurst.burst, engine, featureType, player.blockX(), player.blockZ())
|
||||
.whenComplete((GenerationSemanticQueries.RiverSearch search, Throwable error) -> {
|
||||
if (!(error instanceof CancellationException)) {
|
||||
server.execute(() -> finishRiverSearch(request, search, error));
|
||||
}
|
||||
});
|
||||
.whenComplete((GenerationSemanticQueries.RiverSearch search, Throwable error) ->
|
||||
deliverRiverSearch(server, request, search, error));
|
||||
return 1;
|
||||
}
|
||||
|
||||
private static void deliverRiverSearch(NativeModdedServer server, RiverRequest request, GenerationSemanticQueries.RiverSearch search,
|
||||
Throwable error) {
|
||||
if (error instanceof CancellationException) {
|
||||
return;
|
||||
}
|
||||
try {
|
||||
server.execute(() -> finishRiverSearch(request, search, error));
|
||||
} catch (Throwable rejected) {
|
||||
ModdedIrisLog.error("Hydrology locate result for {} could not reach the server thread", request.type().key(), rejected);
|
||||
}
|
||||
}
|
||||
|
||||
private static void finishRiverSearch(RiverRequest request, GenerationSemanticQueries.RiverSearch search, Throwable error) {
|
||||
if (error != null) {
|
||||
ModdedIrisLog.error("Hydrology locate failed for {}", request.type().key(), error);
|
||||
IrisModdedCommands.fail(request.source(), "Could not search for " + request.label() + ": " + error.getClass().getSimpleName()
|
||||
+ (error.getMessage() == null ? "" : " - " + error.getMessage()));
|
||||
reportRiverFailure(request, error);
|
||||
return;
|
||||
}
|
||||
switch (search) {
|
||||
case GenerationSemanticQueries.RiverSearch.Missing missing -> IrisModdedCommands.fail(request.source(), missing.message());
|
||||
case GenerationSemanticQueries.RiverSearch.Found found -> teleportToStructure(request.source(), request.level(),
|
||||
request.player(), found.feature().x(), found.feature().y() + 2, found.feature().z(), request.label());
|
||||
try {
|
||||
switch (search) {
|
||||
case GenerationSemanticQueries.RiverSearch.Missing missing -> IrisModdedCommands.fail(request.source(), missing.message());
|
||||
case GenerationSemanticQueries.RiverSearch.Stopped stopped -> IrisModdedCommands.fail(request.source(), stopped.message());
|
||||
case GenerationSemanticQueries.RiverSearch.Found found -> teleportToStructure(request.source(), request.level(),
|
||||
request.player(), found.feature().x(), found.feature().y() + 2, found.feature().z(), request.label());
|
||||
}
|
||||
} catch (Throwable failure) {
|
||||
reportRiverFailure(request, failure);
|
||||
}
|
||||
}
|
||||
|
||||
private static void reportRiverFailure(RiverRequest request, Throwable error) {
|
||||
ModdedIrisLog.error("Hydrology locate failed for {}", request.type().key(), error);
|
||||
IrisModdedCommands.fail(request.source(), "Could not search for " + request.label() + ": " + error.getClass().getSimpleName()
|
||||
+ (error.getMessage() == null ? "" : " - " + error.getMessage()));
|
||||
}
|
||||
|
||||
static int gotoStructure(NativeCommandSource source, String keyRaw) {
|
||||
NativeWorld level = source.world();
|
||||
Engine engine = IrisModdedCommands.engineFor(level);
|
||||
|
||||
Reference in new issue
Block a user