From 690dd319cbf615e9b1f948944e70a7173dace231 Mon Sep 17 00:00:00 2001 From: James Seibel Date: Thu, 15 Sep 2022 20:31:41 -0500 Subject: [PATCH] Set up the API config --- .../items/interfaces/config/IDhApiConfig.java | 56 ++++++------------- .../interfaces/config/IDhApiConfigValue.java | 51 +++++++++++++++++ ...DhApiConfig.java => DhApiConfigValue.java} | 8 +-- .../methods/events/DhApiEventRegister.java | 2 +- .../java/com/seibel/lod/core/Initializer.java | 25 ++++++++- .../methods/config/DhApiConfig.java | 39 +++++++++++++ 6 files changed, 134 insertions(+), 47 deletions(-) create mode 100644 api/src/main/java/com/seibel/lod/api/items/interfaces/config/IDhApiConfigValue.java rename api/src/main/java/com/seibel/lod/api/items/objects/config/{DhApiConfig.java => DhApiConfigValue.java} (88%) create mode 100644 core/src/main/java/com/seibel/lod/core/api/external/coreImplementations/methods/config/DhApiConfig.java diff --git a/api/src/main/java/com/seibel/lod/api/items/interfaces/config/IDhApiConfig.java b/api/src/main/java/com/seibel/lod/api/items/interfaces/config/IDhApiConfig.java index 345f2f0b5..dde857bc0 100644 --- a/api/src/main/java/com/seibel/lod/api/items/interfaces/config/IDhApiConfig.java +++ b/api/src/main/java/com/seibel/lod/api/items/interfaces/config/IDhApiConfig.java @@ -1,49 +1,25 @@ package com.seibel.lod.api.items.interfaces.config; +import com.seibel.lod.api.items.interfaces.config.both.IDhApiWorldGenerationConfig; +import com.seibel.lod.api.items.interfaces.config.client.IDhApiBuffersConfig; +import com.seibel.lod.api.items.interfaces.config.client.IDhApiGraphicsConfig; +import com.seibel.lod.api.items.interfaces.config.client.IDhApiMultiplayerConfig; +import com.seibel.lod.api.items.interfaces.config.client.IDhApiThreadingConfig; + /** - * An interface for Distant Horizon's Config. - * - * @param The internal data type of this config. + * This interfaces holds all of the config groups + * the API has access to for easy access to all config values. + * * @author James Seibel - * @version 2022-6-13 + * @version 9-15-2022 */ -public interface IDhApiConfig +public interface IDhApiConfig { - /** - * Returns the active value for this config.
- * Returns the True value if either the config cannot be overridden by - * the API or if it hasn't been set by the API. - */ - public T getValue(); - /** - * Returns the value held by this config.
- * This is the value stored in the config file. - */ - public T getTrueValue(); - /** - * Returns the value of the config if it was set by the API. - * Returns null if the config wasn't set by the API. - */ - public T getApiValue(); - /** - * Sets the config's value.
- * If the newValue is set to null then the config - * will revert to using the True Value.
- * If the config cannot be set via the API this method will return false. - * - * @return true if the value was set, false otherwise. - */ - public boolean setValue(T newValue); - - /** Returns true if this config can be set via the API, false otherwise. */ - public boolean getCanBeOverrodeByApi(); - - /** Returns the default value for this config. */ - public T getDefaultValue(); - /** Returns the max value for this config, null if there is no max. */ - public T getMaxValue(); - /** Returns the min value for this config, null if there is no min. */ - public T getMinValue(); + IDhApiWorldGenerationConfig getWorldGeneratorConfig(); + IDhApiBuffersConfig getBufferConfig(); + IDhApiGraphicsConfig getGraphicsConfig(); + IDhApiMultiplayerConfig getMultiplayerConfig(); + IDhApiThreadingConfig getThreadingConfig(); } diff --git a/api/src/main/java/com/seibel/lod/api/items/interfaces/config/IDhApiConfigValue.java b/api/src/main/java/com/seibel/lod/api/items/interfaces/config/IDhApiConfigValue.java new file mode 100644 index 000000000..7c28c19e5 --- /dev/null +++ b/api/src/main/java/com/seibel/lod/api/items/interfaces/config/IDhApiConfigValue.java @@ -0,0 +1,51 @@ +package com.seibel.lod.api.items.interfaces.config; + +/** + * An interface for Distant Horizon's Config. + * + * @param The data type of this config. + * + * @author James Seibel + * @version 2022-9-15 + */ +public interface IDhApiConfigValue +{ + + /** + * Returns the active value for this config.
+ * Returns the True value if either the config cannot be overridden by + * the API or if it hasn't been set by the API. + */ + public T getValue(); + /** + * Returns the value held by this config.
+ * This is the value stored in the config file. + */ + public T getTrueValue(); + /** + * Returns the value of the config if it was set by the API. + * Returns null if the config wasn't set by the API. + */ + public T getApiValue(); + + /** + * Sets the config's value.
+ * If the newValue is set to null then the config + * will revert to using the True Value.
+ * If the config cannot be set via the API this method will return false. + * + * @return true if the value was set, false otherwise. + */ + public boolean setValue(T newValue); + + /** Returns true if this config can be set via the API, false otherwise. */ + public boolean getCanBeOverrodeByApi(); + + /** Returns the default value for this config. */ + public T getDefaultValue(); + /** Returns the max value for this config, null if there is no max. */ + public T getMaxValue(); + /** Returns the min value for this config, null if there is no min. */ + public T getMinValue(); + +} diff --git a/api/src/main/java/com/seibel/lod/api/items/objects/config/DhApiConfig.java b/api/src/main/java/com/seibel/lod/api/items/objects/config/DhApiConfigValue.java similarity index 88% rename from api/src/main/java/com/seibel/lod/api/items/objects/config/DhApiConfig.java rename to api/src/main/java/com/seibel/lod/api/items/objects/config/DhApiConfigValue.java index 00ebf4b75..6229f8877 100644 --- a/api/src/main/java/com/seibel/lod/api/items/objects/config/DhApiConfig.java +++ b/api/src/main/java/com/seibel/lod/api/items/objects/config/DhApiConfigValue.java @@ -1,6 +1,6 @@ package com.seibel.lod.api.items.objects.config; -import com.seibel.lod.api.items.interfaces.config.IDhApiConfig; +import com.seibel.lod.api.items.interfaces.config.IDhApiConfigValue; import com.seibel.lod.core.interfaces.config.IConfigEntry; import com.seibel.lod.core.interfaces.config.IConverter; import com.seibel.lod.core.interfaces.config.converters.DefaultConverter; @@ -18,7 +18,7 @@ import com.seibel.lod.core.interfaces.config.converters.DefaultConverter; * @author James Seibel * @version 2022-6-30 */ -public class DhApiConfig implements IDhApiConfig +public class DhApiConfigValue implements IDhApiConfigValue { private final IConfigEntry configEntry; @@ -32,7 +32,7 @@ public class DhApiConfig implements IDhApiConfig * Uses the default object converter, this requires coreType and apiType to be the same. */ @SuppressWarnings("unchecked") // DefaultConverter's cast is safe - public DhApiConfig(IConfigEntry newConfigEntry) + public DhApiConfigValue(IConfigEntry newConfigEntry) { this.configEntry = newConfigEntry; this.configConverter = (IConverter) new DefaultConverter(); @@ -42,7 +42,7 @@ public class DhApiConfig implements IDhApiConfig * This constructor should only be called internally.
* There is no reason for API users to create this object.

*/ - public DhApiConfig(IConfigEntry newConfigEntry, IConverter newConverter) + public DhApiConfigValue(IConfigEntry newConfigEntry, IConverter newConverter) { this.configEntry = newConfigEntry; this.configConverter = newConverter; diff --git a/api/src/main/java/com/seibel/lod/api/methods/events/DhApiEventRegister.java b/api/src/main/java/com/seibel/lod/api/methods/events/DhApiEventRegister.java index c63917066..3443687e2 100644 --- a/api/src/main/java/com/seibel/lod/api/methods/events/DhApiEventRegister.java +++ b/api/src/main/java/com/seibel/lod/api/methods/events/DhApiEventRegister.java @@ -13,7 +13,7 @@ import com.seibel.lod.core.interfaces.dependencyInjection.IDhApiEventInjector; */ public class DhApiEventRegister { - private static final IDhApiEventInjector EVENT_INJECTOR = ApiCoreInjectors.getInstance().eventInjector; + private static final IDhApiEventInjector EVENT_INJECTOR = ApiCoreInjectors.getInstance().events; /** * Registers the given event handler.
diff --git a/core/src/main/java/com/seibel/lod/core/Initializer.java b/core/src/main/java/com/seibel/lod/core/Initializer.java index af8b4084c..a9ba3a0a8 100644 --- a/core/src/main/java/com/seibel/lod/core/Initializer.java +++ b/core/src/main/java/com/seibel/lod/core/Initializer.java @@ -1,13 +1,34 @@ package com.seibel.lod.core; +import com.seibel.lod.api.items.interfaces.config.IDhApiConfigGroup; +import com.seibel.lod.api.items.interfaces.config.both.IDhApiWorldGenerationConfig; +import com.seibel.lod.api.items.interfaces.config.client.*; +import com.seibel.lod.core.api.external.coreImplementations.methods.config.DhApiConfig; +import com.seibel.lod.core.api.external.coreImplementations.methods.config.both.DhApiWorldGenerationConfig; +import com.seibel.lod.core.api.external.coreImplementations.methods.config.client.*; import com.seibel.lod.core.datatype.column.ColumnRenderLoader; import com.seibel.lod.core.datatype.full.FullDataLoader; import com.seibel.lod.core.datatype.full.SparseDataLoader; +import com.seibel.lod.core.interfaces.dependencyInjection.ApiCoreInjectors; +import com.seibel.lod.core.interfaces.dependencyInjection.IDependencyInjector; -public class Initializer { - public static void init() { +/** + * Handles first time Core setup. + * + * @author Leetom + * @version 2022-9-15 + */ +public class Initializer +{ + public static void init() + { ColumnRenderLoader unused = new ColumnRenderLoader(); // Auto register into the loader system FullDataLoader unused2 = new FullDataLoader(); // Auto register into the loader system SparseDataLoader unused3 = new SparseDataLoader(); // Auto register + + + // link Core's config to the API + ApiCoreInjectors.getInstance().configs = DhApiConfig.INSTANCE; + } } diff --git a/core/src/main/java/com/seibel/lod/core/api/external/coreImplementations/methods/config/DhApiConfig.java b/core/src/main/java/com/seibel/lod/core/api/external/coreImplementations/methods/config/DhApiConfig.java new file mode 100644 index 000000000..3bf1580bd --- /dev/null +++ b/core/src/main/java/com/seibel/lod/core/api/external/coreImplementations/methods/config/DhApiConfig.java @@ -0,0 +1,39 @@ +package com.seibel.lod.core.api.external.coreImplementations.methods.config; + +import com.seibel.lod.api.items.interfaces.config.IDhApiConfig; +import com.seibel.lod.api.items.interfaces.config.both.IDhApiWorldGenerationConfig; +import com.seibel.lod.api.items.interfaces.config.client.IDhApiBuffersConfig; +import com.seibel.lod.api.items.interfaces.config.client.IDhApiGraphicsConfig; +import com.seibel.lod.api.items.interfaces.config.client.IDhApiMultiplayerConfig; +import com.seibel.lod.api.items.interfaces.config.client.IDhApiThreadingConfig; +import com.seibel.lod.core.api.external.coreImplementations.methods.config.both.DhApiWorldGenerationConfig; +import com.seibel.lod.core.api.external.coreImplementations.methods.config.client.DhApiBuffersConfig; +import com.seibel.lod.core.api.external.coreImplementations.methods.config.client.DhApiGraphicsConfig; +import com.seibel.lod.core.api.external.coreImplementations.methods.config.client.DhApiMultiplayerConfig; +import com.seibel.lod.core.api.external.coreImplementations.methods.config.client.DhApiThreadingConfig; + +/** + * A singleton that holds all of the config groups for the API. + * + * @author James Seibel + * @version 9-15-2022 + */ +public class DhApiConfig implements IDhApiConfig +{ + public static final DhApiConfig INSTANCE = new DhApiConfig(); + + private DhApiConfig() { } + + + @Override + public IDhApiWorldGenerationConfig getWorldGeneratorConfig() { return DhApiWorldGenerationConfig.INSTANCE; } + @Override + public IDhApiBuffersConfig getBufferConfig() { return DhApiBuffersConfig.INSTANCE; } + @Override + public IDhApiGraphicsConfig getGraphicsConfig() { return DhApiGraphicsConfig.INSTANCE; } + @Override + public IDhApiMultiplayerConfig getMultiplayerConfig() { return DhApiMultiplayerConfig.INSTANCE; } + @Override + public IDhApiThreadingConfig getThreadingConfig() { return DhApiThreadingConfig.INSTANCE; } + +}