mirror of
https://github.com/plan-player-analytics/Plan.git
synced 2024-12-15 05:41:51 +08:00
SuperbVote Data
This commit is contained in:
parent
1ef2b1462c
commit
c16d85b9e5
@ -0,0 +1,57 @@
|
||||
/*
|
||||
* 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 com.djrapitops.pluginbridge.plan.superbvote;
|
||||
|
||||
import io.minimum.minecraft.superbvote.storage.VoteStorage;
|
||||
import main.java.com.djrapitops.plan.data.additional.AnalysisContainer;
|
||||
import main.java.com.djrapitops.plan.data.additional.ContainerSize;
|
||||
import main.java.com.djrapitops.plan.data.additional.InspectContainer;
|
||||
import main.java.com.djrapitops.plan.data.additional.PluginData;
|
||||
import main.java.com.djrapitops.plan.utilities.analysis.MathUtils;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* PluginData for SuperbVote plugin;
|
||||
*
|
||||
* @author Rsl1122
|
||||
*/
|
||||
public class SuperbVoteData extends PluginData {
|
||||
private final VoteStorage store;
|
||||
|
||||
public SuperbVoteData(VoteStorage store) {
|
||||
super(ContainerSize.THIRD, "SuperbVote");
|
||||
super.setPluginIcon("check");
|
||||
super.setIconColor("teal");
|
||||
this.store = store;
|
||||
}
|
||||
|
||||
@Override
|
||||
public InspectContainer getPlayerData(UUID uuid, InspectContainer inspectContainer) throws Exception {
|
||||
int votes = store.getVotes(uuid);
|
||||
|
||||
inspectContainer.addValue(getWithIcon("Votes", "check", "teal"), votes);
|
||||
|
||||
return inspectContainer;
|
||||
}
|
||||
|
||||
@Override
|
||||
public AnalysisContainer getServerData(Collection<UUID> uuids, AnalysisContainer analysisContainer) throws Exception {
|
||||
Map<UUID, Integer> votes = new HashMap<>();
|
||||
for (UUID uuid : uuids) {
|
||||
votes.put(uuid, store.getVotes(uuid));
|
||||
}
|
||||
|
||||
long totalVotes = MathUtils.sumLong(votes.values().stream().map(i -> i));
|
||||
analysisContainer.addValue(getWithIcon("Total Votes", "check", "teal"), totalVotes);
|
||||
|
||||
analysisContainer.addPlayerTableValues(getWithIcon("Votes", "check"), votes);
|
||||
|
||||
return analysisContainer;
|
||||
}
|
||||
}
|
@ -33,8 +33,7 @@ public class SuperbVoteHook extends Hook {
|
||||
public void hook() throws NoClassDefFoundError {
|
||||
if (enabled) {
|
||||
VoteStorage store = getPlugin(SuperbVote.class).getVoteStorage();
|
||||
addPluginDataSource(new SuperbVoteVotes(store));
|
||||
addPluginDataSource(new SuperbVoteVotesTable(store));
|
||||
addPluginDataSource(new SuperbVoteData(store));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,43 +0,0 @@
|
||||
package com.djrapitops.pluginbridge.plan.superbvote;
|
||||
|
||||
import io.minimum.minecraft.superbvote.storage.VoteStorage;
|
||||
import main.java.com.djrapitops.plan.data.additional.AnalysisType;
|
||||
import main.java.com.djrapitops.plan.data.additional.PluginData;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* PluginData class for GriefPrevention-plugin.
|
||||
*
|
||||
* @author Rsl1122
|
||||
* @since 3.5.0
|
||||
*/
|
||||
public class SuperbVoteVotes extends PluginData {
|
||||
|
||||
private final VoteStorage store;
|
||||
|
||||
/**
|
||||
* Class Constructor, sets the parameters of the PluginData object.
|
||||
*
|
||||
* @param store VoteStorage of SuperbVote
|
||||
*/
|
||||
public SuperbVoteVotes(VoteStorage store) {
|
||||
super("SuperbVote", "votes", AnalysisType.INT_TOTAL, AnalysisType.INT_AVG);
|
||||
this.store = store;
|
||||
super.setAnalysisOnly(false);
|
||||
super.setIcon("check");
|
||||
super.setPrefix("Votes: ");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getHtmlReplaceValue(String modifierPrefix, UUID uuid) {
|
||||
int votes = store.getVotes(uuid);
|
||||
return parseContainer(modifierPrefix, Integer.toString(votes));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Serializable getValue(UUID uuid) {
|
||||
return store.getVotes(uuid);
|
||||
}
|
||||
}
|
@ -1,60 +0,0 @@
|
||||
/*
|
||||
* To change this license header, choose License Headers in Project Properties.
|
||||
* To change this template file, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
package com.djrapitops.pluginbridge.plan.superbvote;
|
||||
|
||||
import io.minimum.minecraft.superbvote.storage.VoteStorage;
|
||||
import main.java.com.djrapitops.plan.Plan;
|
||||
import main.java.com.djrapitops.plan.data.additional.AnalysisType;
|
||||
import main.java.com.djrapitops.plan.data.additional.PluginData;
|
||||
import main.java.com.djrapitops.plan.utilities.FormatUtils;
|
||||
import main.java.com.djrapitops.plan.utilities.html.Html;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* PluginData class for Vault-plugin.
|
||||
*
|
||||
* @author Rsl1122
|
||||
* @since 3.5.0
|
||||
*/
|
||||
public class SuperbVoteVotesTable extends PluginData {
|
||||
|
||||
private final VoteStorage store;
|
||||
|
||||
public SuperbVoteVotesTable(VoteStorage store) {
|
||||
super("SuperbVote", "vote_table", AnalysisType.HTML);
|
||||
this.store = store;
|
||||
String user = Html.FONT_AWESOME_ICON.parse("user") + " Player";
|
||||
String votes = Html.FONT_AWESOME_ICON.parse("check") + " Votes";
|
||||
super.setPrefix(Html.TABLE_START_2.parse(user, votes));
|
||||
super.setSuffix(Html.TABLE_END.parse());
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getHtmlReplaceValue(String modifierPrefix, UUID uuid) {
|
||||
String tableLines = getTableLines();
|
||||
return parseContainer("", tableLines);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Serializable getValue(UUID uuid) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
private String getTableLines() {
|
||||
StringBuilder html = new StringBuilder();
|
||||
getUUIDsBeingAnalyzed()
|
||||
.forEach(uuid -> {
|
||||
String name = getNameOf(uuid);
|
||||
String link = Html.LINK.parse(Plan.getPlanAPI().getPlayerInspectPageLink(name), name);
|
||||
String bal = FormatUtils.cutDecimals(store.getVotes(uuid));
|
||||
html.append(Html.TABLELINE_2.parse(link, bal));
|
||||
});
|
||||
return html.toString();
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue
Block a user