Begun PluginData conversion, Fixes to containers

This commit is contained in:
Rsl1122 2017-11-26 12:53:19 +02:00
parent 224468e9d2
commit 3889aedddf
22 changed files with 250 additions and 561 deletions

View File

@ -30,13 +30,17 @@ import java.util.UUID;
*/
public final class AnalysisContainer extends InspectContainer {
private TreeMap<String, Map<UUID, Serializable>> playerTableValues;
private TreeMap<String, Map<UUID, ? extends Serializable>> playerTableValues;
public AnalysisContainer() {
playerTableValues = new TreeMap<>();
}
public TreeMap<String, Map<UUID, Serializable>> getPlayerTableValues() {
public TreeMap<String, Map<UUID, ? extends Serializable>> getPlayerTableValues() {
return playerTableValues;
}
public void addPlayerTableValues(String columnName, Map<UUID, ? extends Serializable> values) {
playerTableValues.put(columnName, values);
}
}

View File

@ -4,8 +4,6 @@
*/
package main.java.com.djrapitops.plan.data.additional;
import main.java.com.djrapitops.plan.utilities.html.Html;
import java.io.Serializable;
import java.util.Map;
import java.util.TreeMap;
@ -37,14 +35,6 @@ public class InspectContainer {
tables = new TreeMap<>();
}
public final String getWithIcon(String text, String icon) {
return getWithColoredIcon(text, icon, "black");
}
public final String getWithColoredIcon(String text, String icon, String color) {
return Html.FA_COLORED_ICON.parse(color, icon) + " " + text;
}
public final void addValue(String label, Serializable value) {
values.put(label, value.toString());
}
@ -78,4 +68,8 @@ public class InspectContainer {
public final boolean hasOnlyValues() {
return html.isEmpty() && tables.isEmpty();
}
public final boolean isEmpty() {
return values.isEmpty() && html.isEmpty() && tables.isEmpty();
}
}

View File

@ -67,4 +67,12 @@ public abstract class PluginData {
public final int hashCode() {
return Objects.hashCode(size, sourcePlugin, pluginIcon);
}
public final String getWithIcon(String text, String icon) {
return getWithIcon(text, icon, "black");
}
public final String getWithIcon(String text, String icon, String color) {
return Html.FA_COLORED_ICON.parse(color, icon) + " " + text;
}
}

View File

@ -20,6 +20,8 @@ public final class TableContainer {
private final String[] header;
private List<Serializable[]> values;
private String color;
/**
* Constructor, call with super(...).
*
@ -30,17 +32,15 @@ public final class TableContainer {
values = new ArrayList<>();
}
protected void addRow(Serializable... values) {
public void addRow(Serializable... values) {
this.values.add(values);
}
public String parseHtml() {
StringBuilder table = new StringBuilder(Html.TABLE.parse());
table.append(parseHeader());
table.append(parseBody());
return table.append("</table>").toString();
return Html.TABLE_COLORED.parse(color != null ? color : "") +
parseHeader() +
parseBody() +
"</table>";
}
private String parseBody() {
@ -67,6 +67,10 @@ public final class TableContainer {
return Html.TABLE_BODY.parse(body.toString());
}
public void setColor(String color) {
this.color = color;
}
public String parseHeader() {
StringBuilder header = new StringBuilder("<tr>");
for (String title : this.header) {

View File

@ -158,7 +158,7 @@ public class Analysis {
Benchmark.start("Analysis", "Source " + source.getSourcePlugin());
AnalysisContainer container = source.getServerData(uuids, new AnalysisContainer());
if (container != null) {
if (container != null && !container.isEmpty()) {
containers.put(source, container);
}

View File

@ -54,6 +54,7 @@ public enum Html {
//
TABLE_END("</tbody></table>"),
TABLE("<table class=\"table table-striped\">"),
TABLE_COLORED("<table class=\"bg-${0} table table-striped\">"),
TABLE_HEAD("<thead>${0}</thead>"),
TABLE_BODY("<tbody>${0}</tbody>"),
TABLE_START_2("<table class=\"table table-striped\"><thead><tr><th>${0}</th><th>${1}</th></tr></thead><tbody>"),

View File

@ -4,7 +4,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>com.djrapitops</groupId>
<artifactId>PlanPluginBridge</artifactId>
<version>4.0.5</version>
<version>4.1.0</version>
<packaging>jar</packaging>
<repositories>
<repository>
@ -24,7 +24,7 @@
<dependency>
<groupId>com.djrapitops</groupId>
<artifactId>Plan</artifactId>
<version>4.0.5</version>
<version>4.1.0</version>
<scope>provided</scope>
</dependency>
<dependency>

View File

@ -1,83 +0,0 @@
package com.djrapitops.pluginbridge.plan.advancedachievements;
import com.hm.achievement.api.AdvancedAchievementsAPI;
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.MiscUtils;
import java.io.Serializable;
import java.util.Collection;
import java.util.HashMap;
import java.util.Map;
import java.util.UUID;
/**
* PluginData class for AdvancedAchievements-plugin.
* <p>
* Registered to the plugin by AdvancedAchievementsHook.
* <p>
* Gives the amount of achievements as value.
*
* @author Rsl1122
* @see AdvancedAchievementsHook
* @since 3.1.0
*/
public class AdvancedAchievementsAchievements extends PluginData {
private final AdvancedAchievementsAPI aaAPI;
private long lastRefresh;
private Map<UUID, Integer> totalAchievements;
/**
* Class Constructor, sets the parameters of the PluginData object.
*
* @param aaAPI AdvancedAchievementsAPI given by AdvancedAchievementsHook
*/
public AdvancedAchievementsAchievements(AdvancedAchievementsAPI aaAPI) {
super("AdvancedAchievements", "achievements", AnalysisType.INT_TOTAL, AnalysisType.INT_AVG);
this.aaAPI = aaAPI;
super.setAnalysisOnly(false);
super.setIcon("check-circle-o");
super.setPrefix("Achievements: ");
totalAchievements = aaAPI.getPlayersTotalAchievements();
lastRefresh = MiscUtils.getTime();
}
@Override
public String getHtmlReplaceValue(String modifierPrefix, UUID uuid) {
if (MiscUtils.getTime() - lastRefresh > 60000) {
refreshTotalAchievements();
}
Integer total = totalAchievements.get(uuid);
if (total != null) {
return parseContainer(modifierPrefix, total + "");
}
return parseContainer(modifierPrefix, "0");
}
private void refreshTotalAchievements() {
totalAchievements = aaAPI.getPlayersTotalAchievements();
lastRefresh = MiscUtils.getTime();
}
@Override
public Map<UUID, Serializable> getValues(Collection<UUID> uuid) {
if (MiscUtils.getTime() - lastRefresh > 60000) {
refreshTotalAchievements();
}
return new HashMap<>(totalAchievements);
}
@Override
public Serializable getValue(UUID uuid) {
if (MiscUtils.getTime() - lastRefresh > 60000) {
refreshTotalAchievements();
}
Integer total = totalAchievements.get(uuid);
if (total != null) {
return total;
}
return -1;
}
}

View File

@ -0,0 +1,70 @@
/*
* 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.advancedachievements;
import com.djrapitops.plugin.api.TimeAmount;
import com.hm.achievement.api.AdvancedAchievementsAPI;
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.FormatUtils;
import main.java.com.djrapitops.plan.utilities.MiscUtils;
import main.java.com.djrapitops.plan.utilities.analysis.MathUtils;
import java.util.Collection;
import java.util.Map;
import java.util.UUID;
/**
* PluginData class for AdvancedAchievements.
*
* @author Rsl1122
*/
public class AdvancedAchievementsData extends PluginData {
private final AdvancedAchievementsAPI aaAPI;
private long lastRefresh;
private Map<UUID, Integer> totalAchievements;
public AdvancedAchievementsData(AdvancedAchievementsAPI aaAPI) {
super(ContainerSize.THIRD, "AdvancedAchievements");
super.setPluginIcon("star");
super.setIconColor("green");
this.aaAPI = aaAPI;
refreshTotalAchievements();
}
@Override
public InspectContainer getPlayerData(UUID uuid, InspectContainer inspectContainer) throws Exception {
String text = getWithIcon("Achievements", "check-circle-o", "green");
inspectContainer.addValue(text, aaAPI.getPlayerTotalAchievements(uuid));
return inspectContainer;
}
@Override
public AnalysisContainer getServerData(Collection<UUID> collection, AnalysisContainer analysisContainer) throws Exception {
if (MiscUtils.getTime() - lastRefresh > TimeAmount.MINUTE.ms() * 5L) {
refreshTotalAchievements();
}
long total = getTotal(totalAchievements);
String average = FormatUtils.cutDecimals(MathUtils.averageDouble(total, totalAchievements.size()));
analysisContainer.addValue(getWithIcon("Total Achievements", "check-circle-o", "green"), total);
analysisContainer.addValue(getWithIcon("Average Achievements", "check-circle-o", "green"), average);
analysisContainer.addPlayerTableValues(getWithIcon("Achievements", "star"), totalAchievements);
return analysisContainer;
}
private long getTotal(Map<UUID, Integer> totalAchievements) {
return MathUtils.sumLong(totalAchievements.values().stream().map(i -> i));
}
private void refreshTotalAchievements() {
totalAchievements = aaAPI.getPlayersTotalAchievements();
lastRefresh = MiscUtils.getTime();
}
}

View File

@ -36,8 +36,7 @@ public class AdvancedAchievementsHook extends Hook {
AdvancedAchievements aa = getPlugin(AdvancedAchievements.class);
if (Integer.parseInt(Character.toString(aa.getDescription().getVersion().charAt(0))) >= 5) {
AdvancedAchievementsAPI aaAPI = AdvancedAchievementsBukkitAPI.linkAdvancedAchievements();
addPluginDataSource(new AdvancedAchievementsAchievements(aaAPI));
addPluginDataSource(new AdvancedAchievementsTable(aaAPI));
addPluginDataSource(new AdvancedAchievementsData(aaAPI));
} else {
enabled = false;
}

View File

@ -1,85 +0,0 @@
package com.djrapitops.pluginbridge.plan.advancedachievements;
import com.hm.achievement.api.AdvancedAchievementsAPI;
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.html.Html;
import java.io.Serializable;
import java.util.Map;
import java.util.Set;
import java.util.UUID;
/**
* PluginData class for AdvancedAchievements-plugin.
* <p>
* Registered to the plugin by AdvancedAchievementsHook
* <p>
* Gives a table of players and achievements achievements.
*
* @author Rsl1122
* @see AdvancedAchievementsHook
* @since 3.1.0
*/
public class AdvancedAchievementsTable extends PluginData {
private final AdvancedAchievementsAPI aaAPI;
/**
* Class Constructor, sets the parameters of the PluginData object.
* <p>
* Uses Html to easily parse Html for the table.
*
* @param aaAPI AdvancedAchievementsAPI given by AdvancedAchievementsHook
* @see Html
*/
public AdvancedAchievementsTable(AdvancedAchievementsAPI aaAPI) {
super("AdvancedAchievements", "achievements_table", AnalysisType.HTML);
this.aaAPI = aaAPI;
String player = Html.FONT_AWESOME_ICON.parse("user") + " Player";
String achievements = Html.FONT_AWESOME_ICON.parse("check-circle-o") + " Achievements";
// analysisOnly true by default.
super.setPrefix(Html.TABLE_START_2.parse(player, achievements));
super.setSuffix(Html.TABLE_END.parse());
}
@Override
public String getHtmlReplaceValue(String modifierPrefix, UUID uuidUnused) {
StringBuilder html = new StringBuilder();
Set<UUID> users = Plan.getInstance().getDataCache().getUuids();
if (users.isEmpty()) {
html.append(Html.TABLELINE_2.parse("No Players.", ""));
} else if (aaAPI.getAdvancedAchievementsVersionCode() >= 520) {
appendTableLinesForV520Plus(users, html);
} else {
appendTableLinesForLessThanV520(users, html);
}
return parseContainer("", html.toString());
}
private void appendTableLinesForLessThanV520(Set<UUID> users, StringBuilder html) {
users.forEach(uuid -> {
String name = super.getNameOf(uuid);
String inspectUrl = Plan.getPlanAPI().getPlayerInspectPageLink(name);
int achievements = aaAPI.getPlayerTotalAchievements(uuid);
html.append(Html.TABLELINE_2.parse(Html.LINK.parse(inspectUrl, name), achievements));
});
}
private void appendTableLinesForV520Plus(Set<UUID> users, StringBuilder html) {
Map<UUID, Integer> achievementsMap = aaAPI.getPlayersTotalAchievements();
for (Map.Entry<UUID, Integer> entry : achievementsMap.entrySet()) {
UUID uuid = entry.getKey();
int achievements = entry.getValue();
String name = getNameOf(uuid);
String inspectUrl = Plan.getPlanAPI().getPlayerInspectPageLink(name);
html.append(Html.TABLELINE_2.parse(Html.LINK.parse(inspectUrl, name), achievements));
}
}
@Override
public Serializable getValue(UUID uuid) {
return -1;
}
}

View File

@ -0,0 +1,68 @@
/*
* 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.askyblock;
import com.wasteofplastic.askyblock.ASkyBlockAPI;
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 java.io.Serializable;
import java.util.Collection;
import java.util.HashMap;
import java.util.Map;
import java.util.UUID;
/**
* //TODO Class Javadoc Comment
*
* @author Rsl1122
*/
public class ASkyBlockData extends PluginData {
private final ASkyBlockAPI api;
public ASkyBlockData(ASkyBlockAPI api) {
super(ContainerSize.THIRD, "ASkyBlock");
super.setPluginIcon("street-view");
super.setIconColor("light-blue");
this.api = api;
}
@Override
public InspectContainer getPlayerData(UUID uuid, InspectContainer inspectContainer) throws Exception {
if (api.hasIsland(uuid)) {
String islandName = api.getIslandName(uuid);
int level = api.getIslandLevel(uuid);
int resetsLeft = api.getResetsLeft(uuid);
inspectContainer.addValue(getWithIcon("Island Name", "street-view", "green"), islandName);
inspectContainer.addValue(getWithIcon("Island Level", "street-view", "amber"), level);
inspectContainer.addValue(getWithIcon("Island Resets Left", "refresh", "green"), resetsLeft);
} else {
inspectContainer.addValue(getWithIcon("Island Name", "street-view", "green"), "No Island");
}
return inspectContainer;
}
@Override
public AnalysisContainer getServerData(Collection<UUID> uuids, AnalysisContainer analysisContainer) throws Exception {
int islandCount = api.getIslandCount();
String islandWorldName = api.getIslandWorld().getName();
analysisContainer.addValue(getWithIcon("Island World", "map-o", "green"), islandWorldName);
analysisContainer.addValue(getWithIcon("Island Count", "street-view", "green"), islandCount);
Map<UUID, Serializable> islandLevels = new HashMap<>();
for (UUID uuid : uuids) {
islandLevels.put(uuid, api.hasIsland(uuid) ? api.getIslandLevel(uuid) : "-");
}
analysisContainer.addPlayerTableValues(getWithIcon("Island Level", "street-view"), islandLevels);
return analysisContainer;
}
}

View File

@ -29,10 +29,7 @@ public class ASkyBlockHook extends Hook {
public void hook() throws NoClassDefFoundError {
if (enabled) {
ASkyBlockAPI api = ASkyBlockAPI.getInstance();
addPluginDataSource(new ASkyBlockIslandName(api));
addPluginDataSource(new ASkyBlockIslandLevel(api));
addPluginDataSource(new ASkyBlockIslandResets(api));
addPluginDataSource(new ASkyBlockIslands(api));
addPluginDataSource(new ASkyBlockData(api));
}
}
}

View File

@ -1,50 +0,0 @@
package com.djrapitops.pluginbridge.plan.askyblock;
import com.wasteofplastic.askyblock.ASkyBlockAPI;
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 ASkyBlock-plugin.
*
* @author Rsl1122
* @since 3.5.0
*/
public class ASkyBlockIslandLevel extends PluginData {
private final ASkyBlockAPI api;
/**
* Class Constructor, sets the parameters of the PluginData object.
*
* @param aaAPI ASkyBlockAPI
*/
public ASkyBlockIslandLevel(ASkyBlockAPI aaAPI) {
super("ASkyBlock", "island_level", AnalysisType.INT_AVG);
this.api = aaAPI;
super.setAnalysisOnly(false);
super.setIcon("street-view");
super.setPrefix("Island Level: ");
}
@Override
public String getHtmlReplaceValue(String modifierPrefix, UUID uuid) {
if (api.hasIsland(uuid)) {
int level = api.getIslandLevel(uuid);
return parseContainer(modifierPrefix, Integer.toString(level));
}
return parseContainer(modifierPrefix, "No Island");
}
@Override
public Serializable getValue(UUID uuid) {
if (api.hasIsland(uuid)) {
return api.getIslandLevel(uuid);
}
return -1;
}
}

View File

@ -1,46 +0,0 @@
package com.djrapitops.pluginbridge.plan.askyblock;
import com.wasteofplastic.askyblock.ASkyBlockAPI;
import main.java.com.djrapitops.plan.data.additional.PluginData;
import java.io.Serializable;
import java.util.UUID;
/**
* PluginData class for ASkyBlock-plugin.
*
* @author Rsl1122
* @since 3.5.0
*/
public class ASkyBlockIslandName extends PluginData {
private final ASkyBlockAPI api;
/**
* Class Constructor, sets the parameters of the PluginData object.
*
* @param aaAPI ASkyBlockAPI
*/
public ASkyBlockIslandName(ASkyBlockAPI aaAPI) {
super("ASkyBlock", "island_name");
this.api = aaAPI;
super.setIcon("street-view");
super.setPrefix("Island name: ");
}
@Override
public String getHtmlReplaceValue(String modifierPrefix, UUID uuid) {
if (api.hasIsland(uuid)) {
return parseContainer(modifierPrefix, api.getIslandName(uuid).replace("§r", ""));
}
return parseContainer(modifierPrefix, "No Island");
}
@Override
public Serializable getValue(UUID uuid) {
//Not used ever
return -1;
}
}

View File

@ -1,43 +0,0 @@
package com.djrapitops.pluginbridge.plan.askyblock;
import com.wasteofplastic.askyblock.ASkyBlockAPI;
import main.java.com.djrapitops.plan.data.additional.PluginData;
import java.io.Serializable;
import java.util.UUID;
/**
* PluginData class for ASkyBlock-plugin.
*
* @author Rsl1122
* @since 3.5.0
*/
public class ASkyBlockIslandResets extends PluginData {
private final ASkyBlockAPI api;
/**
* Class Constructor, sets the parameters of the PluginData object.
*
* @param aaAPI ASkyBlockAPI
*/
public ASkyBlockIslandResets(ASkyBlockAPI aaAPI) {
super("ASkyBlock", "island_resets_left");
this.api = aaAPI;
super.setIcon("refresh");
super.setPrefix("Island Resets Left: ");
}
@Override
public String getHtmlReplaceValue(String modifierPrefix, UUID uuid) {
return parseContainer(modifierPrefix, Integer.toString(api.getResetsLeft(uuid)));
}
@Override
public Serializable getValue(UUID uuid) {
//Not used ever
return -1;
}
}

View File

@ -1,47 +0,0 @@
package com.djrapitops.pluginbridge.plan.askyblock;
import com.wasteofplastic.askyblock.ASkyBlockAPI;
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 ASkyBlock-plugin.
*
* @author Rsl1122
* @since 3.5.0
*/
public class ASkyBlockIslands extends PluginData {
private final ASkyBlockAPI api;
/**
* Class Constructor, sets the parameters of the PluginData object.
*
* @param aaAPI ASkyBlockAPI
*/
public ASkyBlockIslands(ASkyBlockAPI aaAPI) {
super("ASkyBlock", "island_count", AnalysisType.HTML);
this.api = aaAPI;
super.setIcon("street-view");
super.setPrefix("Islands: ");
}
@Override
public String getHtmlReplaceValue(String modifierPrefix, UUID uuid) {
int count = api.getIslandCount();
if (count > 0) {
return parseContainer(modifierPrefix, Integer.toString(count));
}
return parseContainer(modifierPrefix, "0");
}
@Override
public Serializable getValue(UUID uuid) {
//Not used ever
return -1;
}
}

View File

@ -0,0 +1,76 @@
/*
* 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.essentials;
import com.earth2me.essentials.Essentials;
import com.earth2me.essentials.User;
import com.earth2me.essentials.UserMap;
import main.java.com.djrapitops.plan.data.additional.*;
import java.util.*;
/**
* //TODO Class Javadoc Comment
*
* @author Rsl1122
*/
public class EssentialsData extends PluginData {
private final Essentials essentials;
public EssentialsData(Essentials essentials) {
super(ContainerSize.THIRD, "Essentials");
super.setPluginIcon("flask");
super.setIconColor("deep-orange");
this.essentials = essentials;
}
@Override
public InspectContainer getPlayerData(UUID uuid, InspectContainer inspectContainer) throws Exception {
if (essentials.getUserMap().userExists(uuid)) {
User user = essentials.getUser(uuid);
boolean jailed = user.isJailed();
boolean muted = user.isMuted();
inspectContainer.addValue(getWithIcon("Jailed", "ban", "deep-orange"), jailed ? "Yes" : "No");
inspectContainer.addValue(getWithIcon("Muted", "bell-slash-o", "deep-orange"), muted ? "Yes" : "No");
} else {
inspectContainer.addValue("No Essentials Data for this user", "-");
}
return inspectContainer;
}
@Override
public AnalysisContainer getServerData(Collection<UUID> uuids, AnalysisContainer analysisContainer) throws Exception {
UserMap userMap = essentials.getUserMap();
Map<UUID, String> jailed = new HashMap<>();
Map<UUID, String> muted = new HashMap<>();
for (UUID uuid : uuids) {
if (userMap.userExists(uuid)) {
User user = essentials.getUser(uuid);
jailed.put(uuid, user.isJailed() ? "Yes" : "No");
muted.put(uuid, user.isMuted() ? "Yes" : "No");
}
}
analysisContainer.addPlayerTableValues(getWithIcon("Jailed", "ban"), jailed);
analysisContainer.addPlayerTableValues(getWithIcon("Muted", "bell-slash-o"), muted);
List<String> warpsList = new ArrayList<>(essentials.getWarps().getList());
if (!warpsList.isEmpty()) {
TableContainer warps = new TableContainer(getWithIcon("Warp", "map-marker"), getWithIcon("Command", "terminal"));
Collections.sort(warpsList);
for (String warp : warpsList) {
warps.addRow(warp, "/warp " + warp);
}
analysisContainer.addTable("WarpTable", warps);
}
return analysisContainer;
}
}

View File

@ -31,9 +31,7 @@ public class EssentialsHook extends Hook {
public void hook() throws NoClassDefFoundError {
if (enabled) {
Essentials ess = getPlugin(Essentials.class);
addPluginDataSource(new EssentialsJailed(ess));
addPluginDataSource(new EssentialsMuted(ess));
addPluginDataSource(new EssentialsWarps(ess));
addPluginDataSource(new EssentialsData(ess));
}
}
}

View File

@ -1,53 +0,0 @@
package com.djrapitops.pluginbridge.plan.essentials;
import com.earth2me.essentials.Essentials;
import com.earth2me.essentials.User;
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;
/**
* PluginData class for Essentials-plugin.
*
* Registered to the plugin by EssentialsHook
*
* Gives Jailed boolean value.
*
* @author Rsl1122
* @since 3.1.0
* @see EssentialsHook
*/
public class EssentialsJailed extends PluginData {
private final Essentials essentials;
/**
* Class Constructor, sets the parameters of the PluginData object.
*
* @param essentials Instance of Essentials plugin.
*/
public EssentialsJailed(Essentials essentials) {
super("Essentials", "jailed", AnalysisType.BOOLEAN_PERCENTAGE, AnalysisType.BOOLEAN_TOTAL);
this.essentials = essentials;
super.setIcon("ban");
super.setAnalysisOnly(false);
super.setPrefix("Jailed: ");
}
@Override
public String getHtmlReplaceValue(String modifier, UUID uuid) {
User user = essentials.getUser(uuid);
if (user != null) {
return parseContainer(modifier, user.isJailed() ? "Yes" : "No");
}
return parseContainer(modifier, "No");
}
@Override
public Serializable getValue(UUID uuid) {
User user = essentials.getUser(uuid);
return user != null && user.isJailed();
}
}

View File

@ -1,53 +0,0 @@
package com.djrapitops.pluginbridge.plan.essentials;
import com.earth2me.essentials.Essentials;
import com.earth2me.essentials.User;
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;
/**
* PluginData class for Essentials-plugin.
*
* Registered to the plugin by EssentialsHook
*
* Gives Muted boolean value.
*
* @author Rsl1122
* @since 3.1.0
* @see EssentialsHook
*/
public class EssentialsMuted extends PluginData {
private final Essentials essentials;
/**
* Class Constructor, sets the parameters of the PluginData object.
*
* @param essentials Instance of Essentials plugin.
*/
public EssentialsMuted(Essentials essentials) {
super("Essentials", "muted", AnalysisType.BOOLEAN_PERCENTAGE, AnalysisType.BOOLEAN_TOTAL);
this.essentials = essentials;
super.setIcon("bell-slash-o");
super.setAnalysisOnly(false);
super.setPrefix("Muted: ");
}
@Override
public String getHtmlReplaceValue(String modifier, UUID uuid) {
User user = essentials.getUser(uuid);
if (user != null) {
return parseContainer("", user.isMuted() ? "Yes" : "No");
}
return parseContainer(modifier, "No");
}
@Override
public Serializable getValue(UUID uuid) {
User user = essentials.getUser(uuid);
return user != null && user.isMuted();
}
}

View File

@ -1,70 +0,0 @@
package com.djrapitops.pluginbridge.plan.essentials;
import com.earth2me.essentials.Essentials;
import com.earth2me.essentials.Warps;
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.html.Html;
import java.io.Serializable;
import java.util.*;
/**
* PluginData class for Essentials-plugin.
*
* Registered to the plugin by EssentialsHook
*
* Gives a list of warps as a String value.
*
* @author Rsl1122
* @since 3.1.0
* @see EssentialsHook
*/
public class EssentialsWarps extends PluginData {
private final Essentials essentials;
/**
* Class Constructor, sets the parameters of the PluginData object.
*
* @param essentials Instance of Essentials plugin.
*/
public EssentialsWarps(Essentials essentials) {
super("Essentials", "warps", AnalysisType.HTML);
this.essentials = essentials;
String warps = Html.FONT_AWESOME_ICON.parse("map-marker") + " Warps";
String command = Html.FONT_AWESOME_ICON.parse("fa-terminal") + " Command";
super.setPrefix(Html.TABLE_START_2.parse(warps, command));
super.setSuffix(Html.TABLE_END.parse());
}
@Override
public String getHtmlReplaceValue(String modifier, UUID uuid) {
Warps warps = essentials.getWarps();
if (!warps.isEmpty()) {
Collection<String> warpList = warps.getList();
return parseContainer("", getTableContents(new ArrayList<>(warpList)));
}
return parseContainer("", Html.TABLELINE_2.parse("No Warps.", ""));
}
private String getTableContents(List<String> warps) {
Collections.sort(warps);
StringBuilder html = new StringBuilder();
if (warps.isEmpty()) {
html.append(Html.TABLELINE_4.parse("No Factions", "", "", ""));
} else {
for (String warp : warps) {
html.append(Html.TABLELINE_2.parse(warp, "/warp " + warp));
}
}
return html.toString();
}
@Override
public Serializable getValue(UUID uuid) {
return -1;
}
}