Interface ModStorage


public interface ModStorage
The mod's tables in zomboidforge.db, next to the world's save. Every table belongs to the mod; other mods cannot reach it.

A record declares a table's columns: String, long/int, double/float, boolean, byte[], UUID, Instant, and enums. Primitive components cannot be null. Table and column names are snake_case (lastPaid is stored as last_paid).

Calls block. On the main thread they are only allowed during startup (onLoad); once the server runs they throw an IllegalStateException, so database I/O never costs tick time. Use modThread() or async().

  • Method Details

    • table

      <R extends Record> Table<R> table(String name, Class<R> type)
      Opens the table name with schema version 1 and no migrations.
    • define

      <R extends Record> TableDefinition<R> define(String name, Class<R> type)
      A table with a schema version and migrations; see TableDefinition.
    • transaction

      void transaction(Runnable work)
      Runs work in one transaction: writes of this thread inside it are committed together, or not at all when work throws.
    • transaction

      <T> T transaction(Supplier<T> work)
      Like transaction(Runnable), returning the result of work.