This commit is contained in:
Fuzzlemann 2017-08-10 21:21:06 +02:00
commit ccc1058841
72 changed files with 1517 additions and 1158 deletions

View File

@ -3,7 +3,6 @@
"http://www.puppycrawl.com/dtds/configuration_1_3.dtd">
<module name='Checker'>
<!-- asetetaan kieliasetukset englanniksi. -->
<property name="localeCountry" value="EN"/>
<property name="localeLanguage" value="en"/>

View File

@ -4,7 +4,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>com.djrapitops</groupId>
<artifactId>Plan</artifactId>
<version>3.6.1</version>
<version>3.6.2</version>
<packaging>jar</packaging>
<repositories>
<repository>
@ -109,6 +109,7 @@
<include>*.js</include>
<include>*.yml</include>
<include>*.html</include>
<include>*.txt</include>
</includes>
</resource>
</resources>

View File

@ -1,271 +0,0 @@
package main.java.com.djrapitops.plan;
import org.bukkit.ChatColor;
import java.io.File;
import java.io.IOException;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;
/**
* Phrase contains every message that is used in placeholders or commands. The
* contents for each message can be changed. Every message can contain a String
* or ChatColor.
*
* @author Rsl1122
* @since 2.0.0
*/
public enum Phrase {
REPLACE0("REPLACE0"),
PREFIX("[Plan] "),
ENABLED("Player Analytics Enabled."),
DISABLED("Player Analytics Disabled."),
RELOAD_COMPLETE(ChatColor.GREEN.toString() + PREFIX + "Reload complete."),
CACHE_SAVE("Saving cached data.."),
CACHE_ADD("Added REPLACE0 to Cache."),
CACHE_REMOVE("Cleared REPLACE0 from Cache."),
CONFIG_HEADER("Plan Config | More info at https://www.spigotmc.org/wiki/plan-configuration/"),
DB_INIT("Database init.."),
WEBSERVER_INIT("Initializing Webserver.."),
WEBSERVER_CLOSE("Shutting down Webserver.."),
WEBSERVER_RUNNING("Webserver running on PORT " + REPLACE0),
DB_CONNECTION_FAIL("REPLACE0-Database Connection failed: REPLACE1"),
DB_ESTABLISHED(REPLACE0 + "-database connection established."),
DB_TYPE_DOES_NOT_EXIST("That database type doesn't exist."),
DB_FAILURE_DISABLE("Database initialization has failed, disabling Plan."),
NOTIFY_EMPTY_IP(ChatColor.YELLOW.toString() + PREFIX + "IP in server.properties is empty & AlternativeServerIP is not used, incorrect links will be given!"),
NOTIFY_DISABLED_CHATLISTENER(ChatColor.YELLOW + "Chat listener disabled, nickname info inaccurate."),
NOTIFY_DISABLED_GMLISTENER(ChatColor.YELLOW + "Gamemode change listener disabled, Gm times info inaccurate."),
NOTIFY_DISABLED_COMMANDLISTENER(ChatColor.YELLOW + "Command usage listener disabled."),
NOTIFY_DISABLED_DEATHLISTENER(ChatColor.YELLOW + "Death listener disabled, player & mob kills not recorded."),
//
CACHE_SAVETASK_DISABLED("Attempted to schedule data for save after task was shut down."),
CACHE_GETTASK_DISABLED("Attempted to schedule data grab after task was shut down."),
CACHE_CLEARTASK_DISABLED("Attempted to schedule data for clear after task was shut down."),
//
VERSION_NEW_AVAILABLE("New Version (" + REPLACE0 + ") is available at https://www.spigotmc.org/resources/plan-player-analytics.32536/"),
VERSION_LATEST("You're running the latest version"),
VERSION_CHECK_ERROR("Failed to compare versions."),
VERSION_FAIL("Failed to get newest version number."),
//
USERNAME_NOT_VALID(ChatColor.RED.toString() + PREFIX + "This Player doesn't exist."),
USERNAME_NOT_SEEN(ChatColor.RED.toString() + PREFIX + "This Player has not played on this server."),
USERNAME_NOT_KNOWN(ChatColor.RED.toString() + PREFIX + "Player not found from the database."),
//
COLOR_MAIN(ChatColor.getByChar(Settings.COLOR_MAIN.toString().charAt(1))),
COLOR_SEC(ChatColor.getByChar(Settings.COLOR_SEC.toString().charAt(1))),
COLOR_TER(ChatColor.getByChar(Settings.COLOR_TER.toString().charAt(1))),
//
ARROWS_RIGHT("»"),
BALL(""),
GRABBING_DATA_MESSAGE(COLOR_TER.toString() + ARROWS_RIGHT + COLOR_MAIN.color() + " Fetching data to cache.."),
//
DEM_UNKNOWN("Not Known"),
NOT_IN_TOWN("Not in a town"),
NOT_IN_FAC("Not in a faction"),
//
ANALYSIS("Analysis | "),
COMMAND_TIMEOUT(ChatColor.RED.toString() + PREFIX + "REPLACE0 Command timed out! Check '/plan status' & console."),
ANALYSIS_START(ANALYSIS + "Beginning analysis of user data.."),
ANALYSIS_BOOT_NOTIFY(ANALYSIS + "Boot analysis in 30 seconds.."),
ANALYSIS_BOOT(ANALYSIS + "Starting Boot Analysis.."),
ANALYSIS_FETCH_PLAYERS(ANALYSIS + "Checking for available players.."),
ANALYSIS_FETCH_DATA(ANALYSIS + "Fetching Data.."),
ANALYSIS_FAIL_NO_PLAYERS(ANALYSIS + "Analysis failed, no known players."),
ANALYSIS_FAIL_NO_DATA(ANALYSIS + "Analysis failed, no data in the database."),
ANALYSIS_BEGIN_ANALYSIS(ANALYSIS + "Data Fetched (REPLACE0 users, took REPLACE1ms), beginning Analysis of data.."),
ANALYSIS_THIRD_PARTY(ANALYSIS + "Analyzing additional data sources (3rd party)"),
ANALYSIS_COMPLETE(ANALYSIS + "Analysis Complete. (took REPLACE0ms) REPLACE1"),
DATA_CORRUPTION_WARN("Some data might be corrupted: " + REPLACE0),
//
ERROR_CONSOLE_PLAYER("This point of code should not be accessable on console. Inform author: " + REPLACE0 + " Console: REPLACE1"),
ERROR_NO_DATA_VIEW(ChatColor.YELLOW + "Webserver disabled but Alternative IP/PlanLite not used, no way to view data!"),
ERROR_WEBSERVER_OFF_ANALYSIS(ChatColor.YELLOW + "" + PREFIX + "This command can be only used if the webserver is running on this server."),
ERROR_WEBSERVER_OFF_INSPECT(ChatColor.YELLOW + "" + PREFIX + "This command can be only used if webserver is enabled on this server."),
ERROR_LOGGED("Caught " + REPLACE0 + ". It has been logged to the Errors.txt"),
ERROR_SESSIONDATA_INITIALIZATION("Player's session was initialized in a wrong way! (" + REPLACE0 + ")"),
ERROR_ANALYSIS_FETCH_FAIL("Failed to fetch data for Analysis, Exception occurred."),
ERROR_ANALYSIS_DISABLED_TEMPORARILY(ChatColor.YELLOW + "Analysis has been temporarily disabled due to expensive task, use /plan status for info."),
//
CMD_FOOTER(COLOR_TER.color().toString() + ARROWS_RIGHT),
MANAGE_ERROR_INCORRECT_PLUGIN(ChatColor.RED.toString() + PREFIX + "Plugin not supported: "),
MANAGE_PROCESS_START(ARROWS_RIGHT.toString() + COLOR_SEC.color() + " Processing data.."),
MANAGE_ERROR_PLUGIN_NOT_ENABLED(ChatColor.RED.toString() + PREFIX + "Plugin is not enabled: "),
MANAGE_ERROR_INCORRECT_DB(ChatColor.RED.toString() + PREFIX + "Incorrect database! (sqlite/mysql accepted): "),
MANAGE_ERROR_SAME_DB(ChatColor.RED.toString() + PREFIX + "Can't move to the same database!"),
MANAGE_DATABASE_FAILURE(ChatColor.RED.toString() + PREFIX + "One of the databases was not initialized properly."),
MANAGE_DB_CONFIG_REMINDER(ChatColor.YELLOW.toString() + PREFIX + "Remember to swap to the new database and reload plugin"),
MANAGE_ERROR_NO_PLAYERS(ChatColor.RED.toString() + PREFIX + "Database has no player data!"),
MANAGE_ERROR_BACKUP_FILE_NOT_FOUND(ChatColor.RED.toString() + PREFIX + "Backup file doesn't exist!"),
MANAGE_MOVE_SUCCESS(ChatColor.GREEN.toString() + PREFIX + "All data moved successfully!"),
MANAGE_COPY_SUCCESS(ChatColor.GREEN.toString() + PREFIX + "All data copied successfully!"),
MANAGE_PROCESS_FAIL(ChatColor.RED.toString() + PREFIX + "Something went wrong while processing the data!"),
MANAGE_CLEAR_SUCCESS(ChatColor.GREEN.toString() + PREFIX + "All data cleared successfully!"),
MANAGE_REMOVE_SUCCESS(CMD_FOOTER + " " + COLOR_MAIN.color() + "Data of " + COLOR_TER.color() + "REPLACE0" + COLOR_MAIN.color() + " was removed from Database " + COLOR_TER.color() + "REPLACE1" + COLOR_MAIN.color() + "."),
MANAGE_IMPORTING(CMD_FOOTER + " " + COLOR_MAIN.color() + " Importing Data.."),
MANAGE_SUCCESS(CMD_FOOTER + " " + COLOR_MAIN.color() + " Success!"),
//
CMD_BALL(COLOR_SEC.color() + " " + Phrase.BALL.toString() + COLOR_MAIN.color()),
CMD_ANALYZE_HEADER(CMD_FOOTER.toString() + COLOR_MAIN.color() + " Player Analytics - Analysis results"),
CMD_INSPECT_HEADER(CMD_FOOTER.toString() + COLOR_MAIN.color() + " Player Analytics - Inspect results: "),
CMD_INFO_HEADER(CMD_FOOTER.toString() + COLOR_MAIN.color() + " Player Analytics - Info"),
CMD_INFO_VERSION(CMD_BALL.toString() + COLOR_MAIN.color() + " Version: " + COLOR_SEC.color() + REPLACE0),
CMD_SEARCH_HEADER(CMD_FOOTER.toString() + COLOR_MAIN.color() + " Player Analytics - Search results for: "),
CMD_SEARCH_SEARCHING(CMD_FOOTER.toString() + COLOR_MAIN.color() + " Searching.."),
CMD_HELP_HEADER(CMD_FOOTER.toString() + COLOR_MAIN.color() + " Player Analytics - Help"),
CMD_MANAGE_HELP_HEADER(CMD_FOOTER.toString() + COLOR_MAIN.color() + " Player Analytics - Managment Help"),
CMD_MANAGE_STATUS_HEADER(CMD_FOOTER.toString() + COLOR_MAIN.color() + " Player Analytics - Database status"),
CMD_MANAGE_STATUS_ACTIVE_DB(CMD_BALL.toString() + COLOR_MAIN.color() + " Active Database: " + COLOR_SEC.color() + "REPLACE0"),
CMD_MANAGE_STATUS_QUEUE_SAVE(CMD_BALL.toString() + COLOR_MAIN.color() + " Save Queue Size: " + COLOR_SEC.color() + "REPLACE0/" + Settings.PROCESS_SAVE_LIMIT.getNumber()),
CMD_MANAGE_STATUS_QUEUE_GET(CMD_BALL.toString() + COLOR_MAIN.color() + " Get Queue Size: " + COLOR_SEC.color() + "REPLACE0/" + Settings.PROCESS_GET_LIMIT.getNumber()),
CMD_MANAGE_STATUS_QUEUE_CLEAR(CMD_BALL.toString() + COLOR_MAIN.color() + " Clear Queue Size: " + COLOR_SEC.color() + "REPLACE0/" + Settings.PROCESS_CLEAR_LIMIT.getNumber()),
CMD_MANAGE_STATUS_QUEUE_PROCESS(CMD_BALL.toString() + COLOR_MAIN.color() + " Process Queue Size: " + COLOR_SEC.color() + "REPLACE0/20000"),
CMD_CLICK_ME("Click Me"),
CMD_LINK(COLOR_SEC.color() + " " + BALL + COLOR_MAIN.color() + " Link: " + COLOR_TER.color()),
CMD_PASS_PLANLITE("UNUSED"),
CMD_RESULTS_AVAILABLE(COLOR_SEC.color() + " Results will be available for " + COLOR_TER.color() + REPLACE0 + COLOR_SEC.color() + " minutes."),
CMD_NO_RESULTS(CMD_BALL + " No results for " + COLOR_SEC.color() + REPLACE0 + COLOR_MAIN.color() + "."),
CMD_MATCH(COLOR_SEC.color() + " Matching players: " + COLOR_TER.color()),
//
CMD_USG_ANALYZE("View the Server Analysis"),
CMD_USG_QANALYZE("View the Server QuickAnalysis"),
CMD_USG_HELP("Show command list."),
CMD_USG_INFO("View Version of Plan"),
CMD_USG_INSPECT("Inspect Player's Data"),
CMD_USG_QINSPECT("QuickInspect Player's Data"),
CMD_USG_MANAGE("Database management command"),
CMD_USG_MANAGE_BACKUP("Backup a database to .db file"),
CMD_USG_MANAGE_RESTORE("Restore a database from a backup file"),
CMD_USG_MANAGE_MOVE("Copy data from one database to another & overwrite values"),
CMD_USG_MANAGE_COMBINE("Copy data from one database to another & combine values"),
CMD_USG_MANAGE_IMPORT("Import Data from supported plugins to Active Database."),
CMD_USG_MANAGE_CLEAR("Clear data from one database"),
CMD_USG_MANAGE_CLEAN("Clear incorrect data from the database"),
CMD_USG_MANAGE_REMOVE("Remove players's data from the Active Database."),
CMD_USG_MANAGE_STATUS("Check the status of the Active Database."),
CMD_USG_MANAGE_HELP("Show management help."),
CMD_USG_MANAGE_HOTSWAP("Hotswap to another database & restart the plugin"),
CMD_USG_RELOAD("Reload plugin config & save cached data"),
CMD_USG_SEARCH("Search for player"),
ARG_SEARCH("<part of playername>"),
ARG_PLAYER("<player>"),
ARG_RESTORE("<Filename.db> <dbTo> [-a]"),
ARG_IMPORT("<plugin>/list [import args]"),
ARG_MOVE("<fromDB> <toDB> [-a]"),
//
USE_BACKUP("Use /plan manage backup <DB>"),
USE_RESTORE("Use /plan manage restore <Filename.db> <dbTo> [-a]"),
USE_MANAGE("Use /plan manage for help"),
USE_PLAN("Use /plan for help"),
USE_MOVE("Use /plan manage move <fromDB> <toDB> [-a]"),
USE_COMBINE("Use /plan manage combine <fromDB> <toDB> [-a]"),
USE_IMPORT("Use /plan manage import " + ARG_IMPORT),
//
WARN_REWRITE("Data in REPLACE0-database will be rewritten!"),
WARN_OVERWRITE("Data in REPLACE0-database will be overwritten!"),
WARN_OVERWRITE_SOME("Some data in REPLACE0-database will be overwritten!"),
WARN_REMOVE("Data in REPLACE0-database will be removed!"),
//
COMMAND_SENDER_NOT_PLAYER(ChatColor.RED.toString() + PREFIX + "This command can be only used as a player."),
COMMAND_REQUIRES_ARGUMENTS(ChatColor.RED.toString() + PREFIX + "Command requires arguments. REPLACE0"),
COMMAND_ADD_CONFIRMATION_ARGUMENT(ChatColor.RED.toString() + PREFIX + "Add -a to confirm execution! REPLACE0"),
COMMAND_REQUIRES_ARGUMENTS_ONE(ChatColor.RED.toString() + PREFIX + "Command requires one argument."),
COMMAND_NO_PERMISSION(ChatColor.RED.toString() + PREFIX + "You do not have the required permission."),
ERROR_TOO_SMALL_QUEUE("Queue size is too small! (REPLACE0), change the setting to a higher number! (Currently REPLACE1)");
private String text;
private ChatColor color;
Phrase(String text) {
this.text = text;
this.color = null;
}
Phrase(ChatColor color) {
this.color = color;
this.text = "";
}
static void loadLocale(File localeFile) {
try (Scanner localeScanner = new Scanner(localeFile, "UTF-8")) {
List<String> localeRows = new ArrayList<>();
while (localeScanner.hasNextLine()) {
String line = localeScanner.nextLine();
if (!line.isEmpty()) {
if ("<<<<<<HTML>>>>>>".equals(line)) {
break;
}
localeRows.add(line);
}
}
for (String localeRow : localeRows) {
try {
String[] split = localeRow.split(" <> ");
Phrase.valueOf(split[0]).setText(split[1]);
} catch (IllegalArgumentException e) {
Log.error("There is a miswritten line in locale on line " + localeRows.indexOf(localeRow));
}
}
} catch (IOException e) {
Log.error("Error at Locale Scanning: " + e.getCause());
}
}
@Override
public String toString() {
return text;
}
/**
* Alternative for toString.
*
* @return toString()
*/
public String parse() {
return this.toString();
}
/**
* Replaces all REPLACE{x} strings with the given parameters.
*
* @param p Strings to replace REPLACE{x}:s with
* @return String with placeholders replaced.
*/
public String parse(Serializable... p) {
String returnValue = this.toString();
for (int i = 0; i < p.length; i++) {
returnValue = returnValue.replace("REPLACE" + i, p[i].toString());
}
return returnValue;
}
/**
* Used to get the ChatColor of COLOR_ enums.
*
* @return Color of the COLOR_ENUM
*/
public ChatColor color() {
return color;
}
/**
* Used to set the text of the Enum.
*
* @param text A String.
*/
public void setText(String text) {
this.text = text;
}
/**
* Set the ChatColor of any Enum.
*
* @param colorCode The character that determines a chatcolor. 1-9, a-f etc.
*/
public void setColor(char colorCode) {
this.color = ChatColor.getByChar(colorCode);
}
}

View File

