mirror of
https://github.com/plan-player-analytics/Plan.git
synced 2025-02-04 22:41:41 +01:00
Added support for GriefPreventionPlus (#494)
This commit is contained in:
parent
f0efc39c83
commit
547b191464
@ -149,6 +149,13 @@
|
|||||||
<version>16.7.1</version>
|
<version>16.7.1</version>
|
||||||
<scope>provided</scope>
|
<scope>provided</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<!-- https://github.com/KaiKikuchi/GriefPreventionPlus/releases -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>net.kaikk.mc</groupId>
|
||||||
|
<artifactId>GriefPreventionPlus</artifactId>
|
||||||
|
<version>RELEASE</version>
|
||||||
|
<scope>provided</scope>
|
||||||
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>litebans</groupId>
|
<groupId>litebans</groupId>
|
||||||
<artifactId>api</artifactId>
|
<artifactId>api</artifactId>
|
||||||
|
@ -0,0 +1,85 @@
|
|||||||
|
/*
|
||||||
|
* 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.plus;
|
||||||
|
|
||||||
|
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.analysis.MathUtils;
|
||||||
|
import com.djrapitops.plugin.utilities.FormatUtils;
|
||||||
|
import net.kaikk.mc.gpp.Claim;
|
||||||
|
import net.kaikk.mc.gpp.DataStore;
|
||||||
|
import net.kaikk.mc.gpp.PlayerData;
|
||||||
|
|
||||||
|
import java.util.*;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* PluginData for GriefPreventionPlus plugin.
|
||||||
|
*
|
||||||
|
* @author Rsl1122
|
||||||
|
*/
|
||||||
|
public class GriefPreventionPlusData extends PluginData {
|
||||||
|
|
||||||
|
private final DataStore dataStore;
|
||||||
|
|
||||||
|
public GriefPreventionPlusData(DataStore dataStore) {
|
||||||
|
super(ContainerSize.THIRD, "GriefPreventionPlus");
|
||||||
|
super.setPluginIcon("shield");
|
||||||
|
super.setIconColor("blue-grey");
|
||||||
|
this.dataStore = dataStore;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public InspectContainer getPlayerData(UUID uuid, InspectContainer inspectContainer) {
|
||||||
|
Map<String, Integer> claims = dataStore.getClaims().values().stream()
|
||||||
|
.filter(Objects::nonNull)
|
||||||
|
.filter(claim -> uuid.equals(claim.getOwnerID()))
|
||||||
|
.collect(Collectors.toMap(
|
||||||
|
claim -> FormatUtils.formatLocation(claim.getGreaterBoundaryCorner()),
|
||||||
|
Claim::getArea)
|
||||||
|
);
|
||||||
|
PlayerData data = dataStore.getPlayerData(uuid);
|
||||||
|
int blocks = data.getAccruedClaimBlocks() + data.getBonusClaimBlocks();
|
||||||
|
long totalArea = MathUtils.sumLong(claims.values().stream().map(i -> (long) i));
|
||||||
|
|
||||||
|
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) {
|
||||||
|
Map<UUID, Integer> area = new HashMap<>();
|
||||||
|
|
||||||
|
for (Claim claim : dataStore.getClaims().values()) {
|
||||||
|
if (claim == null) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
UUID uuid = claim.getOwnerID();
|
||||||
|
int blocks = area.getOrDefault(uuid, 0);
|
||||||
|
blocks += claim.getArea();
|
||||||
|
area.put(uuid, blocks);
|
||||||
|
}
|
||||||
|
|
||||||
|
long totalArea = MathUtils.sumLong(area.values().stream().map(i -> (long) i));
|
||||||
|
analysisContainer.addValue(getWithIcon("Total Claimed Area", "map-o", "blue-grey"), totalArea);
|
||||||
|
|
||||||
|
analysisContainer.addPlayerTableValues(getWithIcon("Claimed Area", "map-o"), area);
|
||||||
|
|
||||||
|
return analysisContainer;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,37 @@
|
|||||||
|
package com.djrapitops.pluginbridge.plan.griefprevention.plus;
|
||||||
|
|
||||||
|
import com.djrapitops.plan.data.plugin.HookHandler;
|
||||||
|
import com.djrapitops.pluginbridge.plan.Hook;
|
||||||
|
import net.kaikk.mc.gpp.DataStore;
|
||||||
|
import net.kaikk.mc.gpp.GriefPreventionPlus;
|
||||||
|
|
||||||
|
import static org.bukkit.plugin.java.JavaPlugin.getPlugin;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A Class responsible for hooking to GriefPreventionPlus and registering data
|
||||||
|
* sources.
|
||||||
|
*
|
||||||
|
* @author Rsl1122
|
||||||
|
* @since 3.5.0
|
||||||
|
*/
|
||||||
|
public class GriefPreventionPlusHook extends Hook {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Hooks the plugin and registers it's PluginData objects.
|
||||||
|
* <p>
|
||||||
|
* API#addPluginDataSource uses the same method from HookHandler.
|
||||||
|
*
|
||||||
|
* @param hookH HookHandler instance for registering the data sources.
|
||||||
|
* @throws NoClassDefFoundError when the plugin class can not be found.
|
||||||
|
*/
|
||||||
|
public GriefPreventionPlusHook(HookHandler hookH) {
|
||||||
|
super("net.kaikk.mc.gpp.GriefPreventionPlus", hookH);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void hook() throws NoClassDefFoundError {
|
||||||
|
if (enabled) {
|
||||||
|
DataStore dataStore = getPlugin(GriefPreventionPlus.class).getDataStore();
|
||||||
|
addPluginDataSource(new GriefPreventionPlusData(dataStore));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user