Merge pull request #279 from Fuzzlemann/master

PR for 4.0.0 (Fuzzlemann) (10)
This commit is contained in:
Rsl1122 2017-08-30 19:28:26 +03:00 committed by GitHub
commit f200f2e7c3
8 changed files with 38 additions and 15 deletions

View File

@ -5,10 +5,12 @@
package main.java.com.djrapitops.plan.systems.webapi.bukkit;
import main.java.com.djrapitops.plan.Plan;
import main.java.com.djrapitops.plan.systems.info.InformationManager;
import main.java.com.djrapitops.plan.systems.webapi.WebAPI;
import main.java.com.djrapitops.plan.systems.webserver.PageCache;
import main.java.com.djrapitops.plan.systems.webserver.response.Response;
import main.java.com.djrapitops.plan.systems.webserver.response.api.BadRequestResponse;
import main.java.com.djrapitops.plan.systems.webserver.response.api.JsonResponse;
import java.util.Map;
@ -18,12 +20,12 @@ import java.util.Map;
public class AnalyticsWebAPI implements WebAPI {
@Override
public Response onResponse(Plan plan, Map<String, String> variables) {
String identifier = "analysisJson";
InformationManager infoManager = plan.getInfoManager();
if (!PageCache.isCached(identifier)) {
if (!infoManager.isAnalysisCached()) {
return PageCache.loadPage("No Analysis Data", () -> new BadRequestResponse("No analysis data available"));
}
return PageCache.loadPage(identifier);
return new JsonResponse(infoManager.getAnalysisHtml());
}
}

View File

@ -18,7 +18,7 @@ import java.util.Map;
public class AnalyzeWebAPI implements WebAPI {
@Override
public Response onResponse(Plan plan, Map<String, String> variables) {
// TODO plan.getAnalysisCache().updateCache();
plan.getInfoManager().refreshAnalysis();
return PageCache.loadPage("success", SuccessResponse::new);
}
}

View File

@ -35,7 +35,7 @@ public class InspectWebAPI implements WebAPI {
return PageCache.loadPage(error, () -> new BadRequestResponse(error));
}
// TODO plan.getInspectCache().cache(uuid);
plan.getInfoManager().cachePlayer(uuid);
return PageCache.loadPage("success", SuccessResponse::new);
}

View File

@ -0,0 +1,25 @@
/*
* 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.webapi.bukkit;
import main.java.com.djrapitops.plan.Plan;
import main.java.com.djrapitops.plan.systems.webapi.WebAPI;
import main.java.com.djrapitops.plan.systems.webserver.response.Response;
import main.java.com.djrapitops.plan.systems.webserver.response.api.JsonResponse;
import org.bukkit.Server;
import java.util.Map;
/**
* @author Fuzzlemann
*/
public class OnlinePlayersWebAPI implements WebAPI {
@Override
public Response onResponse(Plan plan, Map<String, String> variables) {
Server server = plan.getServer();
return new JsonResponse(server.getOnlinePlayers() + "/" + server.getMaxPlayers());
}
}

View File

