Add main config header, explanation for channels

This commit is contained in:
Vankka 2023-06-11 14:49:14 +03:00
parent b69f1de11e
commit 1ca4e69d9a
No known key found for this signature in database
GPG Key ID: 6E50CB7A29B96AD0
2 changed files with 20 additions and 0 deletions

View File

@ -34,6 +34,12 @@ public abstract class MainConfig implements Config {
public static final String FILE_NAME = "config.yaml";
public static final String HEADER = String.join("\n", Arrays.asList(
"Welcome to the DiscordSRV configuration file",
"",
""
));
@Override
public final String getFileName() {
return FILE_NAME;
@ -48,6 +54,12 @@ public abstract class MainConfig implements Config {
}
@DefaultOnly(ChannelConfig.DEFAULT_KEY)
@Comment("Channels configuration\n\n"
+ "This is where everything related to in-game chat channels is configured.\n"
+ "The key of this option is the in-game channel name (the default keys are \"global\" and \"default\")\n"
+ "channel-ids and threads can be configured for all channels except \"default\"\n"
+ "\"default\" is a special section which has the default values for all channels unless they are specified (overridden) under the channel's own section\n"
+ "So if you don't specify a certain option under a channel's own section, the option will take it's value from the \"default\" section")
public Map<String, BaseChannelConfig> channels = new LinkedHashMap<String, BaseChannelConfig>() {{
put(GameChannel.DEFAULT_NAME, createDefaultChannel());
put(ChannelConfig.DEFAULT_KEY, createDefaultBaseChannel());

View File

@ -22,6 +22,8 @@ import com.discordsrv.common.DiscordSRV;
import com.discordsrv.common.config.main.MainConfig;
import com.discordsrv.common.config.manager.loader.YamlConfigLoaderProvider;
import com.discordsrv.common.config.manager.manager.TranslatedConfigManager;
import org.spongepowered.configurate.ConfigurationOptions;
import org.spongepowered.configurate.objectmapping.ObjectMapper;
import org.spongepowered.configurate.yaml.YamlConfigurationLoader;
public abstract class MainConfigManager<C extends MainConfig>
@ -32,6 +34,12 @@ public abstract class MainConfigManager<C extends MainConfig>
super(discordSRV);
}
@Override
public ConfigurationOptions defaultOptions(ObjectMapper.Factory objectMapper) {
return super.defaultOptions(objectMapper)
.header(MainConfig.HEADER);
}
@Override
protected String fileName() {
return MainConfig.FILE_NAME;