资源与缓存契约:公开签名参考
本页目录
本文对应 1.21.10 现代框架。文档中的接口与配置按当前文档快照核对;完整框架仍在开发验收。接口可编译、配置可解析与游戏内效果验证分别记录。
先读开发入门,再按下方类型查阅精确签名。
本章收录声明为 public 的类型和配对编译产物中的公开成员。公开可见性不自动代表稳定扩展点;平台服务应通过既有注册入口获取,底层类型仅供明确契约的扩展使用。构造器、record 访问器与枚举生成方法均保留。没有注解承诺的成员状态为未分类。
DirectoryResourceProvider
com.heartlion.shadowui.resource.DirectoryResourceProvider
public class com.heartlion.shadowui.resource.DirectoryResourceProvider implements com.heartlion.shadowui.resource.ShadowResourceProvider {
public com.heartlion.shadowui.resource.DirectoryResourceProvider(java.io.File);
public boolean exists(java.lang.String);
public java.io.InputStream open(java.lang.String) throws java.lang.Exception;
public com.heartlion.shadowui.resource.ShadowResourceMetadata metadata(java.lang.String) throws java.lang.Exception;
public java.util.List<java.lang.String> list(java.lang.String, java.lang.String);
public void close();
}
EncryptedZipResourceProvider
com.heartlion.shadowui.resource.EncryptedZipResourceProvider
Reads the SPK2 authenticated, flat resource container without extracting it.
public class com.heartlion.shadowui.resource.EncryptedZipResourceProvider implements com.heartlion.shadowui.resource.ShadowResourceProvider {
public com.heartlion.shadowui.resource.EncryptedZipResourceProvider(java.io.File, java.lang.String, java.lang.String) throws java.lang.Exception;
public com.heartlion.shadowui.resource.EncryptedZipResourceProvider(java.io.File, java.lang.String, char[]) throws java.lang.Exception;
public synchronized boolean exists(java.lang.String);
public synchronized java.io.InputStream open(java.lang.String) throws java.lang.Exception;
public synchronized com.heartlion.shadowui.resource.ShadowResourceMetadata metadata(java.lang.String);
public synchronized java.util.List<java.lang.String> list(java.lang.String, java.lang.String);
public synchronized int getEntryCount();
public synchronized long getOpenCount();
public synchronized boolean matchesDirectory(java.io.File) throws java.lang.Exception;
public synchronized void close();
}
matchesDirectory
public synchronized boolean matchesDirectory(File directory) throws Exception
Verifies that every archived entry still has identical plaintext in a retained ShadowCache. Extra plaintext files are allowed because they stay visible through the fallback provider after the encrypted provider wins.
IndexedAssetProvider
com.heartlion.shadowui.resource.IndexedAssetProvider
One immutable client-asset name index over an owned provider. Bytes retain the provider's read semantics.
public final class com.heartlion.shadowui.resource.IndexedAssetProvider implements com.heartlion.shadowui.resource.ShadowResourceProvider {
public com.heartlion.shadowui.resource.IndexedAssetProvider(com.heartlion.shadowui.resource.ShadowResourceProvider, java.util.function.Consumer<java.lang.String>);
public synchronized java.util.Set<java.lang.String> namespaces();
public synchronized boolean exists(java.lang.String);
public synchronized java.io.InputStream open(java.lang.String) throws java.lang.Exception;
public synchronized com.heartlion.shadowui.resource.ShadowResourceMetadata metadata(java.lang.String) throws java.lang.Exception;
public synchronized java.util.List<java.lang.String> list(java.lang.String, java.lang.String);
public synchronized void close() throws java.io.IOException;
}
IndexedAssetProvider
public IndexedAssetProvider(ShadowResourceProvider source, Consumer<String> invalidPath)
Transfers ownership only after successful construction. Invalid logical names never reach native consumers.
LegacyAssetProvider
com.heartlion.shadowui.resource.LegacyAssetProvider
Local legacy aliases and virtual language JSON. The underlying files/archives are never rewritten.
public final class com.heartlion.shadowui.resource.LegacyAssetProvider implements com.heartlion.shadowui.resource.ShadowResourceProvider {
public com.heartlion.shadowui.resource.LegacyAssetProvider(com.heartlion.shadowui.resource.ShadowResourceProvider);
public synchronized boolean exists(java.lang.String);
public synchronized java.io.InputStream open(java.lang.String) throws java.lang.Exception;
public synchronized com.heartlion.shadowui.resource.ShadowResourceMetadata metadata(java.lang.String) throws java.lang.Exception;
public synchronized java.util.List<java.lang.String> list(java.lang.String, java.lang.String);
public synchronized void close() throws java.io.IOException;
}
LegacyLanguage
com.heartlion.shadowui.resource.LegacyLanguage
Read-only adaptation of Forge 1.12 language syntax to native language JSON.
public final class com.heartlion.shadowui.resource.LegacyLanguage {
public static byte[] convert(java.io.InputStream, java.io.InputStream) throws java.io.IOException;
}
convert
public static byte[] convert(InputStream legacy, InputStream modern) throws IOException
Streams remain caller-owned. Modern definitions win per key; old-only keys remain available.
LocalResourceBaseline
com.heartlion.shadowui.resource.LocalResourceBaseline
Local-only baseline selection. Servers cannot select an SPS1 archive or change this mode.
public final class com.heartlion.shadowui.resource.LocalResourceBaseline implements java.lang.AutoCloseable {
public static final java.lang.String SIMPLE_MODE;
public final com.heartlion.shadowui.resource.ShadowResourceProvider provider;
public final java.lang.String kind;
public final com.heartlion.shadowui.resource.LocalResourceBaseline$Discovery discovery;
public final java.lang.Exception fallbackReason;
public static com.heartlion.shadowui.resource.LocalResourceBaseline$Discovery discover(java.io.File) throws java.io.IOException;
public static com.heartlion.shadowui.resource.LocalResourceBaseline open(java.io.File, java.lang.String) throws java.io.IOException;
public void close() throws java.io.IOException;
}
discover
public static Discovery discover(File directory) throws IOException
Extension alone does not distinguish SPK2 from SPS1. Multiple SPS1 candidates are ambiguous.
open
public static LocalResourceBaseline open(File gameDirectory, String mode) throws IOException
Selection is read-only: no migration, creation, deletion or rewriting of the local asset directories.
LocalResourceBaseline.Discovery
com.heartlion.shadowui.resource.LocalResourceBaseline.Discovery
public final class com.heartlion.shadowui.resource.LocalResourceBaseline$Discovery {
public final java.io.File file;
public final int candidates;
}
ManifestResourceProvider
com.heartlion.shadowui.resource.ManifestResourceProvider
A manifest whitelist over verified cache objects; unlisted disk files are never visible.
public final class com.heartlion.shadowui.resource.ManifestResourceProvider implements com.heartlion.shadowui.resource.ShadowResourceProvider {
public com.heartlion.shadowui.resource.ManifestResourceProvider(java.util.Collection<com.heartlion.shadowui.resource.ManifestResourceProvider$Entry>);
public boolean exists(java.lang.String);
public java.io.InputStream open(java.lang.String) throws java.lang.Exception;
public com.heartlion.shadowui.resource.ShadowResourceMetadata metadata(java.lang.String);
public java.util.List<java.lang.String> list(java.lang.String, java.lang.String);
public void close();
}
ManifestResourceProvider.Entry
com.heartlion.shadowui.resource.ManifestResourceProvider.Entry
public final class com.heartlion.shadowui.resource.ManifestResourceProvider$Entry {
public com.heartlion.shadowui.resource.ManifestResourceProvider$Entry(java.lang.String, java.io.File, java.lang.String, long) throws java.io.IOException;
}
ResourceAssetValidator
com.heartlion.shadowui.resource.ResourceAssetValidator
Portable admission and dependency checks before a native resource reload. No external source fallback.
public final class com.heartlion.shadowui.resource.ResourceAssetValidator {
public static java.util.Set<java.lang.String> validate(com.heartlion.shadowui.resource.ShadowResourceProvider) throws java.lang.Exception;
}
ResourceViewStore
com.heartlion.shadowui.resource.ResourceViewStore
Owns one exclusive dynamic source. Preparation cannot change the active view; leases pin retired providers.
public final class com.heartlion.shadowui.resource.ResourceViewStore implements java.lang.AutoCloseable {
public com.heartlion.shadowui.resource.ResourceViewStore(java.util.function.Consumer<java.io.IOException>);
public synchronized long beginChange();
public synchronized com.heartlion.shadowui.resource.ResourceViewStore$Prepared prepare(long, com.heartlion.shadowui.resource.ShadowResourceProvider, java.lang.String);
public synchronized boolean commit(com.heartlion.shadowui.resource.ResourceViewStore$Prepared);
public synchronized boolean commit(com.heartlion.shadowui.resource.ResourceViewStore$Prepared, java.lang.Runnable, java.lang.Runnable);
public synchronized com.heartlion.shadowui.resource.ResourceViewStore$Transition beginTransition(com.heartlion.shadowui.resource.ResourceViewStore$Prepared);
public synchronized boolean transitioning();
public synchronized com.heartlion.shadowui.resource.ResourceViewStore$Lease acquire();
public synchronized boolean isCurrentRequest(long);
public synchronized long generation();
public synchronized boolean exclusive();
public synchronized java.lang.String identity();
public synchronized void close();
}
prepare
public synchronized Prepared prepare(long ticket, ShadowResourceProvider provider, String identity)
Ownership transfers to Prepared only when this method succeeds. Null represents the platform baseline.
commit
public synchronized boolean commit(Prepared prepared, Runnable install, Runnable rollback)
Installs dependent catalogs against the candidate view and restores the previous view on failure. Callbacks may acquire leases, but must not recursively change or close the store. Rollback observes the restored source; both source providers stay owned until callbacks finish.
beginTransition
public synchronized Transition beginTransition(Prepared prepared)
Temporarily exposes a candidate while a platform performs an asynchronous native reload. A newer beginChange invalidates completion; rollback restores the pinned old view. Only one transition may be in flight. Preparation and leases remain available.
ResourceViewStore.Transition
com.heartlion.shadowui.resource.ResourceViewStore.Transition
public final class com.heartlion.shadowui.resource.ResourceViewStore$Transition implements java.lang.AutoCloseable {
public boolean complete();
public void close();
}
complete
public boolean complete()
False means a newer request or close retired this transition; the previous view is restored.
close
public void close()
Restores source visibility before the caller reloads dependent native catalogs.
ResourceViewStore.Prepared
com.heartlion.shadowui.resource.ResourceViewStore.Prepared
public final class com.heartlion.shadowui.resource.ResourceViewStore$Prepared implements java.lang.AutoCloseable {
public com.heartlion.shadowui.resource.ResourceViewStore$Lease acquire();
public void close();
}
ResourceViewStore.Lease
com.heartlion.shadowui.resource.ResourceViewStore.Lease
Each lease serializes its own operations/close. No fallback source is consulted on misses or errors.
public final class com.heartlion.shadowui.resource.ResourceViewStore$Lease implements com.heartlion.shadowui.resource.ShadowResourceProvider {
public long generation();
public boolean exclusive();
public java.lang.String identity();
public synchronized boolean exists(java.lang.String);
public synchronized java.io.InputStream open(java.lang.String) throws java.lang.Exception;
public synchronized java.util.List<java.lang.String> list(java.lang.String, java.lang.String);
public synchronized com.heartlion.shadowui.resource.ShadowResourceMetadata metadata(java.lang.String) throws java.lang.Exception;
public synchronized void close();
}
ShadowCacheResourceProvider
com.heartlion.shadowui.resource.ShadowCacheResourceProvider
public class com.heartlion.shadowui.resource.ShadowCacheResourceProvider implements com.heartlion.shadowui.resource.ShadowResourceProvider {
public com.heartlion.shadowui.resource.ShadowCacheResourceProvider(java.io.File);
public static void createDefaultDirectories(java.io.File);
public boolean exists(java.lang.String);
public java.io.InputStream open(java.lang.String) throws java.lang.Exception;
public com.heartlion.shadowui.resource.ShadowResourceMetadata metadata(java.lang.String) throws java.lang.Exception;
public java.util.List<java.lang.String> list(java.lang.String, java.lang.String);
public void close();
}
ShadowPackCrypto
com.heartlion.shadowui.resource.ShadowPackCrypto
Shared SPK2 format primitives. The same source is used by the packer and client.
public final class com.heartlion.shadowui.resource.ShadowPackCrypto {
public static final byte[] MAGIC;
public static final int VERSION;
public static final int HEADER_BYTES;
public static final int SALT_BYTES;
public static final int NONCE_BYTES;
public static final int TAG_BYTES;
public static final int KEY_BYTES;
public static final int KDF_ITERATIONS;
public static final int MAX_PATH_BYTES;
public static final int MAX_INDEX_BYTES;
public static final int MAX_ENTRIES;
public static final long MAX_ENTRY_BYTES;
public static byte[] randomBytes(int);
public static byte[] deterministicDigest(java.lang.String, byte[]...);
public static byte[] deterministicSalt(java.lang.String, char[], byte[]);
public static byte[] deterministicNonce(java.lang.String, byte[]...);
public static java.lang.String normalizePath(java.lang.String);
public static byte[] packToken(java.lang.String);
public static java.lang.String archiveFileName(java.lang.String);
public static byte[] entryToken(java.lang.String);
public static byte[] headerMac(byte[], byte[], long, int, byte[]);
public static byte[] deriveKey(char[], byte[]) throws java.security.GeneralSecurityException;
public static byte[] encrypt(byte[], byte[], byte[], byte[]) throws java.security.GeneralSecurityException;
public static byte[] decrypt(byte[], byte[], byte[], byte[]) throws java.security.GeneralSecurityException;
public static byte[] sha256(byte[]);
public static java.lang.String hex(byte[]);
public static boolean constantTimeEquals(byte[], byte[]);
public static byte[] hmac(java.lang.String);
public static byte[] hmac(byte[]);
public static java.lang.String[] wrapPassword(java.lang.String, java.lang.String, java.lang.String, java.lang.String) throws java.security.GeneralSecurityException;
public static java.lang.String unwrapPassword(java.lang.String, java.lang.String, java.lang.String, java.lang.String, java.lang.String) throws java.security.GeneralSecurityException;
public static byte[] aadForEntry(byte[], long, byte[]);
public static byte[] aadForIndex(byte[]);
public static java.lang.String requireServerId(java.lang.String);
}
deterministicDigest
public static byte[] deterministicDigest(String domain, byte[]... parts)
Derives stable, domain-separated bytes for pack metadata and nonces.
<p>SPK2 archive digests are part of the server activation contract, so the packer must not let SecureRandom change the archive every time the same ShadowCache is packaged. The caller supplies a canonical manifest digest and the resulting bytes are still distinct for each domain and input tuple. This does not make the archive a secrecy boundary; it only makes the authenticated representation reproducible.</p>
deterministicSalt
public static byte[] deterministicSalt(String serverId, char[] password, byte[] manifestDigest)
Returns the deterministic 16-byte SPK2 salt for one source manifest.
deterministicNonce
public static byte[] deterministicNonce(String domain, byte[]... parts)
Returns a deterministic 12-byte AES-GCM nonce for the supplied context.
ShadowPackWriter
com.heartlion.shadowui.resource.ShadowPackWriter
Client-side SPK2 packer for the local ShadowCache resource tree.
public final class com.heartlion.shadowui.resource.ShadowPackWriter {
public static final java.lang.String PHASE_SCANNING;
public static final java.lang.String PHASE_PACKING;
public static final java.lang.String PHASE_FINALIZING;
public static final java.lang.String PHASE_HASHING;
public static final java.lang.String PHASE_COMPLETE;
public static com.heartlion.shadowui.resource.ShadowPackWriter$PackResult pack(java.io.File, java.io.File, java.lang.String, char[]) throws java.lang.Exception;
public static com.heartlion.shadowui.resource.ShadowPackWriter$PackResult pack(java.io.File, java.io.File, java.lang.String, char[], com.heartlion.shadowui.resource.ShadowPackWriter$ProgressListener) throws java.lang.Exception;
public static com.heartlion.shadowui.resource.ShadowPackWriter$SimplePackResult packSimple(java.io.File, java.io.File) throws java.lang.Exception;
public static com.heartlion.shadowui.resource.ShadowPackWriter$SimplePackResult packSimple(java.io.File, java.io.File, com.heartlion.shadowui.resource.ShadowPackWriter$ProgressListener) throws java.lang.Exception;
}
packSimple
public static SimplePackResult packSimple(File sourceRoot, File resourcePacksDir) throws Exception
Packages an SPS1 client-local archive without server identity or password.
ShadowPackWriter.ProgressListener
com.heartlion.shadowui.resource.ShadowPackWriter.ProgressListener
声明注解:@FunctionalInterface。
public interface com.heartlion.shadowui.resource.ShadowPackWriter$ProgressListener {
public abstract void onProgress(java.lang.String, int, int);
}
ShadowPackWriter.PackResult
com.heartlion.shadowui.resource.ShadowPackWriter.PackResult
public final class com.heartlion.shadowui.resource.ShadowPackWriter$PackResult {
public final java.lang.String serverId;
public final java.io.File file;
public final int entries;
public final long size;
public final java.lang.String sha256;
}
ShadowPackWriter.SimplePackResult
com.heartlion.shadowui.resource.ShadowPackWriter.SimplePackResult
public final class com.heartlion.shadowui.resource.ShadowPackWriter$SimplePackResult {
public final java.io.File file;
public final int entries;
public final long size;
public final java.lang.String sha256;
}
ShadowResourceMetadata
com.heartlion.shadowui.resource.ShadowResourceMetadata
Immutable provider result used to keep resource identity beside an opened stream.
public final class com.heartlion.shadowui.resource.ShadowResourceMetadata {
public final java.lang.String canonicalPath;
public final java.lang.String contentSha256;
public final long length;
public com.heartlion.shadowui.resource.ShadowResourceMetadata(java.lang.String, java.lang.String, long);
}
ShadowResourceProvider
com.heartlion.shadowui.resource.ShadowResourceProvider
public interface com.heartlion.shadowui.resource.ShadowResourceProvider extends java.io.Closeable {
public abstract boolean exists(java.lang.String);
public abstract java.io.InputStream open(java.lang.String) throws java.lang.Exception;
public abstract java.util.List<java.lang.String> list(java.lang.String, java.lang.String);
public default com.heartlion.shadowui.resource.ShadowResourceMetadata metadata(java.lang.String) throws java.lang.Exception;
}
metadata
public default ShadowResourceMetadata metadata(String path) throws Exception
Metadata for the same lookup semantics used by {@link #open(String)}.
SimpleEncryptedResourceProvider
com.heartlion.shadowui.resource.SimpleEncryptedResourceProvider
Reads an SPS1 client-only authenticated resource container.
public class com.heartlion.shadowui.resource.SimpleEncryptedResourceProvider implements com.heartlion.shadowui.resource.ShadowResourceProvider {
public com.heartlion.shadowui.resource.SimpleEncryptedResourceProvider(java.io.File) throws java.lang.Exception;
public static boolean hasSimpleMagic(java.io.File);
public synchronized boolean exists(java.lang.String);
public synchronized java.io.InputStream open(java.lang.String) throws java.lang.Exception;
public synchronized com.heartlion.shadowui.resource.ShadowResourceMetadata metadata(java.lang.String);
public synchronized java.util.List<java.lang.String> list(java.lang.String, java.lang.String);
public synchronized int getEntryCount();
public synchronized long getOpenCount();
public synchronized void close();
}
SimplePackCrypto
com.heartlion.shadowui.resource.SimplePackCrypto
Client-only SPS1 resource-pack primitives.
public final class com.heartlion.shadowui.resource.SimplePackCrypto {
public static final byte[] MAGIC;
public static final int VERSION;
public static final int HEADER_BYTES;
public static java.lang.String archiveFileName();
public static byte[] key();
public static byte[] entryToken(java.lang.String);
public static byte[] aadForEntry(byte[], long, byte[]);
public static byte[] aadForIndex(long, int);
public static byte[] encrypt(byte[], byte[], byte[], byte[]) throws java.security.GeneralSecurityException;
public static byte[] decrypt(byte[], byte[], byte[], byte[]) throws java.security.GeneralSecurityException;
}
VerifiedHttpDownload
com.heartlion.shadowui.resource.VerifiedHttpDownload
Bounded HTTP fetch shared by platform adapters. A failed/retired fetch never replaces its target.
public final class com.heartlion.shadowui.resource.VerifiedHttpDownload {
public com.heartlion.shadowui.resource.VerifiedHttpDownload(java.io.File, com.heartlion.shadowui.resource.VerifiedHttpDownload$Policy) throws java.io.IOException;
public void validate(java.net.URL) throws java.lang.Exception;
public void download(java.lang.String, java.lang.String, long, java.io.File, java.util.function.BooleanSupplier) throws java.lang.Exception;
public boolean matches(java.io.File, java.lang.String, long) throws java.lang.Exception;
}
VerifiedHttpDownload.Policy
com.heartlion.shadowui.resource.VerifiedHttpDownload.Policy
public final class com.heartlion.shadowui.resource.VerifiedHttpDownload$Policy {
public final long maxFileBytes;
public final int connectTimeoutMs;
public final int readTimeoutMs;
public final boolean allowHttp;
public final boolean allowPrivateHosts;
public com.heartlion.shadowui.resource.VerifiedHttpDownload$Policy(long, int, int, boolean, boolean);
}
VerifiedResourceArchive
com.heartlion.shadowui.resource.VerifiedResourceArchive
Verifies the caller's expected archive identity before handing ownership of an authenticated reader to it.
public final class com.heartlion.shadowui.resource.VerifiedResourceArchive {
public static com.heartlion.shadowui.resource.EncryptedZipResourceProvider openSpk2(java.io.File, java.lang.String, char[], java.lang.String, long) throws java.lang.Exception;
public static void verifyIdentity(java.io.File, java.lang.String, long) throws java.lang.Exception;
}
VerifiedResourceCache
com.heartlion.shadowui.resource.VerifiedResourceCache
Content-addressed byte cache. Fetching a new version never writes a previous version's path.
public final class com.heartlion.shadowui.resource.VerifiedResourceCache {
public com.heartlion.shadowui.resource.VerifiedResourceCache(java.io.File, com.heartlion.shadowui.resource.VerifiedHttpDownload$Policy, long) throws java.io.IOException;
public synchronized com.heartlion.shadowui.resource.VerifiedResourceCache$Result fetch(java.lang.String, java.lang.String, long, java.util.function.BooleanSupplier) throws java.lang.Exception;
}
fetch
public synchronized Result fetch(String url, String sha256, long size, BooleanSupplier current) throws Exception
One coordinator per cache root. Cache cleanup must not delete blobs held by an active platform view.
VerifiedResourceCache.Result
com.heartlion.shadowui.resource.VerifiedResourceCache.Result
public final class com.heartlion.shadowui.resource.VerifiedResourceCache$Result {
public final java.io.File file;
public final boolean cached;
}