Add PlatformHooks
This commit is contained in:
@@ -0,0 +1,10 @@
|
||||
package ca.spottedleaf.moonrise.fabric;
|
||||
|
||||
import ca.spottedleaf.moonrise.common.PlatformHooks;
|
||||
|
||||
public final class FabricHooks implements PlatformHooks {
|
||||
@Override
|
||||
public void doSomePlatformAction() {
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
ca.spottedleaf.moonrise.fabric.FabricHooks
|
||||
@@ -0,0 +1,10 @@
|
||||
package ca.spottedleaf.moonrise.neoforge;
|
||||
|
||||
import ca.spottedleaf.moonrise.common.PlatformHooks;
|
||||
|
||||
public final class NeoForgeHooks implements PlatformHooks {
|
||||
@Override
|
||||
public void doSomePlatformAction() {
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
ca.spottedleaf.moonrise.neoforge.NeoForgeHooks
|
||||
@@ -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"));
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user