[config] Tweak config command
This commit is contained in:
parent
9910bf4867
commit
1c7b3dc0cb
@ -104,7 +104,7 @@ public class JfConfigCommand implements ModInitializer {
|
|||||||
|
|
||||||
private <T> void registerEntry(ConfigInstance config, String subpath, LiteralArgumentBuilder<ServerCommandSource> cns, EntryInfo<T> entry) {
|
private <T> void registerEntry(ConfigInstance config, String subpath, LiteralArgumentBuilder<ServerCommandSource> cns, EntryInfo<T> entry) {
|
||||||
LiteralArgumentBuilder<ServerCommandSource> c_entry = literal(entry.getName()).executes(context -> {
|
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;
|
return Command.SINGLE_SUCCESS;
|
||||||
});
|
});
|
||||||
ArgumentType<?> type = getType(entry);
|
ArgumentType<?> type = getType(entry);
|
||||||
@ -112,7 +112,7 @@ public class JfConfigCommand implements ModInitializer {
|
|||||||
c_entry.then(argument("value", type).executes(context -> {
|
c_entry.then(argument("value", type).executes(context -> {
|
||||||
T value = context.getArgument("value", entry.getValueType());
|
T value = context.getArgument("value", entry.getValueType());
|
||||||
tryRun(() -> entry.setValue(value));
|
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;
|
return Command.SINGLE_SUCCESS;
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
@ -120,7 +120,7 @@ public class JfConfigCommand implements ModInitializer {
|
|||||||
for (T enumConstant : entry.getValueType().getEnumConstants()) {
|
for (T enumConstant : entry.getValueType().getEnumConstants()) {
|
||||||
c_entry.then(literal(enumConstant.toString()).executes(context -> {
|
c_entry.then(literal(enumConstant.toString()).executes(context -> {
|
||||||
tryRun(() -> entry.setValue(enumConstant));
|
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;
|
return Command.SINGLE_SUCCESS;
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user