+public class SonePlugin implements FredPlugin, FredPluginFCP, FredPluginL10n, FredPluginBaseL10n, FredPluginThreadless, FredPluginVersioned {
+
+ private static final Logger soneLogger = getLogger("net.pterodactylus.sone");
+
+ static {
+ /* initialize logging. */
+ soneLogger.setUseParentHandlers(false);
+ soneLogger.setLevel(Level.ALL);
+ soneLogger.addHandler(new Handler() {
+ private final LoadingCache<String, Class<?>> classCache = CacheBuilder.newBuilder()
+ .build(new CacheLoader<String, Class<?>>() {
+ @Override
+ public Class<?> load(@Nonnull String key) throws Exception {
+ return SonePlugin.class.getClassLoader().loadClass(key);
+ }
+ });
+
+ @Override
+ public void publish(LogRecord logRecord) {
+ int recordLevel = logRecord.getLevel().intValue();
+ Class<?> loggingClass = classCache.getUnchecked(logRecord.getLoggerName());
+ if (recordLevel < Level.FINE.intValue()) {
+ freenet.support.Logger.debug(loggingClass, logRecord.getMessage(), logRecord.getThrown());
+ } else if (recordLevel < Level.INFO.intValue()) {
+ freenet.support.Logger.minor(loggingClass, logRecord.getMessage(), logRecord.getThrown());
+ } else if (recordLevel < Level.WARNING.intValue()) {
+ freenet.support.Logger.normal(loggingClass, logRecord.getMessage(), logRecord.getThrown());
+ } else if (recordLevel < Level.SEVERE.intValue()) {
+ freenet.support.Logger.warning(loggingClass, logRecord.getMessage(), logRecord.getThrown());
+ } else {
+ freenet.support.Logger.error(loggingClass, logRecord.getMessage(), logRecord.getThrown());
+ }
+ }
+
+ @Override
+ public void flush() {
+ }
+
+ @Override
+ public void close() {
+ }
+ });
+ }
+
+ /** The current year at time of release. */
+ private static final int YEAR = 2020;
+ private static final String SONE_HOMEPAGE = "USK@nwa8lHa271k2QvJ8aa0Ov7IHAV-DFOCFgmDt3X6BpCI,DuQSUZiI~agF8c-6tjsFFGuZ8eICrzWCILB60nT8KKo,AQACAAE/sone/";
+ private static final int LATEST_EDITION = 80;
+
+ /** The logger. */
+ private static final Logger logger = getLogger(SonePlugin.class.getName());
+
+ private final Function1<Module[], Injector> injectorCreator;
+
+ /** The plugin respirator. */
+ private PluginRespirator pluginRespirator;
+
+ /** The core. */
+ private Core core;
+
+ /** The event bus. */
+ private EventBus eventBus;
+
+ /** The web interface. */
+ private WebInterface webInterface;
+
+ /** The FCP interface. */
+ private FcpInterface fcpInterface;
+
+ /** The l10n helper. */
+ private PluginL10n l10n;
+
+ /** The web of trust connector. */
+ private WebOfTrustConnector webOfTrustConnector;
+
+ public SonePlugin() {
+ this(Guice::createInjector);
+ }
+
+ @VisibleForTesting
+ public SonePlugin(Function1<Module[], Injector> injectorCreator) {
+ this.injectorCreator = injectorCreator;
+ }
+
+ //
+ // ACCESSORS
+ //
+
+ /**
+ * Returns the plugin respirator for this plugin.
+ *
+ * @return The plugin respirator
+ */
+ public PluginRespirator pluginRespirator() {
+ return pluginRespirator;
+ }
+
+ /**
+ * Returns the core started by this plugin.
+ *
+ * @return The core
+ */
+ public Core core() {
+ return core;
+ }
+
+ /**
+ * Returns the plugin’s l10n helper.
+ *
+ * @return The plugin’s l10n helper
+ */
+ public PluginL10n l10n() {
+ return l10n;
+ }
+
+ public static String getPluginVersion() {
+ net.pterodactylus.sone.main.Version version = VersionParserKt.getParsedVersion();
+ return (version == null) ? "unknown" : version.getNice();
+ }
+
+ public int getYear() {
+ return YEAR;
+ }
+
+ public String getHomepage() {
+ return SONE_HOMEPAGE + LATEST_EDITION;
+ }
+
+ public static long getLatestEdition() {
+ return LATEST_EDITION;
+ }