APF 3.3.0 Compiling version

This commit is contained in:
Rsl1122 2018-08-17 11:48:23 +03:00
parent 9d45fa1c40
commit 1833eda29b
49 changed files with 273 additions and 380 deletions

View File

@ -41,7 +41,7 @@
<dependency>
<groupId>com.djrapitops</groupId>
<artifactId>AbstractPluginFramework</artifactId>
<version>3.2.0</version>
<version>3.3.0-SNAPSHOT</version>
</dependency>
<!-- SoftDepended Plugins -->
<dependency>

View File

@ -33,7 +33,7 @@ import com.djrapitops.plugin.StaticHolder;
import com.djrapitops.plugin.api.Benchmark;
import com.djrapitops.plugin.api.utility.log.DebugLog;
import com.djrapitops.plugin.api.utility.log.Log;
import com.djrapitops.plugin.settings.ColorScheme;
import com.djrapitops.plugin.command.ColorScheme;
import org.bukkit.configuration.file.FileConfiguration;
import java.util.logging.Level;

View File

@ -16,7 +16,7 @@ import com.djrapitops.plugin.StaticHolder;
import com.djrapitops.plugin.api.Benchmark;
import com.djrapitops.plugin.api.utility.log.DebugLog;
import com.djrapitops.plugin.api.utility.log.Log;
import com.djrapitops.plugin.settings.ColorScheme;
import com.djrapitops.plugin.command.ColorScheme;
import java.io.InputStream;
import java.util.logging.Level;

View File

@ -7,7 +7,7 @@ package com.djrapitops.plan;
import com.djrapitops.plan.system.PlanSystem;
import com.djrapitops.plugin.IPlugin;
import com.djrapitops.plugin.api.Check;
import com.djrapitops.plugin.settings.ColorScheme;
import com.djrapitops.plugin.command.ColorScheme;
import java.io.File;
import java.io.InputStream;

View File

@ -12,7 +12,7 @@ import com.djrapitops.plugin.StaticHolder;
import com.djrapitops.plugin.api.Benchmark;
import com.djrapitops.plugin.api.utility.log.DebugLog;
import com.djrapitops.plugin.api.utility.log.Log;
import com.djrapitops.plugin.settings.ColorScheme;
import com.djrapitops.plugin.command.ColorScheme;
import com.google.inject.Inject;
import org.bstats.sponge.Metrics;
import org.slf4j.Logger;

View File

