Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
fd5961ccd8 |
No files matched your search
@@ -505,8 +505,8 @@ public final class EquipmentSessions implements AutoCloseable {
|
||||
if (!state.canEnter(attempt.character, switchDelay.get(), now)) {
|
||||
Duration remaining = Duration.between(now, state.lastExit().deadline());
|
||||
long seconds = remaining.getSeconds() + (remaining.getNano() == 0 ? 0 : 1);
|
||||
refuse(attempt, "COOLDOWN", "Wait " + seconds + " seconds to switch characters (until "
|
||||
+ state.lastExit().deadline() + "); the same character may be resumed now."); return;
|
||||
refuse(attempt, "COOLDOWN", "Wait " + seconds
|
||||
+ " seconds to switch characters; the same character may be resumed now."); return;
|
||||
}
|
||||
}
|
||||
if (!entryNativeSafe(attempt, loaded.state().orElse(null))) {
|
||||
|
||||
@@ -1292,8 +1292,9 @@ class EquipmentSessionsNativeTest {
|
||||
}
|
||||
}
|
||||
|
||||
@Test void cooldownExplainsRemainingSecondsAndSameCharacterBeforeEquipmentPreflight() throws Exception {
|
||||
try (var f = new Fixture()) {
|
||||
@Test void cooldownShowsOnlyFreshRoundedRemainingSecondsBeforeEquipmentPreflight() throws Exception {
|
||||
var clock = new MutableClock();
|
||||
try (var f = new Fixture(Duration.ofSeconds(13), clock)) {
|
||||
var actor = f.actor(); f.activate(actor);
|
||||
f.sessions.exit(actor.player);
|
||||
var exited = f.state(actor);
|
||||
@@ -1304,14 +1305,18 @@ class EquipmentSessionsNativeTest {
|
||||
actor.inventory.setItem(0, new ItemStack(Material.SHULKER_BOX));
|
||||
actor.cursor = new ItemStack(Material.EMERALD);
|
||||
var before = actor.snapshot(); var cursor = actor.cursor.clone(); var marker = actor.marker();
|
||||
for (int retry = 0; retry < 2; retry++) {
|
||||
clock.advance(Duration.ofMillis(900));
|
||||
for (String expected : java.util.List.of(
|
||||
"Wait 13 seconds to switch characters; the same character may be resumed now.",
|
||||
"Wait 12 seconds to switch characters; the same character may be resumed now.")) {
|
||||
f.sessions.enter(actor.player); f.tick();
|
||||
var notice = f.notices.getLast();
|
||||
assertEquals("COOLDOWN", notice.code());
|
||||
assertTrue(notice.message().matches("(?s).*Wait [1-9][0-9]* seconds.*"), notice::message);
|
||||
assertTrue(notice.message().contains("same character may be resumed now"), notice::message);
|
||||
assertEquals(expected, notice.message());
|
||||
assertFalse(notice.message().contains(exited.lastExit().deadline().toString()));
|
||||
assertArrayEquals(before, actor.snapshot()); assertEquals(cursor, actor.cursor);
|
||||
assertEquals(marker, actor.marker()); assertEquals(exited, f.state(actor));
|
||||
clock.advance(Duration.ofMillis(100));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user