Fixes & PluginData objects

Fixed #144
Added #138 (ASkyBlock PluginData)
Added perm groups for #131
Fixed extra space before tables appearing
Total now indicated (Plugindata) with a "Total " modifier.
Added config setting for disabling minotaur player heads from analysis
page
Split tps graph axes to left & right
Added TimeAmount enum (BukkitPluginDependency)
This commit is contained in:
Rsl1122 2017-06-27 13:44:32 +03:00
parent ab326343e6
commit 64dd0b5a20
24 changed files with 454 additions and 66 deletions

View File

@ -26,6 +26,7 @@ public enum Settings {
GATHERCOMMANDS("Settings.Data.GatherCommandUsage"),
SECURITY_IP_UUID("Settings.WebServer.Security.DisplayIPsAndUUIDs"),
GRAPH_PLAYERS_USEMAXPLAYERS_SCALE("Customization.Graphs.PlayersOnlineGraph.UseMaxPlayersAsScale"),
PLAYERLIST_SHOW_IMAGES("Customization.SmallHeadImagesOnAnalysisPlayerlist"),
ENABLED_AA("Customization.Plugins.Enabled.AdvancedAchievements"),
ENABLED_ESS("Customization.Plugins.Enabled.Essentials"),
ENABLED_FAC("Customization.Plugins.Enabled.Factions"),

View File

@ -209,7 +209,11 @@ public class UserData {
@Override
public String toString() {
return "{" + "accessing:" + accessing + "|uuid:" + uuid + "|location:" + location + "|locations:" + locations.size() + "|ips:" + ips + "|nicknames:" + nicknames + "|lastNick:" + lastNick + "|registered:" + registered + "|lastPlayed:" + lastPlayed + "|playTime:" + playTime + "|loginTimes:" + loginTimes + "|timesKicked:" + timesKicked + "|lastGmSwapTime:" + lastGmSwapTime + "|lastGamemode:" + lastGamemode + "|gmTimes:" + gmTimes + "|isOp:" + isOp + "|isBanned:" + isBanned + "|demData:" + demData + "|mobKills:" + mobKills + "|playerKills:" + playerKills + "|deaths:" + deaths + "|name:" + name + "|isOnline:" + isOnline + "|currentSession:" + currentSession + "|sessions:" + sessions + '}';
try {
return "{" + "accessing:" + accessing + "|uuid:" + uuid + "|location:" + location + "|locations:" + locations.size() + "|ips:" + ips + "|nicknames:" + nicknames + "|lastNick:" + lastNick + "|registered:" + registered + "|lastPlayed:" + lastPlayed + "|playTime:" + playTime + "|loginTimes:" + loginTimes + "|timesKicked:" + timesKicked + "|lastGmSwapTime:" + lastGmSwapTime + "|lastGamemode:" + lastGamemode + "|gmTimes:" + gmTimes + "|isOp:" + isOp + "|isBanned:" + isBanned + "|demData:" + demData + "|mobKills:" + mobKills + "|playerKills:" + playerKills + "|deaths:" + deaths + "|name:" + name + "|isOnline:" + isOnline + "|currentSession:" + currentSession + "|sessions:" + sessions + '}';
} catch (Throwable e) {
return "UserData: Error on toString:" + e;
}
}
/**
@ -955,6 +959,7 @@ public class UserData {
/**
* Set the online value.
*
* @param isOnline true/false
*/
public void setOnline(boolean isOnline) {

View File

@ -41,21 +41,21 @@ public enum AnalysisType {
*
* -1 values will be disregarded from the calculation (size will not grow).
*/
INT_TOTAL("totalInt_"),
INT_TOTAL("totalInt_", "Total "),
/**
* Used when the getValue() method returns a long and total should be
* calculated.
*
* -1 values will be disregarded from the calculation (size will not grow).
*/
LONG_TOTAL("totalLong_"),
LONG_TOTAL("totalLong_", "Total "),
/**
* Used when the getValue() method returns a double and total should be
* calculated.
*
* -1 values will be disregarded from the calculation (size will not grow).
*/
DOUBLE_TOTAL("totalDouble_"),
DOUBLE_TOTAL("totalDouble_", "Total "),
/**
* Used when the getValue() method returns an amount of milliseconds as long
* and average should be calculated.

View File

@ -148,7 +148,7 @@ public abstract class PluginData {
* @see AnalysisType
*/
public final String parseContainer(String modifier, String contents) {
return "<div class=\"plugin-data\">" + Html.FONT_AWESOME_ICON.parse(icon) + " " + modifier + prefix + contents + suffix + "</div>";
return "<div class=\"plugin-data\">" + (icon.isEmpty() ? "" : Html.FONT_AWESOME_ICON.parse(icon)) + " " + modifier + prefix + contents + suffix + "</div>";
}
/**

View File

@ -1,5 +1,6 @@
package main.java.com.djrapitops.plan.data.listeners;
import com.djrapitops.javaplugin.api.TimeAmount;
import com.djrapitops.javaplugin.task.RslBukkitRunnable;
import java.util.ArrayList;
import java.util.List;
@ -37,6 +38,7 @@ public class TPSCountTimer extends RslBukkitRunnable<Plan> {
if (diff > nanotime) { // First run's diff = nanotime + 1, no calc possible.
return;
}
diff -= TimeAmount.MILLISECOND.ns() * 40L; // 40ms Removed because the run appears to take 40-50ms, scewing the tps.
TPS tps = calculateTPS(diff, now);
history.add(tps);
if (history.size() >= 60) {
@ -46,16 +48,17 @@ public class TPSCountTimer extends RslBukkitRunnable<Plan> {
}
public TPS calculateTPS(long diff, long now) {
if (diff < 1000000000L) { // No tick count above 20
diff = 1000000000L; // 1 000 000 000ns = 1s
if (diff < TimeAmount.SECOND.ns()) { // No tick count above 20
diff = TimeAmount.SECOND.ns();
}
int playersOnline = plugin.getServer().getOnlinePlayers().size();
while (diff > 20000000000L) {
long twentySeconds = 20L * TimeAmount.SECOND.ns();
while (diff > twentySeconds) {
history.add(new TPS(now, 0, playersOnline));
diff -= 20000000000L;
diff -= twentySeconds;
}
double tpsN = 20000000000L / diff; // 20 000 000 000ns
double tpsN = twentySeconds / diff;
TPS tps = new TPS(now, tpsN, playersOnline);
return tps;
}

View File

@ -1,5 +1,6 @@
package main.java.com.djrapitops.plan.database.tables;
import com.djrapitops.javaplugin.api.TimeAmount;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
@ -128,7 +129,8 @@ public class TPSTable extends Table {
try {
statement = prepareStatement("DELETE FROM " + tableName + " WHERE (" + columnDate + "<?)");
// More than 8 days ago.
statement.setLong(1, MiscUtils.getTime()-((691200L) * 1000L));
long eightDays = TimeAmount.DAY.ms()*8L;
statement.setLong(1, MiscUtils.getTime()-eightDays);
statement.execute();
} finally {
close(statement);

View File

@ -3,7 +3,6 @@ package main.java.com.djrapitops.plan.ui.graphs;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Date;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
@ -16,6 +15,7 @@ import main.java.com.djrapitops.plan.Settings;
import main.java.com.djrapitops.plan.data.SessionData;
import main.java.com.djrapitops.plan.utilities.Benchmark;
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;
/**
@ -32,7 +32,7 @@ public class PlayerActivityGraphCreator {
*/
public static String[] generateDataArray(List<SessionData> sessionData, long scale) {
Benchmark.start("Generate Player Activity Graph " + sessionData.size() + " " + scale + " |");
long now = new Date().toInstant().getEpochSecond() * (long) 1000;
long now = MiscUtils.getTime();
long nowMinusScale = now - scale;
List<List<Long>> s = filterAndTransformSessions(sessionData, nowMinusScale);
List<Long> sessionStarts = s.get(0);

View File

@ -1,6 +1,7 @@
package main.java.com.djrapitops.plan.ui.tables;
import java.util.Collection;
import main.java.com.djrapitops.plan.Settings;
import main.java.com.djrapitops.plan.data.UserData;
import main.java.com.djrapitops.plan.ui.Html;
import main.java.com.djrapitops.plan.utilities.analysis.AnalysisUtils;
@ -21,18 +22,19 @@ public class SortablePlayersTableCreator {
* @return
*/
public static String createSortablePlayersTable(Collection<UserData> data) {
Benchmark.start("Create Players table "+data.size());
Benchmark.start("Create Players table " + data.size());
String html = "";
long now = MiscUtils.getTime();
boolean showImages = Settings.PLAYERLIST_SHOW_IMAGES.isTrue();
for (UserData uData : data) {
try {
String banOunknownOactiveOinactive = uData.isBanned() ? Html.GRAPH_BANNED.parse()
: uData.getLoginTimes() == 1 ? Html.GRAPH_UNKNOWN.parse()
: AnalysisUtils.isActive(now, uData.getLastPlayed(), uData.getPlayTime(), uData.getLoginTimes()) ? Html.GRAPH_ACTIVE.parse()
: Html.GRAPH_INACTIVE.parse();
String img = showImages ? Html.MINOTAR_SMALL_IMG.parse(uData.getName()) : "";
html += Html.TABLELINE_PLAYERS.parse(
Html.MINOTAR_SMALL_IMG.parse(uData.getName()) + Html.LINK.parse(HtmlUtils.getInspectUrl(uData.getName()), uData.getName()),
img + Html.LINK.parse(HtmlUtils.getInspectUrl(uData.getName()), uData.getName()),
banOunknownOactiveOinactive,
uData.getPlayTime() + "", FormatUtils.formatTimeAmount(uData.getPlayTime()),
uData.getLoginTimes() + "",
@ -43,7 +45,7 @@ public class SortablePlayersTableCreator {
} catch (NullPointerException e) {
}
}
Benchmark.stop("Create Players table "+data.size());
Benchmark.stop("Create Players table " + data.size());
return html;
}
}

View File

@ -35,7 +35,7 @@ public class PlaceholderUtils {
public static Map<String, String> getAnalysisReplaceRules(AnalysisData data) {
Benchmark.start("Replace Placeholders Anaysis");
HashMap<String, String> replaceMap = new HashMap<>();
replaceMap.put("%currenttime%", MiscUtils.getTime()+"");
replaceMap.put("%currenttime%", MiscUtils.getTime() + "");
replaceMap.put("%gm0%", (int) (data.getGm0Perc() * 100) + "%");
replaceMap.put("%gm1%", (int) (data.getGm1Perc() * 100) + "%");
replaceMap.put("%gm2%", (int) (data.getGm2Perc() * 100) + "%");
@ -65,13 +65,13 @@ public class PlaceholderUtils {
replaceMap.put("%version%", plugin.getDescription().getVersion());
replaceMap.put("%planlite%", "");
replaceMap.put("%sortabletable%", data.getSortablePlayersTable());
replaceMap.put("%uniquejoinsday%", data.getUniqueJoinsDay()+"");
replaceMap.put("%uniquejoinsweek%", data.getUniqueJoinsWeek()+"");
replaceMap.put("%uniquejoinsmonth%", data.getUniqueJoinsMonth()+"");
replaceMap.put("%avguniquejoins%", data.getAvgUniqJoins()+"");
replaceMap.put("%avguniquejoinsday%", data.getAvgUniqJoinsDay()+"");
replaceMap.put("%avguniquejoinsweek%", data.getAvgUniqJoinsWeek()+"");
replaceMap.put("%avguniquejoinsmonth%", data.getAvgUniqJoinsMonth()+"");
replaceMap.put("%uniquejoinsday%", data.getUniqueJoinsDay() + "");
replaceMap.put("%uniquejoinsweek%", data.getUniqueJoinsWeek() + "");
replaceMap.put("%uniquejoinsmonth%", data.getUniqueJoinsMonth() + "");
replaceMap.put("%avguniquejoins%", data.getAvgUniqJoins() + "");
replaceMap.put("%avguniquejoinsday%", data.getAvgUniqJoinsDay() + "");
replaceMap.put("%avguniquejoinsweek%", data.getAvgUniqJoinsWeek() + "");
replaceMap.put("%avguniquejoinsmonth%", data.getAvgUniqJoinsMonth() + "");
replaceMap.put("%dataday%", data.getPlayersDataArray()[0]);
replaceMap.put("%labelsday%", data.getPlayersDataArray()[1]);
replaceMap.put("%dataweek%", data.getPlayersDataArray()[2]);
@ -130,14 +130,14 @@ public class PlaceholderUtils {
replaceMap.put("#" + defaultCols[i], "#" + colors[i]);
}
}
replaceMap.put("%graphmaxplayers%", Settings.GRAPH_PLAYERS_USEMAXPLAYERS_SCALE.isTrue() ? plugin.getVariable().getMaxPlayers()+"" : "2");
replaceMap.put("%refreshlong%", data.getRefreshDate()+"");
replaceMap.put("%graphmaxplayers%", Settings.GRAPH_PLAYERS_USEMAXPLAYERS_SCALE.isTrue() ? plugin.getVariable().getMaxPlayers() + "" : "2");
replaceMap.put("%refreshlong%", data.getRefreshDate() + "");
replaceMap.put("%servername%", Settings.SERVER_NAME.toString());
String[] tpsData = data.getTpsData();
replaceMap.put("%tpsdatalabels%", tpsData[0]);
replaceMap.put("%tpsdatatps%", tpsData[1]);
replaceMap.put("%tpsdataplayersonline%", tpsData[2]);
replaceMap.put("%averagetps%", data.getAverageTPS()+"");
replaceMap.put("%averagetps%", FormatUtils.cutDecimals(data.getAverageTPS()) + "");
Benchmark.stop("Replace Placeholders Anaysis");
return replaceMap;
}
@ -151,7 +151,7 @@ public class PlaceholderUtils {
*/
public static Map<String, String> getInspectReplaceRules(UserData data) throws FileNotFoundException {
Benchmark.start("Replace Placeholders Inspect");
HashMap<String, String> replaceMap = new HashMap<>();
boolean showIPandUUID = Settings.SECURITY_IP_UUID.isTrue();
UUID uuid = data.getUuid();
@ -212,7 +212,7 @@ public class PlaceholderUtils {
replaceMap.put("%version%", plugin.getDescription().getVersion());
replaceMap.put("%planlite%", "");
String[] playersDataArray = PlayerActivityGraphCreator.generateDataArray(data.getSessions(), (long) 604800 * 1000);
replaceMap.put("%graphmaxplayers%", 2+"");
replaceMap.put("%graphmaxplayers%", 2 + "");
replaceMap.put("%dataweek%", playersDataArray[0]);
replaceMap.put("%labelsweek%", playersDataArray[1]);
replaceMap.put("%playersgraphcolor%", Settings.HCOLOR_ACT_ONL + "");
@ -233,8 +233,8 @@ public class PlaceholderUtils {
replaceMap.put("#" + defaultCols[i], "#" + colors[i]);
}
}
replaceMap.put("%refreshlong%", plugin.getInspectCache().getCacheTime(uuid)+"");
replaceMap.put("%currenttime%", MiscUtils.getTime()+"");
replaceMap.put("%refreshlong%", plugin.getInspectCache().getCacheTime(uuid) + "");
replaceMap.put("%currenttime%", MiscUtils.getTime() + "");
replaceMap.put("%servername%", Settings.SERVER_NAME.toString());
String pluginsTabHtml = plugin.getHookHandler().getPluginsTabLayoutForInspect();
Map<String, String> additionalReplaceRules = plugin.getHookHandler().getAdditionalInspectReplaceRules(uuid);

View File

@ -1,5 +1,6 @@
package main.java.com.djrapitops.plan.utilities.analysis;
import com.djrapitops.javaplugin.api.TimeAmount;
import com.djrapitops.javaplugin.task.RslBukkitRunnable;
import com.djrapitops.javaplugin.task.RslTask;
import java.util.ArrayList;
@ -325,9 +326,9 @@ public class Analysis {
private void createPlayerActivityGraphs(AnalysisData data, List<SessionData> sData, List<Long> registered, Map<UUID, List<SessionData>> sortedSData) {
long now = new Date().toInstant().getEpochSecond() * (long) 1000;
long scaleDay = 86400 * 1000;
long scaleWeek = 604800 * 1000;
long scaleMonth = (long) 2592000 * (long) 1000;
long scaleDay = TimeAmount.DAY.ms();
long scaleWeek = TimeAmount.WEEK.ms();
long scaleMonth = TimeAmount.MONTH.ms();
data.setNewPlayersDay(AnalysisUtils.getNewPlayers(registered, scaleDay, now));
data.setNewPlayersWeek(AnalysisUtils.getNewPlayers(registered, scaleWeek, now));

View File

@ -653,7 +653,7 @@
%averagetps%
</div>
<div class="info-label">
Average
Average 7d
</div>
</div>
</div>
@ -1040,6 +1040,7 @@
pointRadius: 1,
pointHitRadius: 10,
spanGaps: false,
yAxisID: 'A',
data: %tpsdatatps%
}, {
label: "Players Online",
@ -1060,6 +1061,7 @@
pointRadius: 1,
pointHitRadius: 10,
spanGaps: false,
yAxisID: 'B',
data: %tpsdataplayersonline%
}]
};
@ -1076,9 +1078,28 @@
// },
scales: {
yAxes: [{
display: true,
id: 'A',
type: 'linear',
position: 'left',
ticks: {
suggestedMax: 21
suggestedMax: 21,
suggestedMin: 0
},
scaleLabel: {
display: true,
labelString: 'TPS'
}
}, {
id: 'B',
type: 'linear',
position: 'right',
ticks: {
suggestedMax: %graphmaxplayers%,
suggestedMin: 0
},
scaleLabel: {
display: true,
labelString: 'Players'
}
}],
xAxes: [{

View File

@ -42,6 +42,7 @@ Settings:
Customization:
ServerName: 'Plan'
SmallHeadImagesOnAnalysisPlayerlist: true
Graphs:
PlayersOnlineGraph:
UseMaxPlayersAsScale: true

View File

@ -12,6 +12,7 @@ softdepend:
- AdvancedAchievements
- McMMO
- Jobs
- ASkyBlock
commands:
plan:

View File

@ -78,6 +78,12 @@
<version>1.6</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.wasteofplastic.askyblock</groupId>
<artifactId>ASkyBlock</artifactId>
<version>3.0.6.8</version>
<scope>provided</scope>
</dependency>
</dependencies>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>

View File

@ -6,6 +6,7 @@
package com.djrapitops.pluginbridge.plan;
import com.djrapitops.pluginbridge.plan.advancedachievements.AdvancedAchievementsHook;
import com.djrapitops.pluginbridge.plan.askyblock.ASkyBlockHook;
import com.djrapitops.pluginbridge.plan.essentials.EssentialsHook;
import com.djrapitops.pluginbridge.plan.factions.FactionsHook;
import com.djrapitops.pluginbridge.plan.jobs.JobsHook;
@ -13,7 +14,6 @@ import com.djrapitops.pluginbridge.plan.mcmmo.McmmoHook;
import com.djrapitops.pluginbridge.plan.ontime.OnTimeHook;
import com.djrapitops.pluginbridge.plan.towny.TownyHook;
import com.djrapitops.pluginbridge.plan.vault.VaultHook;
import main.java.com.djrapitops.plan.Plan;
import main.java.com.djrapitops.plan.Settings;
import main.java.com.djrapitops.plan.data.additional.HookHandler;
@ -22,6 +22,7 @@ import main.java.com.djrapitops.plan.data.additional.HookHandler;
* @author Rsl1122
*/
public class Bridge {
public static void hook(HookHandler handler) {
try {
if (Settings.ENABLED_AA.isTrue()) {
@ -71,5 +72,9 @@ public class Bridge {
}
} catch (NoClassDefFoundError e) {
}
try {
ASkyBlockHook askyblockHook = new ASkyBlockHook(handler);
} catch (NoClassDefFoundError e) {
}
}
}

View File

@ -51,26 +51,34 @@ public class AdvancedAchievementsTable extends PluginData {
if (cachedUserData.isEmpty()) {
html.append(Html.TABLELINE_2.parse("No Players.", ""));
} else if (aaAPI.getAdvancedAchievementsVersionCode() >= 520) {
Map<UUID, Integer> achievementsMap = aaAPI.getPlayersTotalAchievements();
for (UUID uuid : achievementsMap.keySet()) {
UserData uData = cachedUserData.get(uuid);
if (uData == null) {
continue;
}
String inspectUrl = HtmlUtils.getInspectUrl(uData.getName());
int achievements = achievementsMap.get(uuid);
html.append(Html.TABLELINE_2.parse(Html.LINK.parse(inspectUrl, uData.getName()), achievements+""));
}
appendTablelinesForV520Plus(cachedUserData, html);
} else {
cachedUserData.values().stream().forEach((uData) -> {
String inspectUrl = HtmlUtils.getInspectUrl(uData.getName());
String achievements = aaAPI.getPlayerTotalAchievements(uData.getUuid()) + "";
html.append(Html.TABLELINE_2.parse(Html.LINK.parse(inspectUrl, uData.getName()), achievements));
});
appendTablelinesForLessThanV520(cachedUserData, html);
}
return parseContainer("", html.toString());
}
private void appendTablelinesForLessThanV520(Map<UUID, UserData> cachedUserData, StringBuilder html) {
cachedUserData.values().stream().forEach((uData) -> {
String inspectUrl = HtmlUtils.getInspectUrl(uData.getName());
String achievements = aaAPI.getPlayerTotalAchievements(uData.getUuid()) + "";
html.append(Html.TABLELINE_2.parse(Html.LINK.parse(inspectUrl, uData.getName()), achievements));
});
}
private void appendTablelinesForV520Plus(Map<UUID, UserData> cachedUserData, StringBuilder html) {
Map<UUID, Integer> achievementsMap = aaAPI.getPlayersTotalAchievements();
for (UUID uuid : achievementsMap.keySet()) {
UserData uData = cachedUserData.get(uuid);
if (uData == null) {
continue;
}
String inspectUrl = HtmlUtils.getInspectUrl(uData.getName());
int achievements = achievementsMap.get(uuid);
html.append(Html.TABLELINE_2.parse(Html.LINK.parse(inspectUrl, uData.getName()), achievements+""));
}
}
@Override
public Serializable getValue(UUID uuid) {
return "";

View File

@ -0,0 +1,35 @@
package com.djrapitops.pluginbridge.plan.askyblock;
import com.djrapitops.pluginbridge.plan.Hook;
import com.wasteofplastic.askyblock.ASkyBlockAPI;
import main.java.com.djrapitops.plan.api.API;
import main.java.com.djrapitops.plan.data.additional.HookHandler;
/**
* A Class responsible for hooking to ASkyBlock and registering data sources.
*
* @author Rsl1122
* @since 3.5.0
*/
public class ASkyBlockHook extends Hook {
/**
* Hooks the plugin and registers it's PluginData objects.
*
* API#addPluginDataSource uses the same method from HookHandler.
*
* @param hookH HookHandler instance for registering the data sources.
* @see API
* @throws NoClassDefFoundError when the plugin class can not be found.
*/
public ASkyBlockHook(HookHandler hookH) throws NoClassDefFoundError {
super("com.wasteofplastic.askyblock.ASkyBlock");
if (enabled) {
ASkyBlockAPI api = ASkyBlockAPI.getInstance();
hookH.addPluginDataSource(new ASkyBlockIslandName(api));
hookH.addPluginDataSource(new ASkyBlockIslandLevel(api));
hookH.addPluginDataSource(new ASkyBlockIslandResets(api));
hookH.addPluginDataSource(new ASkyBlockIslands(api));
}
}
}

View File

@ -0,0 +1,50 @@
package com.djrapitops.pluginbridge.plan.askyblock;
import com.wasteofplastic.askyblock.ASkyBlockAPI;
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 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 AdvancedAchievementsAPI given by AdvancedAchievementsHook
*/
public ASkyBlockIslandLevel(ASkyBlockAPI aaAPI) {
super("ASkyBlock", "island_level", new AnalysisType[]{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, level + "");
}
return parseContainer(modifierPrefix, "No Island");
}
@Override
public Serializable getValue(UUID uuid) {
if (api.hasIsland(uuid)) {
int level = api.getIslandLevel(uuid);
return level;
}
return -1;
}
}

View File

@ -0,0 +1,45 @@
package com.djrapitops.pluginbridge.plan.askyblock;
import com.wasteofplastic.askyblock.ASkyBlockAPI;
import java.io.Serializable;
import java.util.UUID;
import main.java.com.djrapitops.plan.data.additional.PluginData;
/**
* 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 AdvancedAchievementsAPI given by AdvancedAchievementsHook
*/
public ASkyBlockIslandName(ASkyBlockAPI aaAPI) {
super("ASkyBlock", "islandname");
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) + "");
}
return parseContainer(modifierPrefix, "No Island");
}
@Override
public Serializable getValue(UUID uuid) {
//Not used ever
return -1;
}
}

View File

@ -0,0 +1,43 @@
package com.djrapitops.pluginbridge.plan.askyblock;
import com.djrapitops.pluginbridge.plan.advancedachievements.*;
import com.wasteofplastic.askyblock.ASkyBlockAPI;
import java.io.Serializable;
import java.util.UUID;
import main.java.com.djrapitops.plan.data.additional.PluginData;
/**
* 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 AdvancedAchievementsAPI given by AdvancedAchievementsHook
*/
public ASkyBlockIslandResets(ASkyBlockAPI aaAPI) {
super("ASkyBlock", "islandresetsleft");
this.api = aaAPI;
super.setIcon("refresh");
super.setPrefix("Island Resets Left: ");
}
@Override
public String getHtmlReplaceValue(String modifierPrefix, UUID uuid) {
return parseContainer(modifierPrefix, api.getResetsLeft(uuid)+"");
}
@Override
public Serializable getValue(UUID uuid) {
//Not used ever
return -1;
}
}

View File

@ -0,0 +1,47 @@
package com.djrapitops.pluginbridge.plan.askyblock;
import com.djrapitops.pluginbridge.plan.advancedachievements.*;
import com.wasteofplastic.askyblock.ASkyBlockAPI;
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 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 AdvancedAchievementsAPI given by AdvancedAchievementsHook
*/
public ASkyBlockIslands(ASkyBlockAPI aaAPI) {
super("ASkyBlock", "island_count", new AnalysisType[]{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, count + "");
}
return parseContainer(modifierPrefix, "0");
}
@Override
public Serializable getValue(UUID uuid) {
//Not used ever
return -1;
}
}

View File

@ -0,0 +1,47 @@
/*
* 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.vault;
import java.io.Serializable;
import java.util.UUID;
import main.java.com.djrapitops.plan.data.additional.PluginData;
import net.milkbowl.vault.permission.Permission;
import org.apache.commons.lang3.StringUtils;
import static org.bukkit.Bukkit.getOfflinePlayer;
import org.bukkit.OfflinePlayer;
/**
* PluginData class for Vault-plugin.
*
* @author Rsl1122
* @since 3.5.0
*/
public class PermGroup extends PluginData {
private final Permission permSys;
public PermGroup(Permission permSystem) {
super("Vault", "permgroup");
permSys = permSystem;
super.setIcon("balance-scale");
super.setPrefix("Permission Group: ");
}
@Override
public String getHtmlReplaceValue(String modifierPrefix, UUID uuid) {
OfflinePlayer p = getOfflinePlayer(uuid);
if (!p.hasPlayedBefore()) {
return parseContainer("", "Hasn't played.");
}
String group = permSys.getPrimaryGroup(null, p);
return parseContainer(modifierPrefix, StringUtils.capitalize(group));
}
@Override
public Serializable getValue(UUID uuid) {
return -1;
}
}

View File

@ -0,0 +1,66 @@
/*
* 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.vault;
import java.io.Serializable;
import java.util.HashMap;
import java.util.Map;
import java.util.UUID;
import main.java.com.djrapitops.plan.data.additional.AnalysisType;
import main.java.com.djrapitops.plan.data.additional.PluginData;
import main.java.com.djrapitops.plan.ui.Html;
import net.milkbowl.vault.permission.Permission;
import org.apache.commons.lang3.StringUtils;
import static org.bukkit.Bukkit.getOfflinePlayers;
import org.bukkit.OfflinePlayer;
/**
* PluginData class for Vault-plugin.
*
* @author Rsl1122
* @since 3.5.0
*/
public class PermGroupTable extends PluginData {
private final Permission permSys;
public PermGroupTable(Permission permSystem) {
super("Vault", "permgrouptable", AnalysisType.HTML);
permSys = permSystem;
String group = Html.FONT_AWESOME_ICON.parse("balance-scale") + " Perm. Group";
String members = Html.FONT_AWESOME_ICON.parse("users") + " Members";
super.setPrefix(Html.TABLE_START_2.parse(group, members));
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() {
Map<String, Integer> groups = new HashMap<>();
for (OfflinePlayer p : getOfflinePlayers()) {
String group = permSys.getPrimaryGroup(null, p);
if (!groups.containsKey(group)) {
groups.put(group, 0);
}
groups.put(group, groups.get(group) + 1);
}
StringBuilder html = new StringBuilder();
for (String group : groups.keySet()) {
html.append(Html.TABLELINE_2.parse(StringUtils.capitalize(group), groups.get(group) + ""));
}
return html.toString();
}
}

View File

@ -4,18 +4,17 @@ import com.djrapitops.pluginbridge.plan.Hook;
import main.java.com.djrapitops.plan.data.additional.HookHandler;
import main.java.com.djrapitops.plan.api.API;
import net.milkbowl.vault.economy.Economy;
import net.milkbowl.vault.permission.Permission;
import static org.bukkit.Bukkit.getServer;
/**
* A Class responsible for hooking to Vault and registering 1 data source.
* A Class responsible for hooking to Vault and registering data sources.
*
* @author Rsl1122
* @since 3.1.0
*/
public class VaultHook extends Hook {
private Economy econ;
/**
* Hooks the plugin and registers it's PluginData objects.
*
@ -32,16 +31,16 @@ public class VaultHook extends Hook {
}
try {
this.econ = getServer().getServicesManager().getRegistration(Economy.class).getProvider();
enabled = true;
Economy econ = getServer().getServicesManager().getRegistration(Economy.class).getProvider();
hookH.addPluginDataSource(new EconomyBalance(econ));
} catch (Throwable e) {
enabled = false;
}
if (!enabled) {
return;
try {
Permission permSys = getServer().getServicesManager().getRegistration(Permission.class).getProvider();
// hookH.addPluginDataSource(new PermGroupTable(permSys)); // Disabled due to getOfflinePlayers method
hookH.addPluginDataSource(new PermGroup(permSys));
} catch (Throwable e) {
}
hookH.addPluginDataSource(new EconomyBalance(econ));
}
}