feat(config-commands): Write on change and work in singleplayer
This commit is contained in:
parent
e2a891c2e2
commit
e4d510f164
|
@ -111,7 +111,10 @@ public class JfConfigCommand implements ModInitializer {
|
|||
if (type != null) {
|
||||
c_entry.then(argument("value", type).executes(context -> {
|
||||
@SuppressWarnings("unchecked") T value = context.getArgument("value", (Class<T>) entry.getValueType().asClass());
|
||||
tryRun(() -> entry.setValue(value));
|
||||
tryRun(() -> {
|
||||
entry.setValue(value);
|
||||
config.getRoot().write();
|
||||
});
|
||||
context.getSource().sendFeedback(() -> Text.literal("[libjf-config-v1] Set " + subpath + "." + entry.getName() + " to " + value), true);
|
||||
return Command.SINGLE_SUCCESS;
|
||||
}));
|
||||
|
@ -119,7 +122,10 @@ public class JfConfigCommand implements ModInitializer {
|
|||
else if (entry.getValueType().isEnum()) {
|
||||
for (T enumConstant : ((Type.TEnum<T>)entry.getValueType()).options()) {
|
||||
c_entry.then(literal(enumConstant.toString()).executes(context -> {
|
||||
tryRun(() -> entry.setValue(enumConstant));
|
||||
tryRun(() -> {
|
||||
entry.setValue(enumConstant);
|
||||
config.getRoot().write();
|
||||
});
|
||||
context.getSource().sendFeedback(() -> Text.literal("[libjf-config-v1] Set " + subpath + "." + entry.getName() + " to " + enumConstant), true);
|
||||
return Command.SINGLE_SUCCESS;
|
||||
}));
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
"sources": "https://git.frohnmeyer-wds.de/JfMods/LibJF"
|
||||
},
|
||||
"license": "MIT",
|
||||
"environment": "server",
|
||||
"environment": "*",
|
||||
"entrypoints": {
|
||||
"main": ["io.gitlab.jfronny.libjf.config.impl.commands.JfConfigCommand"]
|
||||
},
|
||||
|
|
Loading…
Reference in New Issue