X-Git-Url: https://git.pterodactylus.net/?p=Sone.git;a=blobdiff_plain;f=src%2Fmain%2Fjava%2Fnet%2Fpterodactylus%2Fsone%2Fcore%2FPreferences.java;h=283f8e264f5085fa2e1a762d1d94ecbdbfee9705;hp=456e7f2fae994b6c0ad06fadb4117f3dad4a760f;hb=179e7da4d8d8a474d0b622d60b5f5d32d6ab4052;hpb=c4ae226ec5052116cefc542ae2017036a7bc6332 diff --git a/src/main/java/net/pterodactylus/sone/core/Preferences.java b/src/main/java/net/pterodactylus/sone/core/Preferences.java index 456e7f2..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–2016 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; }