diff --git a/Plan/localization/htmlLocale_EN.txt b/Plan/localization/htmlLocale_EN.txt new file mode 100644 index 000000000..302251dd8 --- /dev/null +++ b/Plan/localization/htmlLocale_EN.txt @@ -0,0 +1,19 @@ +WARN_INACCURATE <>
Data might be inaccurate, player has just registered.
+ERROR_TABLE <>

Error Calcuclating Table (No data)

+TOP_TOWNS <>

Top 20 Towns

+TOP_FACTIONS <>

Top 20 Factions

+TOTAL_BALANCE <>

Server Total Balance: REPLACE0

+TOTAL_VOTES <>

Players have voted total of REPLACE0 times.

+TOWN <>

Town: REPLACE0

+PLOT_OPTIONS <>

Plot options: REPLACE0

+FRIENDS <>

Friends with REPLACE0

+FACTION <>

Faction: REPLACE0

+BALANCE <>

Balance: REPLACE0

+VOTES <>

Player has voted REPLACE0 times.

+BANNED <> | Banned +OPERATOR <> , Operator (Op) +ONLINE <> | Online +OFFLINE <> | Offline +ACTIVE <> | Player is Active +INACTIVE <> | Player is inactive +ERROR_LIST <> Error Creating List

diff --git a/Plan/localization/htmlLocale_FI.txt b/Plan/localization/htmlLocale_FI.txt new file mode 100644 index 000000000..7789ff1a2 --- /dev/null +++ b/Plan/localization/htmlLocale_FI.txt @@ -0,0 +1,19 @@ +WARN_INACCURATE <>
Tiedot voivat olla viallisia, pelaaja rekisteröityi vasta
+ERROR_TABLE <>

Virhe tehdessä taulukkoa (Ei dataa)

+TOP_TOWNS <>

Top 20 Kylää

+TOP_FACTIONS <>

Top 20 Kiltaa

+TOTAL_BALANCE <>

Palvelimen rahan kokonaismäärä: REPLACE0

+TOTAL_VOTES <>

Pelaajat ovat äänestäneet REPLACE0 kertaa.

+TOWN <>

Kylä: REPLACE0

+PLOT_OPTIONS <>

Plot asetukset: REPLACE0

+FRIENDS <>

Kaverit: REPLACE0

+FACTION <>

Kilta: REPLACE0

+BALANCE <>

Rahamäärä: REPLACE0

+VOTES <>

Pelaaja on äänestänyt REPLACE0 kertaa.

+BANNED <> | Banned +OPERATOR <> , Operator (Op) +ONLINE <> | Online +OFFLINE <> | Offline +ACTIVE <> | Pelaaja on aktiivinen +INACTIVE <> | Pelaaja on inaktiivinen +ERROR_LIST <> Virhe luodessa listaa

