Class BackendRegistry
On each platform the backends are ordered by the first DataVersion they serve. Each one is
selected from its first DataVersion up to the next one's start, which also covers snapshots and
releases between the checked ranges; the newest is selected for every later version (future
snapshots). Versions older than the oldest backend's start get none. The checked last
of a descriptor doesn't limit selection; the build check (checkUiBackends) uses it.
For example, the Fabric backends start at DataVersions 1952 (1.14), 2566 (1.16), 3218 (1.19.3), 3463 (1.20) and 4786: a game at 3465 (1.20.1) gets the one starting at 3463, a future snapshot the one starting at 4786, and nothing is selected below 1952. Immutable. Part of the backend contract; mods don't need it.
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionBackendRegistry(List<BackendDescriptor> backends) A registry ofbackends; usually made byload(ClassLoader). -
Method Summary
Modifier and TypeMethodDescriptionall()Every backend, sorted by id.forPlatform(UiPlatform platform) The backends servingplatform, oldest first (byBackendDescriptor.first(UiPlatform)).static BackendRegistryload(ClassLoader loader) Reads the backends listed inINDEX.select(UiPlatform platform, int dataVersion) The backend for a game atdataVersiononplatform: the one with the highest first DataVersion not abovedataVersion.
-
Field Details
-
DESCRIPTORS
Folder of the descriptors in a platform jar; same asUI_BACKEND_DESCRIPTORSin buildSrc.- See Also:
-
INDEX
One backend id per line: the descriptors bundled next to it (a class loader can't list a folder).- See Also:
-
-
Constructor Details
-
BackendRegistry
A registry ofbackends; usually made byload(ClassLoader).- Parameters:
backends- the backends; copied- Throws:
IllegalArgumentException- if two backends have the same id, or start at the same DataVersion on one platform (selection would be ambiguous)
-
-
Method Details
-
load
Reads the backends listed inINDEX. A jar without an index has no backends. Blank lines and lines starting with#in the index are skipped.- Parameters:
loader- the class loader whose resources hold the platform jar's descriptors- Returns:
- the registry
- Throws:
IOException- if the index names a descriptor that is missing or unreadableIllegalArgumentException- if a descriptor is malformed
-
all
-
forPlatform
The backends servingplatform, oldest first (byBackendDescriptor.first(UiPlatform)).- Parameters:
platform- a loader- Returns:
- a new list, possibly empty
-
select
The backend for a game atdataVersiononplatform: the one with the highest first DataVersion not abovedataVersion.- Parameters:
platform- the running loaderdataVersion- the running game's DataVersion- Returns:
- the backend, or
nullif the version is older than every backend of that platform (or the platform has none)
-