mirror of
https://github.com/plan-player-analytics/Plan.git
synced 2024-12-21 05:50:18 +08:00
parent
5c53368f28
commit
36a9825442
@ -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
|
||||
*/
|
||||
@ -10,22 +10,16 @@ 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.FormatUtils;
|
||||
import com.djrapitops.plan.utilities.analysis.MathUtils;
|
||||
import com.djrapitops.plan.utilities.html.Html;
|
||||
import com.gmail.nossr50.database.DatabaseManager;
|
||||
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
||||
import com.gmail.nossr50.datatypes.player.PlayerProfile;
|
||||
import com.gmail.nossr50.datatypes.skills.SkillType;
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.util.player.UserManager;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static org.bukkit.Bukkit.getOnlinePlayers;
|
||||
|
||||
/**
|
||||
* PluginData for McMmo plugin.
|
||||
*
|
||||
@ -43,7 +37,7 @@ public class McMmoData extends PluginData {
|
||||
public InspectContainer getPlayerData(UUID uuid, InspectContainer inspectContainer) {
|
||||
DatabaseManager db = mcMMO.getDatabaseManager();
|
||||
|
||||
PlayerProfile profile = db.loadPlayerProfile(uuid);
|
||||
PlayerProfile profile = db.loadPlayerProfile("", uuid, false);
|
||||
|
||||
String skillS = Html.FONT_AWESOME_ICON.parse("star") + " Skill";
|
||||
String levelS = Html.FONT_AWESOME_ICON.parse("plus") + " Level";
|
||||
@ -59,34 +53,33 @@ public class McMmoData extends PluginData {
|
||||
}
|
||||
|
||||
@Override
|
||||
public AnalysisContainer getServerData(Collection<UUID> collection, AnalysisContainer analysisContainer) {
|
||||
public AnalysisContainer getServerData(Collection<UUID> uuids, AnalysisContainer analysisContainer) {
|
||||
String skillS = Html.FONT_AWESOME_ICON.parse("star") + " Skill";
|
||||
String tLevel = Html.FONT_AWESOME_ICON.parse("plus") + " Total Level";
|
||||
String aLevel = Html.FONT_AWESOME_ICON.parse("plus") + " Average Level";
|
||||
|
||||
analysisContainer.addValue("Only Online Players Shown", "Skills available on Inspect pages.");
|
||||
DatabaseManager databaseManager = mcMMO.getDatabaseManager();
|
||||
|
||||
TableContainer skillTable = new TableContainer(skillS, tLevel, aLevel);
|
||||
skillTable.setColor("indigo");
|
||||
|
||||
List<PlayerProfile> profiles = getOnlinePlayers().stream()
|
||||
List<PlayerProfile> profiles = uuids.stream()
|
||||
.map(uuid -> databaseManager.loadPlayerProfile("", uuid, false))
|
||||
.filter(Objects::nonNull)
|
||||
.map(UserManager::getOfflinePlayer)
|
||||
.filter(Objects::nonNull)
|
||||
.map(McMMOPlayer::getProfile)
|
||||
.filter(PlayerProfile::isLoaded)
|
||||
.collect(Collectors.toList());
|
||||
if (profiles.isEmpty()) {
|
||||
skillTable.addRow("No players online");
|
||||
skillTable.addRow("No players");
|
||||
}
|
||||
|
||||
List<SkillType> skills = Arrays.stream(SkillType.values()).distinct().collect(Collectors.toList());
|
||||
|
||||
for (SkillType skill : skills) {
|
||||
long total = MathUtils.sumInt(profiles.stream().map(p -> (Serializable) p.getSkillLevel(skill)));
|
||||
long total = profiles.stream().mapToInt(p -> p.getSkillLevel(skill)).sum();
|
||||
skillTable.addRow(
|
||||
StringUtils.capitalize(skill.getName().toLowerCase()),
|
||||
Long.toString(total),
|
||||
FormatUtils.cutDecimals(MathUtils.average((int) total, profiles.size()))
|
||||
total,
|
||||
FormatUtils.cutDecimals(total * 1.0 / profiles.size())
|
||||
);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user