diff --git a/Plan/localization/locale_EN.txt b/Plan/localization/locale_EN.txt new file mode 100644 index 000000000..eb64c1df7 --- /dev/null +++ b/Plan/localization/locale_EN.txt @@ -0,0 +1,99 @@ +PREFIX <> [Plan] +ENABLED <> Player Analytics Enabled. +DISABLED <> Player Analytics Disabled. +RELOAD_COMPLETE <> §a[Plan] Reload complete. +SAVE_CACHE <> Saving cached data.. +ADD_TO_CACHE <> Added REPLACE0 to Cache. +DB_INIT <> Database init.. +WEBSERVER_INIT <> Initializing Webserver.. +WEBSERVER_CLOSE <> Shutting down Webserver.. +WEBSERVER_RUNNING <> Webserver running on PORT REPLACE0 +DB_ESTABLISHED <> REPLACE0-database connection established. +DATABASE_TYPE_DOES_NOT_EXIST <> That database type doesn't exist. +DATABASE_FAILURE_DISABLE <> Database initialization has failed, disabling Plan. +NOTIFY_EMPTY_IP <> §e[Plan] IP in server.properties is empty & AlternativeServerIP is not used, incorrect links will be given! +VERSION_NEW_AVAILABLE <> New Version (REPLACE0) is availible 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 <> §c[Plan] This Player doesn't exist. +USERNAME_NOT_SEEN <> §c[Plan] This Player has not played on this server. +USERNAME_NOT_KNOWN <> §c[Plan] Player not found from the database. +GRABBING_DATA_MESSAGE <> » Fetching data to cache.. +NOT_IN_TOWN <> Not in a town +NOT_IN_FAC <> Not in a faction +COMMAND_TIMEOUT <> §c[Plan] REPLACE0 Command timed out! Error most likely on 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, beginning Analysis of data.. +ANALYSIS_COMPLETE <> Analysis | Analysis Complete. +ERROR_NO_DATA_VIEW <> §eWebserver disabled but Alternative IP/PlanLite not used, no way to view data! +ERROR_WEBSERVER_OFF_ANALYSIS <> §e[Plan] This command can be only used if the webserver is running on this server. +ERROR_WEBSERVER_OFF_INSPECT <> §e[Plan] This command can be only used if webserver/planlite is enabled on this server. +MANAGE_ERROR_INCORRECT_PLUGIN <> §c[Plan] Plugin not supported: +MANAGE_PROCESS_START <> »§7 Processing data.. +MANAGE_ERROR_PLUGIN_NOT_ENABLED <> §c[Plan] Plugin is not enabled: +MANAGE_ERROR_INCORRECT_DB <> §c[Plan] Incorrect database! (sqlite/mysql accepted): +MANAGE_ERROR_SAME_DB <> §c[Plan] Can't move to the same database! +MANAGE_DATABASE_FAILURE <> §c[Plan] One of the databases was not initialized properly. +MANAGE_DB_CONFIG_REMINDER <> §e[Plan] Remember to swap to the new database and reload plugin +MANAGE_ERROR_NO_PLAYERS <> §c[Plan] Database has no player data! +MANAGE_ERROR_BACKUP_FILE_NOT_FOUND <> §c[Plan] Backup file doesn't exist! +MANAGE_MOVE_SUCCESS <> §a[Plan] All data moved successfully! +MANAGE_COPY_SUCCESS <> §a[Plan] All data copied successfully! +MANAGE_CLEAR_SUCCESS <> §a[Plan] All data cleared successfully! +MANAGE_REMOVE_SUCCESS <> §f» §2Data of §fREPLACE0§2 was removed from Database §fREPLACE1§2. +MANAGE_IMPORTING <> §f» §2 Importing Data.. +MANAGE_SUCCESS <> §f» §2 Success! +CMD_ANALYZE_HEADER <> §f»§2 Player Analytics - Analysis results +CMD_INSPECT_HEADER <> §f»§2 Player Analytics - Inspect results: +CMD_SEARCH_HEADER <> §f»§2 Player Analytics - Search results for: +CMD_HELP_HEADER <> §f»§2 Player Analytics - Help +CMD_MANAGE_STATUS_HEADER <> §f»§2 Player Analytics - Database status +CMD_MANAGE_STATUS_ACTIVE_DB <> §7 •§2 Active Database: §7REPLACE0 +CMD_CLICK_ME <> Click Me +CMD_LINK <> §7 •§2 Link: §f +CMD_RESULTS_AVAILABLE <> §7 Results will be available for §fREPLACE0§7 minutes. +CMD_NO_RESULTS <> §7 •§2 No results for §7REPLACE0§2. +CMD_MATCH <> §7 Matching player: §f +CMD_USG_ANALYZE <> View the Server Analysis +CMD_USG_HELP <> Show command list. +CMD_USG_INFO <> View Version of Plan +CMD_USG_INSPECT <> Inspect Player's Data +CMD_USG_MANAGE <> Database managment 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_REMOVE <> Remove players's data from the Active Database. +CMD_USG_MANAGE_STATUS <> Check the status of the Active Database. +CMD_USG_RELOAD <> Reload plugin config & save cached data +CMD_USG_SEARCH <> Search for player +ARG_SEARCH <> +ARG_PLAYER <> +ARG_RESTORE <> [-a] +ARG_IMPORT <> [-a] +ARG_MOVE <> [-a] +USE_BACKUP <> Use /plan manage backup +USE_RESTORE <> Use /plan manage restore [-a] +USE_MANAGE <> Use /plan manage for help +USE_PLAN <> Use /plan for help +USE_MOVE <> Use /plan manage move [-a] +USE_COMBINE <> Use /plan manage combine [-a] +USE_IMPORT <> Use /plan manage import [-a] +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 <> §c[Plan] This command can be only used as a player. +COMMAND_REQUIRES_ARGUMENTS <> §c[Plan] Command requires arguments. REPLACE0 +COMMAND_ADD_CONFIRMATION_ARGUMENT <> §c[Plan] Add -a to confirm execution! REPLACE0 +COMMAND_REQUIRES_ARGUMENTS_ONE <> §c[Plan] Command requires one argument. +COMMAND_NO_PERMISSION <> §c[Plan] You do not have the required permmission. diff --git a/Plan/localization/locale_FI.txt b/Plan/localization/locale_FI.txt new file mode 100644 index 000000000..e92fcce0c --- /dev/null +++ b/Plan/localization/locale_FI.txt @@ -0,0 +1,99 @@ +PREFIX <> [Plan] +ENABLED <> Player Analytics Käynnistetty. +DISABLED <> Player Analytics Suljettu. +RELOAD_COMPLETE <> §a[Plan] Ladattu uudelleen. +SAVE_CACHE <> Tallennetaan välimuisti tietoja.. +ADD_TO_CACHE <> REPLACE0 lisättiin välimuistiin. +DB_INIT <> Tietokannan käynnistys.. +WEBSERVER_INIT <> Web-palvelimen käynnistys.. +WEBSERVER_CLOSE <> Sammutetaan Web-palvelin.. +WEBSERVER_RUNNING <> Web-palvelin pyörii PORTILLA REPLACE0 +DB_ESTABLISHED <> REPLACE0-tietokantayhteys muodostettu. +DATABASE_TYPE_DOES_NOT_EXIST <> Tätä tietokantatyyppiä ei ole olemassa. +DATABASE_FAILURE_DISABLE <> Tietokannan käynnistys epäonnistui, suljetaan Plan. +NOTIFY_EMPTY_IP <> §e[Plan] IP server.properties-tiedostossa on tyhjä & AlternativeServerIP-asetus ei ole käytössä, plugin antaa virheellisiä linkkejä! +VERSION_NEW_AVAILABLE <> Uusi versio (REPLACE0) on saatavilla: https://www.spigotmc.org/resources/plan-player-analytics.32536/ +VERSION_LATEST <> Käytät viimeisintä versiota +VERSION_CHECK_ERROR <> Versioiden vertaus epäonnistui. +VERSION_FAIL <> Uusimman version numeron tarkistus epäonnistui. +USERNAME_NOT_VALID <> §c[Plan] Pelaajaa ei ole olemassa. +USERNAME_NOT_SEEN <> §c[Plan] Tämä pelaaja ei ole pelannut tällä serverillä. +USERNAME_NOT_KNOWN <> §c[Plan] Pelaajaa ei löydetty tietokannasta. +GRABBING_DATA_MESSAGE <> » Haetaan välimuistiin.. +NOT_IN_TOWN <> Ei kylässä +NOT_IN_FAC <> Ei killassa +COMMAND_TIMEOUT <> §c[Plan] REPLACE0 Komennon aikakatkaisu. Virheitä luultavasti konsolissa. +ANALYSIS_START <> Analysis | Aloitetaan pelaaja-datan analysointi.. +ANALYSIS_BOOT_NOTIFY <> Analysis | Käynnistyksen yhteinen analyysi 30 sekunnin kuluttua.. +ANALYSIS_BOOT <> Analysis | Aloitetaan käynnistyksen yhteinen analyysi.. +ANALYSIS_FETCH_PLAYERS <> Analysis | Tarkistetaan saatavilla olevia pelaajia.. +ANALYSIS_FETCH_DATA <> Analysis | Haetaan dataa.. +ANALYSIS_FAIL_NO_PLAYERS <> Analysis | Analyysi epäonnistui, ei pelaajia. +ANALYSIS_FAIL_NO_DATA <> Analysis | Analyysi epäonnistui, ei dataa tietokannassa. +ANALYSIS_BEGIN_ANALYSIS <> Analysis | Data haettu, aloitetaan analyysi.. +ANALYSIS_COMPLETE <> Analysis | Analyysi valmis. +ERROR_NO_DATA_VIEW <> §eNettiserveri poissa käytöstä mutta Alternative IP/PlanLite ei ole käytössä, ei keinoa tarkastella dataa! +ERROR_WEBSERVER_OFF_ANALYSIS <> §e[Plan] Tätä komentoa voi käyttää vain jos Nettiserveri on kytketty päälle. +ERROR_WEBSERVER_OFF_INSPECT <> §e[Plan] Tätä komento voi käyttäää vain jos Nettiserveri on kytketty päälle. +MANAGE_ERROR_INCORRECT_PLUGIN <> §c[Plan] Pluginia ei tueta: +MANAGE_PROCESS_START <> »§7 Työstetään tietoa.. +MANAGE_ERROR_PLUGIN_NOT_ENABLED <> §c[Plan] Plugin ei käynnissä: +MANAGE_ERROR_INCORRECT_DB <> §c[Plan] Väärä tietokanta! (sqlite/mysql hyväksytään): +MANAGE_ERROR_SAME_DB <> §c[Plan] Ei voida siirtää samaan tietokantaan! +MANAGE_DATABASE_FAILURE <> §c[Plan] Toinen tietokanta ei ole käynnistynyt kunnolla. +MANAGE_DB_CONFIG_REMINDER <> §e[Plan] Muista vaihtaa uuteen tietokantaan ja ladata Plan uudelleen +MANAGE_ERROR_NO_PLAYERS <> §c[Plan] Tietokannassa ei ole pelaaja dataa! +MANAGE_ERROR_BACKUP_FILE_NOT_FOUND <> §c[Plan] Varmuuskopio tiedostoa ei ole olemassa! +MANAGE_MOVE_SUCCESS <> §a[Plan] Kaikki tieto siirretty onnistuneesti! +MANAGE_COPY_SUCCESS <> §a[Plan] Kaikki tieto kopioitu onnistuneesti! +MANAGE_CLEAR_SUCCESS <> §a[Plan] Kaikki tieto poistettu onnistuneesti! +MANAGE_REMOVE_SUCCESS <> §f» §2Pelaajan §fREPLACE0§2 tiedot poistettiin tietokannasta: §fREPLACE1§2. +MANAGE_IMPORTING <> §f» §2 Tuodaan dataa.. +MANAGE_SUCCESS <> §f» §2 Onnistui! +CMD_ANALYZE_HEADER <> §f»§2 Player Analytics - Analyysin tulokset: +CMD_INSPECT_HEADER <> §f»§2 Player Analytics - Inspect tulokset: +CMD_SEARCH_HEADER <> §f»§2 Player Analytics - Haku tulokset haulle: +CMD_HELP_HEADER <> §f»§2 Player Analytics - Apu +CMD_MANAGE_STATUS_HEADER <> §f»§2 Player Analytics - Tietokannan tila +CMD_MANAGE_STATUS_ACTIVE_DB <> §7 •§2 Nykyinen tietokanta: §7REPLACE0 +CMD_CLICK_ME <> Klikkaa minua +CMD_LINK <> §7 •§2 Linkki: §f +CMD_RESULTS_AVAILABLE <> §7 Tiedot ovat saatavilla §fREPLACE0§7 minuuttia. +CMD_NO_RESULTS <> §7 •§2 Ei tuloksia §7REPLACE0§2. +CMD_MATCH <> §7 Vastaava pelaaja: §f +CMD_USG_ANALYZE <> Tarkastele serverin analyysia +CMD_USG_HELP <> Tarkastele komentoja. +CMD_USG_INFO <> Tarkasta Plan-versio +CMD_USG_INSPECT <> Tarkastele pelaajan tietoja +CMD_USG_MANAGE <> Tietokannan käsittely komento +CMD_USG_MANAGE_BACKUP <> Varmuuskopioi tietokanta .db tiedostoon +CMD_USG_MANAGE_RESTORE <> Palauta tietokanta varmuuskopio tiedostosta +CMD_USG_MANAGE_MOVE <> Kopioi data tietokannasta toiseen ja ylikirjoita vanhat arvot +CMD_USG_MANAGE_COMBINE <> Kopioi data tietokannasta toiseen ja yhdistä arvot +CMD_USG_MANAGE_IMPORT <> Tuo tietoja toisista plugineista nykyiseen tietokantaan. +CMD_USG_MANAGE_CLEAR <> Poista tiedot tietokannasta +CMD_USG_MANAGE_REMOVE <> Poista pelaajan tiedot nykyisestä tietokannasta. +CMD_USG_MANAGE_STATUS <> Check the status of the Active Database. +CMD_USG_RELOAD <> Lataa Plan-Config uudelleen ja käynnistä Plan uudelleen +CMD_USG_SEARCH <> Hae pelaajan tietoja +ARG_SEARCH <> +ARG_PLAYER <> +ARG_RESTORE <> [-a] +ARG_IMPORT <> [-a] +ARG_MOVE <> [-a] +USE_BACKUP <> Käytä /plan manage backup +USE_RESTORE <> Käytä /plan manage restore [-a] +USE_MANAGE <> Kokeile /plan manage +USE_PLAN <> Kokeile /plan +USE_MOVE <> Käytä /plan manage move [-a] +USE_COMBINE <> Käytä /plan manage combine [-a] +USE_IMPORT <> Käytä /plan manage import [-a] +WARN_REWRITE <> REPLACE0-tietokannan tiedot kirjoitetaan uudelleen! +WARN_OVERWRITE <> REPLACE0-tietokannan tiedot ylikirjoitetaan! +WARN_OVERWRITE_SOME <> Osa REPLACE0-tietokannan tiedoista ylikirjoitetaan! +WARN_REMOVE <> REPLACE0-tietokannan tiedot poistetaan! +COMMAND_SENDER_NOT_PLAYER <> §c[Plan] Tätä komentoa voi käyttää vain pelaaja. +COMMAND_REQUIRES_ARGUMENTS <> §c[Plan] Komento vaatii argumentteja. REPLACE0 +COMMAND_ADD_CONFIRMATION_ARGUMENT <> §c[Plan] Lisää -a vahvistaaksesi komennon ajo! REPLACE0 +COMMAND_REQUIRES_ARGUMENTS_ONE <> §c[Plan] Komento vaatii yhden argumentin.. +COMMAND_NO_PERMISSION <> §c[Plan] Sinulla ei ole lupaa tuohon. \ No newline at end of file diff --git a/Plan/src/main/java/com/djrapitops/plan/Phrase.java b/Plan/src/main/java/com/djrapitops/plan/Phrase.java index 5aba07cfb..16e892226 100644 --- a/Plan/src/main/java/com/djrapitops/plan/Phrase.java +++ b/Plan/src/main/java/com/djrapitops/plan/Phrase.java @@ -1,5 +1,10 @@ package com.djrapitops.plan; +import java.io.File; +import java.io.IOException; +import java.util.ArrayList; +import java.util.List; +import java.util.Scanner; import org.bukkit.ChatColor; import static org.bukkit.plugin.java.JavaPlugin.getPlugin; @@ -12,16 +17,20 @@ public enum Phrase { PREFIX("[Plan] "), ENABLED("Player Analytics Enabled."), DISABLED("Player Analytics Disabled."), + RELOAD_COMPLETE(ChatColor.GREEN + "" + PREFIX + "Reload complete."), SAVE_CACHE("Saving cached data.."), ADD_TO_CACHE("Added REPLACE0 to 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_ESTABLISHED(REPLACE0 + "-database connection established."), DATABASE_TYPE_DOES_NOT_EXIST("That database type doesn't exist."), DATABASE_FAILURE_DISABLE("Database initialization has failed, disabling Plan."), - NOTIFY_EMPTY_IP(ChatColor.YELLOW+""+PREFIX+"IP in server.properties is empty & AlternativeServerIP is not used, incorrect links will be given!"), + NOTIFY_EMPTY_IP(ChatColor.YELLOW + "" + PREFIX + "IP in server.properties is empty & AlternativeServerIP is not used, incorrect links will be given!"), // - VERSION_NEW_AVAILABLE("New Version ("+REPLACE0+") is availible at https://www.spigotmc.org/resources/plan-player-analytics.32536/"), + VERSION_NEW_AVAILABLE("New Version (" + REPLACE0 + ") is availible 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."), @@ -69,8 +78,9 @@ public enum Phrase { 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/planlite is enabled on this server."), // + CMD_FOOTER(COLOR_TER.color() + "" + ARROWS_RIGHT), MANAGE_ERROR_INCORRECT_PLUGIN(ChatColor.RED + "" + PREFIX + "Plugin not supported: "), - MANAGE_PROCESS_START(ARROWS_RIGHT +""+COLOR_SEC.color() +" Processing data.."), + MANAGE_PROCESS_START(ARROWS_RIGHT + "" + COLOR_SEC.color() + " Processing data.."), MANAGE_ERROR_PLUGIN_NOT_ENABLED(ChatColor.RED + "" + PREFIX + "Plugin is not enabled: "), MANAGE_ERROR_INCORRECT_DB(ChatColor.RED + "" + PREFIX + "Incorrect database! (sqlite/mysql accepted): "), MANAGE_ERROR_SAME_DB(ChatColor.RED + "" + PREFIX + "Can't move to the same database!"), @@ -81,12 +91,17 @@ public enum Phrase { MANAGE_MOVE_SUCCESS(ChatColor.GREEN + "" + PREFIX + "All data moved successfully!"), MANAGE_COPY_SUCCESS(ChatColor.GREEN + "" + PREFIX + "All data copied successfully!"), MANAGE_CLEAR_SUCCESS(ChatColor.GREEN + "" + 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_FOOTER(COLOR_TER.color() + "" + ARROWS_RIGHT), CMD_BALL(COLOR_SEC.color() + " " + Phrase.BALL.toString() + COLOR_MAIN.color()), CMD_ANALYZE_HEADER(CMD_FOOTER + "" + COLOR_MAIN.color() + " Player Analytics - Analysis results"), CMD_INSPECT_HEADER(CMD_FOOTER + "" + COLOR_MAIN.color() + " Player Analytics - Inspect results: "), CMD_SEARCH_HEADER(CMD_FOOTER + "" + COLOR_MAIN.color() + " Player Analytics - Search results for: "), + CMD_HELP_HEADER(CMD_FOOTER + "" + COLOR_MAIN.color() + " Player Analytics - Help"), + CMD_MANAGE_STATUS_HEADER(CMD_FOOTER + "" + COLOR_MAIN.color() + " Player Analytics - Database status"), + CMD_MANAGE_STATUS_ACTIVE_DB(CMD_BALL + "" + COLOR_MAIN.color() + " Active Database: " + COLOR_SEC.color() + "REPLACE0"), CMD_CLICK_ME("Click Me"), CMD_LINK(COLOR_SEC.color() + " " + BALL + COLOR_MAIN.color() + " Link: " + COLOR_TER.color()), CMD_PASS_PLANLITE(ChatColor.YELLOW + "" + PREFIX + "Passing to PlanLite.."), @@ -94,9 +109,43 @@ public enum Phrase { CMD_NO_RESULTS(CMD_BALL + " No results for " + COLOR_SEC.color() + REPLACE0 + COLOR_MAIN.color() + "."), CMD_MATCH(COLOR_SEC.color() + " Matching player: " + COLOR_TER.color()), // + CMD_USG_ANALYZE("View the Server Analysis"), + CMD_USG_HELP("Show command list."), + CMD_USG_INFO("View Version of Plan"), + CMD_USG_INSPECT("Inspect Player's Data"), + CMD_USG_MANAGE("Database managment 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_REMOVE("Remove players's data from the Active Database."), + CMD_USG_MANAGE_STATUS("Check the status of the Active Database."), + CMD_USG_RELOAD("Reload plugin config & save cached data"), + CMD_USG_SEARCH("Search for player"), + ARG_SEARCH(""), + ARG_PLAYER(""), + ARG_RESTORE(" [-a]"), + ARG_IMPORT(" [-a]"), + ARG_MOVE(" [-a]"), + // + USE_BACKUP("Use /plan manage backup "), + USE_RESTORE("Use /plan manage restore [-a]"), + USE_MANAGE("Use /plan manage for help"), + USE_PLAN("Use /plan for help"), + USE_MOVE("Use /plan manage move [-a]"), + USE_COMBINE("Use /plan manage combine [-a]"), + USE_IMPORT("Use /plan manage import [-a]"), + // + 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 + "" + PREFIX + "This command can be only used as a player."), - COMMAND_REQUIRES_ARGUMENTS(ChatColor.RED + "" + PREFIX + "Command requires arguments."), - COMMAND_ADD_CONFIRMATION_ARGUMENT(ChatColor.RED + "" + PREFIX + "Add -a to confirm execution!"), + COMMAND_REQUIRES_ARGUMENTS(ChatColor.RED + "" + PREFIX + "Command requires arguments. REPLACE0"), + COMMAND_ADD_CONFIRMATION_ARGUMENT(ChatColor.RED + "" + PREFIX + "Add -a to confirm execution! REPLACE0"), COMMAND_REQUIRES_ARGUMENTS_ONE(ChatColor.RED + "" + PREFIX + "Command requires one argument."), COMMAND_NO_PERMISSION(ChatColor.RED + "" + PREFIX + "You do not have the required permmission."); @@ -117,11 +166,11 @@ public enum Phrase { public String toString() { return text; } - + public String parse() { return this.toString(); } - + public String parse(String... p) { String returnValue = this.toString(); for (int i = 0; i < p.length; i++) { @@ -144,4 +193,27 @@ public enum Phrase { public void setColor(String colorCode) { this.color = ChatColor.getByChar(colorCode); } + + static void loadLocale(File localeFile) { + try { + Scanner localeScanner = new Scanner(localeFile, "UTF-8"); + List localeRows = new ArrayList<>(); + while (localeScanner.hasNextLine()) { + String line = localeScanner.nextLine(); + if (!line.isEmpty()) { + localeRows.add(line); + } + } + for (String localeRow : localeRows) { + try { + String[] split = localeRow.split(" <> "); + Phrase.valueOf(split[0]).setText(split[1]); + } catch (IllegalArgumentException e) { + getPlugin(Plan.class).logError("There is a miswritten line in locale on line "+localeRows.indexOf(localeRow)); + } + } + } catch (IOException e) { + + } + } } diff --git a/Plan/src/main/java/com/djrapitops/plan/Plan.java b/Plan/src/main/java/com/djrapitops/plan/Plan.java index 300371537..31238e359 100644 --- a/Plan/src/main/java/com/djrapitops/plan/Plan.java +++ b/Plan/src/main/java/com/djrapitops/plan/Plan.java @@ -8,6 +8,7 @@ import com.djrapitops.plan.database.Database; import com.djrapitops.plan.database.databases.*; import com.djrapitops.plan.data.cache.*; import com.djrapitops.plan.data.listeners.*; +import java.io.File; import java.util.Date; import main.java.com.djrapitops.plan.ui.webserver.WebSocketServer; import org.bukkit.plugin.java.JavaPlugin; @@ -16,6 +17,7 @@ import java.util.HashSet; import java.util.concurrent.Executors; import java.util.concurrent.ScheduledExecutorService; import main.java.com.djrapitops.plan.Settings; +import main.java.com.djrapitops.plan.ui.Html; import org.bukkit.Bukkit; import org.bukkit.command.ConsoleCommandSender; import org.bukkit.plugin.PluginManager; @@ -58,7 +60,17 @@ public class Plan extends JavaPlugin { */ @Override public void onEnable() { - getDataFolder().mkdirs(); + File dataFolder = getDataFolder(); + dataFolder.mkdirs(); + + File localeFile = new File(dataFolder, "locale.txt"); + if (localeFile.exists()) { + Phrase.loadLocale(localeFile); + } + File htmlLocale = new File(dataFolder, "htmlLocale.txt"); + if (htmlLocale.exists()) { + Html.loadLocale(htmlLocale); + } databases = new HashSet<>(); databases.add(new MySQLDB(this)); @@ -186,8 +198,9 @@ public class Plan extends JavaPlugin { /** * Initializes the database according to settings in the config. - * + * * If database connection can not be established plugin is disabled. + * * @return true if init was successful, false if not. */ public boolean initDatabase() { diff --git a/Plan/src/main/java/com/djrapitops/plan/command/PlanCommand.java b/Plan/src/main/java/com/djrapitops/plan/command/PlanCommand.java index b2b904b93..a306735e2 100644 --- a/Plan/src/main/java/com/djrapitops/plan/command/PlanCommand.java +++ b/Plan/src/main/java/com/djrapitops/plan/command/PlanCommand.java @@ -114,8 +114,7 @@ public class PlanCommand implements CommandExecutor { } if (console && args.length < 2 && command.getCommandType() == CommandType.CONSOLE_WITH_ARGUMENTS) { - sender.sendMessage("" + Phrase.COMMAND_REQUIRES_ARGUMENTS); - + sender.sendMessage("" + Phrase.COMMAND_REQUIRES_ARGUMENTS.parse(Phrase.USE_PLAN+"")); return true; } diff --git a/Plan/src/main/java/com/djrapitops/plan/command/commands/AnalyzeCommand.java b/Plan/src/main/java/com/djrapitops/plan/command/commands/AnalyzeCommand.java index ddfd24e24..9d1ccede5 100644 --- a/Plan/src/main/java/com/djrapitops/plan/command/commands/AnalyzeCommand.java +++ b/Plan/src/main/java/com/djrapitops/plan/command/commands/AnalyzeCommand.java @@ -29,7 +29,7 @@ public class AnalyzeCommand extends SubCommand { * @param plugin Current instance of Plan */ public AnalyzeCommand(Plan plugin) { - super("analyze, analyse, analysis", "plan.analyze", "View the Server Analysis", CommandType.CONSOLE, ""); + super("analyze, analyse, analysis", "plan.analyze", Phrase.CMD_USG_ANALYZE.parse(), CommandType.CONSOLE, ""); this.plugin = plugin; analysisCache = plugin.getAnalysisCache(); } diff --git a/Plan/src/main/java/com/djrapitops/plan/command/commands/HelpCommand.java b/Plan/src/main/java/com/djrapitops/plan/command/commands/HelpCommand.java index b418b99e6..981f8f570 100644 --- a/Plan/src/main/java/com/djrapitops/plan/command/commands/HelpCommand.java +++ b/Plan/src/main/java/com/djrapitops/plan/command/commands/HelpCommand.java @@ -27,7 +27,7 @@ public class HelpCommand extends SubCommand { * @param command Current instance of PlanCommand */ public HelpCommand(Plan plugin, PlanCommand command) { - super("help,?", "plan.?", "Show command list.", CommandType.CONSOLE, ""); + super("help,?", "plan.?", Phrase.CMD_USG_HELP+"", CommandType.CONSOLE, ""); this.plugin = plugin; this.command = command; @@ -38,10 +38,9 @@ public class HelpCommand extends SubCommand { ChatColor oColor = Phrase.COLOR_MAIN.color(); ChatColor tColor = Phrase.COLOR_SEC.color(); - ChatColor hColor = Phrase.COLOR_TER.color(); // Header - sender.sendMessage(hColor + Phrase.ARROWS_RIGHT.toString() + oColor + " Player Analytics - Help"); + sender.sendMessage(Phrase.CMD_HELP_HEADER+""); // Help results for (SubCommand command : this.command.getCommands()) { if (command.getName().equalsIgnoreCase(getName())) { @@ -60,7 +59,7 @@ public class HelpCommand extends SubCommand { + " /plan " + command.getFirstName() + " " + command.getArguments() + tColor + " - " + command.getUsage()); } // Footer - sender.sendMessage(hColor + Phrase.ARROWS_RIGHT.toString()); + sender.sendMessage(Phrase.CMD_FOOTER+""); return true; } diff --git a/Plan/src/main/java/com/djrapitops/plan/command/commands/InfoCommand.java b/Plan/src/main/java/com/djrapitops/plan/command/commands/InfoCommand.java index 07c475355..5679963a7 100644 --- a/Plan/src/main/java/com/djrapitops/plan/command/commands/InfoCommand.java +++ b/Plan/src/main/java/com/djrapitops/plan/command/commands/InfoCommand.java @@ -23,7 +23,7 @@ public class InfoCommand extends SubCommand { * @param plugin Current instance of Plan */ public InfoCommand(Plan plugin) { - super("info", "plan.info", "View Version of Plan", CommandType.CONSOLE, ""); + super("info", "plan.info", Phrase.CMD_USG_INFO+"", CommandType.CONSOLE, ""); this.plugin = plugin; } diff --git a/Plan/src/main/java/com/djrapitops/plan/command/commands/InspectCommand.java b/Plan/src/main/java/com/djrapitops/plan/command/commands/InspectCommand.java index ae752845b..71beb8581 100644 --- a/Plan/src/main/java/com/djrapitops/plan/command/commands/InspectCommand.java +++ b/Plan/src/main/java/com/djrapitops/plan/command/commands/InspectCommand.java @@ -19,7 +19,6 @@ import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; import org.bukkit.scheduler.BukkitRunnable; import static org.bukkit.Bukkit.getOfflinePlayer; -import static org.bukkit.Bukkit.getOfflinePlayer; /** * @@ -36,7 +35,7 @@ public class InspectCommand extends SubCommand { * @param plugin Current instance of Plan */ public InspectCommand(Plan plugin) { - super("inspect", "plan.inspect", "Inspect Player's Data", CommandType.CONSOLE_WITH_ARGUMENTS, ""); + super("inspect", "plan.inspect", Phrase.CMD_USG_INSPECT+"", CommandType.CONSOLE_WITH_ARGUMENTS, Phrase.ARG_PLAYER+""); this.plugin = plugin; inspectCache = plugin.getInspectCache(); diff --git a/Plan/src/main/java/com/djrapitops/plan/command/commands/ManageCommand.java b/Plan/src/main/java/com/djrapitops/plan/command/commands/ManageCommand.java index 0a4c21a57..134da5527 100644 --- a/Plan/src/main/java/com/djrapitops/plan/command/commands/ManageCommand.java +++ b/Plan/src/main/java/com/djrapitops/plan/command/commands/ManageCommand.java @@ -29,7 +29,7 @@ public class ManageCommand extends SubCommand { * @param plugin Current instance of Plan */ public ManageCommand(Plan plugin) { - super("manage, m", "plan.manage", "Database managment command", CommandType.CONSOLE, ""); + super("manage, m", "plan.manage", Phrase.CMD_USG_MANAGE+"", CommandType.CONSOLE, ""); this.plugin = plugin; commands = new ArrayList<>(); commands.add(new ManageHelpCommand(plugin, this)); @@ -107,7 +107,7 @@ public class ManageCommand extends SubCommand { } if (console && args.length < 2 && command.getCommandType() == CommandType.CONSOLE_WITH_ARGUMENTS) { - sender.sendMessage("" + Phrase.COMMAND_REQUIRES_ARGUMENTS); + sender.sendMessage("" + Phrase.COMMAND_REQUIRES_ARGUMENTS.parse(Phrase.USE_MANAGE+"")); return true; } diff --git a/Plan/src/main/java/com/djrapitops/plan/command/commands/ReloadCommand.java b/Plan/src/main/java/com/djrapitops/plan/command/commands/ReloadCommand.java index 467dd261e..1b221837a 100644 --- a/Plan/src/main/java/com/djrapitops/plan/command/commands/ReloadCommand.java +++ b/Plan/src/main/java/com/djrapitops/plan/command/commands/ReloadCommand.java @@ -1,9 +1,9 @@ package com.djrapitops.plan.command.commands; +import com.djrapitops.plan.Phrase; import com.djrapitops.plan.Plan; import com.djrapitops.plan.command.CommandType; import com.djrapitops.plan.command.SubCommand; -import org.bukkit.ChatColor; import org.bukkit.command.Command; import org.bukkit.command.CommandSender; @@ -21,7 +21,7 @@ public class ReloadCommand extends SubCommand { * @param plugin Current instance of Plan */ public ReloadCommand(Plan plugin) { - super("reload", "plan.reload", "Reload plugin config & save cached data", CommandType.CONSOLE, ""); + super("reload", "plan.reload", Phrase.CMD_USG_RELOAD+"", CommandType.CONSOLE, ""); this.plugin = plugin; } @@ -31,7 +31,7 @@ public class ReloadCommand extends SubCommand { plugin.reloadConfig(); plugin.onDisable(); plugin.onEnable(); - sender.sendMessage(ChatColor.GREEN + "[Plan] Reload complete."); + sender.sendMessage(Phrase.RELOAD_COMPLETE+""); return true; } diff --git a/Plan/src/main/java/com/djrapitops/plan/command/commands/SearchCommand.java b/Plan/src/main/java/com/djrapitops/plan/command/commands/SearchCommand.java index 05a138dff..cd671a52c 100644 --- a/Plan/src/main/java/com/djrapitops/plan/command/commands/SearchCommand.java +++ b/Plan/src/main/java/com/djrapitops/plan/command/commands/SearchCommand.java @@ -24,7 +24,7 @@ import org.bukkit.entity.Player; public class SearchCommand extends SubCommand { private final Plan plugin; - private InspectCacheHandler inspectCache; + private final InspectCacheHandler inspectCache; /** * Class Constructor. @@ -32,7 +32,7 @@ public class SearchCommand extends SubCommand { * @param plugin Current instance of Plan */ public SearchCommand(Plan plugin) { - super("search", "plan.search", "Search for player", CommandType.CONSOLE_WITH_ARGUMENTS, ""); + super("search", "plan.search", Phrase.CMD_USG_SEARCH+"", CommandType.CONSOLE_WITH_ARGUMENTS, Phrase.ARG_SEARCH+""); this.plugin = plugin; inspectCache = plugin.getInspectCache(); } diff --git a/Plan/src/main/java/com/djrapitops/plan/command/commands/manage/ManageBackupCommand.java b/Plan/src/main/java/com/djrapitops/plan/command/commands/manage/ManageBackupCommand.java index 3c1403de7..63c85ae83 100644 --- a/Plan/src/main/java/com/djrapitops/plan/command/commands/manage/ManageBackupCommand.java +++ b/Plan/src/main/java/com/djrapitops/plan/command/commands/manage/ManageBackupCommand.java @@ -31,7 +31,7 @@ public class ManageBackupCommand extends SubCommand { * @param plugin Current instance of Plan */ public ManageBackupCommand(Plan plugin) { - super("backup", "plan.manage", "Backup a database to .db file", CommandType.CONSOLE, ""); + super("backup", "plan.manage", Phrase.CMD_USG_MANAGE_BACKUP+"", CommandType.CONSOLE, ""); this.plugin = plugin; } @@ -49,7 +49,7 @@ public class ManageBackupCommand extends SubCommand { public boolean onCommand(CommandSender sender, Command cmd, String commandLabel, String[] args) { try { if (args.length < 1) { - sender.sendMessage(Phrase.COMMAND_REQUIRES_ARGUMENTS.toString() + " Use /plan manage backup "); + sender.sendMessage(Phrase.COMMAND_REQUIRES_ARGUMENTS.parse(Phrase.USE_BACKUP+"")); return true; } String db = args[0].toLowerCase(); diff --git a/Plan/src/main/java/com/djrapitops/plan/command/commands/manage/ManageClearCommand.java b/Plan/src/main/java/com/djrapitops/plan/command/commands/manage/ManageClearCommand.java index 3796d0eb7..678793f23 100644 --- a/Plan/src/main/java/com/djrapitops/plan/command/commands/manage/ManageClearCommand.java +++ b/Plan/src/main/java/com/djrapitops/plan/command/commands/manage/ManageClearCommand.java @@ -17,7 +17,7 @@ import org.bukkit.scheduler.BukkitRunnable; */ public class ManageClearCommand extends SubCommand { - private Plan plugin; + private final Plan plugin; /** * Class Constructor. @@ -25,7 +25,7 @@ public class ManageClearCommand extends SubCommand { * @param plugin Current instance of Plan */ public ManageClearCommand(Plan plugin) { - super("clear", "plan.manage", "Clear data from one database", CommandType.CONSOLE_WITH_ARGUMENTS, " [-a]"); + super("clear", "plan.manage", Phrase.CMD_USG_MANAGE_CLEAR+"", CommandType.CONSOLE_WITH_ARGUMENTS, " [-a]"); this.plugin = plugin; } @@ -55,7 +55,7 @@ public class ManageClearCommand extends SubCommand { return true; } if (!Arrays.asList(args).contains("-a")) { - sender.sendMessage(Phrase.COMMAND_ADD_CONFIRMATION_ARGUMENT.toString() + " Data in " + args[0] + "-database will be removed!"); + sender.sendMessage(Phrase.COMMAND_ADD_CONFIRMATION_ARGUMENT.parse(Phrase.WARN_REMOVE.parse(args[0]))); return true; } diff --git a/Plan/src/main/java/com/djrapitops/plan/command/commands/manage/ManageCombineCommand.java b/Plan/src/main/java/com/djrapitops/plan/command/commands/manage/ManageCombineCommand.java index 52d1ff35c..396170dca 100644 --- a/Plan/src/main/java/com/djrapitops/plan/command/commands/manage/ManageCombineCommand.java +++ b/Plan/src/main/java/com/djrapitops/plan/command/commands/manage/ManageCombineCommand.java @@ -34,7 +34,7 @@ public class ManageCombineCommand extends SubCommand { * @param plugin Current instance of Plan */ public ManageCombineCommand(Plan plugin) { - super("combine", "plan.manage", "Copy data from one database to another & combine values", CommandType.CONSOLE_WITH_ARGUMENTS, " [-a]"); + super("combine", "plan.manage", Phrase.CMD_USG_MANAGE_COMBINE+"", CommandType.CONSOLE_WITH_ARGUMENTS, Phrase.ARG_MOVE+""); this.plugin = plugin; } @@ -54,7 +54,7 @@ public class ManageCombineCommand extends SubCommand { @Override public boolean onCommand(CommandSender sender, Command cmd, String commandLabel, String[] args) { if (args.length < 2) { - sender.sendMessage(Phrase.COMMAND_REQUIRES_ARGUMENTS.toString() + " Use /plan manage combine [-a]"); + sender.sendMessage(Phrase.COMMAND_REQUIRES_ARGUMENTS.parse(Phrase.USE_COMBINE+"")); return true; } String fromDB = args[0].toLowerCase(); @@ -72,7 +72,7 @@ public class ManageCombineCommand extends SubCommand { return true; } if (!Arrays.asList(args).contains("-a")) { - sender.sendMessage(Phrase.COMMAND_ADD_CONFIRMATION_ARGUMENT.toString() + " Data in " + args[1] + "-database will be rewritten!"); + sender.sendMessage(Phrase.COMMAND_ADD_CONFIRMATION_ARGUMENT.parse(Phrase.WARN_REWRITE.parse(args[1]))); return true; } diff --git a/Plan/src/main/java/com/djrapitops/plan/command/commands/manage/ManageImportCommand.java b/Plan/src/main/java/com/djrapitops/plan/command/commands/manage/ManageImportCommand.java index ef6a79cfd..6de768ffc 100644 --- a/Plan/src/main/java/com/djrapitops/plan/command/commands/manage/ManageImportCommand.java +++ b/Plan/src/main/java/com/djrapitops/plan/command/commands/manage/ManageImportCommand.java @@ -2,7 +2,6 @@ package main.java.com.djrapitops.plan.command.commands.manage; import com.djrapitops.plan.Phrase; import com.djrapitops.plan.Plan; -import com.djrapitops.plan.PlanLiteHook; import com.djrapitops.plan.command.CommandType; import com.djrapitops.plan.command.SubCommand; import com.djrapitops.plan.data.UserData; @@ -17,13 +16,11 @@ import main.java.com.djrapitops.plan.data.importing.Importer; import main.java.com.djrapitops.plan.data.importing.OnTimeImporter; import org.bukkit.Bukkit; -import org.bukkit.ChatColor; import org.bukkit.GameMode; import org.bukkit.OfflinePlayer; import org.bukkit.command.Command; import org.bukkit.command.CommandSender; import static org.bukkit.Bukkit.getOfflinePlayer; -import static org.bukkit.Bukkit.getOfflinePlayer; /** * @@ -31,8 +28,7 @@ import static org.bukkit.Bukkit.getOfflinePlayer; */ public class ManageImportCommand extends SubCommand { - private Plan plugin; - private PlanLiteHook hook; + private final Plan plugin; /** * Class Constructor. @@ -40,9 +36,8 @@ public class ManageImportCommand extends SubCommand { * @param plugin Current instance of Plan */ public ManageImportCommand(Plan plugin) { - super("import", "plan.manage", "Import Data from supported plugins to Active Database.", CommandType.CONSOLE, " [-a]"); + super("import", "plan.manage", Phrase.CMD_USG_MANAGE_IMPORT+"", CommandType.CONSOLE, Phrase.ARG_IMPORT+""); this.plugin = plugin; - hook = plugin.getPlanLiteHook(); } /** @@ -62,7 +57,7 @@ public class ManageImportCommand extends SubCommand { public boolean onCommand(CommandSender sender, Command cmd, String commandLabel, String[] args) { if (args.length < 1) { - sender.sendMessage(Phrase.COMMAND_REQUIRES_ARGUMENTS_ONE.toString() + " Use /plan manage import [-a]"); + sender.sendMessage(Phrase.COMMAND_REQUIRES_ARGUMENTS_ONE.toString() + " "+Phrase.USE_IMPORT); return true; } @@ -81,29 +76,24 @@ public class ManageImportCommand extends SubCommand { } if (!Arrays.asList(args).contains("-a")) { - sender.sendMessage(Phrase.COMMAND_ADD_CONFIRMATION_ARGUMENT.toString() + " Some data in " + plugin.getDB().getConfigName() + "-database will be overwritten!"); + sender.sendMessage(Phrase.COMMAND_ADD_CONFIRMATION_ARGUMENT.parse(Phrase.WARN_OVERWRITE_SOME.parse(plugin.getDB().getConfigName()))); return true; } - ChatColor oColor = Phrase.COLOR_MAIN.color(); - ChatColor hColor = Phrase.COLOR_TER.color(); - // Header - sender.sendMessage(hColor + Phrase.ARROWS_RIGHT.toString() + oColor + " Importing Data.."); + sender.sendMessage(Phrase.MANAGE_IMPORTING+""); Set uuids = new HashSet<>(); for (OfflinePlayer p : Bukkit.getOfflinePlayers()) { uuids.add(p.getUniqueId()); } - HashMap onTimeData = importPlugins.get(importFromPlugin).grabNumericData(uuids); + HashMap numbericData = importPlugins.get(importFromPlugin).grabNumericData(uuids); DataCacheHandler handler = plugin.getHandler(); if (importFromPlugin.equals("ontime")) { - importOnTime(onTimeData, handler); + importOnTime(numbericData, handler); } handler.saveCachedUserData(); - // Footer - sender.sendMessage(hColor - + Phrase.ARROWS_RIGHT.toString() + oColor + " Success!"); + sender.sendMessage(Phrase.MANAGE_SUCCESS+""); return true; } diff --git a/Plan/src/main/java/com/djrapitops/plan/command/commands/manage/ManageMoveCommand.java b/Plan/src/main/java/com/djrapitops/plan/command/commands/manage/ManageMoveCommand.java index f29deda43..2fe55dde3 100644 --- a/Plan/src/main/java/com/djrapitops/plan/command/commands/manage/ManageMoveCommand.java +++ b/Plan/src/main/java/com/djrapitops/plan/command/commands/manage/ManageMoveCommand.java @@ -33,7 +33,7 @@ public class ManageMoveCommand extends SubCommand { * @param plugin Current instance of Plan */ public ManageMoveCommand(Plan plugin) { - super("move", "plan.manage", "Copy data from one database to another & overwrite values", CommandType.CONSOLE_WITH_ARGUMENTS, " [-a]"); + super("move", "plan.manage", Phrase.CMD_USG_MANAGE_MOVE+"", CommandType.CONSOLE_WITH_ARGUMENTS, Phrase.ARG_MOVE+""); this.plugin = plugin; } @@ -54,7 +54,7 @@ public class ManageMoveCommand extends SubCommand { @Override public boolean onCommand(CommandSender sender, Command cmd, String commandLabel, String[] args) { if (args.length < 2) { - sender.sendMessage(Phrase.COMMAND_REQUIRES_ARGUMENTS.toString() + " Use /plan manage move [-a]"); + sender.sendMessage(Phrase.COMMAND_REQUIRES_ARGUMENTS.parse(Phrase.USE_MOVE+"")); return true; } String fromDB = args[0].toLowerCase(); @@ -72,7 +72,7 @@ public class ManageMoveCommand extends SubCommand { return true; } if (!Arrays.asList(args).contains("-a")) { - sender.sendMessage(Phrase.COMMAND_ADD_CONFIRMATION_ARGUMENT.toString() + " Data in " + args[1] + "-database will be overwritten!"); + sender.sendMessage(Phrase.COMMAND_ADD_CONFIRMATION_ARGUMENT.parse(Phrase.WARN_OVERWRITE.parse(args[1]))); return true; } diff --git a/Plan/src/main/java/com/djrapitops/plan/command/commands/manage/ManageRemoveCommand.java b/Plan/src/main/java/com/djrapitops/plan/command/commands/manage/ManageRemoveCommand.java index 0b35e1ae9..90c1c3abe 100644 --- a/Plan/src/main/java/com/djrapitops/plan/command/commands/manage/ManageRemoveCommand.java +++ b/Plan/src/main/java/com/djrapitops/plan/command/commands/manage/ManageRemoveCommand.java @@ -10,13 +10,11 @@ import com.djrapitops.plan.utilities.MiscUtils; import java.util.Arrays; import java.util.UUID; -import org.bukkit.ChatColor; import org.bukkit.OfflinePlayer; import org.bukkit.command.Command; import org.bukkit.command.CommandSender; import org.bukkit.scheduler.BukkitRunnable; import static org.bukkit.Bukkit.getOfflinePlayer; -import static org.bukkit.Bukkit.getOfflinePlayer; /** * @@ -24,7 +22,7 @@ import static org.bukkit.Bukkit.getOfflinePlayer; */ public class ManageRemoveCommand extends SubCommand { - private Plan plugin; + private final Plan plugin; /** * Class Constructor. @@ -32,7 +30,7 @@ public class ManageRemoveCommand extends SubCommand { * @param plugin Current instance of Plan */ public ManageRemoveCommand(Plan plugin) { - super("remove", "plan.manage", "Remove players's data from the Active Database.", CommandType.CONSOLE_WITH_ARGUMENTS, " [-a]"); + super("remove", "plan.manage", Phrase.CMD_USG_MANAGE_REMOVE+"", CommandType.CONSOLE_WITH_ARGUMENTS, Phrase.ARG_PLAYER+" [-a]"); this.plugin = plugin; } @@ -79,19 +77,16 @@ public class ManageRemoveCommand extends SubCommand { return true; } if (!Arrays.asList(args).contains("-a")) { - sender.sendMessage(Phrase.COMMAND_ADD_CONFIRMATION_ARGUMENT.toString()); + sender.sendMessage(Phrase.COMMAND_ADD_CONFIRMATION_ARGUMENT.parse(Phrase.WARN_REMOVE.parse(plugin.getDB().getConfigName()))); return true; } - - ChatColor oColor = Phrase.COLOR_MAIN.color(); - ChatColor hColor = Phrase.COLOR_TER.color(); - + (new BukkitRunnable() { @Override public void run() { sender.sendMessage(Phrase.MANAGE_PROCESS_START.parse()); plugin.getDB().removeAccount(uuid.toString()); - sender.sendMessage(hColor+""+Phrase.ARROWS_RIGHT+" "+oColor+"Data of "+hColor+playerName+oColor+" was removed from Database "+hColor+plugin.getDB().getConfigName()+oColor+"."); + sender.sendMessage(Phrase.MANAGE_REMOVE_SUCCESS.parse(playerName, plugin.getDB().getConfigName())); this.cancel(); } }).runTaskAsynchronously(plugin); diff --git a/Plan/src/main/java/com/djrapitops/plan/command/commands/manage/ManageRestoreCommand.java b/Plan/src/main/java/com/djrapitops/plan/command/commands/manage/ManageRestoreCommand.java index a6640e257..fec099450 100644 --- a/Plan/src/main/java/com/djrapitops/plan/command/commands/manage/ManageRestoreCommand.java +++ b/Plan/src/main/java/com/djrapitops/plan/command/commands/manage/ManageRestoreCommand.java @@ -32,7 +32,7 @@ public class ManageRestoreCommand extends SubCommand { * @param plugin Current instance of Plan */ public ManageRestoreCommand(Plan plugin) { - super("restore", "plan.restore", "Restore a database from a backup file", CommandType.CONSOLE, " [-a]"); + super("restore", "plan.restore", Phrase.CMD_USG_MANAGE_RESTORE+"", CommandType.CONSOLE, Phrase.ARG_RESTORE+""); this.plugin = plugin; } @@ -50,7 +50,7 @@ public class ManageRestoreCommand extends SubCommand { public boolean onCommand(CommandSender sender, Command cmd, String commandLabel, String[] args) { try { if (args.length < 2) { - sender.sendMessage(Phrase.COMMAND_REQUIRES_ARGUMENTS.toString() + " Use /plan manage restore [-a]"); + sender.sendMessage(Phrase.COMMAND_REQUIRES_ARGUMENTS.parse(Phrase.USE_RESTORE+"")); return true; } String db = args[1].toLowerCase(); @@ -59,7 +59,7 @@ public class ManageRestoreCommand extends SubCommand { return true; } if (!Arrays.asList(args).contains("-a")) { - sender.sendMessage(Phrase.COMMAND_ADD_CONFIRMATION_ARGUMENT.toString() + " Data in " + args[1] + "-database will be rewritten!"); + sender.sendMessage(Phrase.COMMAND_ADD_CONFIRMATION_ARGUMENT.parse(Phrase.WARN_REWRITE.parse(args[1]))); return true; } Database database = null; diff --git a/Plan/src/main/java/com/djrapitops/plan/command/commands/manage/ManageStatusCommand.java b/Plan/src/main/java/com/djrapitops/plan/command/commands/manage/ManageStatusCommand.java index f58a727b9..594811ce1 100644 --- a/Plan/src/main/java/com/djrapitops/plan/command/commands/manage/ManageStatusCommand.java +++ b/Plan/src/main/java/com/djrapitops/plan/command/commands/manage/ManageStatusCommand.java @@ -24,7 +24,7 @@ public class ManageStatusCommand extends SubCommand { * @param plugin Current instance of Plan */ public ManageStatusCommand(Plan plugin) { - super("status", "plan.manage", "Check the status of the Active Database.", CommandType.CONSOLE, ""); + super("status", "plan.manage", Phrase.CMD_USG_MANAGE_STATUS+"", CommandType.CONSOLE, ""); this.plugin = plugin; } @@ -44,15 +44,12 @@ public class ManageStatusCommand extends SubCommand { */ @Override public boolean onCommand(CommandSender sender, Command cmd, String commandLabel, String[] args) { - - ChatColor oColor = Phrase.COLOR_MAIN.color(); - ChatColor tColor = Phrase.COLOR_SEC.color(); ChatColor hColor = Phrase.COLOR_TER.color(); // Header - sender.sendMessage(hColor + Phrase.ARROWS_RIGHT.toString() + oColor + " Player Analytics - Database status"); + sender.sendMessage(Phrase.CMD_MANAGE_STATUS_HEADER+""); - sender.sendMessage(tColor + " " + Phrase.BALL.toString() + oColor +" Active Database: "+ tColor + plugin.getDB().getConfigName()); + sender.sendMessage(Phrase.CMD_MANAGE_STATUS_ACTIVE_DB.parse(plugin.getDB().getConfigName())); // Footer sender.sendMessage(hColor + Phrase.ARROWS_RIGHT.toString()); diff --git a/Plan/src/main/java/com/djrapitops/plan/data/AdditionalData.java b/Plan/src/main/java/com/djrapitops/plan/data/AdditionalData.java new file mode 100644 index 000000000..0a18a0c27 --- /dev/null +++ b/Plan/src/main/java/com/djrapitops/plan/data/AdditionalData.java @@ -0,0 +1,10 @@ + +package main.java.com.djrapitops.plan.data; + +/** + * + * @author Rsl1122 + */ +public class AdditionalData { + +} diff --git a/Plan/src/main/java/com/djrapitops/plan/data/importing/OnTimeImporter.java b/Plan/src/main/java/com/djrapitops/plan/data/importing/OnTimeImporter.java index c9a82e03f..d362406d0 100644 --- a/Plan/src/main/java/com/djrapitops/plan/data/importing/OnTimeImporter.java +++ b/Plan/src/main/java/com/djrapitops/plan/data/importing/OnTimeImporter.java @@ -1,7 +1,6 @@ package main.java.com.djrapitops.plan.data.importing; import com.djrapitops.plan.Plan; -import com.djrapitops.plan.data.UserData; import java.util.HashMap; import java.util.Set; import java.util.UUID; @@ -16,7 +15,7 @@ import org.bukkit.OfflinePlayer; */ public class OnTimeImporter implements Importer { - private Plan plugin; + private final Plan plugin; private boolean enabled; public OnTimeImporter(Plan plugin) { diff --git a/Plan/src/main/java/com/djrapitops/plan/ui/Html.java b/Plan/src/main/java/com/djrapitops/plan/ui/Html.java index e8061e0d1..563fb9a37 100644 --- a/Plan/src/main/java/com/djrapitops/plan/ui/Html.java +++ b/Plan/src/main/java/com/djrapitops/plan/ui/Html.java @@ -1,5 +1,14 @@ package main.java.com.djrapitops.plan.ui; +import com.djrapitops.plan.Phrase; +import com.djrapitops.plan.Plan; +import java.io.File; +import java.io.IOException; +import java.util.ArrayList; +import java.util.List; +import java.util.Scanner; +import static org.bukkit.plugin.java.JavaPlugin.getPlugin; + /** * * @author Rsl1122 @@ -25,35 +34,34 @@ public enum Html { COLOR_d(""), COLOR_e(""), COLOR_f(""), - SPAN(""+REPLACE0+""), - BUTTON(""+REPLACE1+""), + SPAN("" + REPLACE0 + ""), + BUTTON("" + REPLACE1 + ""), BUTTON_CLASS("class=\"button\""), LINK_CLASS("class=\"link\""), TABLE_START(""), TABLE_END("
"), - TABLELINE(""+REPLACE0+"\r\n"+REPLACE1+""), + TABLELINE("" + REPLACE0 + "\r\n" + REPLACE1 + ""), ERROR_TABLE("