@ -10,7 +10,6 @@ import com.djrapitops.plan.system.settings.Permissions;
import com.djrapitops.plugin.command.CommandNode;
import com.djrapitops.plugin.command.CommandType;
import com.djrapitops.plugin.command.TreeCmdNode;
import com.djrapitops.plugin.command.defaultcmds.StatusCommand;
/**
* TreeCommand for the /plan command, and all subcommands.
@ -46,7 +45,6 @@ public class PlanBungeeCommand extends TreeCmdNode {
new BungeeSetupToggleCommand(plugin),
new ReloadCommand(plugin),
new DisableCommand(plugin),
new StatusCommand<>(plugin, Permissions.MANAGE.getPermission(), plugin.getColorScheme()),
// (Settings.ALLOW_UPDATE.isTrue() ? new UpdateCommand() : null)
};
setNodeGroups(analyticsGroup, webGroup, manageGroup);

View File

@ -4,12 +4,10 @@ import com.djrapitops.plan.PlanPlugin;
import com.djrapitops.plan.command.commands.*;
import com.djrapitops.plan.system.locale.Locale;
import com.djrapitops.plan.system.locale.lang.DeepHelpLang;
import com.djrapitops.plan.system.settings.Permissions;
import com.djrapitops.plan.system.settings.Settings;
import com.djrapitops.plugin.command.CommandNode;
import com.djrapitops.plugin.command.CommandType;
import com.djrapitops.plugin.command.TreeCmdNode;
import com.djrapitops.plugin.command.defaultcmds.StatusCommand;
/**
* TreeCommand for the /plan command, and all SubCommands.
@ -48,7 +46,6 @@ public class PlanCommand extends TreeCmdNode {
new InfoCommand(plugin),
new ReloadCommand(plugin),
new ManageCommand(plugin, this),
new StatusCommand<>(plugin, Permissions.MANAGE.getPermission(), plugin.getColorScheme()),
(Settings.DEV_MODE.isTrue() ? new DevCommand(plugin) : null),
// (Settings.ALLOW_UPDATE.isTrue() ? new UpdateCommand() : null)
};

View File

@ -18,8 +18,6 @@ import com.djrapitops.plugin.command.CommandNode;
import com.djrapitops.plugin.command.CommandType;
import com.djrapitops.plugin.command.CommandUtils;
import com.djrapitops.plugin.command.ISender;
import com.djrapitops.plugin.task.AbsRunnable;
import com.djrapitops.plugin.task.RunnableFactory;
import java.util.UUID;
@ -55,32 +53,27 @@ public class InspectCommand extends CommandNode {
}
private void runInspectTask(String playerName, ISender sender) {
RunnableFactory.createNew(new AbsRunnable("InspectTask") {
@Override
public void run() {
try {
UUID uuid = UUIDUtility.getUUIDOf(playerName);
if (uuid == null) {
sender.sendMessage(locale.getString(CommandLang.FAIL_USERNAME_NOT_VALID));
return;
}
Database activeDB = Database.getActive();
if (!activeDB.check().isPlayerRegistered(uuid)) {
sender.sendMessage(locale.getString(CommandLang.FAIL_USERNAME_NOT_KNOWN));
return;
}
checkWebUserAndNotify(activeDB, sender);
Processing.submit(new InspectCacheRequestProcessor(uuid, sender, playerName, locale));
} catch (DBOpException e) {
sender.sendMessage("§eDatabase exception occurred: " + e.getMessage());
Log.toLog(this.getClass(), e);
} finally {
this.cancel();
Processing.submitNonCritical(() -> {
try {
UUID uuid = UUIDUtility.getUUIDOf(playerName);
if (uuid == null) {
sender.sendMessage(locale.getString(CommandLang.FAIL_USERNAME_NOT_VALID));
return;
}
Database activeDB = Database.getActive();
if (!activeDB.check().isPlayerRegistered(uuid)) {
sender.sendMessage(locale.getString(CommandLang.FAIL_USERNAME_NOT_KNOWN));
return;
}
checkWebUserAndNotify(activeDB, sender);
Processing.submit(new InspectCacheRequestProcessor(uuid, sender, playerName, locale));
} catch (DBOpException e) {
sender.sendMessage("§eDatabase exception occurred: " + e.getMessage());
Log.toLog(this.getClass(), e);
}
}).runTaskAsynchronously();
});
}
private void checkWebUserAndNotify(Database activeDB, ISender sender) {

View File

@ -10,10 +10,10 @@ import com.djrapitops.plan.system.locale.lang.CommandLang;
import com.djrapitops.plan.system.locale.lang.DeepHelpLang;
import com.djrapitops.plan.system.settings.Permissions;
import com.djrapitops.plugin.api.utility.log.Log;
import com.djrapitops.plugin.command.ColorScheme;
import com.djrapitops.plugin.command.CommandNode;
import com.djrapitops.plugin.command.CommandType;
import com.djrapitops.plugin.command.ISender;
import com.djrapitops.plugin.settings.ColorScheme;
import java.util.List;

View File

@ -17,6 +17,7 @@ import com.djrapitops.plan.system.locale.lang.CmdHelpLang;
import com.djrapitops.plan.system.locale.lang.CommandLang;
import com.djrapitops.plan.system.locale.lang.DeepHelpLang;
import com.djrapitops.plan.system.locale.lang.GenericLang;
import com.djrapitops.plan.system.processing.Processing;
import com.djrapitops.plan.system.settings.Permissions;
import com.djrapitops.plan.utilities.MiscUtils;
import com.djrapitops.plan.utilities.uuid.UUIDUtility;
@ -24,8 +25,6 @@ import com.djrapitops.plugin.api.utility.log.Log;
import com.djrapitops.plugin.command.CommandNode;
import com.djrapitops.plugin.command.CommandType;
import com.djrapitops.plugin.command.ISender;
import com.djrapitops.plugin.task.AbsRunnable;
import com.djrapitops.plugin.task.RunnableFactory;
import java.util.ArrayList;
import java.util.List;
@ -70,31 +69,26 @@ public class QInspectCommand extends CommandNode {
}
private void runInspectTask(String playerName, ISender sender) {
RunnableFactory.createNew(new AbsRunnable("InspectTask") {
@Override
public void run() {
try {
UUID uuid = UUIDUtility.getUUIDOf(playerName);
if (uuid == null) {
sender.sendMessage(locale.getString(CommandLang.FAIL_USERNAME_NOT_VALID));
return;
}
PlayerContainer container = Database.getActive().fetch().getPlayerContainer(uuid);
if (!container.getValue(PlayerKeys.REGISTERED).isPresent()) {
sender.sendMessage(locale.getString(CommandLang.FAIL_USERNAME_NOT_KNOWN));
return;
}
sendMessages(sender, container);
} catch (DBOpException e) {
sender.sendMessage("§eDatabase exception occurred: " + e.getMessage());
Log.toLog(this.getClass(), e);
} finally {
this.cancel();
Processing.submitNonCritical(() -> {
try {
UUID uuid = UUIDUtility.getUUIDOf(playerName);
if (uuid == null) {
sender.sendMessage(locale.getString(CommandLang.FAIL_USERNAME_NOT_VALID));
return;
}
PlayerContainer container = Database.getActive().fetch().getPlayerContainer(uuid);
if (!container.getValue(PlayerKeys.REGISTERED).isPresent()) {
sender.sendMessage(locale.getString(CommandLang.FAIL_USERNAME_NOT_KNOWN));
return;
}
sendMessages(sender, container);
} catch (DBOpException e) {
sender.sendMessage("§eDatabase exception occurred: " + e.getMessage());
Log.toLog(this.getClass(), e);
}
}).runTaskAsynchronously();
});
}
private void sendMessages(ISender sender, PlayerContainer player) {

View File

@ -7,6 +7,7 @@ import com.djrapitops.plan.system.locale.Locale;
import com.djrapitops.plan.system.locale.lang.CmdHelpLang;
import com.djrapitops.plan.system.locale.lang.CommandLang;
import com.djrapitops.plan.system.locale.lang.DeepHelpLang;
import com.djrapitops.plan.system.processing.Processing;
import com.djrapitops.plan.system.settings.Permissions;
import com.djrapitops.plan.utilities.PassEncryptUtil;
import com.djrapitops.plugin.api.Check;
@ -15,8 +16,6 @@ import com.djrapitops.plugin.command.CommandNode;
import com.djrapitops.plugin.command.CommandType;
import com.djrapitops.plugin.command.CommandUtils;
import com.djrapitops.plugin.command.ISender;
import com.djrapitops.plugin.task.AbsRunnable;
import com.djrapitops.plugin.task.RunnableFactory;
import com.djrapitops.plugin.utilities.Verify;
import java.util.Arrays;
@ -113,29 +112,22 @@ public class RegisterCommand extends CommandNode {
}
private void registerUser(WebUser webUser, ISender sender) {
RunnableFactory.createNew(new AbsRunnable("Register WebUser Task") {
@Override
public void run() {
final String existsMsg = locale.getString(CommandLang.FAIL_WEB_USER_EXISTS);
final String userName = webUser.getName();
final String successMsg = locale.getString(CommandLang.WEB_USER_REGISTER_SUCCESS);
try {
Database database = Database.getActive();
boolean userExists = database.check().doesWebUserExists(userName);
if (userExists) {
sender.sendMessage(existsMsg);
return;
}
database.save().webUser(webUser);
sender.sendMessage(successMsg);
Log.info(locale.getString(CommandLang.WEB_USER_REGISTER_NOTIFY, userName, webUser.getPermLevel()));
} catch (Exception e) {
Log.toLog(this.getClass(), e);
} finally {
this.cancel();
Processing.submitCritical(() -> {
String userName = webUser.getName();
try {
Database database = Database.getActive();
boolean userExists = database.check().doesWebUserExists(userName);
if (userExists) {
sender.sendMessage(locale.getString(CommandLang.FAIL_WEB_USER_EXISTS));
return;
}
database.save().webUser(webUser);
sender.sendMessage(locale.getString(CommandLang.WEB_USER_REGISTER_SUCCESS));
Log.info(locale.getString(CommandLang.WEB_USER_REGISTER_NOTIFY, userName, webUser.getPermLevel()));
} catch (Exception e) {
Log.toLog(this.getClass(), e);
}
}).runTaskAsynchronously();
});
}
/**

View File

@ -7,14 +7,13 @@ import com.djrapitops.plan.system.locale.lang.CmdHelpLang;
import com.djrapitops.plan.system.locale.lang.CommandLang;
import com.djrapitops.plan.system.locale.lang.DeepHelpLang;
import com.djrapitops.plan.system.locale.lang.ManageLang;
import com.djrapitops.plan.system.processing.Processing;
import com.djrapitops.plan.system.settings.Permissions;
import com.djrapitops.plan.utilities.MiscUtils;
import com.djrapitops.plugin.api.utility.log.Log;
import com.djrapitops.plugin.command.CommandNode;
import com.djrapitops.plugin.command.CommandType;
import com.djrapitops.plugin.command.ISender;
import com.djrapitops.plugin.task.AbsRunnable;
import com.djrapitops.plugin.task.RunnableFactory;
import com.djrapitops.plugin.utilities.FormatUtils;
import com.djrapitops.plugin.utilities.Verify;
@ -52,29 +51,24 @@ public class SearchCommand extends CommandNode {
}
private void runSearchTask(String[] args, ISender sender) {
RunnableFactory.createNew(new AbsRunnable("SearchTask: " + Arrays.toString(args)) {
@Override
public void run() {
try {
String searchTerm = args[0];
List<String> names = MiscUtils.getMatchingPlayerNames(searchTerm);
Processing.submitNonCritical(() -> {
try {
String searchTerm = args[0];
List<String> names = MiscUtils.getMatchingPlayerNames(searchTerm);
boolean empty = Verify.isEmpty(names);
boolean empty = Verify.isEmpty(names);
sender.sendMessage(locale.getString(CommandLang.HEADER_SEARCH, empty ? 0 : names.size(), searchTerm));
// Results
if (!empty) {
sender.sendMessage(FormatUtils.collectionToStringNoBrackets(names));
}
sender.sendMessage(">");
} catch (DBOpException e) {
sender.sendMessage("§cDatabase error occurred: " + e.getMessage());
Log.toLog(this.getClass(), e);
} finally {
this.cancel();
sender.sendMessage(locale.getString(CommandLang.HEADER_SEARCH, empty ? 0 : names.size(), searchTerm));
// Results
if (!empty) {
sender.sendMessage(FormatUtils.collectionToStringNoBrackets(names));
}
sender.sendMessage(">");
} catch (DBOpException e) {
sender.sendMessage("§cDatabase error occurred: " + e.getMessage());
Log.toLog(this.getClass(), e);
}
}).runTaskAsynchronously();
});
}
}

View File

@ -12,13 +12,12 @@ import com.djrapitops.plan.system.locale.lang.CmdHelpLang;
import com.djrapitops.plan.system.locale.lang.CommandLang;
import com.djrapitops.plan.system.locale.lang.DeepHelpLang;
import com.djrapitops.plan.system.locale.lang.ManageLang;
import com.djrapitops.plan.system.processing.Processing;
import com.djrapitops.plan.system.settings.Permissions;
import com.djrapitops.plugin.api.utility.log.Log;
import com.djrapitops.plugin.command.CommandNode;
import com.djrapitops.plugin.command.CommandType;
import com.djrapitops.plugin.command.ISender;
import com.djrapitops.plugin.task.AbsRunnable;
import com.djrapitops.plugin.task.RunnableFactory;
import com.djrapitops.plugin.utilities.Verify;
import java.util.Arrays;
@ -67,23 +66,17 @@ public class ManageBackupCommand extends CommandNode {
}
private void runBackupTask(ISender sender, String[] args, Database database) {
RunnableFactory.createNew(new AbsRunnable("BackupTask") {
@Override
public void run() {
try {
Log.debug("Backup", "Start");
sender.sendMessage(locale.getString(ManageLang.PROGRESS_START));
createNewBackup(args[0], database);
sender.sendMessage(locale.getString(ManageLang.PROGRESS_SUCCESS));
} catch (Exception e) {
Log.toLog(ManageBackupCommand.class, e);
sender.sendMessage(locale.getString(ManageLang.PROGRESS_FAIL, e.getMessage()));
} finally {
Log.logDebug("Backup");
this.cancel();
}
Processing.submitCritical(() -> {
try {
Log.debug("Backup", "Start");
sender.sendMessage(locale.getString(ManageLang.PROGRESS_START));
createNewBackup(args[0], database);
sender.sendMessage(locale.getString(ManageLang.PROGRESS_SUCCESS));
} catch (Exception e) {
Log.toLog(ManageBackupCommand.class, e);
sender.sendMessage(locale.getString(ManageLang.PROGRESS_FAIL, e.getMessage()));
}
}).runTaskAsynchronously();
});
}
/**

View File

@ -10,13 +10,12 @@ import com.djrapitops.plan.system.locale.lang.CmdHelpLang;
import com.djrapitops.plan.system.locale.lang.CommandLang;
import com.djrapitops.plan.system.locale.lang.DeepHelpLang;
import com.djrapitops.plan.system.locale.lang.ManageLang;
import com.djrapitops.plan.system.processing.Processing;
import com.djrapitops.plan.system.settings.Permissions;
import com.djrapitops.plugin.api.utility.log.Log;
import com.djrapitops.plugin.command.CommandNode;
import com.djrapitops.plugin.command.CommandType;
import com.djrapitops.plugin.command.ISender;
import com.djrapitops.plugin.task.AbsRunnable;
import com.djrapitops.plugin.task.RunnableFactory;
import com.djrapitops.plugin.utilities.Verify;
import java.util.Arrays;
@ -66,22 +65,17 @@ public class ManageClearCommand extends CommandNode {
}
private void runClearTask(ISender sender, Database database) {
RunnableFactory.createNew(new AbsRunnable("DBClearTask") {
@Override
public void run() {
try {
sender.sendMessage(locale.getString(ManageLang.PROGRESS_START));
Processing.submitCritical(() -> {
try {
sender.sendMessage(locale.getString(ManageLang.PROGRESS_START));
database.remove().everything();
database.remove().everything();
sender.sendMessage(locale.getString(ManageLang.PROGRESS_SUCCESS));
} catch (DBOpException e) {
sender.sendMessage(locale.getString(ManageLang.PROGRESS_FAIL, e.getMessage()));
Log.toLog(this.getClass(), e);
} finally {
this.cancel();
}
sender.sendMessage(locale.getString(ManageLang.PROGRESS_SUCCESS));
} catch (DBOpException e) {
sender.sendMessage(locale.getString(ManageLang.PROGRESS_FAIL, e.getMessage()));
Log.toLog(this.getClass(), e);
}
}).runTaskAsynchronously();
});
}
}

View File

@ -16,10 +16,10 @@ import com.djrapitops.plan.system.processing.Processing;
import com.djrapitops.plan.system.settings.Permissions;
import com.djrapitops.plan.system.webserver.WebServerSystem;
import com.djrapitops.plugin.api.Check;
import com.djrapitops.plugin.command.ColorScheme;
import com.djrapitops.plugin.command.CommandNode;
import com.djrapitops.plugin.command.CommandType;
import com.djrapitops.plugin.command.ISender;
import com.djrapitops.plugin.settings.ColorScheme;
import java.util.List;
import java.util.UUID;

View File

@ -8,13 +8,12 @@ import com.djrapitops.plan.system.locale.lang.CmdHelpLang;
import com.djrapitops.plan.system.locale.lang.CommandLang;
import com.djrapitops.plan.system.locale.lang.DeepHelpLang;
import com.djrapitops.plan.system.locale.lang.ManageLang;
import com.djrapitops.plan.system.processing.Processing;
import com.djrapitops.plan.system.settings.Permissions;
import com.djrapitops.plugin.api.utility.log.Log;
import com.djrapitops.plugin.command.CommandNode;
import com.djrapitops.plugin.command.CommandType;
import com.djrapitops.plugin.command.ISender;
import com.djrapitops.plugin.task.AbsRunnable;
import com.djrapitops.plugin.task.RunnableFactory;
import com.djrapitops.plugin.utilities.Verify;
import java.util.Arrays;
@ -75,27 +74,22 @@ public class ManageMoveCommand extends CommandNode {
}
private void runMoveTask(final Database fromDatabase, final Database toDatabase, ISender sender) {
RunnableFactory.createNew(new AbsRunnable("DBMoveTask") {
@Override
public void run() {
try {
sender.sendMessage(locale.getString(ManageLang.PROGRESS_START));
Processing.submitCritical(() -> {
try {
sender.sendMessage(locale.getString(ManageLang.PROGRESS_START));
fromDatabase.backup().backup(toDatabase);
fromDatabase.backup().backup(toDatabase);
sender.sendMessage(locale.getString(ManageLang.PROGRESS_SUCCESS));
sender.sendMessage(locale.getString(ManageLang.PROGRESS_SUCCESS));
boolean movingToCurrentDB = toDatabase.getConfigName().equalsIgnoreCase(Database.getActive().getConfigName());
if (movingToCurrentDB) {
sender.sendMessage(locale.getString(ManageLang.HOTSWAP_REMINDER, toDatabase.getConfigName()));
}
} catch (Exception e) {
Log.toLog(this.getClass(), e);
sender.sendMessage(locale.getString(ManageLang.PROGRESS_FAIL, e.getMessage()));
} finally {
this.cancel();
boolean movingToCurrentDB = toDatabase.getConfigName().equalsIgnoreCase(Database.getActive().getConfigName());
if (movingToCurrentDB) {
sender.sendMessage(locale.getString(ManageLang.HOTSWAP_REMINDER, toDatabase.getConfigName()));
}
} catch (Exception e) {
Log.toLog(this.getClass(), e);
sender.sendMessage(locale.getString(ManageLang.PROGRESS_FAIL, e.getMessage()));
}
}).runTaskAsynchronously();
});
}
}

View File

@ -8,6 +8,7 @@ import com.djrapitops.plan.system.locale.lang.CmdHelpLang;
import com.djrapitops.plan.system.locale.lang.CommandLang;
import com.djrapitops.plan.system.locale.lang.DeepHelpLang;
import com.djrapitops.plan.system.locale.lang.ManageLang;
import com.djrapitops.plan.system.processing.Processing;
import com.djrapitops.plan.system.settings.Permissions;
import com.djrapitops.plan.utilities.MiscUtils;
import com.djrapitops.plan.utilities.uuid.UUIDUtility;
@ -15,8 +16,6 @@ import com.djrapitops.plugin.api.utility.log.Log;
import com.djrapitops.plugin.command.CommandNode;
import com.djrapitops.plugin.command.CommandType;
import com.djrapitops.plugin.command.ISender;
import com.djrapitops.plugin.task.AbsRunnable;
import com.djrapitops.plugin.task.RunnableFactory;
import com.djrapitops.plugin.utilities.Verify;
import java.util.Arrays;
@ -58,40 +57,35 @@ public class ManageRemoveCommand extends CommandNode {
}
private void runRemoveTask(String playerName, ISender sender, String[] args) {
RunnableFactory.createNew(new AbsRunnable("DBRemoveTask " + playerName) {
@Override
public void run() {
try {
UUID uuid = UUIDUtility.getUUIDOf(playerName);
Processing.submitCritical(() -> {
try {
UUID uuid = UUIDUtility.getUUIDOf(playerName);
if (uuid == null) {
sender.sendMessage(locale.getString(CommandLang.FAIL_USERNAME_NOT_VALID));
return;
}
Database database = Database.getActive();
if (!database.check().isPlayerRegistered(uuid)) {
sender.sendMessage(locale.getString(CommandLang.FAIL_USERNAME_NOT_KNOWN));
return;
}
if (!Verify.contains("-a", args)) {
sender.sendMessage(locale.getString(ManageLang.CONFIRMATION, locale.getString(ManageLang.CONFIRM_REMOVAL, database.getName())));
return;
}
sender.sendMessage(locale.getString(ManageLang.PROGRESS_START));
database.remove().player(uuid);
sender.sendMessage(locale.getString(ManageLang.PROGRESS_SUCCESS));
} catch (DBOpException e) {
Log.toLog(this.getClass(), e);
sender.sendMessage(locale.getString(ManageLang.PROGRESS_FAIL, e.getMessage()));
} finally {
this.cancel();
if (uuid == null) {
sender.sendMessage(locale.getString(CommandLang.FAIL_USERNAME_NOT_VALID));
return;
}
Database database = Database.getActive();
if (!database.check().isPlayerRegistered(uuid)) {
sender.sendMessage(locale.getString(CommandLang.FAIL_USERNAME_NOT_KNOWN));
return;
}
if (!Verify.contains("-a", args)) {
sender.sendMessage(locale.getString(ManageLang.CONFIRMATION, locale.getString(ManageLang.CONFIRM_REMOVAL, database.getName())));
return;
}
sender.sendMessage(locale.getString(ManageLang.PROGRESS_START));
database.remove().player(uuid);
sender.sendMessage(locale.getString(ManageLang.PROGRESS_SUCCESS));
} catch (DBOpException e) {
Log.toLog(this.getClass(), e);
sender.sendMessage(locale.getString(ManageLang.PROGRESS_FAIL, e.getMessage()));
}
}).runTaskAsynchronously();
});
}
}

View File

@ -9,13 +9,12 @@ import com.djrapitops.plan.system.locale.lang.CmdHelpLang;
import com.djrapitops.plan.system.locale.lang.CommandLang;
import com.djrapitops.plan.system.locale.lang.DeepHelpLang;
import com.djrapitops.plan.system.locale.lang.ManageLang;
import com.djrapitops.plan.system.processing.Processing;
import com.djrapitops.plan.system.settings.Permissions;
import com.djrapitops.plugin.api.utility.log.Log;
import com.djrapitops.plugin.command.CommandNode;
import com.djrapitops.plugin.command.CommandType;
import com.djrapitops.plugin.command.ISender;
import com.djrapitops.plugin.task.AbsRunnable;
import com.djrapitops.plugin.task.RunnableFactory;
import com.djrapitops.plugin.utilities.Verify;
import java.io.File;
@ -72,39 +71,34 @@ public class ManageRestoreCommand extends CommandNode {
}
private void runRestoreTask(String backupDbName, ISender sender, final Database database) {
RunnableFactory.createNew(new AbsRunnable("RestoreTask") {
@Override
public void run() {
try {
String backupDBName = backupDbName;
boolean containsDBFileExtension = backupDBName.endsWith(".db");
Processing.submitCritical(() -> {
try {
String backupDBName = backupDbName;
boolean containsDBFileExtension = backupDBName.endsWith(".db");
File backupDBFile = new File(plugin.getDataFolder(), backupDBName + (containsDBFileExtension ? "" : ".db"));
File backupDBFile = new File(plugin.getDataFolder(), backupDBName + (containsDBFileExtension ? "" : ".db"));
if (!backupDBFile.exists()) {
sender.sendMessage(locale.getString(ManageLang.FAIL_FILE_NOT_FOUND, backupDBFile.getAbsolutePath()));
return;
}
if (containsDBFileExtension) {
backupDBName = backupDBName.substring(0, backupDBName.length() - 3);
}
SQLiteDB backupDB = new SQLiteDB(backupDBName, () -> locale);
backupDB.init();
sender.sendMessage(locale.getString(ManageLang.PROGRESS_START));
database.backup().restore(backupDB);
sender.sendMessage(locale.getString(ManageLang.PROGRESS_SUCCESS));
} catch (Exception e) {
Log.toLog(this.getClass(), e);
sender.sendMessage(locale.getString(ManageLang.PROGRESS_FAIL, e.getMessage()));
} finally {
this.cancel();
if (!backupDBFile.exists()) {
sender.sendMessage(locale.getString(ManageLang.FAIL_FILE_NOT_FOUND, backupDBFile.getAbsolutePath()));
return;
}
if (containsDBFileExtension) {
backupDBName = backupDBName.substring(0, backupDBName.length() - 3);
}
SQLiteDB backupDB = new SQLiteDB(backupDBName, () -> locale);
backupDB.init();
sender.sendMessage(locale.getString(ManageLang.PROGRESS_START));
database.backup().restore(backupDB);
sender.sendMessage(locale.getString(ManageLang.PROGRESS_SUCCESS));
} catch (Exception e) {
Log.toLog(this.getClass(), e);
sender.sendMessage(locale.getString(ManageLang.PROGRESS_FAIL, e.getMessage()));
}
}).runTaskAsynchronously();
});
}
}

View File

@ -7,13 +7,12 @@ import com.djrapitops.plan.system.locale.Locale;
import com.djrapitops.plan.system.locale.lang.CmdHelpLang;
import com.djrapitops.plan.system.locale.lang.CommandLang;
import com.djrapitops.plan.system.locale.lang.ManageLang;
import com.djrapitops.plan.system.processing.Processing;
import com.djrapitops.plan.system.settings.Permissions;
import com.djrapitops.plugin.api.utility.log.Log;
import com.djrapitops.plugin.command.CommandNode;
import com.djrapitops.plugin.command.CommandType;
import com.djrapitops.plugin.command.ISender;
import com.djrapitops.plugin.task.AbsRunnable;
import com.djrapitops.plugin.task.RunnableFactory;
import com.djrapitops.plugin.utilities.Verify;
import java.util.Arrays;
@ -45,24 +44,19 @@ public class WebCheckCommand extends CommandNode {
Database database = Database.getActive();
String user = args[0];
RunnableFactory.createNew(new AbsRunnable("Webuser Check Task: " + user) {
@Override
public void run() {
try {
if (!database.check().doesWebUserExists(user)) {
sender.sendMessage(locale.getString(CommandLang.FAIL_WEB_USER_NOT_EXISTS));
return;
}
WebUser info = database.fetch().getWebUser(user);
sender.sendMessage(locale.getString(CommandLang.WEB_USER_LIST, info.getName(), info.getPermLevel()));
} catch (Exception e) {
Log.toLog(this.getClass(), e);
sender.sendMessage(locale.getString(ManageLang.PROGRESS_FAIL, e.getMessage()));
} finally {
this.cancel();
Processing.submitNonCritical(() -> {
try {
if (!database.check().doesWebUserExists(user)) {
sender.sendMessage(locale.getString(CommandLang.FAIL_WEB_USER_NOT_EXISTS));
return;
}
WebUser info = database.fetch().getWebUser(user);
sender.sendMessage(locale.getString(CommandLang.WEB_USER_LIST, info.getName(), info.getPermLevel()));
} catch (Exception e) {
Log.toLog(this.getClass(), e);
sender.sendMessage(locale.getString(ManageLang.PROGRESS_FAIL, e.getMessage()));
}
}).runTaskAsynchronously();
});
}
}

View File

@ -7,14 +7,13 @@ import com.djrapitops.plan.system.locale.Locale;
import com.djrapitops.plan.system.locale.lang.CmdHelpLang;
import com.djrapitops.plan.system.locale.lang.CommandLang;
import com.djrapitops.plan.system.locale.lang.ManageLang;
import com.djrapitops.plan.system.processing.Processing;
import com.djrapitops.plan.system.settings.Permissions;
import com.djrapitops.plan.utilities.comparators.WebUserComparator;
import com.djrapitops.plugin.api.utility.log.Log;
import com.djrapitops.plugin.command.CommandNode;
import com.djrapitops.plugin.command.CommandType;
import com.djrapitops.plugin.command.ISender;
import com.djrapitops.plugin.task.AbsRunnable;
import com.djrapitops.plugin.task.RunnableFactory;
import java.util.List;
@ -38,25 +37,20 @@ public class WebListUsersCommand extends CommandNode {
@Override
public void onCommand(ISender sender, String commandLabel, String[] args) {
RunnableFactory.createNew(new AbsRunnable("Web user List Task") {
@Override
public void run() {
try {
List<WebUser> users = Database.getActive().fetch().getWebUsers();
users.sort(new WebUserComparator());
sender.sendMessage(locale.getString(CommandLang.HEADER_WEB_USERS, users.size()));
for (WebUser user : users) {
sender.sendMessage(locale.getString(CommandLang.WEB_USER_LIST, user.getName(), user.getPermLevel()));
}
sender.sendMessage(">");
} catch (Exception e) {
Log.toLog(this.getClass(), e);
sender.sendMessage(locale.getString(ManageLang.PROGRESS_FAIL, e.getMessage()));
} finally {
this.cancel();
Processing.submitNonCritical(() -> {
try {
List<WebUser> users = Database.getActive().fetch().getWebUsers();
users.sort(new WebUserComparator());
sender.sendMessage(locale.getString(CommandLang.HEADER_WEB_USERS, users.size()));
for (WebUser user : users) {
sender.sendMessage(locale.getString(CommandLang.WEB_USER_LIST, user.getName(), user.getPermLevel()));
}
sender.sendMessage(">");
} catch (Exception e) {
Log.toLog(this.getClass(), e);
sender.sendMessage(locale.getString(ManageLang.PROGRESS_FAIL, e.getMessage()));
}
}).runTaskAsynchronously();
});
}
}

View File

@ -5,9 +5,9 @@
package com.djrapitops.plan.data.element;
import com.djrapitops.plan.data.store.mutators.formatting.Formatter;
import com.djrapitops.plan.utilities.FormatUtils;
import com.djrapitops.plan.utilities.html.Html;
import com.djrapitops.plan.utilities.html.icon.Icon;
import com.djrapitops.plugin.utilities.ArrayUtil;
import java.io.Serializable;
import java.util.ArrayList;
@ -40,10 +40,9 @@ public class TableContainer {
}
public TableContainer(boolean players, String... header) {
this(FormatUtils.mergeArrays(
new String[]{Icon.called("user").build() + " Player"},
header
));
this(
ArrayUtil.merge(new String[]{Icon.called("user").build() + " Player"}, header)
);
}
public final void addRow(Serializable... values) {

View File

@ -16,7 +16,7 @@ import com.djrapitops.plan.system.settings.Settings;
import com.djrapitops.plugin.api.TimeAmount;
import com.djrapitops.plugin.api.utility.log.Log;
import com.djrapitops.plugin.task.AbsRunnable;
import com.djrapitops.plugin.task.ITask;
import com.djrapitops.plugin.task.PluginTask;
import com.djrapitops.plugin.task.RunnableFactory;
import com.djrapitops.plugin.utilities.Verify;
@ -65,7 +65,7 @@ public abstract class SQLDB extends Database {
private final SQLTransferOps transferOps;
private final boolean usingMySQL;
private ITask dbCleanTask;
private PluginTask dbCleanTask;
public SQLDB(Supplier<Locale> locale) {
this.locale = locale;

View File

@ -7,7 +7,7 @@ import com.djrapitops.plan.system.locale.lang.PluginLang;
import com.djrapitops.plan.utilities.MiscUtils;
import com.djrapitops.plugin.api.utility.log.Log;
import com.djrapitops.plugin.task.AbsRunnable;
import com.djrapitops.plugin.task.ITask;
import com.djrapitops.plugin.task.PluginTask;
import com.djrapitops.plugin.task.RunnableFactory;
import java.io.File;
@ -23,7 +23,7 @@ public class SQLiteDB extends SQLDB {
private final File databaseFile;
private final String dbName;
private Connection connection;
private ITask connectionPingTask;
private PluginTask connectionPingTask;
public SQLiteDB(Supplier<Locale> locale) {
this("database", locale);
@ -78,7 +78,7 @@ public class SQLiteDB extends SQLDB {
stopConnectionPingTask();
try {
// Maintains Connection.
connectionPingTask = RunnableFactory.createNew(new AbsRunnable("DBConnectionPingTask " + getName()) {
connectionPingTask = RunnableFactory.createNew("DBConnectionPingTask " + getName(), new AbsRunnable() {
@Override
public void run() {
Statement statement = null;

View File

@ -68,7 +68,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(new LogsFolderCleanTask(Log.getLogsFolder()))
RunnableFactory.createNew("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);

View File

@ -6,7 +6,6 @@ import com.djrapitops.plan.system.processing.Processing;
import com.djrapitops.plan.system.processing.processors.info.NetworkPageUpdateProcessor;
import com.djrapitops.plan.system.processing.processors.info.PlayerPageUpdateProcessor;
import com.djrapitops.plan.system.processing.processors.player.*;
import com.djrapitops.plugin.api.systems.NotificationCenter;
import com.djrapitops.plugin.api.utility.log.Log;
import com.djrapitops.plugin.task.RunnableFactory;
import org.bukkit.entity.Player;
@ -80,7 +79,7 @@ public class PlayerOnlineListener implements Listener {
private void actOnJoinEvent(PlayerJoinEvent event) {
Player player = event.getPlayer();
NotificationCenter.checkNotifications(player);
// TODO Move update notification to the website.
UUID uuid = player.getUniqueId();
long time = System.currentTimeMillis();

View File

@ -6,7 +6,6 @@ import com.djrapitops.plan.system.processing.Processing;
import com.djrapitops.plan.system.processing.processors.info.NetworkPageUpdateProcessor;
import com.djrapitops.plan.system.processing.processors.info.PlayerPageUpdateProcessor;
import com.djrapitops.plan.system.processing.processors.player.*;
import com.djrapitops.plugin.api.systems.NotificationCenter;
import com.djrapitops.plugin.api.utility.log.Log;
import com.djrapitops.plugin.task.RunnableFactory;
import org.spongepowered.api.Sponge;
@ -79,8 +78,6 @@ public class SpongePlayerListener {
private void actOnJoinEvent(ClientConnectionEvent.Join event) {
Player player = event.getTargetEntity();
NotificationCenter.checkNotifications(player);
UUID uuid = player.getUniqueId();
long time = System.currentTimeMillis();

View File

@ -25,7 +25,6 @@ public class RegisterProcessor extends AbsRunnable {
private final Runnable[] afterProcess;
public RegisterProcessor(UUID uuid, Supplier<Long> registered, String name, Runnable... afterProcess) {
super(RegisterProcessor.class.getSimpleName());
this.uuid = uuid;
this.registered = registered;
this.name = name;

View File

@ -6,7 +6,7 @@ package com.djrapitops.plan.system.settings.theme;
import com.djrapitops.plan.system.settings.Settings;
import com.djrapitops.plugin.api.utility.log.Log;
import com.djrapitops.plugin.settings.ColorScheme;
import com.djrapitops.plugin.command.ColorScheme;
/**
* ColorScheme that uses values in config settings specific to Plan or PlanBungee.

View File

@ -9,7 +9,6 @@ import com.djrapitops.plan.system.tasks.server.BukkitTPSCountTimer;
import com.djrapitops.plan.system.tasks.server.PaperTPSCountTimer;
import com.djrapitops.plan.system.tasks.server.PingCountTimer;
import com.djrapitops.plugin.api.Check;
import com.djrapitops.plugin.task.RunnableFactory;
import org.bukkit.Bukkit;
/**
@ -33,7 +32,7 @@ public class BukkitTaskSystem extends ServerTaskSystem {
try {
PingCountTimer pingCountTimer = new PingCountTimer();
((Plan) plugin).registerListener(pingCountTimer);
RunnableFactory.createNew("PingCountTimer", pingCountTimer)
registerTask("PingCountTimer", pingCountTimer)
.runTaskTimer(20L, PingCountTimer.PING_INTERVAL);
} catch (ExceptionInInitializerError | NoClassDefFoundError ignore) {
// Running CraftBukkit

View File

@ -5,6 +5,7 @@
package com.djrapitops.plan.system.tasks;
import com.djrapitops.plan.PlanBungee;
import com.djrapitops.plan.system.processing.Processing;
import com.djrapitops.plan.system.settings.Settings;
import com.djrapitops.plan.system.tasks.bungee.BungeeTPSCountTimer;
import com.djrapitops.plan.system.tasks.bungee.EnableConnectionTask;
@ -22,7 +23,7 @@ public class BungeeTaskSystem extends TaskSystem {
private final PlanBungee plugin;
public BungeeTaskSystem(PlanBungee plugin) {
super(new BungeeTPSCountTimer(plugin));
super(plugin, new BungeeTPSCountTimer(plugin));
this.plugin = plugin;
}
@ -36,7 +37,7 @@ public class BungeeTaskSystem extends TaskSystem {
registerTask(tpsCountTimer).runTaskTimerAsynchronously(1000, TimeAmount.SECOND.ticks());
registerTask(new NetworkPageRefreshTask()).runTaskTimerAsynchronously(1500, TimeAmount.MINUTE.ticks());
if (Settings.ANALYSIS_EXPORT.isTrue()) {
registerTask(new HtmlExport(plugin)).runTaskAsynchronously();
Processing.submitNonCritical(new HtmlExport(plugin));
}
}
}

View File

@ -20,7 +20,6 @@ public class LogsFolderCleanTask extends AbsRunnable {
private final File folder;
public LogsFolderCleanTask(File folder) {
super(LogsFolderCleanTask.class.getSimpleName());
this.folder = folder;
}

View File

@ -1,6 +1,7 @@
package com.djrapitops.plan.system.tasks;
import com.djrapitops.plan.PlanPlugin;
import com.djrapitops.plan.system.processing.Processing;
import com.djrapitops.plan.system.settings.Settings;
import com.djrapitops.plan.system.tasks.server.BootAnalysisTask;
import com.djrapitops.plan.system.tasks.server.NetworkPageRefreshTask;
@ -8,8 +9,7 @@ import com.djrapitops.plan.system.tasks.server.PeriodicAnalysisTask;
import com.djrapitops.plan.utilities.file.export.HtmlExport;
import com.djrapitops.plugin.api.Benchmark;
import com.djrapitops.plugin.api.TimeAmount;
import com.djrapitops.plugin.task.ITask;
import com.djrapitops.plugin.task.RunnableFactory;
import com.djrapitops.plugin.task.PluginTask;
/**
* Abstracted TaskSystem implementation for both Bukkit and Sponge.
@ -19,10 +19,10 @@ import com.djrapitops.plugin.task.RunnableFactory;
public class ServerTaskSystem extends TaskSystem {
protected final PlanPlugin plugin;
protected ITask bootAnalysisTask;
protected PluginTask bootAnalysisTask;
public ServerTaskSystem(PlanPlugin plugin, TPSCountTimer tpsCountTimer) {
super(tpsCountTimer);
super(plugin, tpsCountTimer);
this.plugin = plugin;
}
@ -47,7 +47,7 @@ public class ServerTaskSystem extends TaskSystem {
registerTask(new PeriodicAnalysisTask()).runTaskTimerAsynchronously(analysisPeriod, analysisPeriod);
}
if (Settings.ANALYSIS_EXPORT.isTrue()) {
RunnableFactory.createNew(new HtmlExport(plugin)).runTaskAsynchronously();
Processing.submitNonCritical(new HtmlExport(plugin));
}
Benchmark.stop("Enable", "Task Registration");
}

View File

@ -23,7 +23,7 @@ public abstract class TPSCountTimer<T extends PlanPlugin> extends AbsRunnable {
protected int latestPlayersOnline = 0;
public TPSCountTimer(T plugin) {
super("TPSCountTimer");
super();
this.plugin = plugin;
history = new ArrayList<>();
}

View File

@ -6,9 +6,8 @@ package com.djrapitops.plan.system.tasks;
import com.djrapitops.plan.PlanPlugin;
import com.djrapitops.plan.system.SubSystem;
import com.djrapitops.plugin.api.systems.TaskCenter;
import com.djrapitops.plugin.task.AbsRunnable;
import com.djrapitops.plugin.task.IRunnable;
import com.djrapitops.plugin.task.PluginRunnable;
import com.djrapitops.plugin.task.RunnableFactory;
/**
@ -20,24 +19,28 @@ import com.djrapitops.plugin.task.RunnableFactory;
*/
public abstract class TaskSystem implements SubSystem {
protected final PlanPlugin plugin;
protected TPSCountTimer tpsCountTimer;
protected final RunnableFactory runnableFactory;
public TaskSystem(TPSCountTimer tpsCountTimer) {
public TaskSystem(PlanPlugin plugin, TPSCountTimer tpsCountTimer) {
this.plugin = plugin;
this.tpsCountTimer = tpsCountTimer;
runnableFactory = plugin.getRunnableFactory();
}
protected IRunnable registerTask(AbsRunnable runnable) {
String taskName = runnable.getName();
return registerTask(taskName != null ? taskName : runnable.getClass().getSimpleName(), runnable);
protected PluginRunnable registerTask(AbsRunnable runnable) {
String taskName = runnable.getClass().getSimpleName();
return registerTask(taskName, runnable);
}
protected IRunnable registerTask(String name, AbsRunnable runnable) {
return RunnableFactory.createNew(name, runnable);
protected PluginRunnable registerTask(String name, AbsRunnable runnable) {
return runnableFactory.create(name, runnable);
}
@Override
public void disable() {
TaskCenter.cancelAllKnownTasks(PlanPlugin.getInstance().getClass());
runnableFactory.cancelAllKnownTasks();
}
}

View File

@ -7,10 +7,6 @@ import com.djrapitops.plugin.task.AbsRunnable;
public class EnableConnectionTask extends AbsRunnable {
public EnableConnectionTask() {
super(EnableConnectionTask.class.getSimpleName());
}
@Override
public void run() {
WebExceptionLogger.logIfOccurs(this.getClass(),

View File

@ -10,10 +10,6 @@ import com.djrapitops.plugin.task.AbsRunnable;
public class BootAnalysisTask extends AbsRunnable {
public BootAnalysisTask() {
super(BootAnalysisTask.class.getSimpleName());
}
@Override
public void run() {
try {

View File

@ -6,10 +6,6 @@ import com.djrapitops.plugin.task.AbsRunnable;
public class NetworkPageRefreshTask extends AbsRunnable {
public NetworkPageRefreshTask() {
super(NetworkPageRefreshTask.class.getSimpleName());
}
@Override
public void run() {
WebExceptionLogger.logIfOccurs(this.getClass(), () -> InfoSystem.getInstance().updateNetworkPage());

View File

@ -10,10 +10,6 @@ import com.djrapitops.plugin.task.AbsRunnable;
public class PeriodicAnalysisTask extends AbsRunnable {
public PeriodicAnalysisTask() {
super(PeriodicAnalysisTask.class.getSimpleName());
}
@Override
public void run() {
try {

View File

@ -9,8 +9,6 @@ import com.djrapitops.plan.system.SubSystem;
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.Priority;
import com.djrapitops.plugin.api.systems.NotificationCenter;
import com.djrapitops.plugin.api.utility.Version;
import com.djrapitops.plugin.api.utility.log.Log;
import com.djrapitops.plugin.utilities.Verify;
@ -69,8 +67,6 @@ public class VersionCheckSystem implements SubSystem {
Log.infoColor("§a----------------------------------------");
Log.infoColor("§a" + notification);
Log.infoColor("§a----------------------------------------");
NotificationCenter.getNotifications().clear();
NotificationCenter.addNotification(newestVersion.isRelease() ? Priority.HIGH : Priority.MEDIUM, notification);
} else {
Log.info(locale.get().getString(PluginLang.VERSION_NEWEST));
}
@ -99,7 +95,6 @@ public class VersionCheckSystem implements SubSystem {
Log.infoColor("§a----------------------------------------");
Log.infoColor("§a" + newVersionNotification);
Log.infoColor("§a----------------------------------------");
NotificationCenter.addNotification(Priority.HIGH, newVersionNotification);
} else {
Log.info(locale.get().getString(PluginLang.VERSION_NEWEST));
}

View File

@ -93,16 +93,6 @@ public class FormatUtils {
return format(epochMs, format);
}
/**
* Merges multiple arrays into one.
*
* @param arrays String arrays that need to be combined
* @return One array with contents of the multiple
*/
public static String[] mergeArrays(String[]... arrays) {
return com.djrapitops.plugin.utilities.FormatUtils.mergeArrays(arrays);
}
/**
* Remove extra decimals from the end of the double.
*

View File

@ -9,7 +9,6 @@ import com.djrapitops.plugin.api.Check;
import com.djrapitops.plugin.api.utility.log.Log;
import java.io.IOException;
import java.util.ConcurrentModificationException;
import java.util.UUID;
/**
@ -23,7 +22,6 @@ public class AnalysisExport extends SpecificExport {
private final String serverName;
public AnalysisExport(UUID serverUUID, String serverName) {
super("ServerPageExport:" + serverName);
this.serverUUID = serverUUID;
this.serverName = serverName;
}
@ -38,11 +36,6 @@ public class AnalysisExport extends SpecificExport {
exportAvailableServerPage(serverUUID, serverName);
} catch (IOException e) {
Log.toLog(this.getClass(), e);
} finally {
try {
this.cancel();
} catch (ConcurrentModificationException | IllegalArgumentException ignore) {
}
}
}
}

View File

@ -9,13 +9,13 @@ 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.info.connection.ConnectionSystem;
import com.djrapitops.plan.system.processing.Processing;
import com.djrapitops.plan.system.settings.theme.Theme;
import com.djrapitops.plan.system.settings.theme.ThemeVal;
import com.djrapitops.plan.system.webserver.response.pages.PlayersPageResponse;
import com.djrapitops.plan.utilities.file.FileUtil;
import com.djrapitops.plugin.api.Check;
import com.djrapitops.plugin.api.utility.log.Log;
import com.djrapitops.plugin.task.RunnableFactory;
import com.djrapitops.plugin.utilities.Verify;
import java.io.File;
@ -34,19 +34,20 @@ public class HtmlExport extends SpecificExport {
private final PlanPlugin plugin;
public HtmlExport(PlanPlugin plugin) {
super("HtmlExportTask");
this.plugin = plugin;
}
public static void exportServer(UUID serverUUID) {
Optional<String> serverName = Database.getActive().fetch().getServerName(serverUUID);
serverName.ifPresent(s -> RunnableFactory.createNew(new AnalysisExport(serverUUID, s)).runTaskAsynchronously());
serverName.ifPresent(name -> Processing.submitNonCritical(() -> {
new AnalysisExport(serverUUID, name);
}));
}
public static void exportPlayer(UUID playerUUID) {
String playerName = Database.getActive().fetch().getPlayerName(playerUUID);
if (playerName != null) {
RunnableFactory.createNew(new PlayerExport(playerUUID, playerName)).runTaskAsynchronously();
Processing.submitNonCritical(new PlayerExport(playerUUID, playerName));
}
}
@ -66,11 +67,6 @@ public class HtmlExport extends SpecificExport {
exportPlayersPage();
} catch (IOException | DBOpException e) {
Log.toLog(this.getClass(), e);
} finally {
try {
this.cancel();
} catch (ConcurrentModificationException | IllegalArgumentException ignore) {
}
}
}

View File

@ -9,7 +9,6 @@ import com.djrapitops.plugin.api.Check;
import com.djrapitops.plugin.api.utility.log.Log;
import java.io.IOException;
import java.util.ConcurrentModificationException;
import java.util.UUID;
/**
@ -23,7 +22,6 @@ public class PlayerExport extends SpecificExport {
private final String name;
public PlayerExport(UUID uuid, String name) {
super("PlayerPageExport:" + name);
this.uuid = uuid;
this.name = name;
}
@ -38,11 +36,6 @@ public class PlayerExport extends SpecificExport {
exportAvailablePlayerPage(uuid, name);
} catch (IOException e) {
Log.toLog(this.getClass(), e);
} finally {
try {
this.cancel();
} catch (ConcurrentModificationException | IllegalArgumentException ignore) {
}
}
}
}

View File

@ -12,7 +12,6 @@ import com.djrapitops.plan.system.webserver.cache.ResponseCache;
import com.djrapitops.plan.system.webserver.response.Response;
import com.djrapitops.plugin.api.Check;
import com.djrapitops.plugin.api.utility.log.Log;
import com.djrapitops.plugin.task.AbsRunnable;
import java.io.File;
import java.io.IOException;
@ -28,13 +27,12 @@ import java.util.UUID;
*
* @author Rsl1122
*/
public abstract class SpecificExport extends AbsRunnable {
public abstract class SpecificExport implements Runnable {
protected final File outputFolder;
protected final boolean usingBungee;
protected SpecificExport(String taskName) {
super(taskName);
protected SpecificExport() {
outputFolder = getFolder();
usingBungee = Check.isBungeeAvailable();
}

View File

@ -7,8 +7,8 @@ import com.djrapitops.plan.data.plugin.PluginData;
import com.djrapitops.plan.data.store.containers.PlayerContainer;
import com.djrapitops.plan.data.store.keys.PlayerKeys;
import com.djrapitops.plan.system.settings.Settings;
import com.djrapitops.plan.utilities.FormatUtils;
import com.djrapitops.plan.utilities.html.Html;
import com.djrapitops.plugin.utilities.ArrayUtil;
import org.apache.commons.lang3.ArrayUtils;
import java.io.Serializable;
@ -73,7 +73,7 @@ public class PluginPlayersTable extends TableContainer {
String name = profile.getValue(PlayerKeys.NAME).orElse("Unknown");
String link = Html.LINK_EXTERNAL.parse(PlanAPI.getInstance().getPlayerInspectPageLink(name), name);
String[] playerData = FormatUtils.mergeArrays(new String[]{link}, rows.getOrDefault(uuid, new String[]{}));
String[] playerData = ArrayUtil.merge(new String[]{link}, rows.getOrDefault(uuid, new String[]{}));
addRow(ArrayUtils.addAll(playerData));
i++;

View File

@ -1,5 +1,6 @@
package com.djrapitops.plan.utilities;
import com.djrapitops.plugin.utilities.ArrayUtil;
import org.junit.BeforeClass;
import org.junit.ClassRule;
import org.junit.Test;
@ -41,7 +42,7 @@ public class FormatUtilsTest {
String[][] arrays = new String[][]{new String[]{randomString1, randomString2}, new String[]{randomString3, randomString4}};
String[] expResult = new String[]{randomString1, randomString2, randomString3, randomString4};
String[] result = FormatUtils.mergeArrays(arrays);
String[] result = ArrayUtil.merge(arrays);
assertArrayEquals(expResult, result);
}

View File

@ -6,8 +6,10 @@ package utilities.mocks;
import com.djrapitops.plan.Plan;
import com.djrapitops.plugin.StaticHolder;
import com.djrapitops.plugin.task.RunnableFactory;
import com.djrapitops.plugin.task.ThreadRunnable;
import com.djrapitops.plugin.logging.console.TestPluginLogger;
import com.djrapitops.plugin.logging.error.ConsoleErrorLogger;
import com.djrapitops.plugin.task.thread.ThreadRunnable;
import com.djrapitops.plugin.task.thread.ThreadRunnableFactory;
import org.bukkit.Server;
import org.bukkit.plugin.InvalidDescriptionException;
import org.bukkit.plugin.PluginDescriptionFile;
@ -39,7 +41,6 @@ public class BukkitMockUtil extends MockUtil {
}
public static BukkitMockUtil setUp() {
RunnableFactory.activateTestMode();
Teardown.resetSettingsTempValues();
return new BukkitMockUtil().mockPlugin();
}
@ -56,6 +57,9 @@ public class BukkitMockUtil extends MockUtil {
doCallRealMethod().when(planMock).getVersion();
doCallRealMethod().when(planMock).getColorScheme();
ThreadRunnableFactory runnableFactory = new ThreadRunnableFactory();
doReturn(runnableFactory).when(planMock).getRunnableFactory();
return this;
}
@ -65,9 +69,12 @@ public class BukkitMockUtil extends MockUtil {
}
public BukkitMockUtil withLogging() {
Mockito.doCallRealMethod().when(planMock).log(Mockito.anyString(), Mockito.anyString());
TestLogger testLogger = new TestLogger();
doReturn(testLogger).when(planMock).getLogger();
TestPluginLogger testPluginLogger = new TestPluginLogger();
doReturn(testPluginLogger).when(planMock).getPluginLogger();
ConsoleErrorLogger consoleErrorLogger = new ConsoleErrorLogger(testPluginLogger);
doReturn(consoleErrorLogger).when(planMock).getErrorHandler();
return this;
}

View File

@ -6,8 +6,10 @@ package utilities.mocks;
import com.djrapitops.plan.PlanBungee;
import com.djrapitops.plugin.StaticHolder;
import com.djrapitops.plugin.task.RunnableFactory;
import com.djrapitops.plugin.task.ThreadRunnable;
import com.djrapitops.plugin.logging.console.TestPluginLogger;
import com.djrapitops.plugin.logging.error.ConsoleErrorLogger;
import com.djrapitops.plugin.task.thread.ThreadRunnable;
import com.djrapitops.plugin.task.thread.ThreadRunnableFactory;
import net.md_5.bungee.api.CommandSender;
import net.md_5.bungee.api.ProxyConfig;
import net.md_5.bungee.api.ProxyServer;
@ -23,7 +25,8 @@ import utilities.mocks.objects.TestLogger;
import java.io.File;
import java.util.HashSet;
import static org.mockito.Mockito.*;
import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.when;
/**
* Mocking Utility for Bungee version of Plan (PlanBungee).
@ -38,7 +41,6 @@ public class BungeeMockUtil extends MockUtil {
}
public static BungeeMockUtil setUp() {
RunnableFactory.activateTestMode();
Teardown.resetSettingsTempValues();
return new BungeeMockUtil().mockPlugin();
}
@ -54,8 +56,10 @@ public class BungeeMockUtil extends MockUtil {
when(planMock.getVersion()).thenCallRealMethod();
when(planMock.getColorScheme()).thenCallRealMethod();
// doCallRealMethod().when(planMock).getVersion();
// doCallRealMethod().when(planMock).getColorScheme();
ThreadRunnableFactory runnableFactory = new ThreadRunnableFactory();
doReturn(runnableFactory).when(planMock).getRunnableFactory();
return this;
}
@ -70,9 +74,12 @@ public class BungeeMockUtil extends MockUtil {
}
public BungeeMockUtil withLogging() {
doCallRealMethod().when(planMock).log(Mockito.anyString(), Mockito.anyString());
TestLogger testLogger = new TestLogger();
doReturn(testLogger).when(planMock).getLogger();
TestPluginLogger testPluginLogger = new TestPluginLogger();
doReturn(testPluginLogger).when(planMock).getPluginLogger();
ConsoleErrorLogger consoleErrorLogger = new ConsoleErrorLogger(testPluginLogger);
doReturn(consoleErrorLogger).when(planMock).getErrorHandler();
return this;
}

View File

@ -6,11 +6,14 @@ package utilities.mocks;
import com.djrapitops.plan.PlanSponge;
import com.djrapitops.plugin.StaticHolder;
import com.djrapitops.plugin.task.RunnableFactory;
import com.djrapitops.plugin.task.ThreadRunnable;
import com.djrapitops.plugin.logging.console.TestPluginLogger;
import com.djrapitops.plugin.logging.error.ConsoleErrorLogger;
import com.djrapitops.plugin.task.thread.ThreadRunnable;
import com.djrapitops.plugin.task.thread.ThreadRunnableFactory;
import org.mockito.Mockito;
import org.mockito.junit.MockitoJUnitRunner;
import utilities.Teardown;
import utilities.mocks.objects.TestLogger;
import java.io.File;
@ -29,7 +32,6 @@ public class SpongeMockUtil extends MockUtil {
}
public static SpongeMockUtil setUp() {
RunnableFactory.activateTestMode();
Teardown.resetSettingsTempValues();
return new SpongeMockUtil().mockPlugin();
}
@ -46,6 +48,9 @@ public class SpongeMockUtil extends MockUtil {
doReturn("4.2.0").when(planMock).getVersion();
doCallRealMethod().when(planMock).getColorScheme();
ThreadRunnableFactory runnableFactory = new ThreadRunnableFactory();
doReturn(runnableFactory).when(planMock).getRunnableFactory();
return this;
}
@ -55,9 +60,12 @@ public class SpongeMockUtil extends MockUtil {
}
public SpongeMockUtil withLogging() {
doNothing().when(planMock).log(Mockito.anyString(), Mockito.anyString());
// TestLogger testLogger = new TestLogger();
// doReturn(testLogger).when(planMock).();
TestLogger testLogger = new TestLogger();
doReturn(testLogger).when(planMock).getLogger();
TestPluginLogger testPluginLogger = new TestPluginLogger();
doReturn(testPluginLogger).when(planMock).getPluginLogger();
ConsoleErrorLogger consoleErrorLogger = new ConsoleErrorLogger(testPluginLogger);
doReturn(consoleErrorLogger).when(planMock).getErrorHandler();
return this;
}