Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 16 additions & 25 deletions dependency-reduced-pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<groupId>io.github.ithotl</groupId>
<artifactId>PlayerStats</artifactId>
<name>PlayerStats</name>
<version>2.5</version>
<version>2.6</version>
<description>Statistics Plugin</description>
<url>https://www.spigotmc.org/resources/playerstats.102347/</url>
<developers>
Expand Down Expand Up @@ -66,36 +66,13 @@
<pattern>com.tchristofferson</pattern>
<shadedPattern>com.artemis.the.gr8.playerstats.lib.tchristofferson</shadedPattern>
</relocation>
<relocation>
<pattern>org.bstats</pattern>
<shadedPattern>com.artemis.the.gr8.playerstats.lib.bstats</shadedPattern>
</relocation>
</relocations>
<filters>
<filter>
<artifact>*:*</artifact>
<excludes>
<exclude>META-INF/versions/**</exclude>
<exclude>META-INF/maven/com.tchristofferson/**</exclude>
<exclude>images/**</exclude>
</excludes>
</filter>
<filter>
<artifact>net.kyori:*</artifact>
<excludes>
<exclude>META-INF/**</exclude>
</excludes>
</filter>
<filter>
<artifact>com.tchristofferson:*</artifact>
<excludes>
<exclude>META-INF/**</exclude>
</excludes>
</filter>
<filter>
<artifact>org.bstats:*</artifact>
<excludes>
<exclude>META-INF/**</exclude>
<exclude>images/**</exclude>
</excludes>
</filter>
</filters>
Expand Down Expand Up @@ -211,6 +188,20 @@
<artifactId>placeholderapi</artifactId>
<version>2.11.6</version>
<scope>provided</scope>
<exclusions>
<exclusion>
<artifactId>bstats-bukkit</artifactId>
<groupId>org.bstats</groupId>
</exclusion>
<exclusion>
<artifactId>adventure-platform-bukkit</artifactId>
<groupId>net.kyori</groupId>
</exclusion>
<exclusion>
<artifactId>annotations</artifactId>
<groupId>org.jetbrains</groupId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.jetbrains</groupId>
Expand Down
57 changes: 34 additions & 23 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<groupId>io.github.ithotl</groupId>
<artifactId>PlayerStats</artifactId>
<version>2.5</version>
<version>2.6</version>

<name>PlayerStats</name>
<description>Statistics Plugin</description>
Expand Down Expand Up @@ -74,6 +74,12 @@
<groupId>net.kyori</groupId>
<artifactId>adventure-api</artifactId>
<version>4.22.0</version>
<exclusions>
<exclusion>
<groupId>org.jetbrains</groupId>
<artifactId>annotations</artifactId>
</exclusion>
</exclusions>
</dependency>

<dependency>
Expand All @@ -86,13 +92,35 @@
<groupId>net.kyori</groupId>
<artifactId>adventure-text-minimessage</artifactId>
<version>4.22.0</version>
<exclusions>
<exclusion>
<groupId>net.kyori</groupId>
<artifactId>adventure-api</artifactId>
</exclusion>
</exclusions>
</dependency>

<dependency>
<groupId>me.clip</groupId>
<artifactId>placeholderapi</artifactId>
<version>2.11.6</version>
<scope>provided</scope>
<exclusions>
<exclusion>
<groupId>org.bstats</groupId>
<artifactId>bstats-bukkit</artifactId>
</exclusion>

<exclusion>
<groupId>net.kyori</groupId>
<artifactId>adventure-platform-bukkit</artifactId>
</exclusion>

<exclusion>
<groupId>org.jetbrains</groupId>
<artifactId>annotations</artifactId>
</exclusion>
</exclusions>
</dependency>

<dependency>
Expand All @@ -101,14 +129,14 @@
<version>2.0-SNAPSHOT</version>
<scope>compile</scope>
</dependency>

<!--
<dependency>
<groupId>org.bstats</groupId>
<artifactId>bstats-bukkit</artifactId>
<version>3.0.1</version>
<scope>compile</scope>
</dependency>

-->
<dependency>
<groupId>org.jetbrains</groupId>
<artifactId>annotations</artifactId>
Expand Down Expand Up @@ -160,36 +188,19 @@
<pattern>com.tchristofferson</pattern>
<shadedPattern>com.artemis.the.gr8.playerstats.lib.tchristofferson</shadedPattern>
</relocation>
<!--
<relocation>
<pattern>org.bstats</pattern>
<shadedPattern>com.artemis.the.gr8.playerstats.lib.bstats</shadedPattern>
</relocation>
-->
</relocations>
<filters>
<filter>
<artifact>*:*</artifact>
<excludes>
<exclude>META-INF/versions/**</exclude>
<exclude>META-INF/maven/com.tchristofferson/**</exclude>
<exclude>images/**</exclude>
</excludes>
</filter>
<filter>
<artifact>net.kyori:*</artifact>
<excludes>
<exclude>META-INF/**</exclude>
</excludes>
</filter>
<filter>
<artifact>com.tchristofferson:*</artifact>
<excludes>
<exclude>META-INF/**</exclude>
</excludes>
</filter>
<filter>
<artifact>org.bstats:*</artifact>
<excludes>
<exclude>META-INF/**</exclude>
<exclude>images/**</exclude>
</excludes>
</filter>
</filters>
Expand Down
41 changes: 17 additions & 24 deletions src/main/java/com/artemis/the/gr8/playerstats/core/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,12 @@
import com.artemis.the.gr8.playerstats.core.msg.msgutils.LanguageKeyHandler;
import com.artemis.the.gr8.playerstats.core.sharing.ShareManager;
import com.artemis.the.gr8.playerstats.core.statistic.StatRequestManager;
import com.artemis.the.gr8.playerstats.core.utils.Closable;
import com.artemis.the.gr8.playerstats.core.utils.OfflinePlayerHandler;
import com.artemis.the.gr8.playerstats.core.utils.Reloadable;
import com.artemis.the.gr8.playerstats.core.utils.*;
import me.clip.placeholderapi.PlaceholderAPIPlugin;
import me.clip.placeholderapi.expansion.PlaceholderExpansion;
import org.bstats.bukkit.Metrics;
import org.bstats.charts.SimplePie;
import org.bukkit.Bukkit;
import org.bukkit.command.PluginCommand;
import org.bukkit.plugin.java.JavaPlugin;
import org.bukkit.scheduler.BukkitRunnable;
import org.jetbrains.annotations.Contract;
import org.jetbrains.annotations.NotNull;

Expand Down Expand Up @@ -55,7 +50,7 @@ public void onEnable() {
setupMetrics();

//register the listener
Bukkit.getPluginManager().registerEvents(new JoinListener(threadManager), this);
Bukkit.getPluginManager().registerEvents(new JoinListener(), this);

//finish up
this.getLogger().info("Enabled PlayerStats!");
Expand Down Expand Up @@ -151,23 +146,21 @@ private void registerCommands() {
* Setup bstats
*/
private void setupMetrics() {
new BukkitRunnable() {
@Override
public void run() {
final Metrics metrics = new Metrics(pluginInstance, 15923);
final boolean placeholderExpansionActive;
if (Bukkit.getPluginManager().isPluginEnabled("PlaceholderAPI")) {
PlaceholderExpansion expansion = PlaceholderAPIPlugin
.getInstance()
.getLocalExpansionManager()
.getExpansion("playerstats");
placeholderExpansionActive = expansion != null;
} else {
placeholderExpansionActive = false;
}
metrics.addCustomChart(new SimplePie("using_placeholder_expansion", () -> placeholderExpansionActive ? "yes" : "no"));
}
}.runTaskLaterAsynchronously(this, 200);
final Metrics metrics = new Metrics(pluginInstance, 15923);
final boolean placeholderExpansionActive;
if (Bukkit.getPluginManager().isPluginEnabled("PlaceholderAPI")) {
PlaceholderExpansion expansion = PlaceholderAPIPlugin
.getInstance()
.getLocalExpansionManager()
.getExpansion("playerstats");
placeholderExpansionActive = expansion != null;
} else {
placeholderExpansionActive = false;
}
metrics.addCustomChart(new Metrics.SimplePie("using_placeholder_expansion", () -> placeholderExpansionActive ? "yes" : "no"));

CommandCounter counter = CommandCounter.getInstance();
metrics.addCustomChart(new Metrics.AdvancedPie("commands_used_the_last_30_minutes", counter::getCommandCounts));
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import com.artemis.the.gr8.playerstats.core.enums.StandardMessage;
import com.artemis.the.gr8.playerstats.core.msg.OutputManager;
import com.artemis.the.gr8.playerstats.core.utils.CommandCounter;
import com.artemis.the.gr8.playerstats.core.utils.OfflinePlayerHandler;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
Expand All @@ -14,10 +15,12 @@ public final class ExcludeCommand implements CommandExecutor {

private static OutputManager outputManager;
private final OfflinePlayerHandler offlinePlayerHandler;
private final CommandCounter commandCounter;

public ExcludeCommand() {
outputManager = OutputManager.getInstance();
this.offlinePlayerHandler = OfflinePlayerHandler.getInstance();
offlinePlayerHandler = OfflinePlayerHandler.getInstance();
commandCounter = CommandCounter.getInstance();
}

@Override
Expand All @@ -35,6 +38,7 @@ else if (args.length == 1) {
}
}
else {
commandCounter.upExcludeCommandCount();
switch (args[0]) {
case "add" -> {
if (offlinePlayerHandler.addPlayerToExcludeList(args[1])) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import com.artemis.the.gr8.playerstats.core.enums.StandardMessage;
import com.artemis.the.gr8.playerstats.core.msg.OutputManager;
import com.artemis.the.gr8.playerstats.core.sharing.StoredResult;
import com.artemis.the.gr8.playerstats.core.utils.CommandCounter;
import com.artemis.the.gr8.playerstats.core.utils.MyLogger;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
Expand All @@ -14,10 +15,12 @@ public final class ShareCommand implements CommandExecutor {

private static OutputManager outputManager;
private static ShareManager shareManager;
private final CommandCounter commandCounter;

public ShareCommand() {
outputManager = OutputManager.getInstance();
shareManager = ShareManager.getInstance();
commandCounter = CommandCounter.getInstance();
}

@Override
Expand All @@ -41,6 +44,7 @@ else if (shareManager.isOnCoolDown(sender.getName())) {
if (result == null) { //at this point the only possible cause of formattedComponent being null is the request being older than 25 player-requests ago
outputManager.sendFeedbackMsg(sender, StandardMessage.STAT_RESULTS_TOO_OLD);
} else {
commandCounter.upShareCommandCount();
outputManager.sendToAllPlayers(result.formattedValue());
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import com.artemis.the.gr8.playerstats.core.statistic.PlayerStatRequest;
import com.artemis.the.gr8.playerstats.core.statistic.ServerStatRequest;
import com.artemis.the.gr8.playerstats.core.statistic.TopStatRequest;
import com.artemis.the.gr8.playerstats.core.utils.CommandCounter;
import com.artemis.the.gr8.playerstats.core.utils.EnumHandler;
import com.artemis.the.gr8.playerstats.core.utils.OfflinePlayerHandler;
import org.bukkit.Material;
Expand Down Expand Up @@ -38,6 +39,7 @@ public final class StatCommand implements CommandExecutor {
private final ConfigHandler config;
private final EnumHandler enumHandler;
private final OfflinePlayerHandler offlinePlayerHandler;
private final CommandCounter commandCounter;

public StatCommand(ThreadManager threadManager) {
StatCommand.threadManager = threadManager;
Expand All @@ -46,22 +48,26 @@ public StatCommand(ThreadManager threadManager) {
config = ConfigHandler.getInstance();
enumHandler = EnumHandler.getInstance();
offlinePlayerHandler = OfflinePlayerHandler.getInstance();
commandCounter = CommandCounter.getInstance();
}

@Override
public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, @NotNull String[] args) {
if (args.length == 0 ||
args[0].equalsIgnoreCase("help") ||
args[0].equalsIgnoreCase("info")) {
commandCounter.upHelpCommandCount();
outputManager.sendHelp(sender);
}
else if (args[0].equalsIgnoreCase("examples") ||
args[0].equalsIgnoreCase("example")) {
commandCounter.upHelpCommandCount();
outputManager.sendExamples(sender);
}
else {
ArgProcessor processor = new ArgProcessor(sender, args);
if (processor.request != null && processor.request.isValid()) {
countStatCommand(processor.target);
threadManager.startStatThread(processor.request);
} else {
sendFeedback(sender, processor);
Expand All @@ -70,6 +76,14 @@ else if (args[0].equalsIgnoreCase("examples") ||
return true;
}

private void countStatCommand(@NotNull Target target) {
switch (target) {
case PLAYER -> commandCounter.upPlayerStatCommandCount();
case TOP -> commandCounter.upTopStatCommandCount();
case SERVER -> commandCounter.upServerStatCommandCount();
}
}

/**
* Analyzes the provided args and sends an appropriate
* feedback message to the CommandSender that called the
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,9 @@ public void reload() {
* <br>PlayerStats 1.3: "config-version" is 3.
* <br>PlayerStats 1.4: "config-version" is 4.
* <br>PlayerStats 1.5: "config-version" is 5.
* <br>PlayerStats 1.6 and up: "config-version" is 6.
* <br>PlayerStats 1.6 & 1.7: "config-version" is 6.
* <br>PlayerStats 2.1, 2.2 & 2.3: "config-version" is 7.
* <br>PlayerStats 2.4 and up: "config-version" is 8.
*/
private void checkAndUpdateConfigVersion() {
if (!config.contains("config-version") || config.getInt("config-version") != configVersion) {
Expand Down
Loading