Final touches (Bugfixes to Bungee)

This commit is contained in:
Rsl1122 2017-12-02 16:16:23 +02:00
parent d79add8745
commit 34069d2477
10 changed files with 40 additions and 31 deletions

View File

@ -143,7 +143,7 @@ public class PlanBungee extends BungeePlugin implements IPlan {
Log.logDebug("Enable", "WebServer Initialization");
Log.info(Locale.get(Msg.ENABLED).toString());
if (Settings.ANALYSIS_EXPORT.isTrue()) {
RunnableFactory.createNew(new HtmlExport(this));
RunnableFactory.createNew(new HtmlExport(this)).runTaskAsynchronously();
}
} catch (Exception e) {
Log.error("Plugin Failed to Initialize Correctly.");

View File

@ -11,6 +11,7 @@ import main.java.com.djrapitops.plan.api.exceptions.ParseException;
import main.java.com.djrapitops.plan.api.exceptions.WebAPIConnectionFailException;
import main.java.com.djrapitops.plan.api.exceptions.WebAPIException;
import main.java.com.djrapitops.plan.api.exceptions.WebAPINotFoundException;
import main.java.com.djrapitops.plan.settings.Settings;
import main.java.com.djrapitops.plan.systems.cache.DataCache;
import main.java.com.djrapitops.plan.systems.info.parsing.NetworkPageParser;
import main.java.com.djrapitops.plan.systems.info.server.BungeeServerInfoManager;
@ -24,6 +25,7 @@ import main.java.com.djrapitops.plan.systems.webserver.webapi.bukkit.InspectWebA
import main.java.com.djrapitops.plan.systems.webserver.webapi.bukkit.IsOnlineWebAPI;
import main.java.com.djrapitops.plan.systems.webserver.webapi.bungee.RequestPluginsTabWebAPI;
import main.java.com.djrapitops.plan.utilities.MiscUtils;
import main.java.com.djrapitops.plan.utilities.file.export.HtmlExport;
import main.java.com.djrapitops.plan.utilities.html.HtmlStructure;
import java.io.IOException;
@ -369,7 +371,11 @@ public class BungeeInformationManager extends InformationManager {
@Override
public void updateNetworkPageContent() {
PageCache.cachePage("analysisPage:" + MiscUtils.getIPlan().getServerUuid(), () -> new AnalysisPageResponse(this));
UUID serverUUID = MiscUtils.getIPlan().getServerUuid();
PageCache.cachePage("analysisPage:" + serverUUID, () -> new AnalysisPageResponse(this));
if (Settings.ANALYSIS_EXPORT.isTrue()) {
HtmlExport.exportServer(plugin, serverUUID);
}
}
public void sendConfigSettings() {

View File

@ -1,4 +1,4 @@
/*
/*
* 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
*/
@ -206,14 +206,17 @@ public class ResponseHandler extends APIResponseHandler {
return PageCache.loadPage("notFound: " + error, () -> new NotFoundResponse(error));
}
plugin.getInfoManager().cachePlayer(uuid);
Response response = PageCache.loadPage("inspectPage: " + uuid);
// TODO Create a new method that places NotFoundResponse to PageCache instead.
if (response == null || response.getContent().contains("No Bukkit Servers were online to process this request")) {
PageCache.cachePage("inspectPage: " + uuid, () -> new InspectPageResponse(plugin.getInfoManager(), uuid));
response = PageCache.loadPage("inspectPage: " + uuid);
if (plugin.getDB().wasSeenBefore(uuid)) {
plugin.getInfoManager().cachePlayer(uuid);
Response response = PageCache.loadPage("inspectPage: " + uuid);
// TODO Create a new method that places NotFoundResponse to PageCache instead.
if (response == null || response.getContent().contains("No Bukkit Servers were online to process this request")) {
PageCache.cachePage("inspectPage: " + uuid, () -> new InspectPageResponse(plugin.getInfoManager(), uuid));
response = PageCache.loadPage("inspectPage: " + uuid);
}
return response;
}
return response;
return new NotFoundResponse("Player has not played on this server.");
}
private Response notFoundResponse() {

View File

@ -2,10 +2,7 @@ package main.java.com.djrapitops.plan.systems.webserver.response;
import com.djrapitops.plugin.api.Check;
import com.djrapitops.plugin.api.utility.log.Log;
import main.java.com.djrapitops.plan.Plan;
import main.java.com.djrapitops.plan.api.API;
import main.java.com.djrapitops.plan.api.IPlan;
import main.java.com.djrapitops.plan.data.PlayerProfile;
import main.java.com.djrapitops.plan.data.container.GeoInfo;
import main.java.com.djrapitops.plan.data.container.Session;
import main.java.com.djrapitops.plan.data.container.UserInfo;
@ -79,8 +76,6 @@ public class PlayersPageResponse extends Response {
throw new IllegalArgumentException("No players");
}
API planAPI = Plan.getPlanAPI();
int i = 0;
int maxPlayers = Settings.MAX_PLAYERS_PLAYERS_PAGE.getNumber();
if (maxPlayers <= 0) {
@ -91,14 +86,15 @@ public class PlayersPageResponse extends Response {
break;
}
UUID uuid = userInfo.getUuid();
String[] playerData = new String[6];
String playerName = userInfo.getName();
String link = Html.LINK_EXTERNAL.parse(planAPI.getPlayerInspectPageLink(playerName), playerName);
String link = Html.LINK_EXTERNAL.parse("../player/" + playerName, playerName);
List<Session> sessions = sessionsByUser.getOrDefault(uuid, new ArrayList<>());
int sessionCount = sessions.size();
long playtime = sessionCount != 0 ? PlayerProfile.getPlaytime(sessions.stream()) : 0L;
long playtime = sessionCount != 0 ? sessions.stream().map(Session::getLength)
.mapToLong(p -> p)
.sum() : 0L;
long registered = userInfo.getRegistered();
long lastSeen = lastSeenForAllPlayers.getOrDefault(uuid, 0L);
List<GeoInfo> geoInfoList = geoInfos.getOrDefault(uuid, new ArrayList<>());

View File

@ -32,7 +32,10 @@ public class AnalysisExport extends SpecificExport {
} catch (IOException e) {
Log.toLog(this.getClass().getName(), e);
} finally {
this.cancel();
try {
this.cancel();
} catch (IllegalArgumentException ignore) {
}
}
}
}

View File

@ -71,7 +71,10 @@ public class HtmlExport extends SpecificExport {
} catch (IOException | SQLException e) {
Log.toLog(this.getClass().getName(), e);
} finally {
this.cancel();
try {
this.cancel();
} catch (IllegalArgumentException ignore) {
}
}
}
@ -181,12 +184,8 @@ public class HtmlExport extends SpecificExport {
File to = new File(outputFolder, outputFile);
to.mkdirs();
if (to.exists()) {
if (overwrite) {
to.delete();
to.createNewFile();
} else {
return;
}
to.delete();
to.createNewFile();
}
export(to, lines);
}

View File

@ -32,7 +32,10 @@ public class PlayerExport extends SpecificExport {
} catch (IOException e) {
Log.toLog(this.getClass().getName(), e);
} finally {
this.cancel();
try {
this.cancel();
} catch (IllegalArgumentException ignore) {
}
}
}
}

