Files
purpur-base/src/test/java/games/dmg/spigotbase/PlayerStateTest.java
T
dmg 259ea9410c
Release / release (push) Successful in 2m16s
CI / build (push) Successful in 1m3s
feat(spawning): add spawnable block overlay
2026-08-10 22:46:02 -04:00

68 lines
2.3 KiB
Java

package games.dmg.spigotbase;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.junit.jupiter.api.Assertions.assertTrue;
import java.time.Instant;
import java.util.Map;
import java.util.Optional;
import java.util.UUID;
import org.junit.jupiter.api.Test;
final class PlayerStateTest {
@Test
void spawnableOverlayProgressAndPreferenceCanBeUpdated() {
PlayerState player = PlayerState.newPlayer(UUID.randomUUID(), "Alex")
.withAdministrativeLevels(1, 0, 0, 0, 0, false, false, false)
.withBase(
new BaseLocation(UUID.randomUUID(), "world", 0, 64, 0, 0, 0),
Instant.EPOCH
);
PlayerState updated = player
.withTotalBlocksPlaced(250)
.withSpawnableOverlayEnabled(true);
assertTrue(updated.spawnableOverlayEnabled());
assertTrue(updated.totalBlocksPlaced() == 250);
}
@Test
void borderVisualizationIsDisabledByDefaultAndCanBeEnabled() {
UUID playerId = UUID.randomUUID();
PlayerState player = PlayerState.newPlayer(playerId, "Alex");
PlayerState established = player
.withAdministrativeLevels(1, 0, 0, 0, 0, false, false, false)
.withBase(
new BaseLocation(UUID.randomUUID(), "world", 0, 64, 0, 0, 0),
Instant.EPOCH
);
assertFalse(player.borderEnabled());
assertTrue(established.withBorderEnabled(true).borderEnabled());
}
@Test
void rejectsLevelsOutsideKnownRanges() {
UUID playerId = UUID.randomUUID();
assertThrows(IllegalArgumentException.class, () -> new PlayerState(
playerId, "Alex", Optional.empty(), 5, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0,
false, false, true, false, Optional.empty(), Optional.empty(), Map.of()
));
}
@Test
void rejectsBenefitsWhosePrerequisitesAreMissing() {
UUID playerId = UUID.randomUUID();
assertThrows(IllegalArgumentException.class, () -> new PlayerState(
playerId, "Alex", Optional.empty(), 0, 1, 0, 0, 0,
0, 0, 0, 0, 0, 0,
false, false, true, false, Optional.empty(), Optional.empty(), Map.of()
));
}
}