From aeec459ee9cac860d4b28914f2a61e0c1c4b3e2e Mon Sep 17 00:00:00 2001 From: Rsl1122 Date: Sat, 29 Sep 2018 12:44:56 +0300 Subject: [PATCH] [Debt] Added PlanFiles to FileResponse constructor ResponseFactory provides the Response objects this dependency. Renamed all occurrences of "planFiles" -> "files" --- .../commands/manage/ManageRestoreCommand.java | 8 ++++---- .../com/djrapitops/plan/modules/FilesModule.java | 4 ++-- .../java/com/djrapitops/plan/system/PlanSystem.java | 12 ++++++------ .../plan/system/cache/GeolocationCache.java | 8 ++++---- .../plan/system/database/databases/sql/SQLiteDB.java | 8 ++++---- .../plan/system/info/server/ServerInfoFile.java | 10 +++++----- .../djrapitops/plan/system/locale/LocaleSystem.java | 8 ++++---- .../system/settings/config/BukkitConfigSystem.java | 6 +++--- .../system/settings/config/BungeeConfigSystem.java | 6 +++--- .../plan/system/settings/config/ConfigSystem.java | 6 +++--- .../system/settings/config/SpongeConfigSystem.java | 6 +++--- .../plan/system/settings/theme/ThemeConfig.java | 12 ++++++------ .../djrapitops/plan/system/webserver/WebServer.java | 8 ++++---- .../plan/system/webserver/response/CSSResponse.java | 6 ++++-- .../plan/system/webserver/response/FileResponse.java | 7 ++----- .../webserver/response/JavaScriptResponse.java | 6 ++++-- .../system/webserver/response/ResponseFactory.java | 4 ++-- .../webserver/response/errors/ErrorResponse.java | 4 ++-- .../plan/utilities/file/export/HtmlExport.java | 10 +++++----- .../plan/utilities/file/export/SpecificExport.java | 8 ++++---- .../plan/utilities/html/pages/AnalysisPage.java | 8 ++++---- .../plan/utilities/html/pages/InspectPage.java | 8 ++++---- .../plan/utilities/html/pages/NetworkPage.java | 8 ++++---- .../plan/utilities/html/pages/PlayersPage.java | 8 ++++---- .../plan/system/cache/GeolocationCacheTest.java | 6 +++--- 25 files changed, 93 insertions(+), 92 deletions(-) diff --git a/Plan/src/main/java/com/djrapitops/plan/command/commands/manage/ManageRestoreCommand.java b/Plan/src/main/java/com/djrapitops/plan/command/commands/manage/ManageRestoreCommand.java index f00c9da05..465e736f0 100644 --- a/Plan/src/main/java/com/djrapitops/plan/command/commands/manage/ManageRestoreCommand.java +++ b/Plan/src/main/java/com/djrapitops/plan/command/commands/manage/ManageRestoreCommand.java @@ -35,7 +35,7 @@ public class ManageRestoreCommand extends CommandNode { private final DBSystem dbSystem; private final ErrorHandler errorHandler; private final SQLiteDB.Factory sqliteFactory; - private final PlanFiles planFiles; + private final PlanFiles files; @Inject public ManageRestoreCommand( @@ -43,7 +43,7 @@ public class ManageRestoreCommand extends CommandNode { Processing processing, DBSystem dbSystem, SQLiteDB.Factory sqliteFactory, - PlanFiles planFiles, + PlanFiles files, ErrorHandler errorHandler ) { super("restore", Permissions.MANAGE.getPermission(), CommandType.CONSOLE); @@ -52,7 +52,7 @@ public class ManageRestoreCommand extends CommandNode { this.processing = processing; this.dbSystem = dbSystem; this.sqliteFactory = sqliteFactory; - this.planFiles = planFiles; + this.files = files; this.errorHandler = errorHandler; setArguments("", "", "[-a]"); @@ -96,7 +96,7 @@ public class ManageRestoreCommand extends CommandNode { String backupDBName = backupDbName; boolean containsDBFileExtension = backupDBName.endsWith(".db"); - File backupDBFile = planFiles.getFileFromPluginFolder(backupDBName + (containsDBFileExtension ? "" : ".db")); + File backupDBFile = files.getFileFromPluginFolder(backupDBName + (containsDBFileExtension ? "" : ".db")); if (!backupDBFile.exists()) { sender.sendMessage(locale.getString(ManageLang.FAIL_FILE_NOT_FOUND, backupDBFile.getAbsolutePath())); diff --git a/Plan/src/main/java/com/djrapitops/plan/modules/FilesModule.java b/Plan/src/main/java/com/djrapitops/plan/modules/FilesModule.java index 920e2604a..4a36c429e 100644 --- a/Plan/src/main/java/com/djrapitops/plan/modules/FilesModule.java +++ b/Plan/src/main/java/com/djrapitops/plan/modules/FilesModule.java @@ -19,8 +19,8 @@ public class FilesModule { @Provides @Named("configFile") @Singleton - File provideConfigFile(PlanFiles planFiles) { - return planFiles.getConfigFile(); + File provideConfigFile(PlanFiles files) { + return files.getConfigFile(); } } \ No newline at end of file diff --git a/Plan/src/main/java/com/djrapitops/plan/system/PlanSystem.java b/Plan/src/main/java/com/djrapitops/plan/system/PlanSystem.java index bb47c618a..d2e295674 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/PlanSystem.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/PlanSystem.java @@ -38,7 +38,7 @@ import javax.inject.Singleton; @Singleton public class PlanSystem implements SubSystem { - private final PlanFiles planFiles; + private final PlanFiles files; private final ConfigSystem configSystem; private final VersionCheckSystem versionCheckSystem; private final LocaleSystem localeSystem; @@ -60,7 +60,7 @@ public class PlanSystem implements SubSystem { @Inject public PlanSystem( - PlanFiles planFiles, + PlanFiles files, ConfigSystem configSystem, VersionCheckSystem versionCheckSystem, LocaleSystem localeSystem, @@ -78,7 +78,7 @@ public class PlanSystem implements SubSystem { PlanAPI planAPI, ErrorHandler errorHandler ) { - this.planFiles = planFiles; + this.files = files; this.configSystem = configSystem; this.versionCheckSystem = versionCheckSystem; this.localeSystem = localeSystem; @@ -105,7 +105,7 @@ public class PlanSystem implements SubSystem { @Override public void enable() throws EnableException { enableSystems( - planFiles, + files, configSystem, localeSystem, versionCheckSystem, @@ -143,7 +143,7 @@ public class PlanSystem implements SubSystem { serverInfo, localeSystem, configSystem, - planFiles, + files, versionCheckSystem ); } @@ -171,7 +171,7 @@ public class PlanSystem implements SubSystem { } public PlanFiles getPlanFiles() { - return planFiles; + return files; } public DBSystem getDatabaseSystem() { diff --git a/Plan/src/main/java/com/djrapitops/plan/system/cache/GeolocationCache.java b/Plan/src/main/java/com/djrapitops/plan/system/cache/GeolocationCache.java index 61275e8a9..d4f7481bd 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/cache/GeolocationCache.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/cache/GeolocationCache.java @@ -40,7 +40,7 @@ import java.util.zip.GZIPInputStream; public class GeolocationCache implements SubSystem { private final Locale locale; - private final PlanFiles planFiles; + private final PlanFiles files; private final PlanConfig config; private final PluginLogger logger; private final Map cached; @@ -50,12 +50,12 @@ public class GeolocationCache implements SubSystem { @Inject public GeolocationCache( Locale locale, - PlanFiles planFiles, + PlanFiles files, PlanConfig config, PluginLogger logger ) { this.locale = locale; - this.planFiles = planFiles; + this.files = files; this.config = config; this.logger = logger; @@ -64,7 +64,7 @@ public class GeolocationCache implements SubSystem { @Override public void enable() throws EnableException { - geolocationDB = planFiles.getFileFromPluginFolder("GeoIP.dat"); + geolocationDB = files.getFileFromPluginFolder("GeoIP.dat"); if (config.isTrue(Settings.DATA_GEOLOCATIONS)) { try { checkDB(); diff --git a/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/SQLiteDB.java b/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/SQLiteDB.java index b9cfe9f0a..1cea2e22f 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/SQLiteDB.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/SQLiteDB.java @@ -187,13 +187,13 @@ public class SQLiteDB extends SQLDB { private final PluginLogger logger; private final Timings timings; private final ErrorHandler errorHandler; - private PlanFiles planFiles; + private PlanFiles files; @Inject public Factory( Locale locale, PlanConfig config, - PlanFiles planFiles, + PlanFiles files, Lazy serverInfo, RunnableFactory runnableFactory, PluginLogger logger, @@ -202,7 +202,7 @@ public class SQLiteDB extends SQLDB { ) { this.locale = locale; this.config = config; - this.planFiles = planFiles; + this.files = files; this.serverInfo = serverInfo; this.runnableFactory = runnableFactory; this.logger = logger; @@ -215,7 +215,7 @@ public class SQLiteDB extends SQLDB { } public SQLiteDB usingFileCalled(String fileName) { - return usingFile(planFiles.getFileFromPluginFolder(fileName + ".db")); + return usingFile(files.getFileFromPluginFolder(fileName + ".db")); } public SQLiteDB usingFile(File databaseFile) { diff --git a/Plan/src/main/java/com/djrapitops/plan/system/info/server/ServerInfoFile.java b/Plan/src/main/java/com/djrapitops/plan/system/info/server/ServerInfoFile.java index 4afaa79ef..025f61b96 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/info/server/ServerInfoFile.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/info/server/ServerInfoFile.java @@ -23,16 +23,16 @@ import java.util.UUID; */ public class ServerInfoFile extends Config { - private final PlanFiles planFiles; + private final PlanFiles files; @Inject - public ServerInfoFile(PlanFiles planFiles) { - super(planFiles.getFileFromPluginFolder("ServerInfoFile.yml")); - this.planFiles = planFiles; + public ServerInfoFile(PlanFiles files) { + super(files.getFileFromPluginFolder("ServerInfoFile.yml")); + this.files = files; } public void prepare() throws IOException { - copyDefaults(planFiles.readFromResource("DefaultServerInfoFile.yml")); + copyDefaults(files.readFromResource("DefaultServerInfoFile.yml")); save(); } diff --git a/Plan/src/main/java/com/djrapitops/plan/system/locale/LocaleSystem.java b/Plan/src/main/java/com/djrapitops/plan/system/locale/LocaleSystem.java index cbd164e55..2fe2ebd1a 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/locale/LocaleSystem.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/locale/LocaleSystem.java @@ -28,7 +28,7 @@ import java.util.stream.Collectors; @Singleton public class LocaleSystem implements SubSystem { - private final PlanFiles planFiles; + private final PlanFiles files; private final PlanConfig config; private final PluginLogger logger; private final ErrorHandler errorHandler; @@ -37,12 +37,12 @@ public class LocaleSystem implements SubSystem { @Inject public LocaleSystem( - PlanFiles planFiles, + PlanFiles files, PlanConfig config, PluginLogger logger, ErrorHandler errorHandler ) { - this.planFiles = planFiles; + this.files = files; this.config = config; this.logger = logger; this.errorHandler = errorHandler; @@ -72,7 +72,7 @@ public class LocaleSystem implements SubSystem { @Override public void enable() { - File localeFile = planFiles.getLocaleFile(); + File localeFile = files.getLocaleFile(); if (config.isTrue(Settings.WRITE_NEW_LOCALE)) { writeNewDefaultLocale(localeFile); diff --git a/Plan/src/main/java/com/djrapitops/plan/system/settings/config/BukkitConfigSystem.java b/Plan/src/main/java/com/djrapitops/plan/system/settings/config/BukkitConfigSystem.java index 121b6e97d..7acb04daf 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/settings/config/BukkitConfigSystem.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/settings/config/BukkitConfigSystem.java @@ -25,17 +25,17 @@ public class BukkitConfigSystem extends ConfigSystem { @Inject public BukkitConfigSystem( - PlanFiles planFiles, + PlanFiles files, PlanConfig config, Theme theme, ErrorHandler errorHandler ) { - super(planFiles, config, theme, errorHandler); + super(files, config, theme, errorHandler); } @Override protected void copyDefaults() throws IOException { - config.copyDefaults(planFiles.readFromResource("config.yml")); + config.copyDefaults(files.readFromResource("config.yml")); } @Override diff --git a/Plan/src/main/java/com/djrapitops/plan/system/settings/config/BungeeConfigSystem.java b/Plan/src/main/java/com/djrapitops/plan/system/settings/config/BungeeConfigSystem.java index 1427b8586..001fe9f67 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/settings/config/BungeeConfigSystem.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/settings/config/BungeeConfigSystem.java @@ -25,17 +25,17 @@ public class BungeeConfigSystem extends ConfigSystem { @Inject public BungeeConfigSystem( - PlanFiles planFiles, + PlanFiles files, PlanConfig config, Theme theme, ErrorHandler errorHandler ) { - super(planFiles, config, theme, errorHandler); + super(files, config, theme, errorHandler); } @Override protected void copyDefaults() throws IOException { - config.copyDefaults(planFiles.readFromResource("bungeeconfig.yml")); + config.copyDefaults(files.readFromResource("bungeeconfig.yml")); } @Override diff --git a/Plan/src/main/java/com/djrapitops/plan/system/settings/config/ConfigSystem.java b/Plan/src/main/java/com/djrapitops/plan/system/settings/config/ConfigSystem.java index 39eece6d0..2eacbf7e2 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/settings/config/ConfigSystem.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/settings/config/ConfigSystem.java @@ -24,18 +24,18 @@ import java.io.IOException; @Singleton public abstract class ConfigSystem implements SubSystem { - protected final PlanFiles planFiles; + protected final PlanFiles files; protected final PlanConfig config; protected final Theme theme; protected final ErrorHandler errorHandler; public ConfigSystem( - PlanFiles planFiles, + PlanFiles files, PlanConfig config, Theme theme, ErrorHandler errorHandler ) { - this.planFiles = planFiles; + this.files = files; this.config = config; this.theme = theme; this.errorHandler = errorHandler; diff --git a/Plan/src/main/java/com/djrapitops/plan/system/settings/config/SpongeConfigSystem.java b/Plan/src/main/java/com/djrapitops/plan/system/settings/config/SpongeConfigSystem.java index be0104ce8..7972bf2da 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/settings/config/SpongeConfigSystem.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/settings/config/SpongeConfigSystem.java @@ -25,19 +25,19 @@ public class SpongeConfigSystem extends BukkitConfigSystem { @Inject public SpongeConfigSystem( - PlanFiles planFiles, + PlanFiles files, PlanConfig config, Theme theme, PluginLogger logger, ErrorHandler errorHandler ) { - super(planFiles, config, theme, errorHandler); + super(files, config, theme, errorHandler); this.logger = logger; } @Override public void enable() throws EnableException { - firstInstall = !planFiles.getConfigFile().exists(); + firstInstall = !files.getConfigFile().exists(); super.enable(); config.getNetworkSettings().loadSettingsFromDB(); } diff --git a/Plan/src/main/java/com/djrapitops/plan/system/settings/theme/ThemeConfig.java b/Plan/src/main/java/com/djrapitops/plan/system/settings/theme/ThemeConfig.java index 65db45590..bc609c797 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/settings/theme/ThemeConfig.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/settings/theme/ThemeConfig.java @@ -27,8 +27,8 @@ import java.util.List; public class ThemeConfig extends Config { @Inject - public ThemeConfig(PlanFiles planFiles, PlanConfig config, PluginLogger logger) { - this(getConfigFile(planFiles), getDefaults(planFiles, config, logger)); + public ThemeConfig(PlanFiles files, PlanConfig config, PluginLogger logger) { + this(getConfigFile(files), getDefaults(files, config, logger)); } private ThemeConfig(File configFile, List defaults) { @@ -43,12 +43,12 @@ public class ThemeConfig extends Config { } } - private static List getDefaults(PlanFiles planFiles, PlanConfig config, PluginLogger logger) { + private static List getDefaults(PlanFiles files, PlanConfig config, PluginLogger logger) { String fileName = config.getString(Settings.THEME_BASE); String fileLocation = getFileLocation(fileName); try { - return planFiles.readFromResource(fileLocation); + return files.readFromResource(fileLocation); } catch (IOException e) { logger.error("Could not find theme " + fileLocation + ". Attempting to use default."); return new ArrayList<>(); @@ -82,7 +82,7 @@ public class ThemeConfig extends Config { } } - private static File getConfigFile(PlanFiles planFiles) { - return planFiles.getFileFromPluginFolder("theme.yml"); + private static File getConfigFile(PlanFiles files) { + return files.getFileFromPluginFolder("theme.yml"); } } diff --git a/Plan/src/main/java/com/djrapitops/plan/system/webserver/WebServer.java b/Plan/src/main/java/com/djrapitops/plan/system/webserver/WebServer.java index 94314efe1..3161bc2e5 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/webserver/WebServer.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/webserver/WebServer.java @@ -40,7 +40,7 @@ import java.util.concurrent.TimeUnit; public class WebServer implements SubSystem { private final Locale locale; - private final PlanFiles planFiles; + private final PlanFiles files; private final PlanConfig config; private final ServerProperties serverProperties; @@ -58,7 +58,7 @@ public class WebServer implements SubSystem { @Inject public WebServer( Locale locale, - PlanFiles planFiles, + PlanFiles files, PlanConfig config, ServerProperties serverProperties, PluginLogger logger, @@ -66,7 +66,7 @@ public class WebServer implements SubSystem { RequestHandler requestHandler ) { this.locale = locale; - this.planFiles = planFiles; + this.files = files; this.config = config; this.serverProperties = serverProperties; @@ -136,7 +136,7 @@ public class WebServer implements SubSystem { private boolean startHttpsServer() { String keyStorePath = config.getString(Settings.WEBSERVER_CERTIFICATE_PATH); if (!Paths.get(keyStorePath).isAbsolute()) { - keyStorePath = planFiles.getDataFolder() + File.separator + keyStorePath; + keyStorePath = files.getDataFolder() + File.separator + keyStorePath; } char[] storepass = config.getString(Settings.WEBSERVER_CERTIFICATE_STOREPASS).toCharArray(); diff --git a/Plan/src/main/java/com/djrapitops/plan/system/webserver/response/CSSResponse.java b/Plan/src/main/java/com/djrapitops/plan/system/webserver/response/CSSResponse.java index 2613bf3af..ecfa36cae 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/webserver/response/CSSResponse.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/webserver/response/CSSResponse.java @@ -1,5 +1,7 @@ package com.djrapitops.plan.system.webserver.response; +import com.djrapitops.plan.system.file.PlanFiles; + import java.io.IOException; /** @@ -8,8 +10,8 @@ import java.io.IOException; */ public class CSSResponse extends FileResponse { - public CSSResponse(String fileName) throws IOException { - super(format(fileName)); + public CSSResponse(String fileName, PlanFiles files) throws IOException { + super(format(fileName), files); super.setType(ResponseType.CSS); setContent(getContent()); } diff --git a/Plan/src/main/java/com/djrapitops/plan/system/webserver/response/FileResponse.java b/Plan/src/main/java/com/djrapitops/plan/system/webserver/response/FileResponse.java index 58c5ce4df..1c07bab5a 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/webserver/response/FileResponse.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/webserver/response/FileResponse.java @@ -19,12 +19,9 @@ import java.io.IOException; */ public class FileResponse extends Response { - // TODO - private PlanFiles planFiles; - - public FileResponse(String fileName) throws IOException { + public FileResponse(String fileName, PlanFiles files) throws IOException { super.setHeader("HTTP/1.1 200 OK"); - super.setContent(planFiles.readCustomizableResourceFlat(fileName)); + super.setContent(files.readCustomizableResourceFlat(fileName)); } public static String format(String fileName) { diff --git a/Plan/src/main/java/com/djrapitops/plan/system/webserver/response/JavaScriptResponse.java b/Plan/src/main/java/com/djrapitops/plan/system/webserver/response/JavaScriptResponse.java index 997606845..aa31e00fd 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/webserver/response/JavaScriptResponse.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/webserver/response/JavaScriptResponse.java @@ -1,5 +1,7 @@ package com.djrapitops.plan.system.webserver.response; +import com.djrapitops.plan.system.file.PlanFiles; + import java.io.IOException; /** @@ -8,8 +10,8 @@ import java.io.IOException; */ public class JavaScriptResponse extends FileResponse { - JavaScriptResponse(String fileName) throws IOException { - super(format(fileName)); + JavaScriptResponse(String fileName, PlanFiles files) throws IOException { + super(format(fileName), files); super.setType(ResponseType.JAVASCRIPT); } } diff --git a/Plan/src/main/java/com/djrapitops/plan/system/webserver/response/ResponseFactory.java b/Plan/src/main/java/com/djrapitops/plan/system/webserver/response/ResponseFactory.java index 1775b1488..8966ca421 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/webserver/response/ResponseFactory.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/webserver/response/ResponseFactory.java @@ -97,7 +97,7 @@ public class ResponseFactory { public Response javaScriptResponse(String fileName) { try { - return new JavaScriptResponse(fileName); + return new JavaScriptResponse(fileName, files); } catch (IOException e) { return notFound404("JS File not found from jar: " + fileName + ", " + e.toString()); } @@ -105,7 +105,7 @@ public class ResponseFactory { public Response cssResponse(String fileName) { try { - return new CSSResponse(fileName); + return new CSSResponse(fileName, files); } catch (IOException e) { return notFound404("CSS File not found from jar: " + fileName + ", " + e.toString()); } diff --git a/Plan/src/main/java/com/djrapitops/plan/system/webserver/response/errors/ErrorResponse.java b/Plan/src/main/java/com/djrapitops/plan/system/webserver/response/errors/ErrorResponse.java index b1f6d6c4c..5cd3f4611 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/webserver/response/errors/ErrorResponse.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/webserver/response/errors/ErrorResponse.java @@ -24,9 +24,9 @@ public class ErrorResponse extends Response { private String version; - public ErrorResponse(String version, PlanFiles planFiles) throws IOException { + public ErrorResponse(String version, PlanFiles files) throws IOException { this.version = version; - setContent(planFiles.readCustomizableResourceFlat("web/error.html")); + setContent(files.readCustomizableResourceFlat("web/error.html")); } public ErrorResponse(String message) { diff --git a/Plan/src/main/java/com/djrapitops/plan/utilities/file/export/HtmlExport.java b/Plan/src/main/java/com/djrapitops/plan/utilities/file/export/HtmlExport.java index e83f26ad6..5bacdec75 100644 --- a/Plan/src/main/java/com/djrapitops/plan/utilities/file/export/HtmlExport.java +++ b/Plan/src/main/java/com/djrapitops/plan/utilities/file/export/HtmlExport.java @@ -42,7 +42,7 @@ public class HtmlExport extends SpecificExport { private final PlanPlugin plugin; private final Theme theme; private final Processing processing; - private final PlanFiles planFiles; + private final PlanFiles files; private final Database database; private final PageFactory pageFactory; private final ConnectionSystem connectionSystem; @@ -51,7 +51,7 @@ public class HtmlExport extends SpecificExport { @Inject public HtmlExport( PlanPlugin plugin, - PlanFiles planFiles, + PlanFiles files, PlanConfig config, Theme theme, Processing processing, @@ -61,11 +61,11 @@ public class HtmlExport extends SpecificExport { ConnectionSystem connectionSystem, ErrorHandler errorHandler ) { - super(planFiles, config, serverInfo); + super(files, config, serverInfo); this.plugin = plugin; this.theme = theme; this.processing = processing; - this.planFiles = planFiles; + this.files = files; this.database = database; this.pageFactory = pageFactory; this.connectionSystem = connectionSystem; @@ -186,7 +186,7 @@ public class HtmlExport extends SpecificExport { copyFromJar(resources); try { - String demo = planFiles.readFromResourceFlat("web/js/demo.js") + String demo = files.readFromResourceFlat("web/js/demo.js") .replace("${defaultTheme}", theme.getValue(ThemeVal.THEME_DEFAULT)); List lines = Arrays.asList(demo.split("\n")); File outputFolder = new File(this.outputFolder, "js"); diff --git a/Plan/src/main/java/com/djrapitops/plan/utilities/file/export/SpecificExport.java b/Plan/src/main/java/com/djrapitops/plan/utilities/file/export/SpecificExport.java index 02db3de78..7d4fb6f1c 100644 --- a/Plan/src/main/java/com/djrapitops/plan/utilities/file/export/SpecificExport.java +++ b/Plan/src/main/java/com/djrapitops/plan/utilities/file/export/SpecificExport.java @@ -29,7 +29,7 @@ import java.util.UUID; */ public abstract class SpecificExport implements Runnable { - private final PlanFiles planFiles; + private final PlanFiles files; private final PlanConfig config; private final ServerInfo serverInfo; @@ -37,11 +37,11 @@ public abstract class SpecificExport implements Runnable { private final boolean usingBungee; protected SpecificExport( - PlanFiles planFiles, + PlanFiles files, PlanConfig config, ServerInfo serverInfo ) { - this.planFiles = planFiles; + this.files = files; this.config = config; this.serverInfo = serverInfo; outputFolder = getFolder(); @@ -56,7 +56,7 @@ public abstract class SpecificExport implements Runnable { if (isAbsolute) { folder = new File(path); } else { - File dataFolder = planFiles.getDataFolder(); + File dataFolder = files.getDataFolder(); folder = new File(dataFolder, path); } diff --git a/Plan/src/main/java/com/djrapitops/plan/utilities/html/pages/AnalysisPage.java b/Plan/src/main/java/com/djrapitops/plan/utilities/html/pages/AnalysisPage.java index c7c7d7b5d..ae00333de 100644 --- a/Plan/src/main/java/com/djrapitops/plan/utilities/html/pages/AnalysisPage.java +++ b/Plan/src/main/java/com/djrapitops/plan/utilities/html/pages/AnalysisPage.java @@ -28,16 +28,16 @@ public class AnalysisPage implements Page { private final AnalysisContainer analysisContainer; - private final PlanFiles planFiles; + private final PlanFiles files; private final Formatter decimalFormatter; AnalysisPage( AnalysisContainer analysisContainer, - PlanFiles planFiles, + PlanFiles files, Formatter decimalFormatter ) { this.analysisContainer = analysisContainer; - this.planFiles = planFiles; + this.files = files; this.decimalFormatter = decimalFormatter; } @@ -79,7 +79,7 @@ public class AnalysisPage implements Page { performanceNumbers(placeholderReplacer); try { - return placeholderReplacer.apply(planFiles.readCustomizableResourceFlat("web/server.html")); + return placeholderReplacer.apply(files.readCustomizableResourceFlat("web/server.html")); } catch (IOException e) { throw new ParseException(e); } finally { diff --git a/Plan/src/main/java/com/djrapitops/plan/utilities/html/pages/InspectPage.java b/Plan/src/main/java/com/djrapitops/plan/utilities/html/pages/InspectPage.java index e6c2f3e3f..9ddabfbc5 100644 --- a/Plan/src/main/java/com/djrapitops/plan/utilities/html/pages/InspectPage.java +++ b/Plan/src/main/java/com/djrapitops/plan/utilities/html/pages/InspectPage.java @@ -48,7 +48,7 @@ public class InspectPage implements Page { private final String version; - private final PlanFiles planFiles; + private final PlanFiles files; private final PlanConfig config; private final Theme theme; private final Graphs graphs; @@ -65,7 +65,7 @@ public class InspectPage implements Page { InspectPage( PlayerContainer player, Map serverNames, String version, - PlanFiles planFiles, + PlanFiles files, PlanConfig config, Theme theme, Graphs graphs, @@ -78,7 +78,7 @@ public class InspectPage implements Page { this.player = player; this.serverNames = serverNames; this.version = version; - this.planFiles = planFiles; + this.files = files; this.config = config; this.theme = theme; this.graphs = graphs; @@ -231,7 +231,7 @@ public class InspectPage implements Page { : serverName ); - return replacer.apply(planFiles.readCustomizableResourceFlat("web/player.html")); + return replacer.apply(files.readCustomizableResourceFlat("web/player.html")); } private void sessionsAndPlaytime(PlaceholderReplacer replacer, SessionsMutator sessionsMutator, SessionsMutator daySessionsMutator, SessionsMutator weekSessionsMutator, SessionsMutator monthSessionsMutator) { diff --git a/Plan/src/main/java/com/djrapitops/plan/utilities/html/pages/NetworkPage.java b/Plan/src/main/java/com/djrapitops/plan/utilities/html/pages/NetworkPage.java index bf4e2ad63..6c87ed2a0 100644 --- a/Plan/src/main/java/com/djrapitops/plan/utilities/html/pages/NetworkPage.java +++ b/Plan/src/main/java/com/djrapitops/plan/utilities/html/pages/NetworkPage.java @@ -25,16 +25,16 @@ public class NetworkPage implements Page { private final NetworkContainer networkContainer; - private final PlanFiles planFiles; + private final PlanFiles files; private final ServerProperties serverProperties; public NetworkPage( NetworkContainer networkContainer, - PlanFiles planFiles, + PlanFiles files, ServerProperties serverProperties ) { this.networkContainer = networkContainer; - this.planFiles = planFiles; + this.files = files; this.serverProperties = serverProperties; } @@ -60,7 +60,7 @@ public class NetworkPage implements Page { ResponseCache.loadResponse(PageId.NETWORK_CONTENT.id(), NetworkPageContent::new); placeholderReplacer.put("tabContentServers", networkPageContent.getContents()); - return placeholderReplacer.apply(planFiles.readCustomizableResourceFlat("web/network.html")); + return placeholderReplacer.apply(files.readCustomizableResourceFlat("web/network.html")); } catch (Exception e) { throw new ParseException(e); } diff --git a/Plan/src/main/java/com/djrapitops/plan/utilities/html/pages/PlayersPage.java b/Plan/src/main/java/com/djrapitops/plan/utilities/html/pages/PlayersPage.java index 4e7e82e91..3e55037d5 100644 --- a/Plan/src/main/java/com/djrapitops/plan/utilities/html/pages/PlayersPage.java +++ b/Plan/src/main/java/com/djrapitops/plan/utilities/html/pages/PlayersPage.java @@ -22,7 +22,7 @@ import java.util.List; public class PlayersPage implements Page { private final String version; - private final PlanFiles planFiles; + private final PlanFiles files; private final PlanConfig config; private final Database database; private final ServerInfo serverInfo; @@ -33,7 +33,7 @@ public class PlayersPage implements Page { PlayersPage( String version, - PlanFiles planFiles, + PlanFiles files, PlanConfig config, Database database, ServerInfo serverInfo, @@ -41,7 +41,7 @@ public class PlayersPage implements Page { Timings timings ) { this.version = version; - this.planFiles = planFiles; + this.files = files; this.config = config; this.database = database; this.serverInfo = serverInfo; @@ -66,7 +66,7 @@ public class PlayersPage implements Page { placeholderReplacer.put("playersTable", tables.playerTableForPlayersPage(playerContainers).parseHtml()); timings.end("Pages", "Players page players table parsing"); - return placeholderReplacer.apply(planFiles.readCustomizableResourceFlat("web/players.html")); + return placeholderReplacer.apply(files.readCustomizableResourceFlat("web/players.html")); } catch (Exception e) { throw new ParseException(e); } diff --git a/Plan/src/test/java/com/djrapitops/plan/system/cache/GeolocationCacheTest.java b/Plan/src/test/java/com/djrapitops/plan/system/cache/GeolocationCacheTest.java index d0d84ac14..0daeff51b 100644 --- a/Plan/src/test/java/com/djrapitops/plan/system/cache/GeolocationCacheTest.java +++ b/Plan/src/test/java/com/djrapitops/plan/system/cache/GeolocationCacheTest.java @@ -30,7 +30,7 @@ public class GeolocationCacheTest { private final Map ipsToCountries = new HashMap<>(); @Mock - private PlanFiles planFiles; + private PlanFiles files; @Mock private PlanConfig config; private GeolocationCache geolocationCache; @@ -47,8 +47,8 @@ public class GeolocationCacheTest { @Before public void setUp() throws IOException { - doReturn(temporaryFolder.newFile("GeoIP.dat")).when(planFiles.getFileFromPluginFolder("GeoIP.dat")); - geolocationCache = new GeolocationCache(new Locale(), planFiles, config, new TestPluginLogger()); + doReturn(temporaryFolder.newFile("GeoIP.dat")).when(files.getFileFromPluginFolder("GeoIP.dat")); + geolocationCache = new GeolocationCache(new Locale(), files, config, new TestPluginLogger()); ipsToCountries.put("8.8.8.8", "United States"); ipsToCountries.put("8.8.4.4", "United States");