Set up the API config
This commit is contained in:
@@ -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 <T> 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<T>
|
||||
public interface IDhApiConfig
|
||||
{
|
||||
/**
|
||||
* Returns the active value for this config. <br>
|
||||
* 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. <br>
|
||||
* 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. <br>
|
||||
* If the newValue is set to null then the config
|
||||
* will revert to using the True Value.<br>
|
||||
* 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();
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,51 @@
|
||||
package com.seibel.lod.api.items.interfaces.config;
|
||||
|
||||
/**
|
||||
* An interface for Distant Horizon's Config.
|
||||
*
|
||||
* @param <T> The data type of this config.
|
||||
*
|
||||
* @author James Seibel
|
||||
* @version 2022-9-15
|
||||
*/
|
||||
public interface IDhApiConfigValue<T>
|
||||
{
|
||||
|
||||
/**
|
||||
* Returns the active value for this config. <br>
|
||||
* 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. <br>
|
||||
* 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. <br>
|
||||
* If the newValue is set to null then the config
|
||||
* will revert to using the True Value.<br>
|
||||
* 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();
|
||||
|
||||
}
|
||||
+4
-4
@@ -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<coreType, apiType> implements IDhApiConfig<apiType>
|
||||
public class DhApiConfigValue<coreType, apiType> implements IDhApiConfigValue<apiType>
|
||||
{
|
||||
private final IConfigEntry<coreType> configEntry;
|
||||
|
||||
@@ -32,7 +32,7 @@ public class DhApiConfig<coreType, apiType> implements IDhApiConfig<apiType>
|
||||
* Uses the default object converter, this requires coreType and apiType to be the same.
|
||||
*/
|
||||
@SuppressWarnings("unchecked") // DefaultConverter's cast is safe
|
||||
public DhApiConfig(IConfigEntry<coreType> newConfigEntry)
|
||||
public DhApiConfigValue(IConfigEntry<coreType> newConfigEntry)
|
||||
{
|
||||
this.configEntry = newConfigEntry;
|
||||
this.configConverter = (IConverter<coreType, apiType>) new DefaultConverter<coreType>();
|
||||
@@ -42,7 +42,7 @@ public class DhApiConfig<coreType, apiType> implements IDhApiConfig<apiType>
|
||||
* This constructor should only be called internally. <br>
|
||||
* There is no reason for API users to create this object. <br><br>
|
||||
*/
|
||||
public DhApiConfig(IConfigEntry<coreType> newConfigEntry, IConverter<coreType, apiType> newConverter)
|
||||
public DhApiConfigValue(IConfigEntry<coreType> newConfigEntry, IConverter<coreType, apiType> newConverter)
|
||||
{
|
||||
this.configEntry = newConfigEntry;
|
||||
this.configConverter = newConverter;
|
||||
@@ -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. <Br>
|
||||
|
||||
Reference in New Issue
Block a user