mirror of
https://github.com/plan-player-analytics/Plan.git
synced 2025-03-02 11:11:21 +01:00
PluginBridge: Removed PluginData that has Extensions
This commit is contained in:
parent
9ea39af196
commit
bc6f856b4e
@ -4,7 +4,7 @@
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>com.djrapitops</groupId>
|
||||
<artifactId>PlanPluginBridge</artifactId>
|
||||
<version>4.7.0</version>
|
||||
<version>4.8.2-R0.1</version>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<name>${project.groupId}:${project.artifactId}</name>
|
||||
@ -57,18 +57,10 @@
|
||||
<id>sponge-repo</id>
|
||||
<url>https://repo.spongepowered.org/maven</url>
|
||||
</repository>
|
||||
<repository>
|
||||
<id>vault-repo</id> <!-- Essentials build repository since Vault repo goes down often. -->
|
||||
<url>https://ci.ender.zone/plugin/repository/everything/</url>
|
||||
</repository>
|
||||
<repository>
|
||||
<id>jitpack.io (GriefPrevention)</id>
|
||||
<url>https://jitpack.io</url>
|
||||
</repository>
|
||||
<repository>
|
||||
<id>redprotect-repo</id>
|
||||
<url>https://raw.github.com/FabioZumbi12/RedProtect/mvn-repo/</url>
|
||||
</repository>
|
||||
<repository>
|
||||
<id>viaversion-repo</id>
|
||||
<url>https://repo.viaversion.com</url>
|
||||
@ -77,18 +69,6 @@
|
||||
<id>placeholderapi</id>
|
||||
<url>http://repo.extendedclip.com/content/repositories/placeholderapi/</url>
|
||||
</repository>
|
||||
<repository>
|
||||
<id>advanced-achievements-repo</id>
|
||||
<url>https://raw.github.com/PyvesB/AdvancedAchievements/mvn-repo/</url>
|
||||
</repository>
|
||||
<repository>
|
||||
<id>nucleus-repo</id>
|
||||
<url>http://repo.drnaylor.co.uk/artifactory/list/minecraft</url>
|
||||
</repository>
|
||||
<repository>
|
||||
<id>discordsrv-repo</id>
|
||||
<url>https://nexus.scarsz.me/content/groups/public/</url>
|
||||
</repository>
|
||||
</repositories>
|
||||
|
||||
<dependencies>
|
||||
@ -141,60 +121,24 @@
|
||||
|
||||
<!-- Plugins from repositories -->
|
||||
|
||||
<dependency>
|
||||
<groupId>com.hm.achievement</groupId>
|
||||
<artifactId>advanced-achievements-api</artifactId>
|
||||
<version>1.0.0</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.github.TechFortress</groupId>
|
||||
<artifactId>GriefPrevention</artifactId>
|
||||
<version>16.8</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>me.clip</groupId>
|
||||
<artifactId>placeholderapi</artifactId>
|
||||
<version>2.9.2</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>br.net.fabiozumbi12.RedProtect</groupId>
|
||||
<artifactId>RedProtect-Spigot</artifactId>
|
||||
<version>7.5.3</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>net.milkbowl.vault</groupId>
|
||||
<artifactId>VaultAPI</artifactId>
|
||||
<version>1.7</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>us.myles</groupId>
|
||||
<artifactId>viaversion</artifactId>
|
||||
<version>1.5.0</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>io.github.nucleuspowered</groupId>
|
||||
<artifactId>nucleus-api</artifactId>
|
||||
<version>1.9.3-S7.1</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency> <!-- Maven Central -->
|
||||
<groupId>me.lucko.luckperms</groupId>
|
||||
<artifactId>luckperms-api</artifactId>
|
||||
<version>4.4</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.discordsrv</groupId>
|
||||
<artifactId>discordsrv</artifactId>
|
||||
<version>1.16.6</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
<!-- Plugins requiring local install -->
|
||||
|
||||
@ -204,30 +148,6 @@
|
||||
<version>3.5.0</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>me.leoko</groupId>
|
||||
<artifactId>advancedban</artifactId>
|
||||
<version>2.1.5</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.wasteofplastic.askyblock</groupId>
|
||||
<artifactId>ASkyBlock</artifactId>
|
||||
<version>3.0.9.4</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>me.confuser</groupId>
|
||||
<artifactId>banmanager</artifactId>
|
||||
<version>5.15.0</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>net.ess3</groupId>
|
||||
<artifactId>EssentialsX</artifactId>
|
||||
<version>2.15.0.1</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.massivecraft</groupId>
|
||||
<artifactId>factions</artifactId>
|
||||
@ -240,12 +160,6 @@
|
||||
<version>2.14.0</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>net.kaikk.mc</groupId>
|
||||
<artifactId>GriefPreventionPlus</artifactId>
|
||||
<version>13.3</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.gamingmesh</groupId>
|
||||
<artifactId>jobs</artifactId>
|
||||
@ -264,12 +178,6 @@
|
||||
<version>0.3</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.gmail.nossr50</groupId>
|
||||
<artifactId>mcMMO</artifactId>
|
||||
<version>1.6.0</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.github.ProtocolSupport</groupId>
|
||||
<artifactId>ProtocolSupport</artifactId>
|
||||
|
@ -19,26 +19,15 @@ package com.djrapitops.pluginbridge.plan;
|
||||
import com.djrapitops.plan.system.settings.config.PlanConfig;
|
||||
import com.djrapitops.plugin.logging.error.ErrorHandler;
|
||||
import com.djrapitops.pluginbridge.plan.aac.AdvancedAntiCheatHook;
|
||||
import com.djrapitops.pluginbridge.plan.advancedachievements.AdvancedAchievementsHook;
|
||||
import com.djrapitops.pluginbridge.plan.advancedban.AdvancedBanHook;
|
||||
import com.djrapitops.pluginbridge.plan.askyblock.ASkyBlockHook;
|
||||
import com.djrapitops.pluginbridge.plan.banmanager.BanManagerHook;
|
||||
import com.djrapitops.pluginbridge.plan.buycraft.BuyCraftHook;
|
||||
import com.djrapitops.pluginbridge.plan.discordsrv.DiscordSRVHook;
|
||||
import com.djrapitops.pluginbridge.plan.essentials.EssentialsHook;
|
||||
import com.djrapitops.pluginbridge.plan.factions.FactionsHook;
|
||||
import com.djrapitops.pluginbridge.plan.griefprevention.GriefPreventionHook;
|
||||
import com.djrapitops.pluginbridge.plan.griefprevention.plus.GriefPreventionPlusHook;
|
||||
import com.djrapitops.pluginbridge.plan.jobs.JobsHook;
|
||||
import com.djrapitops.pluginbridge.plan.kingdoms.KingdomsHook;
|
||||
import com.djrapitops.pluginbridge.plan.litebans.LiteBansBukkitHook;
|
||||
import com.djrapitops.pluginbridge.plan.luckperms.LuckPermsHook;
|
||||
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;
|
||||
import com.djrapitops.pluginbridge.plan.viaversion.ViaVersionBukkitHook;
|
||||
|
||||
import javax.inject.Inject;
|
||||
@ -53,27 +42,15 @@ import javax.inject.Singleton;
|
||||
public class BukkitBridge extends AbstractBridge {
|
||||
|
||||
private final AdvancedAntiCheatHook advancedAntiCheatHook;
|
||||
private final AdvancedAchievementsHook advancedAchievementsHook;
|
||||
private final AdvancedBanHook advancedBanHook;
|
||||
private final ASkyBlockHook aSkyBlockHook;
|
||||
private final BanManagerHook banManagerHook;
|
||||
private final BuyCraftHook buyCraftHook;
|
||||
private final DiscordSRVHook discordSRVHook;
|
||||
private final EssentialsHook essentialsHook;
|
||||
private final FactionsHook factionsHook;
|
||||
private final GriefPreventionHook griefPreventionHook;
|
||||
private final GriefPreventionPlusHook griefPreventionPlusHook;
|
||||
private final JobsHook jobsHook;
|
||||
private final KingdomsHook kingdomsHook;
|
||||
private final LiteBansBukkitHook liteBansHook;
|
||||
private final LuckPermsHook luckPermsHook;
|
||||
private final McmmoHook mcmmoHook;
|
||||
// private final PlaceholderAPIHook placeholderAPIHook;
|
||||
private final ProtocolSupportHook protocolSupportHook;
|
||||
private final RedProtectHook redProtectHook;
|
||||
private final SuperbVoteHook superbVoteHook;
|
||||
private final TownyHook townyHook;
|
||||
private final VaultHook vaultHook;
|
||||
private final ViaVersionBukkitHook viaVersionHook;
|
||||
|
||||
@Inject
|
||||
@ -82,52 +59,28 @@ private final ProtocolSupportHook protocolSupportHook;
|
||||
ErrorHandler errorHandler,
|
||||
|
||||
AdvancedAntiCheatHook advancedAntiCheatHook,
|
||||
AdvancedAchievementsHook advancedAchievementsHook,
|
||||
AdvancedBanHook advancedBanHook,
|
||||
ASkyBlockHook aSkyBlockHook,
|
||||
BanManagerHook banManagerHook,
|
||||
BuyCraftHook buyCraftHook,
|
||||
DiscordSRVHook discordSRVHook,
|
||||
EssentialsHook essentialsHook,
|
||||
FactionsHook factionsHook,
|
||||
GriefPreventionHook griefPreventionHook,
|
||||
GriefPreventionPlusHook griefPreventionPlusHook,
|
||||
JobsHook jobsHook,
|
||||
KingdomsHook kingdomsHook,
|
||||
LiteBansBukkitHook liteBansHook,
|
||||
LuckPermsHook luckPermsHook,
|
||||
McmmoHook mcmmoHook,
|
||||
// PlaceholderAPIHook placeholderAPIHook,
|
||||
ProtocolSupportHook protocolSupportHook,
|
||||
RedProtectHook redProtectHook,
|
||||
SuperbVoteHook superbVoteHook,
|
||||
TownyHook townyHook,
|
||||
VaultHook vaultHook,
|
||||
ViaVersionBukkitHook viaVersionHook
|
||||
) {
|
||||
super(config, errorHandler);
|
||||
this.advancedAntiCheatHook = advancedAntiCheatHook;
|
||||
this.advancedAchievementsHook = advancedAchievementsHook;
|
||||
this.advancedBanHook = advancedBanHook;
|
||||
this.aSkyBlockHook = aSkyBlockHook;
|
||||
this.banManagerHook = banManagerHook;
|
||||
this.buyCraftHook = buyCraftHook;
|
||||
this.discordSRVHook = discordSRVHook;
|
||||
this.essentialsHook = essentialsHook;
|
||||
this.factionsHook = factionsHook;
|
||||
this.griefPreventionHook = griefPreventionHook;
|
||||
this.griefPreventionPlusHook = griefPreventionPlusHook;
|
||||
this.jobsHook = jobsHook;
|
||||
this.kingdomsHook = kingdomsHook;
|
||||
this.liteBansHook = liteBansHook;
|
||||
this.luckPermsHook = luckPermsHook;
|
||||
this.mcmmoHook = mcmmoHook;
|
||||
// this.placeholderAPIHook = placeholderAPIHook;
|
||||
this.protocolSupportHook = protocolSupportHook;
|
||||
this.redProtectHook = redProtectHook;
|
||||
this.superbVoteHook = superbVoteHook;
|
||||
this.townyHook = townyHook;
|
||||
this.vaultHook = vaultHook;
|
||||
this.viaVersionHook = viaVersionHook;
|
||||
}
|
||||
|
||||
@ -135,28 +88,15 @@ private final ProtocolSupportHook protocolSupportHook;
|
||||
Hook[] getHooks() {
|
||||
return new Hook[]{
|
||||
advancedAntiCheatHook,
|
||||
advancedAchievementsHook,
|
||||
advancedBanHook,
|
||||
aSkyBlockHook,
|
||||
banManagerHook,
|
||||
buyCraftHook,
|
||||
discordSRVHook,
|
||||
essentialsHook,
|
||||
factionsHook,
|
||||
griefPreventionHook,
|
||||
griefPreventionPlusHook,
|
||||
jobsHook,
|
||||
kingdomsHook,
|
||||
liteBansHook,
|
||||
luckPermsHook,
|
||||
mcmmoHook,
|
||||
// placeholderAPIHook,
|
||||
protocolSupportHook,
|
||||
// new ReactHook(),
|
||||
redProtectHook,
|
||||
superbVoteHook,
|
||||
townyHook,
|
||||
vaultHook,
|
||||
viaVersionHook
|
||||
};
|
||||
}
|
||||
|
@ -18,7 +18,6 @@ package com.djrapitops.pluginbridge.plan;
|
||||
|
||||
import com.djrapitops.plan.system.settings.config.PlanConfig;
|
||||
import com.djrapitops.plugin.logging.error.ErrorHandler;
|
||||
import com.djrapitops.pluginbridge.plan.advancedban.AdvancedBanHook;
|
||||
import com.djrapitops.pluginbridge.plan.buycraft.BuyCraftHook;
|
||||
import com.djrapitops.pluginbridge.plan.litebans.LiteBansBungeeHook;
|
||||
import com.djrapitops.pluginbridge.plan.luckperms.LuckPermsHook;
|
||||
@ -35,7 +34,6 @@ import javax.inject.Singleton;
|
||||
@Singleton
|
||||
public class BungeeBridge extends AbstractBridge {
|
||||
|
||||
private final AdvancedBanHook advancedBanHook;
|
||||
private final BuyCraftHook buyCraftHook;
|
||||
private final LiteBansBungeeHook liteBansHook;
|
||||
private final LuckPermsHook luckPermsHook;
|
||||
@ -46,14 +44,12 @@ public class BungeeBridge extends AbstractBridge {
|
||||
PlanConfig config,
|
||||
ErrorHandler errorHandler,
|
||||
|
||||
AdvancedBanHook advancedBanHook,
|
||||
BuyCraftHook buyCraftHook,
|
||||
LiteBansBungeeHook liteBansHook,
|
||||
LuckPermsHook luckPermsHook,
|
||||
ViaVersionBungeeHook viaVersionHook
|
||||
) {
|
||||
super(config, errorHandler);
|
||||
this.advancedBanHook = advancedBanHook;
|
||||
this.buyCraftHook = buyCraftHook;
|
||||
this.liteBansHook = liteBansHook;
|
||||
this.luckPermsHook = luckPermsHook;
|
||||
@ -63,7 +59,6 @@ public class BungeeBridge extends AbstractBridge {
|
||||
@Override
|
||||
Hook[] getHooks() {
|
||||
return new Hook[]{
|
||||
advancedBanHook,
|
||||
buyCraftHook,
|
||||
liteBansHook,
|
||||
luckPermsHook,
|
||||
|
@ -20,8 +20,6 @@ import com.djrapitops.plan.system.settings.config.PlanConfig;
|
||||
import com.djrapitops.plugin.logging.error.ErrorHandler;
|
||||
import com.djrapitops.pluginbridge.plan.buycraft.BuyCraftHook;
|
||||
import com.djrapitops.pluginbridge.plan.luckperms.LuckPermsHook;
|
||||
import com.djrapitops.pluginbridge.plan.nucleus.NucleusHook;
|
||||
import com.djrapitops.pluginbridge.plan.sponge.SpongeEconomyHook;
|
||||
|
||||
import javax.inject.Inject;
|
||||
import javax.inject.Singleton;
|
||||
@ -36,8 +34,6 @@ public class SpongeBridge extends AbstractBridge {
|
||||
|
||||
private final BuyCraftHook buyCraftHook;
|
||||
private final LuckPermsHook luckPermsHook;
|
||||
private final NucleusHook nucleusHook;
|
||||
private final SpongeEconomyHook spongeEconomyHook;
|
||||
|
||||
@Inject
|
||||
public SpongeBridge(
|
||||
@ -45,24 +41,18 @@ public class SpongeBridge extends AbstractBridge {
|
||||
ErrorHandler errorHandler,
|
||||
|
||||
BuyCraftHook buyCraftHook,
|
||||
LuckPermsHook luckPermsHook,
|
||||
NucleusHook nucleusHook,
|
||||
SpongeEconomyHook spongeEconomyHook
|
||||
LuckPermsHook luckPermsHook
|
||||
) {
|
||||
super(config, errorHandler);
|
||||
this.buyCraftHook = buyCraftHook;
|
||||
this.luckPermsHook = luckPermsHook;
|
||||
this.nucleusHook = nucleusHook;
|
||||
this.spongeEconomyHook = spongeEconomyHook;
|
||||
}
|
||||
|
||||
@Override
|
||||
Hook[] getHooks() {
|
||||
return new Hook[]{
|
||||
buyCraftHook,
|
||||
luckPermsHook,
|
||||
nucleusHook,
|
||||
spongeEconomyHook
|
||||
luckPermsHook
|
||||
};
|
||||
}
|
||||
}
|
@ -1,89 +0,0 @@
|
||||
/*
|
||||
* This file is part of Player Analytics (Plan).
|
||||
*
|
||||
* Plan is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License v3 as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Plan is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Plan. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.djrapitops.pluginbridge.plan.advancedachievements;
|
||||
|
||||
import com.djrapitops.plan.data.element.AnalysisContainer;
|
||||
import com.djrapitops.plan.data.element.InspectContainer;
|
||||
import com.djrapitops.plan.data.plugin.ContainerSize;
|
||||
import com.djrapitops.plan.data.plugin.PluginData;
|
||||
import com.djrapitops.plan.utilities.formatting.Formatter;
|
||||
import com.djrapitops.plan.utilities.html.icon.Color;
|
||||
import com.djrapitops.plan.utilities.html.icon.Family;
|
||||
import com.djrapitops.plan.utilities.html.icon.Icon;
|
||||
import com.hm.achievement.api.AdvancedAchievementsAPI;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
/**
|
||||
* PluginData class for AdvancedAchievements.
|
||||
*
|
||||
* @author Rsl1122
|
||||
*/
|
||||
class AdvancedAchievementsData extends PluginData {
|
||||
|
||||
private final AdvancedAchievementsAPI aaAPI;
|
||||
private final Formatter<Double> decimalFormatter;
|
||||
|
||||
private long lastRefresh;
|
||||
private Map<UUID, Integer> totalAchievements;
|
||||
|
||||
AdvancedAchievementsData(
|
||||
AdvancedAchievementsAPI aaAPI,
|
||||
Formatter<Double> decimalFormatter
|
||||
) {
|
||||
super(ContainerSize.THIRD, "AdvancedAchievements");
|
||||
this.decimalFormatter = decimalFormatter;
|
||||
setPluginIcon(Icon.called("star").of(Color.GREEN).build());
|
||||
this.aaAPI = aaAPI;
|
||||
refreshTotalAchievements();
|
||||
}
|
||||
|
||||
@Override
|
||||
public InspectContainer getPlayerData(UUID uuid, InspectContainer inspectContainer) {
|
||||
String text = getWithIcon("Achievements", Icon.called("check-circle").of(Family.REGULAR).of(Color.GREEN));
|
||||
inspectContainer.addValue(text, aaAPI.getPlayerTotalAchievements(uuid));
|
||||
|
||||
return inspectContainer;
|
||||
}
|
||||
|
||||
@Override
|
||||
public AnalysisContainer getServerData(Collection<UUID> collection, AnalysisContainer analysisContainer) {
|
||||
if (System.currentTimeMillis() - lastRefresh > TimeUnit.MINUTES.toMillis(5L)) {
|
||||
refreshTotalAchievements();
|
||||
}
|
||||
long total = getTotal(totalAchievements);
|
||||
int size = totalAchievements.size();
|
||||
String average = size != 0 ? decimalFormatter.apply(total * 1.0 / size) : "-";
|
||||
|
||||
analysisContainer.addValue(getWithIcon("Total Achievements", Icon.called("check-circle").of(Family.REGULAR).of(Color.GREEN)), total);
|
||||
analysisContainer.addValue(getWithIcon("Average Achievements", Icon.called("check-circle").of(Family.REGULAR).of(Color.GREEN)), average);
|
||||
analysisContainer.addPlayerTableValues(getWithIcon("Achievements", Icon.called("star")), totalAchievements);
|
||||
return analysisContainer;
|
||||
}
|
||||
|
||||
private long getTotal(Map<UUID, Integer> totalAchievements) {
|
||||
return totalAchievements.values().stream().mapToInt(i -> i).sum();
|
||||
}
|
||||
|
||||
private void refreshTotalAchievements() {
|
||||
totalAchievements = aaAPI.getPlayersTotalAchievements();
|
||||
lastRefresh = System.currentTimeMillis();
|
||||
}
|
||||
}
|
@ -1,61 +0,0 @@
|
||||
/*
|
||||
* This file is part of Player Analytics (Plan).
|
||||
*
|
||||
* Plan is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License v3 as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Plan is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Plan. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.djrapitops.pluginbridge.plan.advancedachievements;
|
||||
|
||||
import com.djrapitops.plan.data.plugin.HookHandler;
|
||||
import com.djrapitops.plan.utilities.formatting.Formatter;
|
||||
import com.djrapitops.plan.utilities.formatting.Formatters;
|
||||
import com.djrapitops.pluginbridge.plan.Hook;
|
||||
import com.hm.achievement.api.AdvancedAchievementsAPI;
|
||||
import com.hm.achievement.api.AdvancedAchievementsAPIFetcher;
|
||||
|
||||
import javax.inject.Inject;
|
||||
import javax.inject.Singleton;
|
||||
import java.util.Optional;
|
||||
|
||||
/**
|
||||
* A Class responsible for hooking to AdvancedAchievements and registering 2
|
||||
* data sources.
|
||||
*
|
||||
* @author Rsl1122
|
||||
|
||||
*/
|
||||
@Singleton
|
||||
public class AdvancedAchievementsHook extends Hook {
|
||||
|
||||
private final Formatter<Double> decimalFormatter;
|
||||
|
||||
@Inject
|
||||
public AdvancedAchievementsHook(
|
||||
Formatters formatters
|
||||
) {
|
||||
super("com.hm.achievement.AdvancedAchievements");
|
||||
decimalFormatter = formatters.decimals();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void hook(HookHandler handler) throws NoClassDefFoundError {
|
||||
if (enabled) {
|
||||
Optional<AdvancedAchievementsAPI> aaAPI = AdvancedAchievementsAPIFetcher.fetchInstance();
|
||||
if (aaAPI.isPresent()) {
|
||||
handler.addPluginDataSource(new AdvancedAchievementsData(aaAPI.get(), decimalFormatter));
|
||||
} else {
|
||||
enabled = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -1,113 +0,0 @@
|
||||
/*
|
||||
* This file is part of Player Analytics (Plan).
|
||||
*
|
||||
* Plan is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License v3 as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Plan is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Plan. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.djrapitops.pluginbridge.plan.advancedban;
|
||||
|
||||
import com.djrapitops.plan.api.PlanAPI;
|
||||
import com.djrapitops.plan.data.element.AnalysisContainer;
|
||||
import com.djrapitops.plan.data.element.InspectContainer;
|
||||
import com.djrapitops.plan.data.plugin.ContainerSize;
|
||||
import com.djrapitops.plan.data.plugin.PluginData;
|
||||
import com.djrapitops.plan.utilities.formatting.Formatter;
|
||||
import com.djrapitops.plan.utilities.html.Html;
|
||||
import com.djrapitops.plan.utilities.html.HtmlUtils;
|
||||
import com.djrapitops.plan.utilities.html.icon.Color;
|
||||
import com.djrapitops.plan.utilities.html.icon.Family;
|
||||
import com.djrapitops.plan.utilities.html.icon.Icon;
|
||||
import com.djrapitops.plan.utilities.html.icon.Icons;
|
||||
import me.leoko.advancedban.manager.PunishmentManager;
|
||||
import me.leoko.advancedban.utils.Punishment;
|
||||
import me.leoko.advancedban.utils.PunishmentType;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* PluginData for AdvancedBan plugin.
|
||||
*
|
||||
* @author Vankka
|
||||
*/
|
||||
class AdvancedBanData extends PluginData {
|
||||
|
||||
private final Formatter<Long> timestampFormatter;
|
||||
|
||||
AdvancedBanData(
|
||||
Formatter<Long> timestampFormatter
|
||||
) {
|
||||
super(ContainerSize.THIRD, "AdvancedBan");
|
||||
this.timestampFormatter = timestampFormatter;
|
||||
setPluginIcon(Icons.BANNED);
|
||||
}
|
||||
|
||||
@Override
|
||||
public InspectContainer getPlayerData(UUID uuid, InspectContainer inspectContainer) {
|
||||
String abUuid = uuid.toString().replace("-", "");
|
||||
|
||||
if (uuid.version() == 3) { // Cracked / Offline UUID
|
||||
return inspectContainer;
|
||||
}
|
||||
|
||||
PunishmentManager punishmentManager = PunishmentManager.get();
|
||||
Punishment ban = punishmentManager.getBan(abUuid);
|
||||
Punishment mute = punishmentManager.getMute(abUuid);
|
||||
long warnings = punishmentManager.getWarns(abUuid).stream().filter(warning -> !warning.isExpired()).count();
|
||||
|
||||
inspectContainer.addValue(getWithIcon("Banned", Icons.BANNED), ban != null ? "Yes" : "No");
|
||||
if (ban != null) {
|
||||
addPunishment(inspectContainer, ban, "Permanent ban");
|
||||
}
|
||||
|
||||
inspectContainer.addValue(getWithIcon("Muted", Icon.called("bell-slash").of(Color.DEEP_ORANGE)), mute != null ? "Yes" : "No");
|
||||
if (mute != null) {
|
||||
addPunishment(inspectContainer, mute, "Permanent mute");
|
||||
}
|
||||
|
||||
inspectContainer.addValue(getWithIcon("Warnings", Icon.called("flag").of(Color.YELLOW)), warnings);
|
||||
|
||||
return inspectContainer;
|
||||
}
|
||||
|
||||
private void addPunishment(InspectContainer inspectContainer, Punishment punishment, String identifier) {
|
||||
String operator = punishment.getOperator();
|
||||
String link = Html.LINK.parse(PlanAPI.getInstance().getPlayerInspectPageLink(operator), operator);
|
||||
String reason = HtmlUtils.swapColorsToSpan(punishment.getReason());
|
||||
String start = timestampFormatter.apply(punishment.getStart());
|
||||
String end = timestampFormatter.apply(punishment.getEnd());
|
||||
|
||||
PunishmentType type = punishment.getType();
|
||||
// Permanent
|
||||
if (type == PunishmentType.BAN
|
||||
|| type == PunishmentType.IP_BAN
|
||||
|| type == PunishmentType.MUTE
|
||||
) {
|
||||
end = identifier;
|
||||
}
|
||||
|
||||
if (operator.equals("CONSOLE")) {
|
||||
link = "CONSOLE";
|
||||
}
|
||||
|
||||
inspectContainer.addValue(" " + getWithIcon("Operator", Icon.called("user").of(Color.RED)), link);
|
||||
inspectContainer.addValue(" " + getWithIcon("Date", Icon.called("calendar").of(Color.RED).of(Family.REGULAR)), start);
|
||||
inspectContainer.addValue(" " + getWithIcon("Ends", Icon.called("calendar-check").of(Color.RED).of(Family.REGULAR)), end);
|
||||
inspectContainer.addValue(" " + getWithIcon("Reason", Icon.called("comment").of(Color.RED).of(Family.REGULAR)), reason);
|
||||
}
|
||||
|
||||
@Override
|
||||
public AnalysisContainer getServerData(Collection<UUID> uuids, AnalysisContainer analysisContainer) {
|
||||
return analysisContainer;
|
||||
}
|
||||
}
|
@ -1,52 +0,0 @@
|
||||
/*
|
||||
* This file is part of Player Analytics (Plan).
|
||||
*
|
||||
* Plan is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License v3 as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Plan is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Plan. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.djrapitops.pluginbridge.plan.advancedban;
|
||||
|
||||
import com.djrapitops.plan.data.plugin.HookHandler;
|
||||
import com.djrapitops.plan.utilities.formatting.Formatter;
|
||||
import com.djrapitops.plan.utilities.formatting.Formatters;
|
||||
import com.djrapitops.pluginbridge.plan.Hook;
|
||||
|
||||
import javax.inject.Inject;
|
||||
import javax.inject.Singleton;
|
||||
|
||||
/**
|
||||
* Hook for AdvancedBan plugin.
|
||||
*
|
||||
* @author Vankka
|
||||
*/
|
||||
@Singleton
|
||||
public class AdvancedBanHook extends Hook {
|
||||
|
||||
private final Formatter<Long> timestampFormatter;
|
||||
|
||||
@Inject
|
||||
public AdvancedBanHook(
|
||||
Formatters formatters
|
||||
) {
|
||||
super("me.leoko.advancedban.Universal");
|
||||
|
||||
timestampFormatter = formatters.yearLong();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void hook(HookHandler handler) throws NoClassDefFoundError {
|
||||
if (enabled) {
|
||||
handler.addPluginDataSource(new AdvancedBanData(timestampFormatter));
|
||||
}
|
||||
}
|
||||
}
|
@ -1,111 +0,0 @@
|
||||
/*
|
||||
* This file is part of Player Analytics (Plan).
|
||||
*
|
||||
* Plan is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License v3 as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Plan is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Plan. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.djrapitops.pluginbridge.plan.askyblock;
|
||||
|
||||
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.formatting.Formatter;
|
||||
import com.djrapitops.plan.utilities.html.graphs.ProgressBar;
|
||||
import com.djrapitops.plan.utilities.html.icon.Color;
|
||||
import com.djrapitops.plan.utilities.html.icon.Family;
|
||||
import com.djrapitops.plan.utilities.html.icon.Icon;
|
||||
import com.djrapitops.plugin.utilities.Format;
|
||||
import com.wasteofplastic.askyblock.ASkyBlockAPI;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* PluginData for ASkyBlock plugin.
|
||||
*
|
||||
* @author Rsl1122
|
||||
*/
|
||||
class ASkyBlockData extends PluginData {
|
||||
|
||||
private final ASkyBlockAPI api;
|
||||
|
||||
private final Formatter<Double> percentageFormatter;
|
||||
|
||||
ASkyBlockData(ASkyBlockAPI api, Formatter<Double> percentageFormatter) {
|
||||
super(ContainerSize.THIRD, "ASkyBlock");
|
||||
this.percentageFormatter = percentageFormatter;
|
||||
setPluginIcon(Icon.called("street-view").of(Color.LIGHT_BLUE).build());
|
||||
this.api = api;
|
||||
}
|
||||
|
||||
@Override
|
||||
public InspectContainer getPlayerData(UUID uuid, InspectContainer inspectContainer) {
|
||||
if (api.hasIsland(uuid)) {
|
||||
String islandName = api.getIslandName(uuid);
|
||||
long level = api.getLongIslandLevel(uuid);
|
||||
int resetsLeft = api.getResetsLeft(uuid);
|
||||
|
||||
inspectContainer.addValue(getWithIcon("Island Name", Icon.called("street-view").of(Color.GREEN)), islandName);
|
||||
inspectContainer.addValue(getWithIcon("Island Level", Icon.called("street-view").of(Color.AMBER)), level);
|
||||
inspectContainer.addValue(getWithIcon("Island Resets Left", Icon.called("refresh").of(Color.GREEN)), resetsLeft);
|
||||
} else {
|
||||
inspectContainer.addValue(getWithIcon("Island Name", Icon.called("street-view").of(Color.GREEN)), "No Island");
|
||||
}
|
||||
|
||||
Map<String, Integer> challengeCompletion = api.getChallengeTimes(uuid);
|
||||
int obtained = (int) challengeCompletion.values().stream().filter(value -> value != 0).count();
|
||||
int max = challengeCompletion.size();
|
||||
|
||||
inspectContainer.addValue(getWithIcon("Challenge Progress", Icon.called("bookmark").of(Color.LIGHT_BLUE)), obtained + " / " + max);
|
||||
ProgressBar challengeProgress = new ProgressBar(obtained, max, "light-blue", percentageFormatter);
|
||||
inspectContainer.addHtml("challenge-progress", challengeProgress.toHtml());
|
||||
|
||||
addTable(inspectContainer, challengeCompletion);
|
||||
|
||||
return inspectContainer;
|
||||
}
|
||||
|
||||
private void addTable(InspectContainer inspectContainer, Map<String, Integer> challengeCompletion) {
|
||||
TableContainer challenges = new TableContainer(
|
||||
getWithIcon("Challenge", Icon.called("bookmark")),
|
||||
getWithIcon("Times completed", Icon.called("check"))
|
||||
);
|
||||
challenges.setColor("light-blue");
|
||||
challengeCompletion.entrySet().stream()
|
||||
.sorted((one, two) -> Integer.compare(two.getValue(), one.getValue()))
|
||||
.forEach(entry -> {
|
||||
String challenge = new Format(entry.getKey()).capitalize().toString();
|
||||
Integer completionTimes = entry.getValue();
|
||||
boolean complete = completionTimes > 0;
|
||||
challenges.addRow(
|
||||
"<span" + (complete ? " class=\"col-green\"" : "") + ">" + challenge + "</span>",
|
||||
completionTimes
|
||||
);
|
||||
});
|
||||
inspectContainer.addTable("challenge-table", challenges);
|
||||
}
|
||||
|
||||
@Override
|
||||
public AnalysisContainer getServerData(Collection<UUID> uuids, AnalysisContainer analysisContainer) {
|
||||
int islandCount = api.getIslandCount();
|
||||
String islandWorldName = api.getIslandWorld().getName();
|
||||
|
||||
analysisContainer.addValue(getWithIcon("Island World", Icon.called("map").of(Family.REGULAR).of(Color.GREEN)), islandWorldName);
|
||||
analysisContainer.addValue(getWithIcon("Island Count", Icon.called("street-view").of(Color.GREEN)), islandCount);
|
||||
|
||||
return analysisContainer;
|
||||
}
|
||||
}
|
@ -1,55 +0,0 @@
|
||||
/*
|
||||
* This file is part of Player Analytics (Plan).
|
||||
*
|
||||
* Plan is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License v3 as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Plan is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Plan. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.djrapitops.pluginbridge.plan.askyblock;
|
||||
|
||||
import com.djrapitops.plan.data.plugin.HookHandler;
|
||||
import com.djrapitops.plan.utilities.formatting.Formatter;
|
||||
import com.djrapitops.plan.utilities.formatting.Formatters;
|
||||
import com.djrapitops.pluginbridge.plan.Hook;
|
||||
import com.wasteofplastic.askyblock.ASkyBlockAPI;
|
||||
|
||||
import javax.inject.Inject;
|
||||
import javax.inject.Singleton;
|
||||
|
||||
/**
|
||||
* A Class responsible for hooking to ASkyBlock and registering data sources.
|
||||
*
|
||||
* @author Rsl1122
|
||||
|
||||
*/
|
||||
@Singleton
|
||||
public class ASkyBlockHook extends Hook {
|
||||
|
||||
private final Formatter<Double> percentageFormatter;
|
||||
|
||||
@Inject
|
||||
public ASkyBlockHook(
|
||||
Formatters formatters
|
||||
) throws NoClassDefFoundError {
|
||||
super("com.wasteofplastic.askyblock.ASkyBlock");
|
||||
|
||||
percentageFormatter = formatters.percentage();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void hook(HookHandler handler) throws NoClassDefFoundError {
|
||||
if (enabled) {
|
||||
ASkyBlockAPI api = ASkyBlockAPI.getInstance();
|
||||
handler.addPluginDataSource(new ASkyBlockData(api, percentageFormatter));
|
||||
}
|
||||
}
|
||||
}
|
@ -1,114 +0,0 @@
|
||||
/*
|
||||
* This file is part of Player Analytics (Plan).
|
||||
*
|
||||
* Plan is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License v3 as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Plan is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Plan. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.djrapitops.pluginbridge.plan.banmanager;
|
||||
|
||||
import com.djrapitops.plan.api.PlanAPI;
|
||||
import com.djrapitops.plan.data.element.AnalysisContainer;
|
||||
import com.djrapitops.plan.data.element.InspectContainer;
|
||||
import com.djrapitops.plan.data.plugin.BanData;
|
||||
import com.djrapitops.plan.data.plugin.ContainerSize;
|
||||
import com.djrapitops.plan.data.plugin.PluginData;
|
||||
import com.djrapitops.plan.utilities.formatting.Formatter;
|
||||
import com.djrapitops.plan.utilities.html.Html;
|
||||
import com.djrapitops.plan.utilities.html.icon.Color;
|
||||
import com.djrapitops.plan.utilities.html.icon.Family;
|
||||
import com.djrapitops.plan.utilities.html.icon.Icon;
|
||||
import com.djrapitops.plan.utilities.html.icon.Icons;
|
||||
import me.confuser.banmanager.BmAPI;
|
||||
import me.confuser.banmanager.data.PlayerBanData;
|
||||
import me.confuser.banmanager.data.PlayerMuteData;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.UUID;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* PluginData for BanManager plugin.
|
||||
*
|
||||
* @author Rsl1122
|
||||
*/
|
||||
class BanManagerData extends PluginData implements BanData {
|
||||
|
||||
private final Formatter<Long> timestampFormatter;
|
||||
|
||||
BanManagerData(Formatter<Long> timestampFormatter) {
|
||||
super(ContainerSize.THIRD, "BanManager");
|
||||
this.timestampFormatter = timestampFormatter;
|
||||
setPluginIcon(Icons.BANNED);
|
||||
}
|
||||
|
||||
@Override
|
||||
public InspectContainer getPlayerData(UUID uuid, InspectContainer inspectContainer) {
|
||||
boolean banned = BmAPI.isBanned(uuid);
|
||||
boolean muted = BmAPI.isMuted(uuid);
|
||||
|
||||
inspectContainer.addValue(getWithIcon("Banned", Icons.BANNED), banned ? "Yes" : "No");
|
||||
if (banned) {
|
||||
addBanInformation(uuid, inspectContainer);
|
||||
}
|
||||
|
||||
inspectContainer.addValue(getWithIcon("Muted", Icon.called("bell-slash").of(Color.DEEP_ORANGE)), muted ? "Yes" : "No");
|
||||
if (muted) {
|
||||
addMuteInformation(uuid, inspectContainer);
|
||||
}
|
||||
|
||||
return inspectContainer;
|
||||
}
|
||||
|
||||
private void addBanInformation(UUID uuid, InspectContainer inspectContainer) {
|
||||
PlayerBanData currentBan = BmAPI.getCurrentBan(uuid);
|
||||
String bannedBy = currentBan.getActor().getName();
|
||||
String link = Html.LINK.parse(PlanAPI.getInstance().getPlayerInspectPageLink(bannedBy), bannedBy);
|
||||
long date = currentBan.getCreated();
|
||||
long ends = currentBan.getExpires();
|
||||
String reason = currentBan.getReason();
|
||||
|
||||
inspectContainer.addValue(" " + getWithIcon("Banned by", Icon.called("user").of(Color.RED)), link);
|
||||
inspectContainer.addValue(" " + getWithIcon("Date", Icon.called("calendar").of(Color.RED).of(Family.REGULAR)), timestampFormatter.apply(date));
|
||||
inspectContainer.addValue(" " + getWithIcon("Ends", Icon.called("calendar-check").of(Color.RED).of(Family.REGULAR)), timestampFormatter.apply(ends));
|
||||
inspectContainer.addValue(" " + getWithIcon("Reason", Icon.called("comment").of(Color.RED).of(Family.REGULAR)), reason);
|
||||
}
|
||||
|
||||
private void addMuteInformation(UUID uuid, InspectContainer inspectContainer) {
|
||||
PlayerMuteData currentMute = BmAPI.getCurrentMute(uuid);
|
||||
String mutedBy = currentMute.getActor().getName();
|
||||
String link = Html.LINK.parse(PlanAPI.getInstance().getPlayerInspectPageLink(mutedBy), mutedBy);
|
||||
long date = currentMute.getCreated();
|
||||
long ends = currentMute.getExpires();
|
||||
String reason = currentMute.getReason();
|
||||
|
||||
inspectContainer.addValue(" " + getWithIcon("Muted by", Icon.called("user").of(Color.DEEP_ORANGE)), link);
|
||||
inspectContainer.addValue(" " + getWithIcon("Date", Icon.called("calendar").of(Color.DEEP_ORANGE).of(Family.REGULAR)), timestampFormatter.apply(date));
|
||||
inspectContainer.addValue(" " + getWithIcon("Ends", Icon.called("calendar-check").of(Color.DEEP_ORANGE).of(Family.REGULAR)), timestampFormatter.apply(ends));
|
||||
inspectContainer.addValue(" " + getWithIcon("Reason", Icon.called("comment").of(Color.DEEP_ORANGE).of(Family.REGULAR)), reason);
|
||||
}
|
||||
|
||||
@Override
|
||||
public AnalysisContainer getServerData(Collection<UUID> collection, AnalysisContainer analysisContainer) {
|
||||
return analysisContainer;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isBanned(UUID uuid) {
|
||||
return BmAPI.isBanned(uuid);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<UUID> filterBanned(Collection<UUID> collection) {
|
||||
return collection.stream().filter(BmAPI::isBanned).collect(Collectors.toList());
|
||||
}
|
||||
}
|
@ -1,51 +0,0 @@
|
||||
/*
|
||||
* This file is part of Player Analytics (Plan).
|
||||
*
|
||||
* Plan is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License v3 as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Plan is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Plan. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.djrapitops.pluginbridge.plan.banmanager;
|
||||
|
||||
import com.djrapitops.plan.data.plugin.HookHandler;
|
||||
import com.djrapitops.plan.utilities.formatting.Formatter;
|
||||
import com.djrapitops.plan.utilities.formatting.Formatters;
|
||||
import com.djrapitops.pluginbridge.plan.Hook;
|
||||
|
||||
import javax.inject.Inject;
|
||||
import javax.inject.Singleton;
|
||||
|
||||
/**
|
||||
* Hook for BanManager plugin.
|
||||
*
|
||||
* @author Rsl1122
|
||||
*/
|
||||
@Singleton
|
||||
public class BanManagerHook extends Hook {
|
||||
|
||||
private final Formatter<Long> timestampFormatter;
|
||||
|
||||
@Inject
|
||||
public BanManagerHook(Formatters formatters) {
|
||||
super("me.confuser.banmanager.BanManager");
|
||||
timestampFormatter = formatters.yearLong();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void hook(HookHandler handler) throws NoClassDefFoundError {
|
||||
if (!enabled) {
|
||||
return;
|
||||
}
|
||||
|
||||
handler.addPluginDataSource(new BanManagerData(timestampFormatter));
|
||||
}
|
||||
}
|
@ -1,141 +0,0 @@
|
||||
/*
|
||||
* This file is part of Player Analytics (Plan).
|
||||
*
|
||||
* Plan is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License v3 as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Plan is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Plan. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.djrapitops.pluginbridge.plan.discordsrv;
|
||||
|
||||
import com.djrapitops.plan.data.element.AnalysisContainer;
|
||||
import com.djrapitops.plan.data.element.InspectContainer;
|
||||
import com.djrapitops.plan.data.plugin.ContainerSize;
|
||||
import com.djrapitops.plan.data.plugin.PluginData;
|
||||
import com.djrapitops.plan.utilities.formatting.Formatter;
|
||||
import com.djrapitops.plan.utilities.html.icon.Color;
|
||||
import com.djrapitops.plan.utilities.html.icon.Family;
|
||||
import com.djrapitops.plan.utilities.html.icon.Icon;
|
||||
import github.scarsz.discordsrv.DiscordSRV;
|
||||
import github.scarsz.discordsrv.dependencies.jda.core.entities.Member;
|
||||
import github.scarsz.discordsrv.dependencies.jda.core.entities.Role;
|
||||
import github.scarsz.discordsrv.dependencies.jda.core.entities.User;
|
||||
import github.scarsz.discordsrv.util.DiscordUtil;
|
||||
import org.apache.commons.text.TextStringBuilder;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* PluginData for DiscordSRV plugin.
|
||||
*
|
||||
* @author Vankka
|
||||
*/
|
||||
class DiscordSRVData extends PluginData {
|
||||
|
||||
private final Formatter<Long> timestampFormatter;
|
||||
|
||||
DiscordSRVData(Formatter<Long> timestampFormatter) {
|
||||
super(ContainerSize.THIRD, "DiscordSRV");
|
||||
this.timestampFormatter = timestampFormatter;
|
||||
setPluginIcon(Icon.called("discord").of(Family.BRAND).build());
|
||||
}
|
||||
|
||||
@Override
|
||||
public InspectContainer getPlayerData(UUID uuid, InspectContainer inspectContainer) {
|
||||
if (!DiscordSRV.isReady) {
|
||||
return inspectContainer;
|
||||
}
|
||||
|
||||
String userId = DiscordSRV.getPlugin().getAccountLinkManager().getDiscordId(uuid);
|
||||
User user = userId != null ? DiscordUtil.getUserById(userId) : null;
|
||||
|
||||
if (user == null) {
|
||||
return inspectContainer;
|
||||
}
|
||||
|
||||
inspectContainer.addValue(
|
||||
getWithIcon("Username", Icon.called("user").of(Family.SOLID).of(Color.CYAN)),
|
||||
"@" + user.getName() + "#" + user.getDiscriminator()
|
||||
);
|
||||
inspectContainer.addValue(
|
||||
getWithIcon("Account creation date", Icon.called("plus").of(Family.SOLID).of(Color.BLUE)),
|
||||
timestampFormatter.apply(user.getCreationTime().toEpochSecond() * 1000L)
|
||||
);
|
||||
|
||||
Member member = DiscordSRV.getPlugin().getMainGuild().getMember(user);
|
||||
|
||||
if (member != null) {
|
||||
addMemberData(member, inspectContainer);
|
||||
}
|
||||
|
||||
return inspectContainer;
|
||||
}
|
||||
|
||||
private void addMemberData(Member member, InspectContainer inspectContainer) {
|
||||
String nickname = member.getNickname();
|
||||
|
||||
inspectContainer.addValue(
|
||||
getWithIcon("Nickname", Icon.called("user-ninja").of(Family.SOLID).of(Color.ORANGE)),
|
||||
nickname != null ? nickname : "None"
|
||||
);
|
||||
inspectContainer.addValue(
|
||||
getWithIcon("Join Date", Icon.called("plus").of(Family.SOLID).of(Color.GREEN)),
|
||||
timestampFormatter.apply(member.getJoinDate().toEpochSecond() * 1000L)
|
||||
);
|
||||
|
||||
List<String> roles = member.getRoles().stream().map(Role::getName).collect(Collectors.toList()); // Ordered list of role names
|
||||
if (!roles.isEmpty()) {
|
||||
inspectContainer.addValue(
|
||||
getWithIcon("Roles", Icon.called("user-circle").of(Family.SOLID).of(Color.RED)),
|
||||
new TextStringBuilder().appendWithSeparators(roles, ", ").build()
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public AnalysisContainer getServerData(Collection<UUID> uuids, AnalysisContainer analysisContainer) {
|
||||
if (!DiscordSRV.isReady) {
|
||||
return analysisContainer;
|
||||
}
|
||||
|
||||
int accountsLinked = DiscordSRV.getPlugin().getAccountLinkManager().getLinkedAccounts().size();
|
||||
int guildUsers = DiscordSRV.getPlugin().getMainGuild().getMembers().size();
|
||||
|
||||
analysisContainer.addValue(
|
||||
getWithIcon("Accounts linked", Icon.called("link").of(Family.SOLID).of(Color.CYAN)),
|
||||
accountsLinked
|
||||
);
|
||||
analysisContainer.addValue(
|
||||
getWithIcon("Users in main guild", Icon.called("users").of(Family.SOLID).of(Color.GREEN)),
|
||||
guildUsers
|
||||
);
|
||||
analysisContainer.addValue(
|
||||
getWithIcon("Accounts linked / Total players", Icon.called("percentage").of(Family.SOLID).of(Color.TEAL)),
|
||||
calculatePercentage(accountsLinked, uuids.size()) + "%"
|
||||
);
|
||||
analysisContainer.addValue(
|
||||
getWithIcon("Accounts linked / Users in main guild", Icon.called("percentage").of(Family.SOLID).of(Color.LIGHT_GREEN)),
|
||||
calculatePercentage(accountsLinked, guildUsers) + "%"
|
||||
);
|
||||
|
||||
return analysisContainer;
|
||||
}
|
||||
|
||||
private double calculatePercentage(int input1, int input2) {
|
||||
if (input1 == 0 || input2 == 0)
|
||||
return 0D;
|
||||
|
||||
return Math.round((double) input1 / input2 * 10000D) / 100D; // 2 decimals
|
||||
}
|
||||
}
|
@ -1,52 +0,0 @@
|
||||
/*
|
||||
* This file is part of Player Analytics (Plan).
|
||||
*
|
||||
* Plan is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License v3 as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Plan is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Plan. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.djrapitops.pluginbridge.plan.discordsrv;
|
||||
|
||||
import com.djrapitops.plan.data.plugin.HookHandler;
|
||||
import com.djrapitops.plan.utilities.formatting.Formatter;
|
||||
import com.djrapitops.plan.utilities.formatting.Formatters;
|
||||
import com.djrapitops.pluginbridge.plan.Hook;
|
||||
|
||||
import javax.inject.Inject;
|
||||
import javax.inject.Singleton;
|
||||
|
||||
/**
|
||||
* Hook for DiscordSRV plugin.
|
||||
*
|
||||
* @author Vankka
|
||||
*/
|
||||
@Singleton
|
||||
public class DiscordSRVHook extends Hook {
|
||||
|
||||
private final Formatter<Long> timestampFormatter;
|
||||
|
||||
@Inject
|
||||
public DiscordSRVHook(
|
||||
Formatters formatters
|
||||
) {
|
||||
super("github.scarsz.discordsrv.DiscordSRV");
|
||||
|
||||
timestampFormatter = formatters.yearLong();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void hook(HookHandler handler) throws NoClassDefFoundError {
|
||||
if (enabled) {
|
||||
handler.addPluginDataSource(new DiscordSRVData(timestampFormatter));
|
||||
}
|
||||
}
|
||||
}
|
@ -1,103 +0,0 @@
|
||||
/*
|
||||
* This file is part of Player Analytics (Plan).
|
||||
*
|
||||
* Plan is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License v3 as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Plan is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Plan. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.djrapitops.pluginbridge.plan.essentials;
|
||||
|
||||
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.html.icon.Color;
|
||||
import com.djrapitops.plan.utilities.html.icon.Icon;
|
||||
import com.earth2me.essentials.Essentials;
|
||||
import com.earth2me.essentials.User;
|
||||
import com.earth2me.essentials.UserMap;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* PluginData for Essentials Plugin.
|
||||
*
|
||||
* @author Rsl1122
|
||||
*/
|
||||
class EssentialsData extends PluginData {
|
||||
|
||||
private final Essentials essentials;
|
||||
|
||||
EssentialsData(Essentials essentials) {
|
||||
super(ContainerSize.THIRD, "Essentials");
|
||||
setPluginIcon(Icon.called("flask").of(Color.DEEP_ORANGE).build());
|
||||
this.essentials = essentials;
|
||||
}
|
||||
|
||||
@Override
|
||||
public InspectContainer getPlayerData(UUID uuid, InspectContainer inspectContainer) {
|
||||
if (essentials.getUserMap().userExists(uuid)) {
|
||||
User user = essentials.getUser(uuid);
|
||||
|
||||
boolean jailed = user.isJailed();
|
||||
boolean muted = user.isMuted();
|
||||
|
||||
inspectContainer.addValue(getWithIcon("Jailed", Icon.called("ban").of(Color.DEEP_ORANGE)), jailed ? "Yes" : "No");
|
||||
inspectContainer.addValue(getWithIcon("Muted", Icon.called("bell-slash").of(Color.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) {
|
||||
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");
|
||||
}
|
||||
}
|
||||
|
||||
String jailedString = jailed.values().stream().filter("Yes"::equals).count() + " / " + uuids.size();
|
||||
String mutedString = muted.values().stream().filter("Yes"::equals).count() + " / " + uuids.size();
|
||||
|
||||
analysisContainer.addValue(getWithIcon("Players in Jail", Icon.called("ban").of(Color.DEEP_ORANGE)), jailedString);
|
||||
analysisContainer.addValue(getWithIcon("Muted", Icon.called("bell-slash").of(Color.DEEP_ORANGE)), mutedString);
|
||||
|
||||
analysisContainer.addPlayerTableValues(getWithIcon("Jailed", Icon.called("ban")), jailed);
|
||||
analysisContainer.addPlayerTableValues(getWithIcon("Muted", Icon.called("bell-slash")), muted);
|
||||
|
||||
List<String> warpsList = new ArrayList<>(essentials.getWarps().getList());
|
||||
if (!warpsList.isEmpty()) {
|
||||
TableContainer warps = new TableContainer(
|
||||
getWithIcon("Warp", Icon.called("map-marker-alt")),
|
||||
getWithIcon("Command", Icon.called("terminal"))
|
||||
);
|
||||
warps.setColor("light-green");
|
||||
|
||||
Collections.sort(warpsList);
|
||||
for (String warp : warpsList) {
|
||||
warps.addRow(warp, "/warp " + warp);
|
||||
}
|
||||
analysisContainer.addTable("WarpTable", warps);
|
||||
}
|
||||
|
||||
return analysisContainer;
|
||||
}
|
||||
}
|
@ -1,48 +0,0 @@
|
||||
/*
|
||||
* This file is part of Player Analytics (Plan).
|
||||
*
|
||||
* Plan is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License v3 as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Plan is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Plan. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.djrapitops.pluginbridge.plan.essentials;
|
||||
|
||||
import com.djrapitops.plan.data.plugin.HookHandler;
|
||||
import com.djrapitops.pluginbridge.plan.Hook;
|
||||
import com.earth2me.essentials.Essentials;
|
||||
|
||||
import javax.inject.Inject;
|
||||
import javax.inject.Singleton;
|
||||
|
||||
import static org.bukkit.plugin.java.JavaPlugin.getPlugin;
|
||||
|
||||
/**
|
||||
* A Class responsible for hooking to Essentials.
|
||||
*
|
||||
* @author Rsl1122
|
||||
|
||||
*/
|
||||
@Singleton
|
||||
public class EssentialsHook extends Hook {
|
||||
|
||||
@Inject
|
||||
public EssentialsHook() {
|
||||
super("com.earth2me.essentials.Essentials");
|
||||
}
|
||||
|
||||
public void hook(HookHandler handler) throws NoClassDefFoundError {
|
||||
if (enabled) {
|
||||
Essentials ess = getPlugin(Essentials.class);
|
||||
handler.addPluginDataSource(new EssentialsData(ess));
|
||||
}
|
||||
}
|
||||
}
|
@ -1,103 +0,0 @@
|
||||
/*
|
||||
* This file is part of Player Analytics (Plan).
|
||||
*
|
||||
* Plan is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License v3 as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Plan is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Plan. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.djrapitops.pluginbridge.plan.griefprevention;
|
||||
|
||||
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.html.icon.Color;
|
||||
import com.djrapitops.plan.utilities.html.icon.Family;
|
||||
import com.djrapitops.plan.utilities.html.icon.Icon;
|
||||
import me.ryanhamshire.GriefPrevention.Claim;
|
||||
import me.ryanhamshire.GriefPrevention.DataStore;
|
||||
import org.bukkit.Location;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* PluginData for GriefPrevention plugin.
|
||||
*
|
||||
* @author Rsl1122
|
||||
*/
|
||||
class GriefPreventionData extends PluginData {
|
||||
|
||||
private final DataStore dataStore;
|
||||
|
||||
GriefPreventionData(DataStore dataStore) {
|
||||
super(ContainerSize.THIRD, "GriefPrevention");
|
||||
setPluginIcon(Icon.called("shield-alt").of(Color.BLUE_GREY).build());
|
||||
this.dataStore = dataStore;
|
||||
}
|
||||
|
||||
@Override
|
||||
public InspectContainer getPlayerData(UUID uuid, InspectContainer inspectContainer) {
|
||||
Map<String, Integer> claims = dataStore.getClaims().stream()
|
||||
.filter(Objects::nonNull)
|
||||
.filter(claim -> uuid.equals(claim.ownerID))
|
||||
.collect(Collectors.toMap(
|
||||
claim -> formatLocation(claim.getGreaterBoundaryCorner()),
|
||||
Claim::getArea)
|
||||
);
|
||||
String softMuted = dataStore.isSoftMuted(uuid) ? "Yes" : "No";
|
||||
long totalArea = claims.values().stream().mapToInt(i -> i).sum();
|
||||
|
||||
inspectContainer.addValue(getWithIcon("SoftMuted", Icon.called("bell-slash").of(Color.DEEP_ORANGE).of(Family.REGULAR)), softMuted);
|
||||
inspectContainer.addValue(getWithIcon("Claims", Icon.called("map-marker").of(Color.BLUE_GREY)), claims.size());
|
||||
inspectContainer.addValue(getWithIcon("Claimed Area", Icon.called("map").of(Family.REGULAR).of(Color.BLUE_GREY)), totalArea);
|
||||
|
||||
TableContainer claimsTable = new TableContainer(
|
||||
getWithIcon("Claim", Icon.called("map-marker")),
|
||||
getWithIcon("Area", Icon.called("map").of(Family.REGULAR))
|
||||
);
|
||||
claimsTable.setColor("blue-grey");
|
||||
for (Map.Entry<String, Integer> entry : claims.entrySet()) {
|
||||
claimsTable.addRow(entry.getKey(), entry.getValue());
|
||||
}
|
||||
inspectContainer.addTable("claimTable", claimsTable);
|
||||
|
||||
return inspectContainer;
|
||||
}
|
||||
|
||||
private String formatLocation(Location greaterBoundaryCorner) {
|
||||
return "x: " + greaterBoundaryCorner.getBlockX() + " z: " + greaterBoundaryCorner.getBlockZ();
|
||||
}
|
||||
|
||||
@Override
|
||||
public AnalysisContainer getServerData(Collection<UUID> collection, AnalysisContainer analysisContainer) {
|
||||
Map<UUID, Integer> area = new HashMap<>();
|
||||
|
||||
for (Claim claim : dataStore.getClaims()) {
|
||||
if (claim == null) {
|
||||
continue;
|
||||
}
|
||||
UUID uuid = claim.ownerID;
|
||||
int blocks = area.getOrDefault(uuid, 0);
|
||||
blocks += claim.getArea();
|
||||
area.put(uuid, blocks);
|
||||
}
|
||||
|
||||
long totalArea = area.values().stream().mapToInt(i -> i).sum();
|
||||
analysisContainer.addValue(getWithIcon("Total Claimed Area", Icon.called("map").of(Family.REGULAR).of(Color.BLUE_GREY)), totalArea);
|
||||
|
||||
analysisContainer.addPlayerTableValues(getWithIcon("Claimed Area", Icon.called("map").of(Family.REGULAR)), area);
|
||||
|
||||
return analysisContainer;
|
||||
}
|
||||
}
|
@ -1,60 +0,0 @@
|
||||
/*
|
||||
* This file is part of Player Analytics (Plan).
|
||||
*
|
||||
* Plan is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License v3 as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Plan is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Plan. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.djrapitops.pluginbridge.plan.griefprevention;
|
||||
|
||||
import com.djrapitops.plan.data.plugin.HookHandler;
|
||||
import com.djrapitops.plugin.logging.console.PluginLogger;
|
||||
import com.djrapitops.pluginbridge.plan.Hook;
|
||||
import me.ryanhamshire.GriefPrevention.DataStore;
|
||||
import me.ryanhamshire.GriefPrevention.GriefPrevention;
|
||||
|
||||
import javax.inject.Inject;
|
||||
import javax.inject.Singleton;
|
||||
|
||||
import static org.bukkit.plugin.java.JavaPlugin.getPlugin;
|
||||
|
||||
/**
|
||||
* A Class responsible for hooking to GriefPrevention and registering data
|
||||
* sources.
|
||||
*
|
||||
* @author Rsl1122
|
||||
|
||||
*/
|
||||
@Singleton
|
||||
public class GriefPreventionHook extends Hook {
|
||||
|
||||
private final PluginLogger logger;
|
||||
|
||||
@Inject
|
||||
public GriefPreventionHook(
|
||||
PluginLogger logger
|
||||
) {
|
||||
super("me.ryanhamshire.GriefPrevention.GriefPrevention");
|
||||
this.logger = logger;
|
||||
}
|
||||
|
||||
public void hook(HookHandler handler) throws NoClassDefFoundError {
|
||||
if (enabled) {
|
||||
DataStore dataStore = getPlugin(GriefPrevention.class).dataStore;
|
||||
if (dataStore == null) {
|
||||
logger.warn("GriefPrevention DataStore was not initialized yet. Run '/plan reload' to try to re-hook.");
|
||||
return;
|
||||
}
|
||||
handler.addPluginDataSource(new GriefPreventionData(dataStore));
|
||||
}
|
||||
}
|
||||
}
|
@ -1,101 +0,0 @@
|
||||
/*
|
||||
* This file is part of Player Analytics (Plan).
|
||||
*
|
||||
* Plan is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License v3 as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Plan is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Plan. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
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.html.icon.Color;
|
||||
import com.djrapitops.plan.utilities.html.icon.Family;
|
||||
import com.djrapitops.plan.utilities.html.icon.Icon;
|
||||
import net.kaikk.mc.gpp.Claim;
|
||||
import net.kaikk.mc.gpp.DataStore;
|
||||
import org.bukkit.Location;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* PluginData for GriefPreventionPlus plugin.
|
||||
*
|
||||
* @author Rsl1122
|
||||
*/
|
||||
class GriefPreventionPlusData extends PluginData {
|
||||
|
||||
private final DataStore dataStore;
|
||||
|
||||
GriefPreventionPlusData(DataStore dataStore) {
|
||||
super(ContainerSize.THIRD, "GriefPreventionPlus");
|
||||
setPluginIcon(Icon.called("shield-alt").of(Color.BLUE_GREY).build());
|
||||
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 -> formatLocation(claim.getGreaterBoundaryCorner()),
|
||||
Claim::getArea)
|
||||
);
|
||||
long totalArea = claims.values().stream().mapToInt(i -> i).sum();
|
||||
|
||||
inspectContainer.addValue(getWithIcon("Claims", Icon.called("map-marker").of(Color.BLUE_GREY)), claims.size());
|
||||
inspectContainer.addValue(getWithIcon("Claimed Area", Icon.called("map").of(Family.REGULAR).of(Color.BLUE_GREY)), totalArea);
|
||||
|
||||
TableContainer claimsTable = new TableContainer(
|
||||
getWithIcon("Claim", Icon.called("map-marker")),
|
||||
getWithIcon("Area", Icon.called("map").of(Family.REGULAR))
|
||||
);
|
||||
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 = area.values().stream().mapToInt(i -> i).sum();
|
||||
analysisContainer.addValue(getWithIcon("Total Claimed Area", Icon.called("map").of(Family.REGULAR).of(Color.BLUE_GREY)), totalArea);
|
||||
|
||||
analysisContainer.addPlayerTableValues(getWithIcon("Claimed Area", Icon.called("map").of(Family.REGULAR)), area);
|
||||
|
||||
return analysisContainer;
|
||||
}
|
||||
|
||||
private String formatLocation(Location greaterBoundaryCorner) {
|
||||
return "x: " + greaterBoundaryCorner.getBlockX() + " z: " + greaterBoundaryCorner.getBlockZ();
|
||||
}
|
||||
}
|
@ -1,50 +0,0 @@
|
||||
/*
|
||||
* This file is part of Player Analytics (Plan).
|
||||
*
|
||||
* Plan is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License v3 as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Plan is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Plan. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
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 javax.inject.Inject;
|
||||
import javax.inject.Singleton;
|
||||
|
||||
import static org.bukkit.plugin.java.JavaPlugin.getPlugin;
|
||||
|
||||
/**
|
||||
* A Class responsible for hooking to GriefPreventionPlus and registering data
|
||||
* sources.
|
||||
*
|
||||
* @author Rsl1122
|
||||
|
||||
*/
|
||||
@Singleton
|
||||
public class GriefPreventionPlusHook extends Hook {
|
||||
|
||||
@Inject
|
||||
public GriefPreventionPlusHook() {
|
||||
super("net.kaikk.mc.gpp.GriefPreventionPlus");
|
||||
}
|
||||
|
||||
public void hook(HookHandler handler) throws NoClassDefFoundError {
|
||||
if (enabled) {
|
||||
DataStore dataStore = getPlugin(GriefPreventionPlus.class).getDataStore();
|
||||
handler.addPluginDataSource(new GriefPreventionPlusData(dataStore));
|
||||
}
|
||||
}
|
||||
}
|
@ -1,104 +0,0 @@
|
||||
/*
|
||||
* This file is part of Player Analytics (Plan).
|
||||
*
|
||||
* Plan is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License v3 as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Plan is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Plan. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.djrapitops.pluginbridge.plan.mcmmo;
|
||||
|
||||
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.formatting.Formatter;
|
||||
import com.djrapitops.plan.utilities.html.icon.Color;
|
||||
import com.djrapitops.plan.utilities.html.icon.Family;
|
||||
import com.djrapitops.plan.utilities.html.icon.Icon;
|
||||
import com.gmail.nossr50.database.DatabaseManager;
|
||||
import com.gmail.nossr50.datatypes.player.PlayerProfile;
|
||||
import com.gmail.nossr50.datatypes.skills.SkillType;
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* PluginData for McMmo plugin.
|
||||
*
|
||||
* @author Rsl1122
|
||||
*/
|
||||
class McMmoData extends PluginData {
|
||||
|
||||
private final Formatter<Double> decimalFormatter;
|
||||
|
||||
McMmoData(Formatter<Double> decimalFormatter) {
|
||||
super(ContainerSize.THIRD, "MCMMO");
|
||||
this.decimalFormatter = decimalFormatter;
|
||||
setPluginIcon(Icon.called("compass").of(Color.INDIGO).of(Family.REGULAR).build());
|
||||
}
|
||||
|
||||
@Override
|
||||
public InspectContainer getPlayerData(UUID uuid, InspectContainer inspectContainer) {
|
||||
DatabaseManager db = mcMMO.getDatabaseManager();
|
||||
|
||||
PlayerProfile profile = db.loadPlayerProfile("", uuid, false);
|
||||
|
||||
String skillS = getWithIcon("Skill", Icon.called("star"));
|
||||
String levelS = getWithIcon("Level", Icon.called("plus"));
|
||||
TableContainer skillTable = new TableContainer(skillS, levelS);
|
||||
skillTable.setColor("indigo");
|
||||
|
||||
List<SkillType> skills = Arrays.stream(SkillType.values()).distinct().collect(Collectors.toList());
|
||||
for (SkillType skill : skills) {
|
||||
skillTable.addRow(StringUtils.capitalize(skill.getName().toLowerCase()), profile.getSkillLevel(skill));
|
||||
}
|
||||
|
||||
return inspectContainer;
|
||||
}
|
||||
|
||||
@Override
|
||||
public AnalysisContainer getServerData(Collection<UUID> uuids, AnalysisContainer analysisContainer) {
|
||||
String skillS = getWithIcon("Skill", Icon.called("star"));
|
||||
String tLevel = getWithIcon("Total Level", Icon.called("plus"));
|
||||
String aLevel = getWithIcon("Average Level", Icon.called("plus"));
|
||||
|
||||
DatabaseManager databaseManager = mcMMO.getDatabaseManager();
|
||||
|
||||
TableContainer skillTable = new TableContainer(skillS, tLevel, aLevel);
|
||||
skillTable.setColor("indigo");
|
||||
|
||||
List<PlayerProfile> profiles = uuids.stream()
|
||||
.map(uuid -> databaseManager.loadPlayerProfile("", uuid, false))
|
||||
.filter(Objects::nonNull)
|
||||
.filter(PlayerProfile::isLoaded)
|
||||
.collect(Collectors.toList());
|
||||
if (profiles.isEmpty()) {
|
||||
skillTable.addRow("No players");
|
||||
}
|
||||
|
||||
List<SkillType> skills = Arrays.stream(SkillType.values()).distinct().collect(Collectors.toList());
|
||||
|
||||
for (SkillType skill : skills) {
|
||||
long total = profiles.stream().mapToInt(p -> p.getSkillLevel(skill)).sum();
|
||||
skillTable.addRow(
|
||||
StringUtils.capitalize(skill.getName().toLowerCase()),
|
||||
total,
|
||||
decimalFormatter.apply(total * 1.0 / profiles.size())
|
||||
);
|
||||
}
|
||||
|
||||
return analysisContainer;
|
||||
}
|
||||
}
|
@ -1,51 +0,0 @@
|
||||
/*
|
||||
* This file is part of Player Analytics (Plan).
|
||||
*
|
||||
* Plan is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License v3 as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Plan is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Plan. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.djrapitops.pluginbridge.plan.mcmmo;
|
||||
|
||||
import com.djrapitops.plan.data.plugin.HookHandler;
|
||||
import com.djrapitops.plan.utilities.formatting.Formatter;
|
||||
import com.djrapitops.plan.utilities.formatting.Formatters;
|
||||
import com.djrapitops.pluginbridge.plan.Hook;
|
||||
|
||||
import javax.inject.Inject;
|
||||
import javax.inject.Singleton;
|
||||
|
||||
/**
|
||||
* A Class responsible for hooking to MCMMO and registering data sources.
|
||||
*
|
||||
* @author Rsl1122
|
||||
|
||||
*/
|
||||
@Singleton
|
||||
public class McmmoHook extends Hook {
|
||||
|
||||
private final Formatter<Double> decimalFormatter;
|
||||
|
||||
@Inject
|
||||
public McmmoHook(
|
||||
Formatters formatters
|
||||
) {
|
||||
super("com.gmail.nossr50.mcMMO");
|
||||
decimalFormatter = formatters.decimals();
|
||||
}
|
||||
|
||||
public void hook(HookHandler handler) throws NoClassDefFoundError {
|
||||
if (enabled) {
|
||||
handler.addPluginDataSource(new McMmoData(decimalFormatter));
|
||||
}
|
||||
}
|
||||
}
|
@ -1,307 +0,0 @@
|
||||
/*
|
||||
* This file is part of Player Analytics (Plan).
|
||||
*
|
||||
* Plan is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License v3 as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Plan is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Plan. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.djrapitops.pluginbridge.plan.nucleus;
|
||||
|
||||
import com.djrapitops.plan.api.PlanAPI;
|
||||
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.formatting.Formatter;
|
||||
import com.djrapitops.plan.utilities.html.Html;
|
||||
import com.djrapitops.plan.utilities.html.HtmlUtils;
|
||||
import com.djrapitops.plan.utilities.html.icon.Color;
|
||||
import com.djrapitops.plan.utilities.html.icon.Family;
|
||||
import com.djrapitops.plan.utilities.html.icon.Icon;
|
||||
import io.github.nucleuspowered.nucleus.api.NucleusAPI;
|
||||
import io.github.nucleuspowered.nucleus.api.nucleusdata.*;
|
||||
import io.github.nucleuspowered.nucleus.api.service.*;
|
||||
import org.spongepowered.api.Sponge;
|
||||
import org.spongepowered.api.entity.living.player.User;
|
||||
import org.spongepowered.api.service.user.UserStorageService;
|
||||
import org.spongepowered.api.text.Text;
|
||||
import org.spongepowered.api.text.serializer.TextSerializers;
|
||||
|
||||
import java.time.Duration;
|
||||
import java.time.Instant;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* PluginData for Nucleus plugin.
|
||||
*
|
||||
* @author Vankka
|
||||
*/
|
||||
class NucleusData extends PluginData {
|
||||
|
||||
private UserStorageService userStorageService = null;
|
||||
|
||||
private final Formatter<Long> timestampFormatter;
|
||||
|
||||
NucleusData(Formatter<Long> timestampFormatter) {
|
||||
super(ContainerSize.TWO_THIRDS, "Nucleus");
|
||||
this.timestampFormatter = timestampFormatter;
|
||||
setPluginIcon(Icon.called("flask").of(Color.DEEP_ORANGE).build());
|
||||
|
||||
Sponge.getServiceManager().provide(UserStorageService.class).ifPresent(storageService -> userStorageService = storageService);
|
||||
}
|
||||
|
||||
@Override
|
||||
public InspectContainer getPlayerData(UUID uuid, InspectContainer inspectContainer) {
|
||||
User user = getUser(uuid);
|
||||
|
||||
if (user == null) {
|
||||
inspectContainer.addValue("Data unavailable", "Could not get user data");
|
||||
return inspectContainer;
|
||||
}
|
||||
|
||||
NucleusAPI.getMuteService().ifPresent(muteService -> addMuteData(user, muteService, inspectContainer));
|
||||
NucleusAPI.getJailService().ifPresent(jailService -> addJailData(user, jailService, inspectContainer));
|
||||
NucleusAPI.getHomeService().ifPresent(homeService -> addHomeData(user, homeService, inspectContainer));
|
||||
NucleusAPI.getNoteService().ifPresent(noteService -> addNoteData(user, noteService, inspectContainer));
|
||||
NucleusAPI.getWarningService().ifPresent(warningService -> addWarningData(user, warningService, inspectContainer));
|
||||
NucleusAPI.getInvulnerabilityService().ifPresent(invulnerabilityService -> addInvulnerabilityData(user, invulnerabilityService, inspectContainer));
|
||||
NucleusAPI.getNicknameService().ifPresent(nicknameService -> addNicknameData(user, nicknameService, inspectContainer));
|
||||
|
||||
return inspectContainer;
|
||||
}
|
||||
|
||||
@Override
|
||||
public AnalysisContainer getServerData(Collection<UUID> uuids, AnalysisContainer analysisContainer) {
|
||||
NucleusAPI.getWarpService().ifPresent(warpService -> addWarpData(warpService, analysisContainer));
|
||||
NucleusAPI.getJailService().ifPresent(jailService -> addJailData(jailService, analysisContainer));
|
||||
NucleusAPI.getKitService().ifPresent(kitService -> addKitData(kitService, analysisContainer));
|
||||
|
||||
return analysisContainer;
|
||||
}
|
||||
|
||||
private User getUser(UUID uuid) {
|
||||
if (Sponge.getServer().getPlayer(uuid).isPresent()) {
|
||||
return Sponge.getServer().getPlayer(uuid).get();
|
||||
} else if (userStorageService != null) {
|
||||
Optional<User> optionalUser = userStorageService.get(uuid);
|
||||
return optionalUser.orElse(null);
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
private String formatTimeStampYear(Instant instant) {
|
||||
return timestampFormatter.apply(instant.toEpochMilli());
|
||||
}
|
||||
|
||||
private String formatTimeStampYear(Duration duration) {
|
||||
return timestampFormatter.apply(duration.plusMillis(System.currentTimeMillis()).toMillis());
|
||||
}
|
||||
|
||||
/*
|
||||
* Player Data
|
||||
*/
|
||||
private void addMuteData(User user, NucleusMuteService muteService, InspectContainer inspectContainer) {
|
||||
boolean muted = muteService.isMuted(user);
|
||||
inspectContainer.addValue(getWithIcon("Muted", Icon.called("bell-slash").of(Color.DEEP_ORANGE)), muted ? "Yes" : "No");
|
||||
|
||||
Optional<MuteInfo> optionalMuteInfo = muteService.getPlayerMuteInfo(user);
|
||||
if (muted && optionalMuteInfo.isPresent()) {
|
||||
MuteInfo muteInfo = optionalMuteInfo.get();
|
||||
|
||||
String reason = HtmlUtils.swapColorsToSpan(muteInfo.getReason());
|
||||
String start = muteInfo.getCreationInstant().map(this::formatTimeStampYear).orElse("Unknown");
|
||||
String end = muteInfo.getRemainingTime().map(this::formatTimeStampYear).orElse("Permanent mute");
|
||||
String link = "Unknown";
|
||||
|
||||
User operatorUser = muteInfo.getMuter().map(this::getUser).orElse(null);
|
||||
if (operatorUser != null) {
|
||||
String operator = operatorUser.getName();
|
||||
link = Html.LINK.parse(PlanAPI.getInstance().getPlayerInspectPageLink(operator), operator);
|
||||
}
|
||||
|
||||
inspectContainer.addValue(" " + getWithIcon("Operator", Icon.called("user").of(Color.DEEP_ORANGE)), link);
|
||||
inspectContainer.addValue(" " + getWithIcon("Date", Icon.called("calendar").of(Color.DEEP_ORANGE).of(Family.REGULAR)), start);
|
||||
inspectContainer.addValue(" " + getWithIcon("Ends", Icon.called("calendar-check").of(Color.DEEP_ORANGE).of(Family.REGULAR)), end);
|
||||
inspectContainer.addValue(" " + getWithIcon("Reason", Icon.called("comment").of(Color.DEEP_ORANGE).of(Family.REGULAR)), reason);
|
||||
}
|
||||
}
|
||||
|
||||
private void addJailData(User user, NucleusJailService jailService, InspectContainer inspectContainer) {
|
||||
boolean jailed = jailService.isPlayerJailed(user);
|
||||
inspectContainer.addValue(getWithIcon("Jailed", Icon.called("bars").of(Color.YELLOW).of(Family.SOLID)), jailed ? "Yes" : "No");
|
||||
|
||||
if (jailed && jailService.getPlayerJailData(user).isPresent()) {
|
||||
Inmate inmate = jailService.getPlayerJailData(user).get();
|
||||
|
||||
String reason = inmate.getReason();
|
||||
String start = inmate.getCreationInstant().map(this::formatTimeStampYear).orElse("Unknown");
|
||||
String end = inmate.getRemainingTime().map(this::formatTimeStampYear).orElse("Permanent jail sentence");
|
||||
String link = "Unknown";
|
||||
|
||||
User operatorUser = inmate.getJailer().map(this::getUser).orElse(null);
|
||||
if (operatorUser != null) {
|
||||
String operator = operatorUser.getName();
|
||||
link = Html.LINK.parse(PlanAPI.getInstance().getPlayerInspectPageLink(operator), operator);
|
||||
}
|
||||
|
||||
inspectContainer.addValue(" " + getWithIcon("Operator", Icon.called("user").of(Color.YELLOW)), link);
|
||||
inspectContainer.addValue(" " + getWithIcon("Date", Icon.called("calendar").of(Color.YELLOW).of(Family.REGULAR)), start);
|
||||
inspectContainer.addValue(" " + getWithIcon("Ends", Icon.called("calendar-check").of(Color.YELLOW).of(Family.REGULAR)), end);
|
||||
inspectContainer.addValue(" " + getWithIcon("Reason", Icon.called("comment").of(Color.YELLOW).of(Family.REGULAR)), reason);
|
||||
inspectContainer.addValue(" " + getWithIcon("Jail", Icon.called("bars").of(Color.YELLOW).of(Family.SOLID)), inmate.getJailName());
|
||||
}
|
||||
}
|
||||
|
||||
private void addHomeData(User user, NucleusHomeService homeService, InspectContainer inspectContainer) {
|
||||
int homeCount = homeService.getHomeCount(user);
|
||||
int maxHomes = homeService.getMaximumHomes(user);
|
||||
|
||||
inspectContainer.addValue(" " + getWithIcon("Homes", Icon.called("home").of(Color.GREEN).of(Family.SOLID)), homeCount + "/" + maxHomes);
|
||||
|
||||
List<Home> homes = homeService.getHomes(user);
|
||||
|
||||
if (!homes.isEmpty()) {
|
||||
TableContainer homesTable = new TableContainer(getWithIcon("Home", Icon.called("home").of(Family.SOLID)));
|
||||
homesTable.setColor("light-green");
|
||||
|
||||
for (Home home : homes) {
|
||||
homesTable.addRow(home.getName());
|
||||
}
|
||||
|
||||
inspectContainer.addTable("Homes", homesTable);
|
||||
}
|
||||
}
|
||||
|
||||
private void addNoteData(User user, NucleusNoteService noteService, InspectContainer inspectContainer) {
|
||||
List<Note> notes = noteService.getNotes(user);
|
||||
|
||||
if (!notes.isEmpty()) {
|
||||
TableContainer notesTable = new TableContainer(
|
||||
getWithIcon("Noter", Icon.called("pen").of(Family.SOLID)),
|
||||
getWithIcon("Note", Icon.called("sticky-note").of(Family.REGULAR))
|
||||
);
|
||||
|
||||
notesTable.setColor("light-blue");
|
||||
|
||||
for (Note note : notes) {
|
||||
String noter = "Unknown";
|
||||
|
||||
User noterUser = note.getNoter().map(this::getUser).orElse(null);
|
||||
if (noterUser != null) {
|
||||
noter = noterUser.getName();
|
||||
}
|
||||
|
||||
notesTable.addRow(noter, note.getNote());
|
||||
}
|
||||
|
||||
inspectContainer.addTable("Notes", notesTable);
|
||||
}
|
||||
}
|
||||
|
||||
private void addWarningData(User user, NucleusWarningService warningService, InspectContainer inspectContainer) {
|
||||
List<Warning> warnings = warningService.getWarnings(user);
|
||||
inspectContainer.addValue(getWithIcon("Warning count", Icon.called("flag").of(Color.AMBER)), warnings.size());
|
||||
|
||||
if (!warnings.isEmpty()) {
|
||||
TableContainer warningsTable = new TableContainer(
|
||||
getWithIcon("Warner", Icon.called("exclamation").of(Family.SOLID)),
|
||||
getWithIcon("Reason", Icon.called("sticky-note").of(Family.SOLID))
|
||||
);
|
||||
|
||||
warningsTable.setColor("amber");
|
||||
|
||||
for (Warning warning : warnings) {
|
||||
String warner = "Unknown";
|
||||
|
||||
User warnerUser = warning.getWarner().map(this::getUser).orElse(null);
|
||||
if (warnerUser != null) {
|
||||
warner = warnerUser.getName();
|
||||
}
|
||||
|
||||
warningsTable.addRow(warner, warning.getReason());
|
||||
}
|
||||
|
||||
inspectContainer.addTable("Warnings", warningsTable);
|
||||
}
|
||||
}
|
||||
|
||||
private void addInvulnerabilityData(User user, NucleusInvulnerabilityService invulnerabilityService, InspectContainer inspectContainer) {
|
||||
boolean invulnerable = invulnerabilityService.isInvulnerable(user);
|
||||
inspectContainer.addValue(getWithIcon("Invulnerable", Icon.called("crosshairs").of(Color.BLUE).of(Family.SOLID)), invulnerable ? "Yes" : "No");
|
||||
}
|
||||
|
||||
private void addNicknameData(User user, NucleusNicknameService nicknameService, InspectContainer inspectContainer) {
|
||||
Optional<Text> nickname = nicknameService.getNickname(user);
|
||||
|
||||
if (nickname.isPresent()) {
|
||||
String nicknameString = HtmlUtils.swapColorsToSpan(TextSerializers.FORMATTING_CODE.serialize(nickname.get()));
|
||||
inspectContainer.addValue(" " + getWithIcon("Nickname", Icon.called("id-badge").of(Color.GREEN).of(Family.REGULAR)), nicknameString);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Server Data
|
||||
*/
|
||||
private void addWarpData(NucleusWarpService warpService, AnalysisContainer analysisContainer) {
|
||||
List<Warp> warps = warpService.getAllWarps();
|
||||
analysisContainer.addValue(getWithIcon("Warp count", Icon.called("map-marker-alt").of(Color.BLUE)), warps.size());
|
||||
|
||||
if (!warps.isEmpty()) {
|
||||
TableContainer warpsTable = new TableContainer(
|
||||
getWithIcon("Name", Icon.called("map-marker-alt").of(Family.SOLID)),
|
||||
getWithIcon("Description", Icon.called("sticky-note").of(Family.REGULAR)),
|
||||
getWithIcon("Category", Icon.called("list").of(Family.SOLID))
|
||||
);
|
||||
|
||||
for (Warp warp : warps) {
|
||||
String description = warp.getDescription().map(desc -> HtmlUtils.swapColorsToSpan(TextSerializers.FORMATTING_CODE.serialize(desc))).orElse("None");
|
||||
String category = warp.getCategory().orElse("None");
|
||||
|
||||
warpsTable.addRow(warp.getName(), description, category);
|
||||
}
|
||||
|
||||
analysisContainer.addTable("Warps", warpsTable);
|
||||
}
|
||||
}
|
||||
|
||||
private void addJailData(NucleusJailService jailService, AnalysisContainer analysisContainer) {
|
||||
Map<String, NamedLocation> jails = jailService.getJails();
|
||||
analysisContainer.addValue(getWithIcon("Jail count", Icon.called("bars").of(Family.SOLID).of(Color.TEAL)), jails.size());
|
||||
|
||||
if (!jails.isEmpty()) {
|
||||
TableContainer jailsTable = new TableContainer(getWithIcon("Jail", Icon.called("bars").of(Family.SOLID)));
|
||||
|
||||
for (String jail : jails.keySet()) {
|
||||
jailsTable.addRow(jail);
|
||||
}
|
||||
|
||||
analysisContainer.addTable("Jails", jailsTable);
|
||||
}
|
||||
}
|
||||
|
||||
private void addKitData(NucleusKitService kitService, AnalysisContainer analysisContainer) {
|
||||
Set<String> kits = kitService.getKitNames();
|
||||
analysisContainer.addValue(getWithIcon("Kit count", Icon.called("box").of(Family.SOLID)), kits.size());
|
||||
|
||||
if (!kits.isEmpty()) {
|
||||
TableContainer kitsTable = new TableContainer(getWithIcon("Kit", Icon.called("box").of(Family.SOLID)));
|
||||
|
||||
for (String kit : kits) {
|
||||
kitsTable.addRow(kit);
|
||||
}
|
||||
|
||||
analysisContainer.addTable("Kits", kitsTable);
|
||||
}
|
||||
}
|
||||
}
|
@ -1,52 +0,0 @@
|
||||
/*
|
||||
* This file is part of Player Analytics (Plan).
|
||||
*
|
||||
* Plan is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License v3 as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Plan is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Plan. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.djrapitops.pluginbridge.plan.nucleus;
|
||||
|
||||
import com.djrapitops.plan.data.plugin.HookHandler;
|
||||
import com.djrapitops.plan.utilities.formatting.Formatter;
|
||||
import com.djrapitops.plan.utilities.formatting.Formatters;
|
||||
import com.djrapitops.pluginbridge.plan.Hook;
|
||||
|
||||
import javax.inject.Inject;
|
||||
import javax.inject.Singleton;
|
||||
|
||||
/**
|
||||
* Hook for Nucleus plugin.
|
||||
*
|
||||
* @author Vankka
|
||||
*/
|
||||
@Singleton
|
||||
public class NucleusHook extends Hook {
|
||||
|
||||
private final Formatter<Long> timestampFormatter;
|
||||
|
||||
@Inject
|
||||
public NucleusHook(
|
||||
Formatters formatters
|
||||
) {
|
||||
super("io.github.nucleuspowered.nucleus.NucleusPlugin");
|
||||
|
||||
timestampFormatter = formatters.yearLong();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void hook(HookHandler handler) throws NoClassDefFoundError {
|
||||
if (enabled) {
|
||||
handler.addPluginDataSource(new NucleusData(timestampFormatter));
|
||||
}
|
||||
}
|
||||
}
|
@ -1,90 +0,0 @@
|
||||
/*
|
||||
* This file is part of Player Analytics (Plan).
|
||||
*
|
||||
* Plan is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License v3 as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Plan is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Plan. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.djrapitops.pluginbridge.plan.redprotect;
|
||||
|
||||
import br.net.fabiozumbi12.RedProtect.Bukkit.RedProtect;
|
||||
import br.net.fabiozumbi12.RedProtect.Bukkit.Region;
|
||||
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.html.icon.Color;
|
||||
import com.djrapitops.plan.utilities.html.icon.Family;
|
||||
import com.djrapitops.plan.utilities.html.icon.Icon;
|
||||
import org.bukkit.Location;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* PluginData for RedProtect plugin.
|
||||
*
|
||||
* @author Rsl1122
|
||||
*/
|
||||
class RedProtectData extends PluginData {
|
||||
|
||||
RedProtectData() {
|
||||
super(ContainerSize.THIRD, "RedProtect");
|
||||
setPluginIcon(Icon.called("shield-alt").of(Color.RED).build());
|
||||
}
|
||||
|
||||
@Override
|
||||
public InspectContainer getPlayerData(UUID uuid, InspectContainer inspectContainer) {
|
||||
Set<Region> regions = RedProtect.get().getAPI().getPlayerRegions(uuid.toString());
|
||||
|
||||
addRegionData(inspectContainer, regions);
|
||||
|
||||
return inspectContainer;
|
||||
}
|
||||
|
||||
private void addRegionData(InspectContainer inspectContainer, Set<Region> regions) {
|
||||
inspectContainer.addValue(getWithIcon("Regions", Icon.called("map-marker").of(Color.RED)), regions.size());
|
||||
|
||||
TableContainer regionTable = new TableContainer(
|
||||
getWithIcon("Region", Icon.called("map-marker")),
|
||||
getWithIcon("World", Icon.called("map")),
|
||||
getWithIcon("Area", Icon.called("map").of(Family.REGULAR))
|
||||
);
|
||||
long areaTotal = getTotalAndAddRows(regions, regionTable);
|
||||
|
||||
inspectContainer.addValue(getWithIcon("Total Area", Icon.called("map").of(Family.REGULAR).of(Color.RED)), areaTotal);
|
||||
inspectContainer.addTable("regionTable", regionTable);
|
||||
}
|
||||
|
||||
@Override
|
||||
public AnalysisContainer getServerData(Collection<UUID> collection, AnalysisContainer analysisContainer) {
|
||||
Set<Region> regions = RedProtect.get().getAPI().getAllRegions();
|
||||
|
||||
addRegionData(analysisContainer, regions);
|
||||
return analysisContainer;
|
||||
}
|
||||
|
||||
private long getTotalAndAddRows(Set<Region> regions, TableContainer regionTable) {
|
||||
long areaTotal = 0;
|
||||
for (Region region : regions) {
|
||||
int area = region.getArea();
|
||||
areaTotal += area;
|
||||
Location center = region.getCenterLoc();
|
||||
String location = "x: " + center.getBlockX() + ", z: " + center.getBlockZ();
|
||||
String world = region.getWorld();
|
||||
regionTable.addRow(location, world, area);
|
||||
}
|
||||
return areaTotal;
|
||||
}
|
||||
}
|
@ -1,44 +0,0 @@
|
||||
/*
|
||||
* This file is part of Player Analytics (Plan).
|
||||
*
|
||||
* Plan is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License v3 as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Plan is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Plan. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.djrapitops.pluginbridge.plan.redprotect;
|
||||
|
||||
import com.djrapitops.plan.data.plugin.HookHandler;
|
||||
import com.djrapitops.pluginbridge.plan.Hook;
|
||||
|
||||
import javax.inject.Inject;
|
||||
import javax.inject.Singleton;
|
||||
|
||||
/**
|
||||
* Hook for RedProtect plugin.
|
||||
*
|
||||
* @author Rsl1122
|
||||
*/
|
||||
@Singleton
|
||||
public class RedProtectHook extends Hook {
|
||||
|
||||
@Inject
|
||||
public RedProtectHook() {
|
||||
super("br.net.fabiozumbi12.RedProtect.Bukkit.RedProtect");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void hook(HookHandler handler) throws NoClassDefFoundError {
|
||||
if (enabled) {
|
||||
handler.addPluginDataSource(new RedProtectData());
|
||||
}
|
||||
}
|
||||
}
|
@ -1,98 +0,0 @@
|
||||
/*
|
||||
* This file is part of Player Analytics (Plan).
|
||||
*
|
||||
* Plan is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License v3 as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Plan is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Plan. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.djrapitops.pluginbridge.plan.sponge;
|
||||
|
||||
import com.djrapitops.plan.data.element.AnalysisContainer;
|
||||
import com.djrapitops.plan.data.element.InspectContainer;
|
||||
import com.djrapitops.plan.data.plugin.ContainerSize;
|
||||
import com.djrapitops.plan.data.plugin.PluginData;
|
||||
import com.djrapitops.plan.utilities.html.icon.Color;
|
||||
import com.djrapitops.plan.utilities.html.icon.Icon;
|
||||
import org.spongepowered.api.service.economy.Currency;
|
||||
import org.spongepowered.api.service.economy.EconomyService;
|
||||
import org.spongepowered.api.service.economy.account.UniqueAccount;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* PluginData for Sponge.
|
||||
*
|
||||
* @author BrainStone
|
||||
*/
|
||||
class SpongeEconomyData extends PluginData {
|
||||
private static final Color color = Color.AMBER;
|
||||
private static final String nameMoneyIcon = "money-bill-wave";
|
||||
private static final Icon moneyIcon = Icon.called(nameMoneyIcon).build();
|
||||
private static final Icon moneyIconColored = Icon.called(nameMoneyIcon).of(color).build();
|
||||
|
||||
private final EconomyService economyService;
|
||||
|
||||
SpongeEconomyData(EconomyService economyService) {
|
||||
super(ContainerSize.THIRD, "Sponge Economy");
|
||||
|
||||
this.economyService = economyService;
|
||||
|
||||
setPluginIcon(moneyIconColored);
|
||||
}
|
||||
|
||||
@Override
|
||||
public InspectContainer getPlayerData(UUID uuid, InspectContainer inspectContainer) {
|
||||
Optional<UniqueAccount> uOpt = economyService.getOrCreateAccount(uuid);
|
||||
|
||||
if (!uOpt.isPresent()) {
|
||||
return inspectContainer;
|
||||
}
|
||||
|
||||
UniqueAccount acc = uOpt.get();
|
||||
|
||||
for(Currency currency : economyService.getCurrencies()) {
|
||||
BigDecimal balance = acc.getBalance(currency);
|
||||
inspectContainer.addValue(getWithIcon(currency.getName(), moneyIconColored), currency.format(balance).toPlain());
|
||||
}
|
||||
|
||||
return inspectContainer;
|
||||
}
|
||||
|
||||
@Override
|
||||
public AnalysisContainer getServerData(Collection<UUID> uuids, AnalysisContainer analysisContainer) {
|
||||
List<UniqueAccount> players = uuids.stream().map(economyService::getOrCreateAccount)
|
||||
.filter(Optional::isPresent).map(Optional::get).collect(Collectors.toList());
|
||||
|
||||
for(Currency currency : economyService.getCurrencies()) {
|
||||
addCurrencyToContainer(currency, players, analysisContainer);
|
||||
}
|
||||
|
||||
return analysisContainer;
|
||||
}
|
||||
|
||||
private void addCurrencyToContainer(Currency currency, List<UniqueAccount> players, AnalysisContainer analysisContainer) {
|
||||
BigDecimal totalBalance = BigDecimal.ZERO;
|
||||
Map<UUID, String> playerBalances = new HashMap<>();
|
||||
|
||||
for (UniqueAccount player : players) {
|
||||
BigDecimal balance = player.getBalance(currency);
|
||||
|
||||
totalBalance = totalBalance.add(balance);
|
||||
playerBalances.put(player.getUniqueId(), currency.format(balance).toPlain());
|
||||
}
|
||||
|
||||
analysisContainer.addValue(getWithIcon("Total Server Balance " + currency.getName(), moneyIconColored), currency.format(totalBalance).toPlain());
|
||||
analysisContainer.addPlayerTableValues(getWithIcon("Balance " + currency.getName(), moneyIcon), playerBalances);
|
||||
}
|
||||
}
|
@ -1,61 +0,0 @@
|
||||
/*
|
||||
* This file is part of Player Analytics (Plan).
|
||||
*
|
||||
* Plan is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License v3 as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Plan is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Plan. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.djrapitops.pluginbridge.plan.sponge;
|
||||
|
||||
import com.djrapitops.plan.data.plugin.HookHandler;
|
||||
import com.djrapitops.plugin.logging.L;
|
||||
import com.djrapitops.plugin.logging.error.ErrorHandler;
|
||||
import com.djrapitops.pluginbridge.plan.Hook;
|
||||
import org.spongepowered.api.Sponge;
|
||||
import org.spongepowered.api.service.economy.EconomyService;
|
||||
|
||||
import javax.inject.Inject;
|
||||
import javax.inject.Singleton;
|
||||
import java.util.Optional;
|
||||
|
||||
/**
|
||||
* A Class responsible for hooking to Sponge and registering 1 data sources
|
||||
*
|
||||
* @author BrainStone
|
||||
|
||||
*/
|
||||
@Singleton
|
||||
public class SpongeEconomyHook extends Hook {
|
||||
|
||||
@Inject
|
||||
public SpongeEconomyHook(
|
||||
ErrorHandler errorHandler
|
||||
) {
|
||||
super("org.spongepowered.api.Sponge");
|
||||
|
||||
try {
|
||||
Optional<EconomyService> serviceOpt = Sponge.getServiceManager().provide(EconomyService.class);
|
||||
enabled = serviceOpt.isPresent();
|
||||
} catch(NoClassDefFoundError e) {
|
||||
enabled = false;
|
||||
} catch (IllegalStateException e) {
|
||||
errorHandler.log(L.WARN, this.getClass(), e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void hook(HookHandler handler) {
|
||||
if (enabled) {
|
||||
handler.addPluginDataSource(new SpongeEconomyData(Sponge.getServiceManager().provide(EconomyService.class).get()));
|
||||
}
|
||||
}
|
||||
}
|
@ -1,84 +0,0 @@
|
||||
/*
|
||||
* This file is part of Player Analytics (Plan).
|
||||
*
|
||||
* Plan is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License v3 as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Plan is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Plan. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.djrapitops.pluginbridge.plan.vault;
|
||||
|
||||
import com.djrapitops.plan.data.element.AnalysisContainer;
|
||||
import com.djrapitops.plan.data.element.InspectContainer;
|
||||
import com.djrapitops.plan.data.plugin.ContainerSize;
|
||||
import com.djrapitops.plan.data.plugin.PluginData;
|
||||
import com.djrapitops.plan.data.store.keys.AnalysisKeys;
|
||||
import com.djrapitops.plan.utilities.formatting.Formatter;
|
||||
import com.djrapitops.plan.utilities.html.icon.Color;
|
||||
import com.djrapitops.plan.utilities.html.icon.Icon;
|
||||
import com.djrapitops.pluginbridge.plan.FakeOfflinePlayer;
|
||||
import net.milkbowl.vault.economy.Economy;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* PluginData for Vault Economy.
|
||||
*
|
||||
* @author Rsl1122
|
||||
*/
|
||||
class VaultEcoData extends PluginData {
|
||||
|
||||
private final Economy econ;
|
||||
|
||||
private final Formatter<Double> decimalFormatter;
|
||||
|
||||
VaultEcoData(
|
||||
Economy econ,
|
||||
Formatter<Double> decimalFormatter
|
||||
) {
|
||||
super(ContainerSize.THIRD, "Economy (" + econ.getName() + ")");
|
||||
this.decimalFormatter = decimalFormatter;
|
||||
setPluginIcon(Icon.called("money-bill-wave").of(Color.GREEN).build());
|
||||
this.econ = econ;
|
||||
}
|
||||
|
||||
@Override
|
||||
public InspectContainer getPlayerData(UUID uuid, InspectContainer inspectContainer) {
|
||||
String name = uuid.toString();
|
||||
OfflinePlayer p = new FakeOfflinePlayer(uuid, name);
|
||||
inspectContainer.addValue(getWithIcon("Balance", Icon.called("money-bill-wave").of(Color.GREEN)), econ.format(econ.getBalance(p)));
|
||||
|
||||
return inspectContainer;
|
||||
}
|
||||
|
||||
@Override
|
||||
public AnalysisContainer getServerData(Collection<UUID> collection, AnalysisContainer analysisContainer) {
|
||||
List<FakeOfflinePlayer> offlinePlayers = Optional.ofNullable(analysisData)
|
||||
.flatMap(c -> c.getValue(AnalysisKeys.PLAYERS_MUTATOR))
|
||||
.map(mutator -> mutator.all().stream().map(FakeOfflinePlayer::new)
|
||||
.collect(Collectors.toList()))
|
||||
.orElse(new ArrayList<>());
|
||||
|
||||
Map<UUID, String> balances = new HashMap<>();
|
||||
double totalBalance = 0.0;
|
||||
for (FakeOfflinePlayer p : offlinePlayers) {
|
||||
double bal = econ.getBalance(p);
|
||||
totalBalance += bal;
|
||||
balances.put(p.getUniqueId(), econ.format(bal));
|
||||
}
|
||||
analysisContainer.addValue(getWithIcon("Server Balance", Icon.called("money-bill-wave").of(Color.GREEN)), decimalFormatter.apply(totalBalance));
|
||||
analysisContainer.addPlayerTableValues(getWithIcon("Balance", Icon.called("money-bill-wave")), balances);
|
||||
|
||||
return analysisContainer;
|
||||
}
|
||||
}
|
@ -1,62 +0,0 @@
|
||||
/*
|
||||
* This file is part of Player Analytics (Plan).
|
||||
*
|
||||
* Plan is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License v3 as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Plan is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Plan. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.djrapitops.pluginbridge.plan.vault;
|
||||
|
||||
import com.djrapitops.plan.data.plugin.HookHandler;
|
||||
import com.djrapitops.plan.utilities.formatting.Formatter;
|
||||
import com.djrapitops.plan.utilities.formatting.Formatters;
|
||||
import com.djrapitops.pluginbridge.plan.Hook;
|
||||
import net.milkbowl.vault.economy.Economy;
|
||||
|
||||
import javax.inject.Inject;
|
||||
import javax.inject.Singleton;
|
||||
|
||||
import static org.bukkit.Bukkit.getServer;
|
||||
|
||||
/**
|
||||
* A Class responsible for hooking to Vault and registering data sources.
|
||||
*
|
||||
* @author Rsl1122
|
||||
|
||||
*/
|
||||
@Singleton
|
||||
public class VaultHook extends Hook {
|
||||
|
||||
private final Formatter<Double> decimalFormatter;
|
||||
|
||||
@Inject
|
||||
public VaultHook(
|
||||
Formatters formatters
|
||||
) throws NoClassDefFoundError {
|
||||
super("net.milkbowl.vault.Vault");
|
||||
|
||||
decimalFormatter = formatters.decimals();
|
||||
}
|
||||
|
||||
public void hook(HookHandler handler) throws NoClassDefFoundError {
|
||||
if (!enabled) {
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
Economy econ = getServer().getServicesManager().getRegistration(Economy.class).getProvider();
|
||||
handler.addPluginDataSource(new VaultEcoData(econ, decimalFormatter));
|
||||
} catch (NoSuchFieldError | NoSuchMethodError | Exception ignore) {
|
||||
/* Economy service not present */
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user