下面列出了怎么用net.minecraftforge.common.config.ConfigElement的API类实例代码及写法,或者点击链接到github查看源代码。
protected static IConfigElement createFeatureEntries(String modId) {
final AbstractFeatureManager manager = FeatureRegistry.instance.getManager(modId);
if (manager == null) return null;
final List<IConfigElement> categories = Lists.newArrayList();
for (String category : manager.getCategories()) {
List<IConfigElement> categoryEntries = Lists.newArrayList();
for (String feature : manager.getFeaturesInCategory(category)) {
final Property property = FeatureRegistry.instance.getProperty(modId, category, feature);
if (property != null) categoryEntries.add(new ConfigElement(property));
}
categories.add(new CategoryElement(category, "openmodslib.config.features." + category, categoryEntries));
}
return new CategoryElement("features", "openmodslib.config.features", categories);
}
private static IConfigElement createConfigEntries(String modId) {
final ModConfig config = ConfigProcessing.getConfig(modId);
if (config == null) return null;
final List<IConfigElement> categories = Lists.newArrayList();
for (String category : config.getCategories()) {
final List<IConfigElement> categoryEntries = Lists.newArrayList();
for (String value : config.getValues(category)) {
final ConfigPropertyMeta meta = config.getValue(category, value);
categoryEntries.add(new ConfigElement(meta.getProperty()));
}
categories.add(new CategoryElement(category, "openmodslib.config.category." + category, categoryEntries));
}
return new CategoryElement("config", "openmodslib.config.config", categories, EntryWithWarning.class);
}
public YouTubeConfigurationGui(GuiScreen parentScreen) {
super(
parentScreen,
new ConfigElement(
YouTubeConfiguration.getInstance()
.getConfig()
.getCategory(Configuration.CATEGORY_GENERAL))
.getChildElements(),
YouTubeChat.MODID,
false,
false,
"YouTube Chat");
}
public GuiConfigToroQuest(GuiScreen parent) {
super (parent, new ConfigElement(ConfigurationHandler.config.getCategory(Configuration.CATEGORY_CLIENT)).getChildElements(),
ToroQuest.MODID,
false,
false,
"ToroQuest");
titleLine2 = ConfigurationHandler.config.getConfigFile().getAbsolutePath();
}
@SuppressWarnings({ "rawtypes" })
private static List<IConfigElement> getElements() {
List<IConfigElement> list = new ArrayList<IConfigElement>();
for (String category : ConfigurationHandler.INSTANCE.usedCategories)
list.add(new ConfigElement(ConfigurationHandler.INSTANCE.configFile.getCategory(category)));
return list;
}
public ModGuiConfig (GuiScreen parentScreen)
{
super(parentScreen,
new ConfigElement(ConfigurationHandler.instance().getConfigurationCategory()).getChildElements(),
Reference.MOD_ID,
false,
false,
GuiConfig.getAbridgedConfigPath(ConfigurationHandler.instance().toString()));
}
@SuppressWarnings({ "rawtypes" })
private static List<IConfigElement> createConfigElements() {
ConfigCategory modules = OpenPeripheralIntegration.instance.config().getCategory(OpenPeripheralIntegration.CATEGORY_MODULES);
modules.setLanguageKey("openperipheralintegration.config.modules");
final ConfigElement modulesElement = new ConfigElement(modules);
return Lists.<IConfigElement> newArrayList(modulesElement);
}
private static List<IConfigElement> getConfigElements(GuiScreen parent) {
List<IConfigElement> list = new ArrayList<IConfigElement>();
String prefix = "neiintegration.config.";
for (Section configSection : Config.configSections) {
list.add(new ConfigElement<ConfigCategory>(Config.config.getCategory(configSection.toLowerCase()).setLanguageKey(prefix + configSection.id)));
}
return list;
}
private static List<IConfigElement> getConfigElements() {
List<IConfigElement> configElements = new ArrayList<>();
for (AgriConfigCategory e : AgriConfigCategory.values()) {
String descr = "AgriCraft " + e.getDisplayName() + " Settings";
String name = "agricraft.configgui.ctgy." + e.name();
configElements.add(new DummyConfigElement.DummyCategoryElement(descr, name, new ConfigElement(CoreHandler.getConfig().getCategory(e.name().toLowerCase())).getChildElements()));
}
return configElements;
}
private static List<IConfigElement> getConfigElements()
{
List<IConfigElement> configElements = new ArrayList<IConfigElement>();
Configuration config = ConfigReader.loadConfigsFromFile();
configElements.add(new ConfigElement(config.getCategory(ConfigReader.CATEGORY_GENERIC)));
configElements.add(new ConfigElement(config.getCategory(ConfigReader.CATEGORY_BUILDERSWAND)));
configElements.add(new ConfigElement(config.getCategory(ConfigReader.CATEGORY_LISTS)));
configElements.add(new ConfigElement(config.getCategory(ConfigReader.CATEGORY_CLIENT)));
return configElements;
}
private static List<IConfigElement> getConfigElements(GuiScreen parent) {
List<IConfigElement> list = new ArrayList<IConfigElement>();
String prefix = SimplyJetpacks.PREFIX + "config.";
for (Section configSection : Config.configSections) {
if (configSection.client) {
list.add(new ConfigElement<ConfigCategory>(Config.configClient.getCategory(configSection.toLowerCase()).setLanguageKey(prefix + configSection.id)));
} else {
list.add(new ConfigElement<ConfigCategory>(Config.config.getCategory(configSection.toLowerCase()).setLanguageKey(prefix + configSection.id)));
}
}
return list;
}
public ModGuiConfig(GuiScreen guiScreen)
{
super(guiScreen,
new ConfigElement(ConfigurationHandler.configuration.getCategory(Configuration.CATEGORY_GENERAL)).getChildElements(),
Reference.MOD_ID,
false,
false,
GuiConfig.getAbridgedConfigPath(ConfigurationHandler.configuration.toString()));
}
@SuppressWarnings("rawtypes")
private static List<IConfigElement> getConfigElements(GuiScreen parent) {
List<IConfigElement> list = new ArrayList<IConfigElement>();
list.add(new ConfigElement<ConfigCategory>(config.getCategory(CATEGORY_RANDOM.toLowerCase())));
list.add(new ConfigElement<ConfigCategory>(config.getCategory(CATEGORY_VALUES.toLowerCase())));
list.add(new ConfigElement<ConfigCategory>(config.getCategory(CATEGORY_RESEARCH.toLowerCase())));
list.add(new ConfigElement<ConfigCategory>(config.getCategory(CATEGORY_OUTPUTS.toLowerCase())));
list.add(new ConfigElement<ConfigCategory>(config.getCategory(CATEGORY_MODULES.toLowerCase())));
return list;
}
private static List<IConfigElement> getConfigElements(GuiScreen parent) {
List<IConfigElement> list = new ArrayList<IConfigElement>();
String prefix = "enderzoo.config.";
for (Section section : Config.sections) {
list.add(new ConfigElement(Config.config.getCategory(section.lc()).setLanguageKey(prefix + section.lang)));
}
return list;
}
private static List<IConfigElement> getConfigElements(final Configuration configuration, final String langPrefix) {
final List<IConfigElement> elements = new ArrayList<IConfigElement>();
for (final String name : configuration.getCategoryNames()) {
final ConfigCategory category = configuration.getCategory(name).setLanguageKey(langPrefix + ".category." + name);
if (category.parent == null) {
elements.add(new ConfigElement(category));
}
}
return elements;
}
private static List<IConfigElement> getConfigElements(){
List<IConfigElement> list = new ArrayList<IConfigElement>();
for(String category : Config.CATEGORIES) {
list.add(new DummyCategoryElement(category, category, new ConfigElement(Config.config.getCategory(category).setRequiresMcRestart(!Config.NO_MC_RESTART_CATS.contains(category))).getChildElements()));
}
return list;
}
private static IConfigElement createModConfig() {
final Configuration config = OpenPeripheralCore.instance.config();
final List<IConfigElement> result = Lists.newArrayList();
for (String categoryName : config.getCategoryNames()) {
if (!categoryName.equalsIgnoreCase(Config.CATEGORY_FEATURE_GROUPS)) {
ConfigCategory category = config.getCategory(categoryName);
result.add(new ConfigElement(category));
}
}
return new DummyCategoryElement("modConfig", "openperipheralcore.config.miscConfig", result);
}
/** Creates a button linking to another screen where all options of the category are available */
private static IConfigElement categoryElement(String category, String name, String tooltip_key)
{
return new DummyConfigElement.DummyCategoryElement(name, tooltip_key,
new ConfigElement(SoundPhysicsCore.configFile.getCategory(category)).getChildElements());
}
public NovaGuiConfig(GuiScreen parentScreen, Configuration config, String modID) {
super(parentScreen, new ConfigElement(config.getCategory(Configuration.CATEGORY_GENERAL)).getChildElements(), modID, false, false, GuiConfig.getAbridgedConfigPath(config.toString()));
}
public NovaGuiConfig(GuiScreen parentScreen, Configuration config, String modID) {
super(parentScreen, new ConfigElement(config.getCategory(Configuration.CATEGORY_GENERAL)).getChildElements(), modID, false, false, GuiConfig.getAbridgedConfigPath(config.toString()));
}
public NovaGuiConfig(GuiScreen parentScreen, Configuration config, String modID) {
super(parentScreen, new ConfigElement<>(config.getCategory(Configuration.CATEGORY_GENERAL)).getChildElements(),
modID, false, false, GuiConfig.getAbridgedConfigPath(config.toString()));
}
public GuiChiselConfig(GuiScreen parent) {
super(parent, new ConfigElement<ConfigCategory>(Configurations.config.getCategory(Configuration.CATEGORY_GENERAL)).getChildElements(), Chisel.MOD_ID, false, false, GuiConfig
.getAbridgedConfigPath(Configurations.config.toString()));
}
public GuiChiselConfig(GuiScreen parent)
{
super(parent, new ConfigElement(Configurations.config.getCategory(Configuration.CATEGORY_GENERAL)).getChildElements(), Chisel.MOD_ID, false, false, GuiConfig.getAbridgedConfigPath(Configurations.config.toString()));
}
private static List<IConfigElement> getConfigElements(final Configuration configuration, final String categoryName) {
final ConfigElement element = new ConfigElement(configuration.getCategory(categoryName));
return element.getChildElements();
}
public ConfigGUI(GuiScreen parent) {
super(parent,
new ConfigElement(ConfigHandler.configFile.getCategory(Configuration.CATEGORY_GENERAL)).getChildElements(),
Reference.MOD_ID, false, false, GuiConfig.getAbridgedConfigPath(ConfigHandler.configFile.toString()));
}