Build / build (push) Failing after 27s
Co-Authored-By: Claude Sonnet 5 <[email protected]>
99 lines
3.0 KiB
Java
99 lines
3.0 KiB
Java
package us.tss3.blockparty.logic;
|
|
|
|
import java.util.ArrayList;
|
|
import java.util.List;
|
|
|
|
/**
|
|
* Validates the raw fields of an arena configuration without touching Bukkit types.
|
|
* Callers adapt their config objects into a {@link Fields} record.
|
|
*/
|
|
public final class ArenaConfigValidator {
|
|
|
|
private ArenaConfigValidator() {
|
|
}
|
|
|
|
public record Fields(
|
|
String name,
|
|
String world,
|
|
boolean hasLobby,
|
|
boolean hasSpawn,
|
|
boolean hasSpectator,
|
|
boolean hasFloorCorners,
|
|
int minPlayers,
|
|
int maxPlayers,
|
|
int countdownDuration,
|
|
int roundPrepDuration,
|
|
int floorRemoveDelay,
|
|
int floorRestoreDelay,
|
|
int startingRoundTime,
|
|
int minimumRoundTime,
|
|
int reductionPerRound,
|
|
int winEndingDelay,
|
|
List<String> floorMaterials
|
|
) {
|
|
}
|
|
|
|
public static List<String> validate(Fields f) {
|
|
List<String> errors = new ArrayList<>();
|
|
if (isBlank(f.name())) {
|
|
errors.add("name is missing");
|
|
}
|
|
if (isBlank(f.world())) {
|
|
errors.add("world is missing or invalid");
|
|
}
|
|
if (!f.hasLobby()) {
|
|
errors.add("lobby location is not set");
|
|
}
|
|
if (!f.hasSpawn()) {
|
|
errors.add("spawn location is not set");
|
|
}
|
|
if (!f.hasSpectator()) {
|
|
errors.add("spectator location is not set");
|
|
}
|
|
if (!f.hasFloorCorners()) {
|
|
errors.add("floor region (pos1/pos2) is not set");
|
|
}
|
|
if (f.minPlayers() < 1) {
|
|
errors.add("min-players must be >= 1");
|
|
}
|
|
if (f.maxPlayers() < f.minPlayers()) {
|
|
errors.add("max-players must be >= min-players");
|
|
}
|
|
if (f.countdownDuration() <= 0) {
|
|
errors.add("countdown-duration must be > 0");
|
|
}
|
|
if (f.roundPrepDuration() < 0) {
|
|
errors.add("round-prep-duration must be >= 0");
|
|
}
|
|
if (f.floorRemoveDelay() < 0) {
|
|
errors.add("floor-remove-delay must be >= 0");
|
|
}
|
|
if (f.floorRestoreDelay() < 0) {
|
|
errors.add("floor-restore-delay must be >= 0");
|
|
}
|
|
if (f.startingRoundTime() <= 0) {
|
|
errors.add("starting-round-time must be > 0");
|
|
}
|
|
if (f.minimumRoundTime() < 0) {
|
|
errors.add("minimum-round-time must be >= 0");
|
|
}
|
|
if (f.minimumRoundTime() > f.startingRoundTime()) {
|
|
errors.add("minimum-round-time must be <= starting-round-time");
|
|
}
|
|
if (f.reductionPerRound() < 0) {
|
|
errors.add("round-time-reduction must be >= 0");
|
|
}
|
|
if (f.winEndingDelay() < 0) {
|
|
errors.add("win-ending-delay must be >= 0");
|
|
}
|
|
if (f.floorMaterials() == null || f.floorMaterials().isEmpty()) {
|
|
errors.add("floor-materials palette is empty");
|
|
}
|
|
return errors;
|
|
}
|
|
|
|
private static boolean isBlank(String s) {
|
|
return s == null || s.isBlank();
|
|
}
|
|
}
|