mirror of
https://github.com/plan-player-analytics/Plan.git
synced 2024-12-27 09:00:28 +08:00
GriefPrevention PluginData
This commit is contained in:
parent
81ad293c7f
commit
4427baa744
@ -17,7 +17,7 @@ import java.util.Map;
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* //TODO Class Javadoc Comment
|
||||
* PluginData for ASkyBlock plugin.
|
||||
*
|
||||
* @author Rsl1122
|
||||
*/
|
||||
|
@ -12,7 +12,7 @@ import main.java.com.djrapitops.plan.data.additional.*;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* //TODO Class Javadoc Comment
|
||||
* PluginData for Essentials Plugin.
|
||||
*
|
||||
* @author Rsl1122
|
||||
*/
|
||||
|
@ -18,7 +18,7 @@ import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* //TODO Class Javadoc Comment
|
||||
* PluginData for Factions plugin.
|
||||
*
|
||||
* @author Rsl1122
|
||||
*/
|
||||
|
@ -1,54 +0,0 @@
|
||||
package com.djrapitops.pluginbridge.plan.griefprevention;
|
||||
|
||||
import com.djrapitops.plugin.utilities.Verify;
|
||||
import main.java.com.djrapitops.plan.data.additional.AnalysisType;
|
||||
import main.java.com.djrapitops.plan.data.additional.PluginData;
|
||||
import me.ryanhamshire.GriefPrevention.Claim;
|
||||
import me.ryanhamshire.GriefPrevention.DataStore;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Objects;
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* PluginData class for GriefPrevention-plugin.
|
||||
*
|
||||
* @author Rsl1122
|
||||
* @since 3.5.0
|
||||
*/
|
||||
public class GriefPreventionClaimArea extends PluginData {
|
||||
|
||||
private final DataStore dataStore;
|
||||
|
||||
/**
|
||||
* Class Constructor, sets the parameters of the PluginData object.
|
||||
*
|
||||
* @param dataStore DataStore of GriefPrevention
|
||||
*/
|
||||
public GriefPreventionClaimArea(DataStore dataStore) {
|
||||
super("GriefPrevention", "claim_area", AnalysisType.INT_TOTAL);
|
||||
this.dataStore = dataStore;
|
||||
super.setAnalysisOnly(false);
|
||||
super.setIcon("map-o");
|
||||
super.setPrefix("Claimed Area: ");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getHtmlReplaceValue(String modifierPrefix, UUID uuid) {
|
||||
Verify.nullCheck(uuid);
|
||||
int area = dataStore.getClaims().stream()
|
||||
.filter(Objects::nonNull)
|
||||
.filter(claim -> uuid.equals(claim.ownerID))
|
||||
.map(Claim::getArea).mapToInt(i -> i).sum();
|
||||
return parseContainer(modifierPrefix, Integer.toString(area));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Serializable getValue(UUID uuid) {
|
||||
Verify.nullCheck(uuid);
|
||||
return dataStore.getClaims().stream()
|
||||
.filter(Objects::nonNull)
|
||||
.filter(claim -> uuid.equals(claim.ownerID))
|
||||
.map(Claim::getArea).mapToInt(i -> i).sum();
|
||||
}
|
||||
}
|
@ -1,43 +0,0 @@
|
||||
package com.djrapitops.pluginbridge.plan.griefprevention;
|
||||
|
||||
import main.java.com.djrapitops.plan.data.additional.PluginData;
|
||||
import me.ryanhamshire.GriefPrevention.DataStore;
|
||||
import me.ryanhamshire.GriefPrevention.PlayerData;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* PluginData class for GriefPrevention-plugin.
|
||||
*
|
||||
* @author Rsl1122
|
||||
* @since 3.5.0
|
||||
*/
|
||||
public class GriefPreventionClaimBlocksAvailable extends PluginData {
|
||||
|
||||
private final DataStore dataStore;
|
||||
|
||||
/**
|
||||
* Class Constructor, sets the parameters of the PluginData object.
|
||||
*
|
||||
* @param dataStore DataStore of GriefPrevention
|
||||
*/
|
||||
public GriefPreventionClaimBlocksAvailable(DataStore dataStore) {
|
||||
super("GriefPrevention", "claim_available");
|
||||
this.dataStore = dataStore;
|
||||
super.setIcon("map-o");
|
||||
super.setPrefix("Claim blocks available: ");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getHtmlReplaceValue(String modifierPrefix, UUID uuid) {
|
||||
PlayerData data = dataStore.getPlayerData(uuid);
|
||||
int blocks = data.getAccruedClaimBlocks() + data.getBonusClaimBlocks() + dataStore.getGroupBonusBlocks(uuid);
|
||||
return parseContainer(modifierPrefix, Integer.toString(blocks));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Serializable getValue(UUID uuid) {
|
||||
return -1;
|
||||
}
|
||||
}
|
@ -1,61 +0,0 @@
|
||||
package com.djrapitops.pluginbridge.plan.griefprevention;
|
||||
|
||||
import com.djrapitops.plugin.utilities.FormatUtils;
|
||||
import com.djrapitops.plugin.utilities.Verify;
|
||||
import main.java.com.djrapitops.plan.data.additional.PluginData;
|
||||
import main.java.com.djrapitops.plan.utilities.html.Html;
|
||||
import me.ryanhamshire.GriefPrevention.DataStore;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Objects;
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* PluginData class for GriefPrevention-plugin.
|
||||
*
|
||||
* @author Rsl1122
|
||||
* @since 3.5.0
|
||||
*/
|
||||
public class GriefPreventionClaimTable extends PluginData {
|
||||
|
||||
private final DataStore dataStore;
|
||||
|
||||
/**
|
||||
* Class Constructor, sets the parameters of the PluginData object.
|
||||
*
|
||||
* @param dataStore DataStore of GriefPrevention
|
||||
*/
|
||||
public GriefPreventionClaimTable(DataStore dataStore) {
|
||||
super("GriefPrevention", "inspect_claim_table");
|
||||
this.dataStore = dataStore;
|
||||
String location = Html.FONT_AWESOME_ICON.parse("map-marker") + " Location";
|
||||
String size = Html.FONT_AWESOME_ICON.parse("map-o") + " Area";
|
||||
super.setPrefix(Html.TABLE_START_2.parse(location, size));
|
||||
super.setSuffix(Html.TABLE_END.parse());
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getHtmlReplaceValue(String modifierPrefix, UUID uuid) {
|
||||
return parseContainer(modifierPrefix, getTableLines(uuid));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Serializable getValue(UUID uuid) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
private String getTableLines(UUID uuid) {
|
||||
Verify.nullCheck(uuid);
|
||||
|
||||
StringBuilder html = new StringBuilder();
|
||||
dataStore.getClaims().stream()
|
||||
.filter(Objects::nonNull)
|
||||
.filter(claim -> uuid.equals(claim.ownerID))
|
||||
.forEach(claim -> {
|
||||
String location = FormatUtils.formatLocation(claim.getGreaterBoundaryCorner());
|
||||
int area = claim.getArea();
|
||||
html.append(Html.TABLELINE_2.parse(location, area));
|
||||
});
|
||||
return html.toString();
|
||||
}
|
||||
}
|
@ -1,56 +0,0 @@
|
||||
package com.djrapitops.pluginbridge.plan.griefprevention;
|
||||
|
||||
import com.djrapitops.plugin.utilities.Verify;
|
||||
import main.java.com.djrapitops.plan.data.additional.AnalysisType;
|
||||
import main.java.com.djrapitops.plan.data.additional.PluginData;
|
||||
import me.ryanhamshire.GriefPrevention.Claim;
|
||||
import me.ryanhamshire.GriefPrevention.DataStore;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.UUID;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* PluginData class for GriefPrevention-plugin.
|
||||
*
|
||||
* @author Rsl1122
|
||||
* @since 3.5.0
|
||||
*/
|
||||
public class GriefPreventionClaims extends PluginData {
|
||||
|
||||
private final DataStore dataStore;
|
||||
|
||||
/**
|
||||
* Class Constructor, sets the parameters of the PluginData object.
|
||||
*
|
||||
* @param dataStore DataStore of GriefPrevention
|
||||
*/
|
||||
public GriefPreventionClaims(DataStore dataStore) {
|
||||
super("GriefPrevention", "claim_count", AnalysisType.INT_TOTAL);
|
||||
this.dataStore = dataStore;
|
||||
super.setAnalysisOnly(false);
|
||||
super.setIcon("flag-o");
|
||||
super.setPrefix("Claims: ");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getHtmlReplaceValue(String modifierPrefix, UUID uuid) {
|
||||
Verify.nullCheck(uuid);
|
||||
List<Claim> claims = dataStore.getClaims().stream()
|
||||
.filter(Objects::nonNull)
|
||||
.filter(claim -> uuid.equals(claim.ownerID))
|
||||
.collect(Collectors.toList());
|
||||
return parseContainer(modifierPrefix, Integer.toString(claims.size()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Serializable getValue(UUID uuid) {
|
||||
Verify.nullCheck(uuid);
|
||||
return dataStore.getClaims().stream()
|
||||
.filter(Objects::nonNull)
|
||||
.filter(claim -> uuid.equals(claim.ownerID))
|
||||
.collect(Collectors.toList()).size();
|
||||
}
|
||||
}
|
@ -0,0 +1,78 @@
|
||||
/*
|
||||
* 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.griefprevention;
|
||||
|
||||
import com.djrapitops.plugin.utilities.FormatUtils;
|
||||
import main.java.com.djrapitops.plan.data.additional.*;
|
||||
import main.java.com.djrapitops.plan.utilities.analysis.MathUtils;
|
||||
import me.ryanhamshire.GriefPrevention.Claim;
|
||||
import me.ryanhamshire.GriefPrevention.DataStore;
|
||||
import me.ryanhamshire.GriefPrevention.PlayerData;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.UUID;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* PluginData for GriefPrevention plugin.
|
||||
*
|
||||
* @author Rsl1122
|
||||
*/
|
||||
public class GriefPreventionData extends PluginData {
|
||||
|
||||
private final DataStore dataStore;
|
||||
|
||||
public GriefPreventionData(DataStore dataStore) {
|
||||
super(ContainerSize.THIRD, "GriefPrevention");
|
||||
super.setPluginIcon("map-o");
|
||||
super.setIconColor("blue-grey");
|
||||
this.dataStore = dataStore;
|
||||
}
|
||||
|
||||
@Override
|
||||
public InspectContainer getPlayerData(UUID uuid, InspectContainer inspectContainer) throws Exception {
|
||||
Map<String, Integer> claims = dataStore.getClaims().stream()
|
||||
.filter(Objects::nonNull)
|
||||
.filter(claim -> uuid.equals(claim.ownerID))
|
||||
.collect(Collectors.toMap(
|
||||
claim -> FormatUtils.formatLocation(claim.getGreaterBoundaryCorner()),
|
||||
Claim::getArea)
|
||||
);
|
||||
PlayerData data = dataStore.getPlayerData(uuid);
|
||||
int blocks = data.getAccruedClaimBlocks() + data.getBonusClaimBlocks() + dataStore.getGroupBonusBlocks(uuid);
|
||||
String softMuted = dataStore.isSoftMuted(uuid) ? "Yes" : "No";
|
||||
long totalArea = MathUtils.sumLong(claims.values().stream().map(i -> i));
|
||||
|
||||
inspectContainer.addValue(getWithIcon("SoftMuted", "bell-slash-o", "deep-orange"), softMuted);
|
||||
inspectContainer.addValue(getWithIcon("Claims", "map-marker", "blue-grey"), claims.size());
|
||||
inspectContainer.addValue(getWithIcon("Claimed Area", "map-o", "light-green"), totalArea);
|
||||
inspectContainer.addValue(getWithIcon("Claim Blocks Available", "map-o", "light-green"), blocks);
|
||||
|
||||
TableContainer claimsTable = new TableContainer(getWithIcon("Claim", "map-marker"), getWithIcon("Area", "map-o"));
|
||||
claimsTable.setColor("blue-grey");
|
||||
for (Map.Entry<String, Integer> entry : claims.entrySet()) {
|
||||
claimsTable.addRow(entry.getKey(), entry.getValue());
|
||||
}
|
||||
inspectContainer.addTable("claimTable", claimsTable);
|
||||
|
||||
return inspectContainer;
|
||||
}
|
||||
|
||||
@Override
|
||||
public AnalysisContainer getServerData(Collection<UUID> collection, AnalysisContainer analysisContainer) throws Exception {
|
||||
Map<UUID, Integer> area = dataStore.getClaims().stream()
|
||||
.filter(Objects::nonNull)
|
||||
.collect(Collectors.toMap(claim -> claim.ownerID, Claim::getArea));
|
||||
|
||||
long totalArea = MathUtils.sumLong(area.values().stream().map(i -> i));
|
||||
analysisContainer.addValue(getWithIcon("Total Claimed Area", "map-o", "blue-grey"), totalArea);
|
||||
|
||||
analysisContainer.addPlayerTableValues(getWithIcon("Claimed Area", "map-o"), area);
|
||||
|
||||
return analysisContainer;
|
||||
}
|
||||
}
|
@ -5,6 +5,7 @@ import main.java.com.djrapitops.plan.api.API;
|
||||
import main.java.com.djrapitops.plan.data.additional.HookHandler;
|
||||
import me.ryanhamshire.GriefPrevention.DataStore;
|
||||
import me.ryanhamshire.GriefPrevention.GriefPrevention;
|
||||
|
||||
import static org.bukkit.plugin.java.JavaPlugin.getPlugin;
|
||||
|
||||
/**
|
||||
@ -32,11 +33,7 @@ public class GriefPreventionHook extends Hook {
|
||||
public void hook() throws NoClassDefFoundError {
|
||||
if (enabled) {
|
||||
DataStore dataStore = getPlugin(GriefPrevention.class).dataStore;
|
||||
addPluginDataSource(new GriefPreventionClaims(dataStore));
|
||||
addPluginDataSource(new GriefPreventionClaimArea(dataStore));
|
||||
addPluginDataSource(new GriefPreventionClaimBlocksAvailable(dataStore));
|
||||
addPluginDataSource(new GriefPreventionSoftMuted(dataStore));
|
||||
addPluginDataSource(new GriefPreventionClaimTable(dataStore));
|
||||
addPluginDataSource(new GriefPreventionData(dataStore));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,41 +0,0 @@
|
||||
package com.djrapitops.pluginbridge.plan.griefprevention;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.UUID;
|
||||
import main.java.com.djrapitops.plan.data.additional.AnalysisType;
|
||||
import main.java.com.djrapitops.plan.data.additional.PluginData;
|
||||
import me.ryanhamshire.GriefPrevention.DataStore;
|
||||
|
||||
/**
|
||||
* PluginData class for GriefPrevention-plugin.
|
||||
*
|
||||
* @author Rsl1122
|
||||
* @since 3.5.0
|
||||
*/
|
||||
public class GriefPreventionSoftMuted extends PluginData {
|
||||
|
||||
private final DataStore dataStore;
|
||||
|
||||
/**
|
||||
* Class Constructor, sets the parameters of the PluginData object.
|
||||
*
|
||||
* @param dataStore DataStore of GriefPrevention
|
||||
*/
|
||||
public GriefPreventionSoftMuted(DataStore dataStore) {
|
||||
super("GriefPrevention", "soft_muted", AnalysisType.BOOLEAN_TOTAL, AnalysisType.BOOLEAN_PERCENTAGE);
|
||||
this.dataStore = dataStore;
|
||||
super.setAnalysisOnly(false);
|
||||
super.setIcon("bell-slash-o");
|
||||
super.setPrefix("SoftMuted: ");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getHtmlReplaceValue(String modifierPrefix, UUID uuid) {
|
||||
return parseContainer(modifierPrefix, dataStore.isSoftMuted(uuid) ? "Yes" : "No");
|
||||
}
|
||||
|
||||
@Override
|
||||
public Serializable getValue(UUID uuid) {
|
||||
return dataStore.isSoftMuted(uuid);
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user