mirror of
https://github.com/plan-player-analytics/Plan.git
synced 2024-12-26 02:57:52 +01:00
Network page sending,
Fixed SessionsTableCreator NPE related to Active sessions (No session ID) Fixed NPE related to 0 analysis notifications
This commit is contained in:
parent
9fa4839ee8
commit
a091f0e9d5
@ -5,6 +5,7 @@ import com.djrapitops.plugin.command.CommandUtils;
|
||||
import com.djrapitops.plugin.command.ISender;
|
||||
import com.djrapitops.plugin.command.SubCommand;
|
||||
import com.djrapitops.plugin.task.AbsRunnable;
|
||||
import com.djrapitops.plugin.utilities.Verify;
|
||||
import main.java.com.djrapitops.plan.Log;
|
||||
import main.java.com.djrapitops.plan.Permissions;
|
||||
import main.java.com.djrapitops.plan.Plan;
|
||||
@ -47,6 +48,9 @@ public class AnalyzeCommand extends SubCommand {
|
||||
}
|
||||
|
||||
public static void sendAnalysisMessage(Collection<ISender> senders, UUID serverUUID) throws SQLException {
|
||||
if (Verify.isEmpty(senders)) {
|
||||
return;
|
||||
}
|
||||
Plan plugin = Plan.getInstance();
|
||||
Optional<String> serverName = plugin.getDB().getServerTable().getServerName(serverUUID);
|
||||
if (serverName.isPresent()) {
|
||||
|
@ -91,7 +91,6 @@ public class IPsTable extends UserIDTable {
|
||||
if (ips.contains(ip)) {
|
||||
return;
|
||||
}
|
||||
|
||||
insertIp(uuid, ip, geolocation);
|
||||
}
|
||||
|
||||
|
@ -279,4 +279,16 @@ public class BukkitInformationManager extends InformationManager {
|
||||
}
|
||||
analysisNotification.getOrDefault(serverUUID, new HashSet<>()).clear();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateNetworkPageContent() {
|
||||
if (usingAnotherWebServer) {
|
||||
try {
|
||||
getWebAPI().getAPI(PostNetworkPageContentWebAPI.class).sendNetworkContent(webServerAddress, HtmlStructure.createServerContainer(plugin));
|
||||
} catch (WebAPIException e) {
|
||||
attemptConnection();
|
||||
updateNetworkPageContent();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -73,6 +73,9 @@ public class BungeeInformationManager extends InformationManager {
|
||||
*/
|
||||
@Override
|
||||
public void refreshAnalysis(UUID serverUUID) {
|
||||
if (PlanBungee.getServerUUID().equals(serverUUID)) {
|
||||
return;
|
||||
}
|
||||
ServerInfo serverInfo = getOnlineServerInfo(serverUUID);
|
||||
if (serverInfo == null) {
|
||||
return;
|
||||
@ -323,7 +326,7 @@ public class BungeeInformationManager extends InformationManager {
|
||||
}
|
||||
|
||||
public void removeNetworkPageContent(UUID serverUUID) {
|
||||
networkPageContent.remove(serverUUID);
|
||||
networkPageContent.put(serverUUID, HtmlStructure.parseOfflineServerContainer(networkPageContent.get(serverUUID)));
|
||||
}
|
||||
|
||||
public Map<UUID, String> getNetworkPageContent() {
|
||||
@ -346,4 +349,12 @@ public class BungeeInformationManager extends InformationManager {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateNetworkPageContent() {
|
||||
Collection<ServerInfo> online = serverInfoManager.getOnlineBukkitServers();
|
||||
bukkitServers.values().stream()
|
||||
.filter(s -> !online.contains(s)).map(ServerInfo::getUuid)
|
||||
.forEach(this::removeNetworkPageContent);
|
||||
}
|
||||
}
|
||||
|
@ -87,4 +87,6 @@ public abstract class InformationManager {
|
||||
}
|
||||
|
||||
public abstract void analysisReady(UUID serverUUID);
|
||||
|
||||
public abstract void updateNetworkPageContent();
|
||||
}
|
@ -4,6 +4,8 @@ import com.djrapitops.plugin.utilities.player.Fetch;
|
||||
import main.java.com.djrapitops.plan.Plan;
|
||||
import main.java.com.djrapitops.plan.data.Session;
|
||||
import main.java.com.djrapitops.plan.systems.cache.DataCache;
|
||||
import main.java.com.djrapitops.plan.systems.info.InformationManager;
|
||||
import main.java.com.djrapitops.plan.systems.processing.Processor;
|
||||
import main.java.com.djrapitops.plan.systems.processing.player.*;
|
||||
import main.java.com.djrapitops.plan.utilities.MiscUtils;
|
||||
import org.bukkit.entity.Player;
|
||||
@ -98,7 +100,13 @@ public class PlanPlayerListener implements Listener {
|
||||
new RegisterProcessor(uuid, player.getFirstPlayed(), time, playerName, playersOnline,
|
||||
new IPUpdateProcessor(uuid, ip),
|
||||
new NameProcessor(uuid, playerName, displayName)
|
||||
)
|
||||
),
|
||||
new Processor<InformationManager>(plugin.getInfoManager()) {
|
||||
@Override
|
||||
public void process() {
|
||||
object.updateNetworkPageContent();
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -0,0 +1,48 @@
|
||||
/*
|
||||
* Licence is provided in the jar as license.yml also here:
|
||||
* https://github.com/Rsl1122/Plan-PlayerAnalytics/blob/master/Plan/src/main/resources/license.yml
|
||||
*/
|
||||
package main.java.com.djrapitops.plan.systems.webserver.webapi.bungee;
|
||||
|
||||
import com.djrapitops.plugin.utilities.Compatibility;
|
||||
import main.java.com.djrapitops.plan.api.IPlan;
|
||||
import main.java.com.djrapitops.plan.api.exceptions.WebAPIException;
|
||||
import main.java.com.djrapitops.plan.systems.info.BungeeInformationManager;
|
||||
import main.java.com.djrapitops.plan.systems.webserver.response.Response;
|
||||
import main.java.com.djrapitops.plan.systems.webserver.webapi.WebAPI;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* //TODO Class Javadoc Comment
|
||||
*
|
||||
* @author Rsl1122
|
||||
*/
|
||||
public class PostNetworkPageContentWebAPI extends WebAPI {
|
||||
@Override
|
||||
public Response onRequest(IPlan plugin, Map<String, String> variables) {
|
||||
if (Compatibility.isBukkitAvailable()) {
|
||||
return badRequest("Called a Bukkit server.");
|
||||
}
|
||||
|
||||
UUID serverUUID = UUID.fromString(variables.get("sender"));
|
||||
String html = variables.get("html");
|
||||
if (html == null) {
|
||||
return badRequest("html not present");
|
||||
}
|
||||
|
||||
((BungeeInformationManager) plugin.getInfoManager()).cacheNetworkPageContent(serverUUID, html);
|
||||
return success();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendRequest(String address) throws WebAPIException {
|
||||
throw new IllegalStateException("Wrong method call for this WebAPI, call sendRequest(String, UUID, UUID) instead.");
|
||||
}
|
||||
|
||||
public void sendNetworkContent(String address, String html) throws WebAPIException {
|
||||
addVariable("html", html);
|
||||
super.sendRequest(address);
|
||||
}
|
||||
}
|
@ -428,10 +428,18 @@ public class HtmlStructure {
|
||||
} else {
|
||||
b.append("<a class=\"button disabled right\">Analysis</a>");
|
||||
}
|
||||
// TODO Refresh functionality
|
||||
|
||||
b.append("</div>")
|
||||
.append("</div>");
|
||||
return b.toString();
|
||||
}
|
||||
|
||||
public static String parseOfflineServerContainer(String oldContent) {
|
||||
if (oldContent == null) {
|
||||
return "";
|
||||
}
|
||||
String[] split = oldContent.split("<p>", 2);
|
||||
String[] split2 = split[1].split("box-footer", 2);
|
||||
return split[0] + "<p>Offline</p></div><div class=\"box-footer" + split2[1];
|
||||
}
|
||||
}
|
@ -49,12 +49,23 @@ public class SessionsTableCreator {
|
||||
|
||||
DataCache dataCache = Plan.getInstance().getDataCache();
|
||||
|
||||
Map<Long, UUID> uuidBySessionStart = new HashMap<>();
|
||||
for (Map.Entry<UUID, Session> entry : dataCache.getActiveSessions().entrySet()) {
|
||||
uuidBySessionStart.put(entry.getValue().getSessionStart(), entry.getKey());
|
||||
}
|
||||
|
||||
|
||||
for (Session session : allSessions) {
|
||||
if (i >= 50) {
|
||||
break;
|
||||
}
|
||||
|
||||
UUID uuid = uuidByID.get(session.getSessionID());
|
||||
UUID uuid;
|
||||
if (session.isFetchedFromDB()) {
|
||||
uuid = uuidByID.get(session.getSessionID());
|
||||
} else {
|
||||
uuid = uuidBySessionStart.get(session.getSessionStart());
|
||||
}
|
||||
|
||||
String name = dataCache.getName(uuid);
|
||||
String start = FormatUtils.formatTimeStamp(session.getSessionStart());
|
||||
|
@ -97,8 +97,8 @@ ${killCount} num
|
||||
${mobKillCount} num
|
||||
${deathCount} num
|
||||
|
||||
${commandCount} num //TODO
|
||||
${commandUniqueCount} num //TODO
|
||||
${commandCount} num
|
||||
${commandUniqueCount} num
|
||||
|
||||
//done
|
||||
${tpsAverageDay} num
|
||||
@ -131,7 +131,7 @@ ${punchCardSeries}
|
||||
|
||||
${playersGraphColor} // done
|
||||
|
||||
${gmColors} // TODO Move to World Graph
|
||||
${gmColors}
|
||||
|
||||
// done
|
||||
${active}
|
||||
@ -141,7 +141,7 @@ ${banned}
|
||||
${activityColors}
|
||||
|
||||
${worldTotal} timeamount //done
|
||||
${worldColors} //TODO NOT IMPLEMENTED
|
||||
${worldColors}
|
||||
|
||||
//done
|
||||
${tpsMedium}
|
||||
|
@ -115,7 +115,7 @@
|
||||
<h2><i class="fa fa-pie-chart" aria-hidden="true"></i> Server Preference</h2>
|
||||
</div>
|
||||
<div class="box-footer">
|
||||
<div id="serverPie" style="width: 75%; height: 400px;"></div>
|
||||
<div id="serverPie" style="width: 100%; height: 300px;"></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@ -217,6 +217,7 @@
|
||||
};
|
||||
|
||||
|
||||
|
||||
</script>
|
||||
<script>
|
||||
var navButtons = document.getElementsByClassName("nav-button");
|
||||
@ -270,6 +271,7 @@
|
||||
|
||||
|
||||
|
||||
|
||||
</script>
|
||||
</div>
|
||||
</body>
|
||||
|
@ -288,7 +288,8 @@
|
||||
<div id="tab-command-usage" class="tab">
|
||||
<div class="column">
|
||||
<div class="box-header">
|
||||
<h2><i class="fa fa-terminal"></i> Command Usage</h2>
|
||||
<h2 style="padding: 2px; margin: 0px;"><i class="fa fa-terminal"></i> Command Usage</h2>
|
||||
<p style="padding: 2px; margin: 0px;">Unique Commands: ${commandUniqueCount} • Total Command Count: ${commandCount}</p>
|
||||
</div>
|
||||
<div class="box-footer scrollbar" style="padding: 2px;">
|
||||
<table class="sortable table">
|
||||
@ -447,6 +448,8 @@
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
</script>
|
||||
<script>
|
||||
var navButtons = document.getElementsByClassName("nav-button");
|
||||
@ -504,6 +507,8 @@
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
</script>
|
||||
</div>
|
||||
</body>
|
||||
|
Loading…
Reference in New Issue
Block a user