X-Git-Url: https://git.pterodactylus.net/?a=blobdiff_plain;f=src%2Fmain%2Fjava%2Fnet%2Fpterodactylus%2Fsone%2Fcore%2FCore.java;h=21d7a808aa050cdf5dfdd497fc3bf9ac4cce2cb2;hb=e0f1723814bdfd94f75dd9ad11462124cdcb8a6c;hp=1c282d813cb962be73f759ee06d34d5c48feeb93;hpb=4a12f8559d9e4a662354f0ac2c8cb89f44bfd404;p=Sone.git diff --git a/src/main/java/net/pterodactylus/sone/core/Core.java b/src/main/java/net/pterodactylus/sone/core/Core.java index 1c282d8..21d7a80 100644 --- a/src/main/java/net/pterodactylus/sone/core/Core.java +++ b/src/main/java/net/pterodactylus/sone/core/Core.java @@ -31,6 +31,9 @@ import java.util.UUID; import java.util.logging.Level; import java.util.logging.Logger; +import net.pterodactylus.sone.core.Options.DefaultOption; +import net.pterodactylus.sone.core.Options.Option; +import net.pterodactylus.sone.core.Options.OptionWatcher; import net.pterodactylus.sone.core.SoneException.Type; import net.pterodactylus.sone.data.Post; import net.pterodactylus.sone.data.Profile; @@ -75,6 +78,9 @@ public class Core extends AbstractService { /** The logger. */ private static final Logger logger = Logging.getLogger(Core.class); + /** The options. */ + private final Options options = new Options(); + /** The configuration. */ private Configuration configuration; @@ -116,6 +122,15 @@ public class Core extends AbstractService { // /** + * Returns the options of the Sone plugin. + * + * @return The options of the Sone plugin + */ + public Options getOptions() { + return options; + } + + /** * Sets the configuration of the core. * * @param configuration @@ -603,6 +618,15 @@ public class Core extends AbstractService { private void loadConfiguration() { logger.entering(Core.class.getName(), "loadConfiguration()"); + options.addIntegerOption("InsertionDelay", new DefaultOption(60, new OptionWatcher() { + + @Override + public void optionChanged(Option option, Integer oldValue, Integer newValue) { + SoneInserter.setInsertionDelay(newValue); + } + + })).set(configuration.getIntValue("Option/InsertionDelay").getValue(null)); + /* parse local Sones. */ logger.log(Level.INFO, "Loading Sones…"); int soneId = 0; @@ -744,7 +768,11 @@ public class Core extends AbstractService { private void saveConfiguration() { Set sones = getSones(); logger.log(Level.INFO, "Storing %d Sones…", sones.size()); + try { + /* store the options first. */ + configuration.getIntValue("Option/InsertionDelay").setValue(options.getIntegerOption("InsertionDelay").getReal()); + /* store all Sones. */ int soneId = 0; for (Sone sone : localSones) {