mirror of
https://github.com/plan-player-analytics/Plan.git
synced 2024-11-05 10:20:23 +01:00
Analysis Plugin Section html parsing, Version bump to 4.1.0
This commit is contained in:
parent
973076bb55
commit
224468e9d2
@ -4,7 +4,7 @@
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>com.djrapitops</groupId>
|
||||
<artifactId>Plan</artifactId>
|
||||
<version>4.0.7</version>
|
||||
<version>4.1.0</version>
|
||||
<packaging>jar</packaging>
|
||||
<repositories>
|
||||
<repository>
|
||||
|
@ -76,12 +76,6 @@ public class PlayerProfile implements OfflinePlayer {
|
||||
}
|
||||
|
||||
// Calculating Getters
|
||||
|
||||
@Deprecated // TODO Remove after 4.1.0, made for old html users
|
||||
public boolean isActive(long date) {
|
||||
return getActivityIndex(date) > 1.0;
|
||||
}
|
||||
|
||||
public double getActivityIndex(long date) {
|
||||
Double activityIndx = activityIndex.get(date);
|
||||
if (activityIndx != null) {
|
||||
|
@ -28,7 +28,7 @@ import java.util.UUID;
|
||||
* @see InspectContainer
|
||||
* @since 4.1.0
|
||||
*/
|
||||
public class AnalysisContainer extends InspectContainer {
|
||||
public final class AnalysisContainer extends InspectContainer {
|
||||
|
||||
private TreeMap<String, Map<UUID, Serializable>> playerTableValues;
|
||||
|
||||
|
@ -37,27 +37,27 @@ public class InspectContainer {
|
||||
tables = new TreeMap<>();
|
||||
}
|
||||
|
||||
public String getWithIcon(String text, String icon) {
|
||||
public final String getWithIcon(String text, String icon) {
|
||||
return getWithColoredIcon(text, icon, "black");
|
||||
}
|
||||
|
||||
public String getWithColoredIcon(String text, String icon, String color) {
|
||||
public final String getWithColoredIcon(String text, String icon, String color) {
|
||||
return Html.FA_COLORED_ICON.parse(color, icon) + " " + text;
|
||||
}
|
||||
|
||||
public void addValue(String label, Serializable value) {
|
||||
public final void addValue(String label, Serializable value) {
|
||||
values.put(label, value.toString());
|
||||
}
|
||||
|
||||
public void addHtml(String key, String html) {
|
||||
public final void addHtml(String key, String html) {
|
||||
this.html.put(key, html);
|
||||
}
|
||||
|
||||
public void addTable(String key, TableContainer table) {
|
||||
public final void addTable(String key, TableContainer table) {
|
||||
tables.put(key, table);
|
||||
}
|
||||
|
||||
public String parseHtml() {
|
||||
public final String parseHtml() {
|
||||
StringBuilder html = new StringBuilder();
|
||||
|
||||
for (Map.Entry<String, String> entry : values.entrySet()) {
|
||||
@ -74,4 +74,8 @@ public class InspectContainer {
|
||||
|
||||
return html.toString();
|
||||
}
|
||||
|
||||
public final boolean hasOnlyValues() {
|
||||
return html.isEmpty() && tables.isEmpty();
|
||||
}
|
||||
}
|
@ -22,6 +22,7 @@ public abstract class PluginData {
|
||||
private final String sourcePlugin;
|
||||
|
||||
private String pluginIcon;
|
||||
private String iconColor;
|
||||
|
||||
public PluginData(ContainerSize size, String sourcePlugin) {
|
||||
this.size = size;
|
||||
@ -32,24 +33,28 @@ public abstract class PluginData {
|
||||
|
||||
public abstract AnalysisContainer getServerData(Collection<UUID> uuids, AnalysisContainer fillThis) throws Exception;
|
||||
|
||||
protected void setPluginIcon(String pluginIcon) {
|
||||
protected final void setPluginIcon(String pluginIcon) {
|
||||
this.pluginIcon = pluginIcon;
|
||||
}
|
||||
|
||||
public String parsePluginIcon() {
|
||||
return pluginIcon != null ? Html.FONT_AWESOME_ICON.parse(pluginIcon) : Html.FONT_AWESOME_ICON.parse("cube");
|
||||
protected final void setIconColor(String iconColor) {
|
||||
this.iconColor = iconColor;
|
||||
}
|
||||
|
||||
public ContainerSize getSize() {
|
||||
public final String parsePluginIcon() {
|
||||
return pluginIcon != null ? Html.FA_COLORED_ICON.parse((iconColor != null ? iconColor : "black"), pluginIcon) : Html.FONT_AWESOME_ICON.parse("cube");
|
||||
}
|
||||
|
||||
public final ContainerSize getSize() {
|
||||
return size;
|
||||
}
|
||||
|
||||
public String getSourcePlugin() {
|
||||
public final String getSourcePlugin() {
|
||||
return sourcePlugin;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
public final boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
PluginData that = (PluginData) o;
|
||||
@ -59,7 +64,7 @@ public abstract class PluginData {
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
public final int hashCode() {
|
||||
return Objects.hashCode(size, sourcePlugin, pluginIcon);
|
||||
}
|
||||
}
|
||||
|
@ -15,7 +15,7 @@ import java.util.List;
|
||||
*
|
||||
* @author Rsl1122
|
||||
*/
|
||||
public class TableContainer {
|
||||
public final class TableContainer {
|
||||
|
||||
private final String[] header;
|
||||
private List<Serializable[]> values;
|
||||
|
@ -220,10 +220,6 @@ public class InspectPageParser extends PageParser {
|
||||
|
||||
addValue("playerStatus", HtmlStructure.playerStatus(online, profile.getBannedOnServers(), profile.isOp()));
|
||||
|
||||
boolean isActive = profile.isActive(now);
|
||||
String active = isActive ? "Active" : "Inactive";
|
||||
playerClassification(profile, active);
|
||||
|
||||
if (!plugin.getInfoManager().isUsingAnotherWebServer()) {
|
||||
addValue("networkName", Settings.SERVER_NAME.toString());
|
||||
}
|
||||
@ -234,14 +230,4 @@ public class InspectPageParser extends PageParser {
|
||||
throw new ParseException(e);
|
||||
}
|
||||
}
|
||||
|
||||
private void playerClassification(PlayerProfile profile, String active) {
|
||||
boolean isBanned = profile.isBanned();
|
||||
boolean isOP = profile.isOp();
|
||||
|
||||
String banned = isBanned ? "Banned" : "";
|
||||
String op = isOP ? "Operator (OP)" : "";
|
||||
|
||||
addValue("playerClassification", HtmlStructure.separateWithDots(active, banned, op));
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,23 @@
|
||||
/*
|
||||
* To change this license header, choose License Headers in Project Properties.
|
||||
* To change this template file, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
package main.java.com.djrapitops.plan.utilities.comparators;
|
||||
|
||||
import main.java.com.djrapitops.plan.data.additional.PluginData;
|
||||
|
||||
import java.util.Comparator;
|
||||
|
||||
/**
|
||||
* Comparator for UserInfo for Alphabetical Name order.
|
||||
*
|
||||
* @author Rsl1122
|
||||
*/
|
||||
public class PluginDataNameComparator implements Comparator<PluginData> {
|
||||
|
||||
@Override
|
||||
public int compare(PluginData u1, PluginData u2) {
|
||||
return u1.getSourcePlugin().compareTo(u2.getSourcePlugin());
|
||||
}
|
||||
}
|
@ -6,17 +6,113 @@ package main.java.com.djrapitops.plan.utilities.html.structure;
|
||||
|
||||
import main.java.com.djrapitops.plan.data.additional.AnalysisContainer;
|
||||
import main.java.com.djrapitops.plan.data.additional.PluginData;
|
||||
import main.java.com.djrapitops.plan.utilities.comparators.PluginDataNameComparator;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* //TODO Class Javadoc Comment
|
||||
* Creates Plugin section contents for Analysis page.
|
||||
*
|
||||
* @author Rsl1122
|
||||
*/
|
||||
public class AnalysisPluginsTabContentCreator {
|
||||
|
||||
public static String[] createContent(Map<PluginData, AnalysisContainer> containers) {
|
||||
return new String[]{"", ""};
|
||||
if (containers.isEmpty()) {
|
||||
return new String[]{"<li><a>No Compatible Plugins</a></li>", ""};
|
||||
}
|
||||
|
||||
List<PluginData> order = new ArrayList<>(containers.keySet());
|
||||
order.sort(new PluginDataNameComparator());
|
||||
|
||||
StringBuilder nav = new StringBuilder();
|
||||
StringBuilder generalTab = new StringBuilder();
|
||||
StringBuilder otherTabs = new StringBuilder();
|
||||
|
||||
generalTab.append("<div class=\"tab\"><div class=\"row clearfix\">");
|
||||
|
||||
boolean hadOtherThanTabs = false;
|
||||
|
||||
for (PluginData pluginData : order) {
|
||||
AnalysisContainer container = containers.get(pluginData);
|
||||
|
||||
switch (pluginData.getSize()) {
|
||||
case TAB:
|
||||
appendNewTab(pluginData, container, nav, otherTabs);
|
||||
break;
|
||||
case WHOLE:
|
||||
if (!container.hasOnlyValues()) {
|
||||
appendWhole(pluginData, container, generalTab);
|
||||
hadOtherThanTabs = true;
|
||||
break;
|
||||
}
|
||||
|
||||
case TWO_THIRDS:
|
||||
if (!container.hasOnlyValues()) {
|
||||
appendTwoThirds(pluginData, container, generalTab);
|
||||
hadOtherThanTabs = true;
|
||||
break;
|
||||
}
|
||||
case THIRD:
|
||||
default:
|
||||
appendThird(pluginData, container, generalTab);
|
||||
hadOtherThanTabs = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
generalTab.append("</div></div>");
|
||||
|
||||
return new String[]{
|
||||
hadOtherThanTabs ? "<li><a class=\"nav-button\" href=\"javascript:void(0)\">General</a></li>" + nav.toString() : nav.toString(),
|
||||
hadOtherThanTabs ? generalTab.toString() + otherTabs.toString() : otherTabs.toString()
|
||||
};
|
||||
}
|
||||
|
||||
private static void appendThird(PluginData pluginData, AnalysisContainer container, StringBuilder generalTab) {
|
||||
generalTab.append("<div class=\"col-xs-12 col-sm-12 col-md-4 col-lg-4\">" +
|
||||
"<div class=\"card\">" +
|
||||
"<div class=\"header\">" +
|
||||
"<h2>")
|
||||
.append(pluginData.parsePluginIcon()).append(" ").append(pluginData.getSourcePlugin())
|
||||
.append("</h2></div>").append("<div class=\"body\">")
|
||||
.append(container.parseHtml())
|
||||
.append("</div></div></div>");
|
||||
}
|
||||
|
||||
private static void appendTwoThirds(PluginData pluginData, AnalysisContainer container, StringBuilder generalTab) {
|
||||
generalTab.append("<div class=\"col-xs-12 col-sm-12 col-md-8 col-lg-8\">" +
|
||||
"<div class=\"card\">" +
|
||||
"<div class=\"header\">" +
|
||||
"<h2>")
|
||||
.append(pluginData.parsePluginIcon()).append(" ").append(pluginData.getSourcePlugin())
|
||||
.append("</h2></div>").append("<div class=\"body\">")
|
||||
.append(container.parseHtml())
|
||||
.append("</div></div></div>");
|
||||
}
|
||||
|
||||
private static void appendWhole(PluginData pluginData, AnalysisContainer container, StringBuilder generalTab) {
|
||||
generalTab.append("<div class=\"col-xs-12 col-sm-12 col-md-12 col-lg-12\">" +
|
||||
"<div class=\"card\">" +
|
||||
"<div class=\"header\">" +
|
||||
"<h2>")
|
||||
.append(pluginData.parsePluginIcon()).append(" ").append(pluginData.getSourcePlugin())
|
||||
.append("</h2></div>").append("<div class=\"body\">")
|
||||
.append(container.parseHtml())
|
||||
.append("</div></div></div>");
|
||||
}
|
||||
|
||||
private static void appendNewTab(PluginData pluginData, AnalysisContainer container, StringBuilder nav, StringBuilder otherTabs) {
|
||||
nav.append("<li><a class=\"nav-button\" href=\"javascript:void(0)\">").append(pluginData.getSourcePlugin()).append("</a></li>");
|
||||
otherTabs.append("<div class=\"tab\"><div class=\"row clearfix\"><div class=\"col-xs-12 col-sm-12 col-md-12 col-lg-12\">" +
|
||||
"<div class=\"card\">" +
|
||||
"<div class=\"header\">" +
|
||||
"<h2>")
|
||||
.append(pluginData.parsePluginIcon()).append(" ").append(pluginData.getSourcePlugin())
|
||||
.append("</h2></div>").append("<div class=\"body\">")
|
||||
.append(container.parseHtml())
|
||||
.append("</div></div></div></div></div>");
|
||||
}
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
name: Plan
|
||||
author: Rsl1122
|
||||
main: main.java.com.djrapitops.plan.PlanBungee
|
||||
version: 4.0.7
|
||||
version: 4.1.0
|
@ -1,7 +1,7 @@
|
||||
name: Plan
|
||||
author: Rsl1122
|
||||
main: main.java.com.djrapitops.plan.Plan
|
||||
version: 4.0.7
|
||||
version: 4.1.0
|
||||
softdepend:
|
||||
- OnTime
|
||||
- EssentialsX
|
||||
|
Loading…
Reference in New Issue
Block a user