@ -37,17 +37,16 @@ import main.java.com.djrapitops.plan.data.listeners.*;
import main.java.com.djrapitops.plan.database.Database;
import main.java.com.djrapitops.plan.database.databases.MySQLDB;
import main.java.com.djrapitops.plan.database.databases.SQLiteDB;
import main.java.com.djrapitops.plan.ui.html.Html;
import main.java.com.djrapitops.plan.locale.Locale;
import main.java.com.djrapitops.plan.locale.Msg;
import main.java.com.djrapitops.plan.ui.webserver.WebServer;
import main.java.com.djrapitops.plan.utilities.Benchmark;
import main.java.com.djrapitops.plan.utilities.Check;
import main.java.com.djrapitops.plan.utilities.MiscUtils;
import main.java.com.djrapitops.plan.utilities.metrics.BStats;
import org.apache.logging.log4j.LogManager;
import org.bukkit.ChatColor;
import java.io.*;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.HashSet;
import java.util.Set;
import java.util.concurrent.Executors;
@ -115,7 +114,15 @@ public class Plan extends BukkitPlugin<Plan> {
// Sets the Required variables for BukkitPlugin instance to function correctly
setInstance(this);
super.setDebugMode(Settings.DEBUG.toString());
super.setColorScheme(new ColorScheme(Phrase.COLOR_MAIN.color(), Phrase.COLOR_SEC.color(), Phrase.COLOR_TER.color()));
try {
ChatColor mainColor = ChatColor.getByChar(Settings.COLOR_MAIN.toString().charAt(1));
ChatColor secColor = ChatColor.getByChar(Settings.COLOR_SEC.toString().charAt(1));
ChatColor terColor = ChatColor.getByChar(Settings.COLOR_TER.toString().charAt(1));
super.setColorScheme(new ColorScheme(mainColor, secColor, terColor));
} catch (Exception e) {
Log.infoColor(ChatColor.RED + "Customization, Chat colors set-up wrong, using defaults.");
super.setColorScheme(new ColorScheme(ChatColor.DARK_GREEN, ChatColor.GRAY, ChatColor.WHITE));
}
super.setLogPrefix("[Plan]");
super.setUpdateCheckUrl("https://raw.githubusercontent.com/Rsl1122/Plan-PlayerAnalytics/master/Plan/src/main/resources/plugin.yml");
super.setUpdateUrl("https://www.spigotmc.org/resources/plan-player-analytics.32536/");
@ -125,21 +132,23 @@ public class Plan extends BukkitPlugin<Plan> {
Benchmark.start("Enable");
initLocale();
// Initialize Locale
new Locale(this).loadLocale();
Benchmark.start("Reading server variables");
serverVariableHolder = new ServerVariableHolder(getServer());
Benchmark.stop("Enable", "Reading server variables");
Benchmark.start("Copy default config");
getConfig().options().copyDefaults(true);
getConfig().options().header(Phrase.CONFIG_HEADER.toString());
getConfig().options().header("Plan Config | More info at https://www.spigotmc.org/wiki/plan-configuration/");
saveConfig();
Benchmark.stop("Enable", "Copy default config");
Benchmark.start("Init Database");
Log.info(Phrase.DB_INIT.toString());
if (Check.ErrorIfFalse(initDatabase(), Phrase.DB_FAILURE_DISABLE.toString())) {
Log.info(Phrase.DB_ESTABLISHED.parse(db.getConfigName()));
Log.info(Locale.get(Msg.ENABLE_DB_INIT).toString());
if (Check.ErrorIfFalse(initDatabase(), Locale.get(Msg.ENABLE_DB_FAIL_DISABLE_INFO).toString())) {
Log.info(Locale.get(Msg.ENABLE_DB_INFO).parse(db.getConfigName()));
} else {
disablePlugin();
return;
@ -192,10 +201,10 @@ public class Plan extends BukkitPlugin<Plan> {
setupFilter();
} else if (!hasDataViewCapability) {
Log.infoColor(Phrase.ERROR_NO_DATA_VIEW.toString());
Log.infoColor(Locale.get(Msg.ENABLE_NOTIFY_NO_DATA_VIEW).toString());
}
if (!usingAlternativeIP && serverVariableHolder.getIp().isEmpty()) {
Log.infoColor(Phrase.NOTIFY_EMPTY_IP.toString());
Log.infoColor(Locale.get(Msg.ENABLE_NOTIFY_EMPTY_IP).toString());
}
Benchmark.stop("Enable", "WebServer Initialization");
@ -210,7 +219,7 @@ public class Plan extends BukkitPlugin<Plan> {
Log.debug("Verbose debug messages are enabled.");
Log.logDebug("Enable", Benchmark.stop("Enable", "Enable"));
Log.info(Phrase.ENABLED.toString());
Log.info(Locale.get(Msg.ENABLED).toString());
} catch (Exception e) {
Log.error("Plugin Failed to Initialize Correctly.");
Log.toLog(this.getClass().getName(), e);
@ -238,7 +247,7 @@ public class Plan extends BukkitPlugin<Plan> {
if (Verify.notNull(handler, db)) {
Benchmark.start("Disable: DataCache Save");
// Saves the DataCache to the database without Bukkit's Schedulers.
Log.info(Phrase.CACHE_SAVE.toString());
Log.info(Locale.get(Msg.DISABLE_CACHE_SAVE).toString());
ScheduledExecutorService scheduler = Executors.newSingleThreadScheduledExecutor();
scheduler.execute(() -> {
@ -250,15 +259,15 @@ public class Plan extends BukkitPlugin<Plan> {
scheduler.shutdown(); // Schedules the save to shutdown after it has ran the execute method.
}
Log.info(Phrase.DISABLED.toString());
Log.info(Locale.get(Msg.DISABLED).toString());
}
private void registerListeners() {
Benchmark.start("Register Listeners");
registerListener(new PlanPlayerListener(this));
boolean chatListenerIsEnabled = Check.isTrue(Settings.GATHERCHAT.isTrue(), Phrase.NOTIFY_DISABLED_CHATLISTENER.toString());
boolean commandListenerIsEnabled = Check.isTrue(Settings.GATHERCOMMANDS.isTrue(), Phrase.NOTIFY_DISABLED_COMMANDLISTENER.toString());
boolean deathListenerIsEnabled = Check.isTrue(Settings.GATHERKILLS.isTrue(), Phrase.NOTIFY_DISABLED_DEATHLISTENER.toString());
boolean chatListenerIsEnabled = Check.isTrue(Settings.GATHERCHAT.isTrue(), Locale.get(Msg.ENABLE_NOTIFY_DISABLED_CHATLISTENER).toString());
boolean commandListenerIsEnabled = Check.isTrue(Settings.GATHERCOMMANDS.isTrue(), Locale.get(Msg.ENABLE_NOTIFY_DISABLED_COMMANDLISTENER).toString());
boolean deathListenerIsEnabled = Check.isTrue(Settings.GATHERKILLS.isTrue(), Locale.get(Msg.ENABLE_NOTIFY_DISABLED_DEATHLISTENER).toString());
if (chatListenerIsEnabled) {
registerListener(new PlanChatListener(this));
@ -301,11 +310,11 @@ public class Plan extends BukkitPlugin<Plan> {
}
if (!Verify.notNull(db)) {
Log.info(Phrase.DB_TYPE_DOES_NOT_EXIST.toString() + " " + dbType);
Log.info(Locale.get(Msg.ENABLE_FAIL_WRONG_DB).toString() + " " + dbType);
return false;
}
return Check.ErrorIfFalse(db.init(), Phrase.DB_FAILURE_DISABLE.toString());
return Check.ErrorIfFalse(db.init(), Locale.get(Msg.ENABLE_DB_FAIL_DISABLE_INFO).toString());
}
private void startAnalysisRefreshTask(int everyXMinutes) throws IllegalStateException {
@ -327,12 +336,17 @@ public class Plan extends BukkitPlugin<Plan> {
private void startBootAnalysisTask() throws IllegalStateException {
Benchmark.start("Schedule boot analysis task");
Log.info(Phrase.ANALYSIS_BOOT_NOTIFY + "");
String bootAnalysisMsg = Locale.get(Msg.ENABLE_BOOT_ANALYSIS_INFO).toString();
String bootAnalysisRunMsg = Locale.get(Msg.ENABLE_BOOT_ANALYSIS_RUN_INFO).toString();
Log.info(bootAnalysisMsg);
ITask bootAnalysisTask = getRunnableFactory().createNew("BootAnalysisTask", new AbsRunnable() {
@Override
public void run() {
Log.debug("Running BootAnalysisTask");
Log.info(Phrase.ANALYSIS_BOOT + "");
Log.info(bootAnalysisRunMsg);
analysisCache.updateCache();
this.cancel();
}
@ -341,96 +355,6 @@ public class Plan extends BukkitPlugin<Plan> {
Benchmark.stop("Enable", "Schedule boot analysis task");
}
/**
* Used to write a new Locale file in the plugin's datafolder.
*/
public void writeNewLocaleFile() {
File genLocale = new File(getDataFolder(), "locale_EN.txt");
try (
FileWriter fw = new FileWriter(genLocale, true);
PrintWriter pw = new PrintWriter(fw)
) {
if (genLocale.createNewFile()) {
Log.debug(genLocale.getAbsoluteFile() + " created");
}
for (Phrase p : Phrase.values()) {
pw.println(p.name() + " <> " + p.parse());
pw.flush();
}
pw.println("<<<<<<HTML>>>>>>");
for (Html h : Html.values()) {
pw.println(h.name() + " <> " + h.parse());
pw.flush();
}
} catch (IOException ex) {
Log.toLog(this.getClass().getName(), ex);
}
}
private void initLocale() {
String defaultLocale = "Default: EN";
String locale = Settings.LOCALE.toString().toUpperCase();
Benchmark.start("Initializing locale");
File localeFile = new File(getDataFolder(), "locale.txt");
String usingLocale;
if (localeFile.exists()) {
Phrase.loadLocale(localeFile);
Html.loadLocale(localeFile);
stopInitLocale(defaultLocale);
return;
}
if (locale.equals("DEFAULT")) {
stopInitLocale(defaultLocale);
return;
}
String urlString = "https://raw.githubusercontent.com/Rsl1122/Plan-PlayerAnalytics/master/Plan/localization/locale_" + locale + ".txt";
URL localeURL;
try {
localeURL = new URL(urlString);
} catch (MalformedURLException e) {
Log.error("Error at parsing \"" + urlString + "\" to an URL"); //Shouldn't ever happen
stopInitLocale(defaultLocale);
return;
}
try (InputStream inputStream = localeURL.openStream();
OutputStream outputStream = new FileOutputStream(localeFile)) {
int read;
byte[] bytes = new byte[1024];
while ((read = inputStream.read(bytes)) != -1) {
outputStream.write(bytes, 0, read);
}
Phrase.loadLocale(localeFile);
Html.loadLocale(localeFile);
usingLocale = locale;
if (localeFile.delete()) {
Log.debug(localeFile.getAbsoluteFile() + " (Locale File) deleted");
}
stopInitLocale(usingLocale);
} catch (FileNotFoundException ex) {
Log.error("Attempted using locale that doesn't exist.");
stopInitLocale(defaultLocale);
} catch (IOException e) {
Log.error("Error at loading locale from GitHub, using default locale.");
stopInitLocale(defaultLocale);
}
}
/**
* Setups the command console output filter
*/
@ -439,17 +363,6 @@ public class Plan extends BukkitPlugin<Plan> {
logger.addFilter(new RegisterCommandFilter());
}
/**
* Stops initializing the locale
*
* @param usingLocale The locale that's used
* @implNote Removes clutter in the method
*/
private void stopInitLocale(String usingLocale) {
Benchmark.stop("Enable", "Initializing locale");
Log.info("Using locale: " + usingLocale);
}
/**
* Used to access AnalysisCache.
*

View File

@ -25,6 +25,7 @@ public enum Settings {
COMBINE_COMMAND_ALIASES_TO_MAIN_COMMAND("Customization.Data.CombineCommandAliasesToMainCommand"),
SECURITY_IP_UUID("Settings.WebServer.Security.DisplayIPsAndUUIDs"),
PLAYERLIST_SHOW_IMAGES("Customization.SmallHeadImagesOnAnalysisPlayerlist"),
WRITE_NEW_LOCALE("Settings.WriteNewLocaleFileOnStart"),
// Integer
ANALYSIS_MINUTES_FOR_ACTIVE("Settings.Analysis.MinutesPlayedUntilConsidiredActive"),
SAVE_CACHE_MIN("Settings.Cache.DataCache.SaveEveryXMinutes"),

View File

@ -3,10 +3,11 @@ package main.java.com.djrapitops.plan.command;
import com.djrapitops.plugin.command.CommandType;
import com.djrapitops.plugin.command.TreeCommand;
import com.djrapitops.plugin.command.defaultcmds.StatusCommand;
import com.djrapitops.plugin.settings.ColorScheme;
import main.java.com.djrapitops.plan.Permissions;
import main.java.com.djrapitops.plan.Plan;
import main.java.com.djrapitops.plan.command.commands.*;
import main.java.com.djrapitops.plan.locale.Locale;
import main.java.com.djrapitops.plan.locale.Msg;
/**
* TreeCommand for the /plan command, and all subcommands.
@ -32,18 +33,7 @@ public class PlanCommand extends TreeCommand<Plan> {
@Override
public String[] addHelp() {
ColorScheme colorScheme = Plan.getInstance().getColorScheme();
String mCol = colorScheme.getMainColor();
String sCol = colorScheme.getSecondaryColor();
String tCol = colorScheme.getTertiaryColor();
return new String[]{
mCol + "/plan - Main Command",
tCol + " Used to access all SubCommands & help",
sCol + " /plan - List subcommands",
sCol + " /plan <subcommand> ? - in depth help"
};
return Locale.get(Msg.CMD_HELP_PLAN).toArray();
}
@Override

View File

@ -5,11 +5,15 @@ import com.djrapitops.plugin.command.CommandType;
import com.djrapitops.plugin.command.CommandUtils;
import com.djrapitops.plugin.command.ISender;
import com.djrapitops.plugin.command.SubCommand;
import com.djrapitops.plugin.settings.ColorScheme;
import com.djrapitops.plugin.task.AbsRunnable;
import main.java.com.djrapitops.plan.*;
import main.java.com.djrapitops.plan.Log;
import main.java.com.djrapitops.plan.Permissions;
import main.java.com.djrapitops.plan.Plan;
import main.java.com.djrapitops.plan.Settings;
import main.java.com.djrapitops.plan.command.ConditionUtils;
import main.java.com.djrapitops.plan.data.cache.AnalysisCacheHandler;
import main.java.com.djrapitops.plan.locale.Locale;
import main.java.com.djrapitops.plan.locale.Msg;
import main.java.com.djrapitops.plan.ui.text.TextUI;
import main.java.com.djrapitops.plan.utilities.Check;
import main.java.com.djrapitops.plan.utilities.HtmlUtils;
@ -33,49 +37,39 @@ public class AnalyzeCommand extends SubCommand {
* @param plugin Current instance of Plan
*/
public AnalyzeCommand(Plan plugin) {
super("analyze, analyse, analysis, a", CommandType.CONSOLE, Permissions.ANALYZE.getPermission(), Phrase.CMD_USG_ANALYZE.parse());
super("analyze, analyse, analysis, a",
CommandType.CONSOLE,
Permissions.ANALYZE.getPermission(),
Locale.get(Msg.CMD_USG_ANALYZE).parse());
this.plugin = plugin;
analysisCache = plugin.getAnalysisCache();
}
@Override
public String[] addHelp() {
ColorScheme colorScheme = Plan.getInstance().getColorScheme();
String mCol = colorScheme.getMainColor();
String sCol = colorScheme.getSecondaryColor();
String tCol = colorScheme.getTertiaryColor();
return new String[]{
mCol + "Analysis Command",
tCol + " Used to Refresh analysis cache & Access the result page",
sCol + " /plan status can be used to check status of analysis while it is running.",
sCol + " Aliases: analyze, analyse, analysis, a"
};
return Locale.get(Msg.CMD_HELP_ANALYZE).toArray();
}
@Override
public boolean onCommand(ISender sender, String commandLabel, String[] args) {
if (!Check.isTrue(ConditionUtils.pluginHasViewCapability(), Phrase.ERROR_WEBSERVER_OFF_ANALYSIS.toString(), sender)) {
if (!Check.isTrue(ConditionUtils.pluginHasViewCapability(), Locale.get(Msg.CMD_FAIL_NO_DATA_VIEW).toString(), sender)) {
return true;
}
if (!Check.isTrue(analysisCache.isAnalysisEnabled(), Phrase.ERROR_ANALYSIS_DISABLED_TEMPORARILY.toString(), sender)
if (!Check.isTrue(analysisCache.isAnalysisEnabled(), Locale.get(Msg.CMD_INFO_ANALYSIS_TEMP_DISABLE).toString(), sender)
&& !analysisCache.isCached()) {
return true;
}
sender.sendMessage(Phrase.GRABBING_DATA_MESSAGE + "");
if (plugin.getUiServer().isAuthRequired()) {
sender.sendMessage(Locale.get(Msg.CMD_INFO_FETCH_DATA).toString());
if (plugin.getUiServer().isAuthRequired() && CommandUtils.isPlayer(sender)) {
plugin.getRunnableFactory().createNew(new AbsRunnable("WebUser exist check task") {
@Override
public void run() {
try {
if (CommandUtils.isPlayer(sender)) {
boolean senderHasWebUser = plugin.getDB().getSecurityTable().userExists(sender.getName());
if (!senderHasWebUser) {
sender.sendMessage(ChatColor.YELLOW + "[Plan] You might not have a web user, use /plan register <password>");
}
boolean senderHasWebUser = plugin.getDB().getSecurityTable().userExists(sender.getName());
if (!senderHasWebUser) {
sender.sendMessage(ChatColor.YELLOW + "[Plan] You might not have a web user, use /plan register <password>");
}
} catch (Exception e) {
Log.toLog(this.getClass().getName() + getName(), e);
@ -114,7 +108,7 @@ public class AnalyzeCommand extends SubCommand {
}
if (timesRun > 10) {
Log.debug("Command Timeout Message, Analysis.");
sender.sendMessage(Phrase.COMMAND_TIMEOUT.parse("Analysis"));
sender.sendMessage(Locale.get(Msg.CMD_FAIL_TIMEOUT).parse("Analysis"));
this.cancel();
}
}
@ -130,21 +124,21 @@ public class AnalyzeCommand extends SubCommand {
*/
private void sendAnalysisMessage(ISender sender) {
boolean textUI = Settings.USE_ALTERNATIVE_UI.isTrue();
sender.sendMessage(Phrase.CMD_ANALYZE_HEADER.toString());
sender.sendMessage(Locale.get(Msg.CMD_HEADER_ANALYZE).toString());
if (textUI) {
sender.sendMessage(TextUI.getAnalysisMessages());
} else {
// Link
String url = HtmlUtils.getServerAnalysisUrlWithProtocol();
String message = Phrase.CMD_LINK.toString();
String message = Locale.get(Msg.CMD_INFO_LINK).toString();
boolean console = !CommandUtils.isPlayer(sender);
if (console) {
sender.sendMessage(message + url);
} else {
sender.sendMessage(message);
sender.sendLink(" ", Phrase.CMD_CLICK_ME.toString(), url);
sender.sendLink(" ", Locale.get(Msg.CMD_INFO_CLICK_ME).toString(), url);
}
}
sender.sendMessage(Phrase.CMD_FOOTER.toString());
sender.sendMessage(Locale.get(Msg.CMD_CONSTANT_FOOTER).toString());
}
}

View File

@ -3,11 +3,12 @@ package main.java.com.djrapitops.plan.command.commands;
import com.djrapitops.plugin.command.CommandType;
import com.djrapitops.plugin.command.ISender;
import com.djrapitops.plugin.command.SubCommand;
import com.djrapitops.plugin.settings.ColorScheme;
import com.djrapitops.plugin.settings.Version;
import main.java.com.djrapitops.plan.Permissions;
import main.java.com.djrapitops.plan.Phrase;
import main.java.com.djrapitops.plan.Plan;
import org.bukkit.ChatColor;
import main.java.com.djrapitops.plan.locale.Locale;
import main.java.com.djrapitops.plan.locale.Msg;
/**
* This subcommand is used to view the version and the database type in use.
@ -25,20 +26,26 @@ public class InfoCommand extends SubCommand {
* @param plugin Current instance of Plan
*/
public InfoCommand(Plan plugin) {
super("info", CommandType.CONSOLE, Permissions.INFO.getPermission(), Phrase.CMD_USG_INFO.toString());
super("info",
CommandType.CONSOLE,
Permissions.INFO.getPermission(),
Locale.get(Msg.CMD_USG_INFO).toString());
this.plugin = plugin;
}
@Override
public boolean onCommand(ISender sender, String commandLabel, String[] args) {
ChatColor tColor = Phrase.COLOR_SEC.color();
ColorScheme cs = plugin.getColorScheme();
String mColor = cs.getMainColor();
String sColor = cs.getSecondaryColor();
String tColor = cs.getTertiaryColor();
String[] messages = {
Phrase.CMD_INFO_HEADER.toString(),
Phrase.CMD_INFO_VERSION.parse(plugin.getDescription().getVersion()),
Phrase.CMD_BALL.toString() + tColor + " " + Version.checkVersion(plugin),
Phrase.CMD_MANAGE_STATUS_ACTIVE_DB.parse(plugin.getDB().getConfigName()),
Phrase.CMD_FOOTER.toString()
Locale.get(Msg.CMD_HEADER_INFO).toString(),
Locale.get(Msg.CMD_CONSTANT_LIST_BALL).toString() + mColor + " Version: " + sColor + plugin.getDescription().getVersion(),
Locale.get(Msg.CMD_CONSTANT_LIST_BALL).toString() + tColor + " " + Version.checkVersion(plugin),
Locale.get(Msg.CMD_CONSTANT_LIST_BALL).toString() + mColor + " Active Database: " + tColor + plugin.getDB().getConfigName(),
Locale.get(Msg.CMD_CONSTANT_FOOTER).toString()
};
sender.sendMessage(messages);
return true;

View File

@ -5,12 +5,16 @@ import com.djrapitops.plugin.command.CommandType;
import com.djrapitops.plugin.command.CommandUtils;
import com.djrapitops.plugin.command.ISender;
import com.djrapitops.plugin.command.SubCommand;
import com.djrapitops.plugin.settings.ColorScheme;
import com.djrapitops.plugin.task.AbsRunnable;
import com.djrapitops.plugin.utilities.Verify;
import main.java.com.djrapitops.plan.*;
import main.java.com.djrapitops.plan.Log;
import main.java.com.djrapitops.plan.Permissions;
import main.java.com.djrapitops.plan.Plan;
import main.java.com.djrapitops.plan.Settings;
import main.java.com.djrapitops.plan.command.ConditionUtils;
import main.java.com.djrapitops.plan.data.cache.InspectCacheHandler;
import main.java.com.djrapitops.plan.locale.Locale;
import main.java.com.djrapitops.plan.locale.Msg;
import main.java.com.djrapitops.plan.ui.text.TextUI;
import main.java.com.djrapitops.plan.utilities.Check;
import main.java.com.djrapitops.plan.utilities.HtmlUtils;
@ -38,7 +42,11 @@ public class InspectCommand extends SubCommand {
* @param plugin Current instance of Plan
*/
public InspectCommand(Plan plugin) {
super("inspect", CommandType.CONSOLE_WITH_ARGUMENTS, Permissions.INSPECT.getPermission(), Phrase.CMD_USG_INSPECT.toString(), Phrase.ARG_PLAYER.toString());
super("inspect",
CommandType.CONSOLE_WITH_ARGUMENTS,
Permissions.INSPECT.getPermission(),
Locale.get(Msg.CMD_USG_INSPECT).toString(),
"<player>");
this.plugin = plugin;
inspectCache = plugin.getInspectCache();
@ -47,23 +55,12 @@ public class InspectCommand extends SubCommand {
@Override
public String[] addHelp() {
ColorScheme colorScheme = Plan.getInstance().getColorScheme();
String mCol = colorScheme.getMainColor();
String sCol = colorScheme.getSecondaryColor();
String tCol = colorScheme.getTertiaryColor();
return new String[]{
mCol + "Inspect command",
tCol + " Used to get a link to User's inspect page.",
sCol + " Own inspect page can be accessed with /plan inspect",
sCol + " Alias: /plan <name>"
};
return Locale.get(Msg.CMD_HELP_INSPECT).toArray();
}
@Override
public boolean onCommand(ISender sender, String commandLabel, String[] args) {
if (!Check.isTrue(ConditionUtils.pluginHasViewCapability(), Phrase.ERROR_WEBSERVER_OFF_INSPECT.toString(), sender)) {
if (!Check.isTrue(ConditionUtils.pluginHasViewCapability(), Locale.get(Msg.CMD_FAIL_NO_DATA_VIEW).toString(), sender)) {
return true;
}
@ -79,16 +76,16 @@ public class InspectCommand extends SubCommand {
public void run() {
try {
UUID uuid = UUIDUtility.getUUIDOf(playerName);
if (!Check.isTrue(Verify.notNull(uuid), Phrase.USERNAME_NOT_VALID.toString(), sender)) {
if (!Check.isTrue(Verify.notNull(uuid), Locale.get(Msg.CMD_FAIL_USERNAME_NOT_VALID).toString(), sender)) {
return;
}
if (!Check.isTrue(ConditionUtils.playerHasPlayed(uuid), Phrase.USERNAME_NOT_SEEN.toString(), sender)) {
if (!Check.isTrue(ConditionUtils.playerHasPlayed(uuid), Locale.get(Msg.CMD_FAIL_USERNAME_NOT_SEEN).toString(), sender)) {
return;
}
if (!Check.isTrue(plugin.getDB().wasSeenBefore(uuid), Phrase.USERNAME_NOT_KNOWN.toString(), sender)) {
if (!Check.isTrue(plugin.getDB().wasSeenBefore(uuid), Locale.get(Msg.CMD_FAIL_USERNAME_NOT_KNOWN).toString(), sender)) {
return;
}
sender.sendMessage(Phrase.GRABBING_DATA_MESSAGE.toString());
sender.sendMessage(Locale.get(Msg.CMD_INFO_FETCH_DATA).toString());
if (CommandUtils.isPlayer(sender) && plugin.getUiServer().isAuthRequired()) {
boolean senderHasWebUser = plugin.getDB().getSecurityTable().userExists(sender.getName());
if (!senderHasWebUser) {
@ -120,7 +117,7 @@ public class InspectCommand extends SubCommand {
}
if (timesrun > 10) {
Log.debug("Command Timeout Message, Inspect.");
sender.sendMessage(Phrase.COMMAND_TIMEOUT.parse("Inspect"));
sender.sendMessage(Locale.get(Msg.CMD_FAIL_TIMEOUT).parse("Inspect"));
this.cancel();
}
}
@ -132,23 +129,23 @@ public class InspectCommand extends SubCommand {
boolean usingTextUI = Settings.USE_ALTERNATIVE_UI.isTrue();
sender.sendMessage(Phrase.CMD_INSPECT_HEADER + playerName);
sender.sendMessage(Locale.get(Msg.CMD_HEADER_INSPECT) + playerName);
if (usingTextUI) {
sender.sendMessage(TextUI.getInspectMessages(uuid));
} else {
// Link
String url = HtmlUtils.getInspectUrlWithProtocol(playerName);
String message = Phrase.CMD_LINK.toString();
String message = Locale.get(Msg.CMD_INFO_LINK).toString();
boolean console = !CommandUtils.isPlayer(sender);
if (console) {
sender.sendMessage(message + url);
} else {
sender.sendMessage(message);
sender.sendLink(" ", Phrase.CMD_CLICK_ME.toString(), url);
sender.sendLink(" ", Locale.get(Msg.CMD_INFO_CLICK_ME).toString(), url);
}
}
sender.sendMessage(Phrase.CMD_FOOTER.toString());
sender.sendMessage(Locale.get(Msg.CMD_CONSTANT_FOOTER).toString());
}
}

View File

@ -4,11 +4,11 @@ import com.djrapitops.plugin.command.CommandType;
import com.djrapitops.plugin.command.CommandUtils;
import com.djrapitops.plugin.command.ISender;
import com.djrapitops.plugin.command.SubCommand;
import com.djrapitops.plugin.settings.ColorScheme;
import main.java.com.djrapitops.plan.Permissions;
import main.java.com.djrapitops.plan.Phrase;
import main.java.com.djrapitops.plan.Plan;
import main.java.com.djrapitops.plan.command.ConditionUtils;
import main.java.com.djrapitops.plan.locale.Locale;
import main.java.com.djrapitops.plan.locale.Msg;
import main.java.com.djrapitops.plan.utilities.Check;
import main.java.com.djrapitops.plan.utilities.HtmlUtils;
@ -28,30 +28,18 @@ public class ListCommand extends SubCommand {
* @param plugin Current instance of Plan
*/
public ListCommand(Plan plugin) {
super("list, pl", CommandType.CONSOLE, Permissions.INSPECT_OTHER.getPermission(), "List to all cached players", "");
super("list, pl", CommandType.CONSOLE, Permissions.INSPECT_OTHER.getPermission(), Locale.get(Msg.CMD_USG_LIST).toString(), "");
}
@Override
public String[] addHelp() {
ColorScheme colorScheme = Plan.getInstance().getColorScheme();
String mCol = colorScheme.getMainColor();
String sCol = colorScheme.getSecondaryColor();
String tCol = colorScheme.getTertiaryColor();
return new String[]{
mCol + "List command",
tCol + " Used to get a link to players page.",
sCol + " Players page contains links to all cached inspect pages.",
sCol + " Alias: /plan pl"
};
return Locale.get(Msg.CMD_HELP_LIST).toArray();
}
@Override
public boolean onCommand(ISender sender, String commandLabel, String[] args) {
if (!Check.isTrue(ConditionUtils.pluginHasViewCapability(), Phrase.ERROR_WEBSERVER_OFF_INSPECT + "", sender)) {
if (!Check.isTrue(ConditionUtils.pluginHasViewCapability(), Locale.get(Msg.CMD_FAIL_NO_DATA_VIEW) + "", sender)) {
return true;
}
sendListMsg(sender);
@ -59,18 +47,18 @@ public class ListCommand extends SubCommand {
}
private void sendListMsg(ISender sender) {
sender.sendMessage(Phrase.CMD_FOOTER.parse());
sender.sendMessage(Locale.get(Msg.CMD_CONSTANT_FOOTER).parse());
// Link
String url = HtmlUtils.getServerAnalysisUrlWithProtocol().replace("server", "players");
String message = Phrase.CMD_LINK.toString();
String message = Locale.get(Msg.CMD_INFO_LINK).toString();
boolean console = !CommandUtils.isPlayer(sender);
if (console) {
sender.sendMessage(message + url);
} else {
sender.sendMessage(message);
sender.sendLink(" ", Phrase.CMD_CLICK_ME.toString(), url);
sender.sendLink(" ", Locale.get(Msg.CMD_INFO_CLICK_ME).toString(), url);
}
sender.sendMessage(Phrase.CMD_FOOTER.toString());
sender.sendMessage(Locale.get(Msg.CMD_CONSTANT_FOOTER).toString());
}
}

View File

@ -2,11 +2,11 @@ package main.java.com.djrapitops.plan.command.commands;
import com.djrapitops.plugin.command.CommandType;
import com.djrapitops.plugin.command.TreeCommand;
import com.djrapitops.plugin.settings.ColorScheme;
import main.java.com.djrapitops.plan.Permissions;
import main.java.com.djrapitops.plan.Phrase;
import main.java.com.djrapitops.plan.Plan;
import main.java.com.djrapitops.plan.command.commands.manage.*;
import main.java.com.djrapitops.plan.locale.Locale;
import main.java.com.djrapitops.plan.locale.Msg;
/**
* This command is used to manage the database of the plugin.
@ -24,25 +24,13 @@ public class ManageCommand extends TreeCommand<Plan> {
* @param plugin Current instance of Plan
*/
public ManageCommand(Plan plugin) {
super(plugin, "manage,m", CommandType.CONSOLE, Permissions.MANAGE.getPermission(), Phrase.CMD_USG_MANAGE + "", "plan m");
super(plugin, "manage,m", CommandType.CONSOLE, Permissions.MANAGE.getPermission(), Locale.get(Msg.CMD_USG_MANAGE) + "", "plan m");
}
@Override
public String[] addHelp() {
ColorScheme colorScheme = Plan.getInstance().getColorScheme();
String mCol = colorScheme.getMainColor();
String sCol = colorScheme.getSecondaryColor();
String tCol = colorScheme.getTertiaryColor();
return new String[]{
mCol + "Manage command",
tCol + " Used to Manage Database of the plugin.",
sCol + " Alias: /plan m",
sCol + " /plan m - List subcommands",
sCol + " /plan m <subcommand> ? - in depth help"
};
return Locale.get(Msg.CMD_HELP_MANAGE).toArray();
}
@Override
@ -51,7 +39,6 @@ public class ManageCommand extends TreeCommand<Plan> {
commands.add(new ManageHotswapCommand(plugin));
// commands.add(new ManageBackupCommand(plugin));
// commands.add(new ManageRestoreCommand(plugin));
commands.add(new ManageStatusCommand(plugin));
commands.add(new ManageImportCommand(plugin));
commands.add(new ManageRemoveCommand(plugin));
// commands.add(new ManageCleanCommand(plugin));

View File

@ -4,14 +4,14 @@ import com.djrapitops.plugin.api.TimeAmount;
import com.djrapitops.plugin.command.CommandType;
import com.djrapitops.plugin.command.ISender;
import com.djrapitops.plugin.command.SubCommand;
import com.djrapitops.plugin.settings.ColorScheme;
import com.djrapitops.plugin.task.AbsRunnable;
import main.java.com.djrapitops.plan.Log;
import main.java.com.djrapitops.plan.Permissions;
import main.java.com.djrapitops.plan.Phrase;
import main.java.com.djrapitops.plan.Plan;
import main.java.com.djrapitops.plan.command.ConditionUtils;
import main.java.com.djrapitops.plan.data.cache.AnalysisCacheHandler;
import main.java.com.djrapitops.plan.locale.Locale;
import main.java.com.djrapitops.plan.locale.Msg;
import main.java.com.djrapitops.plan.ui.text.TextUI;
import main.java.com.djrapitops.plan.utilities.Check;
import main.java.com.djrapitops.plan.utilities.MiscUtils;
@ -34,7 +34,10 @@ public class QuickAnalyzeCommand extends SubCommand {
* @param plugin Current instance of Plan
*/
public QuickAnalyzeCommand(Plan plugin) {
super("qanalyze, qanalyse, qanalysis, qa", CommandType.CONSOLE, Permissions.QUICK_ANALYZE.getPermission(), Phrase.CMD_USG_QANALYZE.parse());
super("qanalyze, qanalyse, qanalysis, qa",
CommandType.CONSOLE,
Permissions.QUICK_ANALYZE.getPermission(),
Locale.get(Msg.CMD_USG_QANALYZE).parse());
this.plugin = plugin;
analysisCache = plugin.getAnalysisCache();
@ -42,26 +45,15 @@ public class QuickAnalyzeCommand extends SubCommand {
@Override
public String[] addHelp() {
ColorScheme colorScheme = Plan.getInstance().getColorScheme();
String mCol = colorScheme.getMainColor();
String sCol = colorScheme.getSecondaryColor();
String tCol = colorScheme.getTertiaryColor();
return new String[]{
mCol + "Quick Analysis command",
tCol + " Used to get in game info about analysis.",
sCol + " Has less info than full Analysis web page.",
sCol + " Aliases: qanalyze, ganalyse, qanalysis, qa"
};
return Locale.get(Msg.CMD_HELP_PLAN).toArray();
}
@Override
public boolean onCommand(ISender sender, String commandLabel, String[] args) {
if (!Check.isTrue(ConditionUtils.pluginHasViewCapability(), Phrase.ERROR_WEBSERVER_OFF_ANALYSIS.toString(), sender)) {
if (!Check.isTrue(ConditionUtils.pluginHasViewCapability(), Locale.get(Msg.CMD_FAIL_NO_DATA_VIEW).toString(), sender)) {
return true;
}
if (!Check.isTrue(analysisCache.isAnalysisEnabled(), Phrase.ERROR_ANALYSIS_DISABLED_TEMPORARILY.toString(), sender)
if (!Check.isTrue(analysisCache.isAnalysisEnabled(), Locale.get(Msg.CMD_INFO_ANALYSIS_TEMP_DISABLE).toString(), sender)
&& !analysisCache.isCached()) {
return true;
}
@ -90,14 +82,14 @@ public class QuickAnalyzeCommand extends SubCommand {
public void run() {
timesRun++;
if (analysisCache.isCached() && (!analysisCache.isAnalysisBeingRun() || !analysisCache.isAnalysisEnabled())) {
sender.sendMessage(Phrase.CMD_ANALYZE_HEADER + "");
sender.sendMessage(Locale.get(Msg.CMD_HEADER_ANALYZE) + "");
sender.sendMessage(TextUI.getAnalysisMessages());
sender.sendMessage(Phrase.CMD_FOOTER + "");
sender.sendMessage(Locale.get(Msg.CMD_CONSTANT_FOOTER) + "");
this.cancel();
}
if (timesRun > 10) {
Log.debug("Command Timeout Message, QuickAnalyze.");
sender.sendMessage(Phrase.COMMAND_TIMEOUT.parse("Analysis"));
sender.sendMessage(Locale.get(Msg.CMD_FAIL_TIMEOUT).parse("Analysis"));
this.cancel();
}
}

View File

@ -4,15 +4,15 @@ import com.djrapitops.plugin.api.TimeAmount;
import com.djrapitops.plugin.command.CommandType;
import com.djrapitops.plugin.command.ISender;
import com.djrapitops.plugin.command.SubCommand;
import com.djrapitops.plugin.settings.ColorScheme;
import com.djrapitops.plugin.task.AbsRunnable;
import com.djrapitops.plugin.utilities.Verify;
import main.java.com.djrapitops.plan.Log;
import main.java.com.djrapitops.plan.Permissions;
import main.java.com.djrapitops.plan.Phrase;
import main.java.com.djrapitops.plan.Plan;
import main.java.com.djrapitops.plan.command.ConditionUtils;
import main.java.com.djrapitops.plan.data.cache.InspectCacheHandler;
import main.java.com.djrapitops.plan.locale.Locale;
import main.java.com.djrapitops.plan.locale.Msg;
import main.java.com.djrapitops.plan.ui.text.TextUI;
import main.java.com.djrapitops.plan.utilities.Check;
import main.java.com.djrapitops.plan.utilities.MiscUtils;
@ -38,7 +38,10 @@ public class QuickInspectCommand extends SubCommand {
* @param plugin Current instance of Plan
*/
public QuickInspectCommand(Plan plugin) {
super("qinspect, qi", CommandType.CONSOLE_WITH_ARGUMENTS, Permissions.QUICK_INSPECT.getPermission(), Phrase.CMD_USG_QINSPECT + "", Phrase.ARG_PLAYER + "");
super("qinspect, qi",
CommandType.CONSOLE_WITH_ARGUMENTS,
Permissions.QUICK_INSPECT.getPermission(),
Locale.get(Msg.CMD_USG_QINSPECT).toString(), "<player>");
this.plugin = plugin;
inspectCache = plugin.getInspectCache();
@ -47,18 +50,7 @@ public class QuickInspectCommand extends SubCommand {
@Override
public String[] addHelp() {
ColorScheme colorScheme = Plan.getInstance().getColorScheme();
String mCol = colorScheme.getMainColor();
String sCol = colorScheme.getSecondaryColor();
String tCol = colorScheme.getTertiaryColor();
return new String[]{
mCol + "Quick Inspect command",
tCol + " Used to get some inspect info in game.",
sCol + " Has less info than full Inspect web page.",
sCol + " Alias: /plan qi"
};
return Locale.get(Msg.CMD_HELP_QINSPECT).toArray();
}
@Override
@ -69,16 +61,16 @@ public class QuickInspectCommand extends SubCommand {
public void run() {
try {
UUID uuid = UUIDUtility.getUUIDOf(playerName);
if (!Check.isTrue(Verify.notNull(uuid), Phrase.USERNAME_NOT_VALID.toString(), sender)) {
if (!Check.isTrue(Verify.notNull(uuid), Locale.get(Msg.CMD_FAIL_USERNAME_NOT_VALID).toString(), sender)) {
return;
}
if (!Check.isTrue(ConditionUtils.playerHasPlayed(uuid), Phrase.USERNAME_NOT_SEEN.toString(), sender)) {
if (!Check.isTrue(ConditionUtils.playerHasPlayed(uuid), Locale.get(Msg.CMD_FAIL_USERNAME_NOT_SEEN).toString(), sender)) {
return;
}
if (!Check.isTrue(plugin.getDB().wasSeenBefore(uuid), Phrase.USERNAME_NOT_KNOWN.toString(), sender)) {
if (!Check.isTrue(plugin.getDB().wasSeenBefore(uuid), Locale.get(Msg.CMD_FAIL_USERNAME_NOT_KNOWN).toString(), sender)) {
return;
}
sender.sendMessage(Phrase.GRABBING_DATA_MESSAGE + "");
sender.sendMessage(Locale.get(Msg.CMD_INFO_FETCH_DATA).toString());
inspectCache.cache(uuid);
runMessageSenderTask(uuid, sender, playerName);
} finally {
@ -97,14 +89,14 @@ public class QuickInspectCommand extends SubCommand {
public void run() {
timesrun++;
if (inspectCache.isCached(uuid)) {
sender.sendMessage(Phrase.CMD_INSPECT_HEADER + playerName);
sender.sendMessage(Locale.get(Msg.CMD_HEADER_INSPECT) + playerName);
sender.sendMessage(TextUI.getInspectMessages(uuid));
sender.sendMessage(Phrase.CMD_FOOTER + "");
sender.sendMessage(Locale.get(Msg.CMD_CONSTANT_FOOTER) + "");
this.cancel();
}
if (timesrun > 10) {
Log.debug("Command Timeout Message, QuickInspect.");
sender.sendMessage(Phrase.COMMAND_TIMEOUT.parse("Qinspect"));
sender.sendMessage(Locale.get(Msg.CMD_FAIL_TIMEOUT).parse("Qinspect"));
this.cancel();
}
}

View File

@ -4,14 +4,14 @@ import com.djrapitops.plugin.command.CommandType;
import com.djrapitops.plugin.command.CommandUtils;
import com.djrapitops.plugin.command.ISender;
import com.djrapitops.plugin.command.SubCommand;
import com.djrapitops.plugin.settings.ColorScheme;
import com.djrapitops.plugin.task.AbsRunnable;
import main.java.com.djrapitops.plan.Log;
import main.java.com.djrapitops.plan.Permissions;
import main.java.com.djrapitops.plan.Phrase;
import main.java.com.djrapitops.plan.Plan;
import main.java.com.djrapitops.plan.data.WebUser;
import main.java.com.djrapitops.plan.database.tables.SecurityTable;
import main.java.com.djrapitops.plan.locale.Locale;
import main.java.com.djrapitops.plan.locale.Msg;
import main.java.com.djrapitops.plan.utilities.Check;
import main.java.com.djrapitops.plan.utilities.PassEncryptUtil;
import org.bukkit.ChatColor;
@ -33,30 +33,23 @@ public class RegisterCommand extends SubCommand {
private final Plan plugin;
public RegisterCommand(Plan plugin) {
super("register", CommandType.CONSOLE_WITH_ARGUMENTS, "", "Register a user for the webserver", "<password> [name] [access lvl]");
super("register",
CommandType.CONSOLE_WITH_ARGUMENTS,
"", // No Permission Requirement
Locale.get(Msg.CMD_USG_WEB_REGISTER).toString(),
"<password> [name] [access lvl]");
this.plugin = plugin;
}
@Override
public String[] addHelp() {
ColorScheme colorScheme = Plan.getInstance().getColorScheme();
String mCol = colorScheme.getMainColor();
String sCol = colorScheme.getSecondaryColor();
String tCol = colorScheme.getTertiaryColor();
return new String[]{
mCol + "Web Register command",
tCol + " Used to register a new user for the webserver.",
sCol + " Registering a user for another player requires " + Permissions.MANAGE_WEB.getPerm() + " permission.",
sCol + " Passwords are hashed with PBKDF2 (64,000 iterations of SHA1) using a cryptographically-random salt."
};
return Locale.get(Msg.CMD_HELP_WEB_REGISTER).toArray();
}
@Override
public boolean onCommand(ISender sender, String commandLabel, String[] args) {
String notEnoughArgsMsg = Phrase.COMMAND_REQUIRES_ARGUMENTS.parse("(3) " + super.getArguments());
String notEnoughArgsMsg = Locale.get(Msg.CMD_FAIL_REQ_ARGS).parse("(3) " + super.getArguments());
String hashErrorMsg = ChatColor.RED + "Password hash error.";
String permLvlErrorMsg = ChatColor.RED + "Incorrect perm level, not a number: ";
try {
@ -87,7 +80,7 @@ public class RegisterCommand extends SubCommand {
}
private void playerRegister(String[] args, ISender sender) throws PassEncryptUtil.CannotPerformOperationException {
final String notEnoughArgsMsg = Phrase.COMMAND_REQUIRES_ARGUMENTS.parse("(1 or 3) " + super.getArguments());
final String notEnoughArgsMsg = Locale.get(Msg.CMD_FAIL_REQ_ARGS).parse("(1 or 3) " + super.getArguments());
boolean registerSenderAsUser = args.length == 1;
if (registerSenderAsUser) {
String user = sender.getName();
@ -97,7 +90,7 @@ public class RegisterCommand extends SubCommand {
} else if (sender.hasPermission(Permissions.MANAGE_WEB.getPermission())) {
consoleRegister(args, sender, notEnoughArgsMsg);
} else {
sender.sendMessage(Phrase.COMMAND_NO_PERMISSION.parse());
sender.sendMessage(Locale.get(Msg.CMD_FAIL_NO_PERMISSION).parse());
}
}

View File

@ -4,8 +4,9 @@ import com.djrapitops.plugin.command.CommandType;
import com.djrapitops.plugin.command.ISender;
import com.djrapitops.plugin.command.SubCommand;
import main.java.com.djrapitops.plan.Permissions;
import main.java.com.djrapitops.plan.Phrase;
import main.java.com.djrapitops.plan.Plan;
import main.java.com.djrapitops.plan.locale.Locale;
import main.java.com.djrapitops.plan.locale.Msg;
/**
* This subcommand is used to reload the plugin.
@ -23,7 +24,10 @@ public class ReloadCommand extends SubCommand {
* @param plugin Current instance of Plan
*/
public ReloadCommand(Plan plugin) {
super("reload", CommandType.CONSOLE, Permissions.MANAGE.getPermission(), Phrase.CMD_USG_RELOAD.toString());
super("reload",
CommandType.CONSOLE,
Permissions.MANAGE.getPermission(),
Locale.get(Msg.CMD_USG_RELOAD).toString());
this.plugin = plugin;
}
@ -33,7 +37,7 @@ public class ReloadCommand extends SubCommand {
plugin.onDisable();
plugin.reloadConfig();
plugin.onEnable();
sender.sendMessage(Phrase.RELOAD_COMPLETE.toString());
sender.sendMessage(Locale.get(Msg.CMD_INFO_RELOAD_COMPLETE).toString());
return true;
}

View File

@ -3,12 +3,12 @@ package main.java.com.djrapitops.plan.command.commands;
import com.djrapitops.plugin.command.CommandType;
import com.djrapitops.plugin.command.ISender;
import com.djrapitops.plugin.command.SubCommand;
import com.djrapitops.plugin.settings.ColorScheme;
import com.djrapitops.plugin.task.AbsRunnable;
import com.djrapitops.plugin.utilities.FormattingUtils;
import main.java.com.djrapitops.plan.Permissions;
import main.java.com.djrapitops.plan.Phrase;
import main.java.com.djrapitops.plan.Plan;
import main.java.com.djrapitops.plan.locale.Locale;
import main.java.com.djrapitops.plan.locale.Msg;
import main.java.com.djrapitops.plan.utilities.Check;
import main.java.com.djrapitops.plan.utilities.MiscUtils;
@ -31,32 +31,26 @@ public class SearchCommand extends SubCommand {
* @param plugin Current instance of Plan
*/
public SearchCommand(Plan plugin) {
super("search", CommandType.CONSOLE_WITH_ARGUMENTS, Permissions.SEARCH.getPermission(), Phrase.CMD_USG_SEARCH.toString(), Phrase.ARG_SEARCH.toString());
super("search",
CommandType.CONSOLE_WITH_ARGUMENTS,
Permissions.SEARCH.getPermission(),
Locale.get(Msg.CMD_USG_SEARCH).toString(),
"<part of playername>");
this.plugin = plugin;
}
@Override
public String[] addHelp() {
ColorScheme colorScheme = Plan.getInstance().getColorScheme();
String mCol = colorScheme.getMainColor();
String sCol = colorScheme.getSecondaryColor();
String tCol = colorScheme.getTertiaryColor();
return new String[]{
mCol + "Search command",
tCol + " Used to get a list of Player names that match the given argument.",
sCol + " Example: /plan search 123 - Finds all users with 123 in their name."
};
return Locale.get(Msg.CMD_HELP_SEARCH).toArray();
}
@Override
public boolean onCommand(ISender sender, String commandLabel, String[] args) {
if (!Check.isTrue(args.length >= 1, Phrase.COMMAND_REQUIRES_ARGUMENTS_ONE.toString(), sender)) {
if (!Check.isTrue(args.length >= 1, Locale.get(Msg.CMD_FAIL_REQ_ONE_ARG).toString(), sender)) {
return true;
}
sender.sendMessage(Phrase.CMD_SEARCH_SEARCHING.toString());
sender.sendMessage(Locale.get(Msg.CMD_INFO_SEARCHING).toString());
runSearchTask(args, sender);
return true;
@ -68,15 +62,15 @@ public class SearchCommand extends SubCommand {
public void run() {
try {
List<String> names = MiscUtils.getMatchingPlayerNames(args[0]);
sender.sendMessage(Phrase.CMD_SEARCH_HEADER + args[0] + " (" + names.size() + ")");
sender.sendMessage(Locale.get(Msg.CMD_HEADER_SEARCH) + args[0] + " (" + names.size() + ")");
// Results
if (names.isEmpty()) {
sender.sendMessage(Phrase.CMD_NO_RESULTS.parse(Arrays.toString(args)));
sender.sendMessage(Locale.get(Msg.CMD_INFO_NO_RESULTS).parse(Arrays.toString(args)));
} else {
sender.sendMessage(Phrase.CMD_MATCH.toString() + FormattingUtils.collectionToStringNoBrackets(names));
sender.sendMessage(Locale.get(Msg.CMD_INFO_RESULTS).toString() + FormattingUtils.collectionToStringNoBrackets(names));
}
sender.sendMessage(Phrase.CMD_FOOTER.toString());
sender.sendMessage(Locale.get(Msg.CMD_CONSTANT_FOOTER).toString());
} finally {
this.cancel();
}

View File

@ -2,13 +2,14 @@ package main.java.com.djrapitops.plan.command.commands;
import com.djrapitops.plugin.command.CommandType;
import com.djrapitops.plugin.command.TreeCommand;
import com.djrapitops.plugin.settings.ColorScheme;
import main.java.com.djrapitops.plan.Permissions;
import main.java.com.djrapitops.plan.Plan;
import main.java.com.djrapitops.plan.command.commands.webuser.WebCheckCommand;
import main.java.com.djrapitops.plan.command.commands.webuser.WebDeleteCommand;
import main.java.com.djrapitops.plan.command.commands.webuser.WebLevelCommand;
import main.java.com.djrapitops.plan.command.commands.webuser.WebListUsersCommand;
import main.java.com.djrapitops.plan.locale.Locale;
import main.java.com.djrapitops.plan.locale.Msg;
/**
* Web subcommand used to manage Web users.
@ -19,28 +20,18 @@ import main.java.com.djrapitops.plan.command.commands.webuser.WebListUsersComman
public class WebUserCommand extends TreeCommand<Plan> {
public WebUserCommand(Plan plugin, RegisterCommand register) {
super(plugin, "webuser, web", CommandType.CONSOLE, Permissions.MANAGE_WEB.getPerm(), "Manage Webusers", "plan web");
super(plugin, "webuser, web",
CommandType.CONSOLE,
Permissions.MANAGE_WEB.getPerm(),
Locale.get(Msg.CMD_USG_WEB).toString(),
"plan web");
commands.add(register);
}
@Override
public String[] addHelp() {
ColorScheme colorScheme = Plan.getInstance().getColorScheme();
String mCol = colorScheme.getMainColor();
String sCol = colorScheme.getSecondaryColor();
String tCol = colorScheme.getTertiaryColor();
return new String[]{
mCol + "Web User Manage command",
tCol + " Used to manage web users of the plugin",
sCol + " Users have a permission level:",
tCol + " 0 - Access to all pages",
tCol + " 1 - Access to /players & all inspect pages",
tCol + " 2 - Access to own inspect page",
sCol + " Alias: /plan web"
};
return Locale.get(Msg.CMD_HELP_WEB).toArray();
}
@Override

View File

@ -7,9 +7,10 @@ import com.djrapitops.plugin.task.AbsRunnable;
import com.djrapitops.plugin.utilities.Verify;
import main.java.com.djrapitops.plan.Log;
import main.java.com.djrapitops.plan.Permissions;
import main.java.com.djrapitops.plan.Phrase;
import main.java.com.djrapitops.plan.Plan;
import main.java.com.djrapitops.plan.database.Database;
import main.java.com.djrapitops.plan.locale.Locale;
import main.java.com.djrapitops.plan.locale.Msg;
import main.java.com.djrapitops.plan.utilities.Check;
import main.java.com.djrapitops.plan.utilities.ManageUtils;
@ -29,7 +30,11 @@ public class ManageBackupCommand extends SubCommand {
* @param plugin Current instance of Plan
*/
public ManageBackupCommand(Plan plugin) {
super("backup", CommandType.CONSOLE, Permissions.MANAGE.getPermission(), Phrase.CMD_USG_MANAGE_BACKUP.toString(), "<DB>");
super("backup",
CommandType.CONSOLE,
Permissions.MANAGE.getPermission(),
Locale.get(Msg.CMD_USG_MANAGE_BACKUP).toString(),
"<DB>");
this.plugin = plugin;
}
@ -37,26 +42,26 @@ public class ManageBackupCommand extends SubCommand {
@Override
public boolean onCommand(ISender sender, String commandLabel, String[] args) {
try {
if (!Check.isTrue(args.length >= 1, Phrase.COMMAND_REQUIRES_ARGUMENTS.parse(Phrase.USE_BACKUP.toString()), sender)) {
if (!Check.isTrue(args.length >= 1, Locale.get(Msg.CMD_FAIL_REQ_ARGS).parse(this.getArguments()), sender)) {
return true;
}
String dbName = args[0].toLowerCase();
boolean isCorrectDB = "sqlite".equals(dbName) || "mysql".equals(dbName);
if (Check.isTrue(isCorrectDB, Phrase.MANAGE_ERROR_INCORRECT_DB + dbName, sender)) {
if (Check.isTrue(isCorrectDB, Locale.get(Msg.MANAGE_FAIL_INCORRECT_DB) + dbName, sender)) {
return true;
}
final Database database = ManageUtils.getDB(plugin, dbName);
// If DB is null return
if (!Check.isTrue(Verify.notNull(database), Phrase.MANAGE_DATABASE_FAILURE.toString(), sender)) {
if (!Check.isTrue(Verify.notNull(database), Locale.get(Msg.MANAGE_FAIL_FAULTY_DB).toString(), sender)) {
Log.error(dbName + " was null!");
return true;
}
runBackupTask(sender, args, database);
} catch (NullPointerException e) {
sender.sendMessage(Phrase.MANAGE_DATABASE_FAILURE.toString());
sender.sendMessage(Locale.get(Msg.MANAGE_FAIL_FAULTY_DB).toString());
}
return true;
}
@ -66,15 +71,15 @@ public class ManageBackupCommand extends SubCommand {
@Override
public void run() {
try {
sender.sendMessage(Phrase.MANAGE_PROCESS_START.parse());
sender.sendMessage(Locale.get(Msg.MANAGE_INFO_START).parse());
if (ManageUtils.backup(args[0], database)) {
sender.sendMessage(Phrase.MANAGE_COPY_SUCCESS.toString());
sender.sendMessage(Locale.get(Msg.MANAGE_INFO_COPY_SUCCESS).toString());
} else {
sender.sendMessage(Phrase.MANAGE_PROCESS_FAIL.toString());
sender.sendMessage(Locale.get(Msg.MANAGE_INFO_FAIL).toString());
}
} catch (Exception e) {
Log.toLog(this.getClass().getName() + " " + getTaskName(), e);
sender.sendMessage(Phrase.MANAGE_PROCESS_FAIL.toString());
sender.sendMessage(Locale.get(Msg.MANAGE_INFO_FAIL).toString());
} finally {
this.cancel();
}

View File

@ -7,9 +7,10 @@ import com.djrapitops.plugin.task.AbsRunnable;
import com.djrapitops.plugin.utilities.Verify;
import main.java.com.djrapitops.plan.Log;
import main.java.com.djrapitops.plan.Permissions;
import main.java.com.djrapitops.plan.Phrase;
import main.java.com.djrapitops.plan.Plan;
import main.java.com.djrapitops.plan.database.Database;
import main.java.com.djrapitops.plan.locale.Locale;
import main.java.com.djrapitops.plan.locale.Msg;
import main.java.com.djrapitops.plan.utilities.Check;
import main.java.com.djrapitops.plan.utilities.ManageUtils;
@ -29,28 +30,32 @@ public class ManageCleanCommand extends SubCommand {
* @param plugin Current instance of Plan
*/
public ManageCleanCommand(Plan plugin) {
super("clean", CommandType.CONSOLE_WITH_ARGUMENTS, Permissions.MANAGE.getPermission(), Phrase.CMD_USG_MANAGE_CLEAN.toString(), "<DB>");
super("clean",
CommandType.CONSOLE_WITH_ARGUMENTS,
Permissions.MANAGE.getPermission(),
Locale.get(Msg.CMD_USG_MANAGE_CLEAN).toString(),
"<DB>");
this.plugin = plugin;
}
@Override
public boolean onCommand(ISender sender, String commandLabel, String[] args) {
if (!Check.isTrue(args.length != 0, Phrase.COMMAND_REQUIRES_ARGUMENTS_ONE.toString(), sender)) {
if (!Check.isTrue(args.length != 0, Locale.get(Msg.CMD_FAIL_REQ_ONE_ARG).toString(), sender)) {
return true;
}
String dbName = args[0].toLowerCase();
boolean isCorrectDB = "sqlite".equals(dbName) || "mysql".equals(dbName);
if (!Check.isTrue(isCorrectDB, Phrase.MANAGE_ERROR_INCORRECT_DB + dbName, sender)) {
if (!Check.isTrue(isCorrectDB, Locale.get(Msg.MANAGE_FAIL_INCORRECT_DB) + dbName, sender)) {
return true;
}
final Database database = ManageUtils.getDB(plugin, dbName);
// If DB is null return
if (!Check.isTrue(Verify.notNull(database), Phrase.MANAGE_DATABASE_FAILURE.toString(), sender)) {
if (!Check.isTrue(Verify.notNull(database), Locale.get(Msg.MANAGE_FAIL_FAULTY_DB).toString(), sender)) {
Log.error(dbName + " was null!");
return true;
}
@ -63,9 +68,9 @@ public class ManageCleanCommand extends SubCommand {
plugin.getRunnableFactory().createNew(new AbsRunnable("DBCleanTask") {
@Override
public void run() {
sender.sendMessage(Phrase.MANAGE_PROCESS_START.parse());
sender.sendMessage(Locale.get(Msg.MANAGE_INFO_START).parse());
database.clean();
sender.sendMessage(Phrase.MANAGE_SUCCESS.toString());
sender.sendMessage(Locale.get(Msg.MANAGE_INFO_SUCCESS).toString());
this.cancel();
}
}).runTaskAsynchronously();

View File

@ -3,14 +3,14 @@ package main.java.com.djrapitops.plan.command.commands.manage;
import com.djrapitops.plugin.command.CommandType;
import com.djrapitops.plugin.command.ISender;
import com.djrapitops.plugin.command.SubCommand;
import com.djrapitops.plugin.settings.ColorScheme;
import com.djrapitops.plugin.task.AbsRunnable;
import com.djrapitops.plugin.utilities.Verify;
import main.java.com.djrapitops.plan.Log;
import main.java.com.djrapitops.plan.Permissions;
import main.java.com.djrapitops.plan.Phrase;
import main.java.com.djrapitops.plan.Plan;
import main.java.com.djrapitops.plan.database.Database;
import main.java.com.djrapitops.plan.locale.Locale;
import main.java.com.djrapitops.plan.locale.Msg;
import main.java.com.djrapitops.plan.utilities.Check;
import main.java.com.djrapitops.plan.utilities.ManageUtils;
@ -30,7 +30,11 @@ public class ManageClearCommand extends SubCommand {
* @param plugin Current instance of Plan
*/
public ManageClearCommand(Plan plugin) {
super("clear", CommandType.CONSOLE_WITH_ARGUMENTS, Permissions.MANAGE.getPermission(), Phrase.CMD_USG_MANAGE_CLEAR.toString(), "<DB> [-a]");
super("clear",
CommandType.CONSOLE_WITH_ARGUMENTS,
Permissions.MANAGE.getPermission(),
Locale.get(Msg.CMD_USG_MANAGE_CLEAR).toString(),
"<DB> [-a]");
this.plugin = plugin;
@ -38,41 +42,30 @@ public class ManageClearCommand extends SubCommand {
@Override
public String[] addHelp() {
ColorScheme colorScheme = Plan.getInstance().getColorScheme();
String mCol = colorScheme.getMainColor();
String sCol = colorScheme.getSecondaryColor();
String tCol = colorScheme.getTertiaryColor();
return new String[]{
mCol + "Manage Clear command",
tCol + " Used to delete ALL data in the active database.",
sCol + " Plugin should be reloaded after successful clear.",
sCol + " Alias: /plan pl"
};
return Locale.get(Msg.CMD_HELP_MANAGE_CLEAR).toArray();
}
@Override
public boolean onCommand(ISender sender, String commandLabel, String[] args) {
if (!Check.isTrue(args.length >= 1, Phrase.COMMAND_REQUIRES_ARGUMENTS_ONE.toString(), sender)) {
if (!Check.isTrue(args.length >= 1, Locale.get(Msg.CMD_FAIL_REQ_ONE_ARG).toString(), sender)) {
return true;
}
String dbName = args[0].toLowerCase();
boolean isCorrectDB = "sqlite".equals(dbName) || "mysql".equals(dbName);
if (!Check.isTrue(isCorrectDB, Phrase.MANAGE_ERROR_INCORRECT_DB + dbName, sender)) {
if (!Check.isTrue(isCorrectDB, Locale.get(Msg.MANAGE_FAIL_INCORRECT_DB) + dbName, sender)) {
return true;
}
if (!Check.isTrue(Verify.contains("-a", args), Phrase.COMMAND_ADD_CONFIRMATION_ARGUMENT.parse(Phrase.WARN_REMOVE.parse(args[0])), sender)) {
if (!Check.isTrue(Verify.contains("-a", args), Locale.get(Msg.MANAGE_FAIL_CONFIRM).parse(Locale.get(Msg.MANAGE_NOTIFY_REMOVE).parse(args[0])), sender)) {
return true;
}
final Database database = ManageUtils.getDB(plugin, dbName);
// If DB is null return
if (!Check.isTrue(Verify.notNull(database), Phrase.MANAGE_DATABASE_FAILURE.toString(), sender)) {
if (!Check.isTrue(Verify.notNull(database), Locale.get(Msg.MANAGE_FAIL_FAULTY_DB).toString(), sender)) {
Log.error(dbName + " was null!");
return true;
}
@ -86,13 +79,13 @@ public class ManageClearCommand extends SubCommand {
@Override
public void run() {
try {
sender.sendMessage(Phrase.MANAGE_PROCESS_START.parse());
sender.sendMessage(Locale.get(Msg.MANAGE_INFO_START).parse());
if (database.removeAllData()) {
plugin.getHandler().getDataCache().clear();
sender.sendMessage(Phrase.MANAGE_CLEAR_SUCCESS.toString());
sender.sendMessage(Locale.get(Msg.MANAGE_INFO_CLEAR_SUCCESS).toString());
} else {
sender.sendMessage(Phrase.MANAGE_PROCESS_FAIL.toString());
sender.sendMessage(Locale.get(Msg.MANAGE_INFO_FAIL).toString());
}
} finally {
this.cancel();

View File

@ -3,16 +3,16 @@ package main.java.com.djrapitops.plan.command.commands.manage;
import com.djrapitops.plugin.command.CommandType;
import com.djrapitops.plugin.command.ISender;
import com.djrapitops.plugin.command.SubCommand;
import com.djrapitops.plugin.settings.ColorScheme;
import com.djrapitops.plugin.task.AbsRunnable;
import main.java.com.djrapitops.plan.Permissions;
import main.java.com.djrapitops.plan.Phrase;
import main.java.com.djrapitops.plan.Plan;
import main.java.com.djrapitops.plan.utilities.dump.DumpUtils;
import main.java.com.djrapitops.plan.locale.Locale;
import main.java.com.djrapitops.plan.locale.Msg;
import main.java.com.djrapitops.plan.utilities.file.dump.DumpUtils;
/**
* This manage subcommand is used to dump important data to pastebin,
* so it's easier to write an issue.
* This manage subcommand is used to dump important data to pastebin, so it's
* easier to write an issue.
*
* @author Fuzzlemann
* @since 3.7.0
@ -27,22 +27,17 @@ public class ManageDumpCommand extends SubCommand {
* @param plugin Current instance of Plan
*/
public ManageDumpCommand(Plan plugin) {
super("dump", CommandType.CONSOLE, Permissions.MANAGE.getPermission(), Phrase.CMD_USG_MANAGE_CLEAR.toString());
super("dump",
CommandType.CONSOLE,
Permissions.MANAGE.getPermission(),
Locale.get(Msg.CMD_USG_MANAGE_DUMP).toString());
this.plugin = plugin;
}
@Override
public String[] addHelp() {
ColorScheme colorScheme = plugin.getColorScheme();
String mCol = colorScheme.getMainColor();
String tCol = colorScheme.getTertiaryColor();
return new String[]{
mCol + "Manage Dump command",
tCol + " Used to dump important data for bug reporting to hastebin.",
};
return Locale.get(Msg.CMD_HELP_MANAGE_DUMP).toArray();
}
@Override

View File

@ -3,13 +3,13 @@ package main.java.com.djrapitops.plan.command.commands.manage;
import com.djrapitops.plugin.command.CommandType;
import com.djrapitops.plugin.command.ISender;
import com.djrapitops.plugin.command.SubCommand;
import com.djrapitops.plugin.settings.ColorScheme;
import com.djrapitops.plugin.utilities.Verify;
import main.java.com.djrapitops.plan.Log;
import main.java.com.djrapitops.plan.Permissions;
import main.java.com.djrapitops.plan.Phrase;
import main.java.com.djrapitops.plan.Plan;
import main.java.com.djrapitops.plan.database.Database;
import main.java.com.djrapitops.plan.locale.Locale;
import main.java.com.djrapitops.plan.locale.Msg;
import main.java.com.djrapitops.plan.utilities.Check;
import main.java.com.djrapitops.plan.utilities.ManageUtils;
@ -30,7 +30,11 @@ public class ManageHotswapCommand extends SubCommand {
* @param plugin Current instance of Plan
*/
public ManageHotswapCommand(Plan plugin) {
super("hotswap", CommandType.CONSOLE_WITH_ARGUMENTS, Permissions.MANAGE.getPermission(), Phrase.CMD_USG_MANAGE_HOTSWAP.toString(), "<DB>");
super("hotswap",
CommandType.CONSOLE_WITH_ARGUMENTS,
Permissions.MANAGE.getPermission(),
Locale.get(Msg.CMD_USG_MANAGE_HOTSWAP).toString(),
"<DB>");
this.plugin = plugin;
@ -38,39 +42,29 @@ public class ManageHotswapCommand extends SubCommand {
@Override
public String[] addHelp() {
ColorScheme colorScheme = Plan.getInstance().getColorScheme();
String mCol = colorScheme.getMainColor();
String sCol = colorScheme.getSecondaryColor();
String tCol = colorScheme.getTertiaryColor();
return new String[]{
mCol + "Manage Hotswap command",
tCol + " Used to change database in use on the fly.",
sCol + " Does not change database if connection fails"
};
return Locale.get(Msg.CMD_HELP_MANAGE_HOTSWAP).toArray();
}
@Override
public boolean onCommand(ISender sender, String commandLabel, String[] args) {
if (!Check.isTrue(args.length >= 1, Phrase.COMMAND_REQUIRES_ARGUMENTS_ONE.toString(), sender)) {
if (!Check.isTrue(args.length >= 1, Locale.get(Msg.CMD_FAIL_REQ_ONE_ARG).toString(), sender)) {
return true;
}
String dbName = args[0].toLowerCase();
boolean isCorrectDB = "sqlite".equals(dbName) || "mysql".equals(dbName);
if (!Check.isTrue(isCorrectDB, Phrase.MANAGE_ERROR_INCORRECT_DB + dbName, sender)) {
if (!Check.isTrue(isCorrectDB, Locale.get(Msg.MANAGE_FAIL_INCORRECT_DB) + dbName, sender)) {
return true;
}
if (Check.isTrue(dbName.equals(plugin.getDB().getConfigName()), Phrase.MANAGE_ERROR_SAME_DB.toString(), sender)) {
if (Check.isTrue(dbName.equals(plugin.getDB().getConfigName()), Locale.get(Msg.MANAGE_FAIL_SAME_DB).toString(), sender)) {
return true;
}
final Database database = ManageUtils.getDB(plugin, dbName);
// If DB is null return
if (!Check.isTrue(Verify.notNull(database), Phrase.MANAGE_DATABASE_FAILURE.toString(), sender)) {
if (!Check.isTrue(Verify.notNull(database), Locale.get(Msg.MANAGE_FAIL_FAULTY_DB).toString(), sender)) {
Log.error(dbName + " was null!");
return true;
}
@ -79,7 +73,7 @@ public class ManageHotswapCommand extends SubCommand {
database.getVersion(); //Test db connection
} catch (Exception e) {
Log.toLog(this.getClass().getName(), e);
sender.sendMessage(Phrase.MANAGE_DATABASE_FAILURE.toString());
sender.sendMessage(Locale.get(Msg.MANAGE_FAIL_FAULTY_DB).toString());
return true;
}

View File

@ -3,16 +3,16 @@ package main.java.com.djrapitops.plan.command.commands.manage;
import com.djrapitops.plugin.command.CommandType;
import com.djrapitops.plugin.command.ISender;
import com.djrapitops.plugin.command.SubCommand;
import com.djrapitops.plugin.settings.ColorScheme;
import com.djrapitops.plugin.task.AbsRunnable;
import com.djrapitops.plugin.utilities.FormattingUtils;
import com.djrapitops.plugin.utilities.player.Fetch;
import com.djrapitops.plugin.utilities.player.IOfflinePlayer;
import main.java.com.djrapitops.plan.Permissions;
import main.java.com.djrapitops.plan.Phrase;
import main.java.com.djrapitops.plan.Plan;
import main.java.com.djrapitops.plan.data.handling.importing.ImportUtils;
import main.java.com.djrapitops.plan.data.handling.importing.Importer;
import main.java.com.djrapitops.plan.locale.Locale;
import main.java.com.djrapitops.plan.locale.Msg;
import main.java.com.djrapitops.plan.utilities.Check;
import java.util.List;
@ -38,7 +38,11 @@ public class ManageImportCommand extends SubCommand {
* @param plugin Current instance of Plan
*/
public ManageImportCommand(Plan plugin) {
super("import", CommandType.CONSOLE, Permissions.MANAGE.getPermission(), Phrase.CMD_USG_MANAGE_IMPORT.toString(), Phrase.ARG_IMPORT.toString());
super("import",
CommandType.CONSOLE,
Permissions.MANAGE.getPermission(),
Locale.get(Msg.CMD_USG_MANAGE_IMPORT).toString(),
"<plugin>/list [import args]");
this.plugin = plugin;
@ -46,23 +50,12 @@ public class ManageImportCommand extends SubCommand {
@Override
public String[] addHelp() {
ColorScheme colorScheme = Plan.getInstance().getColorScheme();
String mCol = colorScheme.getMainColor();
String sCol = colorScheme.getSecondaryColor();
String tCol = colorScheme.getTertiaryColor();
return new String[]{
mCol + "Manage Import command",
tCol + "Used to import data from other sources",
sCol + " Analysis will be disabled during import.",
sCol + " If a lot of users are not in the database, saving may take a long time."
};
return Locale.get(Msg.CMD_HELP_MANAGE_IMPORT).toArray();
}
@Override
public boolean onCommand(ISender sender, String commandLabel, String[] args) {
if (!Check.isTrue(args.length >= 1, Phrase.COMMAND_REQUIRES_ARGUMENTS_ONE + " " + Phrase.USE_IMPORT, sender)) {
if (!Check.isTrue(args.length >= 1, Locale.get(Msg.CMD_FAIL_REQ_ONE_ARG) + " " + this.getArguments(), sender)) {
return true;
}
@ -74,11 +67,11 @@ public class ManageImportCommand extends SubCommand {
return true;
}
if (!Check.isTrue(importPlugins.keySet().contains(importFromPlugin), Phrase.MANAGE_ERROR_INCORRECT_PLUGIN + importFromPlugin, sender)) {
if (!Check.isTrue(importPlugins.keySet().contains(importFromPlugin), Locale.get(Msg.MANAGE_FAIL_INCORRECT_PLUGIN) + importFromPlugin, sender)) {
return true;
}
if (!Check.isTrue(ImportUtils.isPluginEnabled(importFromPlugin), Phrase.MANAGE_ERROR_PLUGIN_NOT_ENABLED + importFromPlugin, sender)) {
if (!Check.isTrue(ImportUtils.isPluginEnabled(importFromPlugin), Locale.get(Msg.MANAGE_FAIL_PLUGIN_NOT_ENABLED) + importFromPlugin, sender)) {
return true;
}
@ -94,12 +87,12 @@ public class ManageImportCommand extends SubCommand {
@Override
public void run() {
try {
sender.sendMessage(Phrase.MANAGE_IMPORTING.toString());
sender.sendMessage(Locale.get(Msg.MANAGE_INFO_IMPORT).toString());
List<UUID> uuids = Fetch.getIOfflinePlayers().stream().map(IOfflinePlayer::getUniqueId).collect(Collectors.toList());
if (importer.importData(uuids, importArguments)) {
sender.sendMessage(Phrase.MANAGE_SUCCESS.toString());
sender.sendMessage(Locale.get(Msg.MANAGE_INFO_SUCCESS).toString());
} else {
sender.sendMessage(Phrase.MANAGE_PROCESS_FAIL.toString());
sender.sendMessage(Locale.get(Msg.MANAGE_INFO_FAIL).toString());
}
} finally {
this.cancel();
@ -109,8 +102,8 @@ public class ManageImportCommand extends SubCommand {
}
private void list(Map<String, Importer> importers, ISender sender) {
sender.sendMessage(Phrase.CMD_FOOTER.parse());
importers.forEach((string, importer) -> sender.sendMessage(Phrase.CMD_BALL + " " + string + ": " + importer.getInfo()));
sender.sendMessage(Phrase.CMD_FOOTER.parse());
sender.sendMessage(Locale.get(Msg.CMD_CONSTANT_FOOTER).parse());
importers.forEach((string, importer) -> sender.sendMessage(Locale.get(Msg.CMD_CONSTANT_LIST_BALL) + " " + string + ": " + importer.getInfo()));
sender.sendMessage(Locale.get(Msg.CMD_CONSTANT_FOOTER).parse());
}
}

View File

@ -7,9 +7,10 @@ import com.djrapitops.plugin.task.AbsRunnable;
import com.djrapitops.plugin.utilities.Verify;
import main.java.com.djrapitops.plan.Log;
import main.java.com.djrapitops.plan.Permissions;
import main.java.com.djrapitops.plan.Phrase;
import main.java.com.djrapitops.plan.Plan;
import main.java.com.djrapitops.plan.database.Database;
import main.java.com.djrapitops.plan.locale.Locale;
import main.java.com.djrapitops.plan.locale.Msg;
import main.java.com.djrapitops.plan.utilities.Check;
import main.java.com.djrapitops.plan.utilities.ManageUtils;
@ -34,49 +35,53 @@ public class ManageMoveCommand extends SubCommand {
* @param plugin Current instance of Plan
*/
public ManageMoveCommand(Plan plugin) {
super("move", CommandType.CONSOLE_WITH_ARGUMENTS, Permissions.MANAGE.getPermission(), Phrase.CMD_USG_MANAGE_MOVE.toString(), Phrase.ARG_MOVE.toString());
super("move",
CommandType.CONSOLE_WITH_ARGUMENTS,
Permissions.MANAGE.getPermission(),
Locale.get(Msg.CMD_USG_MANAGE_MOVE).toString(),
"<fromDB> <toDB> [-a]");
this.plugin = plugin;
}
@Override
public boolean onCommand(ISender sender, String commandLabel, String[] args) {
if (!Check.isTrue(args.length >= 2, Phrase.COMMAND_REQUIRES_ARGUMENTS.parse(Phrase.USE_MOVE.toString()), sender)) {
if (!Check.isTrue(args.length >= 2, Locale.get(Msg.CMD_FAIL_REQ_ARGS).parse(this.getArguments()), sender)) {
return true;
}
String fromDB = args[0].toLowerCase();
boolean isCorrectDB = "sqlite".equals(fromDB) || "mysql".equals(fromDB);
if (!Check.isTrue(isCorrectDB, Phrase.MANAGE_ERROR_INCORRECT_DB + fromDB, sender)) {
if (!Check.isTrue(isCorrectDB, Locale.get(Msg.MANAGE_FAIL_INCORRECT_DB) + fromDB, sender)) {
return true;
}
String toDB = args[1].toLowerCase();
isCorrectDB = "sqlite".equals(toDB) || "mysql".equals(toDB);
if (!Check.isTrue(isCorrectDB, Phrase.MANAGE_ERROR_INCORRECT_DB + toDB, sender)) {
if (!Check.isTrue(isCorrectDB, Locale.get(Msg.MANAGE_FAIL_INCORRECT_DB) + toDB, sender)) {
return true;
}
if (!Check.isTrue(!Verify.equalsIgnoreCase(fromDB, toDB), Phrase.MANAGE_ERROR_SAME_DB.toString(), sender)) {
if (!Check.isTrue(!Verify.equalsIgnoreCase(fromDB, toDB), Locale.get(Msg.MANAGE_FAIL_SAME_DB).toString(), sender)) {
return true;
}
if (!Check.isTrue(Verify.contains("-a", args), Phrase.COMMAND_ADD_CONFIRMATION_ARGUMENT.parse(Phrase.WARN_REMOVE.parse(args[1])), sender)) {
if (!Check.isTrue(Verify.contains("-a", args), Locale.get(Msg.MANAGE_FAIL_CONFIRM).parse(Locale.get(Msg.MANAGE_NOTIFY_REMOVE).parse(args[1])), sender)) {
return true;
}
final Database fromDatabase = ManageUtils.getDB(plugin, fromDB);
if (!Check.isTrue(Verify.notNull(fromDatabase), Phrase.MANAGE_DATABASE_FAILURE.toString(), sender)) {
if (!Check.isTrue(Verify.notNull(fromDatabase), Locale.get(Msg.MANAGE_FAIL_FAULTY_DB).toString(), sender)) {
Log.error(fromDB + " was null!");
return true;
}
final Database toDatabase = ManageUtils.getDB(plugin, toDB);
if (!Check.isTrue(Verify.notNull(toDatabase), Phrase.MANAGE_DATABASE_FAILURE.toString(), sender)) {
if (!Check.isTrue(Verify.notNull(toDatabase), Locale.get(Msg.MANAGE_FAIL_FAULTY_DB).toString(), sender)) {
Log.error(toDB + " was null!");
return true;
}
@ -91,23 +96,23 @@ public class ManageMoveCommand extends SubCommand {
public void run() {
try {
final Collection<UUID> uuids = ManageUtils.getUUIDS(fromDatabase);
if (Check.isTrue(Verify.isEmpty(uuids), Phrase.MANAGE_ERROR_NO_PLAYERS + " (" + fromDatabase.getName() + ")", sender)) {
if (Check.isTrue(Verify.isEmpty(uuids), Locale.get(Msg.MANAGE_FAIL_NO_PLAYERS) + " (" + fromDatabase.getName() + ")", sender)) {
return;
}
sender.sendMessage(Phrase.MANAGE_PROCESS_START.parse());
sender.sendMessage(Locale.get(Msg.MANAGE_INFO_START).parse());
if (ManageUtils.clearAndCopy(toDatabase, fromDatabase, uuids)) {
sender.sendMessage(Phrase.MANAGE_MOVE_SUCCESS.toString());
sender.sendMessage(Locale.get(Msg.MANAGE_INFO_MOVE_SUCCESS).toString());
boolean movedToCurrentDatabase = Verify.equalsIgnoreCase(toDatabase.getConfigName(), plugin.getDB().getConfigName());
Check.isTrue(!movedToCurrentDatabase, Phrase.MANAGE_DB_CONFIG_REMINDER.toString(), sender);
Check.isTrue(!movedToCurrentDatabase, Locale.get(Msg.MANAGE_INFO_CONFIG_REMINDER).toString(), sender);
} else {
sender.sendMessage(Phrase.MANAGE_PROCESS_FAIL.toString());
sender.sendMessage(Locale.get(Msg.MANAGE_INFO_FAIL).toString());
}
} catch (Exception e) {
Log.toLog(this.getClass().getName() + " " + getTaskName(), e);
sender.sendMessage(Phrase.MANAGE_PROCESS_FAIL.toString());
sender.sendMessage(Locale.get(Msg.MANAGE_INFO_FAIL).toString());
} finally {
this.cancel();
}

View File

@ -3,13 +3,13 @@ package main.java.com.djrapitops.plan.command.commands.manage;
import com.djrapitops.plugin.command.CommandType;
import com.djrapitops.plugin.command.ISender;
import com.djrapitops.plugin.command.SubCommand;
import com.djrapitops.plugin.settings.ColorScheme;
import com.djrapitops.plugin.task.AbsRunnable;
import com.djrapitops.plugin.utilities.Verify;
import main.java.com.djrapitops.plan.Log;
import main.java.com.djrapitops.plan.Permissions;
import main.java.com.djrapitops.plan.Phrase;
import main.java.com.djrapitops.plan.Plan;
import main.java.com.djrapitops.plan.locale.Locale;
import main.java.com.djrapitops.plan.locale.Msg;
import main.java.com.djrapitops.plan.utilities.Check;
import main.java.com.djrapitops.plan.utilities.MiscUtils;
import main.java.com.djrapitops.plan.utilities.uuid.UUIDUtility;
@ -33,7 +33,11 @@ public class ManageRemoveCommand extends SubCommand {
* @param plugin Current instance of Plan
*/
public ManageRemoveCommand(Plan plugin) {
super("remove", CommandType.CONSOLE_WITH_ARGUMENTS, Permissions.MANAGE.getPermission(), Phrase.CMD_USG_MANAGE_REMOVE.toString(), Phrase.ARG_PLAYER + " [-a]");
super("remove",
CommandType.CONSOLE_WITH_ARGUMENTS,
Permissions.MANAGE.getPermission(),
Locale.get(Msg.CMD_USG_MANAGE_REMOVE).toString(),
"<player> [-a]");
this.plugin = plugin;
@ -41,20 +45,12 @@ public class ManageRemoveCommand extends SubCommand {
@Override
public String[] addHelp() {
ColorScheme colorScheme = Plan.getInstance().getColorScheme();
String mCol = colorScheme.getMainColor();
String tCol = colorScheme.getTertiaryColor();
return new String[]{
mCol + "Manage Remove command",
tCol + " Used to Remove user's data from the active database."
};
return Locale.get(Msg.CMD_HELP_MANAGE_REMOVE).toArray();
}
@Override
public boolean onCommand(ISender sender, String commandLabel, String[] args) {
if (!Check.isTrue(args.length >= 1, Phrase.COMMAND_REQUIRES_ARGUMENTS_ONE.toString(), sender)) {
if (!Check.isTrue(args.length >= 1, Locale.get(Msg.CMD_FAIL_REQ_ONE_ARG).toString(), sender)) {
return true;
}
@ -70,33 +66,33 @@ public class ManageRemoveCommand extends SubCommand {
public void run() {
try {
UUID uuid = UUIDUtility.getUUIDOf(playerName);
String message = Phrase.USERNAME_NOT_VALID.toString();
String message = Locale.get(Msg.CMD_FAIL_USERNAME_NOT_VALID).toString();
if (!Check.isTrue(Verify.notNull(uuid), message, sender)) {
return;
}
message = Phrase.USERNAME_NOT_KNOWN.toString();
message = Locale.get(Msg.CMD_FAIL_USERNAME_NOT_KNOWN).toString();
if (!Check.isTrue(plugin.getDB().wasSeenBefore(uuid), message, sender)) {
return;
}
message = Phrase.COMMAND_ADD_CONFIRMATION_ARGUMENT.parse(Phrase.WARN_REMOVE.parse(plugin.getDB().getConfigName()));
message = Locale.get(Msg.MANAGE_FAIL_CONFIRM).parse(Locale.get(Msg.MANAGE_NOTIFY_REMOVE).parse(plugin.getDB().getConfigName()));
if (!Check.isTrue(Verify.contains("-a", args), message, sender)) {
return;
}
sender.sendMessage(Phrase.MANAGE_PROCESS_START.parse());
sender.sendMessage(Locale.get(Msg.MANAGE_INFO_START).parse());
try {
plugin.getHandler().getDataCache().remove(uuid);
if (plugin.getDB().removeAccount(uuid.toString())) {
sender.sendMessage(Phrase.MANAGE_REMOVE_SUCCESS.parse(playerName, plugin.getDB().getConfigName()));
sender.sendMessage(Locale.get(Msg.MANAGE_INFO_REMOVE_SUCCESS).parse(playerName, plugin.getDB().getConfigName()));
} else {
sender.sendMessage(Phrase.MANAGE_PROCESS_FAIL.toString());
sender.sendMessage(Locale.get(Msg.MANAGE_INFO_FAIL).toString());
}
} catch (SQLException e) {
Log.toLog(this.getClass().getName(), e);
sender.sendMessage(Phrase.MANAGE_PROCESS_FAIL.toString());
sender.sendMessage(Locale.get(Msg.MANAGE_INFO_FAIL).toString());
}
} finally {
this.cancel();

View File

@ -7,10 +7,11 @@ import com.djrapitops.plugin.task.AbsRunnable;
import com.djrapitops.plugin.utilities.Verify;
import main.java.com.djrapitops.plan.Log;
import main.java.com.djrapitops.plan.Permissions;
import main.java.com.djrapitops.plan.Phrase;
import main.java.com.djrapitops.plan.Plan;
import main.java.com.djrapitops.plan.database.Database;
import main.java.com.djrapitops.plan.database.databases.SQLiteDB;
import main.java.com.djrapitops.plan.locale.Locale;
import main.java.com.djrapitops.plan.locale.Msg;
import main.java.com.djrapitops.plan.utilities.Check;
import main.java.com.djrapitops.plan.utilities.ManageUtils;
@ -34,31 +35,35 @@ public class ManageRestoreCommand extends SubCommand {
* @param plugin Current instance of Plan
*/
public ManageRestoreCommand(Plan plugin) {
super("restore", CommandType.CONSOLE, Permissions.MANAGE.getPermission(), Phrase.CMD_USG_MANAGE_RESTORE.toString(), Phrase.ARG_RESTORE.toString());
super("restore",
CommandType.CONSOLE,
Permissions.MANAGE.getPermission(),
Locale.get(Msg.CMD_USG_MANAGE_RESTORE).toString(),
"<Filename.db> <dbTo> [-a]");
this.plugin = plugin;
}
@Override
public boolean onCommand(ISender sender, String commandLabel, String[] args) {
if (!Check.isTrue(args.length >= 2, Phrase.COMMAND_REQUIRES_ARGUMENTS.parse(Phrase.USE_RESTORE.toString()), sender)) {
if (!Check.isTrue(args.length >= 2, Locale.get(Msg.CMD_FAIL_REQ_ARGS).parse(this.getArguments()), sender)) {
return true;
}
String db = args[1].toLowerCase();
boolean isCorrectDB = "sqlite".equals(db) || "mysql".equals(db);
if (!Check.isTrue(isCorrectDB, Phrase.MANAGE_ERROR_INCORRECT_DB + db, sender)) {
if (!Check.isTrue(isCorrectDB, Locale.get(Msg.MANAGE_FAIL_INCORRECT_DB) + db, sender)) {
return true;
}
if (!Check.isTrue(Verify.contains("-a", args), Phrase.COMMAND_ADD_CONFIRMATION_ARGUMENT.parse(Phrase.WARN_REWRITE.parse(args[1])), sender)) {
if (!Check.isTrue(Verify.contains("-a", args), Locale.get(Msg.MANAGE_FAIL_CONFIRM).parse(Locale.get(Msg.MANAGE_NOTIFY_REWRITE).parse(args[1])), sender)) {
return true;
}
final Database database = ManageUtils.getDB(plugin, db);
if (!Check.isTrue(Verify.notNull(database), Phrase.MANAGE_DATABASE_FAILURE.toString(), sender)) {
if (!Check.isTrue(Verify.notNull(database), Locale.get(Msg.MANAGE_FAIL_FAULTY_DB).toString(), sender)) {
Log.error(db + " was null!");
return true;
}
@ -76,7 +81,7 @@ public class ManageRestoreCommand extends SubCommand {
boolean containsDBFileExtension = backupDBName.endsWith(".db");
File backupDBFile = new File(plugin.getDataFolder(), backupDBName + (containsDBFileExtension ? "" : ".db"));
if (!Check.isTrue(Verify.exists(backupDBFile), Phrase.MANAGE_ERROR_BACKUP_FILE_NOT_FOUND + " " + args[0], sender)) {
if (!Check.isTrue(Verify.exists(backupDBFile), Locale.get(Msg.MANAGE_FAIL_FILE_NOT_FOUND) + " " + args[0], sender)) {
return;
}
@ -86,14 +91,14 @@ public class ManageRestoreCommand extends SubCommand {
SQLiteDB backupDB = new SQLiteDB(plugin, backupDBName);
if (!backupDB.init()) {
sender.sendMessage(Phrase.MANAGE_DATABASE_FAILURE.toString());
sender.sendMessage(Locale.get(Msg.MANAGE_FAIL_FAULTY_DB).toString());
return;
}
sender.sendMessage(Phrase.MANAGE_PROCESS_START.parse());
sender.sendMessage(Locale.get(Msg.MANAGE_INFO_START).parse());
final Collection<UUID> uuids = ManageUtils.getUUIDS(backupDB);
if (!Check.isTrue(!Verify.isEmpty(uuids), Phrase.MANAGE_ERROR_NO_PLAYERS + " (" + backupDBName + ")", sender)) {
if (!Check.isTrue(!Verify.isEmpty(uuids), Locale.get(Msg.MANAGE_FAIL_NO_PLAYERS) + " (" + backupDBName + ")", sender)) {
return;
}
@ -102,13 +107,13 @@ public class ManageRestoreCommand extends SubCommand {
plugin.getHandler().getCommandUseFromDb();
}
sender.sendMessage(Phrase.MANAGE_COPY_SUCCESS.toString());
sender.sendMessage(Locale.get(Msg.MANAGE_INFO_COPY_SUCCESS).toString());
} else {
sender.sendMessage(Phrase.MANAGE_PROCESS_FAIL.toString());
sender.sendMessage(Locale.get(Msg.MANAGE_INFO_FAIL).toString());
}
} catch (Exception e) {
Log.toLog(this.getClass().getName() + " " + getTaskName(), e);
sender.sendMessage(Phrase.MANAGE_PROCESS_FAIL.toString());
sender.sendMessage(Locale.get(Msg.MANAGE_INFO_FAIL).toString());
} finally {
this.cancel();
}

View File

@ -1,45 +0,0 @@
package main.java.com.djrapitops.plan.command.commands.manage;
import com.djrapitops.plugin.command.CommandType;
import com.djrapitops.plugin.command.ISender;
import com.djrapitops.plugin.command.SubCommand;
import main.java.com.djrapitops.plan.Permissions;
import main.java.com.djrapitops.plan.Phrase;
import main.java.com.djrapitops.plan.Plan;
/**
* This manage subcommand is used to check the status of the database.
*
* @author Rsl1122
*/
public class ManageStatusCommand extends SubCommand {
private final Plan plugin;
/**
* Class Constructor.
*
* @param plugin Current instance of Plan
*/
public ManageStatusCommand(Plan plugin) {
super("status", CommandType.CONSOLE, Permissions.MANAGE.getPermission(), Phrase.CMD_USG_MANAGE_STATUS.toString());
this.plugin = plugin;
}
@Override
public boolean onCommand(ISender sender, String commandLabel, String[] args) {
String[] messages = new String[]{
Phrase.CMD_MANAGE_STATUS_HEADER.toString(),
Phrase.CMD_MANAGE_STATUS_ACTIVE_DB.parse(plugin.getDB().getConfigName()),
Phrase.CMD_MANAGE_STATUS_QUEUE_PROCESS.parse(String.valueOf(plugin.getHandler().getProcessTask().size())),
Phrase.CMD_MANAGE_STATUS_QUEUE_SAVE.parse(String.valueOf(plugin.getHandler().getSaveTask().size())),
Phrase.CMD_MANAGE_STATUS_QUEUE_GET.parse(String.valueOf(plugin.getHandler().getGetTask().size())),
Phrase.CMD_MANAGE_STATUS_QUEUE_CLEAR.parse(String.valueOf(plugin.getHandler().getClearTask().size())),
Phrase.CMD_FOOTER.toString()
};
sender.sendMessage(messages);
return true;
}
}

View File

@ -6,10 +6,11 @@ import com.djrapitops.plugin.command.SubCommand;
import com.djrapitops.plugin.task.AbsRunnable;
import main.java.com.djrapitops.plan.Log;
import main.java.com.djrapitops.plan.Permissions;
import main.java.com.djrapitops.plan.Phrase;
import main.java.com.djrapitops.plan.Plan;
import main.java.com.djrapitops.plan.data.WebUser;
import main.java.com.djrapitops.plan.database.tables.SecurityTable;
import main.java.com.djrapitops.plan.locale.Locale;
import main.java.com.djrapitops.plan.locale.Msg;
import main.java.com.djrapitops.plan.utilities.Check;
import org.bukkit.ChatColor;
@ -24,13 +25,17 @@ public class WebCheckCommand extends SubCommand {
private final Plan plugin;
public WebCheckCommand(Plan plugin) {
super("check", CommandType.CONSOLE_WITH_ARGUMENTS, Permissions.MANAGE_WEB.getPerm(), "Check a webuser and their permission level.", "<username>");
super("check",
CommandType.CONSOLE_WITH_ARGUMENTS,
Permissions.MANAGE_WEB.getPerm(),
Locale.get(Msg.CMD_USG_WEB_CHECK).toString(),
"<username>");
this.plugin = plugin;
}
@Override
public boolean onCommand(ISender sender, String commandLabel, String[] args) {
if (!Check.isTrue(args.length >= 1, Phrase.COMMAND_REQUIRES_ARGUMENTS_ONE.parse() + " <username>", sender)) {
if (!Check.isTrue(args.length >= 1, Locale.get(Msg.CMD_FAIL_REQ_ONE_ARG).parse() + " <username>", sender)) {
return true;
}
SecurityTable table = plugin.getDB().getSecurityTable();
@ -47,7 +52,7 @@ public class WebCheckCommand extends SubCommand {
sender.sendMessage(info.getName() + ": Permission level: " + info.getPermLevel());
} catch (Exception ex) {
Log.toLog(this.getClass().getName(), ex);
sender.sendMessage(Phrase.MANAGE_PROCESS_FAIL.parse());
sender.sendMessage(Locale.get(Msg.MANAGE_INFO_FAIL).parse());
} finally {
this.cancel();
}

View File

@ -6,9 +6,10 @@ import com.djrapitops.plugin.command.SubCommand;
import com.djrapitops.plugin.task.AbsRunnable;
import main.java.com.djrapitops.plan.Log;
import main.java.com.djrapitops.plan.Permissions;
import main.java.com.djrapitops.plan.Phrase;
import main.java.com.djrapitops.plan.Plan;
import main.java.com.djrapitops.plan.database.tables.SecurityTable;
import main.java.com.djrapitops.plan.locale.Locale;
import main.java.com.djrapitops.plan.locale.Msg;
import main.java.com.djrapitops.plan.utilities.Check;
import net.md_5.bungee.api.ChatColor;
@ -23,13 +24,17 @@ public class WebDeleteCommand extends SubCommand {
private final Plan plugin;
public WebDeleteCommand(Plan plugin) {
super("delete, remove", CommandType.CONSOLE_WITH_ARGUMENTS, Permissions.MANAGE_WEB.getPerm(), "Delete a webuser", "<username>");
super("delete, remove",
CommandType.CONSOLE_WITH_ARGUMENTS,
Permissions.MANAGE_WEB.getPerm(),
Locale.get(Msg.CMD_USG_WEB_DELETE).toString(),
"<username>");
this.plugin = plugin;
}
@Override
public boolean onCommand(ISender sender, String commandLabel, String[] args) {
if (!Check.isTrue(args.length >= 1, Phrase.COMMAND_REQUIRES_ARGUMENTS_ONE.parse() + " <username>", sender)) {
if (!Check.isTrue(args.length >= 1, Locale.get(Msg.CMD_FAIL_REQ_ONE_ARG).parse() + " <username>", sender)) {
return true;
}
SecurityTable table = plugin.getDB().getSecurityTable();
@ -43,13 +48,13 @@ public class WebDeleteCommand extends SubCommand {
return;
}
if (table.removeUser(user)) {
sender.sendMessage(Phrase.MANAGE_SUCCESS.parse());
sender.sendMessage(Locale.get(Msg.MANAGE_INFO_SUCCESS).parse());
} else {
sender.sendMessage(Phrase.MANAGE_PROCESS_FAIL.parse());
sender.sendMessage(Locale.get(Msg.MANAGE_INFO_FAIL).parse());
}
} catch (Exception ex) {
Log.toLog(this.getClass().getName(), ex);
sender.sendMessage(Phrase.MANAGE_PROCESS_FAIL.parse());
sender.sendMessage(Locale.get(Msg.MANAGE_INFO_FAIL).parse());
} finally {
this.cancel();
}

View File

@ -5,8 +5,9 @@ import com.djrapitops.plugin.command.ISender;
import com.djrapitops.plugin.command.SubCommand;
import com.djrapitops.plugin.settings.ColorScheme;
import main.java.com.djrapitops.plan.Permissions;
import main.java.com.djrapitops.plan.Phrase;
import main.java.com.djrapitops.plan.Plan;
import main.java.com.djrapitops.plan.locale.Locale;
import main.java.com.djrapitops.plan.locale.Msg;
/**
* Subcommand for info about permission levels.
@ -19,7 +20,10 @@ public class WebLevelCommand extends SubCommand {
private final Plan plugin;
public WebLevelCommand(Plan plugin) {
super("check", CommandType.CONSOLE, Permissions.MANAGE_WEB.getPerm(), "Info about permission levels.");
super("level",
CommandType.CONSOLE,
Permissions.MANAGE_WEB.getPerm(),
Locale.get(Msg.CMD_USG_WEB_LEVEL).toString());
this.plugin = plugin;
}
@ -27,14 +31,14 @@ public class WebLevelCommand extends SubCommand {
public boolean onCommand(ISender sender, String commandLabel, String[] args) {
ColorScheme cs = plugin.getColorScheme();
String sCol = cs.getSecondaryColor();
String cmdBall = Phrase.CMD_BALL.parse();
String cmdBall = Locale.get(Msg.CMD_CONSTANT_LIST_BALL).parse();
String[] messages = new String[]{
Phrase.CMD_FOOTER.parse(),
cmdBall + sCol + "0: Access all pages",
cmdBall + sCol + "1: Access '/players' and all inspect pages",
cmdBall + sCol + "2: Access inspect page with the same username as the webuser",
cmdBall + sCol + "3+: No permissions",
Phrase.CMD_FOOTER.parse()
Locale.get(Msg.CMD_CONSTANT_FOOTER).parse(),
cmdBall + sCol + "0: Access all pages",
cmdBall + sCol + "1: Access '/players' and all inspect pages",
cmdBall + sCol + "2: Access inspect page with the same username as the webuser",
cmdBall + sCol + "3+: No permissions",
Locale.get(Msg.CMD_CONSTANT_FOOTER).parse()
};
sender.sendMessage(messages);
return true;

View File

@ -7,9 +7,10 @@ import com.djrapitops.plugin.settings.ColorScheme;
import com.djrapitops.plugin.task.AbsRunnable;
import main.java.com.djrapitops.plan.Log;
import main.java.com.djrapitops.plan.Permissions;
import main.java.com.djrapitops.plan.Phrase;
import main.java.com.djrapitops.plan.Plan;
import main.java.com.djrapitops.plan.data.WebUser;
import main.java.com.djrapitops.plan.locale.Locale;
import main.java.com.djrapitops.plan.locale.Msg;
import main.java.com.djrapitops.plan.utilities.comparators.WebUserComparator;
import java.util.List;
@ -39,14 +40,14 @@ public class WebListUsersCommand extends SubCommand {
String mCol = cs.getMainColor();
List<WebUser> users = plugin.getDB().getSecurityTable().getUsers();
users.sort(new WebUserComparator());
sender.sendMessage(Phrase.CMD_FOOTER.parse() + mCol + " WebUsers (" + users.size() + ")");
sender.sendMessage(Locale.get(Msg.CMD_CONSTANT_FOOTER).parse() + mCol + " WebUsers (" + users.size() + ")");
for (WebUser user : users) {
sender.sendMessage(" " + user.getPermLevel() + " : " + user.getName());
}
sender.sendMessage(Phrase.CMD_FOOTER.parse());
sender.sendMessage(Locale.get(Msg.CMD_CONSTANT_FOOTER).parse());
} catch (Exception ex) {
Log.toLog(this.getClass().getName(), ex);
sender.sendMessage(Phrase.MANAGE_PROCESS_FAIL.parse());
sender.sendMessage(Locale.get(Msg.MANAGE_INFO_FAIL).parse());
} finally {
this.cancel();
}

View File

@ -37,9 +37,9 @@ public class WebUser {
WebUser webUser = (WebUser) o;
if (permLevel != webUser.permLevel) return false;
if (!user.equals(webUser.user)) return false;
return saltedPassHash.equals(webUser.saltedPassHash);
return permLevel == webUser.permLevel
&& user.equals(webUser.user)
&& saltedPassHash.equals(webUser.saltedPassHash);
}
@Override

View File

@ -5,7 +5,6 @@ import com.djrapitops.plugin.utilities.Verify;
import main.java.com.djrapitops.plan.Settings;
import main.java.com.djrapitops.plan.data.SessionData;
import main.java.com.djrapitops.plan.data.TPS;
import main.java.com.djrapitops.plan.ui.html.Html;
import main.java.com.djrapitops.plan.ui.html.RecentPlayersButtonsCreator;
import main.java.com.djrapitops.plan.ui.html.graphs.PlayerActivityGraphCreator;
import main.java.com.djrapitops.plan.ui.html.graphs.PunchCardGraphCreator;
@ -104,8 +103,7 @@ public class ActivityPart extends RawData {
addValue("%activitycolors%", activityColors);
String activityLabels = "[" + HtmlUtils.separateWithQuotes(
Html.GRAPH_ACTIVE.parse(), Html.GRAPH_INACTIVE.parse(),
Html.GRAPH_UNKNOWN.parse(), Html.GRAPH_BANNED.parse()) + "]";
"Active", "Inactive", "Unknown", "Banned") + "]";
addValue("%labelsactivity%", activityLabels);
addValue("activitydata", Arrays.toString(counts));

View File

@ -3,7 +3,6 @@ package main.java.com.djrapitops.plan.data.cache;
import com.djrapitops.plugin.task.AbsRunnable;
import com.djrapitops.plugin.utilities.player.IPlayer;
import main.java.com.djrapitops.plan.Log;
import main.java.com.djrapitops.plan.Phrase;
import main.java.com.djrapitops.plan.Plan;
import main.java.com.djrapitops.plan.Settings;
import main.java.com.djrapitops.plan.data.TPS;
@ -16,6 +15,8 @@ import main.java.com.djrapitops.plan.data.handling.info.HandlingInfo;
import main.java.com.djrapitops.plan.data.handling.info.LogoutInfo;
import main.java.com.djrapitops.plan.data.handling.info.ReloadInfo;
import main.java.com.djrapitops.plan.database.Database;
import main.java.com.djrapitops.plan.locale.Locale;
import main.java.com.djrapitops.plan.locale.Msg;
import main.java.com.djrapitops.plan.utilities.Benchmark;
import main.java.com.djrapitops.plan.utilities.MiscUtils;
import main.java.com.djrapitops.plan.utilities.NewPlayerCreator;
@ -81,7 +82,7 @@ public class DataCacheHandler extends SessionCache {
commandUse = new HashMap<>();
if (!getCommandUseFromDb()) {
Log.error(Phrase.DB_FAILURE_DISABLE + "");
Log.error(Locale.get(Msg.ENABLE_DB_FAIL_DISABLE_INFO).toString());
plugin.disablePlugin();
return;
}
@ -198,7 +199,7 @@ public class DataCacheHandler extends SessionCache {
public void cache(UserData data) {
data.setOnline(true);
dataCache.put(data.getUuid(), data);
Log.debug(Phrase.CACHE_ADD.parse(data.getUuid().toString()));
Log.debug("Added " + data.getUuid().toString() + " to Cache.");
}
/**
@ -415,7 +416,7 @@ public class DataCacheHandler extends SessionCache {
}
} else {
dataCache.remove(uuid);
Log.debug(Phrase.CACHE_REMOVE.parse(uuid.toString()));
Log.debug("Cleared " + uuid.toString() + " from Cache.");
}
}

View File

@ -5,10 +5,11 @@ import main.java.com.djrapitops.plan.Plan;
import main.java.com.djrapitops.plan.data.UserData;
import main.java.com.djrapitops.plan.database.Database;
import main.java.com.djrapitops.plan.ui.webserver.response.InspectPageResponse;
import main.java.com.djrapitops.plan.utilities.HtmlUtils;
import main.java.com.djrapitops.plan.utilities.MiscUtils;
import main.java.com.djrapitops.plan.utilities.analysis.ExportUtility;
import java.io.IOException;
import java.io.FileNotFoundException;
import java.sql.SQLException;
import java.util.*;
@ -48,10 +49,11 @@ public class InspectCacheHandler {
cache.put(uuid, new UserData(data));
cacheTimes.put(uuid, MiscUtils.getTime());
PageCacheHandler.cachePage("inspectPage: " + uuid.toString(), () -> new InspectPageResponse(Plan.getInstance().getUiServer().getDataReqHandler(), uuid));
try {
ExportUtility.writeInspectHtml(data, ExportUtility.getPlayersFolder(ExportUtility.getFolder()));
} catch (IOException ex) {
Log.toLog(this.getClass().getName(), ex);
ExportUtility.writeInspectHtml(data, ExportUtility.getPlayersFolder(ExportUtility.getFolder()), HtmlUtils.getStringFromResource("player.html"));
} catch (FileNotFoundException e) {
Log.toLog(this.getClass().getName(), e);
}
};

View File

@ -1,9 +1,10 @@
package main.java.com.djrapitops.plan.data.cache.queue;
import main.java.com.djrapitops.plan.Log;
import main.java.com.djrapitops.plan.Phrase;
import main.java.com.djrapitops.plan.Settings;
import main.java.com.djrapitops.plan.data.cache.DataCacheHandler;
import main.java.com.djrapitops.plan.locale.Locale;
import main.java.com.djrapitops.plan.locale.Msg;
import java.util.Collection;
import java.util.Objects;
@ -55,7 +56,7 @@ public class DataCacheClearQueue extends Queue<UUID> {
try {
queue.addAll(uuids);
} catch (IllegalStateException e) {
Log.error(Phrase.ERROR_TOO_SMALL_QUEUE.parse("Clear Queue", Settings.PROCESS_CLEAR_LIMIT.getNumber()));
Log.error(Locale.get(Msg.RUN_WARN_QUEUE_SIZE).parse("Clear Queue", Settings.PROCESS_CLEAR_LIMIT.getNumber()));
}
}
}

View File

@ -1,11 +1,12 @@
package main.java.com.djrapitops.plan.data.cache.queue;
import main.java.com.djrapitops.plan.Log;
import main.java.com.djrapitops.plan.Phrase;
import main.java.com.djrapitops.plan.Plan;
import main.java.com.djrapitops.plan.Settings;
import main.java.com.djrapitops.plan.data.cache.DBCallableProcessor;
import main.java.com.djrapitops.plan.database.Database;
import main.java.com.djrapitops.plan.locale.Locale;
import main.java.com.djrapitops.plan.locale.Msg;
import java.sql.SQLException;
import java.util.*;
@ -45,7 +46,7 @@ public class DataCacheGetQueue extends Queue<Map<UUID, List<DBCallableProcessor>
map.put(uuid, Arrays.asList(processors));
queue.add(map);
} catch (IllegalStateException e) {
Log.error(Phrase.ERROR_TOO_SMALL_QUEUE.parse("Get Queue", Settings.PROCESS_GET_LIMIT.getNumber()));
Log.error(Locale.get(Msg.RUN_WARN_QUEUE_SIZE).parse("Get Queue", Settings.PROCESS_GET_LIMIT.getNumber()));
}
}

View File

@ -1,12 +1,13 @@
package main.java.com.djrapitops.plan.data.cache.queue;
import main.java.com.djrapitops.plan.Log;
import main.java.com.djrapitops.plan.Phrase;
import main.java.com.djrapitops.plan.Plan;
import main.java.com.djrapitops.plan.Settings;
import main.java.com.djrapitops.plan.data.UserData;
import main.java.com.djrapitops.plan.data.cache.DataCacheHandler;
import main.java.com.djrapitops.plan.database.Database;
import main.java.com.djrapitops.plan.locale.Locale;
import main.java.com.djrapitops.plan.locale.Msg;
import java.sql.SQLException;
import java.util.Collection;
@ -45,7 +46,7 @@ public class DataCacheSaveQueue extends Queue<UserData> {
try {
queue.add(data);
} catch (IllegalStateException e) {
Log.error(Phrase.ERROR_TOO_SMALL_QUEUE.parse("Save Queue", Settings.PROCESS_SAVE_LIMIT.getNumber()));
Log.error(Locale.get(Msg.RUN_WARN_QUEUE_SIZE).parse("Save Queue", Settings.PROCESS_SAVE_LIMIT.getNumber()));
}
}
@ -59,7 +60,7 @@ public class DataCacheSaveQueue extends Queue<UserData> {
try {
queue.addAll(data);
} catch (IllegalStateException e) {
Log.error(Phrase.ERROR_TOO_SMALL_QUEUE.parse("Save Queue", Settings.PROCESS_SAVE_LIMIT.getNumber()));
Log.error(Locale.get(Msg.RUN_WARN_QUEUE_SIZE).parse("Save Queue", Settings.PROCESS_SAVE_LIMIT.getNumber()));
}
}
@ -73,7 +74,7 @@ public class DataCacheSaveQueue extends Queue<UserData> {
try {
queue.add(data);
} catch (IllegalStateException e) {
Log.error(Phrase.ERROR_TOO_SMALL_QUEUE.parse("Save Queue", Settings.PROCESS_SAVE_LIMIT.getNumber()));
Log.error(Locale.get(Msg.RUN_WARN_QUEUE_SIZE).parse("Save Queue", Settings.PROCESS_SAVE_LIMIT.getNumber()));
}
}

View File

@ -70,9 +70,9 @@ public abstract class TimeKeeper {
*/
public void changeState(String newState, long playTime) throws IllegalArgumentException, IllegalStateException {
Verify.nullCheck(newState);
if (playTime < lastStateChange) {
throw new IllegalStateException("Given Playtime is lower than last status change time: " + playTime + " / " + lastStateChange);
}
// if (playTime < lastStateChange) {
// throw new IllegalStateException("Given Playtime is lower than last status change time: " + playTime + " / " + lastStateChange);
// }
if (state == null) {
state = newState;
}
@ -81,7 +81,7 @@ public abstract class TimeKeeper {
currentTime = 0L;
}
long diff = playTime - lastStateChange;
times.put(state, currentTime + diff);
times.put(state, currentTime + Math.abs(diff));
state = newState;
lastStateChange = playTime;
}

View File

@ -1,8 +1,9 @@
package main.java.com.djrapitops.plan.database.databases;
import main.java.com.djrapitops.plan.Log;
import main.java.com.djrapitops.plan.Phrase;
import main.java.com.djrapitops.plan.Plan;
import main.java.com.djrapitops.plan.locale.Locale;
import main.java.com.djrapitops.plan.locale.Msg;
import org.bukkit.configuration.file.FileConfiguration;
import java.sql.Connection;
@ -41,7 +42,7 @@ public class MySQLDB extends SQLDB {
return DriverManager.getConnection(url, config.getString("mysql.user"), config.getString("mysql.password"));
} catch (ClassNotFoundException | SQLException e) {
Log.error(Phrase.DB_CONNECTION_FAIL.parse(getConfigName(), e.getMessage()));
Log.error(Locale.get(Msg.ENABLE_FAIL_DB).parse(getConfigName(), e.getMessage()));
return null;
}
}

View File

@ -392,7 +392,7 @@ public abstract class SQLDB extends Database {
.filter(uuid -> !userIds.containsKey(uuid))
.collect(Collectors.toSet());
List<UUID> uuids = new ArrayList<>(uuidsCol);
Log.debug("Data not found for: " + remove.size());
Log.debug("Database", "Data not found for: " + remove.size());
uuids.removeAll(remove);
Benchmark.start("Create UserData objects for " + userIds.size());
List<UserData> data = usersTable.getUserData(new ArrayList<>(uuids));

View File

@ -0,0 +1,338 @@
package main.java.com.djrapitops.plan.locale;
import com.djrapitops.plugin.settings.ColorScheme;
import com.djrapitops.plugin.settings.DefaultMessages;
import com.djrapitops.plugin.utilities.Verify;
import main.java.com.djrapitops.plan.Log;
import main.java.com.djrapitops.plan.Permissions;
import main.java.com.djrapitops.plan.Plan;
import main.java.com.djrapitops.plan.Settings;
import main.java.com.djrapitops.plan.ui.html.Html;
import main.java.com.djrapitops.plan.utilities.Benchmark;
import main.java.com.djrapitops.plan.utilities.comparators.LocaleEntryComparator;
import main.java.com.djrapitops.plan.utilities.comparators.StringLengthComparator;
import main.java.com.djrapitops.plan.utilities.file.FileUtil;
import org.bukkit.ChatColor;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
/**
* Class responsible for message localization.
* <p>
* Successor to Phrase Enum system.
*
* @author Rsl1122
* @since 3.6.2
*/
public class Locale {
private final Plan plugin;
private final Map<Msg, Message> messages;
public Locale(Plan plugin) {
LocaleHolder.setLOCALE(this);
this.plugin = plugin;
messages = new HashMap<>();
}
public void loadLocale() {
String locale = Settings.LOCALE.toString().toUpperCase();
Benchmark.start("Initializing locale");
loadDefault();
try {
if (Settings.WRITE_NEW_LOCALE.isTrue()) {
writeNewDefaultLocale();
}
File localeFile = new File(plugin.getDataFolder(), "locale.txt");
if (localeFile.exists()) {
loadFromFile(localeFile);
} else if (locale.equals("DEFAULT")) {
Log.info("Using Locale: Default (EN)");
} else {
loadFromResource("locale_" + locale + ".txt");
}
} catch (IOException e) {
Log.toLog(this.getClass().getName(), e);
}
Benchmark.stop("Enable", "Initializing locale");
}
private void writeNewDefaultLocale() throws IOException {
final int length = messages.keySet().stream()
.map(Msg::getIdentifier)
.sorted(new StringLengthComparator())
.findFirst()
.get().length() + 2;
List<String> lines = messages.entrySet().stream()
.sorted(new LocaleEntryComparator())
.map(entry -> getSpacedIdentifier(entry.getKey().getIdentifier(), length) + "|| " + entry.getValue().toString())
.collect(Collectors.toList());
Files.write(new File(plugin.getDataFolder(), "locale.txt").toPath(), lines, StandardCharsets.UTF_8);
plugin.getConfig().set(Settings.WRITE_NEW_LOCALE.getPath(), false);
}
private String getSpacedIdentifier(String identifier, int length) {
StringBuilder b = new StringBuilder(identifier);
while (b.length() < length) {
b.append(" ");
}
return b.toString();
}
private void loadDefault() {
String analysis = "Analysis | ";
String prefix = "[Plan] ";
String green = ChatColor.GREEN.toString();
String yellow = ChatColor.YELLOW.toString();
String red = ChatColor.RED.toString();
String arrowsRight = DefaultMessages.ARROWS_RIGHT.parse();
ColorScheme cs = plugin.getColorScheme();
String mCol = cs.getMainColor();
String sCol = cs.getSecondaryColor();
String tCol = cs.getTertiaryColor();
String cmdFooter = tCol + arrowsRight;
add(Msg.ENABLED, "Player Analytics Enabled.");
add(Msg.ENABLE_DB_INIT, "Database init..");
add(Msg.ENABLE_DB_INFO, "REPLACE0-database connection established.");
add(Msg.ENABLE_WEBSERVER, "Initializing Webserver..");
add(Msg.ENABLE_WEBSERVER_INFO, "Webserver running on PORT REPLACE0");
add(Msg.ENABLE_BOOT_ANALYSIS_INFO, analysis + "Boot analysis in 30 seconds..");
add(Msg.ENABLE_BOOT_ANALYSIS_RUN_INFO, analysis + "Starting Boot Analysis..");
add(Msg.ENABLE_NOTIFY_EMPTY_IP, yellow + "IP in server.properties is empty & AlternativeServerIP is not used, incorrect links will be given!");
add(Msg.ENABLE_NOTIFY_NO_DATA_VIEW, yellow + "Webserver disabled but Alternative IP/TextUI not used, no way to view data!");
add(Msg.ENABLE_NOTIFY_DISABLED_CHATLISTENER, yellow + "Chat listener disabled, nickname info inaccurate.");
add(Msg.ENABLE_NOTIFY_DISABLED_COMMANDLISTENER, yellow + "Command usage listener disabled.");
add(Msg.ENABLE_NOTIFY_DISABLED_DEATHLISTENER, yellow + "Death listener disabled, player & mob kills not recorded.");
add(Msg.ENABLE_FAIL_WRONG_DB, "That database type doesn't exist.");
add(Msg.ENABLE_FAIL_DB, "REPLACE0-Database Connection failed: REPLACE1");
add(Msg.ENABLE_DB_FAIL_DISABLE_INFO, "Database initialization has failed, disabling Plan.");
add(Msg.RUN_WARN_QUEUE_SIZE, "Queue size is too small! (REPLACE0), change the setting to a higher number! (Currently REPLACE1)");
add(Msg.DISABLED, "Player Analytics Disabled.");
add(Msg.DISABLE_CACHE_SAVE, "Saving cached data..");
add(Msg.DISABLE_WEBSERVER, "Shutting down Webserver..");
add(Msg.ANALYSIS_START, analysis + "Beginning analysis of user data..");
add(Msg.ANALYSIS_FETCH_UUID, analysis + "Checking for available players..");
add(Msg.ANALYSIS_FETCH, analysis + "Fetching Data..");
add(Msg.ANALYSIS_PHASE_START, analysis + "Data Fetched (REPLACE0 users, took REPLACE1ms), beginning Analysis of data..");
add(Msg.ANALYSIS_3RD_PARTY, analysis + "Analyzing additional data sources (3rd party)");
add(Msg.ANALYSIS_FINISHED, analysis + "Analysis Complete. (took REPLACE0ms) REPLACE1");
add(Msg.ANALYSIS_FAIL_NO_PLAYERS, analysis + "Analysis failed, no known players.");
add(Msg.ANALYSIS_FAIL_NO_DATA, analysis + "Analysis failed, no data in the database.");
add(Msg.ANALYSIS_FAIL_FETCH_EXCEPTION, analysis + "Failed to fetch data for Analysis, Exception occurred.");
add(Msg.MANAGE_INFO_CONFIG_REMINDER, yellow + prefix + "Remember to swap to the new database and reload plugin");
add(Msg.MANAGE_INFO_START, arrowsRight + sCol + " Processing data..");
add(Msg.MANAGE_INFO_IMPORT, cmdFooter + " " + mCol + " Importing Data..");
add(Msg.MANAGE_INFO_FAIL, red + prefix + "Something went wrong while processing the data!");
add(Msg.MANAGE_INFO_SUCCESS, cmdFooter + " " + mCol + " Success!");
add(Msg.MANAGE_INFO_COPY_SUCCESS, green + prefix + "All data copied successfully!");
add(Msg.MANAGE_INFO_MOVE_SUCCESS, green + prefix + "All data moved successfully!");
add(Msg.MANAGE_INFO_CLEAR_SUCCESS, green + prefix + "All data cleared successfully!");
add(Msg.MANAGE_INFO_REMOVE_SUCCESS, cmdFooter + " " + mCol + "Data of " + tCol + "REPLACE0" + mCol + " was removed from Database " + tCol + "REPLACE1" + mCol + ".");
add(Msg.MANAGE_FAIL_INCORRECT_PLUGIN, red + prefix + "Plugin not supported: ");
add(Msg.MANAGE_FAIL_PLUGIN_NOT_ENABLED, red + prefix + "Plugin is not enabled: ");
add(Msg.MANAGE_FAIL_SAME_DB, red + prefix + "Can't move to the same database!");
add(Msg.MANAGE_FAIL_INCORRECT_DB, red + prefix + "Incorrect database! (sqlite/mysql accepted): ");
add(Msg.MANAGE_FAIL_FAULTY_DB, red + prefix + "One of the databases was not initialized properly.");
add(Msg.MANAGE_FAIL_NO_PLAYERS, red + prefix + "Database has no player data!");
add(Msg.MANAGE_FAIL_FILE_NOT_FOUND, red + prefix + "Backup file doesn't exist!");
add(Msg.MANAGE_FAIL_CONFIRM, red + prefix + "Add -a to confirm execution! REPLACE0");
add(Msg.MANAGE_NOTIFY_REWRITE, "Data in REPLACE0-database will be rewritten!");
add(Msg.MANAGE_NOTIFY_OVERWRITE, "Data in REPLACE0-database will be overwritten!");
add(Msg.MANAGE_NOTIFY_PARTIAL_OVERWRITE, "Some data in REPLACE0-database will be overwritten!");
add(Msg.MANAGE_NOTIFY_REMOVE, "Data in REPLACE0-database will be removed!");
add(Msg.CMD_FAIL_REQ_ARGS, red + prefix + "Command requires arguments. REPLACE0");
add(Msg.CMD_FAIL_REQ_ONE_ARG, red + prefix + "Command requires one argument.");
add(Msg.CMD_FAIL_NO_PERMISSION, red + prefix + "You do not have the required permission.");
add(Msg.CMD_FAIL_USERNAME_NOT_VALID, red + prefix + "This Player doesn't exist.");
add(Msg.CMD_FAIL_USERNAME_NOT_SEEN, red + prefix + "This Player has not played on this server.");
add(Msg.CMD_FAIL_USERNAME_NOT_KNOWN, red + prefix + "Player not found from the database.");
add(Msg.CMD_FAIL_TIMEOUT, red + prefix + "REPLACE0 Command timed out! Check '/plan status' & console.");
add(Msg.CMD_FAIL_NO_DATA_VIEW, yellow + "" + prefix + "No Way to view Data Available.");
add(Msg.CMD_INFO_ANALYSIS_TEMP_DISABLE, yellow + "Analysis has been temporarily disabled due to expensive task, use /plan status for info.");
add(Msg.CMD_INFO_RELOAD_COMPLETE, green + prefix + "Reload complete.");
add(Msg.CMD_INFO_FETCH_DATA, tCol + arrowsRight + mCol + " Fetching data to cache..");
add(Msg.CMD_INFO_CLICK_ME, "Click Me");
add(Msg.CMD_INFO_LINK, sCol + "" + mCol + "Link: " + tCol);
add(Msg.CMD_INFO_RESULTS, sCol + " Matching players: " + tCol);
add(Msg.CMD_INFO_NO_RESULTS, sCol + "" + mCol + "No results for " + sCol + "REPLACE0" + mCol + ".");
add(Msg.CMD_INFO_SEARCHING, cmdFooter + mCol + "Searching..");
add(Msg.CMD_USG_ANALYZE, "View the Server Analysis");
add(Msg.CMD_USG_QANALYZE, "View the Server Analysis as Text");
add(Msg.CMD_USG_HELP, "Show command list.");
add(Msg.CMD_USG_INFO, "Check the version of Plan");
add(Msg.CMD_USG_INSPECT, "Inspect Player's Data");
add(Msg.CMD_USG_QINSPECT, "Inspect Player's Data as Text");
add(Msg.CMD_USG_LIST, "List to all cached players");
add(Msg.CMD_USG_MANAGE, "Database management command");
add(Msg.CMD_USG_MANAGE_BACKUP, "Backup a database to .db file");
add(Msg.CMD_USG_MANAGE_CLEAN, "Clear old data from the database");
add(Msg.CMD_USG_MANAGE_CLEAR, "Clear ALL data from the database");
add(Msg.CMD_USG_MANAGE_DUMP, "Create a Hastebin log for Dev for easier Issue reporting.");
add(Msg.CMD_USG_MANAGE_HOTSWAP, "Hotswap to another database & restart the plugin");
add(Msg.CMD_USG_MANAGE_IMPORT, "Import Data from supported plugins to Active Database.");
add(Msg.CMD_USG_MANAGE_MOVE, "Copy data from one database to another & overwrite values");
add(Msg.CMD_USG_MANAGE_REMOVE, "Remove players's data from the Active Database.");
add(Msg.CMD_USG_MANAGE_RESTORE, "Restore a database from a backup file");
add(Msg.CMD_USG_RELOAD, "Restart the Plugin (Reloads config)");
add(Msg.CMD_USG_SEARCH, "Search for player");
add(Msg.CMD_USG_WEB, "Manage Webusers");
add(Msg.CMD_USG_WEB_CHECK, "Check a webuser and their permission level.");
add(Msg.CMD_USG_WEB_DELETE, "Delete a webuser");
add(Msg.CMD_USG_WEB_LEVEL, "Info about permission levels.");
add(Msg.CMD_USG_WEB_REGISTER, "Register a user for the webserver");
add(Msg.CMD_HELP_ANALYZE, mCol + "Analysis Command"
+ "\\" + tCol + " Used to Refresh analysis cache & Access the result page"
+ "\\" + sCol + " /plan status can be used to check status of analysis while it is running."
+ "\\" + sCol + " Aliases: analyze, analyse, analysis, a");
add(Msg.CMD_HELP_QANALYZE, mCol + "Quick Analysis command"
+ "\\" + tCol + " Used to get in game info about analysis."
+ "\\" + sCol + " Has less info than full Analysis web page."
+ "\\" + sCol + " Aliases: qanalyze, ganalyse, qanalysis, qa");
add(Msg.CMD_HELP_PLAN, mCol + "/plan - Main Command"
+ "\\" + tCol + " Used to access all SubCommands & help"
+ "\\" + sCol + " /plan - List subcommands"
+ "\\" + sCol + " /plan <subcommand> ? - in depth help");
add(Msg.CMD_HELP_INSPECT, mCol + "Inspect command"
+ "\\" + tCol + " Used to get a link to User's inspect page."
+ "\\" + sCol + " Own inspect page can be accessed with /plan inspect"
+ "\\" + sCol + " Alias: /plan <name>");
add(Msg.CMD_HELP_QINSPECT, mCol + "Quick Inspect command"
+ "\\" + tCol + " Used to get some inspect info in game."
+ "\\" + sCol + " Has less info than full Inspect web page."
+ "\\" + sCol + " Alias: /plan qi");
add(Msg.CMD_HELP_LIST, mCol + "List command"
+ "\\" + tCol + " Used to get a link to players page."
+ "\\" + sCol + " Players page contains links to all cached inspect pages."
+ "\\" + sCol + " Alias: /plan pl");
add(Msg.CMD_HELP_MANAGE, mCol + "Manage command\\"
+ tCol + " Used to Manage Database of the plugin."
+ "\\" + sCol + " Alias: /plan m"
+ "\\" + sCol + " /plan m - List subcommands"
+ "\\" + sCol + " /plan m <subcommand> ? - in depth help");
add(Msg.CMD_HELP_MANAGE_CLEAR, mCol + "Manage Clear command"
+ "\\" + tCol + " Used to delete ALL data in the active database."
+ "\\" + sCol + " Plugin should be reloaded after successful clear."
+ "\\" + sCol + " Alias: /plan pl");
add(Msg.CMD_HELP_MANAGE_DUMP, mCol + "Manage Dump command"
+ "\\" + tCol + " Used to dump important data for bug reporting to hastebin.");
add(Msg.CMD_HELP_MANAGE_HOTSWAP, mCol + "Manage Hotswap command"
+ "\\" + tCol + " Used to change database in use on the fly."
+ "\\" + sCol + " Does not change database if connection fails");
add(Msg.CMD_HELP_MANAGE_IMPORT, mCol + "Manage Import command"
+ "\\" + tCol + " Used to import data from other sources"
+ "\\" + sCol + " Analysis will be disabled during import.");
add(Msg.CMD_HELP_MANAGE_REMOVE, mCol + "Manage Remove command"
+ "\\" + tCol + " Used to Remove user's data from the active database.");
add(Msg.CMD_HELP_SEARCH, mCol + "Search command"
+ "\\" + tCol + " Used to get a list of Player names that match the given argument."
+ "\\" + sCol + " Example: /plan search 123 - Finds all users with 123 in their name.");
add(Msg.CMD_HELP_WEB, mCol + "Web User Manage command"
+ "\\" + tCol + " Used to manage web users of the plugin"
+ "\\" + sCol + " Users have a permission level:"
+ "\\" + tCol + " 0 - Access to all pages"
+ "\\" + tCol + " 1 - Access to /players & all inspect pages"
+ "\\" + tCol + " 2 - Access to own inspect page"
+ "\\" + sCol + " Alias: /plan web");
add(Msg.CMD_HELP_WEB_REGISTER, mCol + "Web Register command"
+ "\\" + tCol + " Used to register a new user for the webserver."
+ "\\" + sCol + " Registering a user for another player requires " + Permissions.MANAGE_WEB.getPerm() + " permission."
+ "\\" + sCol + " Passwords are hashed with PBKDF2 (64,000 iterations of SHA1) using a cryptographically-random salt.");
add(Msg.CMD_HEADER_ANALYZE, cmdFooter + mCol + " Player Analytics - Analysis results");
add(Msg.CMD_HEADER_INSPECT, cmdFooter + mCol + " Player Analytics - Inspect results");
add(Msg.CMD_HEADER_INFO, cmdFooter + mCol + " Player Analytics - Info");
add(Msg.CMD_HEADER_SEARCH, cmdFooter + mCol + " Player Analytics - Search results: ");
add(Msg.CMD_CONSTANT_FOOTER, tCol + arrowsRight);
add(Msg.CMD_CONSTANT_LIST_BALL, sCol + " " + "" + mCol);
add(Msg.HTML_NO_PLUGINS, "<p>No extra plugins registered.</p>");
add(Msg.HTML_BANNED, "| " + Html.SPAN.parse(Html.COLOR_4.parse() + "Banned"));
add(Msg.HTML_OP, ", Operator (Op)");
add(Msg.HTML_ONLINE, "| " + Html.SPAN.parse(Html.COLOR_2.parse() + "Online"));
add(Msg.HTML_OFFLINE, "| " + Html.SPAN.parse(Html.COLOR_4.parse() + "Offline"));
add(Msg.HTML_ACTIVE, "Player is Active");
add(Msg.HTML_INACTIVE, "Player is inactive");
add(Msg.HTML_TABLE_NO_KILLS, "No Kills");
}
private void add(Msg msg, String message) {
Verify.nullCheck(msg, message);
messages.put(msg, new Message(message));
}
private void loadFromFile(File localeFile) throws IOException {
loadFromContents(Files.lines(localeFile.toPath(), StandardCharsets.UTF_8).collect(Collectors.toList()), "Custom File");
}
private void loadFromResource(String fileName) {
try {
loadFromContents(FileUtil.lines(plugin, fileName), fileName);
} catch (FileNotFoundException e) {
Log.error("Could not find file inside the jar: " + fileName);
Log.info("Using Locale: Default (EN)");
} catch (Exception e) {
Log.toLog(this.getClass().getName(), e);
Log.info("Using Locale: Default (EN)");
}
}
private void loadFromContents(List<String> locale, String name) {
Log.info("Using Locale: " + name);
Map<String, Msg> identifiers = Msg.getIdentifiers();
locale.forEach(line -> {
String[] split = line.split(" \\|\\| ");
if (split.length == 2) {
String identifier = split[0].trim();
Msg msg = identifiers.get(identifier);
if (msg != null) {
add(msg, split[1]);
}
}
});
}
public Message getMessage(Msg msg) {
Message message = messages.get(msg);
return message != null ? message : new Message("");
}
public static Message get(Msg msg) {
return LocaleHolder.getLOCALE().getMessage(msg);
}
private static class LocaleHolder {
private static Locale LOCALE;
public static void setLOCALE(Locale LOCALE) {
LocaleHolder.LOCALE = LOCALE;
}
public static Locale getLOCALE() {
return LOCALE;
}
}
}

View File

@ -0,0 +1,43 @@
package main.java.com.djrapitops.plan.locale;
import java.io.Serializable;
/**
* Represents a Message that can be modified.
*
* @author Rsl1122
* @since 3.6.2
*/
public class Message {
private final String message;
public Message(String message) {
this.message = message;
}
public String parse(Serializable... p) {
String returnValue = this.message;
for (int i = 0; i < p.length; i++) {
returnValue = returnValue.replace("REPLACE" + i, p[i].toString());
}
return returnValue;
}
@Override
public String toString() {
return message;
}
public String parse() {
return toString();
}
public String[] toArray() {
return message.split("\\\\");
}
public String[] toArray(Serializable... p) {
return parse().split("\\\\");
}
}

View File

@ -0,0 +1,157 @@
package main.java.com.djrapitops.plan.locale;
import java.util.Arrays;
import java.util.Map;
import java.util.function.Function;
import java.util.stream.Collectors;
public enum Msg {
ENABLED("Enable"),
ENABLE_DB_INIT("Enable - Db"),
ENABLE_DB_INFO("Enable - Db Info"),
ENABLE_WEBSERVER("Enable - WebServer"),
ENABLE_WEBSERVER_INFO("Enable - WebServer Info"),
ENABLE_BOOT_ANALYSIS_INFO("Enable - Boot Analysis 30s Notify"),
ENABLE_BOOT_ANALYSIS_RUN_INFO("Enable - Boot Analysis Notify"),
//
ENABLE_NOTIFY_EMPTY_IP("Enable Notify-Empty IP"),
ENABLE_NOTIFY_NO_DATA_VIEW("Enable Notify - No data view"),
ENABLE_NOTIFY_DISABLED_CHATLISTENER("Enable Notify - ChatListener"),
ENABLE_NOTIFY_DISABLED_COMMANDLISTENER("Enable Notify - Disabled CommandListener"),
ENABLE_NOTIFY_DISABLED_DEATHLISTENER("Enable Notify - Disabled DeathListener"),
//
ENABLE_FAIL_WRONG_DB("Enable FAIL - Wrong Db Type"),
ENABLE_FAIL_DB("Enable FAIL-Db"),
ENABLE_DB_FAIL_DISABLE_INFO("Enable Db FAIL - Disable Info"),
//
RUN_WARN_QUEUE_SIZE("WARN - Too Small Queue Size"),
//
DISABLED("Disable"),
DISABLE_CACHE_SAVE("Disable - Save"),
DISABLE_WEBSERVER("Disable - WebServer"),
//
ANALYSIS_START("Analysis - Start"),
ANALYSIS_FETCH_UUID("Analysis - Fetch Phase Start"),
ANALYSIS_FETCH("Analysis - Fetch Phase"),
ANALYSIS_PHASE_START("Analysis - Begin Analysis"),
ANALYSIS_3RD_PARTY("Analysis - Third Party"),
ANALYSIS_FINISHED("Analysis - Complete"),
ANALYSIS_FAIL_NO_PLAYERS("Analysis FAIL - No Players"),
ANALYSIS_FAIL_NO_DATA("Analysis FAIL - No Data"),
ANALYSIS_FAIL_FETCH_EXCEPTION("Analysis FAIL - Fetch Exception"),
//
MANAGE_INFO_CONFIG_REMINDER("Manage - Remind Config Change"),
MANAGE_INFO_START("Manage - Start"),
MANAGE_INFO_IMPORT("Manage - Import"),
MANAGE_INFO_FAIL("Manage - Process Fail"),
MANAGE_INFO_SUCCESS("Manage - Success"),
MANAGE_INFO_COPY_SUCCESS("Manage - Copy Success"),
MANAGE_INFO_MOVE_SUCCESS("Manage - Move Success"),
MANAGE_INFO_CLEAR_SUCCESS("Manage - Clear Success"),
MANAGE_INFO_REMOVE_SUCCESS("Manage - Remove Success"),
//
MANAGE_FAIL_INCORRECT_PLUGIN("Manage FAIL - Incorrect Plugin"),
MANAGE_FAIL_PLUGIN_NOT_ENABLED("Manage FAIL - Unenabled Plugin"),
MANAGE_FAIL_SAME_DB("Manage FAIL - Same DB"),
MANAGE_FAIL_INCORRECT_DB("Manage FAIL - Incorrect DB"),
MANAGE_FAIL_FAULTY_DB("Manage FAIL - Faulty DB Connection"),
MANAGE_FAIL_NO_PLAYERS("Manage FAIL - Empty DB"),
MANAGE_FAIL_FILE_NOT_FOUND("Manage FAIL - Backup File Not Found"),
//
MANAGE_FAIL_CONFIRM("Manage FAIL - Confirm Action"),
MANAGE_NOTIFY_REWRITE("Manage NOTIFY - Rewrite"),
MANAGE_NOTIFY_OVERWRITE("Manage NOTIFY - Overwrite"),
MANAGE_NOTIFY_PARTIAL_OVERWRITE("Manage NOTIFY - Partial Overwrite"),
MANAGE_NOTIFY_REMOVE("Manage NOTIFY - Remove"),
//
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_ANALYSIS_TEMP_DISABLE("Analysis NOTIFY - Temporary Disable"),
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_USG_ANALYZE("Cmd - Usage /plan analyze"),
CMD_USG_QANALYZE("Cmd - Usage /plan qanalyze"),
CMD_USG_HELP("Cmd - Usage /plan help"),
CMD_USG_INFO("Cmd - Usage /plan info"),
CMD_USG_INSPECT("Cmd - Usage /plan inspect"),
CMD_USG_QINSPECT("Cmd - Usage /plan qinspect"),
CMD_USG_LIST("Cmd - Usage /plan list"),
CMD_USG_MANAGE("Cmd - Usage /plan manage"),
CMD_USG_MANAGE_BACKUP("Cmd - Usage /plan manage backup"),
CMD_USG_MANAGE_CLEAN("Cmd - Usage /plan manage clean"),
CMD_USG_MANAGE_CLEAR("Cmd - Usage /plan manage clear"),
CMD_USG_MANAGE_DUMP("Cmd - Usage /plan manage dump"),
CMD_USG_MANAGE_HOTSWAP("Cmd - Usage /plan manage hotswap"),
CMD_USG_MANAGE_IMPORT("Cmd - Usage /plan manage import"),
CMD_USG_MANAGE_MOVE("Cmd - Usage /plan manage move"),
CMD_USG_MANAGE_REMOVE("Cmd - Usage /plan manage remove"),
CMD_USG_MANAGE_RESTORE("Cmd - Usage /plan manage restore"),
CMD_USG_RELOAD("Cmd - Usage /plan reload"),
CMD_USG_SEARCH("Cmd - Usage /plan search"),
CMD_USG_WEB("Cmd - Usage /plan webuser"),
CMD_USG_WEB_CHECK("Cmd - Usage /plan webuser check"),
CMD_USG_WEB_DELETE("Cmd - Usage /plan webuser delete"),
CMD_USG_WEB_LEVEL("Cmd - Usage /plan webuser level"),
CMD_USG_WEB_REGISTER("Cmd - Usage /plan webuser register"),
//
CMD_HELP_ANALYZE("In Depth Help - /plan analyze ?"),
CMD_HELP_QANALYZE("In Depth Help - /plan qanalyze ?"),
CMD_HELP_PLAN("In Depth Help - /plan ?"),
CMD_HELP_INSPECT("In Depth Help - /plan inspect ?"),
CMD_HELP_QINSPECT("In Depth Help - /plan qinspect ?"),
CMD_HELP_LIST("In Depth Help - /plan list ?"),
CMD_HELP_MANAGE("In Depth Help - /plan manage ?"),
CMD_HELP_MANAGE_CLEAR("In Depth Help - /plan manage clear ?"),
CMD_HELP_MANAGE_DUMP("In Depth Help - /plan manage dump ?"),
CMD_HELP_MANAGE_HOTSWAP("In Depth Help - /plan manage hotswap ?"),
CMD_HELP_MANAGE_IMPORT("In Depth Help - /plan manage import ?"),
CMD_HELP_MANAGE_REMOVE("In Depth Help - /plan manage remove ?"),
CMD_HELP_SEARCH("In Depth Help - /plan search ?"),
CMD_HELP_WEB("In Depth Help - /plan webuser ?"),
CMD_HELP_WEB_REGISTER("In Depth Help - /plan webuser register ?"),
//
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_LIST_BALL(">Constant - List Ball"),
CMD_CONSTANT_FOOTER(">Constant - CMD Footer"),
//
HTML_NO_PLUGINS("Html - No Extra Plugins"),
HTML_BANNED("Html - Banned"),
HTML_OP("Html - OP"),
HTML_ONLINE("Html - Online"),
HTML_OFFLINE("Html - Offline"),
HTML_ACTIVE("Html - Active"),
HTML_INACTIVE("Html - Inactive"),
HTML_TABLE_NO_KILLS("Html - Table No Kills"),;
private final String identifier;
Msg(String identifier) {
this.identifier = identifier;
}
public String getIdentifier() {
return identifier;
}
public static Map<String, Msg> getIdentifiers() {
return Arrays.stream(values()).collect(Collectors.toMap(Msg::getIdentifier, Function.identity()));
}
}

View File

@ -14,9 +14,6 @@ import java.util.Scanner;
*/
public enum Html {
REPLACE0("REPLACE0"),
REPLACE1("REPLACE1"),
WARN_INACCURATE("<div class=\"warn\">Data might be inaccurate, player has just registered.</div>"),
COLOR_0("<span class=\"black\">"),
COLOR_1("<span class=\"darkblue\">"),
COLOR_2("<span class=\"darkgreen\">"),
@ -35,57 +32,19 @@ public enum Html {
COLOR_F("<span class=\"white\">"),
//
FONT_AWESOME_ICON("<i class=\"fa fa-REPLACE0\" aria-hidden=\"true\"></i>"),
MINOTAR_SMALL_IMG("<img style=\"float: left; padding: 2px 2px 0px 2px\" alt=\"" + REPLACE0 + "\" src=\"https://minotar.net/avatar/" + REPLACE0 + "/19\">"),
SPAN("" + REPLACE0 + "</span>"),
BUTTON("<a class=\"button\" href=\"" + REPLACE0 + "\">" + REPLACE1 + "</a>"),
MINOTAR_SMALL_IMG("<img style=\"float: left; padding: 2px 2px 0px 2px\" alt=\"REPLACE0\" src=\"https://minotar.net/avatar/REPLACE0/19\">"),
SPAN("REPLACE0</span>"),
BUTTON("<a class=\"button\" href=\"REPLACE0\">REPLACE1</a>"),
BUTTON_CLASS("class=\"button\""),
LINK("<a class=\"link\" href=\"" + REPLACE0 + "\">" + REPLACE1 + "</a>"),
LINK_EXTERNAL("<a class=\"link\" target=\"_blank\" href=\"" + REPLACE0 + "\">" + REPLACE1 + "</a>"),
LINK("<a class=\"link\" href=\"REPLACE0\">REPLACE1</a>"),
LINK_EXTERNAL("<a class=\"link\" target=\"_blank\" href=\"REPLACE0\">REPLACE1</a>"),
LINK_CLASS("class=\"link\""),
IMG("<img src=\"" + REPLACE0 + "\">"),
COLUMNS_DIV_WRAPPER("<div class=\"columns\">" + REPLACE0 + "</div>"),
COLUMN_DIV_WRAPPER("<div class=\"about box column\">" + REPLACE0 + "</div>"),
HEADER("<div class=\"headerbox\" style=\"width: 95%;\"><div class=\"header-icon\"><div class=\"header-label\"><i class=\"fa fa-cube\" aria-hidden=\"true\"></i><span class=\"header-text\"> " + REPLACE0 + "</span></div></div></div>"),
PLUGIN_DATA_WRAPPER("<div class=\"plugin-data\">" + REPLACE0 + "</div>"),
IMG("<img src=\"REPLACE0\">"),
COLUMNS_DIV_WRAPPER("<div class=\"columns\">REPLACE0</div>"),
COLUMN_DIV_WRAPPER("<div class=\"about box column\">REPLACE0</div>"),
HEADER("<div class=\"headerbox\" style=\"width: 95%;\"><div class=\"header-icon\"><div class=\"header-label\"><i class=\"fa fa-cube\" aria-hidden=\"true\"></i><span class=\"header-text\"> REPLACE0</span></div></div></div>"),
PLUGIN_DATA_WRAPPER("<div class=\"plugin-data\">REPLACE0</div>"),
PLUGIN_CONTAINER_START("<div class=\"plugin-container\">"),
NO_PLUGINS("<p>No extra plugins registered.</p>"),
//
TOP_TOWNS("<p><b>Top 20 Towns</b></p>"),
TOP_FACTIONS("<p><b>Top 20 Factions</b></p>"),
TOTAL_BALANCE("<p>Server Total Balance: " + REPLACE0 + "</p>"),
TOTAL_VOTES("<p>Players have voted total of " + REPLACE0 + " times.</p>"),
PLOT_OPTIONS("<p>Plot options: " + REPLACE0 + "</p>"),
FRIENDS("<p>Friends with " + REPLACE0 + "</p>"),
BALANCE("<p>Balance: " + REPLACE0 + "</p>"),
FACTION_NOT_FOUND("Faction not found"),
FACTION_NO_LEADER("No leader"),
FACTION_NO_FACTIONS("No Factions"),
WARPS("<br/>Warps: " + REPLACE0),
ACHIEVEMENTS("<br/>Achievements: " + REPLACE0 + "/" + REPLACE1),
JAILED("| Jailed"),
MUTED("| Muted"),
VOTES("<br/>Has voted " + REPLACE0 + "times"),
FACTION("<br/>Faction: " + REPLACE0 + " | Power: " + REPLACE1 + "/REPLACE2"),
TOWN("<br/>Town: " + REPLACE0),
TOWN_NO_TOWNS("No Towns"),
//
BANNED("| " + SPAN.parse(COLOR_4.parse() + "Banned")),
OPERATOR(", Operator (Op)"),
ONLINE("| " + SPAN.parse(COLOR_2.parse() + "Online")),
OFFLINE("| " + SPAN.parse(COLOR_4.parse() + "Offline")),
ACTIVE("Player is Active"),
INACTIVE("Player is inactive"),
ERROR_LIST("Error Creating List</p>"),
HIDDEN("Hidden (config)"),
ERROR_NOT_SET("Error: Replace rule was not set"),
//
GRAPH_BANNED("Banned"),
GRAPH_UNKNOWN("Unknown"),
GRAPH_INACTIVE("Inactive"),
GRAPH_ACTIVE("Active"),
GRAPH_ONLINE("Players Online"),
GRAPH_PLAYERS("Players"),
GRAPH_DATE("Date"),
//
TABLE_START_2("<table class=\"sortable table\"><thead><tr><th>REPLACE0</th><th>REPLACE1</th></tr></thead><tbody>"),
TABLE_START_3("<table class=\"sortable table\"><thead><tr><th>REPLACE0</th><th>REPLACE1</th><th>REPLACE2</th></tr></thead><tbody>"),
@ -94,16 +53,15 @@ public enum Html {
TABLE_KILLS_START(TABLE_START_3.parse("Date", "Killed", "With")),
TABLE_FACTIONS_START(TABLE_START_4.parse(FONT_AWESOME_ICON.parse("flag") + " Faction", FONT_AWESOME_ICON.parse("bolt") + " Power", FONT_AWESOME_ICON.parse("map-o") + " Land", FONT_AWESOME_ICON.parse("user") + " Leader")),
TABLE_TOWNS_START(TABLE_START_4.parse(FONT_AWESOME_ICON.parse("bank") + " Town", FONT_AWESOME_ICON.parse("users") + " Residents", FONT_AWESOME_ICON.parse("map-o") + " Land", FONT_AWESOME_ICON.parse("user") + " Mayor")),
TABLELINE_2("<tr><td><b>" + REPLACE0 + "</b></td><td>" + REPLACE1 + "</td></tr>"),
TABLELINE_3("<tr><td><b>" + REPLACE0 + "</b></td><td>" + REPLACE1 + "</td><td>REPLACE2</td></tr>"),
TABLELINE_4("<tr><td><b>" + REPLACE0 + "</b></td><td>" + REPLACE1 + "</td><td>REPLACE2</td><td>REPLACE3</td></tr>"),
TABLELINE_2("<tr><td><b>REPLACE0</b></td><td>REPLACE1</td></tr>"),
TABLELINE_3("<tr><td><b>REPLACE0</b></td><td>REPLACE1</td><td>REPLACE2</td></tr>"),
TABLELINE_4("<tr><td><b>REPLACE0</b></td><td>REPLACE1</td><td>REPLACE2</td><td>REPLACE3</td></tr>"),
TABLELINE_PLAYERS("<tr><td>REPLACE0</td><td>REPLACE1</td><td sorttable_customkey=\"REPLACE2\">REPLACE3</td><td>REPLACE4</td><td sorttable_customkey=\"REPLACE5\">REPLACE6</td>" + "<td sorttable_customkey=\"REPLACE7\">REPLACE8</td><td>REPLACE9</td></tr>"),
TABLELINE_3_CUSTOMKEY("<tr><td sorttable_customkey=\"REPLACE0\">REPLACE1</td><td sorttable_customkey=\"REPLACE2\">REPLACE3</td><td sorttable_customkey=\"REPLACE4\">REPLACE5</td></tr>"),
TABLELINE_3_CUSTOMKEY_1("<tr><td sorttable_customkey=\"REPLACE0\">REPLACE1</td><td>REPLACE2</td><td>REPLACE3</td></tr>"),
ERROR_TABLE_2(TABLELINE_2.parse("No data", "No data")),
TABLE_END("</tbody></table>"),
SESSIONDATA_NONE("No Session Data available"),
KILLDATA_NONE("No Kills"),;
TABLE_END("</tbody></table>"), // KILLDATA_NONE("No Kills"),
;
private String html;

View File

@ -3,6 +3,8 @@ package main.java.com.djrapitops.plan.ui.html.tables;
import com.djrapitops.plugin.utilities.player.Fetch;
import com.djrapitops.plugin.utilities.player.IOfflinePlayer;
import main.java.com.djrapitops.plan.data.KillData;
import main.java.com.djrapitops.plan.locale.Locale;
import main.java.com.djrapitops.plan.locale.Msg;
import main.java.com.djrapitops.plan.ui.html.Html;
import main.java.com.djrapitops.plan.utilities.FormatUtils;
import main.java.com.djrapitops.plan.utilities.HtmlUtils;
@ -31,7 +33,7 @@ public class KillsTableCreator {
StringBuilder html = new StringBuilder(Html.TABLE_KILLS_START.parse());
if (killData.isEmpty()) {
html.append(Html.TABLELINE_3.parse(Html.KILLDATA_NONE.parse(), "", ""));
html.append(Html.TABLELINE_3.parse(Locale.get(Msg.HTML_TABLE_NO_KILLS).parse(), "", ""));
} else {
int i = 0;

View File

@ -42,10 +42,10 @@ public class PlayersTableCreator {
boolean isUnknown = uData.getLoginTimes() == 1;
boolean isActive = AnalysisUtils.isActive(now, uData.getLastPlayed(), uData.getPlayTime(), uData.getLoginTimes());
String activityString = isBanned ? Html.GRAPH_BANNED.parse()
: isUnknown ? Html.GRAPH_UNKNOWN.parse()
: isActive ? Html.GRAPH_ACTIVE.parse()
: Html.GRAPH_INACTIVE.parse();
String activityString = isBanned ? "Banned"
: isUnknown ? "Unknown"
: isActive ? "Active"
: "Inactive";
String img = showImages ? Html.MINOTAR_SMALL_IMG.parse(uData.getName()) : "";

View File

@ -1,6 +1,7 @@
package main.java.com.djrapitops.plan.ui.text;
import main.java.com.djrapitops.plan.Phrase;
import com.djrapitops.plugin.settings.ColorScheme;
import com.djrapitops.plugin.settings.DefaultMessages;
import main.java.com.djrapitops.plan.Plan;
import main.java.com.djrapitops.plan.data.AnalysisData;
import main.java.com.djrapitops.plan.data.UserData;
@ -38,15 +39,18 @@ public class TextUI {
return new String[]{"Error has occurred, please retry."};
}
UserData d = inspectCache.getFromCache(uuid);
ChatColor main = Phrase.COLOR_MAIN.color();
ChatColor sec = Phrase.COLOR_SEC.color();
ChatColor ter = Phrase.COLOR_TER.color();
ColorScheme cs = Plan.getInstance().getColorScheme();
String main = cs.getMainColor();
String sec = cs.getSecondaryColor();
String ter = cs.getTertiaryColor();
boolean active = AnalysisUtils.isActive(now, d.getLastPlayed(), d.getPlayTime(), d.getLoginTimes());
boolean banned = d.isBanned();
boolean online = d.isOnline();
String ball = sec + " " + Phrase.BALL + main;
String ball = sec + " " + DefaultMessages.BALL + main;
return new String[]{
sec + " " + Phrase.BALL + (banned ? ChatColor.DARK_RED + " Banned" : ter + (active ? " Active" : " Inactive")) + (online ? ChatColor.GREEN + " Online" : ChatColor.RED + " Offline"),
sec + " " + DefaultMessages.BALL + (banned ? ChatColor.DARK_RED + " Banned" : ter + (active ? " Active" : " Inactive")) + (online ? ChatColor.GREEN + " Online" : ChatColor.RED + " Offline"),
ball + " Registered: " + sec + FormatUtils.formatTimeStampYear(d.getRegistered()),
ball + " Last seen: " + sec + FormatUtils.formatTimeStamp(d.getLastPlayed()),
ball + " Playtime: " + sec + FormatUtils.formatTimeAmount(d.getPlayTime()),
@ -66,9 +70,12 @@ public class TextUI {
return new String[]{"Error has occurred, please retry."};
}
AnalysisData d = analysisCache.getData();
ChatColor main = Phrase.COLOR_MAIN.color();
ChatColor sec = Phrase.COLOR_SEC.color();
String ball = sec + " " + Phrase.BALL + main;
ColorScheme cs = Plan.getInstance().getColorScheme();
String main = cs.getMainColor();
String sec = cs.getSecondaryColor();
String ball = sec + " " + DefaultMessages.BALL + main;
final ActivityPart activity = d.getActivityPart();
final JoinInfoPart join = d.getJoinInfoPart();
final KillPart kills = d.getKillPart();

View File

@ -102,7 +102,8 @@ public class Request implements Closeable {
String[] reqLine = req.split(" ");
if (reqLine.length >= 2) {
request = reqLine[0];
target = reqLine[1];
target = reqLine[1].replace("%20", " ")
.replace("%2E", ".");;
} else {
request = "GET";
target = "/";

View File

@ -3,12 +3,13 @@ package main.java.com.djrapitops.plan.ui.webserver;
import com.djrapitops.plugin.utilities.Verify;
import com.sun.net.httpserver.*;
import main.java.com.djrapitops.plan.Log;
import main.java.com.djrapitops.plan.Phrase;
import main.java.com.djrapitops.plan.Plan;
import main.java.com.djrapitops.plan.Settings;
import main.java.com.djrapitops.plan.data.WebUser;
import main.java.com.djrapitops.plan.data.cache.PageCacheHandler;
import main.java.com.djrapitops.plan.database.tables.SecurityTable;
import main.java.com.djrapitops.plan.locale.Locale;
import main.java.com.djrapitops.plan.locale.Msg;
import main.java.com.djrapitops.plan.ui.html.DataRequestHandler;
import main.java.com.djrapitops.plan.ui.webserver.response.*;
import main.java.com.djrapitops.plan.utilities.Benchmark;
@ -68,7 +69,7 @@ public class WebServer {
return;
}
Log.info(Phrase.WEBSERVER_INIT.toString());
Log.info(Locale.get(Msg.ENABLE_WEBSERVER).toString());
try {
usingHttps = startHttpsServer();
@ -128,7 +129,7 @@ public class WebServer {
enabled = true;
Log.info(Phrase.WEBSERVER_RUNNING.parse(String.valueOf(server.getAddress().getPort())));
Log.info(Locale.get(Msg.ENABLE_WEBSERVER_INFO).parse(server.getAddress().getPort()));
} catch (IllegalArgumentException | IllegalStateException | IOException e) {
Log.toLog(this.getClass().getName(), e);
enabled = false;
@ -359,7 +360,7 @@ public class WebServer {
* Shuts down the server - Async thread is closed with shutdown boolean.
*/
public void stop() {
Log.info(Phrase.WEBSERVER_CLOSE.toString());
Log.info(Locale.get(Msg.DISABLE_WEBSERVER).toString());
if (server != null) {
server.stop(0);
}

View File

@ -2,16 +2,16 @@ package main.java.com.djrapitops.plan.utilities;
import main.java.com.djrapitops.plan.Plan;
import main.java.com.djrapitops.plan.Settings;
import main.java.com.djrapitops.plan.locale.Locale;
import main.java.com.djrapitops.plan.locale.Msg;
import main.java.com.djrapitops.plan.ui.html.Html;
import main.java.com.djrapitops.plan.ui.webserver.WebServer;
import main.java.com.djrapitops.plan.utilities.file.FileUtil;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.InputStream;
import java.io.Serializable;
import java.util.List;
import java.util.Map;
import java.util.Scanner;
/**
* @author Rsl1122
@ -31,28 +31,7 @@ public class HtmlUtils {
* @throws FileNotFoundException
*/
public static String getStringFromResource(String fileName) throws FileNotFoundException {
InputStream resourceStream = null;
Scanner scanner = null;
try {
Plan plugin = Plan.getInstance();
File localFile = new File(plugin.getDataFolder(), fileName);
if (localFile.exists()) {
scanner = new Scanner(localFile, "UTF-8");
} else {
resourceStream = plugin.getResource(fileName);
scanner = new Scanner(resourceStream);
}
StringBuilder html = new StringBuilder();
while (scanner.hasNextLine()) {
String line = scanner.nextLine();
html.append(line).append("\r\n");
}
return html.toString();
} finally {
MiscUtils.close(resourceStream, scanner);
}
return FileUtil.getStringFromResource(fileName);
}
/**
@ -121,7 +100,7 @@ public class HtmlUtils {
*/
public static String getInspectUrl(String playerName) {
String ip = getIP();
return "//" + ip + "/player/" + playerName;
return "//" + ip + "/player/" + playerName.replace(" ", "%20").replace(".", "%2E");
}
public static String getRelativeInspectUrl(String playerName) {
@ -167,7 +146,7 @@ public class HtmlUtils {
return Html.COLUMNS_DIV_WRAPPER.parse(
Html.COLUMN_DIV_WRAPPER.parse(
Html.PLUGIN_DATA_WRAPPER.parse(
Html.NO_PLUGINS.parse()
Locale.get(Msg.HTML_NO_PLUGINS).toString()
)
)
);

View File

@ -3,17 +3,18 @@ package main.java.com.djrapitops.plan.utilities;
import com.djrapitops.plugin.api.TimeAmount;
import com.djrapitops.plugin.command.CommandUtils;
import com.djrapitops.plugin.command.ISender;
import com.djrapitops.plugin.utilities.player.Fetch;
import com.djrapitops.plugin.utilities.player.IOfflinePlayer;
import main.java.com.djrapitops.plan.Log;
import main.java.com.djrapitops.plan.Permissions;
import main.java.com.djrapitops.plan.Phrase;
import main.java.com.djrapitops.plan.Plan;
import main.java.com.djrapitops.plan.data.UserData;
import main.java.com.djrapitops.plan.database.Database;
import main.java.com.djrapitops.plan.locale.Locale;
import main.java.com.djrapitops.plan.locale.Msg;
import java.io.Closeable;
import java.io.IOException;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
import java.util.TimeZone;
import java.sql.SQLException;
import java.util.*;
import java.util.stream.Collectors;
/**
@ -72,7 +73,7 @@ public class MiscUtils {
} else if (args[0].equalsIgnoreCase(sender.getName())) {
playerName = sender.getName();
} else {
sender.sendMessage(Phrase.COMMAND_NO_PERMISSION.toString());
sender.sendMessage(Locale.get(Msg.CMD_FAIL_NO_PERMISSION).toString());
}
} else {
playerName = sender.getName();
@ -88,10 +89,17 @@ public class MiscUtils {
*/
public static List<String> getMatchingPlayerNames(String search) {
final String searchFor = search.toLowerCase();
List<String> matches = Fetch.getIOfflinePlayers().stream()
.map(IOfflinePlayer::getName)
.filter(name -> name.toLowerCase().contains(searchFor))
.collect(Collectors.toList());
Database db = Plan.getInstance().getDB();
List<String> matches = new ArrayList<>();
try {
List<UserData> data = db.getUserDataForUUIDS(db.getSavedUUIDs());
matches = data.stream()
.map(UserData::getName)
.filter(name -> name.toLowerCase().contains(searchFor))
.collect(Collectors.toList());
} catch (SQLException e) {
Log.toLog("MiscUtils.getMatchingPlayerNames", e);
}
Collections.sort(matches);
return matches;
}

View File

@ -8,7 +8,8 @@ import main.java.com.djrapitops.plan.data.UserData;
import main.java.com.djrapitops.plan.data.analysis.GamemodePart;
import main.java.com.djrapitops.plan.data.time.WorldTimes;
import main.java.com.djrapitops.plan.database.tables.GMTimesTable;
import main.java.com.djrapitops.plan.ui.html.Html;
import main.java.com.djrapitops.plan.locale.Locale;
import main.java.com.djrapitops.plan.locale.Msg;
import main.java.com.djrapitops.plan.ui.html.graphs.PlayerActivityGraphCreator;
import main.java.com.djrapitops.plan.ui.html.graphs.PunchCardGraphCreator;
import main.java.com.djrapitops.plan.ui.html.graphs.SessionLengthDistributionGraphCreator;
@ -39,7 +40,6 @@ public class PlaceholderUtils {
* @return HashMap that contains string for each placeholder.
*/
public static Map<String, Serializable> getAnalysisReplaceRules(AnalysisData data) {
Benchmark.start("Replace Placeholders Analysis");
HashMap<String, Serializable> replaceMap = new HashMap<>();
replaceMap.putAll(data.getReplaceMap());
replaceMap.put("%plugins%", data.replacePluginsTabLayout());
@ -59,7 +59,6 @@ public class PlaceholderUtils {
replaceMap.put("#" + defaultCols[i], "#" + colors[i]);
}
}
Benchmark.stop("Replace Placeholders Analysis");
return replaceMap;
}
@ -70,20 +69,19 @@ public class PlaceholderUtils {
* @return HashMap that contains string for each placeholder.
*/
public static Map<String, Serializable> getInspectReplaceRules(UserData data) {
Benchmark.start("Replace Placeholders Inspect");
HashMap<String, Serializable> replaceMap = new HashMap<>();
replaceMap.put("%timezone%", MiscUtils.getTimeZoneOffsetHours());
boolean showIPandUUID = Settings.SECURITY_IP_UUID.isTrue();
UUID uuid = data.getUuid();
replaceMap.put("%uuid%", (showIPandUUID ? uuid.toString() : Html.HIDDEN.parse()));
replaceMap.put("%uuid%", (showIPandUUID ? uuid.toString() : "Hidden (Config)"));
replaceMap.put("%lastseen%", FormatUtils.formatTimeStampYear(data.getLastPlayed()));
replaceMap.put("%logintimes%", data.getLoginTimes());
replaceMap.put("%geoloc%", data.getGeolocation());
long now = MiscUtils.getTime();
boolean isActive = AnalysisUtils.isActive(now, data.getLastPlayed(), data.getPlayTime(), data.getLoginTimes());
replaceMap.put("%active%", isActive ? Html.ACTIVE.parse() : Html.INACTIVE.parse());
replaceMap.put("%active%", isActive ? Locale.get(Msg.HTML_ACTIVE).parse() : Locale.get(Msg.HTML_INACTIVE).parse());
GamemodePart gmPart = new GamemodePart();
Map<String, Long> gmTimes = data.getGmTimes().getTimes();
String[] gms = GMTimesTable.getGMKeyArray();
@ -96,15 +94,15 @@ public class PlaceholderUtils {
gmPart.analyse();
replaceMap.putAll(gmPart.getReplaceMap());
replaceMap.put("%ips%", (showIPandUUID ? data.getIps().toString() : Html.HIDDEN.parse()));
replaceMap.put("%ips%", (showIPandUUID ? data.getIps().toString() : "Hidden (Config)"));
replaceMap.put("%nicknames%", HtmlUtils.removeXSS(HtmlUtils.swapColorsToSpan(data.getNicknames().toString())));
replaceMap.put("%name%", data.getName());
replaceMap.put("%registered%", FormatUtils.formatTimeStampYear(data.getRegistered()));
replaceMap.put("%timeskicked%", "" + data.getTimesKicked());
replaceMap.put("%playtime%", FormatUtils.formatTimeAmount(data.getPlayTime()));
replaceMap.put("%banned%", data.isBanned() ? Html.BANNED.parse() : "");
replaceMap.put("%op%", data.isOp() ? Html.OPERATOR.parse() : "");
replaceMap.put("%isonline%", (data.isOnline()) ? Html.ONLINE.parse() : Html.OFFLINE.parse());
replaceMap.put("%banned%", data.isBanned() ? Locale.get(Msg.HTML_BANNED).parse() : "");
replaceMap.put("%op%", data.isOp() ? Locale.get(Msg.HTML_OP).parse() : "");
replaceMap.put("%isonline%", (data.isOnline()) ? Locale.get(Msg.HTML_ONLINE).parse() : Locale.get(Msg.HTML_OFFLINE).parse());
replaceMap.put("%deaths%", data.getDeaths());
replaceMap.put("%playerkills%", data.getPlayerKills().size());
replaceMap.put("%mobkills%", data.getMobKills());
@ -138,7 +136,6 @@ public class PlaceholderUtils {
Map<String, Serializable> additionalReplaceRules = plugin.getHookHandler().getAdditionalInspectReplaceRules(uuid);
String replacedOnce = HtmlUtils.replacePlaceholders(pluginsTabHtml, additionalReplaceRules);
replaceMap.put("%plugins%", HtmlUtils.replacePlaceholders(replacedOnce, additionalReplaceRules));
Benchmark.stop("Replace Placeholders Inspect");
return replaceMap;
}
}

View File

@ -3,7 +3,6 @@ package main.java.com.djrapitops.plan.utilities.analysis;
import com.djrapitops.plugin.task.AbsRunnable;
import com.djrapitops.plugin.utilities.Verify;
import main.java.com.djrapitops.plan.Log;
import main.java.com.djrapitops.plan.Phrase;
import main.java.com.djrapitops.plan.Plan;
import main.java.com.djrapitops.plan.Settings;
import main.java.com.djrapitops.plan.data.*;
@ -16,6 +15,8 @@ import main.java.com.djrapitops.plan.data.cache.DataCacheHandler;
import main.java.com.djrapitops.plan.data.cache.InspectCacheHandler;
import main.java.com.djrapitops.plan.data.cache.PageCacheHandler;
import main.java.com.djrapitops.plan.database.Database;
import main.java.com.djrapitops.plan.locale.Locale;
import main.java.com.djrapitops.plan.locale.Msg;
import main.java.com.djrapitops.plan.ui.html.tables.PlayersTableCreator;
import main.java.com.djrapitops.plan.ui.webserver.response.AnalysisPageResponse;
import main.java.com.djrapitops.plan.ui.webserver.response.PlayersPageResponse;
@ -62,7 +63,7 @@ public class Analysis {
}
Benchmark.start("Analysis");
log(Phrase.ANALYSIS_START.toString());
log(Locale.get(Msg.ANALYSIS_START).toString());
// Async task for Analysis
plugin.getRunnableFactory().createNew(new AbsRunnable("AnalysisTask") {
@Override
@ -84,7 +85,7 @@ public class Analysis {
* @return Whether or not analysis was successful.
*/
public boolean analyze(AnalysisCacheHandler analysisCache, Database db) {
log(Phrase.ANALYSIS_FETCH_DATA.toString());
log(Locale.get(Msg.ANALYSIS_FETCH).toString());
Benchmark.start("Fetch Phase");
Log.debug("Database", "Analysis Fetch");
plugin.processStatus().setStatus("Analysis", "Analysis Fetch Phase");
@ -92,12 +93,12 @@ public class Analysis {
inspectCache.cacheAllUserData(db);
} catch (Exception ex) {
Log.toLog(this.getClass().getName(), ex);
Log.error(Phrase.ERROR_ANALYSIS_FETCH_FAIL.toString());
Log.error(Locale.get(Msg.ANALYSIS_FAIL_FETCH_EXCEPTION).toString());
}
List<UserData> rawData = inspectCache.getCachedUserData();
if (rawData.isEmpty()) {
Log.info(Phrase.ANALYSIS_FAIL_NO_DATA.toString());
Log.info(Locale.get(Msg.ANALYSIS_FAIL_NO_DATA).toString());
return false;
}
@ -141,7 +142,7 @@ public class Analysis {
Benchmark.start("Analysis Phase");
plugin.processStatus().setStatus("Analysis", "Analysis Phase");
log(Phrase.ANALYSIS_BEGIN_ANALYSIS.parse(String.valueOf(rawData.size()), String.valueOf(fetchPhaseLength)));
log(Locale.get(Msg.ANALYSIS_PHASE_START).parse(rawData.size(), fetchPhaseLength));
String playersTable = PlayersTableCreator.createSortablePlayersTable(rawData);
analysisData.setPlayersTable(playersTable);
@ -151,7 +152,7 @@ public class Analysis {
analysisData.analyseData();
Benchmark.stop("Analysis", "Analysis Phase");
log(Phrase.ANALYSIS_THIRD_PARTY.toString());
log(Locale.get(Msg.ANALYSIS_3RD_PARTY).toString());
plugin.processStatus().setStatus("Analysis", "Analyzing additional data sources (3rd party)");
analysisData.setAdditionalDataReplaceMap(analyzeAdditionalPluginData(uuids));
@ -161,12 +162,12 @@ public class Analysis {
Log.logDebug("Analysis", time);
if (Settings.ANALYSIS_LOG_FINISHED.isTrue()) {
Log.info(Phrase.ANALYSIS_COMPLETE.parse(String.valueOf(time), HtmlUtils.getServerAnalysisUrlWithProtocol()));
Log.info(Locale.get(Msg.ANALYSIS_FINISHED).parse(String.valueOf(time), HtmlUtils.getServerAnalysisUrlWithProtocol()));
}
ExportUtility.export(plugin, analysisData, rawData);
PageCacheHandler.cachePage("analysisPage", () -> new AnalysisPageResponse(plugin.getUiServer().getDataReqHandler()));
PageCacheHandler.cachePage("players", () -> new PlayersPageResponse(plugin));
ExportUtility.export(plugin, analysisData, rawData);
} catch (Exception e) {
Log.toLog(this.getClass().getName(), e);
plugin.processStatus().setStatus("Analysis", "Error: " + e);

View File

@ -6,6 +6,7 @@ import main.java.com.djrapitops.plan.Settings;
import main.java.com.djrapitops.plan.data.AnalysisData;
import main.java.com.djrapitops.plan.data.UserData;
import main.java.com.djrapitops.plan.ui.webserver.response.PlayersPageResponse;
import main.java.com.djrapitops.plan.utilities.Benchmark;
import main.java.com.djrapitops.plan.utilities.HtmlUtils;
import main.java.com.djrapitops.plan.utilities.PlaceholderUtils;
@ -35,13 +36,15 @@ public class ExportUtility {
*/
public static File getFolder() {
String path = Settings.ANALYSIS_EXPORT_PATH.toString();
if (Paths.get(path).isAbsolute()) {
Log.debug("Export", "Path: " + path);
boolean isAbsolute = Paths.get(path).isAbsolute();
Log.debug("Export", "Absolute: " + (isAbsolute ? "Yes" : "No"));
if (isAbsolute) {
File folder = new File(path);
if (folder.exists()
&& folder.isDirectory()) {
return folder;
if (!folder.exists() || !folder.isDirectory()) {
folder.mkdirs();
}
folder.mkdirs();
return folder;
}
File dataFolder = Plan.getInstance().getDataFolder();
@ -59,21 +62,24 @@ public class ExportUtility {
if (!Settings.ANALYSIS_EXPORT.isTrue()) {
return;
}
String processName = "Exporting Html pages";
plugin.processStatus().startExecution(processName);
Benchmark.start("Exporting Html pages");
try {
File folder = getFolder();
Log.debug("Export", "Folder: " + folder.getAbsolutePath());
writePlayersPageHtml(rawData, new File(folder, "players"));
writeAnalysisHtml(analysisData, new File(folder, "server"));
File playersFolder = getPlayersFolder(folder);
plugin.processStatus().setStatus(processName, "Player html files.");
for (UserData userData : rawData) {
writeInspectHtml(userData, playersFolder);
}
Log.debug("Export", "Player html files.");
Log.debug("Export", "Player Page Folder: " + playersFolder.getAbsolutePath());
String playerHtml = HtmlUtils.getStringFromResource("player.html");
rawData.forEach(userData -> {
writeInspectHtml(userData, playersFolder, playerHtml);
});
} catch (IOException ex) {
Log.toLog("ExportUtils.export", ex);
} finally {
plugin.processStatus().finishExecution(processName);
Benchmark.stop("Export", "Exporting Html pages");
Log.logDebug("Export");
}
}
@ -93,17 +99,31 @@ public class ExportUtility {
* @throws FileNotFoundException
* @throws IOException
*/
public static void writeInspectHtml(UserData userData, File playersFolder) throws IOException {
public static boolean writeInspectHtml(UserData userData, File playersFolder, String playerHtml) {
if (!Settings.ANALYSIS_EXPORT.isTrue()) {
return;
return false;
}
String inspectHtml = HtmlUtils.replacePlaceholders(HtmlUtils.getStringFromResource("player.html"),
PlaceholderUtils.getInspectReplaceRules(userData));
File playerFolder = new File(playersFolder, userData.getName());
playerFolder.mkdir();
File inspectHtmlFile = new File(playerFolder, "index.html");
inspectHtmlFile.delete();
Files.write(inspectHtmlFile.toPath(), Collections.singletonList(inspectHtml));
String name = userData.getName();
if (name.endsWith(".")) {
name = name.replace(".", "%2E");
}
if (name.endsWith(" ")) {
name = name.replace(" ", "%20");
}
try {
String inspectHtml = HtmlUtils.replacePlaceholders(playerHtml,
PlaceholderUtils.getInspectReplaceRules(userData));
File playerFolder = new File(playersFolder, name);
playerFolder.mkdirs();
File inspectHtmlFile = new File(playerFolder, "index.html");
inspectHtmlFile.createNewFile();
Files.write(inspectHtmlFile.toPath(), Collections.singletonList(inspectHtml));
} catch (IOException e) {
Log.toLog("Export.inspectPage: " + name, e);
return false;
}
return true;
}
/**
@ -116,12 +136,13 @@ public class ExportUtility {
if (!Settings.ANALYSIS_EXPORT.isTrue()) {
return;
}
serverFolder.mkdirs();
String analysisHtml = HtmlUtils.replacePlaceholders(HtmlUtils.getStringFromResource("analysis.html"),
PlaceholderUtils.getAnalysisReplaceRules(analysisData))
.replace(HtmlUtils.getInspectUrl(""), "../player/");
File analysisHtmlFile = new File(serverFolder, "index.html");
analysisHtmlFile.delete();
Log.debug("Export", "Analysis Page File: " + analysisHtmlFile.getAbsolutePath());
analysisHtmlFile.createNewFile();
Files.write(analysisHtmlFile.toPath(), Collections.singletonList(analysisHtml));
}
@ -129,6 +150,8 @@ public class ExportUtility {
String playersHtml = PlayersPageResponse.buildContent(rawData);
playersFolder.mkdirs();
File playersHtmlFile = new File(playersFolder, "index.html");
Log.debug("Export", "Players Page File: " + playersHtmlFile.getAbsolutePath());
playersHtmlFile.createNewFile();
Files.write(playersHtmlFile.toPath(), Collections.singletonList(playersHtml));
}

View File

@ -0,0 +1,22 @@
package main.java.com.djrapitops.plan.utilities.comparators;
import main.java.com.djrapitops.plan.locale.Message;
import main.java.com.djrapitops.plan.locale.Msg;
import org.apache.commons.lang3.StringUtils;
import java.util.Comparator;
import java.util.Map;
/**
* Compares Locale Map Entries and sorts them alphabetically according to the Enum Names.
*
* @since 3.6.2
* @author Rsl1122
*/
public class LocaleEntryComparator implements Comparator<Map.Entry<Msg, Message>> {
@Override
public int compare(Map.Entry<Msg, Message> o1, Map.Entry<Msg, Message> o2) {
return StringUtils.compare(o1.getKey().name(), o2.getKey().name());
}
}

View File

@ -0,0 +1,17 @@
package main.java.com.djrapitops.plan.utilities.comparators;
import java.util.Comparator;
/**
* Compares Strings & sorts them by length
*
* @author Rsl1122
* @since 3.6.2
*/
public class StringLengthComparator implements Comparator<String> {
@Override
public int compare(String o1, String o2) {
return -Integer.compare(o1.length(), o2.length());
}
}

View File

@ -0,0 +1,58 @@
package main.java.com.djrapitops.plan.utilities.file;
import main.java.com.djrapitops.plan.Plan;
import main.java.com.djrapitops.plan.utilities.MiscUtils;
import org.bukkit.plugin.java.JavaPlugin;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;
public class FileUtil {
public static String getStringFromResource(String fileName) throws FileNotFoundException {
InputStream resourceStream = null;
Scanner scanner = null;
try {
Plan plugin = Plan.getInstance();
File localFile = new File(plugin.getDataFolder(), fileName);
if (localFile.exists()) {
scanner = new Scanner(localFile, "UTF-8");
} else {
resourceStream = plugin.getResource(fileName);
scanner = new Scanner(resourceStream);
}
StringBuilder html = new StringBuilder();
while (scanner.hasNextLine()) {
String line = scanner.nextLine();
html.append(line).append("\r\n");
}
return html.toString();
} finally {
MiscUtils.close(resourceStream, scanner);
}
}
public static List<String> lines(JavaPlugin plugin, String resource) throws IOException {
List<String> lines = new ArrayList<>();
Scanner scanner = null;
try (InputStream inputStream = plugin.getResource(resource)) {
scanner = new Scanner(inputStream, "UTF-8");
while (scanner.hasNextLine()) {
lines.add(scanner.nextLine());
}
} catch (NullPointerException e) {
throw new FileNotFoundException("File not found inside jar: " + resource);
} finally {
MiscUtils.close(scanner);
}
return lines;
}
}

View File

@ -1,4 +1,4 @@
package main.java.com.djrapitops.plan.utilities.dump;
package main.java.com.djrapitops.plan.utilities.file.dump;
import main.java.com.djrapitops.plan.Log;
import org.json.simple.JSONObject;

View File

@ -1,4 +1,4 @@
package main.java.com.djrapitops.plan.utilities.dump;
package main.java.com.djrapitops.plan.utilities.file.dump;
import main.java.com.djrapitops.plan.Log;
import main.java.com.djrapitops.plan.Plan;

View File

@ -274,6 +274,8 @@
</style>
</head>
<body onload="countUpTimer()">
@ -576,22 +578,24 @@
</div>
</div>
</div>
<table class="sortable table" style="height: 100%; max-height: 800px; overflow: auto;">
<thead>
<tr>
<th><i class="fa fa-user" aria-hidden="true"></i> Player</th>
<th><i class="fa fa-check" aria-hidden="true"></i> Active</th>
<th><i class="fa fa-clock-o" aria-hidden="true"></i> Playtime</th>
<th><i class="fa fa-calendar-plus-o" aria-hidden="true"></i> Login times</th>
<th><i class="fa fa-user-plus" aria-hidden="true"></i> Registered</th>
<th><i class="fa fa-calendar-check-o" aria-hidden="true"></i> Last seen</th>
<th><i class="fa fa-globe" aria-hidden="true"></i> Geolocation</th>
</tr>
</thead>
<tbody>
%sortabletable%
</tbody>
</table>
<div style="max-height: 800px; overflow: scroll;">
<table class="sortable table">
<thead>
<tr>
<th><i class="fa fa-user" aria-hidden="true"></i> Player</th>
<th><i class="fa fa-check" aria-hidden="true"></i> Active</th>
<th><i class="fa fa-clock-o" aria-hidden="true"></i> Playtime</th>
<th><i class="fa fa-calendar-plus-o" aria-hidden="true"></i> Login times</th>
<th><i class="fa fa-user-plus" aria-hidden="true"></i> Registered</th>
<th><i class="fa fa-calendar-check-o" aria-hidden="true"></i> Last seen</th>
<th><i class="fa fa-globe" aria-hidden="true"></i> Geolocation</th>
</tr>
</thead>
<tbody>
%sortabletable%
</tbody>
</table>
</div>
</div>
</div>
</div>
@ -617,17 +621,19 @@
</div>
</div>
</div>
<table class="sortable table" style="height: 100%; max-height: 800px; overflow: auto;">
<thead>
<tr>
<th><i class="fa fa-chevron-right" aria-hidden="true"></i> Command</th>
<th><i class="fa fa-list-ol" aria-hidden="true"></i> Times used</th>
</tr>
</thead>
<tbody>
%commanduse%
</tbody>
</table>
<div style="max-height: 800px; overflow: scroll;">
<table class="sortable table">
<thead>
<tr>
<th><i class="fa fa-chevron-right" aria-hidden="true"></i> Command</th>
<th><i class="fa fa-list-ol" aria-hidden="true"></i> Times used</th>
</tr>
</thead>
<tbody>
%commanduse%
</tbody>
</table>
</div>
</div>
</div>
</div>
@ -794,6 +800,8 @@
data: %punchcardseries%
};
</script>
<script>
function playersChart() {
@ -865,6 +873,8 @@
});
}
</script>
<script>
function tpsChart() {
@ -928,6 +938,8 @@
});
}
</script>
<script>
function resourceChart() {
@ -991,6 +1003,8 @@
});
}
</script>
<script>
function worldChart() {
@ -1054,6 +1068,8 @@
});
}
</script>
<script>
function activityPie() {
@ -1084,6 +1100,8 @@
});
};
</script>
<script>
function worldPie() {
@ -1113,6 +1131,8 @@
});
};
</script>
<script>
function gmPie() {
@ -1141,6 +1161,8 @@
});
};
</script>
<script>
function punchCard() {
@ -1168,6 +1190,8 @@
});
}
</script>
<script>
function sessionDistributionChart() {
@ -1203,6 +1227,8 @@
});
};
</script>
<script>
function worldMap() {
@ -1223,6 +1249,8 @@
});
}
</script>
<script>
// Navigation & Refresh time clock
@ -1316,6 +1344,8 @@
setTimeout('countUpTimer()', 1000);
}
</script>
</div>
</body>

View File

@ -1,6 +1,7 @@
Settings:
Debug: false
Locale: default
WriteNewLocaleFileOnStart: false
UseTextUI: false
Data:
ChatListener: true

View File

@ -0,0 +1,118 @@
Analysis - Third Party || Analysis | Analyzing additional data sources (3rd party)
Analysis FAIL - Fetch Exception || Analysis | Failed to fetch data for Analysis, Exception occurred.
Analysis FAIL - No Data || Analyse | Analyse fehlgeschlagen, keine Daten in der Datenbank.
Analysis FAIL - No Players || Analyse | Analyse fehlgeschlagen, keine bekannten Spieler.
Analysis - Fetch Phase || Analyse | Hole Daten...
Analysis - Fetch Phase Start || Analyse | Suche nach verfügbaren Spieler...
Analysis - Complete || Analyse | Analyse vollständig. (dauerte REPLACE0ms) REPLACE1
Analysis - Begin Analysis || Analyse | Daten geholt (REPLACE0 spieler, dauerte REPLACE1ms), beginne mit der Analyse der Daten...
Analysis - Start || Analyse | Beginne die Analyse der Spieler Daten...
>Constant - CMD Footer || §f»
>Constant - List Ball || §7 •§2
Cmd FAIL - No Data View || §e[Plan] Dieser Befehl kann nur benutzt werden wenn Webserver/TextUI auf dem Server aktiviert ist.
Cmd FAIL - No Permission || §c[Plan] Du hast nicht die benötigte Berechtigung.
Cmd FAIL - Requires Arguments || §c[Plan] Dieser Befehl erfordert Argumente. REPLACE0
Cmd FAIL - Require only one Argument || §c[Plan] Der Befehl benötigt ein Argument.
Cmd FAIL - Timeout || §c[Plan] REPLACE0 Befehl ausgetimed! Ansehen '/plan status' & Serverkonsole.
Cmd FAIL - Unknown Username || §c[Plan] Der Spielername konnte in der Datenbank nicht gefunden werden.
Cmd FAIL - Unseen Username || §c[Plan] Dieser Spieler war noch nie auf diesem Server.
Cmd FAIL - Invalid Username || §c[Plan] Dieser Spieler existiert nicht.
Cmd Header - Analysis || §f»§2 Player Analytics - Analyse Ergebnisse
Cmd Header - Info || §f»§2 Player Analytics - Info
Cmd Header - Inspect || §f»§2 Player Analytics - Überprüfe die Ergebnisse:
Cmd Header - Search || §f»§2 Player Analytics - Suchergebnisse für:
In Depth Help - /plan analyze ? || §2Analysis Command\§f Used to Refresh analysis cache & Access the result page\§7 /plan status can be used to check status of analysis while it is running.\§7 Aliases: analyze, analyse, analysis, a
In Depth Help - /plan inspect ? || §2Inspect command\§f Used to get a link to User's inspect page.\§7 Own inspect page can be accessed with /plan inspect\§7 Alias: /plan <name>
In Depth Help - /plan list ? || §2List command\§f Used to get a link to players page.\§7 Players page contains links to all cached inspect pages.\§7 Alias: /plan pl
In Depth Help - /plan manage ? || §2Manage command\§f Used to Manage Database of the plugin.\§7 Alias: /plan m\§7 /plan m - List subcommands\§7 /plan m <subcommand> ? - in depth help
In Depth Help - /plan manage clear ? || §2Manage Clear command\§f Used to delete ALL data in the active database.\§7 Plugin should be reloaded after successful clear.\§7 Alias: /plan pl
In Depth Help - /plan manage dump ? || §2Manage Dump command\§f Used to dump important data for bug reporting to hastebin.
In Depth Help - /plan manage hotswap ? || §2Manage Hotswap command\§f Used to change database in use on the fly.\§7 Does not change database if connection fails
In Depth Help - /plan manage import ? || §2Manage Import command\§f Used to import data from other sources\§7 Analysis will be disabled during import.
In Depth Help - /plan manage remove ? || §2Manage Remove command\§f Used to Remove user's data from the active database.
In Depth Help - /plan ? || §2/plan - Main Command\§f Used to access all SubCommands & help\§7 /plan - List subcommands\§7 /plan <subcommand> ? - in depth help
In Depth Help - /plan qanalyze ? || §2Quick Analysis command\§f Used to get in game info about analysis.\§7 Has less info than full Analysis web page.\§7 Aliases: qanalyze, ganalyse, qanalysis, qa
In Depth Help - /plan qinspect ? || §2Quick Inspect command\§f Used to get some inspect info in game.\§7 Has less info than full Inspect web page.\§7 Alias: /plan qi
In Depth Help - /plan search ? || §2Search command\§f Used to get a list of Player names that match the given argument.\§7 Example: /plan search 123 - Finds all users with 123 in their name.
In Depth Help - /plan webuser ? || §2Web User Manage command\§f Used to manage web users of the plugin\§7 Users have a permission level:\§f 0 - Access to all pages\§f 1 - Access to /players & all inspect pages\§f 2 - Access to own inspect page\§7 Alias: /plan web
In Depth Help - /plan webuser register ? || §2Web Register command\§f Used to register a new user for the webserver.\§7 Registering a user for another player requires plan.webmanage permission.\§7 Passwords are hashed with PBKDF2 (64,000 iterations of SHA1) using a cryptographically-random salt.
Analysis NOTIFY - Temporary Disable || §eAnalysis has been temporarily disabled due to expensive task, use /plan status for info.
Cmd - Click Me || Klick Mich
Cmd - Fetch Data || §f»§2 Hole Daten ins Cache...
Cmd - Link || §7 •§2 Link: §f
Cmd - No Results || §7 •§2 Keine Ergebnisse für §7REPLACE0§2.
Cmd - Reload Success || §a[Plan] Reload abgeschlossen.
Cmd - Results || §7 Übereinstimmender Spieler: §f
Cmd - Searching || §f»§2Searching..
Cmd - Usage /plan analyze || Zeige die Server Analyse
Cmd - Usage /plan help || Show command list.
Cmd - Usage /plan info || Zeige die Version von Plan
Cmd - Usage /plan inspect || Prüfe Spieler Daten
Cmd - Usage /plan list || List to all cached players
Cmd - Usage /plan manage || Datenbank Management Befehl
Cmd - Usage /plan manage backup || Erstelle eine Sicherheitskopie der Datenbank als .db Datei
Cmd - Usage /plan manage clean || Clear old data from the database
Cmd - Usage /plan manage clear || Leere Daten aus einer Datenbank
Cmd - Usage /plan manage dump || Create a Hastebin log for Dev for easier Issue reporting.
Cmd - Usage /plan manage hotswap || Wechsle zu einer anderen Datenbank & starte das Plugin neu
Cmd - Usage /plan manage import || Importiere Daten von unterstützten Plugins zur aktiven Datenbank.
Cmd - Usage /plan manage move || Kopiere Daten von einer Datenbank zur anderen & überschreibe die Werte
Cmd - Usage /plan manage remove || Entferne die Spieler Daten aus der aktiven Datenbank.
Cmd - Usage /plan manage restore || Stelle eine Sicherheitskopie einer Datenbank aus einer Datei wieder her.
Cmd - Usage /plan qanalyze || View the Server Analysis as Text
Cmd - Usage /plan qinspect || Inspect Player's Data as Text
Cmd - Usage /plan reload || Lade die Plugin Konfiguration neu.
Cmd - Usage /plan search || Suche nach einem Spieler
Cmd - Usage /plan webuser || Manage Webusers
Cmd - Usage /plan webuser check || Check a webuser and their permission level.
Cmd - Usage /plan webuser delete || Delete a webuser
Cmd - Usage /plan webuser level || Info about permission levels.
Cmd - Usage /plan webuser register || Register a user for the webserver
Disable || Player Analytics deaktiviert.
Disable - Save || Daten im Cache werden gespeichert...
Disable - WebServer || Webserver wird heruntergefahren...
Enable || Player Analytics aktiviert.
Enable - Boot Analysis 30s Notify || Analyse | Boot Analyse in 30 Sekunden...
Enable - Boot Analysis Notify || Analyse | Starte Boot Analyse...
Enable Db FAIL - Disable Info || Datenbank Initialisierung fehlgeschlagen, deaktiviere Plan.
Enable - Db Info || REPLACE0-Datenbank Verbindung hergestellt.
Enable - Db || Datenbank Initialisierung...
Enable FAIL-Db || REPLACE0-Datenbank Verbindung fehlgeschlagen: REPLACE1
Enable FAIL - Wrong Db Type || Dieser Datenbank Typ existiert nicht.
Enable Notify - ChatListener || §eChat listener disabled, nickname info inaccurate.
Enable Notify - Disabled CommandListener || §eCommand usage listener disabled.
Enable Notify - Disabled DeathListener || §eDeath listener disabled, player & mob kills not recorded.
Enable Notify-Empty IP || §e[Plan] IP in server.properties ist leer & Alternative ServerIP wird nicht benutzt, fehlerhafte Links werden ausgegeben!
Enable Notify - No data view || §eWebserver deaktiviert aber Alternative IP/PlanLite wird nicht benutzt, Daten können nicht angezeigt werden!
Enable - WebServer || Initialisiere Webserver...
Enable - WebServer Info || Webserver läuft auf PORT REPLACE0
Html - Active || Spieler ist aktiv
Html - Banned || | <span class="darkred">Gesperrt</span>
Html - Inactive || Spieler ist inaktiv
Html - No Extra Plugins || <p>No extra plugins registered.</p>
Html - Offline || | <span class="darkred">Offline</span>
Html - Online || | <span class="darkgreen">Online</span>
Html - OP || , Operator (Op)
Html - Table No Kills || No Kills
Manage FAIL - Confirm Action || §c[Plan] Füge -a hinzu um den Befehl zu bestätigen! REPLACE0
Manage FAIL - Faulty DB Connection || §c[Plan] Eine der Datenbanken wurde nicht richtig initialisiert.
Manage FAIL - Backup File Not Found || §c[Plan] Sicherheitskopie existiert nicht!
Manage FAIL - Incorrect DB || §c[Plan] Falsche Datenbank! (SQlite/MySQL wird unterstützt):
Manage FAIL - Incorrect Plugin || §c[Plan] Plugin nicht unterstützt:
Manage FAIL - Empty DB || §c[Plan] Datenbank hat keine Spieler Daten!
Manage FAIL - Unenabled Plugin || §c[Plan] Plugin ist nicht aktiviert:
Manage FAIL - Same DB || §c[Plan] Kann nicht zur selben Datenbank bewegen!
Manage - Clear Success || §a[Plan] Alle Daten wurden erfolgreich gesäubert!
Manage - Remind Config Change || §e[Plan] Vergiss nicht zur neuen Datenbank zu wechseln und das Plugin neu zu laden
Manage - Copy Success || §a[Plan] Alle Daten wurden erfolgreich kopiert!
Manage - Process Fail || §c[Plan] Irgendwas lief schief während die Daten verarbeitet wurden!
Manage - Import || §f» §2 Importiere Daten...
Manage - Move Success || §a[Plan] Alle Daten wurden erfolgreich verschoben!
Manage - Remove Success || §f» §2Daten von §fREPLACE0§2 wurden aus dieser Datenbank entfernt §fREPLACE1§2.
Manage - Start || Ȥ7 Verarbeite Daten...
Manage - Success || §f» §2 Erfolgreich!
Manage NOTIFY - Overwrite || Daten in REPLACE0-Datenbank werden überschrieben!
Manage NOTIFY - Partial Overwrite || Einige Daten in REPLACE0-Datenbank werden überschrieben!
Manage NOTIFY - Remove || Daten in REPLACE0-Datenbank werden entfernt!
Manage NOTIFY - Rewrite || Daten in REPLACE0-Datenbank werden neu geschrieben!
WARN - Too Small Queue Size || Queue size is too small! (REPLACE0), change the setting to a higher number! (Currently REPLACE1)

View File

@ -0,0 +1,118 @@
Analysis - Third Party || Analyysi | Analysoidaan Kolmannen osapuolen lähteitä
Analysis FAIL - Fetch Exception || Analyysi | Datan haku ei onnistunut, Virhe.
Analysis FAIL - No Data || Analyysi | Analyysi ei onnistunut, Ei dataa.
Analysis FAIL - No Players || Analyysi | Analyysi ei onnistunut, Ei tunnettuja pelaajia
Analysis - Fetch Phase || Analyysi | Haetaan Dataa..
Analysis - Fetch Phase Start || Analyysi | Tarkistetaan saatavilla olevia pelaajia..
Analysis - Complete || Analyysi | Analyysi Valmis. (meni REPLACE0ms) REPLACE1
Analysis - Begin Analysis || Analyysi | Data Haettu (REPLACE0 käyttäjää, meni REPLACE1ms), aloitetaan Datan analysointi..
Analysis - Start || Analyysi | Aloitetaan Analyysi..
>Constant - CMD Footer || §f»
>Constant - List Ball || §7 •§2
Cmd FAIL - No Data View || §e[Plan] Dataa ei voida näyttää.
Cmd FAIL - No Permission || §c[Plan] Sinulla ei ole lupaa tähän komentoon.
Cmd FAIL - Requires Arguments || §c[Plan] Komento tarvitsee argumentteja. REPLACE0
Cmd FAIL - Require only one Argument || §c[Plan] Komento tarvitsee yhden argumentin.
Cmd FAIL - Timeout || §c[Plan] REPLACE0 komento aikakatkaistu! Tarkista '/plan status' & konsoli.
Cmd FAIL - Unknown Username || §c[Plan] Pelaajaa ei löytynyt tietokannasta
Cmd FAIL - Unseen Username || §c[Plan] Pelaaja ei ole pelannut palvelimella.
Cmd FAIL - Invalid Username || §c[Plan] Pelaajaa ei ole olemassa.
Cmd Header - Analysis || §f»§2 Player Analytics - Analyysin tulokset
Cmd Header - Info || §f»§2 Player Analytics - Tietoja
Cmd Header - Inspect || §f»§2 Player Analytics - Pelaajan tiedot:
Cmd Header - Search || §f»§2 Player Analytics - Haun tulokset:
In Depth Help - /plan analyze ? || §2Analyysi Komento\§f Päivittää Analyysin ja antaa linkin sen sivulle.\§7 /plan status-komentoa voidaan käyttää Analyysin tilan tarkistamiseen\§7 Vaihtoehtoiset komennot: analyze, analyse, analysis, a
In Depth Help - /plan inspect ? || §2Inspect Komento\§f Antaa linkin pelaajan sivulle.\§7 Oman sivun voi nähdä komennolla /plan inspect\§7 Vaihtoehtoiset komennot /plan <nimi>
In Depth Help - /plan list ? || §2List Komento\§f Antaa linkin pelaajalista sivulle.\§7 Pelaajalista sivulla näkyy kaikki välimuistissa olevat pelaajien sivut.\§7 Vaihtoehtoiset komennot: /plan pl
In Depth Help - /plan manage ? || §2Manage Komento\§f Käytetään Tietokannan hallitsemiseen\§7 Vaihtoehtoiset komennot /plan m\§7 /plan m - Listaa komennot\§7 /plan m <alikomento> ? - tarkempi apu
In Depth Help - /plan manage clear ? || §2Manage Clear Komento\§f Tyhjentää kaiken tiedon tietokannasta\§7 Plan kannattaa uudelleenkäynnistää onnistuneen tyhjennyksen jälkeen\§7 Vaihtoehtoiset komennot /plan pl
In Depth Help - /plan manage dump ? || §2Manage Dump Komento\§f Heittää kaiken tiedon hastebiniin kehittäjän avuksi
In Depth Help - /plan manage hotswap ? || §2Manage Hotswap Komento\§f Vaihtaa tietokantaa lennossa\§7 Ei vaihda tietokantaa mikäli yhteyttä ei saada muodostettua
In Depth Help - /plan manage import ? || §2Manage Import Komento\§f Tuo Dataa muista lähteistä\§7 Analyysi poistetaan käytöstä tuonnin ajaksi
In Depth Help - /plan manage remove ? || §2Manage Remove Komento\§f Poistaa käyttäjän datan aktiivisesta tietokannasta
In Depth Help - /plan ? || §2/plan - Pää komento\§f Käytetään kaikkien komentojen käyttämiseen\§7 /plan - Listaa komennot\§7 /plan <alikomento> ? - tarkempi apu
In Depth Help - /plan qanalyze ? || §2Quick Analysis Komento\§f Näyttää osan analyysin tietoja pelissä\§7 Vähemmän tietoa kuin nettisivulla.\§7 Vaihtoehtoiset komennot: qanalyze, ganalyse, qanalysis, qa
In Depth Help - /plan qinspect ? || §2Quick Inspect Komento\§f Näyttää osan pelaajan tiedoista pelissä.\§7 Vähemmän tietoa kuin nettisivulla.\§7 Vaihtoehtoiset komennot /plan qi
In Depth Help - /plan search ? || §2Search Komento\§f Hakee pelaajia joiden nimestä löytyy haettava osa.\§7 Esim: /plan search 123 - Hakee pelaajat joiden nimestä löytyy 123
In Depth Help - /plan webuser ? || §2Web User Manage Komento\§f Hallitsee Nettiserverin käyttäjiä\§7 Käyttäjillä on lupa taso:\§f 0 - Kaikki sivut\§f 1 - /players & kaikki pelaaja sivut\§f 2 - Oma pelaajan sivu\§7 Vaihtoehtoiset komennot /plan web
In Depth Help - /plan webuser register ? || §2Web Register Komento\§f Rekisteröi uuden käyttäjän nettiserverille.\§7 Toiselle henkilölle rekisteröinti tarvitsee plan.webmanage luvan.\§7 Passwords are hashed with PBKDF2 (64,000 iterations of SHA1) using a cryptographically-random salt.
Analysis NOTIFY - Temporary Disable || §eAnalyysi poistettu käytöstä toistaiseksi, /plan status kertoo lisää
Cmd - Click Me || Klikkaa minua
Cmd - Fetch Data || §f»§2 Haetaan tietoja välimuistiin..
Cmd - Link || §7 • §2Linkki: §f
Cmd - No Results || §7 • §2Ei tuloksia hakusanalle §7REPLACE0§2.
Cmd - Reload Success || §a[Plan] Uudelleenkäynnistys Valmis.
Cmd - Results || §7 Sopivat pelaajat: §f
Cmd - Searching || §f»§2Haetaaan..
Cmd - Usage /plan analyze || Katso serverin analyysi
Cmd - Usage /plan help || Katso komentolista.
Cmd - Usage /plan info || Tarkista Plan versio
Cmd - Usage /plan inspect || Tutki pelaajan sivua
Cmd - Usage /plan list || Listaa välimuistissa olevat pelaajat
Cmd - Usage /plan manage || Tietokannan hallinta komento
Cmd - Usage /plan manage backup || Varmuuskopioi tietokanta .db tiedostoon
Cmd - Usage /plan manage clean || Putsaa vanha data tietokannasta
Cmd - Usage /plan manage clear || Putsaa KAIKKI data tietokannasta
Cmd - Usage /plan manage dump || Luo Hastebin loki kehittäjän avuksi.
Cmd - Usage /plan manage hotswap || Vaihda tietokantaa lennossa ja käynnistä Plan uudelleen
Cmd - Usage /plan manage import || Tuo dataa muualta aktiiviseen tietokantaan
Cmd - Usage /plan manage move || Kopioi tiedot tietokannasta toiseen, ylikirjoittaen vanhat arvot.
Cmd - Usage /plan manage remove || Poista pelaajan tiedot aktiivisesta tietokannasta
Cmd - Usage /plan manage restore || Palauta varmuuskopio
Cmd - Usage /plan qanalyze || Tutki pika-analyysia
Cmd - Usage /plan qinspect || Tutki pelaajan tietoja pelissä
Cmd - Usage /plan reload || Restart the Plugin (Reloads config)
Cmd - Usage /plan search || Hae pelaajaa
Cmd - Usage /plan webuser || Hallitse nettikäyttäjiä
Cmd - Usage /plan webuser check || Tarkista nettikäyttäjä ja sen lupa taso
Cmd - Usage /plan webuser delete || Poista nettikäyttäjä
Cmd - Usage /plan webuser level || Tietoa lupa tasoista
Cmd - Usage /plan webuser register || Register a user for the webserver
Disable || Player Analytics Disabled.
Disable - Save || Tallennetaan välimuistia..
Disable - WebServer || Sammutetaan Web palvelin..
Enable || Player Analytics Enabled.
Enable - Boot Analysis 30s Notify || Analyysi | Käynnistyksen yhteinen analyysi 30 sekunnin kuluttua..
Enable - Boot Analysis Notify || Analysis | Aloitetaan Käynnistyksen yhteinen analyysi..
Enable Db FAIL - Disable Info || Database initialization has failed, disabling Plan.
Enable - Db Info || REPLACE0-tietokantayhteys onnistui.
Enable - Db || Tietokannan käynnistys..
Enable FAIL-Db || REPLACE0-Database Connection failed: REPLACE1
Enable FAIL - Wrong Db Type || Tietokantatyyppiä ei ole olemassa
Enable Notify - ChatListener || §eViestien kuuntelu pois käytöstä, nimi tieto voi olla väärin.
Enable Notify - Disabled CommandListener || §eKomentojen kuuntelu pois käytöstä.
Enable Notify - Disabled DeathListener || §eKuolema kuuntelu pois käytöstä, tappoja ei lasketa.
Enable Notify-Empty IP || §eIP in server.properties is empty & AlternativeServerIP is not used, incorrect links will be given!
Enable Notify - No data view || §eNetti Palvelin Poissa käytöstä, mutta Alternative IP/TextUI ei ole käytössä, dataa ei voi tarkastella!
Enable - WebServer || Käynnistetään Netti Palvelin..
Enable - WebServer Info || Netti Palvelin pyörii PORTILLA REPLACE0
Html - Active || Pelaaja on aktiivinen
Html - Banned || | <span class="darkred">Pannassa</span>
Html - Inactive || Pelaaja ei ole aktiivinen
Html - No Extra Plugins || <p>Ei kauheasti lisä plugineita.</p>
Html - Offline || | <span class="darkred">Offline</span>
Html - Online || | <span class="darkgreen">Online</span>
Html - OP || , Operaattori (Op)
Html - Table No Kills || Ei tappoja
Manage FAIL - Confirm Action || §c[Plan] Lisää -a vahvistaaksesi! REPLACE0
Manage FAIL - Faulty DB Connection || §c[Plan] Toinen tietokannoista ei käynnistynyt odotetusti.
Manage FAIL - Backup File Not Found || §c[Plan] Varmuuskopiota ei ole olemassa!
Manage FAIL - Incorrect DB || §c[Plan] Väärä tietokanta! (sqlite/mysql hyväksytään):
Manage FAIL - Incorrect Plugin || §c[Plan] Plugin ei ole tuettu:
Manage FAIL - Empty DB || §c[Plan] Tietokannassa ei ole pelaaja dataa!
Manage FAIL - Unenabled Plugin || §c[Plan] Plugin ei ole käynnissä:
Manage FAIL - Same DB || §c[Plan] Ei voida siirtää samaan tietokantaan!
Manage - Clear Success || §a[Plan] Kaikki data siirretty onnistuneesti!
Manage - Remind Config Change || §e[Plan] Muista vaihtaa tietokantaa ja käynnistää Plan uudelleen.
Manage - Copy Success || §a[Plan] Kaikki tiedot kopioitu onnistuneesti!
Manage - Process Fail || §c[Plan] Jokin meni vikaan dataa käsitellessä!
Manage - Import || §f» §2 Tuodaan Dataa..
Manage - Move Success || §a[Plan] Kaikki data siirretty onnistuneesti!
Manage - Remove Success || §f» §fREPLACE0:n§2 data poistettiin tietokannasta §fREPLACE1§2.
Manage - Start || »§7 Käsitellään Dataa..
Manage - Success || §f» §2 Onnistui!
Manage NOTIFY - Overwrite || Tiedot REPLACE0-tietokannassa ylikirjoitetaan!
Manage NOTIFY - Partial Overwrite || Osa tiedoista REPLACE0-tietokannassa ylikirjoitetaan!
Manage NOTIFY - Remove || Tiedot REPLACE0-tietokannassa poistetaan!
Manage NOTIFY - Rewrite || Tiedot REPLACE0-tietokannassa uudelleenkirjoitetaan!
WARN - Too Small Queue Size || Queue size is too small! (REPLACE0), change the setting to a higher number! (Currently REPLACE1)

View File

@ -1,7 +1,7 @@
name: Plan
author: Rsl1122
main: main.java.com.djrapitops.plan.Plan
version: 3.6.1
version: 3.6.2
softdepend:
- OnTime
- EssentialsX

View File

@ -1,93 +0,0 @@
package test.java.main.java.com.djrapitops.plan;
import main.java.com.djrapitops.plan.Phrase;
import org.bukkit.ChatColor;
import org.bukkit.plugin.java.JavaPlugin;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.powermock.core.classloader.annotations.PrepareForTest;
import org.powermock.modules.junit4.PowerMockRunner;
import test.java.utils.TestInit;
import static org.junit.Assert.assertEquals;
/**
* @author Rsl1122
*/
@RunWith(PowerMockRunner.class)
@PrepareForTest(JavaPlugin.class)
public class PhraseTest {
/**
*
*/
public PhraseTest() {
}
/**
*
*/
@Before
public void setUp() throws Exception {
TestInit.init();
}
/**
*
*/
@Test
public void testToString() {
Phrase instance = Phrase.REPLACE0;
String expResult = "REPLACE0";
instance.setText(expResult);
String result = instance.toString();
assertEquals(expResult, result);
}
/**
*
*/
@Test
public void testParseWithZeroArgs() {
Phrase instance = Phrase.DEM_UNKNOWN;
String expResult = "Not Known";
String result = instance.parse();
assertEquals(expResult, result);
}
/**
*
*/
@Test
public void testParseStringArr() {
Phrase instance = Phrase.REPLACE0;
String expResult = "Test";
String result = instance.parse(expResult);
assertEquals(expResult, result);
}
/**
*
*/
@Test
public void testColor() {
Phrase instance = Phrase.COLOR_MAIN;
ChatColor expResult = ChatColor.RED;
instance.setColor('c');
ChatColor result = instance.color();
assertEquals(expResult, result);
}
/**
*
*/
@Test
public void testSetText() {
Phrase instance = Phrase.REPLACE0;
String expResult = "Test";
instance.setText(expResult);
String result = instance.toString();
assertEquals(expResult, result);
}
}

View File

@ -169,9 +169,8 @@ public class UserDataTest {
*/
@Test
public void testAddSessionNull() {
SessionData incorrect = null;
test.addSession(incorrect);
assertTrue("Added null", !test.getSessions().contains(incorrect));
test.addSession(null);
assertTrue("Added null", !test.getSessions().contains(null));
}
/**

View File

@ -27,8 +27,8 @@ public class HtmlTest {
*/
@Test
public void testParseWithZeroArgs() {
Html instance = Html.REPLACE0;
String expResult = "REPLACE0";
Html instance = Html.SPAN;
String expResult = "REPLACE0</span>";
String result = instance.parse();
assertEquals(expResult, result);
}
@ -38,9 +38,9 @@ public class HtmlTest {
*/
@Test
public void testParseStringArr() {
Html instance = Html.REPLACE0;
String expResult = "Test";
String result = instance.parse(expResult);
Html instance = Html.SPAN;
String expResult = "Test</span>";
String result = instance.parse("Test");
assertEquals(expResult, result);
}
@ -49,8 +49,8 @@ public class HtmlTest {
*/
@Test
public void testSetHtml() {
Html instance = Html.REPLACE0;
String expResult = "Test";
Html instance = Html.SPAN;
String expResult = "Test</span>";
instance.setHtml(expResult);
String result = instance.parse();
assertEquals(expResult, result);

View File

@ -11,6 +11,7 @@ import main.java.com.djrapitops.plan.utilities.MiscUtils;
import org.bukkit.Bukkit;
import org.bukkit.plugin.java.JavaPlugin;
import org.junit.Before;
import org.junit.Ignore;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.powermock.core.classloader.annotations.PrepareForTest;
@ -118,6 +119,7 @@ public class MiscUtilsTest {
*
*/
@Test
@Ignore("DB mock")
public void testGetMatchingDisplaynames() throws Exception {
TestInit.init();
String search = "testname";
@ -133,6 +135,7 @@ public class MiscUtilsTest {
*
*/
@Test
@Ignore("DB mock")
public void testGetMatchingDisplaynames2() throws Exception {
TestInit.init();
String search = "2";

View File

@ -5,15 +5,15 @@ import main.java.com.djrapitops.plan.data.TPS;
import main.java.com.djrapitops.plan.data.UserData;
import main.java.com.djrapitops.plan.data.WebUser;
import main.java.com.djrapitops.plan.data.handling.info.HandlingInfo;
import main.java.com.djrapitops.plan.locale.Message;
import main.java.com.djrapitops.plan.locale.Msg;
import main.java.com.djrapitops.plan.utilities.PassEncryptUtil;
import main.java.com.djrapitops.plan.utilities.analysis.Point;
import main.java.com.djrapitops.plan.utilities.comparators.*;
import org.junit.Test;
import test.java.utils.RandomData;
import java.util.Collections;
import java.util.List;
import java.util.Random;
import java.util.*;
import java.util.stream.Collectors;
import static org.junit.Assert.assertEquals;
@ -95,4 +95,39 @@ public class ComparatorTest {
List<Integer> afterSort = test.stream().map(WebUser::getPermLevel).collect(Collectors.toList());
assertEquals(intValues, afterSort);
}
@Test
public void testStringLengthComparator() {
List<String> test = new ArrayList<>();
test.add(RandomData.randomString(10));
test.add(RandomData.randomString(3));
test.add(RandomData.randomString(20));
test.add(RandomData.randomString(7));
test.add(RandomData.randomString(4));
test.add(RandomData.randomString(86));
test.add(RandomData.randomString(6));
test.sort(new StringLengthComparator());
assertEquals(86, test.get(0).length());
assertEquals(20, test.get(1).length());
assertEquals(3, test.get(test.size() - 1).length());
}
@Test
public void testLocaleEntryComparator() {
Map<Msg, Message> test = new HashMap<>();
test.put(Msg.CMD_CONSTANT_FOOTER, new Message(""));
test.put(Msg.ANALYSIS_3RD_PARTY, new Message(""));
test.put(Msg.MANAGE_FAIL_NO_PLAYERS, new Message(""));
List<String> sorted = test.entrySet().stream()
.sorted(new LocaleEntryComparator())
.map(entry -> entry.getKey().name())
.collect(Collectors.toList());
assertEquals("ANALYSIS_3RD_PARTY", sorted.get(0));
assertEquals("CMD_CONSTANT_FOOTER", sorted.get(1));
assertEquals("MANAGE_FAIL_NO_PLAYERS", sorted.get(2));
}
}

View File

@ -15,6 +15,7 @@ Config.Point | Version introduced | Type | Default | Description
--- | ---- | ------ | --- | ---------------------------------
Debug | 3.0.0 | boolean | false | Enables debug messages on console.
Locale | 2.5.0 | String | default | Two letter Locale combination. Can be set to one of the Available locales. If a faulty combination is used, default locale will be used. [Available locales](https://github.com/Rsl1122/Plan-PlayerAnalytics/tree/master/Plan/localization)
WriteNewLocaleFileOnStart | 3.6.2 | boolean | false | Setting this to true & reloading the plugin will generate a new locale.txt & it will be set back to false. [Localization](/documentation/Localization.md)
UseTextUI | 3.0.0 | boolean | false | Redirects */plan inspect* and */plan analyze* commands to display same messages as */plan qinspect* & */plan qanalyze*
Data.ChatListener | 3.4.2 | boolean | true | Enables Chat listener
Data.GatherKillData | 3.4.2 | boolean | true | Enables Death listener

View File

@ -2,30 +2,27 @@
# Localization
This article will tell you how you can change the messages seen in the plugin.
(Introduced in version 2.5.0)
(Introduced in version 2.5.0 & Revamped in 3.6.2)
By Default Plan uses internal Locale found inside Phrase.java & Html.java (Config setting: default)
- [Phrase](https://github.com/Rsl1122/Plan-PlayerAnalytics/blob/master/Plan/src/main/java/com/djrapitops/plan/Phrase.java)
- [Html](https://github.com/Rsl1122/Plan-PlayerAnalytics/blob/master/Plan/src/main/java/com/djrapitops/plan/ui/Html.java)
By Default Plan uses internal Locale found inside Locale.java (Config setting: default)
- [Locale](https://github.com/Rsl1122/Plan-PlayerAnalytics/blob/master/Plan/src/main/java/com/djrapitops/plan/locale/Locale.java)
## Config setting
In the config, there is a setting for Locale.
Setting this to, for example EN, will attempt to fetch locale from Github to be used with the plugin.
Unfortunately when this setting is used, the Color customization setting for commands is not used. This can be circumvented by copying the existing locale from Github to `/plugins/Plan/locale.txt` and changing the colors in the file.
Setting this to, for example FI, (Finnish) will attempt to use locale from inside the plugin jar.
Inside the plugin there are multiple locale files.
If you want to use your own locale, just copy contents of this file on github to `/plugins/Plan/locale.txt`
Now you can customize all in game messages!
You can generate a new locale (default values) by setting the config setting **WriteNewLocaleFileOnStart** to true.
This will generate a locale.txt to the plugin's folder & that will be used when present.
To change the messages, only change the parts on the right, left ones are identifiers.
Some messages in the html pages are not loaded from the text file, and need to be changed seperately.
This can be done by copying the html files from the .jar to the plugin folder and editing them.
- [Available Locales](https://github.com/Rsl1122/Plan-PlayerAnalytics/tree/master/Plan/localization)
## Known caveats:
- The 'äåö'-letters etc do not work on the webpage, this will hopefully be fixed in a future update.
## End
If you want to help me out with localizing the plugin to your language, you can translate the locale file to your language and send the contents to me in one way:
- Do a pull request