diff --git a/src/main/java/org/nwapw/abacus/Abacus.java b/src/main/java/org/nwapw/abacus/Abacus.java index eda7b80..795aaf1 100644 --- a/src/main/java/org/nwapw/abacus/Abacus.java +++ b/src/main/java/org/nwapw/abacus/Abacus.java @@ -12,8 +12,6 @@ import org.nwapw.abacus.plugin.StandardPlugin; import org.nwapw.abacus.tree.NumberReducer; import org.nwapw.abacus.tree.TreeNode; -import java.util.function.Supplier; - /** * The main calculator class. This is responsible * for piecing together all of the components, allowing @@ -49,10 +47,10 @@ public class Abacus { /** * Creates a new instance of the Abacus calculator. */ - public Abacus(Supplier configurationSupplier) { + public Abacus(Configuration configuration) { pluginManager = new PluginManager(this); numberReducer = new NumberReducer(this); - configuration = configurationSupplier.get(); + this.configuration = new Configuration(configuration); LexerTokenizer lexerTokenizer = new LexerTokenizer(); ShuntingYardParser shuntingYardParser = new ShuntingYardParser(this); treeBuilder = new TreeBuilder<>(lexerTokenizer, shuntingYardParser); diff --git a/src/main/java/org/nwapw/abacus/config/Configuration.java b/src/main/java/org/nwapw/abacus/config/Configuration.java index c7d7721..2b68236 100644 --- a/src/main/java/org/nwapw/abacus/config/Configuration.java +++ b/src/main/java/org/nwapw/abacus/config/Configuration.java @@ -39,6 +39,15 @@ public class Configuration { */ private Set disabledPlugins = new HashSet<>(); + /** + * Creates a new configuration form the given configuration. + * + * @param copyFrom the configuration to copy. + */ + public Configuration(Configuration copyFrom){ + copyFrom(copyFrom); + } + /** * Creates a new configuration with the given values. * diff --git a/src/main/java/org/nwapw/abacus/fx/AbacusController.java b/src/main/java/org/nwapw/abacus/fx/AbacusController.java index 1e75008..d0cce54 100644 --- a/src/main/java/org/nwapw/abacus/fx/AbacusController.java +++ b/src/main/java/org/nwapw/abacus/fx/AbacusController.java @@ -180,7 +180,7 @@ public class AbacusController implements PluginListener { if (oldValue.equals(settingsTab)) alertIfApplyNeeded(true); }); - abacus = new Abacus(() -> new Configuration(new java.io.File("config.toml"))); + abacus = new Abacus(new Configuration(CONFIG_FILE)); PluginManager abacusPluginManager = abacus.getPluginManager(); abacusPluginManager.addListener(this); abacusPluginManager.addInstantiated(new StandardPlugin(abacus.getPluginManager()));