X-Git-Url: https://git.pterodactylus.net/?a=blobdiff_plain;ds=sidebyside;f=src%2Fmain%2Fjava%2Fnet%2Fpterodactylus%2Fsone%2Fcore%2FPreferences.java;h=283f8e264f5085fa2e1a762d1d94ecbdbfee9705;hb=179e7da4d8d8a474d0b622d60b5f5d32d6ab4052;hp=56bfa73dd062e42272efb17404c290b2e9cf8372;hpb=f229fe41f708d2b275c20ceb9aba5993761218a3;p=Sone.git
diff --git a/src/main/java/net/pterodactylus/sone/core/Preferences.java b/src/main/java/net/pterodactylus/sone/core/Preferences.java
index 56bfa73..283f8e2 100644
--- a/src/main/java/net/pterodactylus/sone/core/Preferences.java
+++ b/src/main/java/net/pterodactylus/sone/core/Preferences.java
@@ -1,5 +1,5 @@
/*
- * Sone - Preferences.java - Copyright © 2013 David Roden
+ * Sone - Preferences.java - Copyright © 2013â2019 David Roden
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -39,35 +39,33 @@ import com.google.common.eventbus.EventBus;
/**
* Convenience interface for external classes that want to access the coreâs
* configuration.
- *
- * @author David âBombeâ Roden
*/
public class Preferences {
private final EventBus eventBus;
private final Option insertionDelay =
- new DefaultOption(60, range(0, MAX_VALUE));
+ new DefaultOption<>(60, range(0, MAX_VALUE));
private final Option postsPerPage =
- new DefaultOption(10, range(1, MAX_VALUE));
+ new DefaultOption<>(10, range(1, MAX_VALUE));
private final Option imagesPerPage =
- new DefaultOption(9, range(1, MAX_VALUE));
+ new DefaultOption<>(9, range(1, MAX_VALUE));
private final Option charactersPerPost =
- new DefaultOption(400, Predicates.or(
+ new DefaultOption<>(400, Predicates.or(
range(50, MAX_VALUE), equalTo(-1)));
private final Option postCutOffLength =
- new DefaultOption(200, range(50, MAX_VALUE));
+ new DefaultOption<>(200, range(50, MAX_VALUE));
private final Option requireFullAccess =
- new DefaultOption(false);
+ new DefaultOption<>(false);
private final Option positiveTrust =
- new DefaultOption(75, range(0, 100));
+ new DefaultOption<>(75, range(0, 100));
private final Option negativeTrust =
- new DefaultOption(-25, range(-100, 100));
+ new DefaultOption<>(-25, range(-100, 100));
private final Option trustComment =
- new DefaultOption("Set from Sone Web Interface");
+ new DefaultOption<>("Set from Sone Web Interface");
private final Option activateFcpInterface =
- new DefaultOption(false);
+ new DefaultOption<>(false);
private final Option fcpFullAccessRequired =
- new DefaultOption(ALWAYS);
+ new DefaultOption<>(ALWAYS);
public Preferences(EventBus eventBus) {
this.eventBus = eventBus;
@@ -105,6 +103,7 @@ public class Preferences {
public Preferences setInsertionDelay(Integer insertionDelay) {
this.insertionDelay.set(insertionDelay);
eventBus.post(new InsertionDelayChangedEvent(getInsertionDelay()));
+ eventBus.post(new PreferenceChangedEvent("InsertionDelay", getInsertionDelay()));
return this;
}
@@ -138,6 +137,7 @@ public class Preferences {
*/
public Preferences setPostsPerPage(Integer postsPerPage) {
this.postsPerPage.set(postsPerPage);
+ eventBus.post(new PreferenceChangedEvent("PostsPerPage", getPostsPerPage()));
return this;
}