Error Calcuclating Table (No data)

"), - IMG(""), + IMG(""), TOP_TOWNS("

Top 20 Towns

"), TOP_FACTIONS("

Top 20 Factions

"), - TOTAL_BALANCE("

Server Total Balance: "+REPLACE0+"

"), - TOTAL_VOTES("

Players have voted total of "+REPLACE0+" times.

"), - TOWN("

Town: "+REPLACE0+"

"), - PLOT_OPTIONS("

Plot options: "+REPLACE0+"

"), - FRIENDS("

Friends with "+REPLACE0+"

"), + TOTAL_BALANCE("

Server Total Balance: " + REPLACE0 + "

"), + TOTAL_VOTES("

Players have voted total of " + REPLACE0 + " times.

"), + TOWN("

Town: " + REPLACE0 + "

"), + PLOT_OPTIONS("

Plot options: " + REPLACE0 + "

"), + FRIENDS("

Friends with " + REPLACE0 + "

"), FACTION("

Faction: " + REPLACE0 + "

"), BALANCE("

Balance: " + REPLACE0 + "

"), VOTES("

Player has voted " + REPLACE0 + " times.

"), - BANNED("| "+SPAN.parse(COLOR_4.parse()+"Banned")), + BANNED("| " + SPAN.parse(COLOR_4.parse() + "Banned")), OPERATOR(", Operator (Op)"), - ONLINE("| "+SPAN.parse(COLOR_2.parse()+"Online")), - OFFLINE("| "+SPAN.parse(COLOR_4.parse()+"Offline")), + 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

