♻️ Turn plugin year into instance method
[Sone.git] / src / main / java / net / pterodactylus / sone / main / SonePlugin.java
index f394d44..82a0217 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Sone - SonePlugin.java - Copyright © 2010–2016 David Roden
+ * Sone - SonePlugin.java - Copyright © 2010–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
@@ -26,7 +26,11 @@ import java.util.logging.Level;
 import java.util.logging.LogRecord;
 import java.util.logging.Logger;
 
+import javax.inject.Singleton;
+
 import net.pterodactylus.sone.core.Core;
+import net.pterodactylus.sone.database.Database;
+import net.pterodactylus.sone.database.memory.MemoryDatabase;
 import net.pterodactylus.sone.fcp.FcpInterface;
 import net.pterodactylus.sone.freenet.PluginStoreConfigurationBackend;
 import net.pterodactylus.sone.freenet.wot.Context;
@@ -68,8 +72,6 @@ import freenet.support.api.Bucket;
 /**
  * This class interfaces with Freenet. It is the class that is loaded by the
  * node and starts up the whole Sone system.
- *
- * @author <a href="mailto:bombe@pterodactylus.net">David ‘Bombe’ Roden</a>
  */
 public class SonePlugin implements FredPlugin, FredPluginFCP, FredPluginL10n, FredPluginBaseL10n, FredPluginThreadless, FredPluginVersioned {
 
@@ -114,13 +116,10 @@ public class SonePlugin implements FredPlugin, FredPluginFCP, FredPluginL10n, Fr
                });
        }
 
-       /** The version. */
-       private static final Version VERSION = new Version(0, 9, 6);
-
        /** The current year at time of release. */
-       private static final int YEAR = 2016;
+       private static final int YEAR = 2017;
        private static final String SONE_HOMEPAGE = "USK@nwa8lHa271k2QvJ8aa0Ov7IHAV-DFOCFgmDt3X6BpCI,DuQSUZiI~agF8c-6tjsFFGuZ8eICrzWCILB60nT8KKo,AQACAAE/sone/";
-       private static final int LATEST_EDITION = 73;
+       private static final int LATEST_EDITION = 77;
 
        /** The logger. */
        private static final Logger logger = getLogger(SonePlugin.class.getName());
@@ -175,10 +174,11 @@ public class SonePlugin implements FredPlugin, FredPluginFCP, FredPluginL10n, Fr
        }
 
        public static String getPluginVersion() {
-               return VERSION.toString();
+               net.pterodactylus.sone.main.Version version = VersionParserKt.getParsedVersion();
+               return (version == null) ? "unknown" : version.getNice();
        }
 
-       public static int getYear() {
+       public int getYear() {
                return YEAR;
        }
 
@@ -250,10 +250,11 @@ public class SonePlugin implements FredPlugin, FredPluginFCP, FredPluginL10n, Fr
                                bind(Context.class).toInstance(context);
                                bind(getOptionalContextTypeLiteral()).toInstance(of(context));
                                bind(SonePlugin.class).toInstance(SonePlugin.this);
-                               bind(Version.class).toInstance(VERSION);
+                               bind(Version.class).toInstance(Version.parse(getVersion()));
                                bind(PluginVersion.class).toInstance(new PluginVersion(getVersion()));
                                bind(PluginYear.class).toInstance(new PluginYear(getYear()));
                                bind(PluginHomepage.class).toInstance(new PluginHomepage(getHomepage()));
+                               bind(Database.class).to(MemoryDatabase.class).in(Singleton.class);
                                if (startConfiguration.getBooleanValue("Developer.LoadFromFilesystem").getValue(false)) {
                                        String path = startConfiguration.getStringValue("Developer.FilesystemPath").getValue(null);
                                        if (path != null) {
@@ -404,49 +405,7 @@ public class SonePlugin implements FredPlugin, FredPluginFCP, FredPluginL10n, Fr
         */
        @Override
        public String getVersion() {
-               return VERSION.toString();
-       }
-
-       public static class PluginVersion {
-
-               private final String version;
-
-               public PluginVersion(String version) {
-                       this.version = version;
-               }
-
-               public String getVersion() {
-                       return version;
-               }
-
-       }
-
-       public static class PluginYear {
-
-               private final int year;
-
-               public PluginYear(int year) {
-                       this.year = year;
-               }
-
-               public int getYear() {
-                       return year;
-               }
-
-       }
-
-       public static class PluginHomepage {
-
-               private final String homepage;
-
-               public PluginHomepage(String homepage) {
-                       this.homepage = homepage;
-               }
-
-               public String getHomepage() {
-                       return homepage;
-               }
-
+               return getPluginVersion();
        }
 
 }