mirror of
https://github.com/plan-player-analytics/Plan.git
synced 2025-01-08 09:27:45 +01:00
[Fix] Fixed compile issues
Compile issues were caused by recent changes in APF: * ISender -> Sender rename * BukkitCMDSender was in use in test, but was made package private. Fixes: * Replaced ISender -> Sender * Replaced BukkitCMDSender use in MiscUtilsTest * Moved two database tests out from MiscUtilsTest
This commit is contained in:
parent
6ca86b8c76
commit
c4bf9a500f
@ -18,7 +18,7 @@ import com.djrapitops.plan.system.webserver.WebServer;
|
||||
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.command.Sender;
|
||||
import com.djrapitops.plugin.logging.L;
|
||||
import com.djrapitops.plugin.logging.error.ErrorHandler;
|
||||
|
||||
@ -73,7 +73,7 @@ public class AnalyzeCommand extends CommandNode {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCommand(ISender sender, String commandLabel, String[] args) {
|
||||
public void onCommand(Sender sender, String commandLabel, String[] args) {
|
||||
sender.sendMessage(locale.getString(ManageLang.PROGRESS_START));
|
||||
|
||||
processing.submitNonCritical(() -> {
|
||||
@ -91,7 +91,7 @@ public class AnalyzeCommand extends CommandNode {
|
||||
});
|
||||
}
|
||||
|
||||
private void sendLink(Server server, ISender sender) {
|
||||
private void sendLink(Server server, Sender sender) {
|
||||
String target = "/server/" + server.getName();
|
||||
String url = connectionSystem.getMainAddress() + target;
|
||||
String linkPrefix = locale.getString(CommandLang.LINK_PREFIX);
|
||||
@ -107,7 +107,7 @@ public class AnalyzeCommand extends CommandNode {
|
||||
sender.sendMessage(">");
|
||||
}
|
||||
|
||||
private void sendWebUserNotificationIfNecessary(ISender sender) {
|
||||
private void sendWebUserNotificationIfNecessary(Sender sender) {
|
||||
if (webServer.isAuthRequired() &&
|
||||
CommandUtils.isPlayer(sender) &&
|
||||
!database.check().doesWebUserExists(sender.getName())) {
|
||||
|
@ -12,7 +12,7 @@ import com.djrapitops.plan.system.locale.lang.DeepHelpLang;
|
||||
import com.djrapitops.plan.system.settings.Permissions;
|
||||
import com.djrapitops.plugin.command.CommandNode;
|
||||
import com.djrapitops.plugin.command.CommandType;
|
||||
import com.djrapitops.plugin.command.ISender;
|
||||
import com.djrapitops.plugin.command.Sender;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
@ -40,7 +40,7 @@ public class BungeeSetupToggleCommand extends CommandNode {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCommand(ISender sender, String s, String[] strings) {
|
||||
public void onCommand(Sender sender, String s, String[] strings) {
|
||||
if (connectionSystem.isSetupAllowed()) {
|
||||
connectionSystem.setSetupAllowed(false);
|
||||
} else {
|
||||
|
@ -9,7 +9,7 @@ import com.djrapitops.plan.system.locale.lang.CmdHelpLang;
|
||||
import com.djrapitops.plan.system.locale.lang.CommandLang;
|
||||
import com.djrapitops.plugin.command.CommandNode;
|
||||
import com.djrapitops.plugin.command.CommandType;
|
||||
import com.djrapitops.plugin.command.ISender;
|
||||
import com.djrapitops.plugin.command.Sender;
|
||||
import com.djrapitops.plugin.utilities.Verify;
|
||||
|
||||
import javax.inject.Inject;
|
||||
@ -35,7 +35,7 @@ public class DevCommand extends CommandNode {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCommand(ISender sender, String cmd, String[] args) {
|
||||
public void onCommand(Sender sender, String cmd, String[] args) {
|
||||
Verify.isTrue(args.length >= 1,
|
||||
() -> new IllegalArgumentException(locale.getString(CommandLang.FAIL_REQ_ONE_ARG, Arrays.toString(this.getArguments()))));
|
||||
|
||||
|
@ -7,7 +7,7 @@ import com.djrapitops.plan.system.locale.lang.CommandLang;
|
||||
import com.djrapitops.plan.system.locale.lang.DeepHelpLang;
|
||||
import com.djrapitops.plugin.command.CommandNode;
|
||||
import com.djrapitops.plugin.command.CommandType;
|
||||
import com.djrapitops.plugin.command.ISender;
|
||||
import com.djrapitops.plugin.command.Sender;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
@ -28,7 +28,7 @@ public class DisableCommand extends CommandNode {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCommand(ISender sender, String commandLabel, String[] args) {
|
||||
public void onCommand(Sender sender, String commandLabel, String[] args) {
|
||||
plugin.onDisable();
|
||||
sender.sendMessage(locale.getString(CommandLang.DISABLE_DISABLED));
|
||||
}
|
||||
|
@ -11,7 +11,7 @@ import com.djrapitops.plan.system.settings.Permissions;
|
||||
import com.djrapitops.plan.system.update.VersionCheckSystem;
|
||||
import com.djrapitops.plugin.command.CommandNode;
|
||||
import com.djrapitops.plugin.command.CommandType;
|
||||
import com.djrapitops.plugin.command.ISender;
|
||||
import com.djrapitops.plugin.command.Sender;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
@ -49,7 +49,7 @@ public class InfoCommand extends CommandNode {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCommand(ISender sender, String commandLabel, String[] args) {
|
||||
public void onCommand(Sender sender, String commandLabel, String[] args) {
|
||||
String yes = locale.getString(GenericLang.YES);
|
||||
String no = locale.getString(GenericLang.NO);
|
||||
|
||||
|
@ -16,7 +16,7 @@ import com.djrapitops.plan.utilities.uuid.UUIDUtility;
|
||||
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.command.Sender;
|
||||
import com.djrapitops.plugin.logging.L;
|
||||
import com.djrapitops.plugin.logging.error.ErrorHandler;
|
||||
|
||||
@ -68,7 +68,7 @@ public class InspectCommand extends CommandNode {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCommand(ISender sender, String commandLabel, String[] args) {
|
||||
public void onCommand(Sender sender, String commandLabel, String[] args) {
|
||||
String playerName = MiscUtils.getPlayerName(args, sender);
|
||||
|
||||
if (playerName == null) {
|
||||
@ -78,7 +78,7 @@ public class InspectCommand extends CommandNode {
|
||||
runInspectTask(playerName, sender);
|
||||
}
|
||||
|
||||
private void runInspectTask(String playerName, ISender sender) {
|
||||
private void runInspectTask(String playerName, Sender sender) {
|
||||
processing.submitNonCritical(() -> {
|
||||
try {
|
||||
UUID uuid = uuidUtility.getUUIDOf(playerName);
|
||||
@ -101,7 +101,7 @@ public class InspectCommand extends CommandNode {
|
||||
});
|
||||
}
|
||||
|
||||
private void checkWebUserAndNotify(ISender sender) {
|
||||
private void checkWebUserAndNotify(Sender sender) {
|
||||
if (CommandUtils.isPlayer(sender) && webServer.isAuthRequired()) {
|
||||
boolean senderHasWebUser = database.check().doesWebUserExists(sender.getName());
|
||||
|
||||
@ -111,7 +111,7 @@ public class InspectCommand extends CommandNode {
|
||||
}
|
||||
}
|
||||
|
||||
private void sendInspectMsg(ISender sender, String playerName) {
|
||||
private void sendInspectMsg(Sender sender, String playerName) {
|
||||
sender.sendMessage(locale.getString(CommandLang.HEADER_INSPECT, playerName));
|
||||
|
||||
String url = connectionSystem.getMainAddress() + "/player/" + playerName;
|
||||
|
@ -9,7 +9,7 @@ import com.djrapitops.plan.system.settings.Permissions;
|
||||
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.command.Sender;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
@ -36,11 +36,11 @@ public class ListPlayersCommand extends CommandNode {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCommand(ISender sender, String commandLabel, String[] args) {
|
||||
public void onCommand(Sender sender, String commandLabel, String[] args) {
|
||||
sendListMsg(sender);
|
||||
}
|
||||
|
||||
private void sendListMsg(ISender sender) {
|
||||
private void sendListMsg(Sender sender) {
|
||||
sender.sendMessage(locale.getString(CommandLang.HEADER_PLAYERS));
|
||||
|
||||
// Link
|
||||
|
@ -1,7 +1,6 @@
|
||||
package com.djrapitops.plan.command.commands;
|
||||
|
||||
import com.djrapitops.plan.api.exceptions.database.DBOpException;
|
||||
import com.djrapitops.plan.utilities.formatting.Formatter;
|
||||
import com.djrapitops.plan.system.database.databases.Database;
|
||||
import com.djrapitops.plan.system.info.server.Server;
|
||||
import com.djrapitops.plan.system.locale.Locale;
|
||||
@ -9,10 +8,11 @@ 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.settings.Permissions;
|
||||
import com.djrapitops.plan.utilities.formatting.Formatter;
|
||||
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.command.Sender;
|
||||
import com.djrapitops.plugin.logging.L;
|
||||
import com.djrapitops.plugin.logging.error.ErrorHandler;
|
||||
|
||||
@ -45,7 +45,7 @@ public class ListServersCommand extends CommandNode {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCommand(ISender sender, String commandLabel, String[] args) {
|
||||
public void onCommand(Sender sender, String commandLabel, String[] args) {
|
||||
String sCol = colorScheme.getSecondaryColor();
|
||||
String tCol = colorScheme.getTertiaryColor();
|
||||
Formatter<Server> serverFormatter = serverLister(sCol, tCol);
|
||||
@ -59,7 +59,7 @@ public class ListServersCommand extends CommandNode {
|
||||
}
|
||||
}
|
||||
|
||||
private void sendServers(ISender sender, Formatter<Server> serverFormatter) {
|
||||
private void sendServers(Sender sender, Formatter<Server> serverFormatter) {
|
||||
List<Server> servers = database.fetch().getServers();
|
||||
for (Server server : servers) {
|
||||
sender.sendMessage(serverFormatter.apply(server));
|
||||
|
@ -9,7 +9,7 @@ import com.djrapitops.plan.system.settings.Permissions;
|
||||
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.command.Sender;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
@ -35,11 +35,11 @@ public class NetworkCommand extends CommandNode {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCommand(ISender sender, String commandLabel, String[] args) {
|
||||
public void onCommand(Sender sender, String commandLabel, String[] args) {
|
||||
sendNetworkMsg(sender);
|
||||
}
|
||||
|
||||
private void sendNetworkMsg(ISender sender) {
|
||||
private void sendNetworkMsg(Sender sender) {
|
||||
sender.sendMessage(locale.getString(CommandLang.HEADER_NETWORK));
|
||||
|
||||
// Link
|
||||
|
@ -22,7 +22,7 @@ import com.djrapitops.plan.utilities.formatting.Formatters;
|
||||
import com.djrapitops.plan.utilities.uuid.UUIDUtility;
|
||||
import com.djrapitops.plugin.command.CommandNode;
|
||||
import com.djrapitops.plugin.command.CommandType;
|
||||
import com.djrapitops.plugin.command.ISender;
|
||||
import com.djrapitops.plugin.command.Sender;
|
||||
import com.djrapitops.plugin.logging.L;
|
||||
import com.djrapitops.plugin.logging.error.ErrorHandler;
|
||||
|
||||
@ -73,7 +73,7 @@ public class QInspectCommand extends CommandNode {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCommand(ISender sender, String commandLabel, String[] args) {
|
||||
public void onCommand(Sender sender, String commandLabel, String[] args) {
|
||||
String playerName = MiscUtils.getPlayerName(args, sender, Permissions.QUICK_INSPECT_OTHER);
|
||||
|
||||
if (playerName == null) {
|
||||
@ -84,7 +84,7 @@ public class QInspectCommand extends CommandNode {
|
||||
runInspectTask(playerName, sender);
|
||||
}
|
||||
|
||||
private void runInspectTask(String playerName, ISender sender) {
|
||||
private void runInspectTask(String playerName, Sender sender) {
|
||||
processing.submitNonCritical(() -> {
|
||||
try {
|
||||
UUID uuid = uuidUtility.getUUIDOf(playerName);
|
||||
@ -107,7 +107,7 @@ public class QInspectCommand extends CommandNode {
|
||||
});
|
||||
}
|
||||
|
||||
private void sendMessages(ISender sender, PlayerContainer player) {
|
||||
private void sendMessages(Sender sender, PlayerContainer player) {
|
||||
long now = System.currentTimeMillis();
|
||||
|
||||
Formatter<DateHolder> timestamp = formatters.year();
|
||||
|
@ -13,7 +13,7 @@ import com.djrapitops.plugin.api.Check;
|
||||
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.command.Sender;
|
||||
import com.djrapitops.plugin.logging.L;
|
||||
import com.djrapitops.plugin.logging.console.PluginLogger;
|
||||
import com.djrapitops.plugin.logging.error.ErrorHandler;
|
||||
@ -71,7 +71,7 @@ public class RegisterCommand extends CommandNode {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCommand(ISender sender, String commandLabel, String[] args) {
|
||||
public void onCommand(Sender sender, String commandLabel, String[] args) {
|
||||
try {
|
||||
if (CommandUtils.isPlayer(sender)) {
|
||||
playerRegister(args, sender);
|
||||
@ -88,7 +88,7 @@ public class RegisterCommand extends CommandNode {
|
||||
}
|
||||
}
|
||||
|
||||
private void consoleRegister(String[] args, ISender sender, String notEnoughArgsMsg) throws PassEncryptUtil.CannotPerformOperationException {
|
||||
private void consoleRegister(String[] args, Sender sender, String notEnoughArgsMsg) throws PassEncryptUtil.CannotPerformOperationException {
|
||||
Verify.isTrue(args.length >= 3, () -> new IllegalArgumentException(notEnoughArgsMsg));
|
||||
|
||||
int permLevel;
|
||||
@ -97,7 +97,7 @@ public class RegisterCommand extends CommandNode {
|
||||
registerUser(new WebUser(args[1], passHash, permLevel), sender);
|
||||
}
|
||||
|
||||
private void playerRegister(String[] args, ISender sender) throws PassEncryptUtil.CannotPerformOperationException {
|
||||
private void playerRegister(String[] args, Sender sender) throws PassEncryptUtil.CannotPerformOperationException {
|
||||
boolean registerSenderAsUser = args.length == 1;
|
||||
if (registerSenderAsUser) {
|
||||
String user = sender.getName();
|
||||
@ -111,7 +111,7 @@ public class RegisterCommand extends CommandNode {
|
||||
}
|
||||
}
|
||||
|
||||
private int getPermissionLevel(ISender sender) {
|
||||
private int getPermissionLevel(Sender sender) {
|
||||
final String permAnalyze = Permissions.ANALYZE.getPerm();
|
||||
final String permInspectOther = Permissions.INSPECT_OTHER.getPerm();
|
||||
final String permInspect = Permissions.INSPECT.getPerm();
|
||||
@ -127,7 +127,7 @@ public class RegisterCommand extends CommandNode {
|
||||
return 100;
|
||||
}
|
||||
|
||||
private void registerUser(WebUser webUser, ISender sender) {
|
||||
private void registerUser(WebUser webUser, Sender sender) {
|
||||
processing.submitCritical(() -> {
|
||||
String userName = webUser.getName();
|
||||
try {
|
||||
|
@ -8,7 +8,7 @@ import com.djrapitops.plan.system.locale.lang.DeepHelpLang;
|
||||
import com.djrapitops.plan.system.settings.Permissions;
|
||||
import com.djrapitops.plugin.command.CommandNode;
|
||||
import com.djrapitops.plugin.command.CommandType;
|
||||
import com.djrapitops.plugin.command.ISender;
|
||||
import com.djrapitops.plugin.command.Sender;
|
||||
import com.djrapitops.plugin.logging.L;
|
||||
import com.djrapitops.plugin.logging.error.ErrorHandler;
|
||||
import com.djrapitops.plugin.task.AbsRunnable;
|
||||
@ -43,7 +43,7 @@ public class ReloadCommand extends CommandNode {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCommand(ISender sender, String commandLabel, String[] args) {
|
||||
public void onCommand(Sender sender, String commandLabel, String[] args) {
|
||||
runnableFactory.create("Reload task", new AbsRunnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
|
@ -11,7 +11,7 @@ import com.djrapitops.plan.system.processing.Processing;
|
||||
import com.djrapitops.plan.system.settings.Permissions;
|
||||
import com.djrapitops.plugin.command.CommandNode;
|
||||
import com.djrapitops.plugin.command.CommandType;
|
||||
import com.djrapitops.plugin.command.ISender;
|
||||
import com.djrapitops.plugin.command.Sender;
|
||||
import com.djrapitops.plugin.logging.L;
|
||||
import com.djrapitops.plugin.logging.error.ErrorHandler;
|
||||
import com.djrapitops.plugin.utilities.Verify;
|
||||
@ -55,7 +55,7 @@ public class SearchCommand extends CommandNode {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCommand(ISender sender, String commandLabel, String[] args) {
|
||||
public void onCommand(Sender sender, String commandLabel, String[] args) {
|
||||
Verify.isTrue(args.length >= 1,
|
||||
() -> new IllegalArgumentException(locale.getString(CommandLang.FAIL_REQ_ONE_ARG, Arrays.toString(this.getArguments()))));
|
||||
|
||||
@ -64,7 +64,7 @@ public class SearchCommand extends CommandNode {
|
||||
runSearchTask(args, sender);
|
||||
}
|
||||
|
||||
private void runSearchTask(String[] args, ISender sender) {
|
||||
private void runSearchTask(String[] args, Sender sender) {
|
||||
processing.submitNonCritical(() -> {
|
||||
try {
|
||||
String searchTerm = args[0];
|
||||
|
@ -16,7 +16,7 @@ import com.djrapitops.plan.utilities.formatting.Formatter;
|
||||
import com.djrapitops.plan.utilities.formatting.Formatters;
|
||||
import com.djrapitops.plugin.command.CommandNode;
|
||||
import com.djrapitops.plugin.command.CommandType;
|
||||
import com.djrapitops.plugin.command.ISender;
|
||||
import com.djrapitops.plugin.command.Sender;
|
||||
import com.djrapitops.plugin.logging.L;
|
||||
import com.djrapitops.plugin.logging.error.ErrorHandler;
|
||||
import com.djrapitops.plugin.utilities.Verify;
|
||||
@ -70,7 +70,7 @@ public class ManageBackupCommand extends CommandNode {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCommand(ISender sender, String commandLabel, String[] args) {
|
||||
public void onCommand(Sender sender, String commandLabel, String[] args) {
|
||||
try {
|
||||
Verify.isTrue(args.length >= 1,
|
||||
() -> new IllegalArgumentException(locale.getString(CommandLang.FAIL_REQ_ONE_ARG, Arrays.toString(this.getArguments()))));
|
||||
@ -90,7 +90,7 @@ public class ManageBackupCommand extends CommandNode {
|
||||
}
|
||||
}
|
||||
|
||||
private void runBackupTask(ISender sender, String[] args, Database database) {
|
||||
private void runBackupTask(Sender sender, String[] args, Database database) {
|
||||
processing.submitCritical(() -> {
|
||||
try {
|
||||
sender.sendMessage(locale.getString(ManageLang.PROGRESS_START));
|
||||
|
@ -13,7 +13,7 @@ import com.djrapitops.plan.system.processing.Processing;
|
||||
import com.djrapitops.plan.system.settings.Permissions;
|
||||
import com.djrapitops.plugin.command.CommandNode;
|
||||
import com.djrapitops.plugin.command.CommandType;
|
||||
import com.djrapitops.plugin.command.ISender;
|
||||
import com.djrapitops.plugin.command.Sender;
|
||||
import com.djrapitops.plugin.logging.L;
|
||||
import com.djrapitops.plugin.logging.error.ErrorHandler;
|
||||
import com.djrapitops.plugin.utilities.Verify;
|
||||
@ -56,7 +56,7 @@ public class ManageClearCommand extends CommandNode {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCommand(ISender sender, String commandLabel, String[] args) {
|
||||
public void onCommand(Sender sender, String commandLabel, String[] args) {
|
||||
Verify.isTrue(args.length >= 1,
|
||||
() -> new IllegalArgumentException(locale.getString(CommandLang.FAIL_REQ_ONE_ARG, Arrays.toString(this.getArguments()))));
|
||||
|
||||
@ -80,7 +80,7 @@ public class ManageClearCommand extends CommandNode {
|
||||
}
|
||||
}
|
||||
|
||||
private void runClearTask(ISender sender, Database database) {
|
||||
private void runClearTask(Sender sender, Database database) {
|
||||
processing.submitCritical(() -> {
|
||||
try {
|
||||
sender.sendMessage(locale.getString(ManageLang.PROGRESS_START));
|
||||
|
@ -18,7 +18,7 @@ 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.command.Sender;
|
||||
|
||||
import javax.inject.Inject;
|
||||
import javax.inject.Singleton;
|
||||
@ -69,7 +69,7 @@ public class ManageConDebugCommand extends CommandNode {
|
||||
setInDepthHelp(locale.getArray(DeepHelpLang.MANAGE_CON));
|
||||
}
|
||||
|
||||
private void testServer(ISender sender, String accessAddress, Server server, Locale locale) {
|
||||
private void testServer(Sender sender, String accessAddress, Server server, Locale locale) {
|
||||
String address = server.getWebAddress().toLowerCase();
|
||||
boolean usingHttps = address.startsWith("https");
|
||||
boolean local = address.contains("localhost")
|
||||
@ -104,7 +104,7 @@ public class ManageConDebugCommand extends CommandNode {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCommand(ISender sender, String commandLabel, String[] args) {
|
||||
public void onCommand(Sender sender, String commandLabel, String[] args) {
|
||||
if (!webServer.isEnabled()) {
|
||||
sender.sendMessage(locale.getString(CommandLang.CONNECT_WEBSERVER_NOT_ENABLED));
|
||||
return;
|
||||
@ -113,7 +113,7 @@ public class ManageConDebugCommand extends CommandNode {
|
||||
processing.submitNonCritical(() -> testServers(sender));
|
||||
}
|
||||
|
||||
private void testServers(ISender sender) {
|
||||
private void testServers(Sender sender) {
|
||||
List<Server> servers = database.fetch().getServers();
|
||||
|
||||
if (servers.isEmpty()) {
|
||||
|
@ -8,7 +8,7 @@ import com.djrapitops.plan.system.locale.lang.DeepHelpLang;
|
||||
import com.djrapitops.plan.system.settings.Permissions;
|
||||
import com.djrapitops.plugin.command.CommandNode;
|
||||
import com.djrapitops.plugin.command.CommandType;
|
||||
import com.djrapitops.plugin.command.ISender;
|
||||
import com.djrapitops.plugin.command.Sender;
|
||||
import com.djrapitops.plugin.utilities.Verify;
|
||||
|
||||
import javax.inject.Inject;
|
||||
@ -36,7 +36,7 @@ public class ManageDisableCommand extends CommandNode {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCommand(ISender sender, String commandLabel, String[] args) {
|
||||
public void onCommand(Sender sender, String commandLabel, String[] args) {
|
||||
Verify.isTrue(args.length >= 1,
|
||||
() -> new IllegalArgumentException(locale.getString(CommandLang.FAIL_REQ_ONE_ARG, Arrays.toString(this.getArguments()))));
|
||||
|
||||
|
@ -12,7 +12,7 @@ import com.djrapitops.plan.system.settings.Settings;
|
||||
import com.djrapitops.plan.system.settings.config.PlanConfig;
|
||||
import com.djrapitops.plugin.command.CommandNode;
|
||||
import com.djrapitops.plugin.command.CommandType;
|
||||
import com.djrapitops.plugin.command.ISender;
|
||||
import com.djrapitops.plugin.command.Sender;
|
||||
import com.djrapitops.plugin.logging.L;
|
||||
import com.djrapitops.plugin.logging.error.ErrorHandler;
|
||||
import com.djrapitops.plugin.utilities.Verify;
|
||||
@ -51,7 +51,7 @@ public class ManageHotSwapCommand extends CommandNode {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCommand(ISender sender, String commandLabel, String[] args) {
|
||||
public void onCommand(Sender sender, String commandLabel, String[] args) {
|
||||
Verify.isTrue(args.length >= 1,
|
||||
() -> new IllegalArgumentException(locale.getString(CommandLang.FAIL_REQ_ONE_ARG, Arrays.toString(this.getArguments()))));
|
||||
|
||||
|
@ -11,7 +11,7 @@ import com.djrapitops.plan.system.processing.Processing;
|
||||
import com.djrapitops.plan.system.settings.Permissions;
|
||||
import com.djrapitops.plugin.command.CommandNode;
|
||||
import com.djrapitops.plugin.command.CommandType;
|
||||
import com.djrapitops.plugin.command.ISender;
|
||||
import com.djrapitops.plugin.command.Sender;
|
||||
import com.djrapitops.plugin.utilities.Verify;
|
||||
|
||||
import javax.inject.Inject;
|
||||
@ -50,7 +50,7 @@ public class ManageImportCommand extends CommandNode {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCommand(ISender sender, String commandLabel, String[] args) {
|
||||
public void onCommand(Sender sender, String commandLabel, String[] args) {
|
||||
Verify.isTrue(args.length >= 1,
|
||||
() -> new IllegalArgumentException(locale.getString(CommandLang.FAIL_REQ_ARGS, "1+", Arrays.toString(this.getArguments()))));
|
||||
|
||||
@ -65,7 +65,7 @@ public class ManageImportCommand extends CommandNode {
|
||||
findImporter(sender, importArg);
|
||||
}
|
||||
|
||||
private void findImporter(ISender sender, String importArg) {
|
||||
private void findImporter(Sender sender, String importArg) {
|
||||
Optional<Importer> foundImporter = importSystem.getImporter(importArg);
|
||||
if (foundImporter.isPresent()) {
|
||||
Importer importer = foundImporter.get();
|
||||
|
@ -11,7 +11,7 @@ import com.djrapitops.plan.system.processing.Processing;
|
||||
import com.djrapitops.plan.system.settings.Permissions;
|
||||
import com.djrapitops.plugin.command.CommandNode;
|
||||
import com.djrapitops.plugin.command.CommandType;
|
||||
import com.djrapitops.plugin.command.ISender;
|
||||
import com.djrapitops.plugin.command.Sender;
|
||||
import com.djrapitops.plugin.logging.L;
|
||||
import com.djrapitops.plugin.logging.error.ErrorHandler;
|
||||
import com.djrapitops.plugin.utilities.Verify;
|
||||
@ -56,7 +56,7 @@ public class ManageMoveCommand extends CommandNode {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCommand(ISender sender, String commandLabel, String[] args) {
|
||||
public void onCommand(Sender sender, String commandLabel, String[] args) {
|
||||
Verify.isTrue(args.length >= 2,
|
||||
() -> new IllegalArgumentException(locale.getString(CommandLang.FAIL_REQ_ARGS, 2, Arrays.toString(this.getArguments()))));
|
||||
|
||||
@ -90,7 +90,7 @@ public class ManageMoveCommand extends CommandNode {
|
||||
}
|
||||
}
|
||||
|
||||
private void runMoveTask(final Database fromDatabase, final Database toDatabase, ISender sender) {
|
||||
private void runMoveTask(final Database fromDatabase, final Database toDatabase, Sender sender) {
|
||||
processing.submitCritical(() -> {
|
||||
try {
|
||||
sender.sendMessage(locale.getString(ManageLang.PROGRESS_START));
|
||||
|
@ -10,7 +10,7 @@ import com.djrapitops.plan.utilities.MiscUtils;
|
||||
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.command.Sender;
|
||||
import com.djrapitops.plugin.utilities.Verify;
|
||||
|
||||
import javax.inject.Inject;
|
||||
@ -40,7 +40,7 @@ public class ManageRawDataCommand extends CommandNode {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCommand(ISender sender, String commandLabel, String[] args) {
|
||||
public void onCommand(Sender sender, String commandLabel, String[] args) {
|
||||
Verify.isTrue(args.length >= 1,
|
||||
() -> new IllegalArgumentException(locale.getString(CommandLang.FAIL_REQ_ONE_ARG, Arrays.toString(this.getArguments()))));
|
||||
|
||||
|
@ -13,7 +13,7 @@ import com.djrapitops.plan.utilities.MiscUtils;
|
||||
import com.djrapitops.plan.utilities.uuid.UUIDUtility;
|
||||
import com.djrapitops.plugin.command.CommandNode;
|
||||
import com.djrapitops.plugin.command.CommandType;
|
||||
import com.djrapitops.plugin.command.ISender;
|
||||
import com.djrapitops.plugin.command.Sender;
|
||||
import com.djrapitops.plugin.logging.L;
|
||||
import com.djrapitops.plugin.logging.error.ErrorHandler;
|
||||
import com.djrapitops.plugin.utilities.Verify;
|
||||
@ -60,7 +60,7 @@ public class ManageRemoveCommand extends CommandNode {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCommand(ISender sender, String commandLabel, String[] args) {
|
||||
public void onCommand(Sender sender, String commandLabel, String[] args) {
|
||||
Verify.isTrue(args.length >= 1,
|
||||
() -> new IllegalArgumentException(locale.getString(CommandLang.FAIL_REQ_ONE_ARG, Arrays.toString(this.getArguments()))));
|
||||
|
||||
@ -74,7 +74,7 @@ public class ManageRemoveCommand extends CommandNode {
|
||||
runRemoveTask(playerName, sender, args);
|
||||
}
|
||||
|
||||
private void runRemoveTask(String playerName, ISender sender, String[] args) {
|
||||
private void runRemoveTask(String playerName, Sender sender, String[] args) {
|
||||
processing.submitCritical(() -> {
|
||||
try {
|
||||
UUID uuid = uuidUtility.getUUIDOf(playerName);
|
||||
|
@ -13,7 +13,7 @@ import com.djrapitops.plan.system.processing.Processing;
|
||||
import com.djrapitops.plan.system.settings.Permissions;
|
||||
import com.djrapitops.plugin.command.CommandNode;
|
||||
import com.djrapitops.plugin.command.CommandType;
|
||||
import com.djrapitops.plugin.command.ISender;
|
||||
import com.djrapitops.plugin.command.Sender;
|
||||
import com.djrapitops.plugin.logging.L;
|
||||
import com.djrapitops.plugin.logging.error.ErrorHandler;
|
||||
import com.djrapitops.plugin.utilities.Verify;
|
||||
@ -61,7 +61,7 @@ public class ManageRestoreCommand extends CommandNode {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCommand(ISender sender, String commandLabel, String[] args) {
|
||||
public void onCommand(Sender sender, String commandLabel, String[] args) {
|
||||
Verify.isTrue(args.length >= 2,
|
||||
() -> new IllegalArgumentException(locale.getString(CommandLang.FAIL_REQ_ARGS, 2, Arrays.toString(this.getArguments()))));
|
||||
|
||||
@ -90,7 +90,7 @@ public class ManageRestoreCommand extends CommandNode {
|
||||
}
|
||||
}
|
||||
|
||||
private void runRestoreTask(String backupDbName, ISender sender, Database database) {
|
||||
private void runRestoreTask(String backupDbName, Sender sender, Database database) {
|
||||
processing.submitCritical(() -> {
|
||||
try {
|
||||
String backupDBName = backupDbName;
|
||||
|
@ -13,7 +13,7 @@ import com.djrapitops.plan.system.settings.config.PlanConfig;
|
||||
import com.djrapitops.plan.system.webserver.WebServer;
|
||||
import com.djrapitops.plugin.command.CommandNode;
|
||||
import com.djrapitops.plugin.command.CommandType;
|
||||
import com.djrapitops.plugin.command.ISender;
|
||||
import com.djrapitops.plugin.command.Sender;
|
||||
import com.djrapitops.plugin.logging.L;
|
||||
import com.djrapitops.plugin.logging.error.ErrorHandler;
|
||||
import com.djrapitops.plugin.utilities.Verify;
|
||||
@ -62,7 +62,7 @@ public class ManageSetupCommand extends CommandNode {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCommand(ISender sender, String commandLabel, String[] args) {
|
||||
public void onCommand(Sender sender, String commandLabel, String[] args) {
|
||||
Verify.isTrue(args.length >= 1,
|
||||
() -> new IllegalArgumentException(locale.getString(CommandLang.FAIL_REQ_ONE_ARG, Arrays.toString(this.getArguments()))));
|
||||
|
||||
@ -82,7 +82,7 @@ public class ManageSetupCommand extends CommandNode {
|
||||
requestSetup(sender, address);
|
||||
}
|
||||
|
||||
private void requestSetup(ISender sender, String address) {
|
||||
private void requestSetup(Sender sender, String address) {
|
||||
processing.submitNonCritical(() -> {
|
||||
try {
|
||||
config.set(Settings.BUNGEE_OVERRIDE_STANDALONE_MODE, false);
|
||||
|
@ -13,7 +13,7 @@ import com.djrapitops.plan.system.processing.Processing;
|
||||
import com.djrapitops.plan.system.settings.Permissions;
|
||||
import com.djrapitops.plugin.command.CommandNode;
|
||||
import com.djrapitops.plugin.command.CommandType;
|
||||
import com.djrapitops.plugin.command.ISender;
|
||||
import com.djrapitops.plugin.command.Sender;
|
||||
import com.djrapitops.plugin.logging.L;
|
||||
import com.djrapitops.plugin.logging.error.ErrorHandler;
|
||||
|
||||
@ -63,7 +63,7 @@ public class ManageUninstalledCommand extends CommandNode {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCommand(ISender sender, String commandLabel, String[] args) {
|
||||
public void onCommand(Sender sender, String commandLabel, String[] args) {
|
||||
sender.sendMessage(locale.getString(ManageLang.PROGRESS_START));
|
||||
|
||||
processing.submitNonCritical(() -> {
|
||||
|
@ -10,7 +10,7 @@ import com.djrapitops.plan.system.processing.Processing;
|
||||
import com.djrapitops.plan.system.settings.Permissions;
|
||||
import com.djrapitops.plugin.command.CommandNode;
|
||||
import com.djrapitops.plugin.command.CommandType;
|
||||
import com.djrapitops.plugin.command.ISender;
|
||||
import com.djrapitops.plugin.command.Sender;
|
||||
import com.djrapitops.plugin.logging.L;
|
||||
import com.djrapitops.plugin.logging.error.ErrorHandler;
|
||||
import com.djrapitops.plugin.utilities.Verify;
|
||||
@ -51,7 +51,7 @@ public class WebCheckCommand extends CommandNode {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCommand(ISender sender, String commandLabel, String[] args) {
|
||||
public void onCommand(Sender sender, String commandLabel, String[] args) {
|
||||
Verify.isTrue(args.length >= 1,
|
||||
() -> new IllegalArgumentException(locale.getString(CommandLang.FAIL_REQ_ONE_ARG, Arrays.toString(this.getArguments()))));
|
||||
|
||||
|
@ -9,7 +9,7 @@ import com.djrapitops.plan.system.processing.Processing;
|
||||
import com.djrapitops.plan.system.settings.Permissions;
|
||||
import com.djrapitops.plugin.command.CommandNode;
|
||||
import com.djrapitops.plugin.command.CommandType;
|
||||
import com.djrapitops.plugin.command.ISender;
|
||||
import com.djrapitops.plugin.command.Sender;
|
||||
import com.djrapitops.plugin.logging.L;
|
||||
import com.djrapitops.plugin.logging.error.ErrorHandler;
|
||||
import com.djrapitops.plugin.utilities.Verify;
|
||||
@ -51,7 +51,7 @@ public class WebDeleteCommand extends CommandNode {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCommand(ISender sender, String commandLabel, String[] args) {
|
||||
public void onCommand(Sender sender, String commandLabel, String[] args) {
|
||||
Verify.isTrue(args.length >= 1,
|
||||
() -> new IllegalArgumentException(locale.getString(CommandLang.FAIL_REQ_ONE_ARG, Arrays.toString(this.getArguments()))));
|
||||
|
||||
|
@ -6,7 +6,7 @@ import com.djrapitops.plan.system.locale.lang.CommandLang;
|
||||
import com.djrapitops.plan.system.settings.Permissions;
|
||||
import com.djrapitops.plugin.command.CommandNode;
|
||||
import com.djrapitops.plugin.command.CommandType;
|
||||
import com.djrapitops.plugin.command.ISender;
|
||||
import com.djrapitops.plugin.command.Sender;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
@ -30,7 +30,7 @@ public class WebLevelCommand extends CommandNode {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCommand(ISender sender, String commandLabel, String[] args) {
|
||||
public void onCommand(Sender sender, String commandLabel, String[] args) {
|
||||
sender.sendMessage(locale.getArray(CommandLang.WEB_PERMISSION_LEVELS));
|
||||
}
|
||||
|
||||
|
@ -11,7 +11,7 @@ import com.djrapitops.plan.system.settings.Permissions;
|
||||
import com.djrapitops.plan.utilities.comparators.WebUserComparator;
|
||||
import com.djrapitops.plugin.command.CommandNode;
|
||||
import com.djrapitops.plugin.command.CommandType;
|
||||
import com.djrapitops.plugin.command.ISender;
|
||||
import com.djrapitops.plugin.command.Sender;
|
||||
import com.djrapitops.plugin.logging.L;
|
||||
import com.djrapitops.plugin.logging.error.ErrorHandler;
|
||||
|
||||
@ -51,7 +51,7 @@ public class WebListUsersCommand extends CommandNode {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCommand(ISender sender, String commandLabel, String[] args) {
|
||||
public void onCommand(Sender sender, String commandLabel, String[] args) {
|
||||
processing.submitNonCritical(() -> {
|
||||
try {
|
||||
List<WebUser> users = database.fetch().getWebUsers();
|
||||
|
@ -2,7 +2,7 @@ package com.djrapitops.plan.system.processing.processors.info;
|
||||
|
||||
import com.djrapitops.plan.system.info.InfoSystem;
|
||||
import com.djrapitops.plan.system.info.connection.WebExceptionLogger;
|
||||
import com.djrapitops.plugin.command.ISender;
|
||||
import com.djrapitops.plugin.command.Sender;
|
||||
import com.djrapitops.plugin.task.RunnableFactory;
|
||||
import dagger.Lazy;
|
||||
|
||||
@ -36,9 +36,9 @@ public class InfoProcessors {
|
||||
|
||||
public InspectCacheRequestProcessor inspectCacheRequestProcessor(
|
||||
UUID uuid,
|
||||
ISender sender,
|
||||
Sender sender,
|
||||
String playerName,
|
||||
BiConsumer<ISender, String> msgSender
|
||||
BiConsumer<Sender, String> msgSender
|
||||
) {
|
||||
return new InspectCacheRequestProcessor(uuid, sender, playerName, msgSender,
|
||||
infoSystem.get(), webExceptionLogger.get()
|
||||
|
@ -8,7 +8,7 @@ import com.djrapitops.plan.api.exceptions.connection.*;
|
||||
import com.djrapitops.plan.system.cache.SessionCache;
|
||||
import com.djrapitops.plan.system.info.InfoSystem;
|
||||
import com.djrapitops.plan.system.info.connection.WebExceptionLogger;
|
||||
import com.djrapitops.plugin.command.ISender;
|
||||
import com.djrapitops.plugin.command.Sender;
|
||||
|
||||
import java.util.UUID;
|
||||
import java.util.function.BiConsumer;
|
||||
@ -21,18 +21,18 @@ import java.util.function.BiConsumer;
|
||||
public class InspectCacheRequestProcessor implements Runnable {
|
||||
|
||||
private final UUID uuid;
|
||||
private final ISender sender;
|
||||
private final Sender sender;
|
||||
private final String playerName;
|
||||
private final BiConsumer<ISender, String> msgSender;
|
||||
private final BiConsumer<Sender, String> msgSender;
|
||||
|
||||
private final InfoSystem infoSystem;
|
||||
private final WebExceptionLogger webExceptionLogger;
|
||||
|
||||
InspectCacheRequestProcessor(
|
||||
UUID uuid,
|
||||
ISender sender,
|
||||
Sender sender,
|
||||
String playerName,
|
||||
BiConsumer<ISender, String> msgSender,
|
||||
BiConsumer<Sender, String> msgSender,
|
||||
InfoSystem infoSystem,
|
||||
WebExceptionLogger webExceptionLogger
|
||||
) {
|
||||
|
@ -2,7 +2,7 @@ package com.djrapitops.plan.utilities;
|
||||
|
||||
import com.djrapitops.plan.system.settings.Permissions;
|
||||
import com.djrapitops.plugin.command.CommandUtils;
|
||||
import com.djrapitops.plugin.command.ISender;
|
||||
import com.djrapitops.plugin.command.Sender;
|
||||
|
||||
import java.io.Closeable;
|
||||
import java.io.IOException;
|
||||
@ -29,7 +29,7 @@ public class MiscUtils {
|
||||
* @param sender Sender of command
|
||||
* @return Player name.
|
||||
*/
|
||||
public static String getPlayerName(String[] args, ISender sender) {
|
||||
public static String getPlayerName(String[] args, Sender sender) {
|
||||
return getPlayerName(args, sender, Permissions.INSPECT_OTHER);
|
||||
}
|
||||
|
||||
@ -41,7 +41,7 @@ public class MiscUtils {
|
||||
* @param perm Permission to use when checking.
|
||||
* @return The name of the player (first argument or sender) or null if sender has no permission.
|
||||
*/
|
||||
public static String getPlayerName(String[] args, ISender sender, Permissions perm) {
|
||||
public static String getPlayerName(String[] args, Sender sender, Permissions perm) {
|
||||
String playerName;
|
||||
boolean isConsole = !CommandUtils.isPlayer(sender);
|
||||
if (isConsole) {
|
||||
|
@ -1038,4 +1038,44 @@ public class SQLiteTest {
|
||||
|
||||
assertTrue("Some keys are not supported by NetworkContainer: NetworkKeys." + unsupported.toString(), unsupported.isEmpty());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetMatchingNames() {
|
||||
String exp1 = "TestName";
|
||||
String exp2 = "TestName2";
|
||||
|
||||
UsersTable usersTable = db.getUsersTable();
|
||||
UUID uuid1 = UUID.randomUUID();
|
||||
usersTable.registerUser(uuid1, 0L, exp1);
|
||||
usersTable.registerUser(UUID.randomUUID(), 0L, exp2);
|
||||
|
||||
String search = "testname";
|
||||
|
||||
List<String> result = db.search().matchingPlayers(search);
|
||||
|
||||
assertNotNull(result);
|
||||
assertEquals(2, result.size());
|
||||
assertEquals(exp1, result.get(0));
|
||||
assertEquals(exp2, result.get(1));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetMatchingNickNames() {
|
||||
UUID uuid = UUID.randomUUID();
|
||||
String userName = RandomData.randomString(10);
|
||||
db.getUsersTable().registerUser(uuid, 0L, userName);
|
||||
db.getUsersTable().registerUser(TestConstants.PLAYER_ONE_UUID, 1L, "Not random");
|
||||
|
||||
String nickname = "2" + RandomData.randomString(10);
|
||||
db.getNicknamesTable().saveUserName(uuid, new Nickname(nickname, System.currentTimeMillis(), TestConstants.SERVER_UUID));
|
||||
db.getNicknamesTable().saveUserName(TestConstants.PLAYER_ONE_UUID, new Nickname("No nick", System.currentTimeMillis(), TestConstants.SERVER_UUID));
|
||||
|
||||
String search = "2";
|
||||
|
||||
List<String> result = db.search().matchingPlayers(search);
|
||||
|
||||
assertNotNull(result);
|
||||
assertEquals(1, result.size());
|
||||
assertEquals(userName, result.get(0));
|
||||
}
|
||||
}
|
||||
|
@ -5,61 +5,35 @@
|
||||
*/
|
||||
package com.djrapitops.plan.utilities;
|
||||
|
||||
import com.djrapitops.plan.Plan;
|
||||
import com.djrapitops.plan.data.store.objects.Nickname;
|
||||
import com.djrapitops.plan.system.database.databases.sql.SQLDB;
|
||||
import com.djrapitops.plan.system.database.databases.sql.tables.UsersTable;
|
||||
import com.djrapitops.plugin.StaticHolder;
|
||||
import com.djrapitops.plugin.command.ISender;
|
||||
import com.djrapitops.plugin.command.bukkit.BukkitCMDSender;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.junit.*;
|
||||
import org.junit.rules.TemporaryFolder;
|
||||
import org.junit.runner.RunWith;
|
||||
import com.djrapitops.plan.system.settings.Permissions;
|
||||
import com.djrapitops.plugin.command.Sender;
|
||||
import com.djrapitops.plugin.command.SenderType;
|
||||
import org.junit.Test;
|
||||
import org.mockito.Mockito;
|
||||
import org.mockito.junit.MockitoJUnitRunner;
|
||||
import utilities.RandomData;
|
||||
import utilities.TestConstants;
|
||||
import utilities.mocks.SystemMockUtil;
|
||||
import utilities.mocks.objects.MockPlayers;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNull;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
/**
|
||||
* Tests for various {@link MiscUtils} methods.
|
||||
*
|
||||
* @author Rsl1122
|
||||
*/
|
||||
@RunWith(MockitoJUnitRunner.Silent.class)
|
||||
public class MiscUtilsTest {
|
||||
|
||||
private SQLDB db;
|
||||
|
||||
@ClassRule
|
||||
public static TemporaryFolder temporaryFolder = new TemporaryFolder();
|
||||
|
||||
@BeforeClass
|
||||
public static void setUpClass() throws Exception {
|
||||
StaticHolder.saveInstance(MiscUtils.class, Plan.class);
|
||||
SystemMockUtil.setUp(temporaryFolder.getRoot())
|
||||
.enableConfigSystem()
|
||||
.enableDatabaseSystem()
|
||||
.enableServerInfoSystem();
|
||||
|
||||
// Database.getActive().save().serverInfoForThisServer(new Server(-1, TestConstants.SERVER_UUID, "ServerName", "", 20));
|
||||
}
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
db = null; // TODO;
|
||||
Assume.assumeNotNull(db);
|
||||
private Sender mockAPlayerSender(String name, boolean hasPermission) {
|
||||
Sender sender = Mockito.mock(Sender.class);
|
||||
when(sender.hasPermission(Permissions.INSPECT_OTHER.getPermission())).thenReturn(hasPermission);
|
||||
when(sender.getName()).thenReturn(name);
|
||||
when(sender.getSenderType()).thenReturn(SenderType.PLAYER);
|
||||
return sender;
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetPlayerDisplayNameArgsPerm() {
|
||||
public void getNameShouldReturnNameWithPermission() {
|
||||
String[] args = new String[]{"Rsl1122", "Test"};
|
||||
ISender sender = new BukkitCMDSender(MockPlayers.mockPlayer());
|
||||
Sender sender = mockAPlayerSender("TestName", true);
|
||||
|
||||
String expResult = "Rsl1122";
|
||||
String result = MiscUtils.getPlayerName(args, sender);
|
||||
@ -68,9 +42,9 @@ public class MiscUtilsTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetPlayerDisplayNameArgsNoPerm() {
|
||||
public void getNameShouldReturnNullWithoutPermission() {
|
||||
String[] args = new String[]{"Rsl1122", "Test"};
|
||||
ISender sender = new BukkitCMDSender(MockPlayers.mockPlayer2());
|
||||
Sender sender = mockAPlayerSender("TestName", false);
|
||||
|
||||
String result = MiscUtils.getPlayerName(args, sender);
|
||||
|
||||
@ -78,88 +52,48 @@ public class MiscUtilsTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetPlayerDisplayNameNoArgsPerm() {
|
||||
public void getNameShouldReturnPlayerNameWithoutArgs() {
|
||||
String[] args = new String[]{};
|
||||
ISender sender = new BukkitCMDSender(MockPlayers.mockPlayer());
|
||||
String expected = "TestName";
|
||||
Sender sender = mockAPlayerSender(expected, true);
|
||||
|
||||
String expResult = "TestName";
|
||||
String result = MiscUtils.getPlayerName(args, sender);
|
||||
|
||||
assertEquals(expResult, result);
|
||||
assertEquals(expected, result);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetPlayerDisplayNameNoArgsNoPerm() {
|
||||
public void getNameShouldReturnPlayerNameWithoutArgsOrPermission() {
|
||||
String[] args = new String[]{};
|
||||
ISender sender = new BukkitCMDSender(MockPlayers.mockPlayer2());
|
||||
String expected = "TestName2";
|
||||
Sender sender = mockAPlayerSender(expected, false);
|
||||
|
||||
String expResult = "TestName2";
|
||||
String result = MiscUtils.getPlayerName(args, sender);
|
||||
|
||||
assertEquals(expResult, result);
|
||||
assertEquals(expected, result);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetPlayerDisplayNameOwnNameNoPerm() {
|
||||
public void getNameShouldReturnPlayerNameWithoutPermissionForOwnName() {
|
||||
String[] args = new String[]{"testname2"};
|
||||
ISender sender = new BukkitCMDSender(MockPlayers.mockPlayer2());
|
||||
String expected = "TestName2";
|
||||
Sender sender = mockAPlayerSender(expected, false);
|
||||
|
||||
String expResult = "TestName2";
|
||||
String result = MiscUtils.getPlayerName(args, sender);
|
||||
|
||||
assertEquals(expResult, result);
|
||||
assertEquals(expected, result);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetPlayerDisplayNameConsole() {
|
||||
public void getNameShouldReturnArgumentForConsole() {
|
||||
String[] args = new String[]{"TestConsoleSender"};
|
||||
ISender sender = new BukkitCMDSender(Mockito.mock(CommandSender.class));
|
||||
String expected = "TestConsoleSender";
|
||||
|
||||
Sender sender = Mockito.mock(Sender.class);
|
||||
when(sender.getSenderType()).thenReturn(SenderType.CONSOLE);
|
||||
|
||||
String expResult = "TestConsoleSender";
|
||||
String result = MiscUtils.getPlayerName(args, sender);
|
||||
|
||||
assertEquals(expResult, result);
|
||||
}
|
||||
|
||||
// TODO Move to database test
|
||||
@Test
|
||||
public void testGetMatchingNames() {
|
||||
String exp1 = "TestName";
|
||||
String exp2 = "TestName2";
|
||||
|
||||
UsersTable usersTable = db.getUsersTable();
|
||||
UUID uuid1 = UUID.randomUUID();
|
||||
usersTable.registerUser(uuid1, 0L, exp1);
|
||||
usersTable.registerUser(UUID.randomUUID(), 0L, exp2);
|
||||
|
||||
String search = "testname";
|
||||
|
||||
List<String> result = db.search().matchingPlayers(search);
|
||||
|
||||
assertNotNull(result);
|
||||
assertEquals(2, result.size());
|
||||
assertEquals(exp1, result.get(0));
|
||||
assertEquals(exp2, result.get(1));
|
||||
}
|
||||
|
||||
// TODO Move to database test
|
||||
@Test
|
||||
public void testGetMatchingNickNames() {
|
||||
UUID uuid = UUID.randomUUID();
|
||||
String userName = RandomData.randomString(10);
|
||||
db.getUsersTable().registerUser(uuid, 0L, userName);
|
||||
db.getUsersTable().registerUser(TestConstants.PLAYER_ONE_UUID, 1L, "Not random");
|
||||
|
||||
String nickname = "2" + RandomData.randomString(10);
|
||||
db.getNicknamesTable().saveUserName(uuid, new Nickname(nickname, System.currentTimeMillis(), TestConstants.SERVER_UUID));
|
||||
db.getNicknamesTable().saveUserName(TestConstants.PLAYER_ONE_UUID, new Nickname("No nick", System.currentTimeMillis(), TestConstants.SERVER_UUID));
|
||||
|
||||
String search = "2";
|
||||
|
||||
List<String> result = db.search().matchingPlayers(search);
|
||||
|
||||
assertNotNull(result);
|
||||
assertEquals(1, result.size());
|
||||
assertEquals(userName, result.get(0));
|
||||
assertEquals(expected, result);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user