From 870b929a9e7befcc8aa3f465c0786677dd85868d Mon Sep 17 00:00:00 2001 From: Rsl1122 Date: Mon, 27 Aug 2018 11:37:57 +0300 Subject: [PATCH] Added ASkyBlock challenges to player page #686 --- .../plan/askyblock/ASkyBlockData.java | 36 ++++++++++++++++++- .../plan/litebans/LiteBansData.java | 2 +- 2 files changed, 36 insertions(+), 2 deletions(-) diff --git a/PlanPluginBridge/src/main/java/com/djrapitops/pluginbridge/plan/askyblock/ASkyBlockData.java b/PlanPluginBridge/src/main/java/com/djrapitops/pluginbridge/plan/askyblock/ASkyBlockData.java index 08516f12d..fc3640f07 100644 --- a/PlanPluginBridge/src/main/java/com/djrapitops/pluginbridge/plan/askyblock/ASkyBlockData.java +++ b/PlanPluginBridge/src/main/java/com/djrapitops/pluginbridge/plan/askyblock/ASkyBlockData.java @@ -6,14 +6,18 @@ package com.djrapitops.pluginbridge.plan.askyblock; import com.djrapitops.plan.data.element.AnalysisContainer; import com.djrapitops.plan.data.element.InspectContainer; +import com.djrapitops.plan.data.element.TableContainer; import com.djrapitops.plan.data.plugin.ContainerSize; import com.djrapitops.plan.data.plugin.PluginData; +import com.djrapitops.plan.utilities.html.graphs.ProgressBar; import com.djrapitops.plan.utilities.html.icon.Color; import com.djrapitops.plan.utilities.html.icon.Family; import com.djrapitops.plan.utilities.html.icon.Icon; +import com.djrapitops.plugin.utilities.Format; import com.wasteofplastic.askyblock.ASkyBlockAPI; import java.util.Collection; +import java.util.Map; import java.util.UUID; /** @@ -35,7 +39,7 @@ public class ASkyBlockData extends PluginData { public InspectContainer getPlayerData(UUID uuid, InspectContainer inspectContainer) { if (api.hasIsland(uuid)) { String islandName = api.getIslandName(uuid); - int level = api.getIslandLevel(uuid); + long level = api.getLongIslandLevel(uuid); int resetsLeft = api.getResetsLeft(uuid); inspectContainer.addValue(getWithIcon("Island Name", Icon.called("street-view").of(Color.GREEN)), islandName); @@ -45,9 +49,39 @@ public class ASkyBlockData extends PluginData { inspectContainer.addValue(getWithIcon("Island Name", Icon.called("street-view").of(Color.GREEN)), "No Island"); } + Map challengeCompletion = api.getChallengeTimes(uuid); + int obtained = (int) challengeCompletion.values().stream().filter(value -> value != 0).count(); + int max = challengeCompletion.size(); + + inspectContainer.addValue(getWithIcon("Challenge Progress", Icon.called("bookmark").of(Color.LIGHT_BLUE)), obtained + " / " + max); + ProgressBar challengeProgress = new ProgressBar(obtained, max, "light-blue"); + inspectContainer.addHtml("challenge-progress", challengeProgress.toHtml()); + + addTable(inspectContainer, challengeCompletion); + return inspectContainer; } + private void addTable(InspectContainer inspectContainer, Map challengeCompletion) { + TableContainer challenges = new TableContainer( + getWithIcon("Challenge", Icon.called("bookmark")), + getWithIcon("Times completed", Icon.called("check")) + ); + challenges.setColor("light-blue"); + challengeCompletion.entrySet().stream() + .sorted((one, two) -> Integer.compare(two.getValue(), one.getValue())) + .forEach(entry -> { + String challenge = new Format(entry.getKey()).capitalize().toString(); + Integer completionTimes = entry.getValue(); + boolean complete = completionTimes > 0; + challenges.addRow( + "" + challenge + "", + completionTimes + ); + }); + inspectContainer.addTable("challenge-table", challenges); + } + @Override public AnalysisContainer getServerData(Collection uuids, AnalysisContainer analysisContainer) { int islandCount = api.getIslandCount(); diff --git a/PlanPluginBridge/src/main/java/com/djrapitops/pluginbridge/plan/litebans/LiteBansData.java b/PlanPluginBridge/src/main/java/com/djrapitops/pluginbridge/plan/litebans/LiteBansData.java index 48cde675c..f58704be9 100644 --- a/PlanPluginBridge/src/main/java/com/djrapitops/pluginbridge/plan/litebans/LiteBansData.java +++ b/PlanPluginBridge/src/main/java/com/djrapitops/pluginbridge/plan/litebans/LiteBansData.java @@ -44,7 +44,7 @@ public class LiteBansData extends PluginData implements BanData { public InspectContainer getPlayerData(UUID uuid, InspectContainer inspectContainer) { inspectContainer.addValue(Icon.called("balance-scale").of(Color.RED) + - "Hover over 'What' column entry for offence reasons", ""); + " Hover over 'What' column entry for offence reasons", ""); String what = getWithIcon("Effect", Icon.called("times-circle").of(Family.REGULAR)); String by = getWithIcon("By", Icon.called("gavel"));