Remove dependencies on ClientApi.LOGGER
each class should have it's own logger instead
This commit is contained in:
@@ -7,15 +7,12 @@ import com.seibel.lod.core.a7.world.DhWorld;
|
||||
import com.seibel.lod.core.wrapperInterfaces.minecraft.IMinecraftSharedWrapper;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
||||
public class SharedApi {
|
||||
public static final Logger LOGGER = DhLoggerBuilder.getLogger("DH Events");
|
||||
public class SharedApi
|
||||
{
|
||||
public static IMinecraftSharedWrapper MC;
|
||||
public static DhWorld currentWorld;
|
||||
public static WorldEnvironment getEnvironment() {
|
||||
return currentWorld==null ? null : currentWorld.environment;
|
||||
}
|
||||
public static WorldEnvironment getEnvironment() { return currentWorld==null ? null : currentWorld.environment; }
|
||||
|
||||
public static void init() {
|
||||
Initializer.init();
|
||||
}
|
||||
public static void init() { Initializer.init(); }
|
||||
|
||||
}
|
||||
|
||||
@@ -1,10 +1,11 @@
|
||||
package com.seibel.lod.core.config;
|
||||
|
||||
import com.seibel.lod.core.api.internal.a7.ClientApi;
|
||||
import com.seibel.lod.core.config.file.ConfigFileHandling;
|
||||
import com.seibel.lod.core.config.types.AbstractConfigType;
|
||||
import com.seibel.lod.core.config.types.ConfigCategory;
|
||||
import com.seibel.lod.core.config.types.ConfigEntry;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.ArrayList;
|
||||
@@ -18,7 +19,10 @@ import java.util.Map;
|
||||
* @author Ran
|
||||
*/
|
||||
// Init the config after singletons have been blinded
|
||||
public class ConfigBase {
|
||||
public class ConfigBase
|
||||
{
|
||||
public static final Logger LOGGER = LogManager.getLogger(ConfigBase.class.getSimpleName());
|
||||
|
||||
/*
|
||||
What the config works with
|
||||
|
||||
@@ -76,8 +80,8 @@ public class ConfigBase {
|
||||
|
||||
if (ConfigEntry.class.isAssignableFrom(field.getType())) { // If item is type ConfigEntry
|
||||
if (!isAcceptableType(((ConfigEntry<?>) entry).get().getClass())) {
|
||||
ClientApi.LOGGER.error("Invalid variable type at [" + (category.isEmpty() ? "" : category + ".") + field.getName() + "].");
|
||||
ClientApi.LOGGER.error("Type [" + ((ConfigEntry<?>) entry).get().getClass() + "] is not one of these types [" + acceptableInputs.toString() + "]");
|
||||
LOGGER.error("Invalid variable type at [" + (category.isEmpty() ? "" : category + ".") + field.getName() + "].");
|
||||
LOGGER.error("Type [" + ((ConfigEntry<?>) entry).get().getClass() + "] is not one of these types [" + acceptableInputs.toString() + "]");
|
||||
entries.remove(entries.size() -1); // Delete the entry if it is invalid so the game can still run
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,13 +2,14 @@ package com.seibel.lod.core.config.file;
|
||||
|
||||
import com.electronwill.nightconfig.core.file.CommentedFileConfig;
|
||||
import com.seibel.lod.core.ModInfo;
|
||||
import com.seibel.lod.core.api.internal.a7.ClientApi;
|
||||
import com.seibel.lod.core.config.ConfigBase;
|
||||
import com.seibel.lod.core.config.types.AbstractConfigType;
|
||||
import com.seibel.lod.core.config.types.ConfigEntry;
|
||||
import com.seibel.lod.core.handlers.dependencyInjection.SingletonInjector;
|
||||
import com.seibel.lod.core.wrapperInterfaces.minecraft.IMinecraftClientWrapper;
|
||||
import com.seibel.lod.core.wrapperInterfaces.minecraft.IMinecraftSharedWrapper;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.json.simple.JSONObject;
|
||||
import org.json.simple.parser.JSONParser;
|
||||
import org.json.simple.parser.ParseException;
|
||||
@@ -23,8 +24,11 @@ import java.nio.file.Path;
|
||||
* @author coolGi
|
||||
* @version 2022-5-26
|
||||
*/
|
||||
public class ConfigFileHandling {
|
||||
public static final Path ConfigPath = SingletonInjector.INSTANCE.get(IMinecraftSharedWrapper.class)
|
||||
public class ConfigFileHandling
|
||||
{
|
||||
public static final Logger LOGGER = LogManager.getLogger(ConfigBase.class.getSimpleName());
|
||||
|
||||
public static final Path ConfigPath = SingletonInjector.INSTANCE.get(IMinecraftSharedWrapper.class)
|
||||
.getInstallationDirectory().toPath().resolve("config").resolve(ModInfo.NAME+".toml");
|
||||
|
||||
/** Saves the config to the file */
|
||||
@@ -128,13 +132,13 @@ public class ConfigFileHandling {
|
||||
else if (entry.isValid() == -1) entry.setWithoutSaving(entry.getMin());
|
||||
else if (entry.isValid() == 1) entry.setWithoutSaving(entry.getMax());
|
||||
} else {
|
||||
ClientApi.LOGGER.warn("Entry ["+ entry.getNameWCategory() +"] is invalid. Expected " + entry.getType() + " but got " + workConfig.get(entry.getNameWCategory()).getClass() + ". Using default value.");
|
||||
LOGGER.warn("Entry ["+ entry.getNameWCategory() +"] is invalid. Expected " + entry.getType() + " but got " + workConfig.get(entry.getNameWCategory()).getClass() + ". Using default value.");
|
||||
saveEntry(entry, workConfig);
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
// e.printStackTrace();
|
||||
ClientApi.LOGGER.warn("Entry ["+entry.getNameWCategory()+"] had an invalid value when loading the config. Using default value.");
|
||||
LOGGER.warn("Entry ["+entry.getNameWCategory()+"] had an invalid value when loading the config. Using default value.");
|
||||
saveEntry(entry, workConfig);
|
||||
}
|
||||
} else {
|
||||
|
||||
-1
@@ -20,7 +20,6 @@
|
||||
package com.seibel.lod.core.handlers.dependencyInjection;
|
||||
|
||||
import com.seibel.lod.core.api.implementation.interfaces.events.IDhApiEvent;
|
||||
import com.seibel.lod.core.api.internal.a7.ClientApi;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
||||
|
||||
@@ -19,7 +19,6 @@
|
||||
|
||||
package com.seibel.lod.core.logging;
|
||||
|
||||
import com.seibel.lod.core.api.internal.a7.ClientApi;
|
||||
import com.seibel.lod.core.enums.config.ELoggerMode;
|
||||
import com.seibel.lod.core.handlers.dependencyInjection.SingletonInjector;
|
||||
import com.seibel.lod.core.wrapperInterfaces.minecraft.IMinecraftClientWrapper;
|
||||
|
||||
@@ -19,7 +19,6 @@
|
||||
|
||||
package com.seibel.lod.core.logging;
|
||||
|
||||
import com.seibel.lod.core.api.internal.a7.ClientApi;
|
||||
import com.seibel.lod.core.enums.config.ELoggerMode;
|
||||
import com.seibel.lod.core.handlers.dependencyInjection.SingletonInjector;
|
||||
import com.seibel.lod.core.wrapperInterfaces.minecraft.IMinecraftClientWrapper;
|
||||
|
||||
Reference in New Issue
Block a user