mirror of
https://github.com/GTNewHorizons/WirelessCraftingTerminal.git
synced 2026-11-26 06:42:55 +00:00
57 lines
1.8 KiB
Java
57 lines
1.8 KiB
Java
package net.p455w0rd.wirelesscraftingterminal.implementation;
|
|
|
|
import net.p455w0rd.wirelesscraftingterminal.api.IWCTInteractionHelper;
|
|
import net.p455w0rd.wirelesscraftingterminal.api.IWCTItems;
|
|
import net.p455w0rd.wirelesscraftingterminal.api.WCTApi;
|
|
import net.p455w0rd.wirelesscraftingterminal.common.WirelessCraftingTerminal;
|
|
import net.p455w0rd.wirelesscraftingterminal.common.utils.WCTLog;
|
|
|
|
import cpw.mods.fml.common.LoaderState;
|
|
|
|
public class WCTAPIImplementation extends WCTApi {
|
|
|
|
private final WCTItems items;
|
|
private final WCTInteractionHelper interactionHelper;
|
|
|
|
private static WCTAPIImplementation INSTANCE = null;
|
|
|
|
private WCTAPIImplementation() {
|
|
this.items = new WCTItems();
|
|
this.interactionHelper = new WCTInteractionHelper();
|
|
}
|
|
|
|
public static WCTAPIImplementation instance() {
|
|
// Has the singleton been created?
|
|
if (WCTAPIImplementation.INSTANCE == null) {
|
|
// Ensure that preinit has finished.
|
|
if (!WCTAPIImplementation.hasFinishedPreInit()) {
|
|
return null;
|
|
}
|
|
// Create the singleton.
|
|
WCTAPIImplementation.INSTANCE = new WCTAPIImplementation();
|
|
}
|
|
return WCTAPIImplementation.INSTANCE;
|
|
}
|
|
|
|
protected static boolean hasFinishedPreInit() {
|
|
// Ensure that ThE has finished the PreInit phase
|
|
if (WirelessCraftingTerminal.getLoaderState() == LoaderState.NOINIT) {
|
|
// Invalid state, API can not yet load.
|
|
WCTLog.warning("API is not available until WCT finishes the PreInit phase.");
|
|
return false;
|
|
}
|
|
|
|
return true;
|
|
}
|
|
|
|
@Override
|
|
public IWCTInteractionHelper interact() {
|
|
return this.interactionHelper;
|
|
}
|
|
|
|
@Override
|
|
public IWCTItems items() {
|
|
return this.items;
|
|
}
|
|
}
|