mirror of
https://github.com/TeamMidnightDust/MidnightLib.git
synced 2025-12-15 17:05:09 +01:00
- adjust: optimize code & add comment
This commit is contained in:
@@ -218,7 +218,7 @@ public abstract class MidnightConfig {
|
|||||||
if (info.dataType == Identifier.class) { // avoid the crash due to Identifier syntax not legitimate
|
if (info.dataType == Identifier.class) { // avoid the crash due to Identifier syntax not legitimate
|
||||||
Identifier id = Identifier.tryParse(s);
|
Identifier id = Identifier.tryParse(s);
|
||||||
if (id == null) return false;
|
if (id == null) return false;
|
||||||
info.setValue(Identifier.tryParse(s));
|
info.setValue(id);
|
||||||
}
|
}
|
||||||
else info.setValue(isNumber ? value : s);
|
else info.setValue(isNumber ? value : s);
|
||||||
}
|
}
|
||||||
@@ -358,7 +358,7 @@ public abstract class MidnightConfig {
|
|||||||
if (info.function != null) {
|
if (info.function != null) {
|
||||||
ClickableWidget widget;
|
ClickableWidget widget;
|
||||||
Entry e = info.entry;
|
Entry e = info.entry;
|
||||||
if (info.function instanceof Map.Entry) {
|
if (info.function instanceof Map.Entry) { // Enums & booleans
|
||||||
var values = (Map.Entry<ButtonWidget.PressAction, Function<Object, Text>>) info.function;
|
var values = (Map.Entry<ButtonWidget.PressAction, Function<Object, Text>>) info.function;
|
||||||
if (info.dataType.isEnum())
|
if (info.dataType.isEnum())
|
||||||
values.setValue(value -> Text.translatable(translationPrefix + "enum." + info.dataType.getSimpleName() + "." + info.value.toString()));
|
values.setValue(value -> Text.translatable(translationPrefix + "enum." + info.dataType.getSimpleName() + "." + info.value.toString()));
|
||||||
|
|||||||
Reference in New Issue
Block a user