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
*/
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;
}
*/
public Preferences setInsertionDelay(Integer insertionDelay) {
options.getIntegerOption("InsertionDelay").set(insertionDelay);
+ eventBus.post(new InsertionDelayChangedEvent(getInsertionDelay()));
return this;
}
*/
public Preferences setFcpInterfaceActive(boolean fcpInterfaceActive) {
options.getBooleanOption("ActivateFcpInterface").set(fcpInterfaceActive);
+ if (fcpInterfaceActive) {
+ eventBus.post(new FcpInterfaceActivatedEvent());
+ } else {
+ eventBus.post(new FcpInterfaceDeactivatedEvent());
+ }
return this;
}
*/
public Preferences setFcpFullAccessRequired(FullAccessRequired fcpFullAccessRequired) {
options.getIntegerOption("FcpFullAccessRequired").set((fcpFullAccessRequired != null) ? fcpFullAccessRequired.ordinal() : null);
+ eventBus.post(new FullAccessRequiredChanged(fcpFullAccessRequired));
return this;
}