Add PlatformHooks

This commit is contained in:
Jason Penilla
2024-08-04 20:23:33 -07:00
parent c8d18ca479
commit d93cc978e3
5 changed files with 46 additions and 0 deletions

View File

@@ -0,0 +1,24 @@
package ca.spottedleaf.moonrise.common;
import java.util.ServiceLoader;
// TODO - placeholder for if we need platform-specific impls for logic that needs to be called from common
public interface PlatformHooks {
static PlatformHooks get() {
return Holder.INSTANCE;
}
void doSomePlatformAction();
final class Holder {
private Holder() {
}
private static final PlatformHooks INSTANCE;
static {
INSTANCE = ServiceLoader.load(PlatformHooks.class, PlatformHooks.class.getClassLoader()).findFirst()
.orElseThrow(() -> new RuntimeException("Failed to locate PlatformHooks"));
}
}
}