[config] Tweak config command

This commit is contained in:
Johannes Frohnmeyer 2022-07-28 11:10:29 +02:00
parent 9910bf4867
commit 1c7b3dc0cb
Signed by: Johannes
GPG Key ID: E76429612C2929F4

View File

@ -104,7 +104,7 @@ public class JfConfigCommand implements ModInitializer {
private <T> void registerEntry(ConfigInstance config, String subpath, LiteralArgumentBuilder<ServerCommandSource> cns, EntryInfo<T> entry) {
LiteralArgumentBuilder<ServerCommandSource> c_entry = literal(entry.getName()).executes(context -> {
context.getSource().sendFeedback(Text.literal("[libjf-config-v0] The value of " + subpath + entry.getName() + " is " + tryRun(entry::getValue)), false);
context.getSource().sendFeedback(Text.literal("[libjf-config-v0] The value of " + subpath + "." + entry.getName() + " is " + tryRun(entry::getValue)), false);
return Command.SINGLE_SUCCESS;
});
ArgumentType<?> type = getType(entry);
@ -112,7 +112,7 @@ public class JfConfigCommand implements ModInitializer {
c_entry.then(argument("value", type).executes(context -> {
T value = context.getArgument("value", entry.getValueType());
tryRun(() -> entry.setValue(value));
context.getSource().sendFeedback(Text.literal("[libjf-config-v0] Set " + subpath + entry.getName() + " to " + value), true);
context.getSource().sendFeedback(Text.literal("[libjf-config-v0] Set " + subpath + "." + entry.getName() + " to " + value), true);
return Command.SINGLE_SUCCESS;
}));
}
@ -120,7 +120,7 @@ public class JfConfigCommand implements ModInitializer {
for (T enumConstant : entry.getValueType().getEnumConstants()) {
c_entry.then(literal(enumConstant.toString()).executes(context -> {
tryRun(() -> entry.setValue(enumConstant));
context.getSource().sendFeedback(Text.literal("[libjf-config-v0] Set " + subpath + entry.getName() + " to " + enumConstant), true);
context.getSource().sendFeedback(Text.literal("[libjf-config-v0] Set " + subpath + "." + entry.getName() + " to " + enumConstant), true);
return Command.SINGLE_SUCCESS;
}));
}