You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
77 lines
1.3 KiB
77 lines
1.3 KiB
10 years ago
|
package mightypork.gamecore.core.config;
|
||
10 years ago
|
|
||
|
|
||
10 years ago
|
import mightypork.gamecore.core.InitTask;
|
||
10 years ago
|
import mightypork.utils.annotations.Stub;
|
||
|
import mightypork.utils.exceptions.IllegalValueException;
|
||
|
|
||
|
|
||
|
/**
|
||
|
* Initialize config. To apply this initializer, you must extend it. That
|
||
|
* ensures that the workdir initializer has already finished when the code is
|
||
|
* executed (such as resolving a file path for the config file).
|
||
|
*
|
||
|
* @author Ondřej Hruška (MightyPork)
|
||
|
*/
|
||
|
public abstract class InitTaskConfig extends InitTask {
|
||
|
|
||
|
/**
|
||
|
* Add a config with given alias
|
||
|
*
|
||
|
* @param alias config alias
|
||
|
* @param config config to add
|
||
|
*/
|
||
|
protected void addConfig(String alias, Config config)
|
||
|
{
|
||
10 years ago
|
Config.register(alias, config);
|
||
10 years ago
|
}
|
||
|
|
||
|
|
||
|
/**
|
||
|
* Initialize the main config.
|
||
|
*
|
||
|
* @return the main config.
|
||
|
*/
|
||
|
protected abstract Config buildConfig();
|
||
|
|
||
|
|
||
|
/**
|
||
|
* Initialize extra configs.<br>
|
||
|
* the addConfig() method can be used to register configs.
|
||
|
*/
|
||
|
@Stub
|
||
|
protected void buildExtraConfigs()
|
||
|
{
|
||
|
}
|
||
|
|
||
|
|
||
10 years ago
|
// locked to encourage the use of the build* methods.
|
||
10 years ago
|
@Override
|
||
|
public final void init()
|
||
|
{
|
||
|
}
|
||
|
|
||
|
|
||
|
@Override
|
||
|
public final void run()
|
||
|
{
|
||
|
addConfig("main", buildConfig());
|
||
|
buildExtraConfigs();
|
||
|
}
|
||
|
|
||
|
|
||
|
@Override
|
||
|
public String getName()
|
||
|
{
|
||
|
return "config";
|
||
|
}
|
||
|
|
||
|
|
||
|
@Override
|
||
|
public String[] getDependencies()
|
||
|
{
|
||
|
return new String[] { "workdir" };
|
||
|
}
|
||
|
|
||
|
}
|