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

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

View File

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

View File

@ -8,20 +8,17 @@ import static org.bukkit.plugin.java.JavaPlugin.getPlugin;
* @author Rsl1122 * @author Rsl1122
*/ */
public enum Phrase { public enum Phrase {
REPLACE0("REPLACE0"),
PREFIX("[Plan] "), PREFIX("[Plan] "),
ENABLED("Player Analytics Enabled."), ENABLED("Player Analytics Enabled."),
DISABLED("Player Analytics Disabled."), DISABLED("Player Analytics Disabled."),
SAVE_CACHE("Saving cached data.."), SAVE_CACHE("Saving cached data.."),
ADD_TO_CACHE("Added REPLACE0 to Cache."), ADD_TO_CACHE("Added #1 to Cache."),
CONFIG_HEADER("Plan Config | More info at https://www.spigotmc.org/wiki/plan-configuration/"), 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_TYPE_DOES_NOT_EXIST("That database type doesn't exist."),
DATABASE_FAILURE_DISABLE("Database initialization has failed, disabling Plan."), 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 (#1) is availible at https://www.spigotmc.org/resources/plan-player-analytics.32536/"),
VERSION_LATEST("You're running the latest version"), VERSION_LATEST("You're running the latest version"),
VERSION_CHECK_ERROR("Failed to compare versions."), VERSION_CHECK_ERROR("Failed to compare versions."),
VERSION_FAIL("Failed to get newest version number."), VERSION_FAIL("Failed to get newest version number."),
@ -86,8 +83,8 @@ public enum Phrase {
CMD_CLICK_ME("Click Me"), CMD_CLICK_ME("Click Me"),
CMD_LINK(COLOR_SEC.color() + " " + BALL + COLOR_MAIN.color() + " Link: " + COLOR_TER.color()), 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(ChatColor.YELLOW + "" + PREFIX + "Passing to PlanLite.."),
CMD_RESULTS_AVAILABLE(COLOR_SEC.color() + " Results will be available for " + COLOR_TER.color() + REPLACE0 + COLOR_SEC.color() + " minutes."), 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() + REPLACE0 + COLOR_MAIN.color() + "."), CMD_NO_RESULTS(CMD_BALL + " No results for " + COLOR_SEC.color() + "#1" + COLOR_MAIN.color() + "."),
CMD_MATCH(COLOR_SEC.color() + " Matching player: " + COLOR_TER.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."), COMMAND_SENDER_NOT_PLAYER(ChatColor.RED + "" + PREFIX + "This command can be only used as a player."),
@ -96,15 +93,15 @@ public enum Phrase {
COMMAND_REQUIRES_ARGUMENTS_ONE(ChatColor.RED + "" + PREFIX + "Command requires one argument."), COMMAND_REQUIRES_ARGUMENTS_ONE(ChatColor.RED + "" + PREFIX + "Command requires one argument."),
COMMAND_NO_PERMISSION(ChatColor.RED + "" + PREFIX + "You do not have the required permmission."); COMMAND_NO_PERMISSION(ChatColor.RED + "" + PREFIX + "You do not have the required permmission.");
private String text; private final String text;
private ChatColor color; private final ChatColor color;
private Phrase(String text) { private Phrase(final String text) {
this.text = text; this.text = text;
this.color = null; this.color = null;
} }
private Phrase(ChatColor color) { private Phrase(final ChatColor color) {
this.color = color; this.color = color;
this.text = ""; this.text = "";
} }
@ -114,12 +111,8 @@ public enum Phrase {
return text; return text;
} }
public String parse(String... p) { public String parse(String replace) {
String returnValue = this.toString(); return text.replaceAll("#1", replace);
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 /* TODO 2.2.0
Placeholder API Placeholder API
Immutable InspectCache ?
Recent players 25%
Database cleaning Database cleaning
Location Analysis to view meaningful locations on Dynmap (Investigate dynmap api) PlanLite Top 20 richest 25%
Integrate PlanLite features to Plan and discontinue PlanLite PlanLite Top 20 most votes 25%
Seperate serverdata and userdata saving Top 20 most active 25%
Make Analysis.java readable Clear setting multiper (InspectCache)
Database Cleaning of useless data Clear check for existing clear task. (InspectCache)
Fix any bugs that come up
- New Players not reset if server not restarted
*/ */
/** /**
* *
@ -67,9 +67,9 @@ public class Plan extends JavaPlugin {
saveConfig(); saveConfig();
log(MiscUtils.checkVersion()); log(MiscUtils.checkVersion());
log(Phrase.DB_INIT+""); log("Database init..");
if (initDatabase()) { if (initDatabase()) {
log(Phrase.DB_ESTABLISHED.parse(db.getConfigName())); log(db.getConfigName() + "-database connection established.");
} else { } else {
logError(Phrase.DATABASE_FAILURE_DISABLE.toString()); logError(Phrase.DATABASE_FAILURE_DISABLE.toString());
getServer().getPluginManager().disablePlugin(this); getServer().getPluginManager().disablePlugin(this);

View File

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

View File

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

View File

@ -1,67 +0,0 @@
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

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

View File

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

View File

@ -1,8 +1,6 @@
package com.djrapitops.plan.utilities; package com.djrapitops.plan.utilities;
import java.util.Arrays;
import java.util.Date; import java.util.Date;
import main.java.com.djrapitops.plan.ui.Html;
import org.bukkit.Location; import org.bukkit.Location;
/** /**
@ -152,20 +150,4 @@ public class FormatUtils {
return "x " + loc.getBlockX() + " z " + loc.getBlockZ() + " in " + loc.getWorld(); 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,132 +1,57 @@
<!DOCTYPE html> <!doctype html>
<html lang="en"> <html lang="en">
<head> <head>
<meta charset="utf-8"> <meta charset="utf-8">
<title>Plan | Server Analysis</title> <title>Plan | Server Analysis</title>
<meta name="description" content="Player Analysis window"> <meta name="description" content="Server Analysis Window">
<meta name="author" content="Rsl1122"> <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;
}
</style> <!--[if lt IE 9]>
<script src="https://cdnjs.cloudflare.com/ajax/libs/html5shiv/3.7.3/html5shiv.js"></script>
<![endif]-->
</head> </head>
<body> <body>
<div style="line-height: 55%; font-family: Verdana, Geneva, sans-serif;padding: 2px 4px 2px 3px;">
<header> <h1 style="text-decoration: underline;">Plan | Server Analysis</h1>
<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> <h4>Analysis refreshed %refresh% ago</h4>
</header> <table>
<div class="clearfix"> <tr>
<div class="column graphs"> <td style="margin-left: 3px; margin-right: auto;
border-style: groove; border-width: 3px; border-radius: 12px; padding: 2px 4px 2px 3px;
<h4>Player Activity - Last 24h</h4> box-shadow: 5px 5px 4px 0px #888888;">
%playerchartday% <h4>Player Activity - Last 24h</h4>
<h4>Player Activity - Last 7 days</h4> %playerchartday%
%playerchartweek% <h4>Player Activity - Last 7 days</h4>
<h4>Player Activity - Last 30 days</h4> %playerchartweek%
%playerchartmonth% <h4>Player Activity - Last 30 days</h4>
<div class="buttons"> %playerchartmonth%
<p><b>Most recent logins</b>: %recentlogins%</p> <p><b>Most recent logins</b>: %recentlogins%</p>
</div> <h4>Top 20 Most Active</h4>
<h4>Top 20 Most Active</h4> %top20mostactive%
%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>
%planlite% %planlite%
</div> </table>
<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> </div>
</body> </body>
</html> </html>

View File

@ -1,130 +1,47 @@
<!DOCTYPE html> <!doctype html>
<html lang="en"> <html lang="en">
<head> <head>
<meta charset="utf-8"> <meta charset="utf-8">
<title>Plan | Inspect %name%</title> <title>Plan | Inspect %name%</title>
<meta name="description" content="Player inspect window"> <meta name="description" content="Player inspect window">
<meta name="author" content="Rsl1122"> <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%;
}
.black { <!--[if lt IE 9]>
color: #000000; <script src="https://cdnjs.cloudflare.com/ajax/libs/html5shiv/3.7.3/html5shiv.js"></script>
} <![endif]-->
.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> </head>
<body> <body>
<div style="line-height: 55%; font-family: Verdana, Geneva, sans-serif;padding: 2px 4px 2px 3px;">
<header> <h1 style="text-decoration: underline;">Plan | Inspect Player %name%</h1>
<img style="float: right; padding: 5px" src="http://puu.sh/tJZUb/c2e0ab220f.png" alt="Player Analytics | Inspect %name%"> <h4>UUID: %uuid%</h4>
<p style="float: right; text-align: right;">Player Analytics v.%version%</p>
<h1>Plan | Inspect Player %name%</h1>
<h4>Registered: %registered% %banned%%op%</h4> <h4>Registered: %registered% %banned%%op%</h4>
</header>
<div class="clearfix">
%inaccuratedatawarning% %inaccuratedatawarning%
<div class="column info"> <table>
<tr>
<h4>Information</h4> <td style="margin-left: 3px; margin-right: auto;
<p>Last seen: %lastseen% %active% %isonline%<br/> border-style: groove; border-width: 3px; border-radius: 12px; padding: 2px 4px 2px 3px;
Nicknames: %nicknames% | Has connected from ips: %ips%<br/> box-shadow: 5px 5px 4px 0px #888888;">
Geolocation: %geoloc%<br/> <h4>Information</h4>
Playtime: %playtime%<br/> <p>Last seen: %lastseen% %active% %isonline%</p>
Has logged in %logintimes% times. | Has been kicked %timeskicked% times.<br/> <p>Nicknames: %nicknames% | Has connected from ips: %ips%</p>
Age: %age% | Gender: %gender%<br/> <p>Geolocation: %geoloc%</p>
UUID: %uuid%</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>
%planlite% %planlite%
</div> </table>
<div class="column info">
<h4>Gamemode Usage</h4>
%gmpiechart%
<p>Survival: %gm0% | Creative: %gm1% | Adventure: %gm2% | Spectator: %gm3% <br/>Total: %gmtotal%</p>
</div>
</div> </div>
</body> </body>
</html> </html>

View File

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