Add modular class loaders, enhanced mod verification, and new test cases for mod loading and validation.
This commit is contained in:
1 parent
df4d58a279
commit
3b21fc3aa6
27 files changed
+1871
-105
No files matched your search
@@ -64,4 +64,7 @@ public abstract class Mod
|
||||
|
||||
/** The mod's folder, {@code <forge>/mods/<id>}. */
|
||||
protected final Path directory() { return this.context.directory(); }
|
||||
|
||||
/** The mod's settings from {@code config.toml}. */
|
||||
protected final ModConfig config() { return this.context.config(); }
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
package dev.overlord.zomboidforge.api;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
/**
|
||||
* Settings of one mod: {@code <forge>/mods/<id>/config.toml}, over the defaults in the mod's
|
||||
* jar ({@code META-INF/zomboidforge/config.toml}). A key missing from the file takes the
|
||||
* default. The table {@code [forge]} belongs to ZomboidForge and is not part of these settings.
|
||||
*
|
||||
* <p>Keys are {@code snake_case}; record components and paths use the same names converted
|
||||
* from {@code camelCase} ({@code maxBalance} reads {@code max_balance}).
|
||||
*/
|
||||
public interface ModConfig
|
||||
{
|
||||
/**
|
||||
* Creates a record from the settings. Supported component types: {@code String},
|
||||
* {@code boolean}, {@code int}, {@code long}, {@code float}, {@code double} (and their
|
||||
* wrappers), enums (by constant name), records (TOML tables), {@code List<T>},
|
||||
* {@code Map<String, T>} (tables with free keys), and {@code Optional<T>} for values that
|
||||
* may be missing. Every other component must have a value. Keys without a component are
|
||||
* logged as warnings.
|
||||
*
|
||||
* @throws IllegalStateException listing every missing or mistyped value
|
||||
*/
|
||||
<T extends Record> T bind(Class<T> type);
|
||||
|
||||
/**
|
||||
* The value at a dotted path, e.g. {@code "features.max_balance"}, converted like a record
|
||||
* component of {@code type}. Primitive values use the wrapper types ({@code Long.class}).
|
||||
*
|
||||
* @throws IllegalStateException when the value exists but has another type
|
||||
*/
|
||||
<T> Optional<T> get(String path, Class<T> type);
|
||||
}
|
||||
@@ -22,4 +22,7 @@ public interface ModContext
|
||||
|
||||
/** The mod's folder, {@code <forge>/mods/<id>}. */
|
||||
Path directory();
|
||||
|
||||
/** The mod's settings from {@code config.toml}. */
|
||||
ModConfig config();
|
||||
}
|
||||
Reference in new issue
Block a user