[Debt] Added PlanFiles to FileResponse constructor

ResponseFactory provides the Response objects this dependency.
Renamed all occurrences of "planFiles" -> "files"
This commit is contained in:
Rsl1122 2018-09-29 12:44:56 +03:00
parent 9b9443adf4
commit aeec459ee9
25 changed files with 93 additions and 92 deletions

View File

@ -35,7 +35,7 @@ public class ManageRestoreCommand extends CommandNode {
private final DBSystem dbSystem; private final DBSystem dbSystem;
private final ErrorHandler errorHandler; private final ErrorHandler errorHandler;
private final SQLiteDB.Factory sqliteFactory; private final SQLiteDB.Factory sqliteFactory;
private final PlanFiles planFiles; private final PlanFiles files;
@Inject @Inject
public ManageRestoreCommand( public ManageRestoreCommand(
@ -43,7 +43,7 @@ public class ManageRestoreCommand extends CommandNode {
Processing processing, Processing processing,
DBSystem dbSystem, DBSystem dbSystem,
SQLiteDB.Factory sqliteFactory, SQLiteDB.Factory sqliteFactory,
PlanFiles planFiles, PlanFiles files,
ErrorHandler errorHandler ErrorHandler errorHandler
) { ) {
super("restore", Permissions.MANAGE.getPermission(), CommandType.CONSOLE); super("restore", Permissions.MANAGE.getPermission(), CommandType.CONSOLE);
@ -52,7 +52,7 @@ public class ManageRestoreCommand extends CommandNode {
this.processing = processing; this.processing = processing;
this.dbSystem = dbSystem; this.dbSystem = dbSystem;
this.sqliteFactory = sqliteFactory; this.sqliteFactory = sqliteFactory;
this.planFiles = planFiles; this.files = files;
this.errorHandler = errorHandler; this.errorHandler = errorHandler;
setArguments("<Filename.db>", "<dbTo>", "[-a]"); setArguments("<Filename.db>", "<dbTo>", "[-a]");
@ -96,7 +96,7 @@ public class ManageRestoreCommand extends CommandNode {
String backupDBName = backupDbName; String backupDBName = backupDbName;
boolean containsDBFileExtension = backupDBName.endsWith(".db"); boolean containsDBFileExtension = backupDBName.endsWith(".db");
File backupDBFile = planFiles.getFileFromPluginFolder(backupDBName + (containsDBFileExtension ? "" : ".db")); File backupDBFile = files.getFileFromPluginFolder(backupDBName + (containsDBFileExtension ? "" : ".db"));
if (!backupDBFile.exists()) { if (!backupDBFile.exists()) {
sender.sendMessage(locale.getString(ManageLang.FAIL_FILE_NOT_FOUND, backupDBFile.getAbsolutePath())); sender.sendMessage(locale.getString(ManageLang.FAIL_FILE_NOT_FOUND, backupDBFile.getAbsolutePath()));

View File

@ -19,8 +19,8 @@ public class FilesModule {
@Provides @Provides
@Named("configFile") @Named("configFile")
@Singleton @Singleton
File provideConfigFile(PlanFiles planFiles) { File provideConfigFile(PlanFiles files) {
return planFiles.getConfigFile(); return files.getConfigFile();
} }
} }

View File

@ -38,7 +38,7 @@ import javax.inject.Singleton;
@Singleton @Singleton
public class PlanSystem implements SubSystem { public class PlanSystem implements SubSystem {
private final PlanFiles planFiles; private final PlanFiles files;
private final ConfigSystem configSystem; private final ConfigSystem configSystem;
private final VersionCheckSystem versionCheckSystem; private final VersionCheckSystem versionCheckSystem;
private final LocaleSystem localeSystem; private final LocaleSystem localeSystem;
@ -60,7 +60,7 @@ public class PlanSystem implements SubSystem {
@Inject @Inject
public PlanSystem( public PlanSystem(
PlanFiles planFiles, PlanFiles files,
ConfigSystem configSystem, ConfigSystem configSystem,
VersionCheckSystem versionCheckSystem, VersionCheckSystem versionCheckSystem,
LocaleSystem localeSystem, LocaleSystem localeSystem,
@ -78,7 +78,7 @@ public class PlanSystem implements SubSystem {
PlanAPI planAPI, PlanAPI planAPI,
ErrorHandler errorHandler ErrorHandler errorHandler
) { ) {
this.planFiles = planFiles; this.files = files;
this.configSystem = configSystem; this.configSystem = configSystem;
this.versionCheckSystem = versionCheckSystem; this.versionCheckSystem = versionCheckSystem;
this.localeSystem = localeSystem; this.localeSystem = localeSystem;
@ -105,7 +105,7 @@ public class PlanSystem implements SubSystem {
@Override @Override
public void enable() throws EnableException { public void enable() throws EnableException {
enableSystems( enableSystems(
planFiles, files,
configSystem, configSystem,
localeSystem, localeSystem,
versionCheckSystem, versionCheckSystem,
@ -143,7 +143,7 @@ public class PlanSystem implements SubSystem {
serverInfo, serverInfo,
localeSystem, localeSystem,
configSystem, configSystem,
planFiles, files,
versionCheckSystem versionCheckSystem
); );
} }
@ -171,7 +171,7 @@ public class PlanSystem implements SubSystem {
} }
public PlanFiles getPlanFiles() { public PlanFiles getPlanFiles() {
return planFiles; return files;
} }
public DBSystem getDatabaseSystem() { public DBSystem getDatabaseSystem() {

View File

@ -40,7 +40,7 @@ import java.util.zip.GZIPInputStream;
public class GeolocationCache implements SubSystem { public class GeolocationCache implements SubSystem {
private final Locale locale; private final Locale locale;
private final PlanFiles planFiles; private final PlanFiles files;
private final PlanConfig config; private final PlanConfig config;
private final PluginLogger logger; private final PluginLogger logger;
private final Map<String, String> cached; private final Map<String, String> cached;
@ -50,12 +50,12 @@ public class GeolocationCache implements SubSystem {
@Inject @Inject
public GeolocationCache( public GeolocationCache(
Locale locale, Locale locale,
PlanFiles planFiles, PlanFiles files,
PlanConfig config, PlanConfig config,
PluginLogger logger PluginLogger logger
) { ) {
this.locale = locale; this.locale = locale;
this.planFiles = planFiles; this.files = files;
this.config = config; this.config = config;
this.logger = logger; this.logger = logger;
@ -64,7 +64,7 @@ public class GeolocationCache implements SubSystem {
@Override @Override
public void enable() throws EnableException { public void enable() throws EnableException {
geolocationDB = planFiles.getFileFromPluginFolder("GeoIP.dat"); geolocationDB = files.getFileFromPluginFolder("GeoIP.dat");
if (config.isTrue(Settings.DATA_GEOLOCATIONS)) { if (config.isTrue(Settings.DATA_GEOLOCATIONS)) {
try { try {
checkDB(); checkDB();

View File

@ -187,13 +187,13 @@ public class SQLiteDB extends SQLDB {
private final PluginLogger logger; private final PluginLogger logger;
private final Timings timings; private final Timings timings;
private final ErrorHandler errorHandler; private final ErrorHandler errorHandler;
private PlanFiles planFiles; private PlanFiles files;
@Inject @Inject
public Factory( public Factory(
Locale locale, Locale locale,
PlanConfig config, PlanConfig config,
PlanFiles planFiles, PlanFiles files,
Lazy<ServerInfo> serverInfo, Lazy<ServerInfo> serverInfo,
RunnableFactory runnableFactory, RunnableFactory runnableFactory,
PluginLogger logger, PluginLogger logger,
@ -202,7 +202,7 @@ public class SQLiteDB extends SQLDB {
) { ) {
this.locale = locale; this.locale = locale;
this.config = config; this.config = config;
this.planFiles = planFiles; this.files = files;
this.serverInfo = serverInfo; this.serverInfo = serverInfo;
this.runnableFactory = runnableFactory; this.runnableFactory = runnableFactory;
this.logger = logger; this.logger = logger;
@ -215,7 +215,7 @@ public class SQLiteDB extends SQLDB {
} }
public SQLiteDB usingFileCalled(String fileName) { public SQLiteDB usingFileCalled(String fileName) {
return usingFile(planFiles.getFileFromPluginFolder(fileName + ".db")); return usingFile(files.getFileFromPluginFolder(fileName + ".db"));
} }
public SQLiteDB usingFile(File databaseFile) { public SQLiteDB usingFile(File databaseFile) {

View File

@ -23,16 +23,16 @@ import java.util.UUID;
*/ */
public class ServerInfoFile extends Config { public class ServerInfoFile extends Config {
private final PlanFiles planFiles; private final PlanFiles files;
@Inject @Inject
public ServerInfoFile(PlanFiles planFiles) { public ServerInfoFile(PlanFiles files) {
super(planFiles.getFileFromPluginFolder("ServerInfoFile.yml")); super(files.getFileFromPluginFolder("ServerInfoFile.yml"));
this.planFiles = planFiles; this.files = files;
} }
public void prepare() throws IOException { public void prepare() throws IOException {
copyDefaults(planFiles.readFromResource("DefaultServerInfoFile.yml")); copyDefaults(files.readFromResource("DefaultServerInfoFile.yml"));
save(); save();
} }

View File

@ -28,7 +28,7 @@ import java.util.stream.Collectors;
@Singleton @Singleton
public class LocaleSystem implements SubSystem { public class LocaleSystem implements SubSystem {
private final PlanFiles planFiles; private final PlanFiles files;
private final PlanConfig config; private final PlanConfig config;
private final PluginLogger logger; private final PluginLogger logger;
private final ErrorHandler errorHandler; private final ErrorHandler errorHandler;
@ -37,12 +37,12 @@ public class LocaleSystem implements SubSystem {
@Inject @Inject
public LocaleSystem( public LocaleSystem(
PlanFiles planFiles, PlanFiles files,
PlanConfig config, PlanConfig config,
PluginLogger logger, PluginLogger logger,
ErrorHandler errorHandler ErrorHandler errorHandler
) { ) {
this.planFiles = planFiles; this.files = files;
this.config = config; this.config = config;
this.logger = logger; this.logger = logger;
this.errorHandler = errorHandler; this.errorHandler = errorHandler;
@ -72,7 +72,7 @@ public class LocaleSystem implements SubSystem {
@Override @Override
public void enable() { public void enable() {
File localeFile = planFiles.getLocaleFile(); File localeFile = files.getLocaleFile();
if (config.isTrue(Settings.WRITE_NEW_LOCALE)) { if (config.isTrue(Settings.WRITE_NEW_LOCALE)) {
writeNewDefaultLocale(localeFile); writeNewDefaultLocale(localeFile);

View File

@ -25,17 +25,17 @@ public class BukkitConfigSystem extends ConfigSystem {
@Inject @Inject
public BukkitConfigSystem( public BukkitConfigSystem(
PlanFiles planFiles, PlanFiles files,
PlanConfig config, PlanConfig config,
Theme theme, Theme theme,
ErrorHandler errorHandler ErrorHandler errorHandler
) { ) {
super(planFiles, config, theme, errorHandler); super(files, config, theme, errorHandler);
} }
@Override @Override
protected void copyDefaults() throws IOException { protected void copyDefaults() throws IOException {
config.copyDefaults(planFiles.readFromResource("config.yml")); config.copyDefaults(files.readFromResource("config.yml"));
} }
@Override @Override

View File

@ -25,17 +25,17 @@ public class BungeeConfigSystem extends ConfigSystem {
@Inject @Inject
public BungeeConfigSystem( public BungeeConfigSystem(
PlanFiles planFiles, PlanFiles files,
PlanConfig config, PlanConfig config,
Theme theme, Theme theme,
ErrorHandler errorHandler ErrorHandler errorHandler
) { ) {
super(planFiles, config, theme, errorHandler); super(files, config, theme, errorHandler);
} }
@Override @Override
protected void copyDefaults() throws IOException { protected void copyDefaults() throws IOException {
config.copyDefaults(planFiles.readFromResource("bungeeconfig.yml")); config.copyDefaults(files.readFromResource("bungeeconfig.yml"));
} }
@Override @Override

View File

@ -24,18 +24,18 @@ import java.io.IOException;
@Singleton @Singleton
public abstract class ConfigSystem implements SubSystem { public abstract class ConfigSystem implements SubSystem {
protected final PlanFiles planFiles; protected final PlanFiles files;
protected final PlanConfig config; protected final PlanConfig config;
protected final Theme theme; protected final Theme theme;
protected final ErrorHandler errorHandler; protected final ErrorHandler errorHandler;
public ConfigSystem( public ConfigSystem(
PlanFiles planFiles, PlanFiles files,
PlanConfig config, PlanConfig config,
Theme theme, Theme theme,
ErrorHandler errorHandler ErrorHandler errorHandler
) { ) {
this.planFiles = planFiles; this.files = files;
this.config = config; this.config = config;
this.theme = theme; this.theme = theme;
this.errorHandler = errorHandler; this.errorHandler = errorHandler;

View File

@ -25,19 +25,19 @@ public class SpongeConfigSystem extends BukkitConfigSystem {
@Inject @Inject
public SpongeConfigSystem( public SpongeConfigSystem(
PlanFiles planFiles, PlanFiles files,
PlanConfig config, PlanConfig config,
Theme theme, Theme theme,
PluginLogger logger, PluginLogger logger,
ErrorHandler errorHandler ErrorHandler errorHandler
) { ) {
super(planFiles, config, theme, errorHandler); super(files, config, theme, errorHandler);
this.logger = logger; this.logger = logger;
} }
@Override @Override
public void enable() throws EnableException { public void enable() throws EnableException {
firstInstall = !planFiles.getConfigFile().exists(); firstInstall = !files.getConfigFile().exists();
super.enable(); super.enable();
config.getNetworkSettings().loadSettingsFromDB(); config.getNetworkSettings().loadSettingsFromDB();
} }

View File

@ -27,8 +27,8 @@ import java.util.List;
public class ThemeConfig extends Config { public class ThemeConfig extends Config {
@Inject @Inject
public ThemeConfig(PlanFiles planFiles, PlanConfig config, PluginLogger logger) { public ThemeConfig(PlanFiles files, PlanConfig config, PluginLogger logger) {
this(getConfigFile(planFiles), getDefaults(planFiles, config, logger)); this(getConfigFile(files), getDefaults(files, config, logger));
} }
private ThemeConfig(File configFile, List<String> defaults) { private ThemeConfig(File configFile, List<String> defaults) {
@ -43,12 +43,12 @@ public class ThemeConfig extends Config {
} }
} }
private static List<String> getDefaults(PlanFiles planFiles, PlanConfig config, PluginLogger logger) { private static List<String> getDefaults(PlanFiles files, PlanConfig config, PluginLogger logger) {
String fileName = config.getString(Settings.THEME_BASE); String fileName = config.getString(Settings.THEME_BASE);
String fileLocation = getFileLocation(fileName); String fileLocation = getFileLocation(fileName);
try { try {
return planFiles.readFromResource(fileLocation); return files.readFromResource(fileLocation);
} catch (IOException e) { } catch (IOException e) {
logger.error("Could not find theme " + fileLocation + ". Attempting to use default."); logger.error("Could not find theme " + fileLocation + ". Attempting to use default.");
return new ArrayList<>(); return new ArrayList<>();
@ -82,7 +82,7 @@ public class ThemeConfig extends Config {
} }
} }
private static File getConfigFile(PlanFiles planFiles) { private static File getConfigFile(PlanFiles files) {
return planFiles.getFileFromPluginFolder("theme.yml"); return files.getFileFromPluginFolder("theme.yml");
} }
} }

View File

@ -40,7 +40,7 @@ import java.util.concurrent.TimeUnit;
public class WebServer implements SubSystem { public class WebServer implements SubSystem {
private final Locale locale; private final Locale locale;
private final PlanFiles planFiles; private final PlanFiles files;
private final PlanConfig config; private final PlanConfig config;
private final ServerProperties serverProperties; private final ServerProperties serverProperties;
@ -58,7 +58,7 @@ public class WebServer implements SubSystem {
@Inject @Inject
public WebServer( public WebServer(
Locale locale, Locale locale,
PlanFiles planFiles, PlanFiles files,
PlanConfig config, PlanConfig config,
ServerProperties serverProperties, ServerProperties serverProperties,
PluginLogger logger, PluginLogger logger,
@ -66,7 +66,7 @@ public class WebServer implements SubSystem {
RequestHandler requestHandler RequestHandler requestHandler
) { ) {
this.locale = locale; this.locale = locale;
this.planFiles = planFiles; this.files = files;
this.config = config; this.config = config;
this.serverProperties = serverProperties; this.serverProperties = serverProperties;
@ -136,7 +136,7 @@ public class WebServer implements SubSystem {
private boolean startHttpsServer() { private boolean startHttpsServer() {
String keyStorePath = config.getString(Settings.WEBSERVER_CERTIFICATE_PATH); String keyStorePath = config.getString(Settings.WEBSERVER_CERTIFICATE_PATH);
if (!Paths.get(keyStorePath).isAbsolute()) { 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(); char[] storepass = config.getString(Settings.WEBSERVER_CERTIFICATE_STOREPASS).toCharArray();

View File

@ -1,5 +1,7 @@
package com.djrapitops.plan.system.webserver.response; package com.djrapitops.plan.system.webserver.response;
import com.djrapitops.plan.system.file.PlanFiles;
import java.io.IOException; import java.io.IOException;
/** /**
@ -8,8 +10,8 @@ import java.io.IOException;
*/ */
public class CSSResponse extends FileResponse { public class CSSResponse extends FileResponse {
public CSSResponse(String fileName) throws IOException { public CSSResponse(String fileName, PlanFiles files) throws IOException {
super(format(fileName)); super(format(fileName), files);
super.setType(ResponseType.CSS); super.setType(ResponseType.CSS);
setContent(getContent()); setContent(getContent());
} }

View File

@ -19,12 +19,9 @@ import java.io.IOException;
*/ */
public class FileResponse extends Response { public class FileResponse extends Response {
// TODO public FileResponse(String fileName, PlanFiles files) throws IOException {
private PlanFiles planFiles;
public FileResponse(String fileName) throws IOException {
super.setHeader("HTTP/1.1 200 OK"); super.setHeader("HTTP/1.1 200 OK");
super.setContent(planFiles.readCustomizableResourceFlat(fileName)); super.setContent(files.readCustomizableResourceFlat(fileName));
} }
public static String format(String fileName) { public static String format(String fileName) {

View File

@ -1,5 +1,7 @@
package com.djrapitops.plan.system.webserver.response; package com.djrapitops.plan.system.webserver.response;
import com.djrapitops.plan.system.file.PlanFiles;
import java.io.IOException; import java.io.IOException;
/** /**
@ -8,8 +10,8 @@ import java.io.IOException;
*/ */
public class JavaScriptResponse extends FileResponse { public class JavaScriptResponse extends FileResponse {
JavaScriptResponse(String fileName) throws IOException { JavaScriptResponse(String fileName, PlanFiles files) throws IOException {
super(format(fileName)); super(format(fileName), files);
super.setType(ResponseType.JAVASCRIPT); super.setType(ResponseType.JAVASCRIPT);
} }
} }

View File

@ -97,7 +97,7 @@ public class ResponseFactory {
public Response javaScriptResponse(String fileName) { public Response javaScriptResponse(String fileName) {
try { try {
return new JavaScriptResponse(fileName); return new JavaScriptResponse(fileName, files);
} catch (IOException e) { } catch (IOException e) {
return notFound404("JS File not found from jar: " + fileName + ", " + e.toString()); return notFound404("JS File not found from jar: " + fileName + ", " + e.toString());
} }
@ -105,7 +105,7 @@ public class ResponseFactory {
public Response cssResponse(String fileName) { public Response cssResponse(String fileName) {
try { try {
return new CSSResponse(fileName); return new CSSResponse(fileName, files);
} catch (IOException e) { } catch (IOException e) {
return notFound404("CSS File not found from jar: " + fileName + ", " + e.toString()); return notFound404("CSS File not found from jar: " + fileName + ", " + e.toString());
} }

View File

@ -24,9 +24,9 @@ public class ErrorResponse extends Response {
private String version; private String version;
public ErrorResponse(String version, PlanFiles planFiles) throws IOException { public ErrorResponse(String version, PlanFiles files) throws IOException {
this.version = version; this.version = version;
setContent(planFiles.readCustomizableResourceFlat("web/error.html")); setContent(files.readCustomizableResourceFlat("web/error.html"));
} }
public ErrorResponse(String message) { public ErrorResponse(String message) {

View File

@ -42,7 +42,7 @@ public class HtmlExport extends SpecificExport {
private final PlanPlugin plugin; private final PlanPlugin plugin;
private final Theme theme; private final Theme theme;
private final Processing processing; private final Processing processing;
private final PlanFiles planFiles; private final PlanFiles files;
private final Database database; private final Database database;
private final PageFactory pageFactory; private final PageFactory pageFactory;
private final ConnectionSystem connectionSystem; private final ConnectionSystem connectionSystem;
@ -51,7 +51,7 @@ public class HtmlExport extends SpecificExport {
@Inject @Inject
public HtmlExport( public HtmlExport(
PlanPlugin plugin, PlanPlugin plugin,
PlanFiles planFiles, PlanFiles files,
PlanConfig config, PlanConfig config,
Theme theme, Theme theme,
Processing processing, Processing processing,
@ -61,11 +61,11 @@ public class HtmlExport extends SpecificExport {
ConnectionSystem connectionSystem, ConnectionSystem connectionSystem,
ErrorHandler errorHandler ErrorHandler errorHandler
) { ) {
super(planFiles, config, serverInfo); super(files, config, serverInfo);
this.plugin = plugin; this.plugin = plugin;
this.theme = theme; this.theme = theme;
this.processing = processing; this.processing = processing;
this.planFiles = planFiles; this.files = files;
this.database = database; this.database = database;
this.pageFactory = pageFactory; this.pageFactory = pageFactory;
this.connectionSystem = connectionSystem; this.connectionSystem = connectionSystem;
@ -186,7 +186,7 @@ public class HtmlExport extends SpecificExport {
copyFromJar(resources); copyFromJar(resources);
try { try {
String demo = planFiles.readFromResourceFlat("web/js/demo.js") String demo = files.readFromResourceFlat("web/js/demo.js")
.replace("${defaultTheme}", theme.getValue(ThemeVal.THEME_DEFAULT)); .replace("${defaultTheme}", theme.getValue(ThemeVal.THEME_DEFAULT));
List<String> lines = Arrays.asList(demo.split("\n")); List<String> lines = Arrays.asList(demo.split("\n"));
File outputFolder = new File(this.outputFolder, "js"); File outputFolder = new File(this.outputFolder, "js");

View File

@ -29,7 +29,7 @@ import java.util.UUID;
*/ */
public abstract class SpecificExport implements Runnable { public abstract class SpecificExport implements Runnable {
private final PlanFiles planFiles; private final PlanFiles files;
private final PlanConfig config; private final PlanConfig config;
private final ServerInfo serverInfo; private final ServerInfo serverInfo;
@ -37,11 +37,11 @@ public abstract class SpecificExport implements Runnable {
private final boolean usingBungee; private final boolean usingBungee;
protected SpecificExport( protected SpecificExport(
PlanFiles planFiles, PlanFiles files,
PlanConfig config, PlanConfig config,
ServerInfo serverInfo ServerInfo serverInfo
) { ) {
this.planFiles = planFiles; this.files = files;
this.config = config; this.config = config;
this.serverInfo = serverInfo; this.serverInfo = serverInfo;
outputFolder = getFolder(); outputFolder = getFolder();
@ -56,7 +56,7 @@ public abstract class SpecificExport implements Runnable {
if (isAbsolute) { if (isAbsolute) {
folder = new File(path); folder = new File(path);
} else { } else {
File dataFolder = planFiles.getDataFolder(); File dataFolder = files.getDataFolder();
folder = new File(dataFolder, path); folder = new File(dataFolder, path);
} }

View File

@ -28,16 +28,16 @@ public class AnalysisPage implements Page {
private final AnalysisContainer analysisContainer; private final AnalysisContainer analysisContainer;
private final PlanFiles planFiles; private final PlanFiles files;
private final Formatter<Double> decimalFormatter; private final Formatter<Double> decimalFormatter;
AnalysisPage( AnalysisPage(
AnalysisContainer analysisContainer, AnalysisContainer analysisContainer,
PlanFiles planFiles, PlanFiles files,
Formatter<Double> decimalFormatter Formatter<Double> decimalFormatter
) { ) {
this.analysisContainer = analysisContainer; this.analysisContainer = analysisContainer;
this.planFiles = planFiles; this.files = files;
this.decimalFormatter = decimalFormatter; this.decimalFormatter = decimalFormatter;
} }
@ -79,7 +79,7 @@ public class AnalysisPage implements Page {
performanceNumbers(placeholderReplacer); performanceNumbers(placeholderReplacer);
try { try {
return placeholderReplacer.apply(planFiles.readCustomizableResourceFlat("web/server.html")); return placeholderReplacer.apply(files.readCustomizableResourceFlat("web/server.html"));
} catch (IOException e) { } catch (IOException e) {
throw new ParseException(e); throw new ParseException(e);
} finally { } finally {

View File

@ -48,7 +48,7 @@ public class InspectPage implements Page {
private final String version; private final String version;
private final PlanFiles planFiles; private final PlanFiles files;
private final PlanConfig config; private final PlanConfig config;
private final Theme theme; private final Theme theme;
private final Graphs graphs; private final Graphs graphs;
@ -65,7 +65,7 @@ public class InspectPage implements Page {
InspectPage( InspectPage(
PlayerContainer player, Map<UUID, String> serverNames, PlayerContainer player, Map<UUID, String> serverNames,
String version, String version,
PlanFiles planFiles, PlanFiles files,
PlanConfig config, PlanConfig config,
Theme theme, Theme theme,
Graphs graphs, Graphs graphs,
@ -78,7 +78,7 @@ public class InspectPage implements Page {
this.player = player; this.player = player;
this.serverNames = serverNames; this.serverNames = serverNames;
this.version = version; this.version = version;
this.planFiles = planFiles; this.files = files;
this.config = config; this.config = config;
this.theme = theme; this.theme = theme;
this.graphs = graphs; this.graphs = graphs;
@ -231,7 +231,7 @@ public class InspectPage implements Page {
: serverName : 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) { private void sessionsAndPlaytime(PlaceholderReplacer replacer, SessionsMutator sessionsMutator, SessionsMutator daySessionsMutator, SessionsMutator weekSessionsMutator, SessionsMutator monthSessionsMutator) {

View File

@ -25,16 +25,16 @@ public class NetworkPage implements Page {
private final NetworkContainer networkContainer; private final NetworkContainer networkContainer;
private final PlanFiles planFiles; private final PlanFiles files;
private final ServerProperties serverProperties; private final ServerProperties serverProperties;
public NetworkPage( public NetworkPage(
NetworkContainer networkContainer, NetworkContainer networkContainer,
PlanFiles planFiles, PlanFiles files,
ServerProperties serverProperties ServerProperties serverProperties
) { ) {
this.networkContainer = networkContainer; this.networkContainer = networkContainer;
this.planFiles = planFiles; this.files = files;
this.serverProperties = serverProperties; this.serverProperties = serverProperties;
} }
@ -60,7 +60,7 @@ public class NetworkPage implements Page {
ResponseCache.loadResponse(PageId.NETWORK_CONTENT.id(), NetworkPageContent::new); ResponseCache.loadResponse(PageId.NETWORK_CONTENT.id(), NetworkPageContent::new);
placeholderReplacer.put("tabContentServers", networkPageContent.getContents()); placeholderReplacer.put("tabContentServers", networkPageContent.getContents());
return placeholderReplacer.apply(planFiles.readCustomizableResourceFlat("web/network.html")); return placeholderReplacer.apply(files.readCustomizableResourceFlat("web/network.html"));
} catch (Exception e) { } catch (Exception e) {
throw new ParseException(e); throw new ParseException(e);
} }

View File

@ -22,7 +22,7 @@ import java.util.List;
public class PlayersPage implements Page { public class PlayersPage implements Page {
private final String version; private final String version;
private final PlanFiles planFiles; private final PlanFiles files;
private final PlanConfig config; private final PlanConfig config;
private final Database database; private final Database database;
private final ServerInfo serverInfo; private final ServerInfo serverInfo;
@ -33,7 +33,7 @@ public class PlayersPage implements Page {
PlayersPage( PlayersPage(
String version, String version,
PlanFiles planFiles, PlanFiles files,
PlanConfig config, PlanConfig config,
Database database, Database database,
ServerInfo serverInfo, ServerInfo serverInfo,
@ -41,7 +41,7 @@ public class PlayersPage implements Page {
Timings timings Timings timings
) { ) {
this.version = version; this.version = version;
this.planFiles = planFiles; this.files = files;
this.config = config; this.config = config;
this.database = database; this.database = database;
this.serverInfo = serverInfo; this.serverInfo = serverInfo;
@ -66,7 +66,7 @@ public class PlayersPage implements Page {
placeholderReplacer.put("playersTable", tables.playerTableForPlayersPage(playerContainers).parseHtml()); placeholderReplacer.put("playersTable", tables.playerTableForPlayersPage(playerContainers).parseHtml());
timings.end("Pages", "Players page players table parsing"); 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) { } catch (Exception e) {
throw new ParseException(e); throw new ParseException(e);
} }

View File

@ -30,7 +30,7 @@ public class GeolocationCacheTest {
private final Map<String, String> ipsToCountries = new HashMap<>(); private final Map<String, String> ipsToCountries = new HashMap<>();
@Mock @Mock
private PlanFiles planFiles; private PlanFiles files;
@Mock @Mock
private PlanConfig config; private PlanConfig config;
private GeolocationCache geolocationCache; private GeolocationCache geolocationCache;
@ -47,8 +47,8 @@ public class GeolocationCacheTest {
@Before @Before
public void setUp() throws IOException { public void setUp() throws IOException {
doReturn(temporaryFolder.newFile("GeoIP.dat")).when(planFiles.getFileFromPluginFolder("GeoIP.dat")); doReturn(temporaryFolder.newFile("GeoIP.dat")).when(files.getFileFromPluginFolder("GeoIP.dat"));
geolocationCache = new GeolocationCache(new Locale(), planFiles, config, new TestPluginLogger()); geolocationCache = new GeolocationCache(new Locale(), files, config, new TestPluginLogger());
ipsToCountries.put("8.8.8.8", "United States"); ipsToCountries.put("8.8.8.8", "United States");
ipsToCountries.put("8.8.4.4", "United States"); ipsToCountries.put("8.8.4.4", "United States");