Update LuaModAutomator to 0.6.0 ZF API, update features and Workshop handling.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
OverlordandClaude Bot committed 2026-10-10 19:55:43 +02:00
1 parent 322092729f
commit 389b5b19d7
17 files changed
+309 -101

No files matched your search

@@ -1,5 +1,7 @@
package dev.overlord.luamodautomator;
import dev.overlord.zomboidforge.api.annotations.RegisterCommand;
import org.jetbrains.annotations.Nullable;
import zombie.characters.Capability;
@@ -15,7 +17,9 @@ import zombie.core.raknet.UdpConnection;
* {@code /collection}: where the running mod list comes from and the result of the last drift
* check. {@code /collection check} starts a drift check on the mod thread. Works in the chat,
* the server console, and RCON; needs the capability of vanilla's {@code checkModsNeedUpdate}.
* ZomboidForge registers it before {@link LuaModAutomatorMod#onLoad()}.
*/
@RegisterCommand
@CommandName(name = "collection")
@CommandArgs(optional = "(\\S+)")
@CommandHelp(helpText = "collection [check]: shows where the mod list comes from and the last drift check; 'check' starts a drift check", shouldTranslated = false)
@@ -225,27 +225,43 @@ final class CollectionResolver
pinned.sort(Comparator.comparingInt(id -> overrides.get(id).position().orElseThrow()));
// All pinned items out first: removing one later would shift those placed before it.
ordered.removeAll(pinned);
for (String id : pinned)
{
ordered.remove(id);
ordered.add(Math.clamp(overrides.get(id).position().orElseThrow() - 1, 0, ordered.size()), id);
}
return ordered.stream().map(byId::get).toList();
}
/**
* Warns about Mod IDs named by two items, which {@code Mods=} lists once, and about Mod IDs
* that differ only in case, which it lists as written, since references ignore case but
* Project Zomboid may not.
*/
private static void duplicateModIds(List<Resolution.Item> items, List<String> warnings)
{
Map<String, Resolution.Item> first = new HashMap<>();
Map<String, Resolution.Item> first = new HashMap<>();
Map<String, String> spellings = new HashMap<>();
for (Resolution.Item item : items)
{
for (String modId : item.modIds())
{
Resolution.Item other = first.putIfAbsent(modId, item);
Resolution.Item other = first.putIfAbsent(modId, item);
String spelling = spellings.putIfAbsent(modId.toLowerCase(Locale.ROOT), modId);
if (other != null && other != item)
{
warnings.add("Mod ID '" + modId + "' is named by '" + other.title() + "' (" + other.id() + ") and '" + item.title() + "' (" + item.id() + "); Mods= lists it once.");
}
else if (spelling != null && !spelling.equals(modId))
{
Resolution.Item owner = first.get(spelling);
warnings.add("Mod IDs '" + spelling + "' of '" + owner.title() + "' (" + owner.id() + ") and '" + modId + "' of '" + item.title() + "' (" + item.id() + ") differ only in case; Mods= lists both.");
}
}
}
}
@@ -3,6 +3,7 @@ package dev.overlord.luamodautomator;
import java.util.ArrayList;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Locale;
import java.util.Set;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
@@ -18,14 +19,23 @@ final class DescriptionParser
private static final Pattern MOD_IDS = Pattern.compile("(?im)^\\s*Mod\\s*IDs?\\h*[:=]\\h*(.+)$");
private static final Pattern MAP_LINE = Pattern.compile("(?im)^\\s*Map\\s*Folder\\h*[:=]");
private static final Pattern MAP_FOLDER = Pattern.compile("(?im)^\\s*Map\\s*Folder\\h*[:=]\\h*(.+)$");
private static final Pattern SEPARATOR = Pattern.compile("[\\s,;]+");
private static final Pattern MOD_ID = Pattern.compile("[A-Za-z0-9_.\\-]+");
private static final Pattern COMMENT = Pattern.compile("\\h+[-–—]\\h.*$");
private static final Pattern SEPARATOR = Pattern.compile("[\\s,;/]+");
private static final Pattern MOD_ID = Pattern.compile("[A-Za-z0-9_.\\-]*[A-Za-z0-9][A-Za-z0-9_.\\-]*");
/** Words between Mod IDs, as in {@code Mod ID: Foo or Foo_Lite}. */
private static final Set<String> CONJUNCTIONS = Set.of("or", "and");
private DescriptionParser() {}
static String stripBbcode(String description) { return DescriptionParser.BBCODE.matcher(description).replaceAll(""); }
/** Every Mod ID of every {@code Mod ID} line, each once, in order of appearance. */
/**
* Every Mod ID of every {@code Mod ID} line, each once, in order of appearance. Mod IDs are
* separated by spaces, {@code ,}, {@code ;}, {@code /}, {@code or}, or {@code and}; a dash
* between spaces ({@code Foo - B42 only}) starts a comment that ends the line; tokens
* without a letter or digit, or with other characters, are skipped.
*/
static List<String> modIds(String description)
{
Set<String> modIds = new LinkedHashSet<>();
@@ -33,9 +43,11 @@ final class DescriptionParser
while (matcher.find())
{
for (String token : DescriptionParser.SEPARATOR.split(matcher.group(1).strip()))
String line = DescriptionParser.COMMENT.matcher(matcher.group(1)).replaceFirst("");
for (String token : DescriptionParser.SEPARATOR.split(line.strip()))
{
if (DescriptionParser.MOD_ID.matcher(token).matches()) modIds.add(token);
if (DescriptionParser.MOD_ID.matcher(token).matches() && !DescriptionParser.CONJUNCTIONS.contains(token.toLowerCase(Locale.ROOT))) modIds.add(token);
}
}
@@ -33,23 +33,33 @@ import org.jetbrains.annotations.Nullable;
*
* <p>While the server runs, a drift check resolves the collection again every
* {@code [drift] interval_min} minutes and logs how it differs from what the server runs, and
* which items were updated on Steam since startup. Changes take effect at the next restart.
* which items have a newer version on Steam than the server downloaded. Changes take effect at
* the next restart.
*
* <p>Threads: game objects ({@code ServerOptions}) on the main thread only, in {@link #onLoad()}
* and {@link CollectionCommand}; drift checks on the mod thread.
* <p>Threads: game objects ({@code ServerOptions}, {@code SteamWorkshop}) on the main thread
* only, in {@link #onLoad()}, {@link #onServerStarted()}, and {@link CollectionCommand}; drift
* checks on the mod thread.
*/
public final class LuaModAutomatorMod extends Mod
{
private static final String NO_CHECK = "No drift check yet.";
private static final DateTimeFormatter TIME = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss 'UTC'").withZone(ZoneOffset.UTC);
private static final String NO_CHECK = "No drift check yet.";
private static final DateTimeFormatter TIME = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss 'UTC'").withZone(ZoneOffset.UTC);
private static final Duration RETRY_DELAY = Duration.ofSeconds(2);
/** The loaded instance, for {@link CollectionCommand}, which Project Zomboid creates. */
private static volatile @Nullable LuaModAutomatorMod instance;
/** When the server started; the Workshop download comes after this, so later Steam updates are not on the server. */
/**
* When the mod loaded, before the Workshop download. Stands in for the installed version of
* items Steam does not report (no Steam mode), on the side of reporting updates the server
* may already have downloaded.
*/
private final Instant startedAt = Instant.now();
private final AtomicBoolean checkQueued = new AtomicBoolean();
/** {@link WorkshopAdapter#installedVersions}, set in {@link #onServerStarted()}, after the Workshop download. */
private volatile Map<String, Long> installed = Map.of();
// Set in onLoad(), read later. Tasks submitted after onLoad() see these values.
private @Nullable Settings settings;
private @Nullable String collectionId;
@@ -73,7 +83,6 @@ public final class LuaModAutomatorMod extends Mod
public void onLoad()
{
LuaModAutomatorMod.instance = this;
this.commands().register(CollectionCommand.class);
this.running = ServerOptionsAdapter.read();
@@ -115,7 +124,7 @@ public final class LuaModAutomatorMod extends Mod
try
{
Resolution resolution = this.resolve();
Resolution resolution = this.resolveAtStartup();
ServerValues values = resolution.values(settings.ini().baseMap());
this.logWarnings(resolution.warnings());
@@ -128,10 +137,14 @@ public final class LuaModAutomatorMod extends Mod
}
catch (SteamException | ConfigurationException e)
{
String reason = Objects.requireNonNullElse(e.getMessage(), e.getClass().getSimpleName());
this.log(WARNING, "Cannot resolve collection '" + this.collectionId + "': " + reason);
this.fallBack(reason.endsWith(".") ? reason.substring(0, reason.length() - 1) : reason);
this.log(WARNING, "Cannot resolve collection '" + this.collectionId + "': " + LuaModAutomatorMod.reason(e) + ".");
this.fallBack(LuaModAutomatorMod.reason(e));
}
catch (RuntimeException e)
{
// An exception that leaves onLoad() stops the server.
this.logger().log(ERROR, "Cannot resolve collection '" + this.collectionId + "'.", e);
this.fallBack(e.toString());
}
this.log(INFO, this.startup);
@@ -141,7 +154,18 @@ public final class LuaModAutomatorMod extends Mod
public void onServerStarted()
{
Settings settings = this.settings;
if (settings == null || settings.drift().intervalMin() == 0) return;
if (settings == null) return;
try
{
this.installed = WorkshopAdapter.installedVersions(this.running.workshopIds());
}
catch (RuntimeException e)
{
this.logger().log(WARNING, "Cannot read the versions of the installed Workshop items; updates count from the server's start.", e);
}
if (settings.drift().intervalMin() == 0) return;
Duration interval = Duration.ofMinutes(settings.drift().intervalMin());
this.modThread().scheduleWithFixedDelay(this::scheduledCheck, interval, interval);
@@ -272,7 +296,7 @@ public final class LuaModAutomatorMod extends Mod
this.lastCheck = "Last drift check " + time + ": "
+ (drift.isEmpty() ? "the collection matches the running mod list." : "the collection differs: " + difference + "; restart the server to apply it.")
+ (updated.isEmpty() ? "" : "\nUpdated on Steam since startup: " + String.join(", ", updated) + "; restart the server to load the updates.");
+ (updated.isEmpty() ? "" : "\nNewer on Steam than on the server: " + String.join(", ", updated) + "; restart the server to load the updates.");
}
catch (SteamException | ConfigurationException e)
{
@@ -294,28 +318,58 @@ public final class LuaModAutomatorMod extends Mod
}
/**
* Items the server runs that Steam updated after the server started, as {@code 'title' (id)};
* logs each update once. Mod thread.
* Items the server runs that have a newer version on Steam than the installed one (or, when
* Steam does not report it, than {@link #startedAt}), as {@code 'title' (id)}; logs each
* update once. Mod thread.
*/
private List<String> updatedItems(Resolution resolution)
{
Set<String> running = new HashSet<>(this.running.workshopIds());
List<String> updated = new ArrayList<>();
Set<String> running = new HashSet<>(this.running.workshopIds());
Map<String, Long> installed = this.installed;
List<String> updated = new ArrayList<>();
for (Resolution.Item item : resolution.items())
{
if (!running.contains(item.id()) || item.timeUpdated() <= this.startedAt.getEpochSecond()) continue;
if (!running.contains(item.id()) || item.timeUpdated() <= installed.getOrDefault(item.id(), this.startedAt.getEpochSecond())) continue;
String name = "'" + item.title() + "' (" + item.id() + ")";
updated.add(name);
if (!Objects.equals(this.reportedUpdates.put(item.id(), item.timeUpdated()), item.timeUpdated()))
this.log(WARNING, name + " was updated on Steam at " + LuaModAutomatorMod.TIME.format(Instant.ofEpochSecond(item.timeUpdated())) + ", after the server started. Restart the server to load the update; clients with the new version may not be able to join until then.");
this.log(WARNING, name + " was updated on Steam at " + LuaModAutomatorMod.TIME.format(Instant.ofEpochSecond(item.timeUpdated())) + ", after the version the server downloaded. Restart the server to load the update; clients with the new version may not be able to join until then.");
}
return updated;
}
/**
* {@link #resolve()}, tried once more after {@link #RETRY_DELAY} when Steam fails. Main
* thread, in {@link #onLoad()}, before the server runs.
*/
private Resolution resolveAtStartup() throws SteamException, ConfigurationException
{
try
{
return this.resolve();
}
catch (SteamException e)
{
this.log(WARNING, "Cannot resolve collection '" + this.collectionId + "': " + LuaModAutomatorMod.reason(e) + "; retrying in " + LuaModAutomatorMod.RETRY_DELAY.toSeconds() + " seconds.");
try
{
Thread.sleep(LuaModAutomatorMod.RETRY_DELAY);
}
catch (InterruptedException interrupted)
{
Thread.currentThread().interrupt();
throw e;
}
return this.resolve();
}
}
private Resolution resolve() throws SteamException, ConfigurationException
{
Settings settings = Objects.requireNonNull(this.settings);
@@ -386,6 +440,13 @@ public final class LuaModAutomatorMod extends Mod
private void log(System.Logger.Level level, String message) { this.logger().log(level, message); }
/** The message of {@code e}, without a final period. */
private static String reason(Exception e)
{
String reason = Objects.requireNonNullElse(e.getMessage(), e.getClass().getSimpleName());
return reason.endsWith(".") ? reason.substring(0, reason.length() - 1) : reason;
}
private static String counts(ServerValues values)
{
return LuaModAutomatorMod.count(values.workshopIds().size(), "Workshop item") + ", " + LuaModAutomatorMod.count(values.modIds().size(), "Mod ID") + ", Map=" + values.map();
@@ -51,10 +51,11 @@ record Resolution(List<Resolution.Item> items, List<Resolution.Item> excluded, L
*/
List<String> modList()
{
// Widths start at 1: "%-0s" is not a valid format.
List<String> lines = new ArrayList<>();
int number = String.valueOf(this.items.size()).length();
int title = 0;
int modIds = 0;
int title = 1;
int modIds = 1;
for (Item item : this.items)
{
@@ -1,5 +1,7 @@
package dev.overlord.luamodautomator;
import dev.overlord.zomboidforge.api.annotations.Min;
import java.util.List;
import java.util.Map;
import java.util.Optional;
@@ -21,22 +23,10 @@ record Settings(String collection, Settings.Ini ini, Settings.Steam steam, Setti
record Ini(boolean write, boolean manageMap, List<String> baseMap) {}
/** @param timeoutS seconds per Steam Web API request */
record Steam(int timeoutS)
{
Steam
{
if (timeoutS < 1) throw new IllegalArgumentException("'timeout_s' must be at least 1, found " + timeoutS);
}
}
record Steam(@Min(1) int timeoutS) {}
/** @param intervalMin minutes between drift checks while the server runs; 0 turns them off */
record Drift(int intervalMin)
{
Drift
{
if (intervalMin < 0) throw new IllegalArgumentException("'interval_min' must be 0 or more, found " + intervalMin);
}
}
record Drift(@Min(0) int intervalMin) {}
/**
* @param buckets the bucket sequence of the load order
@@ -53,15 +43,10 @@ record Settings(String collection, Settings.Ini ini, Settings.Steam steam, Setti
* @param position 1-based place in the final list, applied after {@code priority}
* @param exclude whether the item is left out of {@code Mods=}, {@code WorkshopItems=}, and {@code Map=}
*/
record Item(Optional<List<String>> modIds, Optional<String> title, Optional<String> bucket, Optional<Integer> position, Optional<Boolean> exclude)
record Item(Optional<List<String>> modIds, Optional<String> title, Optional<String> bucket, @Min(1) Optional<Integer> position, Optional<Boolean> exclude)
{
static final Item NONE = new Item(Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty());
Item
{
if (position.isPresent() && position.get() < 1) throw new IllegalArgumentException("'position' must be at least 1, found " + position.get());
}
boolean excluded() { return this.exclude.orElse(false); }
/** These overrides, with the fields this item does not set taken from {@code other}. */
@@ -44,7 +44,8 @@ final class SteamWorkshopApi implements AutoCloseable
/** {@code filetype} of a child that is itself a collection. */
private static final int COLLECTION = 2;
private static final Pattern COLLECTION_ID = Pattern.compile("(?:[?&]id=)?(\\d{2,})");
private static final Pattern ID_PARAMETER = Pattern.compile("[?&]id=(\\d{2,})");
private static final Pattern BARE_ID = Pattern.compile("\\d{2,}");
private final HttpClient client;
private final URI base;
@@ -59,11 +60,19 @@ final class SteamWorkshopApi implements AutoCloseable
this.userAgent = userAgent;
}
/** The collection id in {@code setting}, a collection URL or a bare id. */
/**
* The collection id in {@code setting}: the {@code id} parameter of a collection URL, which
* may have other numeric parameters such as {@code tscn}, or a bare id.
*/
static Optional<String> collectionId(String setting)
{
Matcher matcher = SteamWorkshopApi.COLLECTION_ID.matcher(setting.strip());
return matcher.find() ? Optional.of(matcher.group(1)) : Optional.empty();
String value = setting.strip();
Matcher matcher = SteamWorkshopApi.ID_PARAMETER.matcher(value);
if (matcher.find()) return Optional.of(matcher.group(1));
if (SteamWorkshopApi.BARE_ID.matcher(value).matches()) return Optional.of(value);
return Optional.empty();
}
/**
@@ -0,0 +1,50 @@
package dev.overlord.luamodautomator;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import zombie.core.znet.SteamUtils;
import zombie.core.znet.SteamWorkshop;
/**
* The versions of the Workshop items installed on the server. Main thread only.
*
* <p>Steam reports, for an installed item, when the installed version was updated on the
* Workshop; {@code GameServerWorkshopItems} compares it with Steam's {@code time_updated} to
* decide whether an item needs an update (Project Zomboid 42.21).
*/
final class WorkshopAdapter
{
private WorkshopAdapter() {}
/**
* For each of {@code ids}, when its installed version was updated on the Workshop, in
* seconds since the epoch. Ids that are not installed or not numeric are left out; all of
* them without Steam mode.
*/
static Map<String, Long> installedVersions(List<String> ids)
{
if (!SteamUtils.isSteamModeEnabled()) return Map.of();
Map<String, Long> versions = new HashMap<>();
for (String id : ids)
{
long timeUpdated;
try
{
timeUpdated = SteamWorkshop.instance.GetItemInstallTimeStamp(Long.parseLong(id));
}
catch (NumberFormatException e)
{
continue;
}
if (timeUpdated > 0) versions.put(id, timeUpdated);
}
return Map.copyOf(versions);
}
}
@@ -2,10 +2,12 @@
* LuaModAutomator: the server's {@code Mods=}, {@code WorkshopItems=}, and {@code Map=} come
* from a public Steam Workshop collection, resolved at every start.
*
* <p>Only {@link dev.overlord.luamodautomator.LuaModAutomatorMod},
* {@link dev.overlord.luamodautomator.ServerOptionsAdapter}, and
* {@link dev.overlord.luamodautomator.CollectionCommand} use game classes; everything else runs
* without the game.
* <p>Only
* {@link dev.overlord.luamodautomator.LuaModAutomatorMod},
* {@link dev.overlord.luamodautomator.ServerOptionsAdapter},
* {@link dev.overlord.luamodautomator.WorkshopAdapter}, and
* {@link dev.overlord.luamodautomator.CollectionCommand} use game classes;
* everything else runs without the game.
*
* @noinspection UnstableApiUsage, RedundantSuppression
*/
@@ -73,7 +73,24 @@ class CollectionResolverTest
Resolution resolution = CollectionResolver.resolve(CollectionResolverTest.COLLECTION, order, items);
assertEquals(List.of("100", "200", "300", "400", "500"), CollectionResolverTest.ids(resolution));
assertEquals(List.of("100", "300", "200", "400", "500"), CollectionResolverTest.ids(resolution));
}
@Test
void pinsKeepTheirPlaceWhenALaterPinStartsAheadOfThem() throws ConfigurationException
{
List<WorkshopItem> collection = List.of(
CollectionResolverTest.item("1", "B", "Mod ID: B"),
CollectionResolverTest.item("2", "X", "Mod ID: X"),
CollectionResolverTest.item("3", "Y", "Mod ID: Y"),
CollectionResolverTest.item("4", "P", "Mod ID: P"),
CollectionResolverTest.item("5", "Z", "Mod ID: Z")
);
Map<String, Settings.Item> items = Map.of("P", CollectionResolverTest.position(3), "B", CollectionResolverTest.position(4));
Resolution resolution = CollectionResolver.resolve(collection, CollectionResolverTest.DEFAULT_ORDER, items);
assertEquals(List.of("2", "3", "4", "1", "5"), CollectionResolverTest.ids(resolution));
}
@Test
@@ -169,6 +186,16 @@ class CollectionResolverTest
assertEquals(1, resolution.warnings().size());
}
@Test
void modIdsDifferingOnlyInCaseAreWarnedAboutAndBothListed() throws ConfigurationException
{
List<WorkshopItem> collection = List.of(CollectionResolverTest.item("100", "One", "Mod ID: Shared"), CollectionResolverTest.item("200", "Two", "Mod ID: shared"));
Resolution resolution = CollectionResolver.resolve(collection, CollectionResolverTest.DEFAULT_ORDER, Map.of());
assertEquals("\\Shared;\\shared", resolution.values(List.of()).mods());
assertEquals(List.of("Mod IDs 'Shared' of 'One' (100) and 'shared' of 'Two' (200) differ only in case; Mods= lists both."), resolution.warnings());
}
@Test
void mapFoldersThenBaseMapEachOnce() throws ConfigurationException
{
@@ -200,6 +227,15 @@ class CollectionResolverTest
), modList);
}
@Test
void modListWithAnEmptyTitle() throws ConfigurationException
{
List<WorkshopItem> collection = List.of(CollectionResolverTest.item("100", "Misc One", "Mod ID: MiscOne"));
Map<String, Settings.Item> items = Map.of("100", new Settings.Item(Optional.empty(), Optional.of(""), Optional.empty(), Optional.empty(), Optional.empty()));
assertEquals(List.of("Mod List:", "1. 100 MiscOne"), CollectionResolver.resolve(collection, CollectionResolverTest.DEFAULT_ORDER, items).modList());
}
private static List<String> ids(Resolution resolution) { return resolution.items().stream().map(Resolution.Item::id).toList(); }
private static WorkshopItem item(String id, String title, String description) { return WorkshopItem.of(id, title, description, List.of("Build 42"), 0); }
@@ -43,6 +43,30 @@ class DescriptionParserTest
assertEquals(List.of("Foo", "Bar"), DescriptionParser.modIds("Mod ID: Foo (Bar) Bar"));
}
@Test
void modIdsSkipTokensWithoutLetterOrDigit()
{
assertEquals(List.of("Foo", "Bar"), DescriptionParser.modIds("Mod ID: Foo -- Bar ..."));
}
@Test
void modIdsSeparatedByWords()
{
assertEquals(List.of("Foo", "Foo_Lite", "Bar", "Baz"), DescriptionParser.modIds("Mod ID: Foo or Foo_Lite\nMod IDs: Bar AND Baz"));
}
@Test
void modIdsSeparatedBySlashes()
{
assertEquals(List.of("Foo", "FooLite"), DescriptionParser.modIds("Mod ID: Foo/FooLite"));
}
@Test
void spacedDashStartsAComment()
{
assertEquals(List.of("Bar", "Baz-Lite"), DescriptionParser.modIds("Mod ID: Bar - B42 only\nMod ID: Baz-Lite – optional"));
}
@Test
void emptyModIdLineDoesNotReadTheNextLine()
{
@@ -102,13 +102,20 @@ class SettingsTest
@Test
void invalidValues()
{
assertThrows(IllegalStateException.class, () -> SettingsTest.bind("[steam]\ntimeout_s = 0"));
assertThrows(IllegalStateException.class, () -> SettingsTest.bind("[drift]\ninterval_min = -1"));
assertThrows(IllegalStateException.class, () -> SettingsTest.bind("[items.123]\nposition = 0"));
assertThrows(IllegalStateException.class, () -> SettingsTest.bind("[items.123]\nmod_ids = \"Foo\""));
assertThrows(IllegalStateException.class, () -> SettingsTest.bind("collection = 123"));
}
@Test
void valuesOutOfBoundsAreReportedTogetherWithTheirKeys()
{
String message = assertThrows(IllegalStateException.class, () -> SettingsTest.bind("[steam]\ntimeout_s = 0\n[drift]\ninterval_min = -1\n[items.123]\nposition = 0")).getMessage();
assertTrue(message.contains("'steam.timeout_s' must be at least 1, found 0."), message);
assertTrue(message.contains("'drift.interval_min' must be at least 0, found -1."), message);
assertTrue(message.contains("'items.123.position' must be at least 1, found 0."), message);
}
static Settings bind(String overrides) { return SettingsTest.bind(overrides, new CopyOnWriteArrayList<>()); }
/** The shipped defaults with {@code overrides} on top, bound like the server binds them; warnings go to {@code warnings}. */
@@ -73,8 +73,10 @@ class SteamWorkshopApiTest
{
assertEquals(Optional.of("1234567890"), SteamWorkshopApi.collectionId("https://steamcommunity.com/sharedfiles/filedetails/?id=1234567890"));
assertEquals(Optional.of("1234567890"), SteamWorkshopApi.collectionId("https://steamcommunity.com/sharedfiles/filedetails/?searchtext=&id=1234567890"));
assertEquals(Optional.of("1234567890"), SteamWorkshopApi.collectionId("https://steamcommunity.com/sharedfiles/filedetails/?tscn=1712345678&id=1234567890"));
assertEquals(Optional.of("1234567890"), SteamWorkshopApi.collectionId(" 1234567890 "));
assertEquals(Optional.empty(), SteamWorkshopApi.collectionId("my collection"));
assertEquals(Optional.empty(), SteamWorkshopApi.collectionId("https://steamcommunity.com/sharedfiles/filedetails/?tscn=1712345678"));
}
@Test