Made Processing non static and initialized by Dagger

This commit is contained in:
Rsl1122 2018-08-29 10:58:29 +03:00
parent c0f1dfc8c5
commit 23f679802e
50 changed files with 477 additions and 218 deletions

View File

@ -23,6 +23,7 @@ import com.djrapitops.plugin.logging.L;
import com.djrapitops.plugin.logging.error.ErrorHandler;
import javax.inject.Inject;
import javax.inject.Singleton;
import java.util.Map;
import java.util.Optional;
import java.util.UUID;
@ -33,22 +34,35 @@ import java.util.UUID;
* @author Rsl1122
* @since 2.0.0
*/
@Singleton
public class AnalyzeCommand extends CommandNode {
private final Locale locale;
private final Processing processing;
private final InfoSystem infoSystem;
private final ServerInfo serverInfo;
private final WebServer webServer;
private final Database database;
private final ConnectionSystem connectionSystem;
private final ErrorHandler errorHandler;
@Inject
public AnalyzeCommand(Locale locale, InfoSystem infoSystem, WebServer webServer, Database database, ErrorHandler errorHandler) {
public AnalyzeCommand(
Locale locale,
Processing processing,
InfoSystem infoSystem,
ServerInfo serverInfo,
WebServer webServer,
Database database,
ErrorHandler errorHandler
) {
super("analyze|analyse|analysis|a", Permissions.ANALYZE.getPermission(), CommandType.CONSOLE);
this.locale = locale;
this.processing = processing;
this.infoSystem = infoSystem;
connectionSystem = infoSystem.getConnectionSystem();
this.serverInfo = serverInfo;
this.webServer = webServer;
this.database = database;
this.errorHandler = errorHandler;
@ -62,9 +76,9 @@ public class AnalyzeCommand extends CommandNode {
public void onCommand(ISender sender, String commandLabel, String[] args) {
sender.sendMessage(locale.getString(ManageLang.PROGRESS_START));
Processing.submitNonCritical(() -> {
processing.submitNonCritical(() -> {
try {
Server server = getServer(args).orElseGet(ServerInfo::getServer_Old);
Server server = getServer(args).orElseGet(serverInfo::getServer);
UUID serverUUID = server.getUuid();
infoSystem.generateAnalysisPage(serverUUID);

View File

@ -34,6 +34,7 @@ public class InspectCommand extends CommandNode {
private final Locale locale;
private final Database database;
private final WebServer webServer;
private final Processing processing;
private final ConnectionSystem connectionSystem;
private final UUIDUtility uuidUtility;
private final ErrorHandler errorHandler;
@ -41,6 +42,7 @@ public class InspectCommand extends CommandNode {
@Inject
public InspectCommand(
Locale locale,
Processing processing,
Database database,
WebServer webServer,
ConnectionSystem connectionSystem,
@ -48,6 +50,7 @@ public class InspectCommand extends CommandNode {
ErrorHandler errorHandler
) {
super("inspect", Permissions.INSPECT.getPermission(), CommandType.PLAYER_OR_ARGS);
this.processing = processing;
this.connectionSystem = connectionSystem;
setArguments("<player>");
@ -73,7 +76,7 @@ public class InspectCommand extends CommandNode {
}
private void runInspectTask(String playerName, ISender sender) {
Processing.submitNonCritical(() -> {
processing.submitNonCritical(() -> {
try {
UUID uuid = uuidUtility.getUUIDOf(playerName);
if (uuid == null) {
@ -87,7 +90,7 @@ public class InspectCommand extends CommandNode {
}
checkWebUserAndNotify(sender);
Processing.submit(new InspectCacheRequestProcessor(uuid, sender, playerName, this::sendInspectMsg));
processing.submit(new InspectCacheRequestProcessor(uuid, sender, playerName, this::sendInspectMsg));
} catch (DBOpException e) {
sender.sendMessage("§eDatabase exception occurred: " + e.getMessage());
errorHandler.log(L.ERROR, this.getClass(), e);

View File

@ -27,6 +27,7 @@ import com.djrapitops.plugin.logging.L;
import com.djrapitops.plugin.logging.error.ErrorHandler;
import javax.inject.Inject;
import javax.inject.Singleton;
import java.util.ArrayList;
import java.util.List;
import java.util.Optional;
@ -38,21 +39,25 @@ import java.util.UUID;
* @author Rsl1122
* @since 1.0.0
*/
@Singleton
public class QInspectCommand extends CommandNode {
private final Locale locale;
private final Database database;
private UUIDUtility uuidUtility;
private final Processing processing;
private final UUIDUtility uuidUtility;
private final ErrorHandler errorHandler;
@Inject
public QInspectCommand(
Locale locale,
Processing processing,
Database database,
UUIDUtility uuidUtility,
ErrorHandler errorHandler
) {
super("qinspect", Permissions.QUICK_INSPECT.getPermission(), CommandType.PLAYER_OR_ARGS);
this.processing = processing;
setArguments("<player>");
this.locale = locale;
@ -77,7 +82,7 @@ public class QInspectCommand extends CommandNode {
}
private void runInspectTask(String playerName, ISender sender) {
Processing.submitNonCritical(() -> {
processing.submitNonCritical(() -> {
try {
UUID uuid = uuidUtility.getUUIDOf(playerName);
if (uuid == null) {

View File

@ -20,6 +20,7 @@ import com.djrapitops.plugin.logging.error.ErrorHandler;
import com.djrapitops.plugin.utilities.Verify;
import javax.inject.Inject;
import javax.inject.Singleton;
import java.util.Arrays;
/**
@ -33,20 +34,28 @@ import java.util.Arrays;
* @author Rsl1122
* @since 3.5.2
*/
@Singleton
public class RegisterCommand extends CommandNode {
private final String notEnoughArgsMsg;
private final Locale locale;
private final PluginLogger logger;
private final Processing processing;
private final Database database;
private final PluginLogger logger;
private final ErrorHandler errorHandler;
@Inject
public RegisterCommand(Locale locale, PluginLogger logger, Database database, ErrorHandler errorHandler) {
public RegisterCommand(
Locale locale,
Processing processing,
Database database,
PluginLogger logger,
ErrorHandler errorHandler) {
// No Permission Requirement
super("register", "", CommandType.PLAYER_OR_ARGS);
this.locale = locale;
this.processing = processing;
this.logger = logger;
this.database = database;
this.errorHandler = errorHandler;
@ -119,7 +128,7 @@ public class RegisterCommand extends CommandNode {
}
private void registerUser(WebUser webUser, ISender sender) {
Processing.submitCritical(() -> {
processing.submitCritical(() -> {
String userName = webUser.getName();
try {
boolean userExists = database.check().doesWebUserExists(userName);

View File

@ -17,6 +17,7 @@ import com.djrapitops.plugin.logging.error.ErrorHandler;
import com.djrapitops.plugin.utilities.Verify;
import javax.inject.Inject;
import javax.inject.Singleton;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
@ -27,17 +28,24 @@ import java.util.List;
* @author Rsl1122
* @since 2.0.0
*/
@Singleton
public class SearchCommand extends CommandNode {
private final Locale locale;
private final Processing processing;
private final Database database;
private final ErrorHandler errorHandler;
@Inject
public SearchCommand(Locale locale, Database database, ErrorHandler errorHandler) {
public SearchCommand(
Locale locale,
Processing processing,
Database database,
ErrorHandler errorHandler) {
super("search", Permissions.SEARCH.getPermission(), CommandType.PLAYER_OR_ARGS);
this.locale = locale;
this.processing = processing;
this.database = database;
this.errorHandler = errorHandler;
@ -57,7 +65,7 @@ public class SearchCommand extends CommandNode {
}
private void runSearchTask(String[] args, ISender sender) {
Processing.submitNonCritical(() -> {
processing.submitNonCritical(() -> {
try {
String searchTerm = args[0];
List<String> names = database.search().matchingPlayers(searchTerm);

View File

@ -21,6 +21,7 @@ import com.djrapitops.plugin.logging.error.ErrorHandler;
import com.djrapitops.plugin.utilities.Verify;
import javax.inject.Inject;
import javax.inject.Singleton;
import java.util.Arrays;
import java.util.Collection;
import java.util.UUID;
@ -31,18 +32,26 @@ import java.util.UUID;
* @author Rsl1122
* @since 2.3.0
*/
@Singleton
public class ManageBackupCommand extends CommandNode {
private final Locale locale;
private final Processing processing;
private final DBSystem dbSystem;
private SQLiteDB.Factory sqliteFactory;
private final SQLiteDB.Factory sqliteFactory;
private final ErrorHandler errorHandler;
@Inject
public ManageBackupCommand(Locale locale, DBSystem dbSystem, SQLiteDB.Factory sqliteFactory, ErrorHandler errorHandler) {
public ManageBackupCommand(
Locale locale,
Processing processing,
DBSystem dbSystem,
SQLiteDB.Factory sqliteFactory,
ErrorHandler errorHandler) {
super("backup", Permissions.MANAGE.getPermission(), CommandType.CONSOLE);
this.locale = locale;
this.processing = processing;
this.dbSystem = dbSystem;
this.sqliteFactory = sqliteFactory;
this.errorHandler = errorHandler;
@ -75,7 +84,7 @@ public class ManageBackupCommand extends CommandNode {
}
private void runBackupTask(ISender sender, String[] args, Database database) {
Processing.submitCritical(() -> {
processing.submitCritical(() -> {
try {
sender.sendMessage(locale.getString(ManageLang.PROGRESS_START));
createNewBackup(args[0], database);

View File

@ -19,6 +19,7 @@ import com.djrapitops.plugin.logging.error.ErrorHandler;
import com.djrapitops.plugin.utilities.Verify;
import javax.inject.Inject;
import javax.inject.Singleton;
import java.util.Arrays;
/**
@ -27,17 +28,25 @@ import java.util.Arrays;
* @author Rsl1122
* @since 2.3.0
*/
@Singleton
public class ManageClearCommand extends CommandNode {
private final Locale locale;
private final Processing processing;
private final DBSystem dbSystem;
private final ErrorHandler errorHandler;
@Inject
public ManageClearCommand(Locale locale, DBSystem dbSystem, ErrorHandler errorHandler) {
public ManageClearCommand(
Locale locale,
Processing processing,
DBSystem dbSystem,
ErrorHandler errorHandler
) {
super("clear", Permissions.MANAGE.getPermission(), CommandType.PLAYER_OR_ARGS);
this.locale = locale;
this.processing = processing;
this.dbSystem = dbSystem;
this.errorHandler = errorHandler;
@ -72,7 +81,7 @@ public class ManageClearCommand extends CommandNode {
}
private void runClearTask(ISender sender, Database database) {
Processing.submitCritical(() -> {
processing.submitCritical(() -> {
try {
sender.sendMessage(locale.getString(ManageLang.PROGRESS_START));

View File

@ -21,6 +21,7 @@ import com.djrapitops.plugin.command.CommandType;
import com.djrapitops.plugin.command.ISender;
import javax.inject.Inject;
import javax.inject.Singleton;
import java.util.List;
import java.util.UUID;
@ -30,10 +31,12 @@ import java.util.UUID;
* @author Rsl1122
* @since 2.3.0
*/
@Singleton
public class ManageConDebugCommand extends CommandNode {
private final ColorScheme colorScheme;
private final Locale locale;
private final Processing processing;
private final ServerInfo serverInfo;
private final ConnectionSystem connectionSystem;
private final InfoRequestFactory infoRequestFactory;
@ -44,7 +47,9 @@ public class ManageConDebugCommand extends CommandNode {
public ManageConDebugCommand(
ColorScheme colorScheme,
Locale locale,
ServerInfo serverInfo, ConnectionSystem connectionSystem,
Processing processing,
ServerInfo serverInfo,
ConnectionSystem connectionSystem,
InfoRequestFactory infoRequestFactory,
WebServer webServer,
Database database
@ -53,6 +58,7 @@ public class ManageConDebugCommand extends CommandNode {
this.colorScheme = colorScheme;
this.locale = locale;
this.processing = processing;
this.serverInfo = serverInfo;
this.connectionSystem = connectionSystem;
this.infoRequestFactory = infoRequestFactory;
@ -104,7 +110,7 @@ public class ManageConDebugCommand extends CommandNode {
return;
}
Processing.submitNonCritical(() -> testServers(sender));
processing.submitNonCritical(() -> testServers(sender));
}
private void testServers(ISender sender) {

View File

@ -15,6 +15,7 @@ import com.djrapitops.plugin.command.ISender;
import com.djrapitops.plugin.utilities.Verify;
import javax.inject.Inject;
import javax.inject.Singleton;
import java.util.Arrays;
/**
@ -23,15 +24,21 @@ import java.util.Arrays;
* @author Rsl1122
* @since 2.3.0
*/
@Singleton
public class ManageImportCommand extends CommandNode {
private final Locale locale;
private final Processing processing;
@Inject
public ManageImportCommand(Locale locale) {
public ManageImportCommand(
Locale locale,
Processing processing
) {
super("import", Permissions.MANAGE.getPermission(), CommandType.CONSOLE);
this.locale = locale;
this.processing = processing;
setArguments("<plugin>/list", "[import args]");
setShortHelp(locale.getString(CmdHelpLang.MANAGE_IMPORT));
@ -60,6 +67,6 @@ public class ManageImportCommand extends CommandNode {
return;
}
Processing.submitNonCritical(importer::processImport);
processing.submitNonCritical(importer::processImport);
}
}

View File

@ -17,6 +17,7 @@ import com.djrapitops.plugin.logging.error.ErrorHandler;
import com.djrapitops.plugin.utilities.Verify;
import javax.inject.Inject;
import javax.inject.Singleton;
import java.util.Arrays;
/**
@ -27,17 +28,25 @@ import java.util.Arrays;
* @author Rsl1122
* @since 2.3.0
*/
@Singleton
public class ManageMoveCommand extends CommandNode {
private final Locale locale;
private final Processing processing;
private final DBSystem dbSystem;
private final ErrorHandler errorHandler;
@Inject
public ManageMoveCommand(Locale locale, DBSystem dbSystem, ErrorHandler errorHandler) {
public ManageMoveCommand(
Locale locale,
Processing processing,
DBSystem dbSystem,
ErrorHandler errorHandler
) {
super("move", Permissions.MANAGE.getPermission(), CommandType.PLAYER_OR_ARGS);
this.locale = locale;
this.processing = processing;
this.dbSystem = dbSystem;
this.errorHandler = errorHandler;
@ -82,7 +91,7 @@ public class ManageMoveCommand extends CommandNode {
}
private void runMoveTask(final Database fromDatabase, final Database toDatabase, ISender sender) {
Processing.submitCritical(() -> {
processing.submitCritical(() -> {
try {
sender.sendMessage(locale.getString(ManageLang.PROGRESS_START));

View File

@ -19,6 +19,7 @@ import com.djrapitops.plugin.logging.error.ErrorHandler;
import com.djrapitops.plugin.utilities.Verify;
import javax.inject.Inject;
import javax.inject.Singleton;
import java.util.Arrays;
import java.util.UUID;
@ -28,16 +29,19 @@ import java.util.UUID;
*
* @author Rsl1122
*/
@Singleton
public class ManageRemoveCommand extends CommandNode {
private final Locale locale;
private final Processing processing;
private final Database database;
private UUIDUtility uuidUtility;
private final UUIDUtility uuidUtility;
private final ErrorHandler errorHandler;
@Inject
public ManageRemoveCommand(
Locale locale,
Processing processing,
Database database,
UUIDUtility uuidUtility,
ErrorHandler errorHandler
@ -45,6 +49,7 @@ public class ManageRemoveCommand extends CommandNode {
super("remove|delete", Permissions.MANAGE.getPermission(), CommandType.PLAYER_OR_ARGS);
this.locale = locale;
this.processing = processing;
this.database = database;
this.uuidUtility = uuidUtility;
this.errorHandler = errorHandler;
@ -70,7 +75,7 @@ public class ManageRemoveCommand extends CommandNode {
}
private void runRemoveTask(String playerName, ISender sender, String[] args) {
Processing.submitCritical(() -> {
processing.submitCritical(() -> {
try {
UUID uuid = uuidUtility.getUUIDOf(playerName);

View File

@ -31,16 +31,25 @@ import java.util.Arrays;
public class ManageRestoreCommand extends CommandNode {
private final Locale locale;
private final Processing processing;
private final DBSystem dbSystem;
private final ErrorHandler errorHandler;
private SQLiteDB.Factory sqliteFactory;
private final SQLiteDB.Factory sqliteFactory;
private final FileSystem fileSystem;
@Inject
public ManageRestoreCommand(Locale locale, DBSystem dbSystem, SQLiteDB.Factory sqliteFactory, FileSystem fileSystem, ErrorHandler errorHandler) {
public ManageRestoreCommand(
Locale locale,
Processing processing,
DBSystem dbSystem,
SQLiteDB.Factory sqliteFactory,
FileSystem fileSystem,
ErrorHandler errorHandler
) {
super("restore", Permissions.MANAGE.getPermission(), CommandType.CONSOLE);
this.locale = locale;
this.processing = processing;
this.dbSystem = dbSystem;
this.sqliteFactory = sqliteFactory;
this.fileSystem = fileSystem;
@ -82,7 +91,7 @@ public class ManageRestoreCommand extends CommandNode {
}
private void runRestoreTask(String backupDbName, ISender sender, Database database) {
Processing.submitCritical(() -> {
processing.submitCritical(() -> {
try {
String backupDBName = backupDbName;
boolean containsDBFileExtension = backupDBName.endsWith(".db");

View File

@ -19,6 +19,7 @@ import com.djrapitops.plugin.logging.error.ErrorHandler;
import com.djrapitops.plugin.utilities.Verify;
import javax.inject.Inject;
import javax.inject.Singleton;
import java.util.Arrays;
/**
@ -27,20 +28,30 @@ import java.util.Arrays;
* @author Rsl1122
* @since 2.3.0
*/
@Singleton
public class ManageSetupCommand extends CommandNode {
private final Locale locale;
private final PlanConfig config;
private final Processing processing;
private final InfoSystem infoSystem;
private final WebServer webServer;
private final ErrorHandler errorHandler;
@Inject
public ManageSetupCommand(Locale locale, PlanConfig config, InfoSystem infoSystem, WebServer webServer, ErrorHandler errorHandler) {
public ManageSetupCommand(
Locale locale,
PlanConfig config,
Processing processing,
InfoSystem infoSystem,
WebServer webServer,
ErrorHandler errorHandler
) {
super("setup", Permissions.MANAGE.getPermission(), CommandType.PLAYER_OR_ARGS);
this.locale = locale;
this.config = config;
this.processing = processing;
this.infoSystem = infoSystem;
this.webServer = webServer;
this.errorHandler = errorHandler;
@ -72,7 +83,7 @@ public class ManageSetupCommand extends CommandNode {
}
private void requestSetup(ISender sender, String address) {
Processing.submitNonCritical(() -> {
processing.submitNonCritical(() -> {
try {
config.set(Settings.BUNGEE_OVERRIDE_STANDALONE_MODE, false);
config.set(Settings.BUNGEE_COPY_CONFIG, true);

View File

@ -18,6 +18,7 @@ import com.djrapitops.plugin.logging.L;
import com.djrapitops.plugin.logging.error.ErrorHandler;
import javax.inject.Inject;
import javax.inject.Singleton;
import java.util.Map;
import java.util.Optional;
import java.util.UUID;
@ -28,19 +29,31 @@ import java.util.UUID;
* @author Rsl1122
* @since 2.0.0
*/
@Singleton
public class ManageUninstalledCommand extends CommandNode {
private final Locale locale;
private final Processing processing;
private final Database database;
private final ErrorHandler errorHandler;
private final ServerInfo serverInfo;
private final ConnectionSystem connectionSystem;
@Inject
public ManageUninstalledCommand(Locale locale, Database database, ConnectionSystem connectionSystem, ErrorHandler errorHandler) {
public ManageUninstalledCommand(
Locale locale,
Processing processing,
Database database,
ServerInfo serverInfo,
ConnectionSystem connectionSystem,
ErrorHandler errorHandler
) {
super("uninstalled", Permissions.MANAGE.getPermission(), CommandType.ALL_WITH_ARGS);
this.locale = locale;
this.processing = processing;
this.database = database;
this.serverInfo = serverInfo;
this.connectionSystem = connectionSystem;
this.errorHandler = errorHandler;
@ -53,7 +66,7 @@ public class ManageUninstalledCommand extends CommandNode {
public void onCommand(ISender sender, String commandLabel, String[] args) {
sender.sendMessage(locale.getString(ManageLang.PROGRESS_START));
Processing.submitNonCritical(() -> {
processing.submitNonCritical(() -> {
try {
Optional<Server> serverOptional = getServer(args);
if (!serverOptional.isPresent()) {
@ -62,7 +75,7 @@ public class ManageUninstalledCommand extends CommandNode {
}
Server server = serverOptional.get();
UUID serverUUID = server.getUuid();
if (ServerInfo.getServerUUID_Old().equals(serverUUID)) {
if (serverInfo.getServerUUID().equals(serverUUID)) {
sender.sendMessage(locale.getString(ManageLang.UNINSTALLING_SAME_SERVER));
return;
}

View File

@ -16,6 +16,7 @@ import com.djrapitops.plugin.logging.error.ErrorHandler;
import com.djrapitops.plugin.utilities.Verify;
import javax.inject.Inject;
import javax.inject.Singleton;
import java.util.Arrays;
/**
@ -24,17 +25,24 @@ import java.util.Arrays;
* @author Rsl1122
* @since 3.5.2
*/
@Singleton
public class WebCheckCommand extends CommandNode {
private final Locale locale;
private final Processing processing;
private final Database database;
private final ErrorHandler errorHandler;
@Inject
public WebCheckCommand(Locale locale, Database database, ErrorHandler errorHandler) {
public WebCheckCommand(
Locale locale,
Processing processing,
Database database,
ErrorHandler errorHandler) {
super("check", Permissions.MANAGE_WEB.getPerm(), CommandType.PLAYER_OR_ARGS);
this.locale = locale;
this.processing = processing;
this.database = database;
this.errorHandler = errorHandler;
@ -49,7 +57,7 @@ public class WebCheckCommand extends CommandNode {
String user = args[0];
Processing.submitNonCritical(() -> {
processing.submitNonCritical(() -> {
try {
if (!database.check().doesWebUserExists(user)) {
sender.sendMessage(locale.getString(CommandLang.FAIL_WEB_USER_NOT_EXISTS));

View File

@ -15,6 +15,7 @@ import com.djrapitops.plugin.logging.error.ErrorHandler;
import com.djrapitops.plugin.utilities.Verify;
import javax.inject.Inject;
import javax.inject.Singleton;
import java.util.Arrays;
/**
@ -23,17 +24,25 @@ import java.util.Arrays;
* @author Rsl1122
* @since 3.5.2
*/
@Singleton
public class WebDeleteCommand extends CommandNode {
private final Locale locale;
private final Processing processing;
private final Database database;
private final ErrorHandler errorHandler;
@Inject
public WebDeleteCommand(Locale locale, Database database, ErrorHandler errorHandler) {
public WebDeleteCommand(
Locale locale,
Processing processing,
Database database,
ErrorHandler errorHandler
) {
super("delete|remove", Permissions.MANAGE_WEB.getPerm(), CommandType.PLAYER_OR_ARGS);
this.locale = locale;
this.processing = processing;
this.database = database;
this.errorHandler = errorHandler;
@ -48,7 +57,7 @@ public class WebDeleteCommand extends CommandNode {
String user = args[0];
Processing.submitNonCritical(() -> {
processing.submitNonCritical(() -> {
try {
if (!database.check().doesWebUserExists(user)) {
sender.sendMessage("§c[Plan] User Doesn't exist.");

View File

@ -16,6 +16,7 @@ import com.djrapitops.plugin.logging.L;
import com.djrapitops.plugin.logging.error.ErrorHandler;
import javax.inject.Inject;
import javax.inject.Singleton;
import java.util.List;
/**
@ -24,17 +25,25 @@ import java.util.List;
* @author Rsl1122
* @since 3.5.2
*/
@Singleton
public class WebListUsersCommand extends CommandNode {
private final Locale locale;
private final Processing processing;
private final Database database;
private final ErrorHandler errorHandler;
@Inject
public WebListUsersCommand(Locale locale, Database database, ErrorHandler errorHandler) {
public WebListUsersCommand(
Locale locale,
Processing processing,
Database database,
ErrorHandler errorHandler
) {
super("list", Permissions.MANAGE_WEB.getPerm(), CommandType.CONSOLE);
this.locale = locale;
this.processing = processing;
this.database = database;
this.errorHandler = errorHandler;
@ -43,7 +52,7 @@ public class WebListUsersCommand extends CommandNode {
@Override
public void onCommand(ISender sender, String commandLabel, String[] args) {
Processing.submitNonCritical(() -> {
processing.submitNonCritical(() -> {
try {
List<WebUser> users = database.fetch().getWebUsers();
users.sort(new WebUserComparator());

View File

@ -67,7 +67,7 @@ public class PlanSystem implements SubSystem {
InfoSystem infoSystem,
ServerInfo serverInfo,
WebServerSystem webServerSystem,
//Processing processing,
Processing processing,
ExportSystem exportSystem,
HookHandler hookHandler,
PlanAPI planAPI
@ -83,7 +83,7 @@ public class PlanSystem implements SubSystem {
this.infoSystem = infoSystem;
this.serverInfo = serverInfo;
this.webServerSystem = webServerSystem;
this.processing = new Processing(localeSystem::getLocale);
this.processing = processing;
this.exportSystem = exportSystem;
this.hookHandler = hookHandler;
this.planAPI = planAPI;

View File

@ -6,7 +6,9 @@ import com.djrapitops.plan.system.file.FileSystem;
import com.djrapitops.plan.system.locale.Locale;
import com.djrapitops.plan.system.locale.lang.PluginLang;
import com.djrapitops.plan.system.settings.Settings;
import com.djrapitops.plugin.api.utility.log.Log;
import com.djrapitops.plan.system.settings.config.PlanConfig;
import com.djrapitops.plugin.logging.L;
import com.djrapitops.plugin.logging.console.PluginLogger;
import com.djrapitops.plugin.utilities.Verify;
import com.maxmind.geoip2.DatabaseReader;
import com.maxmind.geoip2.exception.GeoIp2Exception;
@ -14,6 +16,7 @@ import com.maxmind.geoip2.model.CountryResponse;
import com.maxmind.geoip2.record.Country;
import javax.inject.Inject;
import javax.inject.Singleton;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
@ -34,31 +37,44 @@ import java.util.zip.GZIPInputStream;
* @author Fuzzlemann
* @since 3.5.5
*/
@Singleton
public class GeolocationCache implements SubSystem {
private final Locale locale;
private final FileSystem fileSystem;
private final PlanConfig config;
private final PluginLogger logger;
private final Map<String, String> cached;
private File geolocationDB;
@Inject
public GeolocationCache(Locale locale) {
public GeolocationCache(
Locale locale,
FileSystem fileSystem,
PlanConfig config,
PluginLogger logger
) {
this.locale = locale;
this.fileSystem = fileSystem;
this.config = config;
this.logger = logger;
cached = new HashMap<>();
}
@Override
public void enable() throws EnableException {
geolocationDB = new File(FileSystem.getDataFolder_Old(), "GeoIP.dat");
if (Settings.DATA_GEOLOCATIONS.isTrue()) {
geolocationDB = fileSystem.getFileFromPluginFolder("GeoIP.dat");
if (config.isTrue(Settings.DATA_GEOLOCATIONS)) {
try {
GeolocationCache.checkDB();
} catch (UnknownHostException e) {
Log.error(locale.getString(PluginLang.ENABLE_NOTIFY_GEOLOCATIONS_INTERNET_REQUIRED));
logger.error(locale.getString(PluginLang.ENABLE_NOTIFY_GEOLOCATIONS_INTERNET_REQUIRED));
} catch (IOException e) {
throw new EnableException(locale.getString(PluginLang.ENABLE_FAIL_GEODB_WRITE), e);
}
} else {
Log.infoColor("§e" + locale.getString(PluginLang.ENABLE_NOTIFY_GEOLOCATIONS_DISABLED));
logger.log(L.INFO_COLOR, "§e" + locale.getString(PluginLang.ENABLE_NOTIFY_GEOLOCATIONS_DISABLED));
}
}

View File

@ -7,30 +7,35 @@ import com.djrapitops.plan.system.settings.config.PlanConfig;
import com.djrapitops.plan.utilities.file.export.HtmlExport;
import javax.inject.Inject;
import javax.inject.Singleton;
/**
* System in charge of exporting html.
*
* @author Rsl1122
*/
@Singleton
public class ExportSystem implements SubSystem {
private PlanConfig config;
private HtmlExport htmlExport;
private final PlanConfig config;
private final Processing processing;
private final HtmlExport htmlExport;
@Inject
public ExportSystem(
PlanConfig config,
Processing processing,
HtmlExport htmlExport
) {
this.config = config;
this.processing = processing;
this.htmlExport = htmlExport;
}
@Override
public void enable() {
if (config.isTrue(Settings.ANALYSIS_EXPORT)) {
Processing.submitNonCritical(htmlExport);
processing.submitNonCritical(htmlExport);
}
}

View File

@ -6,16 +6,15 @@ package com.djrapitops.plan.system.file;
import com.djrapitops.plan.PlanPlugin;
import com.djrapitops.plan.api.exceptions.EnableException;
import com.djrapitops.plan.system.PlanSystem;
import com.djrapitops.plan.system.SubSystem;
import com.djrapitops.plan.system.tasks.LogsFolderCleanTask;
import com.djrapitops.plan.utilities.file.FileUtil;
import com.djrapitops.plugin.api.TimeAmount;
import com.djrapitops.plugin.api.utility.log.Log;
import com.djrapitops.plugin.task.RunnableFactory;
import com.djrapitops.plugin.utilities.Verify;
import javax.inject.Inject;
import javax.inject.Singleton;
import java.io.File;
import java.io.IOException;
import java.util.List;
@ -25,44 +24,19 @@ import java.util.List;
*
* @author Rsl1122
*/
@Singleton
public class FileSystem implements SubSystem {
private final File dataFolder;
private final PlanPlugin plugin;
private File configFile;
private final File dataFolder;
private final File configFile;
@Inject
public FileSystem(PlanPlugin plugin) {
this.dataFolder = plugin.getDataFolder();
this.plugin = plugin;
configFile = new File(dataFolder, "config.yml");
}
@Deprecated
public static FileSystem getInstance() {
FileSystem fileSystem = PlanSystem.getInstance().getFileSystem();
Verify.nullCheck(fileSystem, () -> new IllegalStateException("File system was not initialized."));
return fileSystem;
}
@Deprecated
public static File getDataFolder_Old() {
return getInstance().dataFolder;
}
@Deprecated
public static File getConfigFile_Old() {
return getInstance().configFile;
}
@Deprecated
public static File getLocaleFile_Old() {
return getInstance().getLocaleFile();
}
@Deprecated
public static List<String> readFromResource_Old(String fileName) throws IOException {
return FileUtil.lines(PlanPlugin.getInstance(), fileName);
this.configFile = getFileFromPluginFolder("config.yml");
}
public List<String> readFromResource(String fileName) throws IOException {
@ -93,7 +67,7 @@ public class FileSystem implements SubSystem {
Verify.isTrue((configFile.exists() && configFile.isFile()) || configFile.createNewFile(),
() -> new EnableException("Could not create config file at " + configFile.getAbsolutePath()));
RunnableFactory.createNew("Logs folder Clean Task", new LogsFolderCleanTask(Log.getLogsFolder()))
plugin.getRunnableFactory().create("Logs folder Clean Task", new LogsFolderCleanTask(Log.getLogsFolder()))
.runTaskLaterAsynchronously(TimeAmount.SECOND.ticks() * 30L);
} catch (IOException e) {
throw new EnableException("Failed to create config.yml", e);
@ -104,4 +78,13 @@ public class FileSystem implements SubSystem {
public void disable() {
// No disable actions necessary.
}
public String readFromResourceFlat(String fileName) throws IOException {
List<String> lines = readFromResource(fileName);
StringBuilder flat = new StringBuilder();
for (String line : lines) {
flat.append(line).append("\r\n");
}
return flat.toString();
}
}

View File

@ -37,6 +37,7 @@ public class ServerConnectionSystem extends ConnectionSystem {
private final Locale locale;
private final PlanConfig config;
private final Processing processing;
private final Database database;
private final WebServer webServer;
private final PluginLogger pluginLogger;
@ -50,6 +51,7 @@ public class ServerConnectionSystem extends ConnectionSystem {
public ServerConnectionSystem(
Locale locale,
PlanConfig config,
Processing processing,
Database database,
WebServer webServer,
ConnectionLog connectionLog,
@ -62,6 +64,7 @@ public class ServerConnectionSystem extends ConnectionSystem {
super(connectionLog, infoRequests, infoSystem, serverInfo);
this.locale = locale;
this.config = config;
this.processing = processing;
this.database = database;
this.webServer = webServer;
this.pluginLogger = pluginLogger;
@ -70,7 +73,7 @@ public class ServerConnectionSystem extends ConnectionSystem {
}
private void refreshServerMap() {
Processing.submitNonCritical(() -> {
processing.submitNonCritical(() -> {
if (latestServerMapRefresh < System.currentTimeMillis() - TimeAmount.SECOND.ms() * 15L) {
Optional<Server> bungeeInformation = database.fetch().getBungeeInformation();
bungeeInformation.ifPresent(server -> mainServer = server);

View File

@ -29,18 +29,30 @@ import java.util.UUID;
public class CacheAnalysisPageRequest extends InfoRequestWithVariables implements CacheRequest {
private final PlanConfig config;
private final Processing processing;
private final HtmlExport htmlExport;
private UUID serverUUID;
private String html;
CacheAnalysisPageRequest(PlanConfig config, HtmlExport htmlExport) {
CacheAnalysisPageRequest(
PlanConfig config,
Processing processing,
HtmlExport htmlExport
) {
this.config = config;
this.processing = processing;
this.htmlExport = htmlExport;
}
CacheAnalysisPageRequest(UUID serverUUID, String html, PlanConfig config, HtmlExport htmlExport) {
CacheAnalysisPageRequest(
UUID serverUUID, String html,
PlanConfig config,
Processing processing,
HtmlExport htmlExport
) {
this.config = config;
this.processing = processing;
this.htmlExport = htmlExport;
Verify.nullCheck(serverUUID, html);
@ -66,7 +78,7 @@ public class CacheAnalysisPageRequest extends InfoRequestWithVariables implement
ResponseCache.cacheResponse(PageId.SERVER.of(serverUUID), () -> new AnalysisPageResponse(html));
if (config.isTrue(Settings.ANALYSIS_EXPORT)) {
Processing.submitNonCritical(() -> htmlExport.exportServer(serverUUID));
processing.submitNonCritical(() -> htmlExport.exportServer(serverUUID));
}
}

View File

@ -32,6 +32,7 @@ import java.util.UUID;
public class CacheInspectPageRequest extends InfoRequestWithVariables implements CacheRequest {
private final PlanConfig config;
private final Processing processing;
private final ServerInfo serverInfo;
private final HtmlExport htmlExport;
@ -40,10 +41,12 @@ public class CacheInspectPageRequest extends InfoRequestWithVariables implements
CacheInspectPageRequest(
PlanConfig config,
Processing processing,
ServerInfo serverInfo,
HtmlExport htmlExport
) {
this.config = config;
this.processing = processing;
this.serverInfo = serverInfo;
this.htmlExport = htmlExport;
}
@ -51,10 +54,12 @@ public class CacheInspectPageRequest extends InfoRequestWithVariables implements
CacheInspectPageRequest(
UUID player, String html,
PlanConfig config,
Processing processing,
ServerInfo serverInfo,
HtmlExport htmlExport
) {
this.config = config;
this.processing = processing;
this.serverInfo = serverInfo;
this.htmlExport = htmlExport;
@ -85,7 +90,7 @@ public class CacheInspectPageRequest extends InfoRequestWithVariables implements
private void cache(UUID uuid, String html) {
ResponseCache.cacheResponse(PageId.PLAYER.of(uuid), () -> new InspectPageResponse(uuid, html));
if (config.isTrue(Settings.ANALYSIS_EXPORT)) {
Processing.submitNonCritical(() -> htmlExport.exportPlayer(uuid));
processing.submitNonCritical(() -> htmlExport.exportPlayer(uuid));
}
}

View File

@ -4,6 +4,7 @@ import com.djrapitops.plan.PlanPlugin;
import com.djrapitops.plan.system.info.InfoSystem;
import com.djrapitops.plan.system.info.connection.ConnectionSystem;
import com.djrapitops.plan.system.info.server.ServerInfo;
import com.djrapitops.plan.system.processing.Processing;
import com.djrapitops.plan.system.settings.config.PlanConfig;
import com.djrapitops.plan.utilities.file.export.HtmlExport;
import com.djrapitops.plan.utilities.html.pages.PageFactory;
@ -25,6 +26,7 @@ public class InfoRequestFactory {
private final Lazy<PlanPlugin> plugin;
private final Lazy<PlanConfig> config;
private final Lazy<Processing> processing;
private final Lazy<InfoSystem> infoSystem;
private final Lazy<ConnectionSystem> connectionSystem;
private final Lazy<ServerInfo> serverInfo;
@ -38,6 +40,7 @@ public class InfoRequestFactory {
public InfoRequestFactory(
Lazy<PlanPlugin> plugin,
Lazy<PlanConfig> config,
Lazy<Processing> processing,
Lazy<InfoSystem> infoSystem,
Lazy<ConnectionSystem> connectionSystem,
Lazy<ServerInfo> serverInfo,
@ -49,6 +52,7 @@ public class InfoRequestFactory {
) {
this.plugin = plugin;
this.config = config;
this.processing = processing;
this.infoSystem = infoSystem;
this.connectionSystem = connectionSystem;
this.serverInfo = serverInfo;
@ -60,11 +64,11 @@ public class InfoRequestFactory {
}
public CacheRequest cacheAnalysisPageRequest(UUID serverUUID, String html) {
return new CacheAnalysisPageRequest(serverUUID, html, config.get(), htmlExport.get());
return new CacheAnalysisPageRequest(serverUUID, html, config.get(), processing.get(), htmlExport.get());
}
public CacheRequest cacheInspectPageRequest(UUID uuid, String html) {
return new CacheInspectPageRequest(uuid, html, config.get(), serverInfo.get(), htmlExport.get());
return new CacheInspectPageRequest(uuid, html, config.get(), processing.get(), serverInfo.get(), htmlExport.get());
}
public CacheRequest cacheInspectPluginsTabRequest(UUID uuid, String nav, String html) {

View File

@ -4,6 +4,7 @@ import com.djrapitops.plan.PlanPlugin;
import com.djrapitops.plan.system.info.InfoSystem;
import com.djrapitops.plan.system.info.connection.ConnectionSystem;
import com.djrapitops.plan.system.info.server.ServerInfo;
import com.djrapitops.plan.system.processing.Processing;
import com.djrapitops.plan.system.settings.config.PlanConfig;
import com.djrapitops.plan.utilities.file.export.HtmlExport;
import com.djrapitops.plan.utilities.html.pages.PageFactory;
@ -24,6 +25,7 @@ public class InfoRequestHandlerFactory {
private final Lazy<PlanPlugin> plugin;
private final Lazy<PlanConfig> config;
private final Lazy<Processing> processing;
private final Lazy<InfoSystem> infoSystem;
private final Lazy<ConnectionSystem> connectionSystem;
private final Lazy<ServerInfo> serverInfo;
@ -37,6 +39,7 @@ public class InfoRequestHandlerFactory {
public InfoRequestHandlerFactory(
Lazy<PlanPlugin> plugin,
Lazy<PlanConfig> config,
Lazy<Processing> processing,
Lazy<InfoSystem> infoSystem,
Lazy<ConnectionSystem> connectionSystem,
Lazy<ServerInfo> serverInfo,
@ -48,6 +51,7 @@ public class InfoRequestHandlerFactory {
) {
this.plugin = plugin;
this.config = config;
this.processing = processing;
this.infoSystem = infoSystem;
this.connectionSystem = connectionSystem;
this.serverInfo = serverInfo;
@ -59,11 +63,11 @@ public class InfoRequestHandlerFactory {
}
CacheRequest cacheAnalysisPageRequest() {
return new CacheAnalysisPageRequest(config.get(), htmlExport.get());
return new CacheAnalysisPageRequest(config.get(), processing.get(), htmlExport.get());
}
CacheRequest cacheInspectPageRequest() {
return new CacheInspectPageRequest(config.get(), serverInfo.get(), htmlExport.get());
return new CacheInspectPageRequest(config.get(), processing.get(), serverInfo.get(), htmlExport.get());
}
CacheRequest cacheInspectPluginsTabRequest() {

View File

@ -20,10 +20,15 @@ import java.util.UUID;
*/
public class ChatListener implements Listener {
private final Processing processing;
private final ErrorHandler errorHandler;
@Inject
public ChatListener(ErrorHandler errorHandler) {
public ChatListener(
Processing processing,
ErrorHandler errorHandler
) {
this.processing = processing;
this.errorHandler = errorHandler;
}
@ -45,6 +50,6 @@ public class ChatListener implements Listener {
UUID uuid = p.getUniqueId();
String name = p.getName();
String displayName = p.getDisplayName();
Processing.submit(new NameProcessor(uuid, name, displayName));
processing.submit(new NameProcessor(uuid, name, displayName));
}
}

View File

@ -23,11 +23,17 @@ import javax.inject.Inject;
public class CommandListener implements Listener {
private final Plan plugin;
private final Processing processing;
private final ErrorHandler errorHandler;
@Inject
public CommandListener(Plan plugin, ErrorHandler errorHandler) {
public CommandListener(
Plan plugin,
Processing processing,
ErrorHandler errorHandler
) {
this.plugin = plugin;
this.processing = processing;
this.errorHandler = errorHandler;
}
@ -61,7 +67,7 @@ public class CommandListener implements Listener {
commandName = command.getName();
}
}
Processing.submit(new CommandProcessor(commandName));
processing.submit(new CommandProcessor(commandName));
}
private Command getBukkitCommand(String commandName) {

View File

@ -27,10 +27,15 @@ import javax.inject.Inject;
*/
public class DeathEventListener implements Listener {
private final Processing processing;
private final ErrorHandler errorHandler;
@Inject
public DeathEventListener(ErrorHandler errorHandler) {
public DeathEventListener(
Processing processing,
ErrorHandler errorHandler
) {
this.processing = processing;
this.errorHandler = errorHandler;
}
@ -42,7 +47,7 @@ public class DeathEventListener implements Listener {
if (dead instanceof Player) {
// Process Death
Processing.submitCritical(() -> SessionCache.getCachedSession(dead.getUniqueId()).ifPresent(Session::died));
SessionCache.getCachedSession(dead.getUniqueId()).ifPresent(Session::died);
}
try {
@ -70,7 +75,7 @@ public class DeathEventListener implements Listener {
processor = handleProjectileKill(time, dead, (Projectile) killerEntity);
}
if (processor != null) {
Processing.submit(processor);
processing.submit(processor);
}
}

View File

@ -32,6 +32,7 @@ public class PlayerOnlineListener implements Listener {
private static boolean countKicks = true;
private final Processing processing;
private final SessionCache sessionCache;
private final ErrorHandler errorHandler;
private final RunnableFactory runnableFactory;
@ -41,7 +42,13 @@ public class PlayerOnlineListener implements Listener {
}
@Inject
public PlayerOnlineListener(SessionCache sessionCache, RunnableFactory runnableFactory, ErrorHandler errorHandler) {
public PlayerOnlineListener(
Processing processing,
SessionCache sessionCache,
RunnableFactory runnableFactory,
ErrorHandler errorHandler
) {
this.processing = processing;
this.sessionCache = sessionCache;
this.runnableFactory = runnableFactory;
this.errorHandler = errorHandler;
@ -54,7 +61,7 @@ public class PlayerOnlineListener implements Listener {
UUID uuid = event.getPlayer().getUniqueId();
boolean op = event.getPlayer().isOp();
boolean banned = result == PlayerLoginEvent.Result.KICK_BANNED;
Processing.submit(new BanAndOpProcessor(uuid, () -> banned, op));
processing.submit(new BanAndOpProcessor(uuid, () -> banned, op));
} catch (Exception e) {
errorHandler.log(L.ERROR, this.getClass(), e);
}
@ -75,7 +82,7 @@ public class PlayerOnlineListener implements Listener {
return;
}
UUID uuid = event.getPlayer().getUniqueId();
Processing.submit(new KickProcessor(uuid));
processing.submit(new KickProcessor(uuid));
} catch (Exception e) {
errorHandler.log(L.ERROR, this.getClass(), e);
}
@ -116,7 +123,7 @@ public class PlayerOnlineListener implements Listener {
new PlayerPageUpdateProcessor(uuid)
)
).runTaskAsynchronously();
Processing.submit(new NetworkPageUpdateProcessor());
processing.submit(new NetworkPageUpdateProcessor());
}
@EventHandler(priority = EventPriority.MONITOR)
@ -135,9 +142,9 @@ public class PlayerOnlineListener implements Listener {
AFKListener.AFK_TRACKER.loggedOut(uuid, time);
Processing.submit(new BanAndOpProcessor(uuid, player::isBanned, player.isOp()));
Processing.submit(new EndSessionProcessor(uuid, time));
Processing.submit(new NetworkPageUpdateProcessor());
Processing.submit(new PlayerPageUpdateProcessor(uuid));
processing.submit(new BanAndOpProcessor(uuid, player::isBanned, player.isOp()));
processing.submit(new EndSessionProcessor(uuid, time));
processing.submit(new NetworkPageUpdateProcessor());
processing.submit(new PlayerPageUpdateProcessor(uuid));
}
}

View File

@ -33,16 +33,19 @@ import java.util.UUID;
*/
public class PlayerOnlineListener implements Listener {
private final Processing processing;
private final SessionCache sessionCache;
private final ServerInfo serverInfo;
private final ErrorHandler errorHandler;
@Inject
public PlayerOnlineListener(
Processing processing,
SessionCache sessionCache,
ServerInfo serverInfo,
ErrorHandler errorHandler
) {
this.processing = processing;
this.sessionCache = sessionCache;
this.serverInfo = serverInfo;
this.errorHandler = errorHandler;
@ -59,10 +62,10 @@ public class PlayerOnlineListener implements Listener {
sessionCache.cacheSession(uuid, new Session(uuid, now, "", ""));
Processing.submit(new BungeePlayerRegisterProcessor(uuid, name, now,
processing.submit(new BungeePlayerRegisterProcessor(uuid, name, now,
new IPUpdateProcessor(uuid, address, now))
);
Processing.submit(new PlayerPageUpdateProcessor(uuid));
processing.submit(new PlayerPageUpdateProcessor(uuid));
ResponseCache.clearResponse(PageId.SERVER.of(serverInfo.getServerUUID()));
} catch (Exception e) {
errorHandler.log(L.WARN, this.getClass(), e);
@ -76,7 +79,7 @@ public class PlayerOnlineListener implements Listener {
UUID uuid = player.getUniqueId();
sessionCache.endSession(uuid, System.currentTimeMillis());
Processing.submit(new PlayerPageUpdateProcessor(uuid));
processing.submit(new PlayerPageUpdateProcessor(uuid));
ResponseCache.clearResponse(PageId.SERVER.of(serverInfo.getServerUUID()));
} catch (Exception e) {
errorHandler.log(L.WARN, this.getClass(), e);
@ -92,7 +95,7 @@ public class PlayerOnlineListener implements Listener {
long now = System.currentTimeMillis();
// Replaces the current session in the cache.
sessionCache.cacheSession(uuid, new Session(uuid, now, "", ""));
Processing.submit(new PlayerPageUpdateProcessor(uuid));
processing.submit(new PlayerPageUpdateProcessor(uuid));
} catch (Exception e) {
errorHandler.log(L.WARN, this.getClass(), e);
}

View File

@ -20,10 +20,15 @@ import java.util.UUID;
*/
public class SpongeChatListener {
private final Processing processing;
private ErrorHandler errorHandler;
@Inject
public SpongeChatListener(ErrorHandler errorHandler) {
public SpongeChatListener(
Processing processing,
ErrorHandler errorHandler
) {
this.processing = processing;
this.errorHandler = errorHandler;
}
@ -44,7 +49,7 @@ public class SpongeChatListener {
UUID uuid = player.getUniqueId();
String name = player.getName();
String displayName = player.getDisplayNameData().displayName().get().toPlain();
Processing.submit(new NameProcessor(uuid, name, displayName));
processing.submit(new NameProcessor(uuid, name, displayName));
}
}

View File

@ -24,10 +24,15 @@ import java.util.Optional;
*/
public class SpongeCommandListener {
private final Processing processing;
private ErrorHandler errorHandler;
@Inject
public SpongeCommandListener(ErrorHandler errorHandler) {
public SpongeCommandListener(
Processing processing,
ErrorHandler errorHandler
) {
this.processing = processing;
this.errorHandler = errorHandler;
}
@ -60,7 +65,7 @@ public class SpongeCommandListener {
commandName = existingCommand.get().getPrimaryAlias();
}
}
Processing.submit(new CommandProcessor(commandName));
processing.submit(new CommandProcessor(commandName));
}
}

View File

@ -34,10 +34,15 @@ import java.util.UUID;
*/
public class SpongeDeathListener {
private final Processing processing;
private ErrorHandler errorHandler;
@Inject
public SpongeDeathListener(ErrorHandler errorHandler) {
public SpongeDeathListener(
Processing processing,
ErrorHandler errorHandler
) {
this.processing = processing;
this.errorHandler = errorHandler;
}
@ -48,7 +53,7 @@ public class SpongeDeathListener {
if (dead instanceof Player) {
// Process Death
Processing.submitCritical(() -> SessionCache.getCachedSession(dead.getUniqueId()).ifPresent(Session::died));
SessionCache.getCachedSession(dead.getUniqueId()).ifPresent(Session::died);
}
try {
@ -73,7 +78,7 @@ public class SpongeDeathListener {
processor = handleProjectileKill(time, dead, (Projectile) killerEntity);
}
if (processor != null) {
Processing.submit(processor);
processing.submit(processor);
}
}

View File

@ -33,12 +33,19 @@ import java.util.UUID;
*/
public class SpongePlayerListener {
private final Processing processing;
private SessionCache sessionCache;
private RunnableFactory runnableFactory;
private ErrorHandler errorHandler;
@Inject
public SpongePlayerListener(SessionCache sessionCache, RunnableFactory runnableFactory, ErrorHandler errorHandler) {
public SpongePlayerListener(
Processing processing,
SessionCache sessionCache,
RunnableFactory runnableFactory,
ErrorHandler errorHandler
) {
this.processing = processing;
this.sessionCache = sessionCache;
this.runnableFactory = runnableFactory;
this.errorHandler = errorHandler;
@ -57,14 +64,14 @@ public class SpongePlayerListener {
GameProfile profile = event.getProfile();
UUID uuid = profile.getUniqueId();
boolean banned = isBanned(profile);
Processing.submit(new BanAndOpProcessor(uuid, () -> banned, false));
processing.submit(new BanAndOpProcessor(uuid, () -> banned, false));
}
@Listener(order = Order.POST)
public void onKick(KickPlayerEvent event) {
try {
UUID uuid = event.getTargetEntity().getUniqueId();
Processing.submit(new KickProcessor(uuid));
processing.submit(new KickProcessor(uuid));
} catch (Exception e) {
errorHandler.log(L.ERROR, this.getClass(), e);
}
@ -117,7 +124,7 @@ public class SpongePlayerListener {
new PlayerPageUpdateProcessor(uuid)
)
).runTaskAsynchronously();
Processing.submit(new NetworkPageUpdateProcessor());
processing.submit(new NetworkPageUpdateProcessor());
}
@Listener(order = Order.POST)
@ -137,9 +144,9 @@ public class SpongePlayerListener {
SpongeAFKListener.AFK_TRACKER.loggedOut(uuid, time);
boolean banned = isBanned(player.getProfile());
Processing.submit(new BanAndOpProcessor(uuid, () -> banned, false));
Processing.submit(new EndSessionProcessor(uuid, time));
Processing.submit(new NetworkPageUpdateProcessor());
Processing.submit(new PlayerPageUpdateProcessor(uuid));
processing.submit(new BanAndOpProcessor(uuid, () -> banned, false));
processing.submit(new EndSessionProcessor(uuid, time));
processing.submit(new NetworkPageUpdateProcessor());
processing.submit(new PlayerPageUpdateProcessor(uuid));
}
}

View File

@ -1,36 +1,43 @@
package com.djrapitops.plan.system.processing;
import com.djrapitops.plan.PlanPlugin;
import com.djrapitops.plan.api.exceptions.EnableException;
import com.djrapitops.plan.system.PlanSystem;
import com.djrapitops.plan.system.SubSystem;
import com.djrapitops.plan.system.locale.Locale;
import com.djrapitops.plan.system.locale.lang.PluginLang;
import com.djrapitops.plugin.StaticHolder;
import com.djrapitops.plugin.api.utility.log.Log;
import com.djrapitops.plugin.utilities.Verify;
import com.djrapitops.plugin.logging.L;
import com.djrapitops.plugin.logging.console.PluginLogger;
import com.djrapitops.plugin.logging.error.ErrorHandler;
import dagger.Lazy;
import javax.inject.Inject;
import javax.inject.Singleton;
import java.util.List;
import java.util.concurrent.*;
import java.util.function.Supplier;
@Singleton
public class Processing implements SubSystem {
private final Supplier<Locale> locale;
private final Lazy<Locale> locale;
private final PluginLogger logger;
private final ErrorHandler errorHandler;
private final ExecutorService nonCriticalExecutor;
private final ExecutorService criticalExecutor;
public Processing(Supplier<Locale> locale) {
@Inject
public Processing(
Lazy<Locale> locale,
PluginLogger logger,
ErrorHandler errorHandler
) {
this.locale = locale;
this.logger = logger;
this.errorHandler = errorHandler;
nonCriticalExecutor = Executors.newFixedThreadPool(6);
criticalExecutor = Executors.newFixedThreadPool(2);
saveInstance(nonCriticalExecutor);
saveInstance(criticalExecutor);
saveInstance(this);
}
public static void submit(Runnable runnable) {
public void submit(Runnable runnable) {
if (runnable instanceof CriticalRunnable) {
submitCritical(runnable);
return;
@ -38,54 +45,32 @@ public class Processing implements SubSystem {
submitNonCritical(runnable);
}
public static void saveInstance(Object obj) {
StaticHolder.saveInstance(obj.getClass(), PlanPlugin.getInstance().getClass());
}
public static void submitNonCritical(Runnable runnable) {
saveInstance(runnable);
ExecutorService executor = getInstance().nonCriticalExecutor;
if (executor.isShutdown()) {
public void submitNonCritical(Runnable runnable) {
if (nonCriticalExecutor.isShutdown()) {
return;
}
CompletableFuture.supplyAsync(() -> {
runnable.run();
return true;
}, executor).handle(Processing::exceptionHandler);
}, nonCriticalExecutor).handle(this::exceptionHandlerNonCritical);
}
public static void submitCritical(Runnable runnable) {
saveInstance(runnable);
public void submitCritical(Runnable runnable) {
CompletableFuture.supplyAsync(() -> {
runnable.run();
return true;
}, getInstance().criticalExecutor).handle(Processing::exceptionHandler);
}, criticalExecutor).handle(this::exceptionHandlerCritical);
}
public static void submitNonCritical(Runnable... runnables) {
for (Runnable runnable : runnables) {
submitNonCritical(runnable);
}
}
public static void submitCritical(Runnable... runnables) {
for (Runnable runnable : runnables) {
submitCritical(runnable);
}
}
public static <T> Future<T> submit(Callable<T> task) {
saveInstance(task);
public <T> Future<T> submit(Callable<T> task) {
if (task instanceof CriticalCallable) {
return submitCritical(task);
}
return submitNonCritical(task);
}
public static <T> Future<T> submitNonCritical(Callable<T> task) {
saveInstance(task);
ExecutorService executor = getInstance().nonCriticalExecutor;
if (executor.isShutdown()) {
public <T> Future<T> submitNonCritical(Callable<T> task) {
if (nonCriticalExecutor.isShutdown()) {
return null;
}
return CompletableFuture.supplyAsync(() -> {
@ -94,31 +79,31 @@ public class Processing implements SubSystem {
} catch (Exception e) {
throw new IllegalStateException(e);
}
}, getInstance().nonCriticalExecutor).handle(Processing::exceptionHandler);
}, nonCriticalExecutor).handle(this::exceptionHandlerNonCritical);
}
private static <T> T exceptionHandler(T t, Throwable throwable) {
private <T> T exceptionHandlerNonCritical(T t, Throwable throwable) {
if (throwable != null) {
Log.toLog(Processing.class, throwable.getCause());
errorHandler.log(L.WARN, Processing.class, throwable.getCause());
}
return t;
}
public static <T> Future<T> submitCritical(Callable<T> task) {
saveInstance(task);
private <T> T exceptionHandlerCritical(T t, Throwable throwable) {
if (throwable != null) {
errorHandler.log(L.ERROR, Processing.class, throwable.getCause());
}
return t;
}
public <T> Future<T> submitCritical(Callable<T> task) {
return CompletableFuture.supplyAsync(() -> {
try {
return task.call();
} catch (Exception e) {
throw new IllegalStateException(e);
}
}, getInstance().criticalExecutor).handle(Processing::exceptionHandler);
}
public static Processing getInstance() {
Processing processing = PlanSystem.getInstance().getProcessing();
Verify.nullCheck(processing, () -> new IllegalStateException("Processing System has not been initialized."));
return processing;
}, criticalExecutor).handle(this::exceptionHandlerCritical);
}
@Override
@ -135,12 +120,12 @@ public class Processing implements SubSystem {
public void disable() {
nonCriticalExecutor.shutdown();
List<Runnable> criticalTasks = criticalExecutor.shutdownNow();
Log.info(locale.get().getString(PluginLang.DISABLED_PROCESSING, criticalTasks.size()));
logger.info(locale.get().getString(PluginLang.DISABLED_PROCESSING, criticalTasks.size()));
for (Runnable runnable : criticalTasks) {
try {
runnable.run();
} catch (Exception | NoClassDefFoundError | NoSuchMethodError | NoSuchFieldError e) {
Log.toLog(this.getClass(), e);
errorHandler.log(L.WARN, this.getClass(), e);
}
}
if (!nonCriticalExecutor.isTerminated()) {
@ -153,6 +138,6 @@ public class Processing implements SubSystem {
if (!criticalExecutor.isTerminated()) {
criticalExecutor.shutdownNow();
}
Log.info(locale.get().getString(PluginLang.DISABLED_PROCESSING_COMPLETE));
logger.info(locale.get().getString(PluginLang.DISABLED_PROCESSING_COMPLETE));
}
}

View File

@ -22,6 +22,8 @@ public class BungeePlayerRegisterProcessor implements CriticalRunnable {
private final long registered;
private final Runnable[] afterProcess;
private Processing processing;
public BungeePlayerRegisterProcessor(UUID uuid, String name, long registered, Runnable... afterProcess) {
this.uuid = uuid;
this.name = name;
@ -39,9 +41,8 @@ public class BungeePlayerRegisterProcessor implements CriticalRunnable {
database.save().registerNewUser(uuid, registered, name);
} finally {
for (Runnable process : afterProcess) {
Processing.submit(process);
processing.submit(process);
}
}
}
}

View File

@ -24,6 +24,8 @@ public class RegisterProcessor extends AbsRunnable {
private final String name;
private final Runnable[] afterProcess;
private Processing processing;
public RegisterProcessor(UUID uuid, Supplier<Long> registered, String name, Runnable... afterProcess) {
this.uuid = uuid;
this.registered = registered;
@ -44,7 +46,7 @@ public class RegisterProcessor extends AbsRunnable {
}
} finally {
for (Runnable runnable : afterProcess) {
Processing.submit(runnable);
processing.submit(runnable);
}
cancel();
}

View File

@ -27,11 +27,17 @@ import java.util.Map;
public class WorldAliasSettings {
private final Lazy<PlanConfig> config;
private final Processing processing;
private final ErrorHandler errorHandler;
@Inject
public WorldAliasSettings(Lazy<PlanConfig> config, ErrorHandler errorHandler) {
public WorldAliasSettings(
Lazy<PlanConfig> config,
Processing processing,
ErrorHandler errorHandler
) {
this.config = config;
this.processing = processing;
this.errorHandler = errorHandler;
}
@ -77,7 +83,7 @@ public class WorldAliasSettings {
String previousValue = aliasSect.getConfigNode(world).getValue();
if (Verify.isEmpty(previousValue)) {
aliasSect.set(world, world);
Processing.submitNonCritical(() -> {
processing.submitNonCritical(() -> {
try {
aliasSect.save();
} catch (IOException e) {

View File

@ -40,6 +40,7 @@ public class NetworkSettings {
private static final String VAL_SPLIT = ";;VALUE;;";
private final Lazy<PlanConfig> config;
private final Processing processing;
private final Lazy<Database> database;
private final Lazy<ServerInfo> serverInfo;
private final PluginLogger logger;
@ -50,6 +51,7 @@ public class NetworkSettings {
public NetworkSettings(
Lazy<PlanConfig> config,
ServerSpecificSettings serverSpecificSettings,
Processing processing,
Lazy<Database> database,
Lazy<ServerInfo> serverInfo,
PluginLogger logger,
@ -57,6 +59,7 @@ public class NetworkSettings {
) {
this.config = config;
this.serverSpecificSettings = serverSpecificSettings;
this.processing = processing;
this.database = database;
this.serverInfo = serverInfo;
this.logger = logger;
@ -74,7 +77,7 @@ public class NetworkSettings {
return;
}
Processing.submitNonCritical(this::loadFromDatabase);
processing.submitNonCritical(this::loadFromDatabase);
}
public void placeSettingsToDB() {
@ -82,7 +85,7 @@ public class NetworkSettings {
return;
}
Processing.submitCritical(this::placeToDatabase);
processing.submitNonCritical(this::placeToDatabase);
}
void loadFromDatabase() {

View File

@ -21,6 +21,7 @@ import javax.inject.Inject;
public class BukkitTaskSystem extends ServerTaskSystem {
private final Plan plugin;
private final PingCountTimer pingCountTimer;
@Inject
public BukkitTaskSystem(
@ -31,7 +32,8 @@ public class BukkitTaskSystem extends ServerTaskSystem {
BukkitTPSCountTimer bukkitTPSCountTimer,
NetworkPageRefreshTask networkPageRefreshTask,
BootAnalysisTask bootAnalysisTask,
PeriodicAnalysisTask periodicAnalysisTask
PeriodicAnalysisTask periodicAnalysisTask,
PingCountTimer pingCountTimer
) {
super(
runnableFactory,
@ -44,14 +46,13 @@ public class BukkitTaskSystem extends ServerTaskSystem {
periodicAnalysisTask
);
this.plugin = plugin;
this.pingCountTimer = pingCountTimer;
}
@Override
public void enable() {
super.enable();
try {
PingCountTimer pingCountTimer = new PingCountTimer(runnableFactory);
plugin.registerListener(pingCountTimer);
registerTask("PingCountTimer", pingCountTimer)
.runTaskTimer(20L, PingCountTimer.PING_INTERVAL);

View File

@ -19,12 +19,15 @@ import java.util.List;
public abstract class TPSCountTimer extends AbsRunnable {
protected final List<TPS> history;
protected final Processing processing;
protected final PluginLogger logger;
protected final ErrorHandler errorHandler;
protected int latestPlayersOnline = 0;
public TPSCountTimer(PluginLogger logger, ErrorHandler errorHandler) {
public TPSCountTimer(Processing processing, PluginLogger logger, ErrorHandler errorHandler) {
this.processing = processing;
this.logger = logger;
this.errorHandler = errorHandler;
history = new ArrayList<>();
@ -39,7 +42,7 @@ public abstract class TPSCountTimer extends AbsRunnable {
addNewTPSEntry(nanoTime, now);
if (history.size() >= 60) {
Processing.submit(new TPSInsertProcessor(new ArrayList<>(history)));
processing.submit(new TPSInsertProcessor(new ArrayList<>(history)));
history.clear();
}
} catch (Exception | NoClassDefFoundError | NoSuchMethodError | NoSuchFieldError e) {

View File

@ -3,23 +3,27 @@ package com.djrapitops.plan.system.tasks.bungee;
import com.djrapitops.plan.data.container.TPS;
import com.djrapitops.plan.data.container.builders.TPSBuilder;
import com.djrapitops.plan.system.info.server.properties.ServerProperties;
import com.djrapitops.plan.system.processing.Processing;
import com.djrapitops.plan.system.tasks.TPSCountTimer;
import com.djrapitops.plugin.logging.console.PluginLogger;
import com.djrapitops.plugin.logging.error.ErrorHandler;
import javax.inject.Inject;
import javax.inject.Singleton;
@Singleton
public class BungeeTPSCountTimer extends TPSCountTimer {
private final ServerProperties serverProperties;
@Inject
public BungeeTPSCountTimer(
Processing processing,
ServerProperties serverProperties,
PluginLogger logger,
ErrorHandler errorHandler
) {
super(logger, errorHandler);
super(processing, logger, errorHandler);
this.serverProperties = serverProperties;
}

View File

@ -3,6 +3,7 @@ package com.djrapitops.plan.system.tasks.server;
import com.djrapitops.plan.Plan;
import com.djrapitops.plan.data.container.TPS;
import com.djrapitops.plan.system.info.server.properties.ServerProperties;
import com.djrapitops.plan.system.processing.Processing;
import com.djrapitops.plan.system.tasks.TPSCountTimer;
import com.djrapitops.plugin.api.TimeAmount;
import com.djrapitops.plugin.api.utility.log.Log;
@ -11,9 +12,11 @@ import com.djrapitops.plugin.logging.error.ErrorHandler;
import org.bukkit.World;
import javax.inject.Inject;
import javax.inject.Singleton;
import java.lang.management.ManagementFactory;
import java.lang.management.OperatingSystemMXBean;
@Singleton
public class BukkitTPSCountTimer extends TPSCountTimer {
protected final Plan plugin;
@ -23,11 +26,12 @@ public class BukkitTPSCountTimer extends TPSCountTimer {
@Inject
public BukkitTPSCountTimer(
Plan plugin,
Processing processing,
ServerProperties serverProperties,
PluginLogger logger,
ErrorHandler errorHandler
) {
super(logger, errorHandler);
super(processing, logger, errorHandler);
this.plugin = plugin;
this.serverProperties = serverProperties;
lastCheckNano = -1;

View File

@ -3,6 +3,7 @@ package com.djrapitops.plan.system.tasks.server;
import com.djrapitops.plan.Plan;
import com.djrapitops.plan.data.container.TPS;
import com.djrapitops.plan.system.info.server.properties.ServerProperties;
import com.djrapitops.plan.system.processing.Processing;
import com.djrapitops.plugin.logging.console.PluginLogger;
import com.djrapitops.plugin.logging.error.ErrorHandler;
import org.bukkit.World;
@ -14,11 +15,12 @@ public class PaperTPSCountTimer extends BukkitTPSCountTimer {
@Inject
public PaperTPSCountTimer(
Plan plugin,
Processing processing,
ServerProperties serverProperties,
PluginLogger logger,
ErrorHandler errorHandler
) {
super(plugin, serverProperties, logger, errorHandler);
super(plugin, processing, serverProperties, logger, errorHandler);
}
@Override

View File

@ -38,6 +38,8 @@ import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.event.player.PlayerQuitEvent;
import javax.inject.Inject;
import javax.inject.Singleton;
import java.lang.invoke.MethodHandle;
import java.lang.invoke.MethodHandles;
import java.lang.invoke.MethodHandles.Lookup;
@ -52,6 +54,7 @@ import java.util.*;
*
* @author games647
*/
@Singleton
public class PingCountTimer extends AbsRunnable implements Listener {
//the server is pinging the client every 40 Ticks (2 sec) - so check it then
@ -88,9 +91,16 @@ public class PingCountTimer extends AbsRunnable implements Listener {
}
private final Map<UUID, List<DateObj<Integer>>> playerHistory;
private final Processing processing;
private final RunnableFactory runnableFactory;
public PingCountTimer(RunnableFactory runnableFactory) {
@Inject
public PingCountTimer(
Processing processing,
RunnableFactory runnableFactory
) {
this.processing = processing;
this.runnableFactory = runnableFactory;
playerHistory = new HashMap<>();
}
@ -119,7 +129,7 @@ public class PingCountTimer extends AbsRunnable implements Listener {
}
history.add(new DateObj<>(time, ping));
if (history.size() >= 30) {
Processing.submit(new PingInsertProcessor(uuid, new ArrayList<>(history)));
processing.submit(new PingInsertProcessor(uuid, new ArrayList<>(history)));
history.clear();
}
} else {

View File

@ -3,6 +3,7 @@ package com.djrapitops.plan.system.tasks.server;
import com.djrapitops.plan.data.container.TPS;
import com.djrapitops.plan.data.container.builders.TPSBuilder;
import com.djrapitops.plan.system.info.server.properties.ServerProperties;
import com.djrapitops.plan.system.processing.Processing;
import com.djrapitops.plan.system.tasks.TPSCountTimer;
import com.djrapitops.plugin.api.utility.log.Log;
import com.djrapitops.plugin.logging.console.PluginLogger;
@ -11,17 +12,24 @@ import org.spongepowered.api.Sponge;
import org.spongepowered.api.world.World;
import javax.inject.Inject;
import javax.inject.Singleton;
import java.lang.management.ManagementFactory;
import java.lang.management.OperatingSystemMXBean;
@Singleton
public class SpongeTPSCountTimer extends TPSCountTimer {
private long lastCheckNano;
private ServerProperties serverProperties;
@Inject
public SpongeTPSCountTimer(ServerProperties serverProperties, PluginLogger logger, ErrorHandler errorHandler) {
super(logger, errorHandler);
public SpongeTPSCountTimer(
Processing processing,
ServerProperties serverProperties,
PluginLogger logger,
ErrorHandler errorHandler
) {
super(processing, logger, errorHandler);
this.serverProperties = serverProperties;
lastCheckNano = -1;
}
@ -43,7 +51,7 @@ public class SpongeTPSCountTimer extends TPSCountTimer {
/**
* Calculates the TPS
*
* @param now The time right now
* @param now The time right now
* @return the TPS
*/
private TPS calculateTPS(long now) {

View File

@ -9,6 +9,7 @@ import com.djrapitops.plan.api.exceptions.connection.WebException;
import com.djrapitops.plan.system.database.databases.Database;
import com.djrapitops.plan.system.info.InfoSystem;
import com.djrapitops.plan.system.info.server.ServerInfo;
import com.djrapitops.plan.system.processing.Processing;
import com.djrapitops.plan.system.webserver.Request;
import com.djrapitops.plan.system.webserver.auth.Authentication;
import com.djrapitops.plan.system.webserver.cache.PageId;
@ -32,6 +33,7 @@ import java.util.UUID;
@Singleton
public class ServerPageHandler implements PageHandler {
private final Processing processing;
private final ResponseFactory responseFactory;
private final Database database;
private final ServerInfo serverInfo;
@ -39,11 +41,13 @@ public class ServerPageHandler implements PageHandler {
@Inject
public ServerPageHandler(
Processing processing,
ResponseFactory responseFactory,
Database database,
ServerInfo serverInfo,
InfoSystem infoSystem
) {
this.processing = processing;
this.responseFactory = responseFactory;
this.database = database;
this.serverInfo = serverInfo;
@ -72,7 +76,7 @@ public class ServerPageHandler implements PageHandler {
}
return ResponseCache.loadResponse(PageId.SERVER.of(serverUUID));
}
return AnalysisPageResponse.refreshNow(serverUUID, infoSystem);
return AnalysisPageResponse.refreshNow(serverUUID, processing, infoSystem);
}
}

View File

@ -20,9 +20,10 @@ import java.util.UUID;
*/
public class AnalysisPageResponse extends Response {
// TODO Split responsibility so that this method does not call system to refresh and also render a refresh page.
@Deprecated
public static AnalysisPageResponse refreshNow(UUID serverUUID, InfoSystem infoSystem) {
Processing.submitNonCritical(() -> {
public static AnalysisPageResponse refreshNow(UUID serverUUID, Processing processing, InfoSystem infoSystem) {
processing.submitNonCritical(() -> {
try {
infoSystem.generateAnalysisPage(serverUUID);
} catch (NoServersException | ConnectionFailException e) {

View File

@ -9,6 +9,7 @@ import com.djrapitops.plan.api.exceptions.ParseException;
import com.djrapitops.plan.api.exceptions.database.DBOpException;
import com.djrapitops.plan.data.container.UserInfo;
import com.djrapitops.plan.system.database.databases.Database;
import com.djrapitops.plan.system.file.FileSystem;
import com.djrapitops.plan.system.info.connection.ConnectionSystem;
import com.djrapitops.plan.system.info.server.ServerInfo;
import com.djrapitops.plan.system.processing.Processing;
@ -39,6 +40,9 @@ import java.util.*;
public class HtmlExport extends SpecificExport {
private final PlanPlugin plugin;
private final Theme theme;
private final Processing processing;
private final FileSystem fileSystem;
private final Database database;
private final PageFactory pageFactory;
private final ConnectionSystem connectionSystem;
@ -48,6 +52,9 @@ public class HtmlExport extends SpecificExport {
public HtmlExport(
PlanPlugin plugin,
PlanConfig config,
Theme theme,
Processing processing,
FileSystem fileSystem,
Database database,
PageFactory pageFactory,
ServerInfo serverInfo,
@ -56,26 +63,21 @@ public class HtmlExport extends SpecificExport {
) {
super(config, serverInfo);
this.plugin = plugin;
this.theme = theme;
this.processing = processing;
this.fileSystem = fileSystem;
this.database = database;
this.pageFactory = pageFactory;
this.connectionSystem = connectionSystem;
this.errorHandler = errorHandler;
}
@Deprecated
public static void exportServer_Old(UUID serverUUID) {
}
@Deprecated
public static void exportPlayer_Old(UUID playerUUID) {
}
public void exportServer(UUID serverUUID) {
if (Check.isBukkitAvailable() && connectionSystem.isServerAvailable()) {
return;
}
Optional<String> serverName = database.fetch().getServerName(serverUUID);
serverName.ifPresent(name -> Processing.submitNonCritical(() -> {
serverName.ifPresent(name -> processing.submitNonCritical(() -> {
try {
exportAvailableServerPage(serverUUID, name);
} catch (IOException e) {
@ -90,7 +92,7 @@ public class HtmlExport extends SpecificExport {
}
String playerName = database.fetch().getPlayerName(uuid);
if (playerName != null) {
Processing.submitNonCritical(() -> {
processing.submitNonCritical(() -> {
try {
exportAvailablePlayerPage(uuid, playerName);
} catch (IOException e) {
@ -184,8 +186,8 @@ public class HtmlExport extends SpecificExport {
copyFromJar(resources);
try {
String demo = FileUtil.getStringFromResource("web/js/demo.js")
.replace("${defaultTheme}", Theme.getValue_Old(ThemeVal.THEME_DEFAULT));
String demo = fileSystem.readFromResourceFlat("web/js/demo.js")
.replace("${defaultTheme}", theme.getValue(ThemeVal.THEME_DEFAULT));
List<String> lines = Arrays.asList(demo.split("\n"));
File outputFolder = new File(this.outputFolder, "js");
Verify.isTrue(outputFolder.exists() && outputFolder.isDirectory() || outputFolder.mkdirs(),