mirror of
https://github.com/plan-player-analytics/Plan.git
synced 2024-12-23 09:37:54 +01:00
Automatic PluginData config section, GriefPrevention data
Implemented #132 Implemented N.5 of #125 Moved debug log header to BukkitPluginDependency Task disabling to BukkitPluginDependency
This commit is contained in:
parent
64dd0b5a20
commit
d03d0836a1
@ -92,14 +92,7 @@ public class Plan extends RslPlugin<Plan> {
|
||||
|
||||
Server server = getServer();
|
||||
variable = new ServerVariableHolder(server);
|
||||
|
||||
Log.debug("-------------------------------------");
|
||||
Log.debug("Debug log: Plan v." + getVersion());
|
||||
Log.debug("Implements RslPlugin v." + getRslVersion());
|
||||
Log.debug("Server: " + server.getBukkitVersion());
|
||||
Log.debug("Version: " + server.getVersion());
|
||||
Log.debug("-------------------------------------");
|
||||
|
||||
|
||||
databases = new HashSet<>();
|
||||
databases.add(new MySQLDB(this));
|
||||
databases.add(new SQLiteDB(this));
|
||||
@ -147,7 +140,7 @@ public class Plan extends RslPlugin<Plan> {
|
||||
Log.infoColor(Phrase.NOTIFY_EMPTY_IP + "");
|
||||
}
|
||||
|
||||
hookHandler = new HookHandler();
|
||||
hookHandler = new HookHandler(this);
|
||||
|
||||
Log.debug("Verboose debug messages are enabled.");
|
||||
Log.info(Phrase.ENABLED + "");
|
||||
@ -162,17 +155,17 @@ public class Plan extends RslPlugin<Plan> {
|
||||
public void onDisable() {
|
||||
if (uiServer != null) {
|
||||
uiServer.stop();
|
||||
}
|
||||
}
|
||||
Bukkit.getScheduler().cancelTasks(this);
|
||||
if (handler != null) {
|
||||
Log.info(Phrase.CACHE_SAVE + "");
|
||||
ScheduledExecutorService scheduler = Executors.newScheduledThreadPool(1);
|
||||
scheduler.execute(() -> {
|
||||
handler.saveCacheOnDisable();
|
||||
taskStatus().cancelAllKnownTasks();
|
||||
});
|
||||
|
||||
scheduler.shutdown();
|
||||
}
|
||||
}
|
||||
Log.info(Phrase.DISABLED + "");
|
||||
}
|
||||
|
||||
|
@ -27,14 +27,6 @@ public enum Settings {
|
||||
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"),
|
||||
ENABLED_JOB("Customization.Plugins.Enabled.Jobs"),
|
||||
ENABLED_MCM("Customization.Plugins.Enabled.McMMO"),
|
||||
ENABLED_ONT("Customization.Plugins.Enabled.OnTime"),
|
||||
ENABLED_TOW("Customization.Plugins.Enabled.Towny"),
|
||||
ENABLED_VAU("Customization.Plugins.Enabled.Vault"),
|
||||
LINK_PROTOCOL("Settings.WebServer.LinkProtocol"),
|
||||
// Integer
|
||||
ANALYSIS_MINUTES_FOR_ACTIVE("Settings.Analysis.MinutesPlayedUntilConsidiredActive"),
|
||||
|
@ -9,6 +9,7 @@ import java.util.Map;
|
||||
import java.util.UUID;
|
||||
import java.util.stream.Collectors;
|
||||
import main.java.com.djrapitops.plan.Log;
|
||||
import main.java.com.djrapitops.plan.Plan;
|
||||
import main.java.com.djrapitops.plan.utilities.HtmlUtils;
|
||||
|
||||
/**
|
||||
@ -21,12 +22,16 @@ import main.java.com.djrapitops.plan.utilities.HtmlUtils;
|
||||
public class HookHandler {
|
||||
|
||||
private List<PluginData> additionalDataSources;
|
||||
private final PluginConfigSectionHandler configHandler;
|
||||
|
||||
/**
|
||||
* Class constructor, hooks to plugins.
|
||||
*
|
||||
* @param plugin Current instance of plan.
|
||||
*/
|
||||
public HookHandler() {
|
||||
public HookHandler(Plan plugin) {
|
||||
additionalDataSources = new ArrayList<>();
|
||||
configHandler = new PluginConfigSectionHandler(plugin);
|
||||
try {
|
||||
Bridge.hook(this);
|
||||
} catch (Throwable e) {
|
||||
@ -46,8 +51,18 @@ public class HookHandler {
|
||||
* @param dataSource an object extending the PluginData class.
|
||||
*/
|
||||
public void addPluginDataSource(PluginData dataSource) {
|
||||
Log.debug("Registered a new datasource: " + dataSource.getPlaceholder("").replace("%", ""));
|
||||
additionalDataSources.add(dataSource);
|
||||
try {
|
||||
if (!configHandler.hasSection(dataSource)) {
|
||||
configHandler.createSection(dataSource);
|
||||
}
|
||||
if (configHandler.isEnabled(dataSource)) {
|
||||
Log.debug("Registered a new datasource: " + dataSource.getPlaceholder("").replace("%", ""));
|
||||
additionalDataSources.add(dataSource);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
Log.toLog(this.getClass().getName(), e);
|
||||
Log.error("Attempting to register PluginDataSource caused an exception.");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -0,0 +1,58 @@
|
||||
package main.java.com.djrapitops.plan.data.additional;
|
||||
|
||||
import main.java.com.djrapitops.plan.Plan;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
|
||||
/**
|
||||
* Class responsible for generating and generating settings for PluginData
|
||||
* objects to the config.
|
||||
*
|
||||
* @author Rsl1122
|
||||
* @since 3.5.0
|
||||
*/
|
||||
public class PluginConfigSectionHandler {
|
||||
|
||||
private final Plan plan;
|
||||
|
||||
public PluginConfigSectionHandler(Plan plan) {
|
||||
this.plan = plan;
|
||||
}
|
||||
|
||||
public boolean hasSection(PluginData dataSource) {
|
||||
ConfigurationSection section = getPluginsSection();
|
||||
String pluginName = dataSource.getSourcePlugin();
|
||||
if (!section.contains(pluginName)) {
|
||||
return false;
|
||||
}
|
||||
ConfigurationSection pluginSection = section.getConfigurationSection(pluginName);
|
||||
return pluginSection.contains(dataSource.getPlaceholder(""));
|
||||
}
|
||||
|
||||
private ConfigurationSection getPluginsSection() {
|
||||
FileConfiguration config = plan.getConfig();
|
||||
ConfigurationSection section = config.getConfigurationSection("Customization.Plugins");
|
||||
return section;
|
||||
}
|
||||
|
||||
public void createSection(PluginData dataSource) {
|
||||
ConfigurationSection section = getPluginsSection();
|
||||
String pluginName = dataSource.getSourcePlugin();
|
||||
String source = dataSource.placeholder;
|
||||
section.addDefault(pluginName + ".Enabled", true);
|
||||
section.addDefault(pluginName + ".Data." + source, true);
|
||||
FileConfiguration config = plan.getConfig();
|
||||
config.set("Customization.Plugins", section);
|
||||
plan.saveConfig();
|
||||
}
|
||||
|
||||
public boolean isEnabled(PluginData dataSource) {
|
||||
ConfigurationSection section = getPluginsSection();
|
||||
String pluginName = dataSource.getSourcePlugin();
|
||||
if (!section.getBoolean(pluginName + ".Enabled")) {
|
||||
return false;
|
||||
}
|
||||
String source = dataSource.placeholder;
|
||||
return section.getBoolean(pluginName + ".Data." + source);
|
||||
}
|
||||
}
|
@ -394,7 +394,9 @@ public class Analysis {
|
||||
Benchmark.start("Analysis 3rd party");
|
||||
final Map<String, String> replaceMap = new HashMap<>();
|
||||
final HookHandler hookHandler = plugin.getHookHandler();
|
||||
final List<PluginData> sources = hookHandler.getAdditionalDataSources();
|
||||
final List<PluginData> sources = hookHandler.getAdditionalDataSources().stream()
|
||||
.filter(p -> !p.getAnalysisTypes().isEmpty())
|
||||
.collect(Collectors.toList());
|
||||
final AnalysisType[] totalTypes = new AnalysisType[]{
|
||||
AnalysisType.INT_TOTAL, AnalysisType.LONG_TOTAL, AnalysisType.LONG_TIME_MS_TOTAL, AnalysisType.DOUBLE_TOTAL
|
||||
};
|
||||
|
@ -88,15 +88,6 @@ Customization:
|
||||
Male: 'male, boy, man, boe, sir, mr, guy, he, männlich, maskulin, junge, mann'
|
||||
IgnoreWhen: 'sure, think, with, are, you, din'
|
||||
Plugins:
|
||||
Enabled:
|
||||
AdvancedAchievements: true
|
||||
Essentials: true
|
||||
Factions: true
|
||||
Jobs: true
|
||||
McMMO: true
|
||||
OnTime: true
|
||||
Towny: true
|
||||
Vault: true
|
||||
Factions:
|
||||
HideFactions:
|
||||
- ExampleFaction
|
||||
|
@ -13,6 +13,7 @@ softdepend:
|
||||
- McMMO
|
||||
- Jobs
|
||||
- ASkyBlock
|
||||
- GriefPrevention
|
||||
|
||||
commands:
|
||||
plan:
|
||||
|
@ -10,6 +10,10 @@
|
||||
<id>vault-repo</id>
|
||||
<url>http://nexus.hc.to/content/repositories/pub_releases</url>
|
||||
</repository>
|
||||
<repository>
|
||||
<id>jitpack.io</id>
|
||||
<url>https://jitpack.io</url>
|
||||
</repository>
|
||||
</repositories>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
@ -84,6 +88,12 @@
|
||||
<version>3.0.6.8</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.github.TechFortress</groupId>
|
||||
<artifactId>GriefPrevention</artifactId>
|
||||
<version>16.7.1</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
<properties>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
|
@ -14,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.Settings;
|
||||
import main.java.com.djrapitops.plan.data.additional.HookHandler;
|
||||
|
||||
/**
|
||||
@ -25,51 +24,35 @@ public class Bridge {
|
||||
|
||||
public static void hook(HookHandler handler) {
|
||||
try {
|
||||
if (Settings.ENABLED_AA.isTrue()) {
|
||||
AdvancedAchievementsHook advancedAchievementsHook = new AdvancedAchievementsHook(handler);
|
||||
}
|
||||
AdvancedAchievementsHook advancedAchievementsHook = new AdvancedAchievementsHook(handler);
|
||||
} catch (NoClassDefFoundError e) {
|
||||
}
|
||||
try {
|
||||
if (Settings.ENABLED_ESS.isTrue()) {
|
||||
EssentialsHook essentialsHook = new EssentialsHook(handler);
|
||||
}
|
||||
EssentialsHook essentialsHook = new EssentialsHook(handler);
|
||||
} catch (NoClassDefFoundError e) {
|
||||
}
|
||||
try {
|
||||
if (Settings.ENABLED_FAC.isTrue()) {
|
||||
FactionsHook factionsHook = new FactionsHook(handler);
|
||||
}
|
||||
FactionsHook factionsHook = new FactionsHook(handler);
|
||||
} catch (NoClassDefFoundError e) {
|
||||
}
|
||||
try {
|
||||
if (Settings.ENABLED_MCM.isTrue()) {
|
||||
McmmoHook mcMmoHook = new McmmoHook(handler);
|
||||
}
|
||||
McmmoHook mcMmoHook = new McmmoHook(handler);
|
||||
} catch (NoClassDefFoundError e) {
|
||||
}
|
||||
try {
|
||||
if (Settings.ENABLED_JOB.isTrue()) {
|
||||
JobsHook jobsHook = new JobsHook(handler);
|
||||
}
|
||||
JobsHook jobsHook = new JobsHook(handler);
|
||||
} catch (NoClassDefFoundError e) {
|
||||
}
|
||||
try {
|
||||
if (Settings.ENABLED_ONT.isTrue()) {
|
||||
OnTimeHook onTimeHook = new OnTimeHook(handler);
|
||||
}
|
||||
OnTimeHook onTimeHook = new OnTimeHook(handler);
|
||||
} catch (NoClassDefFoundError e) {
|
||||
}
|
||||
try {
|
||||
if (Settings.ENABLED_TOW.isTrue()) {
|
||||
TownyHook townyHook = new TownyHook(handler);
|
||||
}
|
||||
TownyHook townyHook = new TownyHook(handler);
|
||||
} catch (NoClassDefFoundError e) {
|
||||
}
|
||||
try {
|
||||
if (Settings.ENABLED_VAU.isTrue()) {
|
||||
VaultHook vaultHook = new VaultHook(handler);
|
||||
}
|
||||
VaultHook vaultHook = new VaultHook(handler);
|
||||
} catch (NoClassDefFoundError e) {
|
||||
}
|
||||
try {
|
||||
|
@ -19,7 +19,7 @@ public class ASkyBlockIslandLevel extends PluginData {
|
||||
/**
|
||||
* Class Constructor, sets the parameters of the PluginData object.
|
||||
*
|
||||
* @param aaAPI AdvancedAchievementsAPI given by AdvancedAchievementsHook
|
||||
* @param aaAPI ASkyBlockAPI
|
||||
*/
|
||||
public ASkyBlockIslandLevel(ASkyBlockAPI aaAPI) {
|
||||
super("ASkyBlock", "island_level", new AnalysisType[]{AnalysisType.INT_AVG});
|
||||
|
@ -18,7 +18,7 @@ public class ASkyBlockIslandName extends PluginData {
|
||||
/**
|
||||
* Class Constructor, sets the parameters of the PluginData object.
|
||||
*
|
||||
* @param aaAPI AdvancedAchievementsAPI given by AdvancedAchievementsHook
|
||||
* @param aaAPI ASkyBlockAPI
|
||||
*/
|
||||
public ASkyBlockIslandName(ASkyBlockAPI aaAPI) {
|
||||
super("ASkyBlock", "islandname");
|
||||
|
@ -1,6 +1,5 @@
|
||||
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;
|
||||
@ -19,7 +18,7 @@ public class ASkyBlockIslandResets extends PluginData {
|
||||
/**
|
||||
* Class Constructor, sets the parameters of the PluginData object.
|
||||
*
|
||||
* @param aaAPI AdvancedAchievementsAPI given by AdvancedAchievementsHook
|
||||
* @param aaAPI ASkyBlockAPI
|
||||
*/
|
||||
public ASkyBlockIslandResets(ASkyBlockAPI aaAPI) {
|
||||
super("ASkyBlock", "islandresetsleft");
|
||||
|
@ -1,6 +1,5 @@
|
||||
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;
|
||||
@ -20,7 +19,7 @@ public class ASkyBlockIslands extends PluginData {
|
||||
/**
|
||||
* Class Constructor, sets the parameters of the PluginData object.
|
||||
*
|
||||
* @param aaAPI AdvancedAchievementsAPI given by AdvancedAchievementsHook
|
||||
* @param aaAPI ASkyBlockAPI
|
||||
*/
|
||||
public ASkyBlockIslands(ASkyBlockAPI aaAPI) {
|
||||
super("ASkyBlock", "island_count", new AnalysisType[]{AnalysisType.HTML});
|
||||
|
@ -0,0 +1,43 @@
|
||||
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 main.java.com.djrapitops.plan.utilities.analysis.MathUtils;
|
||||
import me.ryanhamshire.GriefPrevention.DataStore;
|
||||
|
||||
/**
|
||||
* 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", new AnalysisType[]{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) {
|
||||
int area = MathUtils.sumInt(dataStore.getClaims().stream().filter(claim -> claim.ownerID.equals(uuid)).map(c -> c.getArea()));
|
||||
return parseContainer(modifierPrefix, area + "");
|
||||
}
|
||||
|
||||
@Override
|
||||
public Serializable getValue(UUID uuid) {
|
||||
return MathUtils.sumInt(dataStore.getClaims().stream().filter(claim -> claim.ownerID.equals(uuid)).map(c -> c.getArea()));
|
||||
}
|
||||
}
|
@ -0,0 +1,42 @@
|
||||
package com.djrapitops.pluginbridge.plan.griefprevention;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.UUID;
|
||||
import main.java.com.djrapitops.plan.data.additional.PluginData;
|
||||
import me.ryanhamshire.GriefPrevention.DataStore;
|
||||
import me.ryanhamshire.GriefPrevention.PlayerData;
|
||||
|
||||
/**
|
||||
* 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, blocks + "");
|
||||
}
|
||||
|
||||
@Override
|
||||
public Serializable getValue(UUID uuid) {
|
||||
return -1;
|
||||
}
|
||||
}
|
@ -0,0 +1,55 @@
|
||||
package com.djrapitops.pluginbridge.plan.griefprevention;
|
||||
|
||||
import com.djrapitops.javaplugin.utilities.FormattingUtils;
|
||||
import java.io.Serializable;
|
||||
import java.util.UUID;
|
||||
import main.java.com.djrapitops.plan.data.additional.PluginData;
|
||||
import main.java.com.djrapitops.plan.ui.Html;
|
||||
import me.ryanhamshire.GriefPrevention.DataStore;
|
||||
|
||||
/**
|
||||
* 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", "inspectclaimtable");
|
||||
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_3.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) {
|
||||
StringBuilder html = new StringBuilder();
|
||||
dataStore.getClaims().stream()
|
||||
.filter(claim -> claim.ownerID.equals(uuid))
|
||||
.forEach(claim -> {
|
||||
String location = FormattingUtils.formatLocation(claim.getGreaterBoundaryCorner());
|
||||
String area = claim.getArea() + "";
|
||||
html.append(Html.TABLELINE_3.parse(location, area));
|
||||
});
|
||||
return html.toString();
|
||||
}
|
||||
}
|
@ -0,0 +1,45 @@
|
||||
package com.djrapitops.pluginbridge.plan.griefprevention;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
import java.util.stream.Collectors;
|
||||
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;
|
||||
|
||||
/**
|
||||
* 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", new AnalysisType[]{AnalysisType.INT_TOTAL});
|
||||
this.dataStore = dataStore;
|
||||
super.setAnalysisOnly(false);
|
||||
super.setIcon("flag-o");
|
||||
super.setPrefix("Claims: ");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getHtmlReplaceValue(String modifierPrefix, UUID uuid) {
|
||||
List<Claim> claims = dataStore.getClaims().stream().filter(claim -> claim.ownerID.equals(uuid)).collect(Collectors.toList());
|
||||
return parseContainer(modifierPrefix, claims.size()+"");
|
||||
}
|
||||
|
||||
@Override
|
||||
public Serializable getValue(UUID uuid) {
|
||||
return dataStore.getClaims().stream().filter(claim -> claim.ownerID.equals(uuid)).collect(Collectors.toList()).size();
|
||||
}
|
||||
}
|
@ -0,0 +1,39 @@
|
||||
package com.djrapitops.pluginbridge.plan.griefprevention;
|
||||
|
||||
import com.djrapitops.pluginbridge.plan.Hook;
|
||||
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;
|
||||
|
||||
/**
|
||||
* A Class responsible for hooking to GriefPrevention and registering data
|
||||
* sources.
|
||||
*
|
||||
* @author Rsl1122
|
||||
* @since 3.5.0
|
||||
*/
|
||||
public class GriefPreventionHook 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 GriefPreventionHook(HookHandler hookH) throws NoClassDefFoundError {
|
||||
super("me.ryanhamshire.GriefPrevention");
|
||||
if (enabled) {
|
||||
DataStore dataStore = getPlugin(GriefPrevention.class).dataStore;
|
||||
hookH.addPluginDataSource(new GriefPreventionClaims(dataStore));
|
||||
hookH.addPluginDataSource(new GriefPreventionClaimArea(dataStore));
|
||||
hookH.addPluginDataSource(new GriefPreventionClaimBlocksAvailable(dataStore));
|
||||
hookH.addPluginDataSource(new GriefPreventionSoftMuted(dataStore));
|
||||
hookH.addPluginDataSource(new GriefPreventionClaimTable(dataStore));
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,41 @@
|
||||
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", "softmuted", new AnalysisType[]{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