mirror of
https://github.com/PolyhedralDev/Terra.git
synced 2026-06-17 22:31:52 +00:00
move platform addon registration
This commit is contained in:
@@ -54,18 +54,13 @@ public abstract class AbstractTerraPlugin implements TerraPlugin {
|
|||||||
|
|
||||||
private final CommandManager manager = new TerraCommandManager(this);
|
private final CommandManager manager = new TerraCommandManager(this);
|
||||||
|
|
||||||
private final AddonRegistry addonRegistry;
|
private final AddonRegistry addonRegistry = new AddonRegistry(this);
|
||||||
|
|
||||||
private final Logger logger;
|
private final Lazy<Logger> logger = Lazy.lazy(() -> createLogger());
|
||||||
|
|
||||||
private static final MutableBoolean LOADED = new MutableBoolean(false);
|
private static final MutableBoolean LOADED = new MutableBoolean(false);
|
||||||
|
|
||||||
|
|
||||||
public AbstractTerraPlugin() {
|
|
||||||
this.logger = createLogger();
|
|
||||||
addonRegistry = getPlatformAddon().map(terraAddon -> new AddonRegistry(terraAddon, this)).orElseGet(() -> new AddonRegistry(this));
|
|
||||||
}
|
|
||||||
|
|
||||||
protected void load() {
|
protected void load() {
|
||||||
if(LOADED.get()) {
|
if(LOADED.get()) {
|
||||||
throw new IllegalStateException("Someone tried to initialize Terra, but Terra has already initialized. This is most likely due to a broken platform implementation, or a misbehaving mod.");
|
throw new IllegalStateException("Someone tried to initialize Terra, but Terra has already initialized. This is most likely due to a broken platform implementation, or a misbehaving mod.");
|
||||||
@@ -74,6 +69,8 @@ public abstract class AbstractTerraPlugin implements TerraPlugin {
|
|||||||
|
|
||||||
logger().info("Initializing Terra...");
|
logger().info("Initializing Terra...");
|
||||||
|
|
||||||
|
getPlatformAddon().ifPresent(addonRegistry::register);
|
||||||
|
|
||||||
try(InputStream stream = getClass().getResourceAsStream("/config.yml")) {
|
try(InputStream stream = getClass().getResourceAsStream("/config.yml")) {
|
||||||
File configFile = new File(getDataFolder(), "config.yml");
|
File configFile = new File(getDataFolder(), "config.yml");
|
||||||
if(!configFile.exists()) {
|
if(!configFile.exists()) {
|
||||||
@@ -166,6 +163,6 @@ public abstract class AbstractTerraPlugin implements TerraPlugin {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Logger logger() {
|
public Logger logger() {
|
||||||
return logger;
|
return logger.value();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user