View File

@ -7,7 +7,6 @@ package main.java.com.djrapitops.plan.utilities.file.export;
import com.djrapitops.plugin.api.Check;
import com.djrapitops.plugin.api.utility.log.Log;
import com.djrapitops.plugin.task.AbsRunnable;
import main.java.com.djrapitops.plan.Plan;
import main.java.com.djrapitops.plan.settings.Settings;
import main.java.com.djrapitops.plan.systems.webserver.PageCache;
import main.java.com.djrapitops.plan.systems.webserver.response.Response;
@ -51,7 +50,7 @@ public abstract class SpecificExport extends AbsRunnable {
}
return folder;
}
File dataFolder = Plan.getInstance().getDataFolder();
File dataFolder = MiscUtils.getIPlan().getDataFolder();
File folder = new File(dataFolder, path);
folder.mkdirs();
return folder;

View File

@ -88,7 +88,7 @@ public enum Html {
TABLELINE_3("<tr><td><b>${0}</b></td><td>${1}</td><td>${2}</td></tr>"),
TABLELINE_4("<tr><td><b>${0}</b></td><td>${1}</td><td>${2}</td><td>${3}</td></tr>"),
TABLELINE_PLAYERS("<tr><td>${0}</td><td>${1}</td><td data-order=\"${2}\">${3}</td><td>${4}</td><td data-order=\"${5}\">${6}</td>" + "<td data-order=\"${7}\">${8}</td><td>${9}</td></tr>"),
TABLELINE_PLAYERS_PLAYERS_PAGE("<tr><td>${0}</td><td data-order=\"${1}\">${2}</td><td>${4}</td><td>${5}</td>" + "<td>${6}</td><td>${7}</td></tr>"),
TABLELINE_PLAYERS_PLAYERS_PAGE("<tr><td>${0}</td><td data-order=\"${1}\">${2}</td><td>${3}</td><td>${4}</td>" + "<td>${5}</td><td>${6}</td></tr>"),
TABLELINE_3_CUSTOMKEY("<tr><td sorttable_customkey=\"${0}\">${1}</td><td sorttable_customkey=\"${2}\">${3}</td><td sorttable_customkey=\"${4}\">${5}</td></tr>"),
TABLELINE_3_CUSTOMKEY_1("<tr><td sorttable_customkey=\"${0}\">${1}</td><td>${2}</td><td>${3}</td></tr>");

View File

@ -311,7 +311,7 @@
<script src="js/admin.js"></script>
<!-- Plan Charts -->
<script src="./js/charts/playerGraph.js"></script>
<script src="../js/charts/playerGraph.js"></script>
<!-- Chart Data -->
<script>