Added ASkyBlock challenges to player page #686

This commit is contained in:
Rsl1122 2018-08-27 11:37:57 +03:00
parent f5b6b43aec
commit 870b929a9e
2 changed files with 36 additions and 2 deletions

View File

@ -6,14 +6,18 @@ package com.djrapitops.pluginbridge.plan.askyblock;
import com.djrapitops.plan.data.element.AnalysisContainer; import com.djrapitops.plan.data.element.AnalysisContainer;
import com.djrapitops.plan.data.element.InspectContainer; 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.ContainerSize;
import com.djrapitops.plan.data.plugin.PluginData; 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.Color;
import com.djrapitops.plan.utilities.html.icon.Family; import com.djrapitops.plan.utilities.html.icon.Family;
import com.djrapitops.plan.utilities.html.icon.Icon; import com.djrapitops.plan.utilities.html.icon.Icon;
import com.djrapitops.plugin.utilities.Format;
import com.wasteofplastic.askyblock.ASkyBlockAPI; import com.wasteofplastic.askyblock.ASkyBlockAPI;
import java.util.Collection; import java.util.Collection;
import java.util.Map;
import java.util.UUID; import java.util.UUID;
/** /**
@ -35,7 +39,7 @@ public class ASkyBlockData extends PluginData {
public InspectContainer getPlayerData(UUID uuid, InspectContainer inspectContainer) { public InspectContainer getPlayerData(UUID uuid, InspectContainer inspectContainer) {
if (api.hasIsland(uuid)) { if (api.hasIsland(uuid)) {
String islandName = api.getIslandName(uuid); String islandName = api.getIslandName(uuid);
int level = api.getIslandLevel(uuid); long level = api.getLongIslandLevel(uuid);
int resetsLeft = api.getResetsLeft(uuid); int resetsLeft = api.getResetsLeft(uuid);
inspectContainer.addValue(getWithIcon("Island Name", Icon.called("street-view").of(Color.GREEN)), islandName); 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"); inspectContainer.addValue(getWithIcon("Island Name", Icon.called("street-view").of(Color.GREEN)), "No Island");
} }
Map<String, Integer> 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; return inspectContainer;
} }
private void addTable(InspectContainer inspectContainer, Map<String, Integer> 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(
"<span" + (complete ? " class=\"col-green\"" : "") + ">" + challenge + "</span>",
completionTimes
);
});
inspectContainer.addTable("challenge-table", challenges);
}
@Override @Override
public AnalysisContainer getServerData(Collection<UUID> uuids, AnalysisContainer analysisContainer) { public AnalysisContainer getServerData(Collection<UUID> uuids, AnalysisContainer analysisContainer) {
int islandCount = api.getIslandCount(); int islandCount = api.getIslandCount();

View File

@ -44,7 +44,7 @@ public class LiteBansData extends PluginData implements BanData {
public InspectContainer getPlayerData(UUID uuid, InspectContainer inspectContainer) { public InspectContainer getPlayerData(UUID uuid, InspectContainer inspectContainer) {
inspectContainer.addValue(Icon.called("balance-scale").of(Color.RED) + 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 what = getWithIcon("Effect", Icon.called("times-circle").of(Family.REGULAR));
String by = getWithIcon("By", Icon.called("gavel")); String by = getWithIcon("By", Icon.called("gavel"));