mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2026-11-29 17:23:59 +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
@@ -240,9 +240,11 @@ public class CommandFind implements DirectorExecutor {
|
||||
switch (search) {
|
||||
case GenerationSemanticQueries.RiverSearch.Missing missing ->
|
||||
sendStructureMessage(request.target(), request.sender(), C.YELLOW + missing.message());
|
||||
case GenerationSemanticQueries.RiverSearch.Stopped stopped ->
|
||||
sendStructureMessage(request.target(), request.sender(), C.YELLOW + stopped.message());
|
||||
case GenerationSemanticQueries.RiverSearch.Found found -> arriveAtRiver(request, found.feature());
|
||||
}
|
||||
} catch (RuntimeException error) {
|
||||
} catch (Throwable error) {
|
||||
reportRiverFailure(request, error);
|
||||
}
|
||||
}
|
||||
@@ -258,10 +260,10 @@ public class CommandFind implements DirectorExecutor {
|
||||
}
|
||||
|
||||
private void reportRiverFailure(RiverRequest request, Throwable failure) {
|
||||
Iris.reportError("Could not locate hydrology feature '" + request.type().key() + "'.", failure);
|
||||
sendStructureMessage(request.target(), request.sender(),
|
||||
C.RED + "Could not search for " + request.label() + ": " + failure.getClass().getSimpleName()
|
||||
+ (failure.getMessage() == null ? "" : " - " + failure.getMessage()));
|
||||
Iris.reportError("Could not locate hydrology feature '" + request.type().key() + "'.", failure);
|
||||
}
|
||||
|
||||
@Director(description = "Find a structure (a vanilla key like minecraft:village_plains or minecraft:stronghold, or an imported iris structure key)", descriptionKey = "iris.director.commandfind.director.find_structure_vanilla_key_like_minecraft_village_plains_minecraft_stronghold_imported_iris", sync = true)
|
||||
|
||||
+37
@@ -2,6 +2,9 @@ package art.arcane.iris.command;
|
||||
|
||||
import art.arcane.iris.Iris;
|
||||
import art.arcane.iris.generation.hydrology.engine.HydrologyRuntime;
|
||||
import art.arcane.iris.generation.hydrology.query.HydrologyFeatureRef;
|
||||
import art.arcane.iris.generation.hydrology.query.HydrologySearchTimeoutException;
|
||||
import art.arcane.iris.generation.terrain.IrisDimension;
|
||||
import art.arcane.iris.generation.hydrology.query.HydrologyFeatureType;
|
||||
import art.arcane.iris.generation.runtime.Engine;
|
||||
import art.arcane.iris.generation.runtime.IrisComplex;
|
||||
@@ -18,6 +21,7 @@ import org.bukkit.entity.Player;
|
||||
import org.junit.Test;
|
||||
import org.mockito.MockedStatic;
|
||||
|
||||
import java.time.Duration;
|
||||
import java.util.Optional;
|
||||
import java.util.OptionalLong;
|
||||
import java.util.UUID;
|
||||
@@ -31,6 +35,7 @@ import static org.mockito.ArgumentMatchers.anyInt;
|
||||
import static org.mockito.ArgumentMatchers.contains;
|
||||
import static org.mockito.ArgumentMatchers.eq;
|
||||
import static org.mockito.Mockito.doReturn;
|
||||
import static org.mockito.Mockito.doThrow;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.mockStatic;
|
||||
import static org.mockito.Mockito.never;
|
||||
@@ -179,6 +184,38 @@ public class CommandFindHydrologyTest {
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void stoppedSearchReportsTheNearestWaterWithoutTeleporting() throws Exception {
|
||||
try (Fixture fixture = new Fixture()) {
|
||||
fixture.searchForReal();
|
||||
IrisDimension dimension = mock(IrisDimension.class);
|
||||
when(fixture.engine.getDimension()).thenReturn(dimension);
|
||||
when(dimension.getMinHeight()).thenReturn(-64);
|
||||
when(fixture.runtime.nearestFeature(anyInt(), anyInt(), any(), anyInt(), any(), any())).thenThrow(
|
||||
new HydrologySearchTimeoutException(Duration.ofSeconds(30L), new HydrologyFeatureRef(1L, HydrologyFeatureType.RIVER, 32, 127, 32)));
|
||||
fixture.command.river("river", true);
|
||||
fixture.search.get().run();
|
||||
|
||||
verify(fixture.sender).sendMessage(contains("Stopped searching for the nearest river after 30 seconds. The nearest river found so "
|
||||
+ "far is at 32, 63, 32; a nearer one may exist."));
|
||||
fixture.platform.verify(() -> BukkitPlatform.chunkAtAsync(any(World.class), anyInt(), anyInt(), eq(true)), never());
|
||||
fixture.platform.verify(() -> BukkitPlatform.teleportAsync(any(Player.class), any(Location.class)), never());
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void deliveryFailureIsReportedInsteadOfLost() {
|
||||
try (Fixture fixture = new Fixture()) {
|
||||
LinkageError failure = new LinkageError("sender gone");
|
||||
doThrow(failure).when(fixture.sender).sendMessage(contains("Found river"));
|
||||
fixture.command.river("river", false);
|
||||
fixture.search.get().run();
|
||||
|
||||
fixture.logging.verify(() -> Iris.reportError(any(String.class), eq(failure)));
|
||||
verify(fixture.sender).sendMessage(contains("Could not search for river: LinkageError - sender gone"));
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void missingCavePoolIsReportedAsNotFoundInGeneratedChunks() {
|
||||
try (Fixture fixture = new Fixture()) {
|
||||
|
||||
Reference in new issue
Block a user