Document valid values for MultipleChoiceSettings in config file
This commit is contained in:
@@ -1,8 +1,10 @@
|
||||
package com.replaymod.core;
|
||||
|
||||
import net.minecraftforge.common.config.Configuration;
|
||||
import net.minecraftforge.common.config.Property;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
class SettingsRegistryBackend {
|
||||
@@ -36,7 +38,14 @@ class SettingsRegistryBackend {
|
||||
} else if (key.getDefault() instanceof Double) {
|
||||
value = configuration.get(key.getCategory(), key.getKey(), (Double) key.getDefault()).getDouble();
|
||||
} else if (key.getDefault() instanceof String) {
|
||||
value = configuration.get(key.getCategory(), key.getKey(), (String) key.getDefault()).getString();
|
||||
Property property = configuration.get(key.getCategory(), key.getKey(), (String) key.getDefault());
|
||||
value = property.getString();
|
||||
if (key instanceof SettingsRegistry.MultipleChoiceSettingKey) {
|
||||
@SuppressWarnings("unchecked")
|
||||
List<String> choices = ((SettingsRegistry.MultipleChoiceSettingKey<String>) key).getChoices();
|
||||
property.setValidValues(choices.toArray(new String[0]));
|
||||
property.setComment("Valid values: " + String.join(", ", choices));
|
||||
}
|
||||
} else {
|
||||
throw new IllegalArgumentException("Default type " + key.getDefault().getClass() + " not supported.");
|
||||
}
|
||||
|
||||
@@ -7,6 +7,7 @@ import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraftforge.client.event.GuiScreenEvent;
|
||||
import net.minecraftforge.client.event.RenderGameOverlayEvent;
|
||||
import net.minecraftforge.client.event.RenderLivingEvent;
|
||||
import net.minecraftforge.common.config.Property;
|
||||
|
||||
class Patterns {
|
||||
@Pattern
|
||||
@@ -44,4 +45,13 @@ class Patterns {
|
||||
//$$ return event.type;
|
||||
//#endif
|
||||
}
|
||||
|
||||
@Pattern
|
||||
private static void setComment(Property property, String comment) {
|
||||
//#if MC>=10900
|
||||
property.setComment(comment);
|
||||
//#else
|
||||
//$$ property.comment = comment;
|
||||
//#endif
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user