@ -13,10 +13,7 @@ import main.java.com.djrapitops.plan.locale.Msg;
import main.java.com.djrapitops.plan.systems.info.InformationManager;
import main.java.com.djrapitops.plan.systems.webapi.WebAPI;
import main.java.com.djrapitops.plan.systems.webapi.WebAPIManager;
import main.java.com.djrapitops.plan.systems.webapi.bukkit.AnalyticsWebAPI;
import main.java.com.djrapitops.plan.systems.webapi.bukkit.AnalyzeWebAPI;
import main.java.com.djrapitops.plan.systems.webapi.bukkit.ConfigureWebAPI;
import main.java.com.djrapitops.plan.systems.webapi.bukkit.InspectWebAPI;
import main.java.com.djrapitops.plan.systems.webapi.bukkit.*;
import main.java.com.djrapitops.plan.systems.webserver.response.*;
import main.java.com.djrapitops.plan.systems.webserver.response.api.BadRequestResponse;
import main.java.com.djrapitops.plan.systems.webserver.response.api.JsonResponse;
@ -74,6 +71,7 @@ public class WebServer {
WebAPIManager.registerNewAPI("analyze", new AnalyzeWebAPI());
WebAPIManager.registerNewAPI("configure", new ConfigureWebAPI());
WebAPIManager.registerNewAPI("inspect", new InspectWebAPI());
WebAPIManager.registerNewAPI("onlineplayers", new OnlinePlayersWebAPI());
}
/**

View File

@ -22,7 +22,6 @@ import main.java.com.djrapitops.plan.systems.info.InformationManager;
import main.java.com.djrapitops.plan.systems.webserver.PageCache;
import main.java.com.djrapitops.plan.systems.webserver.response.AnalysisPageResponse;
import main.java.com.djrapitops.plan.systems.webserver.response.PlayersPageResponse;
import main.java.com.djrapitops.plan.systems.webserver.response.api.JsonResponse;
import main.java.com.djrapitops.plan.utilities.Benchmark;
import main.java.com.djrapitops.plan.utilities.MiscUtils;
import main.java.com.djrapitops.plan.utilities.comparators.UserInfoLastPlayedComparator;
@ -154,7 +153,6 @@ public class Analysis {
PageCache.removeIf(identifier -> identifier.startsWith("inspectPage: ") || identifier.startsWith("inspectionJson: "));
PageCache.cachePage("analysisPage", () -> new AnalysisPageResponse(plugin.getInfoManager()));
PageCache.cachePage("analysisJson", () -> new JsonResponse(analysisData));
PageCache.cachePage("players", PlayersPageResponse::new);
// TODO Export

View File

@ -1,7 +1,7 @@
package main.java.com.djrapitops.plan.utilities.html;
import main.java.com.djrapitops.plan.data.Session;
import org.apache.commons.lang.StringUtils;
import org.apache.commons.lang3.StringUtils;
import org.bukkit.plugin.java.JavaPlugin;
import org.junit.Before;
import org.junit.Test;

View File

@ -6,6 +6,7 @@ package test.java.main.java.com.djrapitops.plan.ui.graphs;
import main.java.com.djrapitops.plan.data.Session;
import main.java.com.djrapitops.plan.data.TPS;
import main.java.com.djrapitops.plan.data.time.WorldTimes;
import main.java.com.djrapitops.plan.utilities.analysis.Point;
import main.java.com.djrapitops.plan.utilities.html.graphs.*;
import org.junit.Before;
@ -24,7 +25,7 @@ public class GraphTest {
private final List<TPS> tpsList = new ArrayList<>();
private final List<Session> sessionList = new ArrayList<>();
private final Map<String, Integer> geoList = new HashMap<>();
private final Map<String, Long> worldTimes = new HashMap<>();
private final WorldTimes worldTimes = new WorldTimes("WORLD", "SURVIVAL");
private List<Point> points = new ArrayList<>();
@ -34,7 +35,6 @@ public class GraphTest {
tpsList.add(new TPS(i, i, i, i, i, i, i));
sessionList.add(new Session(i, (long) i, (long) i, i, i));
geoList.put(String.valueOf(i), i);
worldTimes.put(String.valueOf(i), (long) i);
}
points = RandomData.randomPoints();
@ -50,7 +50,7 @@ public class GraphTest {
assertEquals("[[0,0.0],[9,9.0]]", WorldLoadGraphCreator.buildSeriesDataStringChunks(tpsList));
assertEquals("[[0,0.0],[9,9.0]]", WorldLoadGraphCreator.buildSeriesDataStringEntities(tpsList));
assertEquals("[{'code':'1','value':1},{'code':'2','value':2},{'code':'3','value':3},{'code':'4','value':4},{'code':'5','value':5},{'code':'6','value':6},{'code':'7','value':7},{'code':'8','value':8},{'code':'9','value':9}]", WorldMapCreator.createDataSeries(geoList));
//assertEquals(WorldPieCreator.createSeriesData(worldTimes), "[{name:'0',y:0},{name:'1',y:1, sliced: true, selected: true},{name:'2',y:2},{name:'3',y:3},{name:'4',y:4},{name:'5',y:5},{name:'6',y:6},{name:'7',y:7},{name:'8',y:8},{name:'9',y:9}]");
assertEquals(Arrays.toString(WorldPieCreator.createSeriesData(worldTimes)), "[[{name:'WORLD',y:0,drilldown: 'WORLD'}], {name:'WORLD', id:'WORLD',data: []}]");
}
@Test