RedProtect Support #423

This commit is contained in:
Rsl1122 2017-11-27 11:25:16 +02:00
parent 0dc3e134b4
commit 1da0b9e9a7
4 changed files with 111 additions and 1 deletions

View File

@ -10,6 +10,7 @@ import com.djrapitops.pluginbridge.plan.jobs.JobsHook;
import com.djrapitops.pluginbridge.plan.litebans.LiteBansHook;
import com.djrapitops.pluginbridge.plan.mcmmo.McmmoHook;
import com.djrapitops.pluginbridge.plan.protocolsupport.ProtocolSupportHook;
import com.djrapitops.pluginbridge.plan.redprotect.RedProtectHook;
import com.djrapitops.pluginbridge.plan.superbvote.SuperbVoteHook;
import com.djrapitops.pluginbridge.plan.towny.TownyHook;
import com.djrapitops.pluginbridge.plan.vault.VaultHook;
@ -28,6 +29,7 @@ import main.java.com.djrapitops.plan.data.additional.HookHandler;
* @see McmmoHook
* @see SuperbVoteHook
* @see ProtocolSupportHook
* @see RedProtectHook
* @see TownyHook
* @see VaultHook
* @see ViaVersionHook
@ -51,6 +53,7 @@ public class Bridge {
new McmmoHook(h),
new SuperbVoteHook(h),
new ProtocolSupportHook(h),
new RedProtectHook(h),
new TownyHook(h),
new VaultHook(h),
new ViaVersionHook(h)

View File

@ -28,7 +28,7 @@ public class GriefPreventionData extends PluginData {
public GriefPreventionData(DataStore dataStore) {
super(ContainerSize.THIRD, "GriefPrevention");
super.setPluginIcon("map-o");
super.setPluginIcon("shield");
super.setIconColor("blue-grey");
this.dataStore = dataStore;
}

View File

@ -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.redprotect;
import br.net.fabiozumbi12.RedProtect.API.RedProtectAPI;
import br.net.fabiozumbi12.RedProtect.Region;
import main.java.com.djrapitops.plan.data.additional.*;
import main.java.com.djrapitops.plan.utilities.FormatUtils;
import java.util.Collection;
import java.util.Set;
import java.util.UUID;
/**
* PluginData for RedProtect plugin.
*
* @author Rsl1122
*/
public class RedProtectData extends PluginData {
public RedProtectData() {
super(ContainerSize.THIRD, "RedProtect");
super.setPluginIcon("map-o");
super.setIconColor("shield");
}
@Override
public InspectContainer getPlayerData(UUID uuid, InspectContainer inspectContainer) throws Exception {
Set<Region> regions = RedProtectAPI.getPlayerRegions(uuid.toString());
inspectContainer.addValue(getWithIcon("Regions", "map-marker", "red"), regions.size());
TableContainer regionTable = new TableContainer(
getWithIcon("Region", "map-marker"),
getWithIcon("World", "map"),
getWithIcon("Area", "map-o")
);
long areaTotal = getTotalAndAddRows(regions, regionTable);
inspectContainer.addValue(getWithIcon("Total Area", "map-o", "red"), areaTotal);
inspectContainer.addTable("regionTable", regionTable);
return inspectContainer;
}
@Override
public AnalysisContainer getServerData(Collection<UUID> collection, AnalysisContainer analysisContainer) throws Exception {
Set<Region> regions = RedProtectAPI.getAllRegions();
analysisContainer.addValue(getWithIcon("All Regions", "map-marker", "red"), regions.size());
TableContainer regionTable = new TableContainer(
getWithIcon("Region", "map-marker"),
getWithIcon("World", "map"),
getWithIcon("Area", "map-o")
);
long areaTotal = getTotalAndAddRows(regions, regionTable);
analysisContainer.addValue(getWithIcon("Total Area", "map-o", "red"), areaTotal);
analysisContainer.addTable("regionTable", regionTable);
return analysisContainer;
}
private long getTotalAndAddRows(Set<Region> regions, TableContainer regionTable) {
long areaTotal = 0;
for (Region region : regions) {
int area = region.getArea();
areaTotal += area;
String location = FormatUtils.formatLocation(region.getCenterLoc());
String world = region.getWorld();
regionTable.addRow(location, world, area);
}
return areaTotal;
}
}

View File

@ -0,0 +1,29 @@
/*
* 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.redprotect;
import com.djrapitops.pluginbridge.plan.Hook;
import main.java.com.djrapitops.plan.data.additional.HookHandler;
/**
* Hook for RedProtect plugin.
*
* @author Rsl1122
*/
public class RedProtectHook extends Hook {
public RedProtectHook(HookHandler hookHandler) {
super("br.net.fabiozumbi12.RedProtect.Bukkit.RedProtect", hookHandler);
}
@Override
public void hook() throws NoClassDefFoundError {
if (!enabled) {
return;
}
addPluginDataSource(new RedProtectData());
}
}