Skip to content

Commit

Permalink
Merge branch 'improve/extra-options' into feature/updater
Browse files Browse the repository at this point in the history
  • Loading branch information
ItsNature committed Sep 21, 2023
2 parents c70c810 + c2e1291 commit b71a9a8
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ public static void bootstrap(ApolloPlatform platform) {
* @since 1.0.0
*/
public static void registerOptions(Option<?, ?, ?>... options) {
optionKeys.addAll(Arrays.asList(options));
ApolloManager.optionKeys.addAll(Arrays.asList(options));
}

/**
Expand Down Expand Up @@ -144,7 +144,7 @@ public static void saveConfiguration() {
return;
}

ConfigOptions.saveOptions(ApolloManager.platform.getOptions(), ApolloManager.configurationNode);
ConfigOptions.saveOptions(ApolloManager.platform.getOptions(), ApolloManager.configurationNode, ApolloManager.optionKeys);

CommentedConfigurationNode modules = ApolloManager.configurationNode.node("modules");

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ public void saveConfiguration(CommentedConfigurationNode node) {
CommentedConfigurationNode moduleNode = node.node(module.getId().toLowerCase(Locale.ENGLISH));

Options optionsContainer = module.getOptions();
ConfigOptions.saveOptions(optionsContainer, moduleNode);
ConfigOptions.saveOptions(optionsContainer, moduleNode, module.getOptionKeys());
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,11 +64,12 @@ public static void loadOptions(Options options, CommentedConfigurationNode node,
*
* @param options the options container
* @param node the configuration node
* @param optionKeys the option keys
* @since 1.0.0
*/
@SuppressWarnings("unchecked")
public static void saveOptions(Options options, CommentedConfigurationNode node) {
for (Option<?, ?, ?> option : options) {
public static void saveOptions(Options options, CommentedConfigurationNode node, List<Option<?, ?, ?>> optionKeys) {
for (Option<?, ?, ?> option : optionKeys) {
CommentedConfigurationNode optionNode = node.node((Object[]) option.getPath());
if (optionNode == null) {
continue;
Expand Down

0 comments on commit b71a9a8

Please sign in to comment.