Revert "Revert "Html improvements, Html Enum, JHeatmap removed, bugfixes""

This reverts commit f91079cede.
This commit is contained in:
Rsl1122 2017-02-02 00:13:02 +02:00
parent f91079cede
commit a19fcbd4e0
14 changed files with 397 additions and 197 deletions

View File

@ -30,12 +30,6 @@
<version>1.3</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.javaheatmap</groupId>
<artifactId>jheatchart</artifactId>
<version>0.6</version>
<scope>compile</scope>
</dependency>
</dependencies>
<build>
<defaultGoal>clean package install</defaultGoal>

View File

@ -8,17 +8,20 @@ import static org.bukkit.plugin.java.JavaPlugin.getPlugin;
* @author Rsl1122
*/
public enum Phrase {
REPLACE0("REPLACE0"),
PREFIX("[Plan] "),
ENABLED("Player Analytics Enabled."),
DISABLED("Player Analytics Disabled."),
SAVE_CACHE("Saving cached data.."),
ADD_TO_CACHE("Added #1 to Cache."),
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.."),
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!"),
//
VERSION_NEW_AVAILABLE("New Version (#1) 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."),
@ -83,8 +86,8 @@ public enum Phrase {
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_RESULTS_AVAILABLE(COLOR_SEC.color() + " Results will be available for " + COLOR_TER.color() + "#1" + COLOR_SEC.color() + " minutes."),
CMD_NO_RESULTS(CMD_BALL + " No results for " + COLOR_SEC.color() + "#1" + COLOR_MAIN.color() + "."),
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()),
//
COMMAND_SENDER_NOT_PLAYER(ChatColor.RED + "" + PREFIX + "This command can be only used as a player."),
@ -93,15 +96,15 @@ public enum Phrase {
COMMAND_REQUIRES_ARGUMENTS_ONE(ChatColor.RED + "" + PREFIX + "Command requires one argument."),
COMMAND_NO_PERMISSION(ChatColor.RED + "" + PREFIX + "You do not have the required permmission.");
private final String text;
private final ChatColor color;
private String text;
private ChatColor color;
private Phrase(final String text) {
private Phrase(String text) {
this.text = text;
this.color = null;
}
private Phrase(final ChatColor color) {
private Phrase(ChatColor color) {
this.color = color;
this.text = "";
}
@ -111,8 +114,12 @@ public enum Phrase {
return text;
}
public String parse(String replace) {
return text.replaceAll("#1", replace);
public String parse(String... p) {
String returnValue = this.toString();
for (int i = 0; i < p.length; i++) {
returnValue = returnValue.replaceAll("REPLACE" + i, p[i]);
}
return returnValue;
}
/**

View File

@ -23,14 +23,14 @@ import org.bukkit.scheduler.BukkitRunnable;
/* TODO 2.2.0
Placeholder API
Immutable InspectCache ?
Recent players 25%
Database cleaning
PlanLite Top 20 richest 25%
PlanLite Top 20 most votes 25%
Top 20 most active 25%
Clear setting multiper (InspectCache)
Clear check for existing clear task. (InspectCache)
Location Analysis to view meaningful locations on Dynmap (Investigate dynmap api)
Integrate PlanLite features to Plan and discontinue PlanLite
Seperate serverdata and userdata saving
Make Analysis.java readable
Database Cleaning of useless data
Fix any bugs that come up
- New Players not reset if server not restarted
*/
/**
*
@ -67,9 +67,9 @@ public class Plan extends JavaPlugin {
saveConfig();
log(MiscUtils.checkVersion());
log("Database init..");
log(Phrase.DB_INIT+"");
if (initDatabase()) {
log(db.getConfigName() + "-database connection established.");
log(Phrase.DB_ESTABLISHED.parse(db.getConfigName()));
} else {
logError(Phrase.DATABASE_FAILURE_DISABLE.toString());
getServer().getPluginManager().disablePlugin(this);

View File

@ -29,23 +29,23 @@ public enum Settings {
DEM_IGNORE(getPlugin(Plan.class).getConfig().getString("Customization.DemographicsTriggers.IgnoreWhen")),
;
private final String text;
private final boolean bool;
private final int number;
private String text;
private boolean bool;
private int number;
private Settings(final String text) {
private Settings(String text) {
this.text = text;
this.bool = false;
this.number = -1;
}
private Settings(final boolean bool) {
private Settings(boolean bool) {
this.bool = bool;
this.text = "";
this.number = -1;
}
private Settings(final int number) {
private Settings(int number) {
this.bool = false;
this.text = "";
this.number = number;

View File

@ -28,6 +28,7 @@ public class ReloadCommand extends SubCommand {
@Override
public boolean onCommand(CommandSender sender, Command cmd, String commandLabel, String[] args) {
plugin.reloadConfig();
plugin.onDisable();
plugin.onEnable();
sender.sendMessage(ChatColor.GREEN + "[Plan] Reload complete.");

View File

@ -0,0 +1,67 @@
package main.java.com.djrapitops.plan.ui;
/**
*
* @author Rsl1122
*/
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\">"),
COLOR_3("<span class=\"darkaqua\">"),
COLOR_4("<span class=\"darkred\">"),
COLOR_5("<span class=\"darkpurple\">"),
COLOR_6("<span class=\"gold\">"),
COLOR_7("<span class=\"gray\">"),
COLOR_8("<span class=\"darkgray\">"),
COLOR_9("<span class=\"blue\">"),
COLOR_a("<span class=\"green\">"),
COLOR_b("<span class=\"aqua\">"),
COLOR_c("<span class=\"red\">"),
COLOR_d("<span class=\"pink\">"),
COLOR_e("<span class=\"yellow\">"),
COLOR_f("<span class=\"white\">"),
SPAN(""+REPLACE0+"</span>"),
BUTTON("<a class=\"button\" href=\""+REPLACE0+"\">"+REPLACE1+"</a>"),
BUTTON_CLASS("class=\"button\""),
LINK_CLASS("class=\"link\""),
TABLE_START("<table class=\"table\">"),
TABLE_END("</table>"),
TABLELINE("<tr class=\"tableline\"><td><b>"+REPLACE0+"</b></td>\r\n<td>"+REPLACE1+"</td></tr>"),
ERROR_TABLE("<p class=\"red\">Error Calcuclating Table (No data)</p>"),
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>")
;
private final String html;
private Html(String html) {
this.html = html;
}
public String parse() {
return html;
}
public String parse(String... p) {
String returnValue = this.html;
for (int i = 0; i < p.length; i++) {
returnValue = returnValue.replaceAll("REPLACE" + i, p[i]);
}
return returnValue;
}
}

View File

@ -1,52 +0,0 @@
package main.java.com.djrapitops.plan.ui.graphs;
import com.djrapitops.plan.Plan;
import java.io.File;
import java.io.IOException;
import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;
import org.bukkit.Location;
import org.tc33.jheatchart.HeatChart;
import static org.bukkit.plugin.java.JavaPlugin.getPlugin;
/**
*
* @author Rsl1122
*/
public class HeatMapCreator {
public static String createLocationHeatmap(List<Location> locations) {
double[][] data = new double[1000][1000];
for (int i = 0; i < 1000; i++) {
for (int j = 0; j < 1000; j++) {
data[i][j] = 0;
}
}
for (Location loc : locations) {
int x = loc.getBlockX()+500;
int z = loc.getBlockZ()+500;
if (x < 0 || x > 1000) {
continue;
}
if (z < 0 || z > 1000) {
continue;
}
data[x][z] = data[x][z] + 1;
}
HeatChart map = new HeatChart(data);
map.setTitle("Location heatmap.");
map.setXAxisLabel("X");
map.setYAxisLabel("Z");
try {
String folder = getPlugin(Plan.class).getDataFolder().getAbsolutePath()+File.separator+"Heatmaps";
map.saveToFile(new File(folder + File.separator+"java-heat-chart.png"));
} catch (IOException ex) {
Logger.getLogger(HeatMapCreator.class.getName()).log(Level.SEVERE, null, ex);
}
return "";
}
}

View File

@ -76,6 +76,7 @@ public class WebSocketServer {
Response response = new Response(output, dataReqHandler);
response.setRequest(request);
response.sendStaticResource();
socket.close();
} catch (IOException e) {
}
}

View File

@ -16,9 +16,9 @@ import java.util.UUID;
import main.java.com.djrapitops.plan.Settings;
import main.java.com.djrapitops.plan.data.PlanLiteAnalyzedData;
import main.java.com.djrapitops.plan.data.PlanLitePlayerData;
import main.java.com.djrapitops.plan.ui.Html;
import org.bukkit.GameMode;
import org.bukkit.OfflinePlayer;
import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.scheduler.BukkitRunnable;
/**
@ -168,10 +168,11 @@ public class Analysis {
long playTime = uData.getPlayTime();
totalPlaytime += playTime;
String playerName = uData.getName();
String url = "<a href=\"http://" + (useAlternativeIP ? alternativeIP : plugin.getServer().getIp() + ":" + port)
+ "/player/" + playerName+"\">"+playerName+"</a>";
playtimes.put(url, playTime);
latestLogins.put(url, uData.getLastPlayed());
String url = "http://" + (useAlternativeIP ? alternativeIP : plugin.getServer().getIp() + ":" + port)
+ "/player/" + playerName;
String html = Html.BUTTON.parse(url, playerName);
playtimes.put(html, playTime);
latestLogins.put(html, uData.getLastPlayed());
totalLoginTimes += uData.getLoginTimes();
int age = uData.getDemData().getAge();
if (age != -1) {
@ -258,7 +259,7 @@ public class Analysis {
data.setTop50CommandsListHtml(AnalysisUtils.createTableOutOfHashMap(sData.getCommandUsage()));
}
} else {
data.setTop50CommandsListHtml("<p>Error Calcuclating Command usages (No usage data)</p>");
data.setTop50CommandsListHtml(Html.ERROR_TABLE.parse());
}
data.setRefreshDate(new Date().getTime());

View File

@ -15,6 +15,7 @@ import java.util.Scanner;
import main.java.com.djrapitops.plan.Settings;
import main.java.com.djrapitops.plan.data.PlanLiteAnalyzedData;
import main.java.com.djrapitops.plan.data.PlanLitePlayerData;
import main.java.com.djrapitops.plan.ui.Html;
import main.java.com.djrapitops.plan.ui.graphs.ActivityPieChartCreator;
import main.java.com.djrapitops.plan.ui.graphs.PlayerActivityGraphCreator;
import main.java.com.djrapitops.plan.utilities.comparators.MapComparator;
@ -36,7 +37,7 @@ public class AnalysisUtils {
*/
public static String createGMPieChart(HashMap<GameMode, Long> gmTimes) {
String url = GMTimesPieChartCreator.createChart(gmTimes);
return "<img src=\"" + url + "\">";
return Html.IMG.parse(url);
}
/**
@ -49,7 +50,7 @@ public class AnalysisUtils {
*/
public static String createGMPieChart(HashMap<GameMode, Long> gmTimes, long total) {
String url = GMTimesPieChartCreator.createChart(gmTimes, total);
return "<img src=\"" + url + "\">";
return Html.IMG.parse(url);
}
/**
@ -68,10 +69,11 @@ public class AnalysisUtils {
replaceMap.put("%active%", AnalysisUtils.isActive(data.getLastPlayed(), data.getPlayTime(), data.getLoginTimes())
? "| Player is Active" : "| Player is inactive");
int age = data.getDemData().getAge();
replaceMap.put("%age%", (age != -1) ? "" + age : Phrase.DEM_UNKNOWN+"");
replaceMap.put("%age%", (age != -1) ? "" + age : Phrase.DEM_UNKNOWN + "");
replaceMap.put("%gender%", "" + data.getDemData().getGender().name().toLowerCase());
HashMap<GameMode, Long> gmTimes = data.getGmTimes();
replaceMap.put("%gmpiechart%", createGMPieChart(gmTimes));
long gmZero = gmTimes.get(GameMode.SURVIVAL);
long gmOne = gmTimes.get(GameMode.CREATIVE);
long gmTwo = gmTimes.get(GameMode.ADVENTURE);
@ -85,6 +87,7 @@ public class AnalysisUtils {
} catch (NoSuchFieldError e) {
gmThree = 0;
}
Plan plugin = getPlugin(Plan.class);
long total = gmZero + gmOne + gmTwo + gmThree;
replaceMap.put("%gm0%", FormatUtils.formatTimeAmount("" + gmZero));
replaceMap.put("%gm1%", FormatUtils.formatTimeAmount("" + gmOne));
@ -92,7 +95,7 @@ public class AnalysisUtils {
replaceMap.put("%gm3%", FormatUtils.formatTimeAmount("" + gmThree));
replaceMap.put("%gmtotal%", FormatUtils.formatTimeAmount("" + total));
replaceMap.put("%ips%", data.getIps().toString());
replaceMap.put("%nicknames%", data.getNicknames().toString());
replaceMap.put("%nicknames%", FormatUtils.swapColorsToSpan(data.getNicknames().toString()));
replaceMap.put("%name%", data.getName());
replaceMap.put("%registered%", FormatUtils.formatTimeStamp("" + data.getRegistered()));
replaceMap.put("%timeskicked%", "" + data.getTimesKicked());
@ -100,20 +103,21 @@ public class AnalysisUtils {
replaceMap.put("%banned%", data.isBanned() ? "Banned" : "Not Banned");
replaceMap.put("%op%", data.isOp() ? ", Operator (Op)" : "");
replaceMap.put("%isonline%", (data.isOnline()) ? "| Online" : "| Offline");
PlanLiteHook hook = getPlugin(Plan.class).getPlanLiteHook();
replaceMap.put("%version%", plugin.getDescription().getVersion());
PlanLiteHook hook = plugin.getPlanLiteHook();
if (hook != null) {
replaceMap.put("%planlite%", hook.isEnabled() ? getPlanLitePlayerHtml(data.getPlanLiteData()) : "");
} else {
replaceMap.put("%planlite%", "");
}
replaceMap.put("%inaccuratedatawarning%", (new Date().getTime() - data.getRegistered() < 180000)
? "<h3>Data might be inaccurate, player has just registered.</h3>" : "");
? Html.WARN_INACCURATE.parse() : "");
return replaceMap;
}
static String createPlayerActivityGraph(HashMap<Long, ServerData> rawServerData, long scale) {
String url = PlayerActivityGraphCreator.createChart(rawServerData, scale);
return "<img src=\"" + url + "\">";
return Html.IMG.parse(url);
}
/**
@ -139,7 +143,7 @@ public class AnalysisUtils {
replaceMap.put("%playerchartweek%", data.getPlayersChartImgHtmlWeek());
replaceMap.put("%playerchartday%", data.getPlayersChartImgHtmlDay());
replaceMap.put("%top50commands%", data.getTop50CommandsListHtml());
replaceMap.put("%avgage%", (data.getAverageAge() != -1) ? "" + data.getAverageAge() : Phrase.DEM_UNKNOWN+"");
replaceMap.put("%avgage%", (data.getAverageAge() != -1) ? "" + data.getAverageAge() : Phrase.DEM_UNKNOWN + "");
replaceMap.put("%avgplaytime%", FormatUtils.formatTimeAmount("" + data.getAveragePlayTime()));
replaceMap.put("%totalplaytime%", FormatUtils.formatTimeAmount("" + data.getTotalPlayTime()));
replaceMap.put("%ops%", "" + data.getOps());
@ -147,7 +151,9 @@ public class AnalysisUtils {
replaceMap.put("%totallogins%", "" + data.getTotalLoginTimes());
replaceMap.put("%top20mostactive%", data.getTop20ActivePlayers());
replaceMap.put("%recentlogins%", data.getRecentPlayers());
PlanLiteHook hook = getPlugin(Plan.class).getPlanLiteHook();
Plan plugin = getPlugin(Plan.class);
PlanLiteHook hook = plugin.getPlanLiteHook();
replaceMap.put("%version%", plugin.getDescription().getVersion());
if (hook != null) {
replaceMap.put("%planlite%", hook.isEnabled() ? getPlanLiteAnalysisHtml(data.getPlanLiteData()) : "");
} else {
@ -157,7 +163,6 @@ public class AnalysisUtils {
}
static boolean isActive(long lastPlayed, long playTime, int loginTimes) {
Plan plugin = getPlugin(Plan.class);
int timeToActive = Settings.ANALYSIS_MINUTES_FOR_ACTIVE.getNumber();
if (timeToActive < 0) {
timeToActive = 0;
@ -175,7 +180,7 @@ public class AnalysisUtils {
static String createActivityPieChart(int totalBanned, int active, int inactive, int joinleaver) {
String url = ActivityPieChartCreator.createChart(totalBanned, active, inactive, joinleaver);
return "<img src=\"" + url + "\">";
return Html.IMG.parse(url);
}
static String createTableOutOfHashMap(HashMap<String, Integer> commandUse) {
@ -188,9 +193,9 @@ public class AnalysisUtils {
static String createTableOutOfHashMap(HashMap<String, Integer> map, int limit) {
List<String[]> sorted = MapComparator.sortByValue(map);
String html = "<table style=\"border-collapse: collapse;table-layout: fixed; border-style: solid; border-width: 1px; width: 100%;\">";
String html = Html.TABLE_START.parse();
if (sorted.isEmpty()) {
html = "<p>Error Calcuclating Table usages (sorted data was empty)</p>";
html = Html.ERROR_TABLE.parse();
return html;
}
Collections.reverse(sorted);
@ -199,18 +204,18 @@ public class AnalysisUtils {
if (i >= limit) {
break;
}
html += "<tr style=\"text-align: center;border-style: solid; border-width: 1px;height: 28px;\"><td><b>" + values[1] + "</b></td>\r\n<td>" + values[0] + "</td></tr>";
html += Html.TABLELINE.parse(values[1], values[0]);
i++;
}
html += "</table>";
html += Html.TABLE_END.parse();
return html;
}
static String createActivePlayersTable(HashMap<String, Long> map, int limit) {
List<String[]> sorted = MapComparator.sortByValueLong(map);
String html = "<table style=\"border-collapse: collapse;table-layout: fixed; border-style: solid; border-width: 1px; width: 100%;\">";
String html = Html.TABLE_START.parse();
if (sorted.isEmpty()) {
html = "<p>Error Calculating Active players (sorted list was empty)</p>";
html = Html.ERROR_TABLE.parse()+Html.TABLE_END.parse();
return html;
}
Collections.reverse(sorted);
@ -219,13 +224,13 @@ public class AnalysisUtils {
if (i >= limit) {
break;
}
html += "<tr style=\"text-align: center;border-style: solid; border-width: 1px;height: 28px;\"><td><b>" + values[1] + "</b></td>\r\n<td>" + FormatUtils.formatTimeAmount(values[0]) + "</td></tr>";
html += Html.TABLELINE.parse(values[1].replaceAll(Html.BUTTON_CLASS.parse(), Html.LINK_CLASS.parse()),FormatUtils.formatTimeAmount(values[0]));
i++;
}
html += "</table>";
html += Html.TABLE_END.parse();
return html;
}
static String createListStringOutOfHashMapLong(HashMap<String, Long> map, int limit) {
List<String[]> sorted = MapComparator.sortByValueLong(map);
String html = "<p>";
@ -239,7 +244,7 @@ public class AnalysisUtils {
if (i >= limit) {
break;
}
html += values[1]+" ";
html += values[1] + " ";
i++;
}
html += "</p>";
@ -264,12 +269,12 @@ public class AnalysisUtils {
private static HashMap<String, String> getPlanLiteAnalysisReplaceRules(PlanLiteAnalyzedData planLiteData) {
HashMap<String, String> replaceMap = new HashMap<>();
PlanLiteHook hook = getPlugin(Plan.class).getPlanLiteHook();
replaceMap.put("%townyheader%", hook.hasTowny() ? "<p>Top 20 Towns</p>" : "");
replaceMap.put("%townyheader%", hook.hasTowny() ? Html.TOP_TOWNS.parse() : "");
replaceMap.put("%townylist%", hook.hasTowny() ? createTableOutOfHashMap(planLiteData.getTownMap(), 20) : "");
replaceMap.put("%factionheader%", hook.hasFactions() ? "<p>Top 20 Factions</p>" : "");
replaceMap.put("%factionheader%", hook.hasFactions() ? Html.TOP_FACTIONS.parse() : "");
replaceMap.put("%factionlist%", hook.hasFactions() ? createTableOutOfHashMap(planLiteData.getFactionMap(), 20) : "");
replaceMap.put("%totalmoneyline%", hook.hasVault() ? "<p>Server Total Balance: " + planLiteData.getTotalMoney() + "</p>" : "");
replaceMap.put("%totalvotesline%", hook.hasSuperbVote() ? "<p>Players have voted total of " + planLiteData.getTotalVotes() + " times.</p>" : "");
replaceMap.put("%totalmoneyline%", hook.hasVault() ? Html.TOTAL_BALANCE.parse(planLiteData.getTotalMoney()+"") : "");
replaceMap.put("%totalvotesline%", hook.hasSuperbVote() ? Html.TOTAL_VOTES.parse(planLiteData.getTotalVotes()+"") : "");
return replaceMap;
}
@ -291,13 +296,13 @@ public class AnalysisUtils {
private static HashMap<String, String> getPlanLitePlayerReplaceRules(PlanLitePlayerData planLiteData) {
HashMap<String, String> replaceMap = new HashMap<>();
PlanLiteHook hook = getPlugin(Plan.class).getPlanLiteHook();
replaceMap.put("%townylinetown%", hook.hasTowny() ? "<p>Town: " + planLiteData.getTown() + "</p>" : "");
replaceMap.put("%townylinetown%", hook.hasTowny() ? Html.TOWN.parse(planLiteData.getTown()) : "");
replaceMap.put("%townylineplotperms%", "");
replaceMap.put("%townylineplotoptions%", hook.hasTowny() ? "<p>Plot options: " + planLiteData.getPlotOptions() + "</p>" : "");
replaceMap.put("%townylinefriends%", hook.hasTowny() ? "<p>Friends with " + planLiteData.getFriends() + "</p>" : "");
replaceMap.put("%factionsline%", hook.hasFactions() ? "<p>Faction: " + planLiteData.getFaction() + "</p>" : "");
replaceMap.put("%totalmoneyline%", hook.hasVault() ? "<p>Balance: " + planLiteData.getMoney() + "</p>" : "");
replaceMap.put("%totalvotesline%", hook.hasSuperbVote() ? "<p>Player has voted " + planLiteData.getVotes() + " times.</p>" : "");
replaceMap.put("%townylineplotoptions%", hook.hasTowny() ? Html.PLOT_OPTIONS.parse(planLiteData.getPlotOptions()) : "");
replaceMap.put("%townylinefriends%", hook.hasTowny() ? Html.FRIENDS.parse(planLiteData.getFriends()) : "");
replaceMap.put("%factionsline%", hook.hasFactions() ? Html.FACTION.parse(planLiteData.getFaction()) : "");
replaceMap.put("%totalmoneyline%", hook.hasVault() ? Html.BALANCE.parse(planLiteData.getMoney()+"") : "");
replaceMap.put("%totalvotesline%", hook.hasSuperbVote() ? Html.VOTES.parse(planLiteData.getVotes()+"") : "");
return replaceMap;
}
}

View File

@ -1,6 +1,8 @@
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;
/**
@ -150,4 +152,20 @@ public class FormatUtils {
return "x " + loc.getBlockX() + " z " + loc.getBlockZ() + " in " + loc.getWorld();
}
static String swapColorsToSpan(String string) {
Html[] replacer = new Html[]{Html.COLOR_0, Html.COLOR_1, Html.COLOR_2, Html.COLOR_3,
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());
}
int spans = string.split("<span").length-1;
for (int i = 0; i < spans; i++) {
string = Html.SPAN.parse(string);
}
return string.replaceAll("§r", "");
}
}

View File

@ -1,57 +1,132 @@
<!doctype html>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Plan | Server Analysis</title>
<meta name="description" content="Server Analysis Window">
<meta name="description" content="Player Analysis window">
<meta name="author" content="Rsl1122">
<link rel="icon" href="https://puu.sh/tK0KL/6aa2ba141b.ico" type="image/x-icon" />
<style>
* {
box-sizing: border-box;
}
img {
width: auto;
}
body {
line-height: 140%;
font-family: Verdana, Geneva, sans-serif;
font-style: normal;
}
header, footer {
line-height: 40%;
background-color: #267F00;
color: white;
padding: 10px 15px 5px 15px;
font-family: futura-pt, Futura, Futura-Medium, Verdana, Geneva, sans-serif;
font-style: normal;
}
.column {
float: left;
padding: 15px;
}
.warn {
padding: 8px;
background-color: #ffcc00;
color: black;
margin: 0;
}
.clearfix::after {
content: "";
clear: both;
display: table;
}
.info {
width: 40%;
}
.graphs {
width: 60%
}
.button {
padding: 8px 14px;
background-color: green;
border: none;
color: white;
outline: 0;
text-decoration:none!important;
}
.button:hover {
background-color: darkgreen;
}
.table {
border-collapse: collapse;
table-layout: fixed;
border-style: solid;
border-width: 1px;
padding: 8px 14px;
width: 70%;
}
.tableline {
text-align: left;
border-style: solid;
border-width: 1px;
}
.buttons {
line-height: 270%;
}
.link {
color: green;
text-decoration:none!important;
}
.link:hover {
color: darkgreen;
}
<!--[if lt IE 9]>
<script src="https://cdnjs.cloudflare.com/ajax/libs/html5shiv/3.7.3/html5shiv.js"></script>
<![endif]-->
</style>
</head>
<body>
<div style="line-height: 55%; font-family: Verdana, Geneva, sans-serif;padding: 2px 4px 2px 3px;">
<h1 style="text-decoration: underline;">Plan | Server Analysis</h1>
<header>
<img style="float: right; padding: 5px" src="http://puu.sh/tJZUb/c2e0ab220f.png" alt="Player Analytics | Analysis">
<p style="float: right; text-align: right;">Player Analytics v.%version%</p>
<h1>Plan | Server Analysis</h1>
<h4>Analysis refreshed %refresh% ago</h4>
<table>
<tr>
<td style="margin-left: 3px; margin-right: auto;
border-style: groove; border-width: 3px; border-radius: 12px; padding: 2px 4px 2px 3px;
box-shadow: 5px 5px 4px 0px #888888;">
<h4>Player Activity - Last 24h</h4>
%playerchartday%
<h4>Player Activity - Last 7 days</h4>
%playerchartweek%
<h4>Player Activity - Last 30 days</h4>
%playerchartmonth%
<p><b>Most recent logins</b>: %recentlogins%</p>
<h4>Top 20 Most Active</h4>
%top20mostactive%
</td>
<td style="margin-left: 3px; margin-right: auto;
border-style: groove; border-width: 3px; border-radius: 12px; padding: 2px 4px 2px 3px;
box-shadow: 5px 5px 4px 0px #888888;text-align: left;vertical-align: top;">
<h4>Information</h4>
<p>%activitytotal% players have played on this server.</p>
<p>A Total of %totalplaytime% has been played with the average of %avgplaytime%</p>
<p>Players have joined %totallogins% times.</p>
<p>The average of known player ages is %avgage%.</p>
<br/><h4>Playerbase composition</h4>
%activitypiechart%
<p>Active %active% | Inactive %inactive% | Banned %banned% | Joined once %joinleaver% | Total: %activitytotal%</p>
<br/><h4>Gamemode Usage</h4>
%gmpiechart%
<p>Survival: %gm0% | Creative: %gm1% | Adventure: %gm2% | Spectator: %gm3%</p>
<br/><h4>Top 50 Most used commands</h4>
%top50commands%
</td>
</tr>
</header>
<div class="clearfix">
<div class="column graphs">
<h4>Player Activity - Last 24h</h4>
%playerchartday%
<h4>Player Activity - Last 7 days</h4>
%playerchartweek%
<h4>Player Activity - Last 30 days</h4>
%playerchartmonth%
<div class="buttons">
<p><b>Most recent logins</b>: %recentlogins%</p>
</div>
<h4>Top 20 Most Active</h4>
%top20mostactive%
%planlite%
</table>
</div>
<div class="column info">
<h4>Information</h4>
<p>%activitytotal% players have played on this server.<br/>
A Total of %totalplaytime% has been played with the average of %avgplaytime%<br/>
Players have joined %totallogins% times.<br/>
The average of known player ages is %avgage%.</p>
<h4>Playerbase composition</h4>
%activitypiechart%
<p>Active %active% | Inactive %inactive% | Banned %banned% | Joined once %joinleaver% <br/>
Total: %activitytotal%</p>
<br/><h4>Gamemode Usage</h4>
%gmpiechart%
<p>Survival: %gm0% | Creative: %gm1% | Adventure: %gm2% | Spectator: %gm3%</p>
<h4>Top 50 Most used commands</h4>
%top50commands%
</div>
</div>
</body>
</html>

View File

@ -1,47 +1,130 @@
<!doctype html>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Plan | Inspect %name%</title>
<meta name="description" content="Player inspect window">
<meta name="author" content="Rsl1122">
<link rel="icon" href="https://puu.sh/tK0KL/6aa2ba141b.ico" type="image/x-icon" />
<style>
* {
box-sizing: border-box;
}
img {
width: auto;
}
body {
line-height: 140%;
font-family: Verdana, Geneva, sans-serif;
font-style: normal;
}
header, footer {
line-height: 40%;
background-color: #267F00;
color: white;
padding: 10px 15px 5px 15px;
font-family: futura-pt, Futura, Futura-Medium, Verdana, Geneva, sans-serif;
font-style: normal;
}
.column {
float: left;
padding: 15px;
}
.warn {
padding: 8px;
background-color: #ffcc00;
color: black;
margin: 0;
}
.clearfix::after {
content: "";
clear: both;
display: table;
}
.info {
width: 50%;
}
<!--[if lt IE 9]>
<script src="https://cdnjs.cloudflare.com/ajax/libs/html5shiv/3.7.3/html5shiv.js"></script>
<![endif]-->
.black {
color: #000000;
}
.darkblue {
color: #0000AA;
}
.darkgreen {
color: #00AA00;
}
.darkaqua {
color: #00AAAA;
}
.darkred {
color: #AA0000;
}
.darkpurple {
color: #AA00AA;
}
.gold {
color: #FFAA00;
}
.gray {
color: #AAAAAA;
}
.darkgray {
color: #555555;
}
.blue {
color: #5555FF;
}
.green {
color: #55FF55;
}
.aqua {
color: #55FFFF;
}
.red {
color: #FF5555;
}
.pink {
color: #FF55FF;
}
.yellow {
color: #FFFF55;
}
.white {
color: #FFFFFF;
}
</style>
</head>
<body>
<div style="line-height: 55%; font-family: Verdana, Geneva, sans-serif;padding: 2px 4px 2px 3px;">
<h1 style="text-decoration: underline;">Plan | Inspect Player %name%</h1>
<h4>UUID: %uuid%</h4>
<header>
<img style="float: right; padding: 5px" src="http://puu.sh/tJZUb/c2e0ab220f.png" alt="Player Analytics | Inspect %name%">
<p style="float: right; text-align: right;">Player Analytics v.%version%</p>
<h1>Plan | Inspect Player %name%</h1>
<h4>Registered: %registered% %banned%%op%</h4>
</header>
<div class="clearfix">
%inaccuratedatawarning%
<table>
<tr>
<td style="margin-left: 3px; margin-right: auto;
border-style: groove; border-width: 3px; border-radius: 12px; padding: 2px 4px 2px 3px;
box-shadow: 5px 5px 4px 0px #888888;">
<h4>Information</h4>
<p>Last seen: %lastseen% %active% %isonline%</p>
<p>Nicknames: %nicknames% | Has connected from ips: %ips%</p>
<p>Geolocation: %geoloc%</p>
<p>Playtime: %playtime%</p>
<p>Has logged in %logintimes% times. | Has been kicked %timeskicked% times.</p>
<p>Age: %age% | Gender: %gender%</p>
</td>
<td style="margin-left: 3px; margin-right: auto;
border-style: groove; border-width: 3px; border-radius: 12px; padding: 2px 4px 2px 3px;
box-shadow: 5px 5px 4px 0px #888888;">
<h4>Gamemode Usage</h4>
%gmpiechart%
<p>Survival: %gm0% | Creative: %gm1% | Adventure: %gm2% | Spectator: %gm3% | Total: %gmtotal%</p>
</td>
</tr>
<div class="column info">
<h4>Information</h4>
<p>Last seen: %lastseen% %active% %isonline%<br/>
Nicknames: %nicknames% | Has connected from ips: %ips%<br/>
Geolocation: %geoloc%<br/>
Playtime: %playtime%<br/>
Has logged in %logintimes% times. | Has been kicked %timeskicked% times.<br/>
Age: %age% | Gender: %gender%<br/>
UUID: %uuid%</p>
%planlite%
</table>
</div>
<div class="column info">
<h4>Gamemode Usage</h4>
%gmpiechart%
<p>Survival: %gm0% | Creative: %gm1% | Adventure: %gm2% | Spectator: %gm3% <br/>Total: %gmtotal%</p>
</div>
</div>
</body>
</html>

View File

@ -1,7 +1,7 @@
name: Plan
author: Rsl1122
main: com.djrapitops.plan.Plan
version: 2.3.1
version: 2.4.0
commands:
plan: