Package com.enhancedechest.migration
Class SourceDatabaseReader
java.lang.Object
com.enhancedechest.migration.SourceDatabaseReader
- All Implemented Interfaces:
AutoCloseable
Opens an EnhancedEchest database of any supported dialect read-only and reads its
players and enderchests tables (under the active install's
database.table-prefix) verbatim, for the /ee import DB→DB copy. Unlike the vault-plugin
migrators this does no item decoding: rows are read column-for-column (including the raw
container_data bytes) and handed straight to
EnderChestStorage.importRows(java.util.List<com.enhancedechest.storage.EnderChestStorage.RawPlayerRow>, java.util.List<com.enhancedechest.storage.EnderChestStorage.RawChestRow>).
The schema is assumed to already be at the current version — the docs instruct the admin to load
the source with this plugin version first. No SchemaMigrator is run here; a missing column
surfaces as a SQLException, which the service turns into a "source schema outdated"
message rather than silently importing partial data. The source's tables are assumed to use the same
table-prefix as the active destination, since both are the same plugin's schema.
Not thread-safe; open, readAll() and close() on one thread (the shared DB
executor). Uses the same shaded/relocated drivers as the storage layer, registered via
Class.forName(java.lang.String) so DriverManager can find them under Paper's plugin classloader.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final recordThe two tables read from the source, kept in memory (data is modest — see the import plan). -
Method Summary
Modifier and TypeMethodDescriptionbackend()The source backend name (e.g.voidclose()static SourceDatabaseReaderopen(SourceSpec spec, Path dataFolder, org.slf4j.Logger log, String tablePrefix) Opens the source database described byspec, read-only.readAll()Reads both tables in two forward-only queries — no per-player N+1.
-
Method Details
-
backend
The source backend name (e.g. "SQLite", "MySQL"), for logging. -
open
public static SourceDatabaseReader open(SourceSpec spec, Path dataFolder, org.slf4j.Logger log, String tablePrefix) throws Exception Opens the source database described byspec, read-only.- Parameters:
dataFolder- plugin data folder, used to resolve a relative SQLite file pathtablePrefix- the active install'sdatabase.table-prefix, assumed shared with the source- Throws:
IllegalStateException- if the SQLite source file does not existIllegalArgumentException- if the source type is unsupportedException- if the driver is missing or the connection fails
-
readAll
Reads both tables in two forward-only queries — no per-player N+1.- Throws:
Exception
-
close
public void close()- Specified by:
closein interfaceAutoCloseable
-