"), - ; + ERROR_LIST("Error Creating List

"),; - private final String html; + private String html; private Html(String html) { this.html = html; @@ -71,4 +79,27 @@ public enum Html { return returnValue; } + public void setHtml(String html) { + this.html = html; + } + + public static void loadLocale(File localeFile) { + try { + Scanner localeScanner = new Scanner(localeFile, "UTF-8"); + List localeRows = new ArrayList<>(); + while (localeScanner.hasNextLine()) { + localeRows.add(localeScanner.nextLine()); + } + for (String localeRow : localeRows) { + try { + String[] split = localeRow.split(" <> "); + Html.valueOf(split[0]).setHtml(split[1]); + } catch (IllegalArgumentException e) { + getPlugin(Plan.class).logError("There is a miswritten line in locale on line " + localeRows.indexOf(localeRow)); + } + } + } catch (IOException e) { + + } + } } diff --git a/Plan/src/main/java/com/djrapitops/plan/ui/webserver/WebSocketServer.java b/Plan/src/main/java/com/djrapitops/plan/ui/webserver/WebSocketServer.java index e440e0091..8504cde98 100644 --- a/Plan/src/main/java/com/djrapitops/plan/ui/webserver/WebSocketServer.java +++ b/Plan/src/main/java/com/djrapitops/plan/ui/webserver/WebSocketServer.java @@ -1,5 +1,6 @@ package main.java.com.djrapitops.plan.ui.webserver; +import com.djrapitops.plan.Phrase; import com.djrapitops.plan.Plan; import com.djrapitops.plan.ui.DataRequestHandler; import com.djrapitops.plan.ui.webserver.Request; @@ -19,12 +20,12 @@ import org.bukkit.scheduler.BukkitRunnable; */ public class WebSocketServer { - private int PORT; + private final int PORT; private boolean ENABLED = false; private ServerSocket server; - private Plan plugin; - private DataRequestHandler dataReqHandler; + private final Plan plugin; + private final DataRequestHandler dataReqHandler; private boolean shutdown; @@ -50,7 +51,7 @@ public class WebSocketServer { if (ENABLED) { return; } - plugin.log("Initializing Webserver.."); + plugin.log(Phrase.WEBSERVER_INIT+""); try { //Setup server try { @@ -86,7 +87,7 @@ public class WebSocketServer { ENABLED = true; - plugin.log("Webserver running on PORT " + server.getLocalPort()); + plugin.log(Phrase.WEBSERVER_RUNNING.parse(server.getLocalPort()+"")); } catch (Exception e) { ENABLED = false; } @@ -96,7 +97,7 @@ public class WebSocketServer { * Shuts down the server - Async thread is closed with shutdown boolean. */ public void stop() { - plugin.log("Shutting down Webserver.."); + plugin.log(Phrase.WEBSERVER_CLOSE+""); shutdown = true; try { server.close(); diff --git a/Plan/src/main/java/com/djrapitops/plan/utilities/FormatUtils.java b/Plan/src/main/java/com/djrapitops/plan/utilities/FormatUtils.java index 7e983fdb9..8075957bc 100644 --- a/Plan/src/main/java/com/djrapitops/plan/utilities/FormatUtils.java +++ b/Plan/src/main/java/com/djrapitops/plan/utilities/FormatUtils.java @@ -1,6 +1,5 @@ package com.djrapitops.plan.utilities; -import java.util.Arrays; import java.util.Date; import main.java.com.djrapitops.plan.ui.Html; import org.bukkit.Location; @@ -157,7 +156,6 @@ public class FormatUtils { Html.COLOR_4, Html.COLOR_5, Html.COLOR_6, Html.COLOR_7, Html.COLOR_8, Html.COLOR_9, Html.COLOR_a, Html.COLOR_b, Html.COLOR_c, Html.COLOR_d, Html.COLOR_e, Html.COLOR_f}; - for (Html html : replacer) { string = string.replaceAll("§"+html.name().charAt(6), html.parse()); }