A lot of CommandLang locale - removed rest of Msg

This commit is contained in:
Rsl1122 2018-07-29 10:58:00 +03:00
parent 3417b6ca9f
commit 73afb678d0
30 changed files with 274 additions and 214 deletions

View File

@ -9,9 +9,10 @@ import com.djrapitops.plan.system.info.connection.ConnectionSystem;
import com.djrapitops.plan.system.info.server.Server;
import com.djrapitops.plan.system.info.server.ServerInfo;
import com.djrapitops.plan.system.locale.Locale;
import com.djrapitops.plan.system.locale.Msg;
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.system.webserver.WebServerSystem;
@ -47,7 +48,7 @@ public class AnalyzeCommand extends CommandNode {
@Override
public void onCommand(ISender sender, String commandLabel, String[] args) {
sender.sendMessage(locale.get(Msg.CMD_INFO_FETCH_DATA).toString());
sender.sendMessage(locale.getString(ManageLang.PROGRESS_START));
Processing.submitNonCritical(() -> {
try {
@ -67,17 +68,17 @@ public class AnalyzeCommand extends CommandNode {
private void sendLink(Server server, ISender sender) {
String target = "/server/" + server.getName();
String url = ConnectionSystem.getAddress() + target;
String message = locale.get(Msg.CMD_INFO_LINK).toString();
sender.sendMessage(locale.get(Msg.CMD_HEADER_ANALYZE).toString());
String linkPrefix = locale.getString(CommandLang.LINK_PREFIX);
sender.sendMessage(locale.getString(CommandLang.HEADER_ANALYSIS));
// Link
boolean console = !CommandUtils.isPlayer(sender);
if (console) {
sender.sendMessage(message + url);
sender.sendMessage(linkPrefix + url);
} else {
sender.sendMessage(message);
sender.sendLink(" ", locale.get(Msg.CMD_INFO_CLICK_ME).toString(), url);
sender.sendMessage(linkPrefix);
sender.sendLink(" ", locale.getString(CommandLang.LINK_CLICK_ME), url);
}
sender.sendMessage(locale.get(Msg.CMD_CONSTANT_FOOTER).toString());
sender.sendMessage(">");
}
private void sendWebUserNotificationIfNecessary(ISender sender) {
@ -85,7 +86,7 @@ public class AnalyzeCommand extends CommandNode {
boolean senderHasWebUser = Database.getActive().check().doesWebUserExists(sender.getName());
if (!senderHasWebUser) {
sender.sendMessage("§e[Plan] You might not have a web user, use /plan register <password>");
sender.sendMessage("§e" + locale.getString(CommandLang.NO_WEB_USER_NOTIFY));
}
}
}

View File

@ -6,13 +6,15 @@ package com.djrapitops.plan.command.commands;
import com.djrapitops.plan.PlanPlugin;
import com.djrapitops.plan.system.locale.Locale;
import com.djrapitops.plan.system.locale.Msg;
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.utilities.Verify;
import java.util.Arrays;
/**
* Command used for testing functions that are too difficult to unit test.
*
@ -33,7 +35,8 @@ public class DevCommand extends CommandNode {
@Override
public void onCommand(ISender sender, String cmd, String[] args) {
Verify.isTrue(args.length >= 1, () -> new IllegalArgumentException(locale.get(Msg.CMD_FAIL_REQ_ONE_ARG).toString()));
Verify.isTrue(args.length >= 1,
() -> new IllegalArgumentException(locale.getString(CommandLang.FAIL_REQ_ONE_ARG, Arrays.toString(this.getArguments()))));
sender.sendMessage("No features currently implemented in the command.");
}

View File

@ -4,14 +4,14 @@ import com.djrapitops.plan.PlanPlugin;
import com.djrapitops.plan.system.database.databases.Database;
import com.djrapitops.plan.system.info.connection.ConnectionSystem;
import com.djrapitops.plan.system.locale.Locale;
import com.djrapitops.plan.system.locale.Msg;
import com.djrapitops.plan.system.locale.lang.CmdHelpLang;
import com.djrapitops.plan.system.locale.lang.CommandLang;
import com.djrapitops.plan.system.locale.lang.GenericLang;
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.settings.ColorScheme;
/**
* This SubCommand is used to view the version and the database type in use.
@ -35,19 +35,20 @@ public class InfoCommand extends CommandNode {
@Override
public void onCommand(ISender sender, String commandLabel, String[] args) {
ColorScheme cs = plugin.getColorScheme();
String mColor = cs.getMainColor();
String sColor = cs.getSecondaryColor();
String tColor = cs.getTertiaryColor();
String yes = locale.getString(GenericLang.YES);
String no = locale.getString(GenericLang.NO);
String upToDate = VersionCheckSystem.isNewVersionAvailable() ? "Update Available" : "Up to date";
String updateAvailable = VersionCheckSystem.isNewVersionAvailable() ? yes : no;
String connectedToBungee = ConnectionSystem.getInstance().isServerAvailable() ? yes : no;
String[] messages = {
locale.get(Msg.CMD_HEADER_INFO).toString(),
mColor + " Version: " + sColor + plugin.getVersion(),
mColor + " Up to date: " + sColor + upToDate,
mColor + " Active Database: " + tColor + Database.getActive().getConfigName(),
mColor + " Connected to Bungee: " + tColor + (ConnectionSystem.getInstance().isServerAvailable() ? "Yes" : "No"),
locale.get(Msg.CMD_CONSTANT_FOOTER).toString()
locale.getString(CommandLang.HEADER_INFO),
"",
locale.getString(CommandLang.INFO_VERSION, plugin.getVersion()),
locale.getString(CommandLang.INFO_UPDATE, updateAvailable),
locale.getString(CommandLang.INFO_DATABASE, Database.getActive().getName()),
locale.getString(CommandLang.INFO_BUNGEE_CONNECTION, connectedToBungee),
"",
">"
};
sender.sendMessage(messages);
}

View File

@ -4,8 +4,8 @@ import com.djrapitops.plan.PlanPlugin;
import com.djrapitops.plan.api.exceptions.database.DBOpException;
import com.djrapitops.plan.system.database.databases.Database;
import com.djrapitops.plan.system.locale.Locale;
import com.djrapitops.plan.system.locale.Msg;
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.processing.processors.info.InspectCacheRequestProcessor;
@ -48,7 +48,7 @@ public class InspectCommand extends CommandNode {
String playerName = MiscUtils.getPlayerName(args, sender);
if (playerName == null) {
sender.sendMessage(locale.getString(Msg.CMD_FAIL_NO_PERMISSION));
sender.sendMessage(locale.getString(CommandLang.FAIL_NO_PERMISSION));
}
runInspectTask(playerName, sender);
@ -61,13 +61,13 @@ public class InspectCommand extends CommandNode {
try {
UUID uuid = UUIDUtility.getUUIDOf(playerName);
if (uuid == null) {
sender.sendMessage(locale.getString(Msg.CMD_FAIL_USERNAME_NOT_VALID));
sender.sendMessage(locale.getString(CommandLang.FAIL_USERNAME_NOT_VALID));
return;
}
Database activeDB = Database.getActive();
if (!activeDB.check().isPlayerRegistered(uuid)) {
sender.sendMessage(locale.getString(Msg.CMD_FAIL_USERNAME_NOT_KNOWN));
sender.sendMessage(locale.getString(CommandLang.FAIL_USERNAME_NOT_KNOWN));
return;
}
@ -92,7 +92,7 @@ public class InspectCommand extends CommandNode {
boolean senderHasWebUser = activeDB.check().doesWebUserExists(sender.getName());
if (!senderHasWebUser) {
sender.sendMessage("§e[Plan] You might not have a web user, use /plan register <password>");
sender.sendMessage("§e" + locale.getString(CommandLang.NO_WEB_USER_NOTIFY));
}
}
}

View File

@ -3,8 +3,8 @@ package com.djrapitops.plan.command.commands;
import com.djrapitops.plan.PlanPlugin;
import com.djrapitops.plan.system.info.connection.ConnectionSystem;
import com.djrapitops.plan.system.locale.Locale;
import com.djrapitops.plan.system.locale.Msg;
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.plugin.command.CommandNode;
@ -37,18 +37,18 @@ public class ListPlayersCommand extends CommandNode {
}
private void sendListMsg(ISender sender) {
sender.sendMessage(locale.getString(Msg.CMD_CONSTANT_FOOTER));
sender.sendMessage(locale.getString(CommandLang.HEADER_PLAYERS));
// Link
String url = ConnectionSystem.getAddress() + "/players/";
String message = locale.getString(Msg.CMD_INFO_LINK);
String linkPrefix = locale.getString(CommandLang.LINK_PREFIX);
boolean console = !CommandUtils.isPlayer(sender);
if (console) {
sender.sendMessage(message + url);
sender.sendMessage(linkPrefix + url);
} else {
sender.sendMessage(message);
sender.sendLink(" ", locale.getString(Msg.CMD_INFO_CLICK_ME), url);
sender.sendMessage(linkPrefix);
sender.sendLink(" ", locale.getString(CommandLang.LINK_CLICK_ME), url);
}
sender.sendMessage(locale.getString(Msg.CMD_CONSTANT_FOOTER));
sender.sendMessage(">");
}
}

View File

@ -5,8 +5,8 @@ import com.djrapitops.plan.api.exceptions.database.DBOpException;
import com.djrapitops.plan.system.database.databases.Database;
import com.djrapitops.plan.system.info.server.Server;
import com.djrapitops.plan.system.locale.Locale;
import com.djrapitops.plan.system.locale.Msg;
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.plugin.api.utility.log.Log;
@ -44,12 +44,12 @@ public class ListServersCommand extends CommandNode {
String sCol = colorScheme.getSecondaryColor();
String tCol = colorScheme.getTertiaryColor();
try {
sender.sendMessage(locale.get(Msg.CMD_CONSTANT_FOOTER).toString() + mCol + " Servers");
sender.sendMessage(locale.getString(CommandLang.HEADER_SERVERS));
List<Server> servers = Database.getActive().fetch().getServers();
for (Server server : servers) {
sender.sendMessage(" " + tCol + server.getId() + sCol + " : " + server.getName() + " : " + server.getWebAddress());
}
sender.sendMessage(locale.get(Msg.CMD_CONSTANT_FOOTER).toString());
sender.sendMessage(">");
} catch (DBOpException e) {
sender.sendMessage("§cDatabase Exception occurred.");
Log.toLog(this.getClass(), e);

View File

@ -3,8 +3,8 @@ package com.djrapitops.plan.command.commands;
import com.djrapitops.plan.PlanPlugin;
import com.djrapitops.plan.system.info.connection.ConnectionSystem;
import com.djrapitops.plan.system.locale.Locale;
import com.djrapitops.plan.system.locale.Msg;
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.plugin.command.CommandNode;
@ -36,18 +36,18 @@ public class NetworkCommand extends CommandNode {
}
private void sendNetworkMsg(ISender sender) {
sender.sendMessage(locale.get(Msg.CMD_CONSTANT_FOOTER).parse());
sender.sendMessage(locale.getString(CommandLang.HEADER_NETWORK));
// Link
String url = ConnectionSystem.getAddress() + "/network/";
String message = locale.get(Msg.CMD_INFO_LINK).toString();
String linkPrefix = locale.getString(CommandLang.LINK_PREFIX);
boolean console = !CommandUtils.isPlayer(sender);
if (console) {
sender.sendMessage(message + url);
sender.sendMessage(linkPrefix + url);
} else {
sender.sendMessage(message);
sender.sendLink(" ", locale.get(Msg.CMD_INFO_CLICK_ME).toString(), url);
sender.sendMessage(linkPrefix);
sender.sendLink(" ", locale.getString(CommandLang.LINK_CLICK_ME), url);
}
sender.sendMessage(locale.get(Msg.CMD_CONSTANT_FOOTER).toString());
sender.sendMessage(">");
}
}

View File

@ -13,9 +13,10 @@ import com.djrapitops.plan.data.store.mutators.formatting.Formatters;
import com.djrapitops.plan.data.store.objects.DateHolder;
import com.djrapitops.plan.system.database.databases.Database;
import com.djrapitops.plan.system.locale.Locale;
import com.djrapitops.plan.system.locale.Msg;
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.settings.Permissions;
import com.djrapitops.plan.utilities.MiscUtils;
import com.djrapitops.plan.utilities.uuid.UUIDUtility;
@ -23,7 +24,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.settings.ColorScheme;
import com.djrapitops.plugin.task.AbsRunnable;
import com.djrapitops.plugin.task.RunnableFactory;
@ -40,7 +40,6 @@ import java.util.UUID;
*/
public class QInspectCommand extends CommandNode {
private final PlanPlugin plugin;
private final Locale locale;
/**
@ -56,8 +55,6 @@ public class QInspectCommand extends CommandNode {
setShortHelp(locale.getString(CmdHelpLang.QINSPECT));
setInDepthHelp(locale.getArray(DeepHelpLang.QINSPECT));
this.plugin = plugin;
}
@Override
@ -65,7 +62,7 @@ public class QInspectCommand extends CommandNode {
String playerName = MiscUtils.getPlayerName(args, sender, Permissions.QUICK_INSPECT_OTHER);
if (playerName == null) {
sender.sendMessage(locale.getString(Msg.CMD_FAIL_NO_PERMISSION));
sender.sendMessage(locale.getString(CommandLang.FAIL_NO_PERMISSION));
return;
}
@ -79,13 +76,13 @@ public class QInspectCommand extends CommandNode {
try {
UUID uuid = UUIDUtility.getUUIDOf(playerName);
if (uuid == null) {
sender.sendMessage(locale.get(Msg.CMD_FAIL_USERNAME_NOT_VALID).toString());
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.get(Msg.CMD_FAIL_USERNAME_NOT_KNOWN).toString());
sender.sendMessage(locale.getString(CommandLang.FAIL_USERNAME_NOT_KNOWN));
return;
}
@ -107,36 +104,34 @@ public class QInspectCommand extends CommandNode {
private void sendMessages(ISender sender, PlayerContainer player) {
long now = System.currentTimeMillis();
ColorScheme colorScheme = plugin.getColorScheme();
String colM = colorScheme.getMainColor();
String colS = colorScheme.getSecondaryColor();
String colT = colorScheme.getTertiaryColor();
Formatter<DateHolder> timestamp = Formatters.year();
Formatter<Long> length = Formatters.timeAmount();
sender.sendMessage(locale.get(Msg.CMD_HEADER_INSPECT).toString() + ": " + colT + player.getValue(PlayerKeys.NAME).orElse("Unknown"));
String playerName = player.getValue(PlayerKeys.NAME).orElse(locale.getString(GenericLang.UNKNOWN));
ActivityIndex activityIndex = player.getActivityIndex(now);
Long registered = player.getValue(PlayerKeys.REGISTERED).orElse(0L);
Long lastSeen = player.getValue(PlayerKeys.LAST_SEEN).orElse(0L);
List<GeoInfo> geoInfo = player.getValue(PlayerKeys.GEO_INFO).orElse(new ArrayList<>());
Optional<GeoInfo> mostRecentGeoInfo = new GeoInfoMutator(geoInfo).mostRecent();
String loginLocation = mostRecentGeoInfo.isPresent() ? mostRecentGeoInfo.get().getGeolocation() : "-";
String geolocation = mostRecentGeoInfo.isPresent() ? mostRecentGeoInfo.get().getGeolocation() : "-";
SessionsMutator sessionsMutator = SessionsMutator.forContainer(player);
sender.sendMessage(colM + " Activity Index: " + colS + activityIndex.getFormattedValue() + " | " + activityIndex.getGroup());
sender.sendMessage(colM + " Registered: " + colS + timestamp.apply(() -> registered));
sender.sendMessage(colM + " Last Seen: " + colS + timestamp.apply(() -> lastSeen));
sender.sendMessage(colM + " Logged in from: " + colS + loginLocation);
sender.sendMessage(colM + " Playtime: " + colS + length.apply(sessionsMutator.toPlaytime()));
sender.sendMessage(colM + " Longest Session: " + colS + length.apply(sessionsMutator.toLongestSessionLength()));
sender.sendMessage(colM + " Times Kicked: " + colS + player.getValue(PlayerKeys.KICK_COUNT).orElse(0));
sender.sendMessage("");
sender.sendMessage(colM + " Player Kills : " + colS + sessionsMutator.toPlayerKillCount());
sender.sendMessage(colM + " Mob Kills : " + colS + sessionsMutator.toMobKillCount());
sender.sendMessage(colM + " Deaths : " + colS + sessionsMutator.toDeathCount());
sender.sendMessage(locale.get(Msg.CMD_CONSTANT_FOOTER).toString());
String[] messages = new String[]{
locale.getString(CommandLang.HEADER_INSPECT, playerName),
locale.getString(CommandLang.QINSPECT_ACTIVITY_INDEX, activityIndex.getFormattedValue(), activityIndex.getGroup()),
locale.getString(CommandLang.QINSPECT_REGISTERED, timestamp.apply(() -> registered)),
locale.getString(CommandLang.QINSPECT_LAST_SEEN, timestamp.apply(() -> lastSeen)),
locale.getString(CommandLang.QINSPECT_GEOLOCATION, geolocation),
locale.getString(CommandLang.QINSPECT_PLAYTIME, length.apply(sessionsMutator.toPlaytime())),
locale.getString(CommandLang.QINSPECT_LONGEST_SESSION, length.apply(sessionsMutator.toLongestSessionLength())),
locale.getString(CommandLang.QINSPECT_TIMES_KICKED, player.getValue(PlayerKeys.KICK_COUNT).orElse(0)),
"",
locale.getString(CommandLang.QINSPECT_PLAYER_KILLS, sessionsMutator.toPlayerKillCount()),
locale.getString(CommandLang.QINSPECT_MOB_KILLS, sessionsMutator.toMobKillCount()),
locale.getString(CommandLang.QINSPECT_DEATHS, sessionsMutator.toDeathCount()),
">"
};
sender.sendMessage(messages);
}
}

View File

@ -4,8 +4,8 @@ import com.djrapitops.plan.PlanPlugin;
import com.djrapitops.plan.data.WebUser;
import com.djrapitops.plan.system.database.databases.Database;
import com.djrapitops.plan.system.locale.Locale;
import com.djrapitops.plan.system.locale.Msg;
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.PassEncryptUtil;
@ -51,7 +51,7 @@ public class RegisterCommand extends CommandNode {
setupFilter();
}
notEnoughArgsMsg = locale.get(Msg.CMD_FAIL_REQ_ARGS).parse("(3) " + Arrays.toString(getArguments()));
notEnoughArgsMsg = locale.getString(CommandLang.FAIL_REQ_ARGS, 3, Arrays.toString(getArguments()));
hashErrorMsg = "§cPassword hash error.";
}
@ -59,7 +59,6 @@ public class RegisterCommand extends CommandNode {
public void onCommand(ISender sender, String commandLabel, String[] args) {
try {
if (CommandUtils.isPlayer(sender)) {
Log.info(sender.getName() + " issued WebUser register command.");
playerRegister(args, sender);
} else {
consoleRegister(args, sender, notEnoughArgsMsg);
@ -93,7 +92,7 @@ public class RegisterCommand extends CommandNode {
} else if (sender.hasPermission(Permissions.MANAGE_WEB.getPermission())) {
consoleRegister(args, sender, notEnoughArgsMsg);
} else {
sender.sendMessage(locale.get(Msg.CMD_FAIL_NO_PERMISSION).parse());
sender.sendMessage(locale.getString(CommandLang.FAIL_NO_PERMISSION));
}
}
@ -117,9 +116,9 @@ public class RegisterCommand extends CommandNode {
RunnableFactory.createNew(new AbsRunnable("Register WebUser Task") {
@Override
public void run() {
final String existsMsg = "§cUser Already Exists!";
final String existsMsg = locale.getString(CommandLang.FAIL_WEB_USER_EXISTS);
final String userName = webUser.getName();
final String successMsg = "§aAdded a new user (" + userName + ") successfully!";
final String successMsg = locale.getString(CommandLang.WEB_USER_REGISTER_SUCCESS);
try {
Database database = Database.getActive();
boolean userExists = database.check().doesWebUserExists(userName);
@ -129,7 +128,7 @@ public class RegisterCommand extends CommandNode {
}
database.save().webUser(webUser);
sender.sendMessage(successMsg);
Log.info("Registered new user: " + userName + " Perm level: " + webUser.getPermLevel());
Log.info(locale.getString(CommandLang.WEB_USER_REGISTER_NOTIFY, userName, webUser.getPermLevel()));
} catch (Exception e) {
Log.toLog(this.getClass(), e);
} finally {

View File

@ -2,8 +2,8 @@ package com.djrapitops.plan.command.commands;
import com.djrapitops.plan.PlanPlugin;
import com.djrapitops.plan.system.locale.Locale;
import com.djrapitops.plan.system.locale.Msg;
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.plugin.api.utility.log.Log;
@ -38,8 +38,8 @@ public class ReloadCommand extends CommandNode {
plugin.reloadPlugin(true);
} catch (Exception e) {
Log.toLog(this.getClass(), e);
sender.sendMessage("§cSomething went wrong during reload of the plugin, a restart is recommended.");
sender.sendMessage(locale.getString(CommandLang.RELOAD_FAILED));
}
sender.sendMessage(locale.get(Msg.CMD_INFO_RELOAD_COMPLETE).toString());
sender.sendMessage(locale.getString(CommandLang.RELOAD_COMPLETE));
}
}

View File

@ -3,9 +3,10 @@ package com.djrapitops.plan.command.commands;
import com.djrapitops.plan.PlanPlugin;
import com.djrapitops.plan.api.exceptions.database.DBOpException;
import com.djrapitops.plan.system.locale.Locale;
import com.djrapitops.plan.system.locale.Msg;
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.settings.Permissions;
import com.djrapitops.plan.utilities.MiscUtils;
import com.djrapitops.plugin.api.utility.log.Log;
@ -42,9 +43,10 @@ public class SearchCommand extends CommandNode {
@Override
public void onCommand(ISender sender, String commandLabel, String[] args) {
Verify.isTrue(args.length >= 1, () -> new IllegalArgumentException(locale.get(Msg.CMD_FAIL_REQ_ONE_ARG).toString()));
Verify.isTrue(args.length >= 1,
() -> new IllegalArgumentException(locale.getString(CommandLang.FAIL_REQ_ONE_ARG, Arrays.toString(this.getArguments()))));
sender.sendMessage(locale.get(Msg.CMD_INFO_SEARCHING).toString());
sender.sendMessage(locale.getString(ManageLang.PROGRESS_START));
runSearchTask(args, sender);
}
@ -54,19 +56,18 @@ public class SearchCommand extends CommandNode {
@Override
public void run() {
try {
List<String> names = MiscUtils.getMatchingPlayerNames(args[0]);
String searchTerm = args[0];
List<String> names = MiscUtils.getMatchingPlayerNames(searchTerm);
boolean empty = Verify.isEmpty(names);
sender.sendMessage(locale.get(Msg.CMD_HEADER_SEARCH) + args[0] + " (" + (empty ? 0 : names.size()) + ")");
sender.sendMessage(locale.getString(CommandLang.HEADER_SEARCH, empty ? 0 : names.size(), searchTerm));
// Results
if (empty) {
sender.sendMessage(locale.get(Msg.CMD_INFO_NO_RESULTS).parse(Arrays.toString(args)));
} else {
sender.sendMessage(locale.get(Msg.CMD_INFO_RESULTS).toString() + FormatUtils.collectionToStringNoBrackets(names));
if (!empty) {
sender.sendMessage(FormatUtils.collectionToStringNoBrackets(names));
}
sender.sendMessage(locale.get(Msg.CMD_CONSTANT_FOOTER).toString());
sender.sendMessage(">");
} catch (DBOpException e) {
sender.sendMessage("§cDatabase error occurred: " + e.getMessage());
Log.toLog(this.getClass(), e);

View File

@ -11,8 +11,8 @@ import com.djrapitops.plan.system.info.request.UpdateCancelRequest;
import com.djrapitops.plan.system.info.request.UpdateRequest;
import com.djrapitops.plan.system.info.server.Server;
import com.djrapitops.plan.system.locale.Locale;
import com.djrapitops.plan.system.locale.Msg;
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.system.update.VersionCheckSystem;
@ -75,7 +75,7 @@ public class UpdateCommand extends CommandNode {
sender.sendMessage(message + url);
} else {
sender.sendMessage(message);
sender.sendLink(" ", locale.get(Msg.CMD_INFO_CLICK_ME).toString(), url);
sender.sendLink(" ", locale.getString(CommandLang.LINK_CLICK_ME), url);
}
return;
}

View File

@ -8,8 +8,8 @@ import com.djrapitops.plan.system.database.DBSystem;
import com.djrapitops.plan.system.database.databases.Database;
import com.djrapitops.plan.system.database.databases.sql.SQLiteDB;
import com.djrapitops.plan.system.locale.Locale;
import com.djrapitops.plan.system.locale.Msg;
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.settings.Permissions;
@ -50,7 +50,7 @@ public class ManageBackupCommand extends CommandNode {
public void onCommand(ISender sender, String commandLabel, String[] args) {
try {
Verify.isTrue(args.length >= 1,
() -> new IllegalArgumentException(locale.get(Msg.CMD_FAIL_REQ_ARGS).parse(Arrays.toString(this.getArguments()))));
() -> new IllegalArgumentException(locale.getString(CommandLang.FAIL_REQ_ONE_ARG, Arrays.toString(this.getArguments()))));
String dbName = args[0].toLowerCase();

View File

@ -6,8 +6,8 @@ import com.djrapitops.plan.api.exceptions.database.DBOpException;
import com.djrapitops.plan.system.database.DBSystem;
import com.djrapitops.plan.system.database.databases.Database;
import com.djrapitops.plan.system.locale.Locale;
import com.djrapitops.plan.system.locale.Msg;
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.settings.Permissions;
@ -19,6 +19,8 @@ import com.djrapitops.plugin.task.AbsRunnable;
import com.djrapitops.plugin.task.RunnableFactory;
import com.djrapitops.plugin.utilities.Verify;
import java.util.Arrays;
/**
* This manage SubCommand is used to clear a database of all data.
*
@ -42,7 +44,7 @@ public class ManageClearCommand extends CommandNode {
@Override
public void onCommand(ISender sender, String commandLabel, String[] args) {
Verify.isTrue(args.length >= 1,
() -> new IllegalArgumentException(locale.get(Msg.CMD_FAIL_REQ_ONE_ARG).toString()));
() -> new IllegalArgumentException(locale.getString(CommandLang.FAIL_REQ_ONE_ARG, Arrays.toString(this.getArguments()))));
String dbName = args[0].toLowerCase();

View File

@ -3,8 +3,8 @@ package com.djrapitops.plan.command.commands.manage;
import com.djrapitops.plan.PlanPlugin;
import com.djrapitops.plan.system.listeners.bukkit.PlayerOnlineListener;
import com.djrapitops.plan.system.locale.Locale;
import com.djrapitops.plan.system.locale.Msg;
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.plugin.command.CommandNode;
@ -37,15 +37,15 @@ public class ManageDisableCommand extends CommandNode {
@Override
public void onCommand(ISender sender, String commandLabel, String[] args) {
Verify.isTrue(args.length >= 1,
() -> new IllegalArgumentException(locale.get(Msg.CMD_FAIL_REQ_ARGS).parse(Arrays.toString(this.getArguments()))));
() -> new IllegalArgumentException(locale.getString(CommandLang.FAIL_REQ_ONE_ARG, Arrays.toString(this.getArguments()))));
switch (args[0].toLowerCase()) {
case "kickcount":
PlayerOnlineListener.setCountKicks(false);
sender.sendMessage("§aDisabled Kick Counting temporarily until next plugin reload.");
sender.sendMessage(locale.getString(CommandLang.FEATURE_DISABLED, "Kick Counting"));
break;
default:
sender.sendMessage("§eDefine a feature to disable! (currently supports only kickCount)");
sender.sendMessage(locale.getString(CommandLang.FAIL_NO_SUCH_FEATURE, "'kickcount'"));
}
}
}

View File

@ -4,8 +4,8 @@ import com.djrapitops.plan.PlanPlugin;
import com.djrapitops.plan.system.database.DBSystem;
import com.djrapitops.plan.system.database.databases.Database;
import com.djrapitops.plan.system.locale.Locale;
import com.djrapitops.plan.system.locale.Msg;
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.settings.Permissions;
import com.djrapitops.plan.system.settings.Settings;
@ -15,6 +15,8 @@ import com.djrapitops.plugin.command.CommandType;
import com.djrapitops.plugin.command.ISender;
import com.djrapitops.plugin.utilities.Verify;
import java.util.Arrays;
/**
* This manage SubCommand is used to swap to a different database and reload the
* plugin if the connection to the new database can be established.
@ -40,7 +42,7 @@ public class ManageHotSwapCommand extends CommandNode {
@Override
public void onCommand(ISender sender, String commandLabel, String[] args) {
Verify.isTrue(args.length >= 1,
() -> new IllegalArgumentException(locale.get(Msg.CMD_FAIL_REQ_ONE_ARG).toString()));
() -> new IllegalArgumentException(locale.getString(CommandLang.FAIL_REQ_ONE_ARG, Arrays.toString(this.getArguments()))));
String dbName = args[0].toLowerCase();

View File

@ -2,8 +2,8 @@ package com.djrapitops.plan.command.commands.manage;
import com.djrapitops.plan.PlanPlugin;
import com.djrapitops.plan.system.locale.Locale;
import com.djrapitops.plan.system.locale.Msg;
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.importing.ImporterManager;
import com.djrapitops.plan.system.processing.importing.importers.Importer;
@ -40,7 +40,7 @@ public class ManageImportCommand extends CommandNode {
@Override
public void onCommand(ISender sender, String commandLabel, String[] args) {
Verify.isTrue(args.length >= 1,
() -> new IllegalArgumentException(locale.get(Msg.CMD_FAIL_REQ_ARGS).parse(Arrays.toString(this.getArguments()))));
() -> new IllegalArgumentException(locale.getString(CommandLang.FAIL_REQ_ARGS, "1+", Arrays.toString(this.getArguments()))));
String importArg = args[0];

View File

@ -4,8 +4,8 @@ import com.djrapitops.plan.PlanPlugin;
import com.djrapitops.plan.system.database.DBSystem;
import com.djrapitops.plan.system.database.databases.Database;
import com.djrapitops.plan.system.locale.Locale;
import com.djrapitops.plan.system.locale.Msg;
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.settings.Permissions;
@ -44,7 +44,7 @@ public class ManageMoveCommand extends CommandNode {
@Override
public void onCommand(ISender sender, String commandLabel, String[] args) {
Verify.isTrue(args.length >= 2,
() -> new IllegalArgumentException(locale.get(Msg.CMD_FAIL_REQ_ARGS).parse(Arrays.toString(this.getArguments()))));
() -> new IllegalArgumentException(locale.getString(CommandLang.FAIL_REQ_ARGS, 2, Arrays.toString(this.getArguments()))));
String fromDB = args[0].toLowerCase();
boolean isCorrectDB = Verify.equalsOne(fromDB, "sqlite", "mysql");

View File

@ -4,8 +4,8 @@ import com.djrapitops.plan.PlanPlugin;
import com.djrapitops.plan.api.exceptions.database.DBOpException;
import com.djrapitops.plan.system.database.databases.Database;
import com.djrapitops.plan.system.locale.Locale;
import com.djrapitops.plan.system.locale.Msg;
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.settings.Permissions;
@ -19,6 +19,7 @@ import com.djrapitops.plugin.task.AbsRunnable;
import com.djrapitops.plugin.task.RunnableFactory;
import com.djrapitops.plugin.utilities.Verify;
import java.util.Arrays;
import java.util.UUID;
/**
@ -44,12 +45,12 @@ public class ManageRemoveCommand extends CommandNode {
@Override
public void onCommand(ISender sender, String commandLabel, String[] args) {
Verify.isTrue(args.length >= 1,
() -> new IllegalArgumentException(locale.get(Msg.CMD_FAIL_REQ_ONE_ARG).toString()));
() -> new IllegalArgumentException(locale.getString(CommandLang.FAIL_REQ_ONE_ARG, Arrays.toString(this.getArguments()))));
String playerName = MiscUtils.getPlayerName(args, sender, Permissions.MANAGE);
if (playerName == null) {
sender.sendMessage(locale.getString(Msg.CMD_FAIL_NO_PERMISSION));
sender.sendMessage(locale.getString(CommandLang.FAIL_NO_PERMISSION));
return;
}
@ -64,13 +65,13 @@ public class ManageRemoveCommand extends CommandNode {
UUID uuid = UUIDUtility.getUUIDOf(playerName);
if (uuid == null) {
sender.sendMessage(locale.get(Msg.CMD_FAIL_USERNAME_NOT_VALID).toString());
sender.sendMessage(locale.getString(CommandLang.FAIL_USERNAME_NOT_VALID));
return;
}
Database database = Database.getActive();
if (!database.check().isPlayerRegistered(uuid)) {
sender.sendMessage(locale.get(Msg.CMD_FAIL_USERNAME_NOT_KNOWN).toString());
sender.sendMessage(locale.getString(CommandLang.FAIL_USERNAME_NOT_KNOWN));
return;
}

View File

@ -5,8 +5,8 @@ import com.djrapitops.plan.system.database.DBSystem;
import com.djrapitops.plan.system.database.databases.Database;
import com.djrapitops.plan.system.database.databases.sql.SQLiteDB;
import com.djrapitops.plan.system.locale.Locale;
import com.djrapitops.plan.system.locale.Msg;
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.settings.Permissions;
@ -46,7 +46,7 @@ public class ManageRestoreCommand extends CommandNode {
@Override
public void onCommand(ISender sender, String commandLabel, String[] args) {
Verify.isTrue(args.length >= 2,
() -> new IllegalArgumentException(locale.get(Msg.CMD_FAIL_REQ_ARGS).parse(Arrays.toString(this.getArguments()))));
() -> new IllegalArgumentException(locale.getString(CommandLang.FAIL_REQ_ARGS, 2, Arrays.toString(this.getArguments()))));
String backupDbName = args[0];

View File

@ -4,8 +4,8 @@ import com.djrapitops.plan.PlanPlugin;
import com.djrapitops.plan.api.exceptions.connection.*;
import com.djrapitops.plan.system.info.InfoSystem;
import com.djrapitops.plan.system.locale.Locale;
import com.djrapitops.plan.system.locale.Msg;
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;
@ -17,6 +17,8 @@ import com.djrapitops.plugin.command.CommandType;
import com.djrapitops.plugin.command.ISender;
import com.djrapitops.plugin.utilities.Verify;
import java.util.Arrays;
/**
* This manage SubCommand is used to request settings from Bungee so that connection can be established.
*
@ -40,15 +42,15 @@ public class ManageSetupCommand extends CommandNode {
@Override
public void onCommand(ISender sender, String commandLabel, String[] args) {
Verify.isTrue(args.length >= 1,
() -> new IllegalArgumentException(locale.get(Msg.CMD_FAIL_REQ_ONE_ARG).toString()));
() -> new IllegalArgumentException(locale.getString(CommandLang.FAIL_REQ_ONE_ARG, Arrays.toString(this.getArguments()))));
if (!WebServerSystem.isWebServerEnabled()) {
sender.sendMessage("§cWebServer is not enabled on this server! Make sure it enables on boot!");
sender.sendMessage(locale.getString(CommandLang.CONNECT_WEBSERVER_NOT_ENABLED));
return;
}
String address = args[0].toLowerCase();
if (!address.startsWith("http") || address.endsWith("://")) {
sender.sendMessage("§cMake sure you're using the full address (Starts with http:// or https://) - Check Bungee enable log for the full address.");
sender.sendMessage(locale.getString(CommandLang.CONNECT_URL_MISTAKE));
return;
}
if (address.endsWith("/")) {
@ -66,22 +68,22 @@ public class ManageSetupCommand extends CommandNode {
InfoSystem.getInstance().requestSetUp(address);
sender.sendMessage("§aConnection successful, Plan may restart in a few seconds..");
sender.sendMessage(locale.getString(CommandLang.CONNECT_SUCCESS));
} catch (ForbiddenException e) {
sender.sendMessage("§eConnection succeeded, but Bungee has set-up mode disabled - use '/planbungee setup' to enable it.");
sender.sendMessage(locale.getString(CommandLang.CONNECT_FORBIDDEN));
} catch (BadRequestException e) {
sender.sendMessage("§eConnection succeeded, but Receiving server was a Bukkit server. Use Bungee address instead.");
sender.sendMessage(locale.getString(CommandLang.CONNECT_BAD_REQUEST));
} catch (UnauthorizedServerException e) {
sender.sendMessage("§eConnection succeeded, but Receiving server didn't authorize this server. Contact Discord for support");
sender.sendMessage(locale.getString(CommandLang.CONNECT_UNAUTHORIZED));
} catch (ConnectionFailException e) {
sender.sendMessage("§eConnection failed: " + e.getMessage());
sender.sendMessage(locale.getString(CommandLang.CONNECT_FAIL, e.getMessage()));
} catch (InternalErrorException e) {
sender.sendMessage("§eConnection succeeded. " + e.getMessage() + ", check possible ErrorLog on receiving server's debug page.");
sender.sendMessage(locale.getString(CommandLang.CONNECT_INTERNAL_ERROR, e.getMessage()));
} catch (GatewayException e) {
sender.sendMessage("§eConnection succeeded, but Bungee failed to connect to this server. Use Connection debug commands for more.");
sender.sendMessage(locale.getString(CommandLang.CONNECT_GATEWAY));
} catch (WebException e) {
Log.toLog(this.getClass(), e);
sender.sendMessage("§cConnection to Bungee WebServer failed: More info in the error log.");
sender.sendMessage(locale.getString(CommandLang.CONNECT_FAIL, e.toString()));
}
});
}

View File

@ -4,8 +4,8 @@ import com.djrapitops.plan.PlanPlugin;
import com.djrapitops.plan.data.WebUser;
import com.djrapitops.plan.system.database.databases.Database;
import com.djrapitops.plan.system.locale.Locale;
import com.djrapitops.plan.system.locale.Msg;
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.settings.Permissions;
import com.djrapitops.plugin.api.utility.log.Log;
@ -40,7 +40,7 @@ public class WebCheckCommand extends CommandNode {
@Override
public void onCommand(ISender sender, String commandLabel, String[] args) {
Verify.isTrue(args.length >= 1,
() -> new IllegalArgumentException(locale.get(Msg.CMD_FAIL_REQ_ARGS).parse(Arrays.toString(this.getArguments()))));
() -> new IllegalArgumentException(locale.getString(CommandLang.FAIL_REQ_ONE_ARG, Arrays.toString(this.getArguments()))));
Database database = Database.getActive();
String user = args[0];
@ -50,11 +50,11 @@ public class WebCheckCommand extends CommandNode {
public void run() {
try {
if (!database.check().doesWebUserExists(user)) {
sender.sendMessage("§c[Plan] User Doesn't exist.");
sender.sendMessage(locale.getString(CommandLang.FAIL_WEB_USER_NOT_EXISTS));
return;
}
WebUser info = database.fetch().getWebUser(user);
sender.sendMessage(info.getName() + ": Permission level: " + info.getPermLevel());
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()));

View File

@ -3,8 +3,8 @@ package com.djrapitops.plan.command.commands.webuser;
import com.djrapitops.plan.PlanPlugin;
import com.djrapitops.plan.system.database.databases.Database;
import com.djrapitops.plan.system.locale.Locale;
import com.djrapitops.plan.system.locale.Msg;
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.settings.Permissions;
import com.djrapitops.plugin.api.utility.log.Log;
@ -39,7 +39,7 @@ public class WebDeleteCommand extends CommandNode {
@Override
public void onCommand(ISender sender, String commandLabel, String[] args) {
Verify.isTrue(args.length >= 1,
() -> new IllegalArgumentException(locale.get(Msg.CMD_FAIL_REQ_ARGS).parse(Arrays.toString(this.getArguments()))));
() -> new IllegalArgumentException(locale.getString(CommandLang.FAIL_REQ_ONE_ARG, Arrays.toString(this.getArguments()))));
Database database = Database.getActive();
String user = args[0];

View File

@ -2,13 +2,12 @@ package com.djrapitops.plan.command.commands.webuser;
import com.djrapitops.plan.PlanPlugin;
import com.djrapitops.plan.system.locale.Locale;
import com.djrapitops.plan.system.locale.Msg;
import com.djrapitops.plan.system.locale.lang.CmdHelpLang;
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.settings.ColorScheme;
/**
* Subcommand for info about permission levels.
@ -18,7 +17,6 @@ import com.djrapitops.plugin.settings.ColorScheme;
*/
public class WebLevelCommand extends CommandNode {
private final PlanPlugin plugin;
private final Locale locale;
public WebLevelCommand(PlanPlugin plugin) {
@ -27,25 +25,11 @@ public class WebLevelCommand extends CommandNode {
locale = plugin.getSystem().getLocaleSystem().getLocale();
setShortHelp(locale.getString(CmdHelpLang.WEB_LEVEL));
this.plugin = plugin;
}
@Override
public void onCommand(ISender sender, String commandLabel, String[] args) {
ColorScheme cs = plugin.getColorScheme();
String sCol = cs.getSecondaryColor();
String cmdFooter = locale.get(Msg.CMD_CONSTANT_FOOTER).parse();
String[] messages = new String[]{
cmdFooter,
sCol + "0: Access all pages",
sCol + "1: Access '/players' and all inspect pages",
sCol + "2: Access inspect page with the same username as the webuser",
sCol + "3+: No permissions",
cmdFooter
};
sender.sendMessage(messages);
sender.sendMessage(locale.getArray(CommandLang.WEB_PERMISSION_LEVELS));
}
}

View File

@ -4,8 +4,8 @@ import com.djrapitops.plan.PlanPlugin;
import com.djrapitops.plan.data.WebUser;
import com.djrapitops.plan.system.database.databases.Database;
import com.djrapitops.plan.system.locale.Locale;
import com.djrapitops.plan.system.locale.Msg;
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.settings.Permissions;
import com.djrapitops.plan.utilities.comparators.WebUserComparator;
@ -41,7 +41,7 @@ public class WebListUsersCommand extends CommandNode {
@Override
public void onCommand(ISender sender, String commandLabel, String[] args) {
RunnableFactory.createNew(new AbsRunnable("Webuser List Task") {
RunnableFactory.createNew(new AbsRunnable("Web user List Task") {
@Override
public void run() {
try {
@ -49,11 +49,11 @@ public class WebListUsersCommand extends CommandNode {
String mCol = cs.getMainColor();
List<WebUser> users = Database.getActive().fetch().getWebUsers();
users.sort(new WebUserComparator());
sender.sendMessage(locale.get(Msg.CMD_CONSTANT_FOOTER).parse() + mCol + " WebUsers (" + users.size() + ")");
sender.sendMessage(locale.getString(CommandLang.HEADER_WEB_USERS, users.size()));
for (WebUser user : users) {
sender.sendMessage(" " + user.getPermLevel() + " : " + user.getName());
sender.sendMessage(locale.getString(CommandLang.WEB_USER_LIST, user.getName(), user.getPermLevel()));
}
sender.sendMessage(locale.get(Msg.CMD_CONSTANT_FOOTER).parse());
sender.sendMessage(">");
} catch (Exception e) {
Log.toLog(this.getClass(), e);
sender.sendMessage(locale.getString(ManageLang.PROGRESS_FAIL, e.getMessage()));

View File

@ -29,10 +29,12 @@ public class LocaleSystem implements SubSystem {
public static Map<String, Lang> getIdentifiers() {
Lang[][] lang = new Lang[][]{
CommandLang.values(),
CmdHelpLang.values(),
DeepHelpLang.values(),
PluginLang.values(),
ManageLang.values()
ManageLang.values(),
GenericLang.values()
};
return Arrays.stream(lang)

View File

@ -1,48 +0,0 @@
package com.djrapitops.plan.system.locale;
import com.djrapitops.plan.system.locale.lang.Lang;
@Deprecated
public enum Msg implements Lang {
CMD_FAIL_REQ_ARGS("Cmd FAIL - Requires Arguments"),
CMD_FAIL_REQ_ONE_ARG("Cmd FAIL - Require only one Argument"),
CMD_FAIL_NO_PERMISSION("Cmd FAIL - No Permission"),
CMD_FAIL_USERNAME_NOT_VALID("Cmd FAIL - Invalid Username"),
CMD_FAIL_USERNAME_NOT_SEEN("Cmd FAIL - Unseen Username"),
CMD_FAIL_USERNAME_NOT_KNOWN("Cmd FAIL - Unknown Username"),
CMD_FAIL_TIMEOUT("Cmd FAIL - Timeout"),
CMD_FAIL_NO_DATA_VIEW("Cmd FAIL - No Data View"),
CMD_INFO_CLICK_ME("Cmd - Click Me"),
CMD_INFO_LINK("Cmd - Link"),
CMD_INFO_RESULTS("Cmd - Results"),
CMD_INFO_NO_RESULTS("Cmd - No Results"),
CMD_INFO_RELOAD_COMPLETE("Cmd - Reload Success"),
CMD_INFO_FETCH_DATA("Cmd - Fetch Data"),
CMD_INFO_SEARCHING("Cmd - Searching"),
CMD_HEADER_ANALYZE("Cmd Header - Analysis"),
CMD_HEADER_INSPECT("Cmd Header - Inspect"),
CMD_HEADER_INFO("Cmd Header - Info"),
CMD_HEADER_SEARCH("Cmd Header - Search"),
CMD_CONSTANT_FOOTER(">Constant - CMD Footer"),
;
private final String identifier;
private String defaultValue;
Msg(String identifier) {
this.identifier = identifier;
defaultValue = "";
}
public String getIdentifier() {
return identifier;
}
public String getDefault() {
return defaultValue;
}
}

View File

@ -0,0 +1,85 @@
package com.djrapitops.plan.system.locale.lang;
/**
* {@link Lang} implementation for general command language.
*
* @author Rsl1122
*/
public enum CommandLang implements Lang {
FAIL_REQ_ARGS("Cmd FAIL - Requires Arguments", "§cArguments required (${0}) ${1}"),
FAIL_REQ_ONE_ARG("Cmd FAIL - Require only one Argument", "§cSingle Argument required ${1}"),
FAIL_NO_PERMISSION("Cmd FAIL - No Permission", "§cYou do not have the required permission."),
FAIL_USERNAME_NOT_VALID("Cmd FAIL - Invalid Username", "§cUser does not have an UUID."),
FAIL_USERNAME_NOT_KNOWN("Cmd FAIL - Unknown Username", "§cUser has not been seen on this server"),
FAIL_WEB_USER_EXISTS("Cmd FAIL - WebUser exists", "§cUser already exists!"),
FAIL_WEB_USER_NOT_EXISTS("Cmd FAIL - WebUser does not exists", "§cUser does not exists!"),
FAIL_NO_SUCH_FEATURE("Cmd FAIL - No Feature", "§eDefine a feature to disable! (currently supports ${0})"),
FEATURE_DISABLED("Cmd SUCCESS - Feature disabled", "§aDisabled '${0}' temporarily until next plugin reload."),
WEB_USER_REGISTER_SUCCESS("Cmd SUCCESS - WebUser register", "§aAdded a new user (${0}) successfully!"),
WEB_USER_REGISTER_NOTIFY("Cmd Notify - WebUser register", "Registered new user: '${0}' Perm level: ${1}"),
WEB_USER_LIST("Web User Listing", " §2${0} §7: §f${1}"),
NO_WEB_USER_NOTIFY("Cmd Notify - No WebUser", "You might not have a web user, use /plan register <password>"),
WEB_PERMISSION_LEVELS("Cmd Web - Permission Levels", ">\\§70: Access all pages\\§71: Access '/players' and all inspect pages\\§72: Access inspect page with the same username as the webuser\\§73+: No permissions"),
CONNECT_SUCCESS("Cmd Setup - Success", "§aConnection successful, Plan may restart in a few seconds.."),
CONNECT_FORBIDDEN("Cmd Setup - Forbidden", "§eConnection succeeded, but Bungee has set-up mode disabled - use '/planbungee setup' to enable it."),
CONNECT_BAD_REQUEST("Cmd Setup - Bad Request", "§eConnection succeeded, but Receiving server was a Bukkit server. Use Bungee address instead."),
CONNECT_UNAUTHORIZED("Cmd Setup - Unauthorized", "§eConnection succeeded, but Receiving server didn't authorize this server. Contact Discord for support"),
CONNECT_FAIL("Cmd Setup - Generic Fail", "§eConnection failed: ${0}"),
CONNECT_INTERNAL_ERROR("Cmd Setup - Internal Error", "§eConnection succeeded. ${0}, check possible ErrorLog on receiving server's debug page."),
CONNECT_GATEWAY("Cmd Setup - Gateway Error", "§eConnection succeeded, but Bungee failed to connect to this server (Did current web server restart?). Use /plan m con & /planbungee con to debug."),
CONNECT_WEBSERVER_NOT_ENABLED("Cmd Setup - WebServer not Enabled", "§cWebServer is not enabled on this server! Make sure it enables on boot!"),
CONNECT_URL_MISTAKE("Cmd Setup - Url mistake", "§cMake sure you're using the full address (Starts with http:// or https://) - Check Bungee enable log for the full address."),
LINK_CLICK_ME("Cmd - Click Me", "Click me"),
LINK_PREFIX("Cmd - Link", " §2Link: "),
HEADER_SEARCH("Cmd Header - Search", "> §2${0} Results for §f${1}§2:"),
HEADER_ANALYSIS("Cmd Header - Analysis", "> §2Analysis Results"),
HEADER_INFO("Cmd Header - Info", "> §2Player Analytics"),
HEADER_INSPECT("Cmd Header - Inspect", "> §2Player: §f${0}"),
HEADER_SERVERS("Cmd Header - Servers", "> §2Servers"),
HEADER_PLAYERS("Cmd Header - Players", "> §2Players"),
HEADER_WEB_USERS("Cmd Header - Web Users", "> §2${0} Web Users"),
HEADER_NETWORK("Cmd Header - Network", "> §2Network Page"),
INFO_VERSION("Cmd Info - Version", " §2Version: §f${0}"),
INFO_UPDATE("Cmd Info - Update", " §2Update Available: §f${0}"),
INFO_DATABASE("Cmd Info - Database", " §2Active Database: §f${0}"),
INFO_BUNGEE_CONNECTION("Cmd Info - Bungee Connection", " §2Connected to Bungee: §f${0}"),
QINSPECT_ACTIVITY_INDEX("Cmd Qinspect - Activity Index", " §2Activity Index: §f${0} | ${1}"),
QINSPECT_REGISTERED("Cmd Qinspect - Registered", " §2Registered: §f${0}"),
QINSPECT_LAST_SEEN("Cmd Qinspect - Last Seen", " §2Last Seen: §f${0}"),
QINSPECT_GEOLOCATION("Cmd Qinspect - Geolocation", " §2Logged in from: §f${0}"),
QINSPECT_PLAYTIME("Cmd Qinspect - Playtime", " §2Playtime: §f${0}"),
QINSPECT_LONGEST_SESSION("Cmd Qinspect - Longest Session", " §2Longest Session: §f${0}"),
QINSPECT_TIMES_KICKED("Cmd Qinspect - Times Kicked", " §2Times Kicked: §f${0}"),
QINSPECT_PLAYER_KILLS("Cmd Qinspect - Player Kills", " §2Player Kills: §f${0}"),
QINSPECT_MOB_KILLS("Cmd Qinspect - Mob Kills", " §2Mob Kills: §f${0}"),
QINSPECT_DEATHS("Cmd Qinspect - Deaths", " §2Deaths: §f${0}"),
RELOAD_COMPLETE("Cmd Info - Reload Complete", "§aReload Complete"),
RELOAD_FAILED("Cmd Info - Reload Failed", "§cSomething went wrong during reload of the plugin, a restart is recommended.");
private final String identifier;
private final String defaultValue;
CommandLang(String identifier, String defaultValue) {
this.identifier = identifier;
this.defaultValue = defaultValue;
}
@Override
public String getIdentifier() {
return identifier;
}
@Override
public String getDefault() {
return defaultValue;
}
}

View File

@ -0,0 +1,30 @@
package com.djrapitops.plan.system.locale.lang;
/**
* {@link Lang} implementation for single words.
*
* @author Rsl1122
*/
public enum GenericLang implements Lang {
YES("Positive", "Yes"),
NO("Negative", "No"),
UNKNOWN("Unknown", "Unknown");
private final String identifier;
private final String defaultValue;
GenericLang(String identifier, String defaultValue) {
this.identifier = identifier;
this.defaultValue = defaultValue;
}
@Override
public String getIdentifier() {
return identifier;
}
@Override
public String getDefault() {
return defaultValue;
}
}

View File

@ -9,7 +9,7 @@ import com.djrapitops.plan.system.cache.SessionCache;
import com.djrapitops.plan.system.info.InfoSystem;
import com.djrapitops.plan.system.info.connection.ConnectionSystem;
import com.djrapitops.plan.system.locale.Locale;
import com.djrapitops.plan.system.locale.Msg;
import com.djrapitops.plan.system.locale.lang.CommandLang;
import com.djrapitops.plugin.api.utility.log.Log;
import com.djrapitops.plugin.command.CommandUtils;
import com.djrapitops.plugin.command.ISender;
@ -51,18 +51,18 @@ public class InspectCacheRequestProcessor implements Runnable {
// TODO Move to InspectCommand somehow.
private void sendInspectMsg(ISender sender, String playerName) {
sender.sendMessage(locale.get(Msg.CMD_HEADER_INSPECT) + " " + playerName);
sender.sendMessage(locale.getString(CommandLang.HEADER_INSPECT, playerName));
// Link
String url = ConnectionSystem.getInstance().getMainAddress() + "/player/" + playerName;
String message = locale.get(Msg.CMD_INFO_LINK).toString();
String linkPrefix = locale.getString(CommandLang.LINK_PREFIX);
boolean console = !CommandUtils.isPlayer(sender);
if (console) {
sender.sendMessage(message + url);
sender.sendMessage(linkPrefix + url);
} else {
sender.sendMessage(message);
sender.sendLink(" ", locale.get(Msg.CMD_INFO_CLICK_ME).toString(), url);
sender.sendMessage(linkPrefix);
sender.sendLink(" ", locale.getString(CommandLang.LINK_CLICK_ME), url);
}
sender.sendMessage(locale.get(Msg.CMD_CONSTANT_FOOTER).toString());
sender.sendMessage(">");
}
}