X-Git-Url: https://git.pterodactylus.net/?p=Sone.git;a=blobdiff_plain;f=src%2Fmain%2Fjava%2Fnet%2Fpterodactylus%2Fsone%2Fcore%2FPreferences.java;h=7edff1a75506698d0b507a98554eb72846af696c;hp=16d945363afc08eccc4ea1168a2a5159dd082bf8;hb=fdbdc26c744865a7200017cb117943d48df498ad;hpb=6f019de1d4d9742981d851ac3c9097cca8bff58e diff --git a/src/main/java/net/pterodactylus/sone/core/Preferences.java b/src/main/java/net/pterodactylus/sone/core/Preferences.java index 16d9453..7edff1a 100644 --- a/src/main/java/net/pterodactylus/sone/core/Preferences.java +++ b/src/main/java/net/pterodactylus/sone/core/Preferences.java @@ -17,8 +17,14 @@ package net.pterodactylus.sone.core; +import net.pterodactylus.sone.core.event.InsertionDelayChangedEvent; import net.pterodactylus.sone.fcp.FcpInterface; import net.pterodactylus.sone.fcp.FcpInterface.FullAccessRequired; +import net.pterodactylus.sone.fcp.event.FcpInterfaceActivatedEvent; +import net.pterodactylus.sone.fcp.event.FcpInterfaceDeactivatedEvent; +import net.pterodactylus.sone.fcp.event.FullAccessRequiredChanged; + +import com.google.common.eventbus.EventBus; /** * Convenience interface for external classes that want to access the core’s @@ -28,16 +34,11 @@ import net.pterodactylus.sone.fcp.FcpInterface.FullAccessRequired; */ public class Preferences { - /** The wrapped options. */ + private final EventBus eventBus; private final Options options; - /** - * Creates a new preferences object wrapped around the given options. - * - * @param options - * The options to wrap - */ - public Preferences(Options options) { + public Preferences(EventBus eventBus, Options options) { + this.eventBus = eventBus; this.options = options; } @@ -72,6 +73,7 @@ public class Preferences { */ public Preferences setInsertionDelay(Integer insertionDelay) { options.getIntegerOption("InsertionDelay").set(insertionDelay); + eventBus.post(new InsertionDelayChangedEvent(getInsertionDelay())); return this; } @@ -345,6 +347,11 @@ public class Preferences { */ public Preferences setFcpInterfaceActive(boolean fcpInterfaceActive) { options.getBooleanOption("ActivateFcpInterface").set(fcpInterfaceActive); + if (fcpInterfaceActive) { + eventBus.post(new FcpInterfaceActivatedEvent()); + } else { + eventBus.post(new FcpInterfaceDeactivatedEvent()); + } return this; } @@ -369,6 +376,7 @@ public class Preferences { */ public Preferences setFcpFullAccessRequired(FullAccessRequired fcpFullAccessRequired) { options.getIntegerOption("FcpFullAccessRequired").set((fcpFullAccessRequired != null) ? fcpFullAccessRequired.ordinal() : null); + eventBus.post(new FullAccessRequiredChanged(fcpFullAccessRequired)); return this; }