[2.6.4-SNAPSHOT] All important things now use Phrase and Html, Bugfix for #24

Plugin.yml version not changed to not push update notification
This commit is contained in:
Rsl1122 2017-02-23 19:44:52 +02:00
parent b41c51f103
commit de1a4570b1
30 changed files with 161 additions and 154 deletions

View File

@ -18,8 +18,9 @@ public enum Phrase {
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."),
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.."),
@ -27,8 +28,8 @@ public enum Phrase {
WEBSERVER_RUNNING("Webserver running on PORT " + REPLACE0),
DB_CONNECTION_FAIL("REPLACE0-Database Connection failed: REPLACE1"),
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."),
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 + "" + 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/"),
@ -56,7 +57,7 @@ public enum Phrase {
//
ARROWS_RIGHT("»"),
BALL(""),
GRABBING_DATA_MESSAGE(COLOR_TER + "" + ARROWS_RIGHT + COLOR_MAIN + " Fetching data to cache.."),
GRABBING_DATA_MESSAGE(COLOR_TER + "" + ARROWS_RIGHT + COLOR_MAIN.color() + " Fetching data to cache.."),
//
DEM_UNKNOWN("Not Known"),
NOT_IN_TOWN("Not in a town"),
@ -75,12 +76,12 @@ public enum Phrase {
ANALYSIS_COMPLETE(ANALYSIS + "Analysis Complete."),
DATA_CORRUPTION_WARN("Some data might be corrupted: " + REPLACE0),
//
ERROR_PLANLITE("PlanLite not found, if you're have plugins using PlanAPI v1.6.0 download PlanLite."),
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/planlite is enabled on this server."),
ERROR_LOGGED("Ran into an error. It has been logged to the Errors.txt"),
ERROR_SESSIONDATA_INITIALIZATION("Player's session was initialized in a wrong way! (" + REPLACE0 + ")"),
//
CMD_FOOTER(COLOR_TER.color() + "" + ARROWS_RIGHT),
MANAGE_ERROR_INCORRECT_PLUGIN(ChatColor.RED + "" + PREFIX + "Plugin not supported: "),
@ -103,13 +104,16 @@ public enum Phrase {
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_INFO_HEADER(CMD_FOOTER + "" + COLOR_MAIN.color() + " Player Analytics - Info"),
CMD_INFO_VERSION(CMD_BALL + "" + COLOR_MAIN.color() + " Version: " + COLOR_SEC.color() + REPLACE0),
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_HELP_HEADER(CMD_FOOTER + "" + COLOR_MAIN.color() + " Player Analytics - Managment 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.."),
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 player: " + COLOR_TER.color()),
@ -127,6 +131,8 @@ public enum Phrase {
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_MANAGE_HELP("Show managment 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>"),

View File

@ -60,7 +60,6 @@ Location Analysis to view meaningful locations on Dynmap (Investigate dynmap api
Text interface
Database Cleaning of useless data
Add -n argument for nickname search.
Location saving & getting seperately
Fix any bugs that come up
Random security code generation
*/
@ -109,7 +108,7 @@ public class Plan extends JavaPlugin {
if (initDatabase()) {
log(Phrase.DB_ESTABLISHED.parse(db.getConfigName()));
} else {
logError(Phrase.DATABASE_FAILURE_DISABLE.toString());
logError(Phrase.DB_FAILURE_DISABLE.toString());
getServer().getPluginManager().disablePlugin(this);
return;
}
@ -160,7 +159,7 @@ public class Plan extends JavaPlugin {
}
Bukkit.getScheduler().cancelTasks(this);
if (handler != null) {
log(Phrase.SAVE_CACHE + "");
log(Phrase.CACHE_SAVE + "");
ScheduledExecutorService scheduler = Executors.newScheduledThreadPool(1);
scheduler.execute(() -> {
handler.saveCacheOnDisable();
@ -263,11 +262,11 @@ public class Plan extends JavaPlugin {
}
}
if (db == null) {
log(Phrase.DATABASE_TYPE_DOES_NOT_EXIST.toString());
log(Phrase.DB_TYPE_DOES_NOT_EXIST.toString());
return false;
}
if (!db.init()) {
log(Phrase.DATABASE_FAILURE_DISABLE.toString());
log(Phrase.DB_FAILURE_DISABLE.toString());
setEnabled(false);
return false;
}

View File

@ -1,6 +1,5 @@
package main.java.com.djrapitops.plan.command.commands;
//import main.java.com.djrapitops.plan.Phrase;
import main.java.com.djrapitops.plan.Phrase;
import main.java.com.djrapitops.plan.Plan;
import main.java.com.djrapitops.plan.command.CommandType;

View File

@ -30,16 +30,14 @@ public class InfoCommand 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();
String[] messages = {
hColor + Phrase.ARROWS_RIGHT.toString() + oColor + " Player Analytics - Info",
tColor + " " + Phrase.BALL.toString() + oColor + " Version: " + tColor + plugin.getDescription().getVersion(),
tColor + " " + Phrase.BALL.toString() + tColor + " " + MiscUtils.checkVersion(),
tColor + " " + Phrase.BALL.toString() + oColor +" Active Database: "+ tColor + plugin.getDB().getConfigName(),
hColor + Phrase.ARROWS_RIGHT.toString()
Phrase.CMD_INFO_HEADER+"",
Phrase.CMD_INFO_VERSION.parse(plugin.getDescription().getVersion()),
Phrase.CMD_BALL.toString() + tColor + " " + MiscUtils.checkVersion(),
Phrase.CMD_MANAGE_STATUS_ACTIVE_DB.parse(plugin.getDB().getConfigName()),
Phrase.CMD_FOOTER+""
};
sender.sendMessage(messages);
return true;

View File

@ -123,7 +123,6 @@ public class ManageCommand extends SubCommand {
}
if (!command.onCommand(sender, cmd, commandLabel, realArgs)) {
// Phrase.TRY_COMMAND.sendWithPrefix( sender, parse( commandLabel, command ) );
}
return true;
}

View File

@ -26,7 +26,7 @@ public class ManageHelpCommand extends SubCommand {
* @param command Current instance of PlanCommand
*/
public ManageHelpCommand(Plan plugin, ManageCommand command) {
super("help,?", "plan.manage", "Show managment help.", CommandType.CONSOLE, "");
super("help,?", "plan.manage", Phrase.CMD_USG_MANAGE_HELP+"", CommandType.CONSOLE, "");
this.plugin = plugin;
this.command = command;
@ -40,7 +40,7 @@ public class ManageHelpCommand extends SubCommand {
ChatColor hColor = Phrase.COLOR_TER.color();
// Header
sender.sendMessage(hColor + Phrase.ARROWS_RIGHT.toString() + oColor + " Player Analytics - Managment Help");
sender.sendMessage(Phrase.CMD_MANAGE_HELP_HEADER+"");
// Help results
for (SubCommand command : this.command.getCommands()) {
if (command.getName().equalsIgnoreCase(getName())) {

View File

@ -23,18 +23,15 @@ public class ManageHotswapCommand extends SubCommand {
* @param plugin Current instance of Plan
*/
public ManageHotswapCommand(Plan plugin) {
super("hotswap", "plan.manage", "Hotswap to another database & restart the plugin", CommandType.CONSOLE_WITH_ARGUMENTS, "<DB>");
super("hotswap", "plan.manage", Phrase.CMD_USG_MANAGE_HOTSWAP+"", CommandType.CONSOLE_WITH_ARGUMENTS, "<DB>");
this.plugin = plugin;
}
/**
* Subcommand inspect.
*
* Adds player's data from DataCache/DB to the InspectCache for amount of
* time specified in the config, and clears the data from Cache with a timer
* task.
*
* Subcommand hotswap.
* Swaps db type and reloads plugin if the connection works.
*
* @param sender
* @param cmd
* @param commandLabel

View File

@ -118,6 +118,7 @@ public class ManageImportCommand extends SubCommand {
}
}
};
handler.getUserDataForProcessing(importer, uuid);
}
handler.saveCachedUserData();
sender.sendMessage(Phrase.MANAGE_SUCCESS + "");

View File

@ -1,5 +1,7 @@
package main.java.com.djrapitops.plan.data;
import main.java.com.djrapitops.plan.ui.Html;
/**
*
* @author Rsl1122
@ -50,15 +52,15 @@ public class AnalysisData {
* All data has to be set with setters to avoid NPE.
*/
public AnalysisData() {
sortablePlayersTable = "Error: Replace rule was not set";
gmTimesChartImgHtml = "Error: Replace rule was not set";
playersChartImgHtmlMonth = "Error: Replace rule was not set";
playersChartImgHtmlWeek = "Error: Replace rule was not set";
playersChartImgHtmlDay = "Error: Replace rule was not set";
activityChartImgHtml = "Error: Replace rule was not set";
top50CommandsListHtml = "Error: Replace rule was not set";
top20ActivePlayers = "Error: Replace rule was not set";
recentPlayers = "Error: Replace rule was not set";
sortablePlayersTable = Html.ERROR_NOT_SET+"";
gmTimesChartImgHtml = Html.ERROR_NOT_SET+"";
playersChartImgHtmlMonth = Html.ERROR_NOT_SET+"";
playersChartImgHtmlWeek = Html.ERROR_NOT_SET+"";
playersChartImgHtmlDay = Html.ERROR_NOT_SET+"";
activityChartImgHtml = Html.ERROR_NOT_SET+"";
top50CommandsListHtml = Html.ERROR_NOT_SET+"";
top20ActivePlayers = Html.ERROR_NOT_SET+"";
recentPlayers = Html.ERROR_NOT_SET+"";
}
// Getters and setters v---------------------------------v

View File

@ -54,7 +54,7 @@ public class UserData {
nicknames = new HashSet<>();
ips = new HashSet<>();
gmTimes = new HashMap<>();
long zero = Long.parseLong("0");
long zero = 0;
gmTimes.put(GameMode.SURVIVAL, zero);
gmTimes.put(GameMode.CREATIVE, zero);
gmTimes.put(GameMode.ADVENTURE, zero);
@ -81,7 +81,7 @@ public class UserData {
nicknames = new HashSet<>();
ips = new HashSet<>();
gmTimes = new HashMap<>();
long zero = Long.parseLong("0");
long zero = 0;
gmTimes.put(GameMode.SURVIVAL, zero);
gmTimes.put(GameMode.CREATIVE, zero);
gmTimes.put(GameMode.ADVENTURE, zero);

View File

@ -1,6 +1,5 @@
package main.java.com.djrapitops.plan.data.additional;
import com.massivecraft.factions.Factions;
import com.massivecraft.factions.entity.Faction;
import com.massivecraft.factions.entity.FactionColl;
import com.massivecraft.factions.entity.MPlayer;
@ -11,7 +10,9 @@ import java.util.HashMap;
import java.util.List;
import java.util.UUID;
import java.util.stream.Collectors;
import main.java.com.djrapitops.plan.Phrase;
import main.java.com.djrapitops.plan.Plan;
import main.java.com.djrapitops.plan.ui.Html;
import main.java.com.djrapitops.plan.utilities.comparators.FactionComparator;
/**
@ -69,14 +70,14 @@ public class FactionsHook extends Hook {
if (leader != null) {
info.put("LEADER", leader.getNameAndSomething("", ""));
} else {
info.put("LEADER", "No leader");
info.put("LEADER", Html.FACTION_NO_LEADER.parse());
}
info.put("POWER", faction.getPower());
info.put("LAND", faction.getLandCount());
} else {
info.put("LEADER", "Faction not found");
info.put("POWER", "Faction not found");
info.put("LAND", "Faction not found");
info.put("LEADER", Html.FACTION_NOT_FOUND.parse());
info.put("POWER", Html.FACTION_NOT_FOUND.parse());
info.put("LAND", Html.FACTION_NOT_FOUND.parse());
}
return info;
}
@ -98,12 +99,12 @@ public class FactionsHook extends Hook {
if (mPlayer.hasFaction()) {
info.put("FACTION", mPlayer.getFactionName());
} else {
info.put("FACTION", "Not in faction");
info.put("FACTION", Phrase.NOT_IN_FAC+"");
}
} else {
info.put("POWER", 0);
info.put("MAXPOWER", 0);
info.put("FACTION", "Not in faction");
info.put("FACTION", Phrase.NOT_IN_FAC+"");
}
return info;
}

View File

@ -5,6 +5,7 @@ import java.util.HashMap;
import java.util.Map;
import java.util.UUID;
import main.java.com.djrapitops.plan.Plan;
import main.java.com.djrapitops.plan.ui.Html;
import main.java.com.djrapitops.plan.ui.tables.SortableFactionsTableCreator;
import main.java.com.djrapitops.plan.ui.tables.SortableTownTableCreator;
@ -97,7 +98,7 @@ public class HookHandler {
TownyHook tH = townyHook;
addReplace.put("%towntable%", tH.isEnabled() ? SortableTownTableCreator.createSortableTownsTable(tH.getTopTowns(), tH) : "");
addReplace.put("%factionstable%", fH.isEnabled() ? SortableFactionsTableCreator.createSortableFactionsTable(fH.getTopFactions(), fH) : "");
addReplace.put("%essentialswarps%", eH.isEnabled() ? "<br/>Warps: " + eH.getWarps().toString() : "");
addReplace.put("%essentialswarps%", eH.isEnabled() ? Html.WARPS.parse(eH.getWarps().toString()) : "");
return addReplace;
}
@ -108,25 +109,25 @@ public class HookHandler {
SuperbVoteHook sH = superbVoteHook;
FactionsHook fH = factionsHook;
TownyHook tH = townyHook;
addReplace.put("%achievements%", (aH.isEnabled() ? "<br/>Achievements: " + aH.getPlayerAchievements(uuid) + "/" + aH.getTotalAchievements() : ""));
addReplace.put("%achievements%", (aH.isEnabled() ? Html.ACHIEVEMENTS.parse(aH.getPlayerAchievements(uuid)+"",aH.getTotalAchievements()+"") : ""));
if (eH.isEnabled()) {
HashMap<String, Serializable> essData = eH.getEssentialsData(uuid);
addReplace.put("%essentials%", ((boolean) essData.get("JAILED") ? "| Jailed" : "")
+ " " + ((boolean) essData.get("MUTED") ? "| Muted" : ""));
addReplace.put("%essentials%", ((boolean) essData.get("JAILED") ? Html.JAILED.parse() : "")
+ " " + ((boolean) essData.get("MUTED") ? Html.MUTED.parse() : ""));
} else {
addReplace.put("%essentials%", "");
}
addReplace.put("%votes%", sH.isEnabled() ? "<br/>Has voted " + sH.getVotes(uuid) + "times" : "");
addReplace.put("%votes%", sH.isEnabled() ? Html.VOTES.parse(sH.getVotes(uuid)+"") : "");
if (fH.isEnabled()) {
HashMap<String, Serializable> facInfo = fH.getPlayerInfo(uuid);
addReplace.put("%faction%", "<br/>Faction: " + facInfo.get("FACTION") + " | Power: " + facInfo.get("POWER") + "/" + facInfo.get("MAXPOWER"));
addReplace.put("%faction%", Html.FACTION.parse(facInfo.get("FACTION")+"",facInfo.get("POWER")+"",facInfo.get("MAXPOWER")+""));
} else {
addReplace.put("%faction%", "");
}
if (tH.isEnabled()) {
HashMap<String, Serializable> townInfo = tH.getPlayerInfo(uuid);
addReplace.put("%town%", "<br/>Town: " + townInfo.get("TOWN"));
addReplace.put("%town%", Html.TOWN.parse(townInfo.get("TOWN")+""));
} else {
addReplace.put("%town%", "");
}

View File

@ -1,6 +1,5 @@
package main.java.com.djrapitops.plan.data.additional;
import io.minimum.minecraft.superbvote.SuperbVote;
import io.minimum.minecraft.superbvote.storage.VoteStorage;
import java.util.UUID;
import main.java.com.djrapitops.plan.Plan;

View File

@ -10,6 +10,7 @@ import java.util.HashMap;
import java.util.List;
import java.util.UUID;
import java.util.stream.Collectors;
import main.java.com.djrapitops.plan.Phrase;
import main.java.com.djrapitops.plan.Plan;
import main.java.com.djrapitops.plan.utilities.comparators.TownComparator;
import static org.bukkit.Bukkit.getOfflinePlayer;
@ -86,7 +87,7 @@ public class TownyHook extends Hook {
if (res.hasTown()) {
info.put("TOWN", res.getTown().getName());
} else {
info.put("TOWN", "Not in town");
info.put("TOWN", Phrase.NOT_IN_TOWN+"");
}
info.put("FRIENDS", res.getFriends().toString());
} catch (Exception ex) {

View File

@ -73,7 +73,7 @@ public class DataCacheHandler {
commandUseHandler = new CommandUseHandler(commandUse);
} catch (SQLException e) {
plugin.toLog(this.getClass().getName(), e);
plugin.logError(Phrase.DATABASE_FAILURE_DISABLE + "");
plugin.logError(Phrase.DB_FAILURE_DISABLE + "");
plugin.getServer().getPluginManager().disablePlugin(plugin);
}
int minutes = Settings.SAVE_CACHE_MIN.getNumber();
@ -124,7 +124,7 @@ public class DataCacheHandler {
public void process(UserData data) {
if (cache) {
dataCache.put(uuid, data);
plugin.log(Phrase.ADD_TO_CACHE.parse(uuid.toString()));
plugin.log(Phrase.CACHE_ADD.parse(uuid.toString()));
}
}
};
@ -280,7 +280,7 @@ public class DataCacheHandler {
}).runTaskTimer(plugin, 30 * 20, 30 * 20);
} else {
dataCache.remove(uuid);
plugin.log("Cleared " + uuid.toString() + " from Cache.");
plugin.log(Phrase.CACHE_REMOVE+"");
}
}
}

View File

@ -104,7 +104,7 @@ public class DemographicsHandler {
* Uses ip-api.com to locate the IP address If too many calls are made to
* the API the IP will be blocked from further calls.
*
* @param event JoinEvent to get the InetAddress
* @param ip Player's IP address
* @param data UserData corresponding the player
*/
public void handleLogin(InetAddress ip, UserData data) {

View File

@ -4,6 +4,7 @@ package main.java.com.djrapitops.plan.data.handlers;
import java.util.Date;
import java.util.HashMap;
import java.util.UUID;
import main.java.com.djrapitops.plan.Phrase;
import main.java.com.djrapitops.plan.Plan;
import main.java.com.djrapitops.plan.data.SessionData;
import main.java.com.djrapitops.plan.data.UserData;
@ -40,7 +41,7 @@ public class SessionHandler {
data.addSession(currentSession);
activeSessions.remove(uuid);
} else {
System.out.println("Player's session was initialized in a wrong way! (" + data.getName() + ")");
System.out.println(Phrase.ERROR_SESSIONDATA_INITIALIZATION.parse(data.getName()));
}
}
}

View File

@ -2,8 +2,6 @@ package main.java.com.djrapitops.plan.data.listeners;
import java.util.UUID;
import main.java.com.djrapitops.plan.Plan;
import main.java.com.djrapitops.plan.data.UserData;
import main.java.com.djrapitops.plan.data.cache.DBCallableProcessor;
import main.java.com.djrapitops.plan.data.cache.DataCacheHandler;
import main.java.com.djrapitops.plan.data.handlers.LocationHandler;
import org.bukkit.Location;

View File

@ -8,7 +8,6 @@ import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
@ -25,7 +24,6 @@ import org.bukkit.Location;
import org.bukkit.World;
import org.bukkit.scheduler.BukkitRunnable;
import static org.bukkit.Bukkit.getOfflinePlayer;
import static org.bukkit.Bukkit.getOfflinePlayer;
public abstract class SQLDB extends Database {

View File

@ -38,29 +38,53 @@ public enum Html {
BUTTON_CLASS("class=\"button\""),
LINK("<a class=\"link\" href=\"" + REPLACE0 + "\">" + REPLACE1 + "</a>"),
LINK_CLASS("class=\"link\""),
TABLE_START("<table class=\"table\">"),
TABLE_END("</table>"),
TABLELINE("<tr><td><b>" + REPLACE0 + "</b></td>\r\n<td>" + REPLACE1 + "</td></tr>"),
ERROR_TABLE("<tr><td>No data</td>\r\n<td>No data</td></tr>"),
IMG("<img src=\"" + REPLACE0 + "\">"),
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>"),
TOWN("<p>Town: " + REPLACE0 + "</p>"),
PLOT_OPTIONS("<p>Plot options: " + REPLACE0 + "</p>"),
FRIENDS("<p>Friends with " + REPLACE0 + "</p>"),
FACTION("<p>Faction: " + REPLACE0 + "</p>"),
BALANCE("<p>Balance: " + REPLACE0 + "</p>"),
VOTES("<p>Player has voted " + REPLACE0 + " times.</p>"),
BANNED("| " + SPAN.parse(COLOR_4.parse() + "Banned")),
BALANCE("<p>Balance: " + REPLACE0 + "</p>"), 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)");
HIDDEN("Hidden (config)"),
ERROR_NOT_SET("Error: Replace rule was not set"),
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"),
GRAPH_BANNED("Banned"),
GRAPH_UNKNOWN("Unknown"),
GRAPH_INACTIVE("Inactive"),
GRAPH_ACTIVE("Active"),
GRAPH_ONLINE("Players Online"),
GRAPH_PLAYERS("Players"),
GRAPH_DATE("Date"),
TABLE_START_3("<table class=\"sortable table\"><thead><tr><th>REPLACE0</th><th>REPLACE1</th><th>REPLACE2</th></tr></thead><tbody>"),
TABLE_START_4("<table class=\"sortable table\"><thead><tr><th>REPLACE0</th><th>REPLACE1</th><th>REPLACE2</th><th>REPLACE3</th></tr></thead><tbody>"),
TABLE_SESSIONS_START(TABLE_START_3.parse("Session Started", "Session Ended", "Session Length")),
TABLE_FACTIONS_START(TABLE_START_4.parse("Faction", "Power", "Land", "Leader")),
TABLE_TOWNS_START(TABLE_START_4.parse("Town", "Residents", "Land", "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_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>"),
ERROR_TABLE_2(TABLELINE_2.parse("No data", "No data")),
TABLE_END("</tbody></table>"),
SESSIONDATA_NONE("No Session Data available"),;
private String html;

View File

@ -5,6 +5,7 @@ import com.googlecode.charts4j.GCharts;
import com.googlecode.charts4j.PieChart;
import com.googlecode.charts4j.Slice;
import main.java.com.djrapitops.plan.Phrase;
import main.java.com.djrapitops.plan.ui.Html;
/**
*
@ -35,11 +36,15 @@ public class ActivityPieChartCreator {
while (banPerc + inacPerc + actPerc + joinlPerc > 100) {
actPerc--;
}
String labelBanned = Html.GRAPH_BANNED.parse();
String labelUnknown = Html.GRAPH_UNKNOWN.parse();
String labelInactive = Html.GRAPH_INACTIVE.parse();
String labelActive = Html.GRAPH_ACTIVE.parse();
Slice bannedSlice = Slice.newSlice((int) (banPerc), Color.newColor(Phrase.HCOLOR_ACTP_BAN + ""), "Banned", "Banned");
Slice joinLeaverSlice = Slice.newSlice((int) (joinlPerc), Color.newColor(Phrase.HCOLOR_ACTP_JON + ""), "Unknown", "Unknown");
Slice inactiveSlice = Slice.newSlice((int) (inacPerc), Color.newColor(Phrase.HCOLOR_ACTP_INA + ""), "Inactive", "Inactive");
Slice activeSlice = Slice.newSlice((int) (actPerc), Color.newColor(Phrase.HCOLOR_ACTP_ACT + ""), "Active", "Active");
Slice bannedSlice = Slice.newSlice((int) (banPerc), Color.newColor(Phrase.HCOLOR_ACTP_BAN + ""), labelBanned, labelBanned);
Slice joinLeaverSlice = Slice.newSlice((int) (joinlPerc), Color.newColor(Phrase.HCOLOR_ACTP_JON + ""), labelUnknown, labelUnknown);
Slice inactiveSlice = Slice.newSlice((int) (inacPerc), Color.newColor(Phrase.HCOLOR_ACTP_INA + ""), labelInactive, labelInactive);
Slice activeSlice = Slice.newSlice((int) (actPerc), Color.newColor(Phrase.HCOLOR_ACTP_ACT + ""), labelActive, labelActive);
PieChart refChart = GCharts.newPieChart(activeSlice, bannedSlice, inactiveSlice, joinLeaverSlice);
refChart.setSize(400, 150);

View File

@ -15,6 +15,7 @@ import java.util.concurrent.CopyOnWriteArrayList;
import main.java.com.djrapitops.plan.Phrase;
import main.java.com.djrapitops.plan.Plan;
import main.java.com.djrapitops.plan.data.SessionData;
import main.java.com.djrapitops.plan.ui.Html;
import main.java.com.djrapitops.plan.utilities.FormatUtils;
import static org.bukkit.plugin.java.JavaPlugin.getPlugin;
@ -38,14 +39,6 @@ public class PlayerActivityGraphCreator {
CopyOnWriteArrayList<Long> sessionStarts = new CopyOnWriteArrayList<>();
CopyOnWriteArrayList<Long> sessionEnds = new CopyOnWriteArrayList<>();
CopyOnWriteArrayList<SessionData> s = new CopyOnWriteArrayList(sessionData);
// List<Long> sessionStarts = sessionData.parallelStream()
// .filter((session) -> (session.getSessionStart() > nowMinusScale))
// .map(SessionData::getSessionStart)
// .collect(Collectors.toList());
// List<Long> sessionEnds = sessionData.parallelStream()
// .filter((session) -> (session.getSessionStart() > nowMinusScale))
// .map(SessionData::getSessionEnd)
// .collect(Collectors.toList());
s.parallelStream()
.filter((session) -> (session.getSessionStart() > nowMinusScale))
.forEach((session) -> {
@ -112,13 +105,13 @@ public class PlayerActivityGraphCreator {
AxisLabels xAxisLabels = AxisLabelsFactory.newAxisLabels(xDateAxisLabels, xDateAxisLabelsLocations);
Data xData = Data.newData(xListDate);
Data pYData = Data.newData(pYList);
XYLine playerLine = Plots.newXYLine(xData, pYData, Color.newColor(Phrase.HCOLOR_ACT_ONL + ""), "Players Online");
XYLine playerLine = Plots.newXYLine(xData, pYData, Color.newColor(Phrase.HCOLOR_ACT_ONL + ""), Html.GRAPH_ONLINE.parse());
LineChart chart = GCharts.newLineChart(playerLine);
chart.addXAxisLabels(xAxisLabels);
chart.addTopAxisLabels(AxisLabelsFactory.newAxisLabels("Players", 1));
chart.addTopAxisLabels(AxisLabelsFactory.newAxisLabels(Html.GRAPH_PLAYERS.parse(), 1));
chart.addYAxisLabels(AxisLabelsFactory.newAxisLabels(yAxisLabels));
chart.addRightAxisLabels(AxisLabelsFactory.newAxisLabels("Date", 4));
chart.addRightAxisLabels(AxisLabelsFactory.newAxisLabels(Html.GRAPH_DATE.parse(), 4));
chart.setSize(1000, 250);
return chart.toURLString();
}

View File

@ -3,6 +3,7 @@ package main.java.com.djrapitops.plan.ui.tables;
import java.util.Collections;
import java.util.List;
import main.java.com.djrapitops.plan.data.SessionData;
import main.java.com.djrapitops.plan.ui.Html;
import main.java.com.djrapitops.plan.utilities.FormatUtils;
import main.java.com.djrapitops.plan.utilities.comparators.SessionDataComparator;
@ -13,14 +14,9 @@ import main.java.com.djrapitops.plan.utilities.comparators.SessionDataComparator
public class SortabeSessionTableCreator {
public static String createSortedSessionDataTable5(List<SessionData> sessionData) {
String html = "<table class=\"sortable table\"><thead><tr>"
+ "<th>Session Started</th>"
+ "<th>Session Ended</th>"
+ "<th>Session Length</th>"
+ "</tr></thead>"
+ "<tbody>";
String html = Html.TABLE_SESSIONS_START.parse();
if (sessionData.isEmpty()) {
html += "<tr><td>No Session Data available</td><td></td><td></td></tr>";
html += Html.TABLELINE_3.parse(Html.SESSIONDATA_NONE.parse(), "", "");
} else {
Collections.sort(sessionData, new SessionDataComparator());
Collections.reverse(sessionData);
@ -31,15 +27,15 @@ public class SortabeSessionTableCreator {
}
long start = session.getSessionStart();
long end = session.getSessionEnd();
long length = end-start;
html += "<tr>"
+ "<td sorttable_customkey=\""+start+"\">" + FormatUtils.formatTimeStamp(start+"") + "</td>"
+ "<td sorttable_customkey=\""+end+"\">" + FormatUtils.formatTimeStamp(end+"") + "</td>"
+ "<td sorttable_customkey=\""+length+"\">" + FormatUtils.formatTimeAmount(length+"") + "</td>"
+ "</tr>";
long length = end - start;
html += Html.TABLELINE_3_CUSTOMKEY.parse(
start+"", FormatUtils.formatTimeStamp(start+""),
end+"", FormatUtils.formatTimeStamp(end+""),
length+"", FormatUtils.formatTimeAmount(length+"")
);
}
}
html += "</tbody></table>";
html += Html.TABLE_END.parse();
return html;
}
}

View File

@ -16,12 +16,12 @@ public class SortableCommandUseTableCreator {
List<String[]> sorted = MapComparator.sortByValue(commandUse);
String html = "";
if (sorted.isEmpty()) {
html = Html.ERROR_TABLE.parse();
html = Html.ERROR_TABLE_2.parse();
return html;
}
Collections.reverse(sorted);
for (String[] values : sorted) {
html += Html.TABLELINE.parse(values[1], values[0]);
html += Html.TABLELINE_2.parse(values[1], values[0]);
}
return html;
}

View File

@ -14,27 +14,22 @@ import main.java.com.djrapitops.plan.utilities.HtmlUtils;
public class SortableFactionsTableCreator {
public static String createSortableFactionsTable(Collection<String> factionList, FactionsHook fHook) {
String html = "<table class=\"sortable table\"><thead><tr>"
+ "<th>Faction</th>"
+ "<th>Power</th>"
+ "<th>Land</th>"
+ "<th>Leader</th>"
+ "</tr></thead>"
+ "<tbody>";
String html = Html.TABLE_FACTIONS_START.parse();
if (factionList.isEmpty()) {
html += "<tr><td>No Factions</td><td></td><td></td><td></td></tr>";
html += Html.TABLELINE_4.parse(Html.FACTION_NO_FACTIONS.parse(), "", "", "");
} else {
for (String factionName : factionList) {
HashMap<String, Serializable> info = fHook.getFactionInfo(factionName);
html += "<tr>"
+ "<td>" + factionName + "</td>"
+ "<td>" + info.get("POWER") + "</td>"
+ "<td>" + info.get("LAND") + "</td>"
+ "<td>" + Html.LINK.parse(HtmlUtils.getInspectUrl((String) info.get("LEADER")), (String) info.get("LEADER")) + "</td>"
+ "</tr>";
String leader = (String) info.get("LEADER");
html += Html.TABLELINE_4.parse(
factionName,
info.get("POWER")+"",
info.get("LAND")+"",
Html.LINK.parse(HtmlUtils.getInspectUrl(leader), leader)
);
}
}
html += "</tbody></table>";
html += Html.TABLE_END.parse();
return html;
}
}

View File

@ -1,7 +1,6 @@
package main.java.com.djrapitops.plan.ui.tables;
import java.util.Collection;
import java.util.Date;
import main.java.com.djrapitops.plan.data.UserData;
import main.java.com.djrapitops.plan.ui.Html;
import main.java.com.djrapitops.plan.utilities.AnalysisUtils;
@ -17,16 +16,17 @@ public class SortablePlayersTableCreator {
public static String createSortablePlayersTable(Collection<UserData> data) {
String html = "";
for (UserData uData : data) {
html += "<tr>"
+ "<td>" + Html.LINK.parse(HtmlUtils.getInspectUrl(uData.getName()), uData.getName()) + "</td>"
+ "<td>" + (uData.isBanned() ? "Banned" : (AnalysisUtils.isActive(uData.getLastPlayed(), uData.getPlayTime(), uData.getLoginTimes())
? "Active" : "Inactive")) + "</td>"
+ "<td sorttable_customkey=\""+uData.getPlayTime()+"\">" + FormatUtils.formatTimeAmount(uData.getPlayTime() + "") + "</td>"
+ "<td>" + uData.getLoginTimes() + "</td>"
+ "<td sorttable_customkey=\""+uData.getRegistered()+"\">" + FormatUtils.formatTimeStamp(uData.getRegistered() + "") + "</td>"
+ "<td sorttable_customkey=\""+uData.getLastPlayed()+"\">" + FormatUtils.formatTimeStamp(uData.getLastPlayed() + "") + "</td>"
+ "<td>" + uData.getDemData().getGeoLocation() + "</td>"
+ "</tr>";
String bORaORi = uData.isBanned() ? Html.GRAPH_BANNED.parse() :
(AnalysisUtils.isActive(uData.getLastPlayed(), uData.getPlayTime(), uData.getLoginTimes())
? Html.GRAPH_ACTIVE.parse() : Html.GRAPH_INACTIVE.parse());
html += Html.TABLELINE_PLAYERS.parse(Html.LINK.parse(HtmlUtils.getInspectUrl(uData.getName()), uData.getName()), bORaORi,
uData.getPlayTime() + "", FormatUtils.formatTimeAmount(uData.getPlayTime() + ""),
uData.getLoginTimes()+"",
uData.getRegistered() + "", FormatUtils.formatTimeStamp(uData.getRegistered() + ""),
uData.getLastPlayed() + "", FormatUtils.formatTimeStamp(uData.getLastPlayed() + ""),
uData.getDemData().getGeoLocation()
);
}
return html;
}

View File

@ -14,27 +14,21 @@ import main.java.com.djrapitops.plan.utilities.HtmlUtils;
public class SortableTownTableCreator {
public static String createSortableTownsTable(Collection<String> townNames, TownyHook tHook) {
String html = "<table class=\"sortable table\"><thead><tr>"
+ "<th>Town</th>"
+ "<th>Residents</th>"
+ "<th>Land</th>"
+ "<th>Mayor</th>"
+ "</tr></thead>"
+ "<tbody>";
String html = Html.TABLE_TOWNS_START.parse();
if (townNames.isEmpty()) {
html += "<tr><td>No Towns</td><td></td><td></td><td></td></tr>";
html += Html.TABLELINE_4.parse(Html.TOWN_NO_TOWNS.parse(), "", "", "");
} else {
for (String town : townNames) {
HashMap<String, Serializable> info = tHook.getTownInfo(town);
html += "<tr>"
+ "<td>" + town + "</td>"
+ "<td>" + info.get("RESIDENTS") + "</td>"
+ "<td>" + info.get("LAND") + "</td>"
+ "<td>" + Html.LINK.parse(HtmlUtils.getInspectUrl((String) info.get("MAYOR")), (String) info.get("MAYOR")) + "</td>"
+ "</tr>";
html += Html.TABLELINE_4.parse(
town,
info.get("RESIDENTS") + "",
info.get("LAND") + "",
Html.LINK.parse(HtmlUtils.getInspectUrl((String) info.get("MAYOR")), (String) info.get("MAYOR"))
);
}
}
html += "</tbody></table>";
html += Html.TABLE_END.parse();
return html;
}
}

View File

@ -58,9 +58,9 @@ public class Response {
if (forbidden) {
String errorMessage = "HTTP/1.1 403 Forbidden\r\n"
+ "Content-Type: text/html\r\n"
+ "Content-Length: 38\r\n"
+ "Content-Length: 100\r\n"
+ "\r\n"
+ "<h1>403 Forbidden - Access Denied</h1>";
+ "<h1>403 Forbidden - Access Denied</h1><p>Make sure you're accessing the link given by a command</p>";
output.write(errorMessage.getBytes());
return;
}

View File

@ -86,7 +86,7 @@ public class WebSocketServer {
ENABLED = true;
plugin.log(Phrase.WEBSERVER_RUNNING.parse(server.getLocalPort()+""));
} catch (Exception e) {
} catch (IllegalArgumentException | IllegalStateException e) {
ENABLED = false;
}
}
@ -100,7 +100,7 @@ public class WebSocketServer {
try {
server.close();
} catch (IOException e) {
e.printStackTrace();
plugin.toLog(this.getClass().getName(), e);
}
}

View File

@ -170,7 +170,7 @@ public class Analysis {
if (!raw.getCommandUse().isEmpty()) {
data.setTop50CommandsListHtml(AnalysisUtils.createTableOutOfHashMap(raw.getCommandUse()));
} else {
data.setTop50CommandsListHtml(Html.ERROR_TABLE.parse());
data.setTop50CommandsListHtml(Html.ERROR_TABLE_2.parse());
}
}