Added finishing touches to javadoc comments and started preparing for 1.7 release (#100)

This commit is contained in:
Artemis-the-gr8 2022-08-17 00:27:25 +02:00
parent 7c9f03038f
commit 7e2a105b71
59 changed files with 376 additions and 302 deletions

View File

@ -49,7 +49,7 @@
<configuration> <configuration>
<transformers> <transformers>
<transformer> <transformer>
<mainClass>com.github.artemis.the.gr8.playerstats.Main</mainClass> <mainClass>com.artemis.the.gr8.playerstats.Main</mainClass>
</transformer> </transformer>
</transformers> </transformers>
<artifactSet> <artifactSet>
@ -126,7 +126,6 @@
</executions> </executions>
<configuration> <configuration>
<name>PlayerStats Javadocs</name> <name>PlayerStats Javadocs</name>
<docTitle>PlayerStats Javadocs</docTitle>
<additionalOptions>-Xdoclint:none</additionalOptions> <additionalOptions>-Xdoclint:none</additionalOptions>
<failOnError>false</failOnError> <failOnError>false</failOnError>
<quiet>true</quiet> <quiet>true</quiet>

12
pom.xml
View File

@ -4,7 +4,7 @@
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<groupId>io.github.artemis-the-gr8</groupId> <groupId>io.github.ithotl</groupId>
<artifactId>PlayerStats</artifactId> <artifactId>PlayerStats</artifactId>
<version>1.7</version> <version>1.7</version>
@ -141,7 +141,7 @@
<transformers> <transformers>
<transformer <transformer
implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer"> implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
<mainClass>com.github.artemis.the.gr8.playerstats.Main</mainClass> <mainClass>com.artemis.the.gr8.playerstats.Main</mainClass>
</transformer> </transformer>
</transformers> </transformers>
<artifactSet> <artifactSet>
@ -152,15 +152,15 @@
<relocations> <relocations>
<relocation> <relocation>
<pattern>net.kyori</pattern> <pattern>net.kyori</pattern>
<shadedPattern>com.github.artemis.the.gr8.lib.kyori</shadedPattern> <shadedPattern>com.artemis.the.gr8.lib.kyori</shadedPattern>
</relocation> </relocation>
<relocation> <relocation>
<pattern>com.tchristofferson</pattern> <pattern>com.tchristofferson</pattern>
<shadedPattern>com.github.artemis.the.gr8.util.tchristofferson</shadedPattern> <shadedPattern>com.artemis.the.gr8.util.tchristofferson</shadedPattern>
</relocation> </relocation>
<relocation> <relocation>
<pattern>org.bstats</pattern> <pattern>org.bstats</pattern>
<shadedPattern>com.github.artemis.the.gr8.util.bstats</shadedPattern> <shadedPattern>com.artemis.the.gr8.util.bstats</shadedPattern>
</relocation> </relocation>
</relocations> </relocations>
<filters> <filters>
@ -226,7 +226,7 @@
<groups> <groups>
<group> <group>
<title>API</title> <title>API</title>
<packages>com.github.artemis.the.gr8.playerstats.api</packages> <packages>com.artemis.the.gr8.playerstats.api</packages>
</group> </group>
</groups> </groups>
<detectLinks>true</detectLinks> <detectLinks>true</detectLinks>

View File

@ -1,20 +1,20 @@
package com.github.artemis.the.gr8.playerstats; package com.artemis.the.gr8.playerstats;
import com.github.artemis.the.gr8.playerstats.api.PlayerStats; import com.artemis.the.gr8.playerstats.api.PlayerStats;
import com.github.artemis.the.gr8.playerstats.msg.OutputManager; import com.artemis.the.gr8.playerstats.msg.OutputManager;
import com.github.artemis.the.gr8.playerstats.api.PlayerStatsAPI; import com.artemis.the.gr8.playerstats.api.PlayerStatsAPI;
import com.github.artemis.the.gr8.playerstats.commands.ReloadCommand; import com.artemis.the.gr8.playerstats.commands.ReloadCommand;
import com.github.artemis.the.gr8.playerstats.commands.ShareCommand; import com.artemis.the.gr8.playerstats.commands.ShareCommand;
import com.github.artemis.the.gr8.playerstats.commands.StatCommand; import com.artemis.the.gr8.playerstats.commands.StatCommand;
import com.github.artemis.the.gr8.playerstats.commands.TabCompleter; import com.artemis.the.gr8.playerstats.commands.TabCompleter;
import com.github.artemis.the.gr8.playerstats.config.ConfigHandler; import com.artemis.the.gr8.playerstats.config.ConfigHandler;
import com.github.artemis.the.gr8.playerstats.listeners.JoinListener; import com.artemis.the.gr8.playerstats.listeners.JoinListener;
import com.github.artemis.the.gr8.playerstats.msg.InternalFormatter; import com.artemis.the.gr8.playerstats.msg.InternalFormatter;
import com.github.artemis.the.gr8.playerstats.msg.MessageBuilder; import com.artemis.the.gr8.playerstats.msg.MessageBuilder;
import com.github.artemis.the.gr8.playerstats.msg.msgutils.LanguageKeyHandler; import com.artemis.the.gr8.playerstats.msg.msgutils.LanguageKeyHandler;
import com.github.artemis.the.gr8.playerstats.statistic.StatCalculator; import com.artemis.the.gr8.playerstats.statistic.StatCalculator;
import com.github.artemis.the.gr8.playerstats.utils.EnumHandler; import com.artemis.the.gr8.playerstats.utils.EnumHandler;
import com.github.artemis.the.gr8.playerstats.utils.OfflinePlayerHandler; import com.artemis.the.gr8.playerstats.utils.OfflinePlayerHandler;
import me.clip.placeholderapi.PlaceholderAPIPlugin; import me.clip.placeholderapi.PlaceholderAPIPlugin;
import me.clip.placeholderapi.expansion.PlaceholderExpansion; import me.clip.placeholderapi.expansion.PlaceholderExpansion;
import net.kyori.adventure.platform.bukkit.BukkitAudiences; import net.kyori.adventure.platform.bukkit.BukkitAudiences;

View File

@ -1,8 +1,8 @@
package com.github.artemis.the.gr8.playerstats; package com.artemis.the.gr8.playerstats;
import com.github.artemis.the.gr8.playerstats.statistic.result.InternalStatResult; import com.artemis.the.gr8.playerstats.statistic.result.InternalStatResult;
import com.github.artemis.the.gr8.playerstats.config.ConfigHandler; import com.artemis.the.gr8.playerstats.config.ConfigHandler;
import com.github.artemis.the.gr8.playerstats.utils.MyLogger; import com.artemis.the.gr8.playerstats.utils.MyLogger;
import net.kyori.adventure.text.TextComponent; import net.kyori.adventure.text.TextComponent;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
import org.bukkit.command.ConsoleCommandSender; import org.bukkit.command.ConsoleCommandSender;

View File

@ -1,13 +1,13 @@
package com.github.artemis.the.gr8.playerstats; package com.artemis.the.gr8.playerstats;
import com.github.artemis.the.gr8.playerstats.msg.OutputManager; import com.artemis.the.gr8.playerstats.msg.OutputManager;
import com.github.artemis.the.gr8.playerstats.config.ConfigHandler; import com.artemis.the.gr8.playerstats.config.ConfigHandler;
import com.github.artemis.the.gr8.playerstats.enums.StandardMessage; import com.artemis.the.gr8.playerstats.enums.StandardMessage;
import com.github.artemis.the.gr8.playerstats.statistic.request.RequestSettings; import com.artemis.the.gr8.playerstats.statistic.request.RequestSettings;
import com.github.artemis.the.gr8.playerstats.reload.ReloadThread; import com.artemis.the.gr8.playerstats.reload.ReloadThread;
import com.github.artemis.the.gr8.playerstats.statistic.StatCalculator; import com.artemis.the.gr8.playerstats.statistic.StatCalculator;
import com.github.artemis.the.gr8.playerstats.statistic.StatThread; import com.artemis.the.gr8.playerstats.statistic.StatThread;
import com.github.artemis.the.gr8.playerstats.utils.MyLogger; import com.artemis.the.gr8.playerstats.utils.MyLogger;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
import java.util.HashMap; import java.util.HashMap;

View File

@ -1,9 +1,9 @@
package com.github.artemis.the.gr8.playerstats.api; package com.artemis.the.gr8.playerstats.api;
import com.github.artemis.the.gr8.playerstats.enums.Unit; import com.artemis.the.gr8.playerstats.enums.Unit;
import com.github.artemis.the.gr8.playerstats.msg.components.ComponentUtils; import com.artemis.the.gr8.playerstats.msg.components.ComponentUtils;
import com.github.artemis.the.gr8.playerstats.msg.msgutils.NumberFormatter; import com.artemis.the.gr8.playerstats.msg.msgutils.NumberFormatter;
import com.github.artemis.the.gr8.playerstats.statistic.result.StatResult; import com.artemis.the.gr8.playerstats.statistic.result.StatResult;
import net.kyori.adventure.text.TextComponent; import net.kyori.adventure.text.TextComponent;
import org.bukkit.Statistic; import org.bukkit.Statistic;
import org.jetbrains.annotations.Nullable; import org.jetbrains.annotations.Nullable;
@ -20,8 +20,9 @@ public interface ApiFormatter {
/** /**
* Turns a TextComponent into its String representation. This method is equipped * Turns a TextComponent into its String representation. This method is equipped
* to turn all PlayerStats' formatted statResults into String. * to turn all PlayerStats' formatted statResults into String, using a custom
* Serializer.
*
* @param component the Component to turn into String * @param component the Component to turn into String
* @return a String representation of this TextComponent, without hover/click events, * @return a String representation of this TextComponent, without hover/click events,
* but with color, style and formatting. TranslatableComponents will be turned into * but with color, style and formatting. TranslatableComponents will be turned into
@ -34,7 +35,7 @@ public interface ApiFormatter {
/** /**
* Gets a {@link NumberFormatter} to format raw numbers into something more readable. * Gets a {@link NumberFormatter} to format raw numbers into something more readable.
*
* @return the <code>NumberFormatter</code> * @return the <code>NumberFormatter</code>
*/ */
default NumberFormatter getNumberFormatter() { default NumberFormatter getNumberFormatter() {
@ -56,13 +57,13 @@ public interface ApiFormatter {
/** /**
* Gets the version of the prefix that is surrounded by underscores. * Gets the version of the prefix that is surrounded by underscores.
* This is meant to be used as a title above a message or statistic display. * This is meant to be used as a title above a message or statistic display.
* @return ________ [PlayerStats] ________ * @return ________ [PlayerStats] ________
*/ */
TextComponent getPluginPrefixAsTitle(); TextComponent getPluginPrefixAsTitle();
/** /**
* Gets the special rainbow version of the title-prefix. * Gets the special rainbow version of the title-prefix.
*
* @return ________ [PlayerStats] ________ in rainbow colors * @return ________ [PlayerStats] ________ in rainbow colors
*/ */
TextComponent getRainbowPluginPrefixAsTitle(); TextComponent getRainbowPluginPrefixAsTitle();
@ -71,7 +72,7 @@ public interface ApiFormatter {
* Gets a formatted message that displays the name of this Statistic as it is * Gets a formatted message that displays the name of this Statistic as it is
* displayed by PlayerStats. If this Statistic is not of Type.Untyped, * displayed by PlayerStats. If this Statistic is not of Type.Untyped,
* include the name of the relevant sub-statistic (block, item or entity). * include the name of the relevant sub-statistic (block, item or entity).
*
* @param statistic the Statistic enum constant to display the name of * @param statistic the Statistic enum constant to display the name of
* @param subStatName where necessary, the name of the Material or EntityType * @param subStatName where necessary, the name of the Material or EntityType
* to include, acquired by doing #toString() on the Material/EntityType in question * to include, acquired by doing #toString() on the Material/EntityType in question
@ -84,7 +85,7 @@ public interface ApiFormatter {
* displayed by PlayerStats in a top-stat-message. If this Statistic is not * displayed by PlayerStats in a top-stat-message. If this Statistic is not
* of Type.Untyped, include the name of the relevant sub-statistic * of Type.Untyped, include the name of the relevant sub-statistic
* (block, item or entity). * (block, item or entity).
*
* @param statistic the Statistic enum constant for this message * @param statistic the Statistic enum constant for this message
* @param subStatName the name of the Material or EntityType to include, * @param subStatName the name of the Material or EntityType to include,
* acquired by doing #toString() on the Material/EntityType in question * acquired by doing #toString() on the Material/EntityType in question
@ -99,7 +100,7 @@ public interface ApiFormatter {
* Statistic. For Type.Time, the resulting formatted number will have as * Statistic. For Type.Time, the resulting formatted number will have as
* many additional smaller units as are specified in the config, * many additional smaller units as are specified in the config,
* unless <code>formatTopStatLineForTypeTime()</code> is used. * unless <code>formatTopStatLineForTypeTime()</code> is used.
*
* @param positionInTopList the rank-number in this list of the Player * @param positionInTopList the rank-number in this list of the Player
* @param playerName the name of the Player on this line * @param playerName the name of the Player on this line
* @param statNumber the result of Player#getStatistic() * @param statNumber the result of Player#getStatistic()
@ -115,7 +116,7 @@ public interface ApiFormatter {
* resulting formatted number will have as many additional smaller * resulting formatted number will have as many additional smaller
* units as are specified in the config, unless * units as are specified in the config, unless
* <code>formatTopStatLineForTypeTime()</code> is used. * <code>formatTopStatLineForTypeTime()</code> is used.
*
* @param positionInTopList the rank-number in this list of the Player * @param positionInTopList the rank-number in this list of the Player
* @param playerName the name of the Player on this line * @param playerName the name of the Player on this line
* @param statNumber the result of Player#getStatistic() * @param statNumber the result of Player#getStatistic()
@ -129,7 +130,7 @@ public interface ApiFormatter {
* Formats the input into a single top-statistic line for a time-based * Formats the input into a single top-statistic line for a time-based
* statistic with the Unit-range that is between <code>bigUnit</code> * statistic with the Unit-range that is between <code>bigUnit</code>
* and <code>smallUnit</code> (both inclusive). * and <code>smallUnit</code> (both inclusive).
*
* @param positionInTopList the rank-number in this list of the Player * @param positionInTopList the rank-number in this list of the Player
* @param playerName the name of the Player on this line * @param playerName the name of the Player on this line
* @param statNumber the result of Player#getStatistic() * @param statNumber the result of Player#getStatistic()
@ -146,7 +147,7 @@ public interface ApiFormatter {
* Statistic. For Type.Time, the resulting formatted number will have as * Statistic. For Type.Time, the resulting formatted number will have as
* many additional smaller units as are specified in the config, * many additional smaller units as are specified in the config,
* unless <code>formatServerStatForTypeTime()</code> is used. * unless <code>formatServerStatForTypeTime()</code> is used.
*
* @param statNumber the result of all Player#getStatistic() values combined * @param statNumber the result of all Player#getStatistic() values combined
* @param statistic te Statistic enum constant for this message * @param statistic te Statistic enum constant for this message
* @return [Total on this server]: [stat-number] [stat-name] * @return [Total on this server]: [stat-number] [stat-name]
@ -156,7 +157,7 @@ public interface ApiFormatter {
/** /**
* Formats the input into a server statistic message for a statistic * Formats the input into a server statistic message for a statistic
* that has a sub-statistic (block, item or entity). * that has a sub-statistic (block, item or entity).
*
* @param statistic the Statistic enum constant for this message * @param statistic the Statistic enum constant for this message
* @param statNumber the result of all Player#getStatistic() values combined * @param statNumber the result of all Player#getStatistic() values combined
* @param subStatName the name of the Material or EntityType of this * @param subStatName the name of the Material or EntityType of this
@ -173,7 +174,7 @@ public interface ApiFormatter {
* resulting formatted number will have as many additional smaller * resulting formatted number will have as many additional smaller
* units as are specified in the config, unless * units as are specified in the config, unless
* <code>formatServerStatForTypeTime()</code> is used. * <code>formatServerStatForTypeTime()</code> is used.
*
* @param statistic the Statistic enum constant for this message * @param statistic the Statistic enum constant for this message
* @param statNumber the result of all Player#getStatistic() values combined * @param statNumber the result of all Player#getStatistic() values combined
* @param unit the Unit to use to format te <code>statNumber</code> * @param unit the Unit to use to format te <code>statNumber</code>
@ -185,7 +186,7 @@ public interface ApiFormatter {
* Formats the input into a server statistic message for a time-based * Formats the input into a server statistic message for a time-based
* statistic with the Unit-range that is between <code>bigUnit</code> * statistic with the Unit-range that is between <code>bigUnit</code>
* and <code>smallUnit</code> (both inclusive). * and <code>smallUnit</code> (both inclusive).
*
* @param statistic the Statistic enum constant for this message * @param statistic the Statistic enum constant for this message
* @param statNumber the result of all Player#getStatistic() values combined * @param statNumber the result of all Player#getStatistic() values combined
* @param bigUnit the biggest Unit to use of {@link Unit.Type#TIME} * @param bigUnit the biggest Unit to use of {@link Unit.Type#TIME}
@ -199,7 +200,7 @@ public interface ApiFormatter {
* the resulting formatted number will have as many additional smaller * the resulting formatted number will have as many additional smaller
* units as are specified in the config, unless * units as are specified in the config, unless
* <code>formatPlayerStatForTypeTime</code> is used. * <code>formatPlayerStatForTypeTime</code> is used.
*
* @param playerName the name of the Player * @param playerName the name of the Player
* @param statistic the Statistic enum constant for this message * @param statistic the Statistic enum constant for this message
* @param statNumber the result of Player#getStatistic() * @param statNumber the result of Player#getStatistic()
@ -210,7 +211,7 @@ public interface ApiFormatter {
/** /**
* Formats the input into a player statistic message for a statistic * Formats the input into a player statistic message for a statistic
* that has a sub-statistic (block, item or entity). * that has a sub-statistic (block, item or entity).
*
* @param playerName the name of the Player * @param playerName the name of the Player
* @param statistic the Statistic enum constant for this message * @param statistic the Statistic enum constant for this message
* @param statNumber the result of Player#getStatistic() * @param statNumber the result of Player#getStatistic()
@ -226,7 +227,7 @@ public interface ApiFormatter {
* {@link Unit}. For Unit.Type.Time, the resulting formatted number will * {@link Unit}. For Unit.Type.Time, the resulting formatted number will
* have as many additional smaller units as are specified in the config, * have as many additional smaller units as are specified in the config,
* unless <code>formatPlayerStatForTypeTime</code> is used. * unless <code>formatPlayerStatForTypeTime</code> is used.
*
* @param playerName the name of the Player * @param playerName the name of the Player
* @param statistic the Statistic enum constant for this message * @param statistic the Statistic enum constant for this message
* @param statNumber the result of Player#getStatistic() * @param statNumber the result of Player#getStatistic()
@ -239,7 +240,7 @@ public interface ApiFormatter {
* Formats the input into a player statistic message for a time-based * Formats the input into a player statistic message for a time-based
* statistic with the Unit-range that is between <code>bigUnit</code> * statistic with the Unit-range that is between <code>bigUnit</code>
* and <code>smallUnit</code> (both inclusive). * and <code>smallUnit</code> (both inclusive).
*
* @param playerName the name of the Player * @param playerName the name of the Player
* @param statNumber the result of Player#getStatistic() * @param statNumber the result of Player#getStatistic()
* @param statistic the Statistic enum constant for this message * @param statistic the Statistic enum constant for this message

View File

@ -1,20 +1,23 @@
package com.github.artemis.the.gr8.playerstats.api; package com.artemis.the.gr8.playerstats.api;
import com.github.artemis.the.gr8.playerstats.Main; import com.artemis.the.gr8.playerstats.Main;
import com.github.artemis.the.gr8.playerstats.statistic.request.StatRequest; import com.artemis.the.gr8.playerstats.statistic.request.StatRequest;
import org.jetbrains.annotations.Contract; import org.jetbrains.annotations.Contract;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
/** /**
* The outgoing API that represents the core functionality of PlayerStats! * The outgoing API that represents the core functionality of PlayerStats!
* *
* <p> To work with it, you'll need to call PlayerStats.{@link #getAPI()} to get an instance of * <p> To work with it, you'll need to call PlayerStats.{@link #getAPI()} and get an instance of
* {@link PlayerStatsAPI}. You can then use this object to access any of the further methods. * {@link PlayerStatsAPI}. You can then use this object to access any of the further methods.
* <br> *
* <br>Since calculating a top or server statistics can take some time, I strongly * <p> Since calculating a top or server statistics can take some time, I strongly
* encourage you to call {@link StatRequest#execute()} asynchronously. * encourage you to call {@link StatRequest#execute()} asynchronously.
* Otherwise, the main Thread will have to wait until all calculations are done, * Otherwise, the main Thread will have to wait until all calculations are done,
* and this can severely impact server performance. * and this can severely impact server performance.
*
* @see StatManager
* @see ApiFormatter
*/ */
public interface PlayerStats { public interface PlayerStats {

View File

@ -1,7 +1,7 @@
package com.github.artemis.the.gr8.playerstats.api; package com.artemis.the.gr8.playerstats.api;
import com.github.artemis.the.gr8.playerstats.statistic.request.*; import com.artemis.the.gr8.playerstats.statistic.request.*;
import com.github.artemis.the.gr8.playerstats.utils.OfflinePlayerHandler; import com.artemis.the.gr8.playerstats.utils.OfflinePlayerHandler;
import static org.jetbrains.annotations.ApiStatus.Internal; import static org.jetbrains.annotations.ApiStatus.Internal;

View File

@ -1,33 +1,39 @@
package com.github.artemis.the.gr8.playerstats.api; package com.artemis.the.gr8.playerstats.api;
import com.github.artemis.the.gr8.playerstats.statistic.StatCalculator; import com.artemis.the.gr8.playerstats.statistic.StatCalculator;
import com.github.artemis.the.gr8.playerstats.statistic.request.StatRequest; import com.artemis.the.gr8.playerstats.statistic.request.StatRequest;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.Statistic; import org.bukkit.Statistic;
import org.bukkit.entity.EntityType; import org.bukkit.entity.EntityType;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
/** Creates an executable {@link StatRequest}. This Request holds all /**
* Creates an executable {@link StatRequest}. This Request holds all
* the information PlayerStats needs to work with, and is used by the {@link StatCalculator} * the information PlayerStats needs to work with, and is used by the {@link StatCalculator}
* to get the desired statistic data.*/ * to get the desired statistic data.
*/
public interface RequestGenerator<T> { public interface RequestGenerator<T> {
/** Gets an executable Request object for a Statistic of Statistic.Type {@code Untyped}. /**
* Gets an executable Request object for a Statistic of Statistic.Type {@code Untyped}.
*
* @param statistic a Statistic of Type.Untyped * @param statistic a Statistic of Type.Untyped
* @return a {@link StatRequest} * @return a {@link StatRequest}
* @throws IllegalArgumentException if <code>statistic</code> is not of Type.Untyped*/ * @throws IllegalArgumentException if <code>statistic</code> is not of Type.Untyped
* */
StatRequest<T> untyped(@NotNull Statistic statistic) throws IllegalArgumentException; StatRequest<T> untyped(@NotNull Statistic statistic) throws IllegalArgumentException;
/** Gets an executable Request object for a Statistic of Statistic.Type Block or Item. /**
* Gets an executable Request object for a Statistic of Statistic.Type Block or Item.
*
* @param statistic a Statistic of Type.Block or Type.Item * @param statistic a Statistic of Type.Block or Type.Item
* @param material a block if the <code>statistic</code> is of Type.Block, * @param material a block if the <code>statistic</code> is of Type.Block,
* and an item if the <code>statistic</code> is of Type.Item * and an item if the <code>statistic</code> is of Type.Item
* @return a {@link StatRequest} * @return a {@link StatRequest}
* @throws IllegalArgumentException if <code>statistic</code> is not of Type.Block * @throws IllegalArgumentException if <code>statistic</code> is not of Type.Block
* (with a block as <code>material</code>), or <code>statistic</code> is not of Type.Item * (with a block as <code>material</code>), or <code>statistic</code> is not of Type.Item
* (with an item as <code>material</code>) */ * (with an item as <code>material</code>)
*/
StatRequest<T> blockOrItemType(@NotNull Statistic statistic, @NotNull Material material) throws IllegalArgumentException; StatRequest<T> blockOrItemType(@NotNull Statistic statistic, @NotNull Material material) throws IllegalArgumentException;
/** Gets an executable Request object for a Statistic of Statistic.Type Entity. /** Gets an executable Request object for a Statistic of Statistic.Type Entity.

View File

@ -1,6 +1,7 @@
package com.github.artemis.the.gr8.playerstats.api; package com.artemis.the.gr8.playerstats.api;
import com.artemis.the.gr8.playerstats.statistic.request.StatRequest;
import com.github.artemis.the.gr8.playerstats.statistic.request.StatRequest;
import java.util.LinkedHashMap; import java.util.LinkedHashMap;
/** /**

View File

@ -0,0 +1,4 @@
/**
* The PlayerStats API
*/
package com.artemis.the.gr8.playerstats.api;

View File

@ -1,6 +1,6 @@
package com.github.artemis.the.gr8.playerstats.commands; package com.artemis.the.gr8.playerstats.commands;
import com.github.artemis.the.gr8.playerstats.ThreadManager; import com.artemis.the.gr8.playerstats.ThreadManager;
import org.bukkit.command.Command; import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor; import org.bukkit.command.CommandExecutor;

View File

@ -1,10 +1,10 @@
package com.github.artemis.the.gr8.playerstats.commands; package com.artemis.the.gr8.playerstats.commands;
import com.github.artemis.the.gr8.playerstats.ShareManager; import com.artemis.the.gr8.playerstats.ShareManager;
import com.github.artemis.the.gr8.playerstats.enums.StandardMessage; import com.artemis.the.gr8.playerstats.enums.StandardMessage;
import com.github.artemis.the.gr8.playerstats.msg.OutputManager; import com.artemis.the.gr8.playerstats.msg.OutputManager;
import com.github.artemis.the.gr8.playerstats.statistic.result.InternalStatResult; import com.artemis.the.gr8.playerstats.statistic.result.InternalStatResult;
import com.github.artemis.the.gr8.playerstats.utils.MyLogger; import com.artemis.the.gr8.playerstats.utils.MyLogger;
import org.bukkit.command.Command; import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor; import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;

View File

@ -1,11 +1,11 @@
package com.github.artemis.the.gr8.playerstats.commands; package com.artemis.the.gr8.playerstats.commands;
import com.github.artemis.the.gr8.playerstats.ThreadManager; import com.artemis.the.gr8.playerstats.ThreadManager;
import com.github.artemis.the.gr8.playerstats.enums.StandardMessage; import com.artemis.the.gr8.playerstats.enums.StandardMessage;
import com.github.artemis.the.gr8.playerstats.enums.Target; import com.artemis.the.gr8.playerstats.enums.Target;
import com.github.artemis.the.gr8.playerstats.msg.OutputManager; import com.artemis.the.gr8.playerstats.msg.OutputManager;
import com.github.artemis.the.gr8.playerstats.statistic.request.RequestHandler; import com.artemis.the.gr8.playerstats.statistic.request.RequestHandler;
import com.github.artemis.the.gr8.playerstats.statistic.request.RequestSettings; import com.artemis.the.gr8.playerstats.statistic.request.RequestSettings;
import org.bukkit.Statistic; import org.bukkit.Statistic;
import org.bukkit.command.Command; import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor; import org.bukkit.command.CommandExecutor;
@ -47,9 +47,9 @@ public final class StatCommand implements CommandExecutor {
} }
/** /**
* If a given {@link RequestSettings} does not result in a valid statistic look-up, * If a given {@link RequestSettings} object does not result in a valid
* this will send a feedback message to the CommandSender that made the request. * statistic look-up, this will send a feedback message to the CommandSender
* <br> The following is checked: * that made the request. The following is checked:
* <ul> * <ul>
* <li>Is a <code>statistic</code> set? * <li>Is a <code>statistic</code> set?
* <li>Is a <code>subStatEntry</code> needed, and if so, is a corresponding Material/EntityType present? * <li>Is a <code>subStatEntry</code> needed, and if so, is a corresponding Material/EntityType present?

View File

@ -1,8 +1,8 @@
package com.github.artemis.the.gr8.playerstats.commands; package com.artemis.the.gr8.playerstats.commands;
import com.github.artemis.the.gr8.playerstats.utils.EnumHandler; import com.artemis.the.gr8.playerstats.utils.EnumHandler;
import com.github.artemis.the.gr8.playerstats.utils.OfflinePlayerHandler; import com.artemis.the.gr8.playerstats.utils.OfflinePlayerHandler;
import com.github.artemis.the.gr8.playerstats.commands.cmdutils.TabCompleteHelper; import com.artemis.the.gr8.playerstats.commands.cmdutils.TabCompleteHelper;
import org.bukkit.Statistic; import org.bukkit.Statistic;
import org.bukkit.command.Command; import org.bukkit.command.Command;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;

View File

@ -1,6 +1,6 @@
package com.github.artemis.the.gr8.playerstats.commands.cmdutils; package com.artemis.the.gr8.playerstats.commands.cmdutils;
import com.github.artemis.the.gr8.playerstats.utils.EnumHandler; import com.artemis.the.gr8.playerstats.utils.EnumHandler;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.entity.EntityType; import org.bukkit.entity.EntityType;

View File

@ -1,9 +1,9 @@
package com.github.artemis.the.gr8.playerstats.config; package com.artemis.the.gr8.playerstats.config;
import com.github.artemis.the.gr8.playerstats.Main; import com.artemis.the.gr8.playerstats.Main;
import com.github.artemis.the.gr8.playerstats.enums.Target; import com.artemis.the.gr8.playerstats.enums.Target;
import com.github.artemis.the.gr8.playerstats.enums.Unit; import com.artemis.the.gr8.playerstats.enums.Unit;
import com.github.artemis.the.gr8.playerstats.utils.MyLogger; import com.artemis.the.gr8.playerstats.utils.MyLogger;
import org.bukkit.configuration.ConfigurationSection; import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.configuration.file.FileConfiguration; import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.configuration.file.YamlConfiguration; import org.bukkit.configuration.file.YamlConfiguration;

View File

@ -1,7 +1,7 @@
package com.github.artemis.the.gr8.playerstats.config; package com.artemis.the.gr8.playerstats.config;
import com.github.artemis.the.gr8.playerstats.Main; import com.artemis.the.gr8.playerstats.Main;
import com.github.artemis.the.gr8.playerstats.utils.MyLogger; import com.artemis.the.gr8.playerstats.utils.MyLogger;
import org.bukkit.configuration.file.YamlConfiguration; import org.bukkit.configuration.file.YamlConfiguration;
import java.io.File; import java.io.File;

View File

@ -1,4 +1,4 @@
package com.github.artemis.the.gr8.playerstats.enums; package com.artemis.the.gr8.playerstats.enums;
/** /**
* Represents the debugging level that PlayerStats can use. * Represents the debugging level that PlayerStats can use.

View File

@ -1,4 +1,4 @@
package com.github.artemis.the.gr8.playerstats.enums; package com.artemis.the.gr8.playerstats.enums;
import net.kyori.adventure.text.format.NamedTextColor; import net.kyori.adventure.text.format.NamedTextColor;
import net.kyori.adventure.text.format.TextColor; import net.kyori.adventure.text.format.TextColor;

View File

@ -1,4 +1,4 @@
package com.github.artemis.the.gr8.playerstats.enums; package com.artemis.the.gr8.playerstats.enums;
/** /**
* All standard messages PlayerStats can send as feedback. * All standard messages PlayerStats can send as feedback.

View File

@ -1,4 +1,4 @@
package com.github.artemis.the.gr8.playerstats.enums; package com.artemis.the.gr8.playerstats.enums;
/** /**
* This enum represents the targets PlayerStats accepts * This enum represents the targets PlayerStats accepts

View File

@ -1,10 +1,11 @@
package com.github.artemis.the.gr8.playerstats.enums; package com.artemis.the.gr8.playerstats.enums;
import org.bukkit.Statistic; import org.bukkit.Statistic;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
/** /**
* All the units PlayerStats can display statistics in, separated by Type. * All the units PlayerStats can display statistics in, separated
* by {@link Unit.Type}.
*/ */
public enum Unit { public enum Unit {
NUMBER (Type.UNTYPED, "Times"), NUMBER (Type.UNTYPED, "Times"),
@ -29,26 +30,31 @@ public enum Unit {
} }
/** /**
* Returns a pretty name belonging to this enum constant. If the Unit is * Gets the pretty name belonging to this enum constant.
* NUMBER, it will return null. *
* @return the label
*/ */
public String getLabel() { public String getLabel() {
return this.label; return this.label;
} }
/** /**
* Returns the Type this enum constant belongs to. * Gets the Type this enum constant belongs to.
*
* @return the Type
*/ */
public Type getType() { public Type getType() {
return this.type; return this.type;
} }
/** /**
* For Type Time, Damage and Distance, this will return a smaller Unit than the current one * For Type Time, Damage and Distance, this will return a smaller Unit
* (if there is a smaller Unit, that is, otherwise it will return itself). * than the current one (if there is a smaller Unit, that is, otherwise
* So for DAY, for example, it can return HOUR, MINUTE or SECOND. * it will return itself). So for DAY, for example, it can return HOUR,
* MINUTE or SECOND.
* *
* @param stepsSmaller how many steps smaller the returned Unit should be * @param stepsSmaller how many steps smaller the returned Unit should be
* @return the smaller Unit
*/ */
public Unit getSmallerUnit(int stepsSmaller) { public Unit getSmallerUnit(int stepsSmaller) {
switch (this) { switch (this) {
@ -110,7 +116,9 @@ public enum Unit {
/** /**
* Converts the current Unit into seconds (and returns * Converts the current Unit into seconds (and returns
* -1 if the current Unit is not of Type TIME) * -1 if the current Unit is not of {@link Unit.Type} TIME).
*
* @return this Unit in seconds
*/ */
public double getSeconds() { public double getSeconds() {
return switch (this) { return switch (this) {
@ -124,11 +132,13 @@ public enum Unit {
} }
/** /**
* Returns the Unit corresponding to the given String. This String does NOT need to * Gets the Unit corresponding to the given String. This String
* match exactly (it can be "day" or "days", for example), and is case-insensitive. * does not need to match exactly (it can be "day" or "days",
* for example), and is case-insensitive.
* *
* @param unitName an approximation of the name belonging to the desired Unit, * @param unitName the name belonging to the desired Unit,
* case-insensitive * case-insensitive
* @return the Unit
*/ */
public static @NotNull Unit fromString(@NotNull String unitName) { public static @NotNull Unit fromString(@NotNull String unitName) {
return switch (unitName.toLowerCase()) { return switch (unitName.toLowerCase()) {
@ -148,10 +158,11 @@ public enum Unit {
} }
/** /**
* Returns the Unit.Type of this Statistic, which can be Untyped, * Gets the Unit.Type of this Statistic, which can be Untyped,
* Distance, Damage, or Time. * Distance, Damage, or Time.
* *
* @param statistic the Statistic enum constant * @param statistic the Statistic enum constant
* @return the Type of this Unit
*/ */
public static @NotNull Type getTypeFromStatistic(Statistic statistic) { public static @NotNull Type getTypeFromStatistic(Statistic statistic) {
String name = statistic.toString().toLowerCase(); String name = statistic.toString().toLowerCase();
@ -167,10 +178,11 @@ public enum Unit {
} }
/** /**
* Returns the most suitable Unit for this number. * Gets the most suitable Unit for this number.
* *
* @param type the Unit.Type of the statistic this number belongs to * @param type the Unit.Type of the statistic this number belongs to
* @param number the statistic number as returned by Player.getStatistic() * @param number the statistic number as returned by Player.getStatistic()
* @return the Unit
*/ */
public static Unit getMostSuitableUnit(Unit.Type type, long number) { public static Unit getMostSuitableUnit(Unit.Type type, long number) {
switch (type) { switch (type) {

View File

@ -1,6 +1,6 @@
package com.github.artemis.the.gr8.playerstats.listeners; package com.artemis.the.gr8.playerstats.listeners;
import com.github.artemis.the.gr8.playerstats.ThreadManager; import com.artemis.the.gr8.playerstats.ThreadManager;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener; import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerJoinEvent; import org.bukkit.event.player.PlayerJoinEvent;

View File

@ -1,16 +1,17 @@
package com.github.artemis.the.gr8.playerstats.msg; package com.artemis.the.gr8.playerstats.msg;
import com.github.artemis.the.gr8.playerstats.statistic.request.RequestSettings; import com.artemis.the.gr8.playerstats.statistic.request.RequestSettings;
import com.github.artemis.the.gr8.playerstats.statistic.StatCalculator; import com.artemis.the.gr8.playerstats.statistic.StatCalculator;
import net.kyori.adventure.text.*; import net.kyori.adventure.text.*;
import org.jetbrains.annotations.ApiStatus.Internal; import org.jetbrains.annotations.ApiStatus.Internal;
import java.util.LinkedHashMap; import java.util.LinkedHashMap;
/** The {@link InternalFormatter} formats raw numbers into pretty messages. /** The {@link InternalFormatter} formats raw numbers into pretty messages.
* This ApiFormatter takes a {@link RequestSettings} object and combines it with the raw data * This Formatter takes a {@link RequestSettings} object and combines it
* returned by the {@link StatCalculator}, and transforms those into a pretty message * with the raw data returned by the {@link StatCalculator}, and transforms
* with all the relevant information in it. * those into a pretty message with all the relevant information in it.
* @see MessageBuilder
*/ */
@Internal @Internal
public interface InternalFormatter { public interface InternalFormatter {

View File

@ -1,19 +1,20 @@
package com.github.artemis.the.gr8.playerstats.msg; package com.artemis.the.gr8.playerstats.msg;
import com.github.artemis.the.gr8.playerstats.Main; import com.artemis.the.gr8.playerstats.Main;
import com.github.artemis.the.gr8.playerstats.api.ApiFormatter; import com.artemis.the.gr8.playerstats.api.ApiFormatter;
import com.github.artemis.the.gr8.playerstats.msg.components.ComponentFactory; import com.artemis.the.gr8.playerstats.msg.components.ComponentFactory;
import com.github.artemis.the.gr8.playerstats.msg.components.ExampleMessage; import com.artemis.the.gr8.playerstats.msg.components.ExampleMessage;
import com.github.artemis.the.gr8.playerstats.msg.components.HelpMessage; import com.artemis.the.gr8.playerstats.msg.components.HelpMessage;
import com.github.artemis.the.gr8.playerstats.msg.components.PrideComponentFactory; import com.artemis.the.gr8.playerstats.msg.components.BukkitConsoleComponentFactory;
import com.github.artemis.the.gr8.playerstats.msg.msgutils.*; import com.artemis.the.gr8.playerstats.msg.components.PrideComponentFactory;
import com.github.artemis.the.gr8.playerstats.utils.EnumHandler; import com.artemis.the.gr8.playerstats.msg.msgutils.*;
import com.github.artemis.the.gr8.playerstats.utils.MyLogger; import com.artemis.the.gr8.playerstats.utils.EnumHandler;
import com.github.artemis.the.gr8.playerstats.enums.Target; import com.artemis.the.gr8.playerstats.utils.MyLogger;
import com.github.artemis.the.gr8.playerstats.config.ConfigHandler; import com.artemis.the.gr8.playerstats.enums.Target;
import com.github.artemis.the.gr8.playerstats.enums.Unit; import com.artemis.the.gr8.playerstats.config.ConfigHandler;
import com.artemis.the.gr8.playerstats.enums.Unit;
import com.github.artemis.the.gr8.playerstats.statistic.request.RequestSettings; import com.artemis.the.gr8.playerstats.statistic.request.RequestSettings;
import net.kyori.adventure.text.Component; import net.kyori.adventure.text.Component;
import net.kyori.adventure.text.TextComponent; import net.kyori.adventure.text.TextComponent;
import org.bukkit.Statistic; import org.bukkit.Statistic;
@ -29,10 +30,13 @@ import static net.kyori.adventure.text.Component.*;
/** /**
* Composes messages to send to a Player or Console. This class is responsible * Composes messages to send to a Player or Console. This class is responsible
* for constructing a final Component with the text content of the desired message. * for constructing a final {@link TextComponent} with the text content of the
* The component parts (with appropriate formatting) are supplied by a * desired message. The component parts (with appropriate formatting) are supplied
* {@link ComponentFactory}. By default, this class works with the default * by a {@link ComponentFactory}. By default, this class works with the standard
* ComponentFactory, but you can give it a different ComponentFactory upon creation. * ComponentFactory, but you can give it a different ComponentFactory upon creation.
*
* @see PrideComponentFactory
* @see BukkitConsoleComponentFactory
*/ */
public final class MessageBuilder implements ApiFormatter { public final class MessageBuilder implements ApiFormatter {

View File

@ -1,11 +1,11 @@
package com.github.artemis.the.gr8.playerstats.msg; package com.artemis.the.gr8.playerstats.msg;
import com.github.artemis.the.gr8.playerstats.ShareManager; import com.artemis.the.gr8.playerstats.ShareManager;
import com.github.artemis.the.gr8.playerstats.config.ConfigHandler; import com.artemis.the.gr8.playerstats.config.ConfigHandler;
import com.github.artemis.the.gr8.playerstats.enums.StandardMessage; import com.artemis.the.gr8.playerstats.enums.StandardMessage;
import com.github.artemis.the.gr8.playerstats.statistic.request.RequestSettings; import com.artemis.the.gr8.playerstats.statistic.request.RequestSettings;
import com.github.artemis.the.gr8.playerstats.msg.components.BukkitConsoleComponentFactory; import com.artemis.the.gr8.playerstats.msg.components.BukkitConsoleComponentFactory;
import com.github.artemis.the.gr8.playerstats.msg.components.PrideComponentFactory; import com.artemis.the.gr8.playerstats.msg.components.PrideComponentFactory;
import net.kyori.adventure.platform.bukkit.BukkitAudiences; import net.kyori.adventure.platform.bukkit.BukkitAudiences;
import net.kyori.adventure.text.TextComponent; import net.kyori.adventure.text.TextComponent;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
@ -22,7 +22,7 @@ import java.util.LinkedHashMap;
import java.util.function.BiFunction; import java.util.function.BiFunction;
import java.util.function.Function; import java.util.function.Function;
import static com.github.artemis.the.gr8.playerstats.enums.StandardMessage.*; import static com.artemis.the.gr8.playerstats.enums.StandardMessage.*;
/** /**
* This class manages all PlayerStats output. It is the only * This class manages all PlayerStats output. It is the only
@ -30,7 +30,7 @@ import static com.github.artemis.the.gr8.playerstats.enums.StandardMessage.*;
* {@link MessageBuilder} configured for either a Console or * {@link MessageBuilder} configured for either a Console or
* for Players (mainly to deal with the lack of hover-text, * for Players (mainly to deal with the lack of hover-text,
* and for Bukkit consoles to make up for the lack of hex-colors). * and for Bukkit consoles to make up for the lack of hex-colors).
* */ */
public final class OutputManager implements InternalFormatter { public final class OutputManager implements InternalFormatter {
private static BukkitAudiences adventure; private static BukkitAudiences adventure;

View File

@ -1,7 +1,7 @@
package com.github.artemis.the.gr8.playerstats.msg.components; package com.artemis.the.gr8.playerstats.msg.components;
import com.github.artemis.the.gr8.playerstats.enums.PluginColor; import com.artemis.the.gr8.playerstats.enums.PluginColor;
import com.github.artemis.the.gr8.playerstats.config.ConfigHandler; import com.artemis.the.gr8.playerstats.config.ConfigHandler;
import net.kyori.adventure.text.TextComponent; import net.kyori.adventure.text.TextComponent;
import net.kyori.adventure.text.format.NamedTextColor; import net.kyori.adventure.text.format.NamedTextColor;
import net.kyori.adventure.text.format.TextColor; import net.kyori.adventure.text.format.TextColor;

View File

@ -1,11 +1,11 @@
package com.github.artemis.the.gr8.playerstats.msg.components; package com.artemis.the.gr8.playerstats.msg.components;
import com.github.artemis.the.gr8.playerstats.config.ConfigHandler; import com.artemis.the.gr8.playerstats.config.ConfigHandler;
import com.github.artemis.the.gr8.playerstats.enums.PluginColor; import com.artemis.the.gr8.playerstats.enums.PluginColor;
import com.github.artemis.the.gr8.playerstats.enums.Target; import com.artemis.the.gr8.playerstats.enums.Target;
import com.github.artemis.the.gr8.playerstats.enums.Unit; import com.artemis.the.gr8.playerstats.enums.Unit;
import com.github.artemis.the.gr8.playerstats.msg.MessageBuilder; import com.artemis.the.gr8.playerstats.msg.MessageBuilder;
import com.github.artemis.the.gr8.playerstats.msg.msgutils.LanguageKeyHandler; import com.artemis.the.gr8.playerstats.msg.msgutils.LanguageKeyHandler;
import net.kyori.adventure.text.Component; import net.kyori.adventure.text.Component;
import net.kyori.adventure.text.TextComponent; import net.kyori.adventure.text.TextComponent;
import net.kyori.adventure.text.TranslatableComponent; import net.kyori.adventure.text.TranslatableComponent;
@ -26,8 +26,10 @@ import static net.kyori.adventure.text.Component.*;
* {@link MessageBuilder} to build messages with. This class * {@link MessageBuilder} to build messages with. This class
* can put Strings into formatted Components with TextColor * can put Strings into formatted Components with TextColor
* and TextDecoration, or return empty Components with the * and TextDecoration, or return empty Components with the
* desired formatting. * desired formatting (as specified by the {@link ConfigHandler}).
* */ *
* @see PluginColor
*/
public class ComponentFactory { public class ComponentFactory {
private static ConfigHandler config; private static ConfigHandler config;

View File

@ -1,7 +1,7 @@
package com.github.artemis.the.gr8.playerstats.msg.components; package com.artemis.the.gr8.playerstats.msg.components;
import com.github.artemis.the.gr8.playerstats.msg.msgutils.LanguageKeyHandler; import com.artemis.the.gr8.playerstats.msg.msgutils.LanguageKeyHandler;
import com.github.artemis.the.gr8.playerstats.msg.msgutils.StringUtils; import com.artemis.the.gr8.playerstats.msg.msgutils.StringUtils;
import net.kyori.adventure.text.*; import net.kyori.adventure.text.*;
import net.kyori.adventure.text.flattener.ComponentFlattener; import net.kyori.adventure.text.flattener.ComponentFlattener;
import net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer; import net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer;
@ -17,6 +17,9 @@ public final class ComponentUtils {
* language-keys I am using to improve the entity-related statistic * language-keys I am using to improve the entity-related statistic
* names. This serializer will create a String with hex colors and styles, * names. This serializer will create a String with hex colors and styles,
* and it will turn language keys into prettified, readable English. * and it will turn language keys into prettified, readable English.
*
* @return the Serializer
* @see LanguageKeyHandler
*/ */
public static LegacyComponentSerializer getTranslatableComponentSerializer() { public static LegacyComponentSerializer getTranslatableComponentSerializer() {
LegacyComponentSerializer serializer = getTextComponentSerializer(); LegacyComponentSerializer serializer = getTextComponentSerializer();

View File

@ -1,4 +1,4 @@
package com.github.artemis.the.gr8.playerstats.msg.components; package com.artemis.the.gr8.playerstats.msg.components;
import net.kyori.adventure.text.Component; import net.kyori.adventure.text.Component;
import net.kyori.adventure.text.ComponentLike; import net.kyori.adventure.text.ComponentLike;

View File

@ -1,4 +1,4 @@
package com.github.artemis.the.gr8.playerstats.msg.components; package com.artemis.the.gr8.playerstats.msg.components;
import net.kyori.adventure.text.Component; import net.kyori.adventure.text.Component;
import net.kyori.adventure.text.ComponentLike; import net.kyori.adventure.text.ComponentLike;

View File

@ -1,8 +1,8 @@
package com.github.artemis.the.gr8.playerstats.msg.components; package com.artemis.the.gr8.playerstats.msg.components;
import com.github.artemis.the.gr8.playerstats.config.ConfigHandler; import com.artemis.the.gr8.playerstats.config.ConfigHandler;
import com.github.artemis.the.gr8.playerstats.enums.PluginColor; import com.artemis.the.gr8.playerstats.enums.PluginColor;
import net.kyori.adventure.text.TextComponent; import net.kyori.adventure.text.TextComponent;
import net.kyori.adventure.text.format.TextColor; import net.kyori.adventure.text.format.TextColor;
import net.kyori.adventure.text.minimessage.MiniMessage; import net.kyori.adventure.text.minimessage.MiniMessage;

View File

@ -1,4 +1,4 @@
package com.github.artemis.the.gr8.playerstats.msg.msgutils; package com.artemis.the.gr8.playerstats.msg.msgutils;
import me.clip.placeholderapi.PlaceholderAPI; import me.clip.placeholderapi.PlaceholderAPI;
import net.kyori.adventure.text.Component; import net.kyori.adventure.text.Component;

View File

@ -1,4 +1,4 @@
package com.github.artemis.the.gr8.playerstats.msg.msgutils; package com.artemis.the.gr8.playerstats.msg.msgutils;
import org.bukkit.map.MinecraftFont; import org.bukkit.map.MinecraftFont;

View File

@ -1,9 +1,9 @@
package com.github.artemis.the.gr8.playerstats.msg.msgutils; package com.artemis.the.gr8.playerstats.msg.msgutils;
import com.github.artemis.the.gr8.playerstats.Main; import com.artemis.the.gr8.playerstats.Main;
import com.github.artemis.the.gr8.playerstats.utils.EnumHandler; import com.artemis.the.gr8.playerstats.utils.EnumHandler;
import com.github.artemis.the.gr8.playerstats.utils.MyLogger; import com.artemis.the.gr8.playerstats.utils.MyLogger;
import com.github.artemis.the.gr8.playerstats.enums.Unit; import com.artemis.the.gr8.playerstats.enums.Unit;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.Statistic; import org.bukkit.Statistic;
import org.bukkit.configuration.file.FileConfiguration; import org.bukkit.configuration.file.FileConfiguration;
@ -30,6 +30,10 @@ public final class LanguageKeyHandler {
private static FileConfiguration languageKeys; private static FileConfiguration languageKeys;
/** /**
* Since this class uses a file to get the English translations
* of languageKeys, it needs an instance of the PlayerStats
* plugin to get access to this file.
*
* @param plugin an instance of PlayerStats' Main class * @param plugin an instance of PlayerStats' Main class
*/ */
public LanguageKeyHandler(Main plugin) { public LanguageKeyHandler(Main plugin) {

View File

@ -1,6 +1,6 @@
package com.github.artemis.the.gr8.playerstats.msg.msgutils; package com.artemis.the.gr8.playerstats.msg.msgutils;
import com.github.artemis.the.gr8.playerstats.enums.Unit; import com.artemis.the.gr8.playerstats.enums.Unit;
import java.text.DecimalFormat; import java.text.DecimalFormat;

View File

@ -1,6 +1,6 @@
package com.github.artemis.the.gr8.playerstats.msg.msgutils; package com.artemis.the.gr8.playerstats.msg.msgutils;
import com.github.artemis.the.gr8.playerstats.utils.MyLogger; import com.artemis.the.gr8.playerstats.utils.MyLogger;
/** /**
* A small utility class that helps make enum constant * A small utility class that helps make enum constant

View File

@ -1,8 +1,9 @@
package com.github.artemis.the.gr8.playerstats.reload; package com.artemis.the.gr8.playerstats.reload;
import com.github.artemis.the.gr8.playerstats.ThreadManager; import com.artemis.the.gr8.playerstats.ThreadManager;
import com.github.artemis.the.gr8.playerstats.utils.MyLogger; import com.artemis.the.gr8.playerstats.utils.MyLogger;
import com.github.artemis.the.gr8.playerstats.utils.UnixTimeHandler; import com.artemis.the.gr8.playerstats.utils.OfflinePlayerHandler;
import com.artemis.the.gr8.playerstats.utils.UnixTimeHandler;
import org.bukkit.OfflinePlayer; import org.bukkit.OfflinePlayer;
import java.util.UUID; import java.util.UUID;
@ -30,6 +31,7 @@ final class ReloadAction extends RecursiveAction {
* @param players array of all OfflinePlayers (straight from Bukkit) * @param players array of all OfflinePlayers (straight from Bukkit)
* @param lastPlayedLimit whether to set a limit based on last-played-date * @param lastPlayedLimit whether to set a limit based on last-played-date
* @param offlinePlayerUUIDs the ConcurrentHashMap to put playerNames and UUIDs in * @param offlinePlayerUUIDs the ConcurrentHashMap to put playerNames and UUIDs in
* @see OfflinePlayerHandler
*/ */
public ReloadAction(OfflinePlayer[] players, public ReloadAction(OfflinePlayer[] players,
int lastPlayedLimit, ConcurrentHashMap<String, UUID> offlinePlayerUUIDs) { int lastPlayedLimit, ConcurrentHashMap<String, UUID> offlinePlayerUUIDs) {

View File

@ -1,16 +1,16 @@
package com.github.artemis.the.gr8.playerstats.reload; package com.artemis.the.gr8.playerstats.reload;
import com.github.artemis.the.gr8.playerstats.ShareManager; import com.artemis.the.gr8.playerstats.ShareManager;
import com.github.artemis.the.gr8.playerstats.ThreadManager; import com.artemis.the.gr8.playerstats.ThreadManager;
import com.github.artemis.the.gr8.playerstats.enums.StandardMessage; import com.artemis.the.gr8.playerstats.enums.StandardMessage;
import com.github.artemis.the.gr8.playerstats.msg.OutputManager; import com.artemis.the.gr8.playerstats.msg.OutputManager;
import com.github.artemis.the.gr8.playerstats.msg.msgutils.LanguageKeyHandler; import com.artemis.the.gr8.playerstats.msg.msgutils.LanguageKeyHandler;
import com.github.artemis.the.gr8.playerstats.statistic.StatCalculator; import com.artemis.the.gr8.playerstats.statistic.StatCalculator;
import com.github.artemis.the.gr8.playerstats.statistic.StatThread; import com.artemis.the.gr8.playerstats.statistic.StatThread;
import com.github.artemis.the.gr8.playerstats.utils.MyLogger; import com.artemis.the.gr8.playerstats.utils.MyLogger;
import com.github.artemis.the.gr8.playerstats.utils.OfflinePlayerHandler; import com.artemis.the.gr8.playerstats.utils.OfflinePlayerHandler;
import com.github.artemis.the.gr8.playerstats.config.ConfigHandler; import com.artemis.the.gr8.playerstats.config.ConfigHandler;
import com.github.artemis.the.gr8.playerstats.enums.DebugLevel; import com.artemis.the.gr8.playerstats.enums.DebugLevel;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.OfflinePlayer; import org.bukkit.OfflinePlayer;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;

View File

@ -1,9 +1,9 @@
package com.github.artemis.the.gr8.playerstats.statistic; package com.artemis.the.gr8.playerstats.statistic;
import com.github.artemis.the.gr8.playerstats.ThreadManager; import com.artemis.the.gr8.playerstats.ThreadManager;
import com.github.artemis.the.gr8.playerstats.utils.OfflinePlayerHandler; import com.artemis.the.gr8.playerstats.utils.OfflinePlayerHandler;
import com.github.artemis.the.gr8.playerstats.statistic.request.RequestSettings; import com.artemis.the.gr8.playerstats.statistic.request.RequestSettings;
import com.github.artemis.the.gr8.playerstats.utils.MyLogger; import com.artemis.the.gr8.playerstats.utils.MyLogger;
import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableList;
import org.bukkit.OfflinePlayer; import org.bukkit.OfflinePlayer;
@ -24,12 +24,14 @@ final class StatAction extends RecursiveTask<ConcurrentHashMap<String, Integer>>
private final ConcurrentHashMap<String, Integer> allStats; private final ConcurrentHashMap<String, Integer> allStats;
/** /**
* Gets the statistic numbers for all players whose name is on the list, puts them in a ConcurrentHashMap * Gets the statistic numbers for all players whose name is on
* using the default ForkJoinPool, and returns the ConcurrentHashMap when everything is done. * the list, puts them in a ConcurrentHashMap using the default
* ForkJoinPool, and returns the ConcurrentHashMap when
* everything is done.
* *
* @param offlinePlayerHandler the OfflinePlayerHandler to convert playerNames into Players * @param offlinePlayerHandler the OfflinePlayerHandler to convert playerNames into Players
* @param playerNames ImmutableList of playerNames for players that should be included in stat calculations * @param playerNames ImmutableList of playerNames for players that should be included in stat calculations
* @param requestSettings a validated requestSettings * @param requestSettings a validated requestSettings object
* @param allStats the ConcurrentHashMap to put the results on * @param allStats the ConcurrentHashMap to put the results on
*/ */
public StatAction(OfflinePlayerHandler offlinePlayerHandler, ImmutableList<String> playerNames, RequestSettings requestSettings, ConcurrentHashMap<String, Integer> allStats) { public StatAction(OfflinePlayerHandler offlinePlayerHandler, ImmutableList<String> playerNames, RequestSettings requestSettings, ConcurrentHashMap<String, Integer> allStats) {

View File

@ -1,9 +1,9 @@
package com.github.artemis.the.gr8.playerstats.statistic; package com.artemis.the.gr8.playerstats.statistic;
import com.github.artemis.the.gr8.playerstats.ThreadManager; import com.artemis.the.gr8.playerstats.ThreadManager;
import com.github.artemis.the.gr8.playerstats.utils.OfflinePlayerHandler; import com.artemis.the.gr8.playerstats.utils.OfflinePlayerHandler;
import com.github.artemis.the.gr8.playerstats.statistic.request.RequestSettings; import com.artemis.the.gr8.playerstats.statistic.request.RequestSettings;
import com.github.artemis.the.gr8.playerstats.utils.MyLogger; import com.artemis.the.gr8.playerstats.utils.MyLogger;
import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableList;
import org.bukkit.OfflinePlayer; import org.bukkit.OfflinePlayer;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
@ -47,9 +47,8 @@ public final class StatCalculator {
} }
/** /**
* Invokes a bunch of worker pool threads to divide and conquer * Invokes a bunch of worker pool threads to get the statistics for
* (get the statistics for all players that are stored in the * all players that are stored in the {@link OfflinePlayerHandler}).
* {@link OfflinePlayerHandler})
*/ */
private @NotNull ConcurrentHashMap<String, Integer> getAllStatsAsync(RequestSettings requestSettings) { private @NotNull ConcurrentHashMap<String, Integer> getAllStatsAsync(RequestSettings requestSettings) {
long time = System.currentTimeMillis(); long time = System.currentTimeMillis();

View File

@ -1,12 +1,12 @@
package com.github.artemis.the.gr8.playerstats.statistic; package com.artemis.the.gr8.playerstats.statistic;
import com.github.artemis.the.gr8.playerstats.ThreadManager; import com.artemis.the.gr8.playerstats.ThreadManager;
import com.github.artemis.the.gr8.playerstats.msg.OutputManager; import com.artemis.the.gr8.playerstats.msg.OutputManager;
import com.github.artemis.the.gr8.playerstats.utils.MyLogger; import com.artemis.the.gr8.playerstats.utils.MyLogger;
import com.github.artemis.the.gr8.playerstats.enums.StandardMessage; import com.artemis.the.gr8.playerstats.enums.StandardMessage;
import com.github.artemis.the.gr8.playerstats.enums.Target; import com.artemis.the.gr8.playerstats.enums.Target;
import com.github.artemis.the.gr8.playerstats.statistic.request.RequestSettings; import com.artemis.the.gr8.playerstats.statistic.request.RequestSettings;
import com.github.artemis.the.gr8.playerstats.reload.ReloadThread; import com.artemis.the.gr8.playerstats.reload.ReloadThread;
import net.kyori.adventure.text.TextComponent; import net.kyori.adventure.text.TextComponent;
import org.jetbrains.annotations.Nullable; import org.jetbrains.annotations.Nullable;

View File

@ -1,9 +1,9 @@
package com.github.artemis.the.gr8.playerstats.statistic.request; package com.artemis.the.gr8.playerstats.statistic.request;
import com.github.artemis.the.gr8.playerstats.Main; import com.artemis.the.gr8.playerstats.Main;
import com.github.artemis.the.gr8.playerstats.statistic.result.PlayerStatResult; import com.artemis.the.gr8.playerstats.statistic.result.PlayerStatResult;
import com.github.artemis.the.gr8.playerstats.api.RequestGenerator; import com.artemis.the.gr8.playerstats.api.RequestGenerator;
import com.github.artemis.the.gr8.playerstats.msg.components.ComponentUtils; import com.artemis.the.gr8.playerstats.msg.components.ComponentUtils;
import net.kyori.adventure.text.TextComponent; import net.kyori.adventure.text.TextComponent;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.Statistic; import org.bukkit.Statistic;

View File

@ -1,9 +1,9 @@
package com.github.artemis.the.gr8.playerstats.statistic.request; package com.artemis.the.gr8.playerstats.statistic.request;
import com.github.artemis.the.gr8.playerstats.Main; import com.artemis.the.gr8.playerstats.Main;
import com.github.artemis.the.gr8.playerstats.enums.Target; import com.artemis.the.gr8.playerstats.utils.EnumHandler;
import com.github.artemis.the.gr8.playerstats.utils.EnumHandler; import com.artemis.the.gr8.playerstats.utils.OfflinePlayerHandler;
import com.github.artemis.the.gr8.playerstats.utils.OfflinePlayerHandler; import com.artemis.the.gr8.playerstats.enums.Target;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.Statistic; import org.bukkit.Statistic;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;

View File

@ -1,7 +1,7 @@
package com.github.artemis.the.gr8.playerstats.statistic.request; package com.artemis.the.gr8.playerstats.statistic.request;
import com.github.artemis.the.gr8.playerstats.api.RequestGenerator; import com.artemis.the.gr8.playerstats.api.RequestGenerator;
import com.github.artemis.the.gr8.playerstats.enums.Target; import com.artemis.the.gr8.playerstats.enums.Target;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.Statistic; import org.bukkit.Statistic;

View File

@ -1,9 +1,9 @@
package com.github.artemis.the.gr8.playerstats.statistic.request; package com.artemis.the.gr8.playerstats.statistic.request;
import com.github.artemis.the.gr8.playerstats.Main; import com.artemis.the.gr8.playerstats.Main;
import com.github.artemis.the.gr8.playerstats.statistic.result.ServerStatResult; import com.artemis.the.gr8.playerstats.statistic.result.ServerStatResult;
import com.github.artemis.the.gr8.playerstats.api.RequestGenerator; import com.artemis.the.gr8.playerstats.api.RequestGenerator;
import com.github.artemis.the.gr8.playerstats.msg.components.ComponentUtils; import com.artemis.the.gr8.playerstats.msg.components.ComponentUtils;
import net.kyori.adventure.text.TextComponent; import net.kyori.adventure.text.TextComponent;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.Statistic; import org.bukkit.Statistic;

View File

@ -1,7 +1,8 @@
package com.github.artemis.the.gr8.playerstats.statistic.request; package com.artemis.the.gr8.playerstats.statistic.request;
import com.github.artemis.the.gr8.playerstats.statistic.result.StatResult; import com.artemis.the.gr8.playerstats.api.PlayerStats;
import com.github.artemis.the.gr8.playerstats.enums.Target; import com.artemis.the.gr8.playerstats.statistic.result.StatResult;
import com.artemis.the.gr8.playerstats.enums.Target;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.Statistic; import org.bukkit.Statistic;
import org.bukkit.entity.EntityType; import org.bukkit.entity.EntityType;
@ -24,16 +25,21 @@ public abstract class StatRequest<T> {
} }
/** /**
* Executes this StatRequest. Don't call this from the Main Thread! * Executes this StatRequest. For a Top- or ServerRequest, this can
* take some time!
* *
* @return a StatResult containing the value of this lookup, both as * @return a StatResult containing the value of this lookup, both as
* numerical value and as formatted message * numerical value and as formatted message
* @see PlayerStats
* @see StatResult
*/ */
public abstract StatResult<T> execute(); public abstract StatResult<T> execute();
/** /**
* @return the Statistic this StatRequest will get the data of * Gets the Statistic that calling {@link #execute()} will calculate
* */ * the data for.
* @return the Statistic
*/
public Statistic getStatisticSetting() { public Statistic getStatisticSetting() {
return requestSettings.getStatistic(); return requestSettings.getStatistic();
} }
@ -71,6 +77,8 @@ public abstract class StatRequest<T> {
} }
/** /**
* Gets the Target that will be used when calling {@link #execute()}.
*
* @return the Target for this lookup (either Player, Server or Top) * @return the Target for this lookup (either Player, Server or Top)
*/ */
public Target getTargetSetting() { public Target getTargetSetting() {

View File

@ -1,9 +1,9 @@
package com.github.artemis.the.gr8.playerstats.statistic.request; package com.artemis.the.gr8.playerstats.statistic.request;
import com.github.artemis.the.gr8.playerstats.Main; import com.artemis.the.gr8.playerstats.Main;
import com.github.artemis.the.gr8.playerstats.statistic.result.TopStatResult; import com.artemis.the.gr8.playerstats.statistic.result.TopStatResult;
import com.github.artemis.the.gr8.playerstats.api.RequestGenerator; import com.artemis.the.gr8.playerstats.api.RequestGenerator;
import com.github.artemis.the.gr8.playerstats.msg.components.ComponentUtils; import com.artemis.the.gr8.playerstats.msg.components.ComponentUtils;
import net.kyori.adventure.text.TextComponent; import net.kyori.adventure.text.TextComponent;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.Statistic; import org.bukkit.Statistic;

View File

@ -1,6 +1,6 @@
package com.github.artemis.the.gr8.playerstats.statistic.result; package com.artemis.the.gr8.playerstats.statistic.result;
import com.github.artemis.the.gr8.playerstats.msg.components.ComponentUtils; import com.artemis.the.gr8.playerstats.msg.components.ComponentUtils;
import net.kyori.adventure.text.TextComponent; import net.kyori.adventure.text.TextComponent;
/** /**

View File

@ -1,4 +1,4 @@
package com.github.artemis.the.gr8.playerstats.statistic.result; package com.artemis.the.gr8.playerstats.statistic.result;
import net.kyori.adventure.text.TextComponent; import net.kyori.adventure.text.TextComponent;

View File

@ -1,4 +1,4 @@
package com.github.artemis.the.gr8.playerstats.statistic.result; package com.artemis.the.gr8.playerstats.statistic.result;
import net.kyori.adventure.text.TextComponent; import net.kyori.adventure.text.TextComponent;

View File

@ -1,6 +1,6 @@
package com.github.artemis.the.gr8.playerstats.statistic.result; package com.artemis.the.gr8.playerstats.statistic.result;
import com.github.artemis.the.gr8.playerstats.api.ApiFormatter; import com.artemis.the.gr8.playerstats.api.ApiFormatter;
import net.kyori.adventure.platform.bukkit.BukkitAudiences; import net.kyori.adventure.platform.bukkit.BukkitAudiences;
import net.kyori.adventure.text.TextComponent; import net.kyori.adventure.text.TextComponent;
@ -35,9 +35,9 @@ import net.kyori.adventure.text.TextComponent;
* on how to get and use the BukkitAudiences object can be found on * on how to get and use the BukkitAudiences object can be found on
* <a href="https://docs.adventure.kyori.net/platform/bukkit.html">Adventure's website</a>. * <a href="https://docs.adventure.kyori.net/platform/bukkit.html">Adventure's website</a>.
* *
* <p>You can also use the provided {@link #getFormattedString()} method to * <p>You can also use the provided {@link #getFormattedString()} method to get the
* get the same information in String-format. Don't use Adventure's .content() * same information in String-format. Don't use Adventure's <code>#content()</code>
* or .toString() methods on the Components - those won't get the actual * or <code>#toString()</code> methods on the Components - those won't get the actual
* message. And finally, if you want the results to be formatted differently, * message. And finally, if you want the results to be formatted differently,
* you can get an instance of the {@link ApiFormatter}. * you can get an instance of the {@link ApiFormatter}.
*/ */
@ -54,23 +54,25 @@ public interface StatResult<T> {
/** /**
* Gets the formatted message for the completed stat-lookup this * Gets the formatted message for the completed stat-lookup this
* {@link StatResult} stores. * StatResult stores.
* @return a {@code TextComponent} message containing the formatted number. * @return a {@code TextComponent} message containing the formatted number.
* This message follows the same style/color/language settings that are * This message follows the same style/color/language settings that are
* specified in the PlayerStats config. See class description for more * specified in the PlayerStats config. See class description for more
* information. * information.
* @see StatResult
*/ */
TextComponent getFormattedTextComponent(); TextComponent getFormattedTextComponent();
/** /**
* Gets the formatted message for the completed stat-lookup this * Gets the formatted message for the completed stat-lookup this
* {@link StatResult} stores. * StatResult stores.
* @return a String message containing the formatted number. This message * @return a String message containing the formatted number. This message
* follows the same style and color settings that are specified in the * follows the same style and color settings that are specified in the
* PlayerStats config, but it is not translatable (it is always plain English). * PlayerStats config, but it is not translatable (it is always plain English).
* See class description for more information. * See class description for more information.
* @see StatResult
*/ */
String getFormattedString(); String getFormattedString();
} }

View File

@ -1,4 +1,4 @@
package com.github.artemis.the.gr8.playerstats.statistic.result; package com.artemis.the.gr8.playerstats.statistic.result;
import net.kyori.adventure.text.TextComponent; import net.kyori.adventure.text.TextComponent;

View File

@ -1,4 +1,4 @@
package com.github.artemis.the.gr8.playerstats.utils; package com.artemis.the.gr8.playerstats.utils;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.Statistic; import org.bukkit.Statistic;
@ -32,6 +32,8 @@ public final class EnumHandler {
/** /**
* Returns all block-names in lowercase. * Returns all block-names in lowercase.
*
* @return the List
*/ */
public List<String> getBlockNames() { public List<String> getBlockNames() {
return blockNames; return blockNames;
@ -39,6 +41,8 @@ public final class EnumHandler {
/** /**
* Returns all item-names in lowercase. * Returns all item-names in lowercase.
*
* @return the List
*/ */
public List<String> getItemNames() { public List<String> getItemNames() {
return itemNames; return itemNames;
@ -46,6 +50,8 @@ public final class EnumHandler {
/** /**
* Returns all statistic-names in lowercase. * Returns all statistic-names in lowercase.
*
* @return the List
*/ */
public List<String> getStatNames() { public List<String> getStatNames() {
return statNames; return statNames;
@ -54,8 +60,9 @@ public final class EnumHandler {
/** /**
* Returns the corresponding Material enum constant for an itemName. * Returns the corresponding Material enum constant for an itemName.
* *
* @param itemName String, case-insensitive * @param itemName String (case-insensitive)
* @return Material enum constant, uppercase * @return Material enum constant (uppercase), or null if none
* can be found
*/ */
public static @Nullable Material getItemEnum(String itemName) { public static @Nullable Material getItemEnum(String itemName) {
if (itemName == null) return null; if (itemName == null) return null;
@ -67,8 +74,9 @@ public final class EnumHandler {
/** /**
* Returns the corresponding EntityType enum constant for an entityName. * Returns the corresponding EntityType enum constant for an entityName.
* *
* @param entityName String, case-insensitive * @param entityName String (case-insensitive)
* @return EntityType enum constant, uppercase * @return EntityType enum constant (uppercase), or null if none
* can be found
*/ */
public static @Nullable EntityType getEntityEnum(String entityName) { public static @Nullable EntityType getEntityEnum(String entityName) {
try { try {
@ -82,8 +90,9 @@ public final class EnumHandler {
/** /**
* Returns the corresponding Material enum constant for a materialName. * Returns the corresponding Material enum constant for a materialName.
* *
* @param materialName String, case-insensitive * @param materialName String (case-insensitive)
* @return Material enum constant, uppercase * @return Material enum constant (uppercase), or null if none
* can be found
*/ */
public static @Nullable Material getBlockEnum(String materialName) { public static @Nullable Material getBlockEnum(String materialName) {
if (materialName == null) return null; if (materialName == null) return null;
@ -95,7 +104,8 @@ public final class EnumHandler {
/** /**
* Returns the statistic enum constant, or null if that failed. * Returns the statistic enum constant, or null if that failed.
* *
* @param statName String, case-insensitive * @param statName String (case-insensitive)
* @return the Statistic enum constant, or null
*/ */
public static @Nullable Statistic getStatEnum(@NotNull String statName) { public static @Nullable Statistic getStatEnum(@NotNull String statName) {
try { try {
@ -107,16 +117,21 @@ public final class EnumHandler {
} }
/** /**
* Checks if string is a valid statistic. * Checks if string is a valid {@link Statistic}.
* *
* @param statName String, case-insensitive * @param statName the String to check (case-insensitive)
* @return true if this String is a valid Statistic
*/ */
public boolean isStatistic(@NotNull String statName) { public boolean isStatistic(@NotNull String statName) {
return statNames.contains(statName.toLowerCase()); return statNames.contains(statName.toLowerCase());
} }
/** /**
* Checks whether the given String equals the name of an entity-type statistic. * Checks whether the given String equals the name of a
* {@link Statistic} of Type.Entity.
*
* @param statName the String to check (case-insensitive)
* @return true if this String is a Statistic of Type.Entity
*/ */
public boolean isEntityStatistic(String statName) { public boolean isEntityStatistic(String statName) {
return statName.equalsIgnoreCase(Statistic.ENTITY_KILLED_BY.toString()) || return statName.equalsIgnoreCase(Statistic.ENTITY_KILLED_BY.toString()) ||
@ -127,14 +142,19 @@ public final class EnumHandler {
* Checks if this statistic is a subStatEntry, meaning it is a block, * Checks if this statistic is a subStatEntry, meaning it is a block,
* item or entity. * item or entity.
* *
* @param statName String, case-insensitive * @param statName the String to check (case-insensitive)
* @return true if this String is a Statistic that is not
* of Type.Untyped
*/ */
public boolean isSubStatEntry(@NotNull String statName) { public boolean isSubStatEntry(@NotNull String statName) {
return subStatNames.contains(statName.toLowerCase()); return subStatNames.contains(statName.toLowerCase());
} }
/** /**
* Returns "block", "entity", "item", or "sub-statistic" if the * Gets the name of the given Statistic.Type
*
* @param statType the Type of the Statistic to check
* @return "block", "entity", "item", or "sub-statistic" if the
* provided Type is null. * provided Type is null.
*/ */
public static String getSubStatTypeName(Statistic.Type statType) { public static String getSubStatTypeName(Statistic.Type statType) {

View File

@ -1,6 +1,6 @@
package com.github.artemis.the.gr8.playerstats.utils; package com.artemis.the.gr8.playerstats.utils;
import com.github.artemis.the.gr8.playerstats.enums.DebugLevel; import com.artemis.the.gr8.playerstats.enums.DebugLevel;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.plugin.Plugin; import org.bukkit.plugin.Plugin;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;

View File

@ -1,4 +1,4 @@
package com.github.artemis.the.gr8.playerstats.utils; package com.artemis.the.gr8.playerstats.utils;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.OfflinePlayer; import org.bukkit.OfflinePlayer;
@ -37,15 +37,18 @@ public final class OfflinePlayerHandler {
* Checks if a given playerName is on the private HashMap of players * Checks if a given playerName is on the private HashMap of players
* that should be included in statistic calculations. * that should be included in statistic calculations.
* *
* @param playerName String, case-sensitive * @param playerName String (case-sensitive)
* @return true if this Player should be included in calculations
*/ */
public boolean isRelevantPlayer(String playerName) { public boolean isRelevantPlayer(String playerName) {
return offlinePlayerUUIDs.containsKey(playerName); return offlinePlayerUUIDs.containsKey(playerName);
} }
/** /**
* Returns the number of OfflinePlayers that are included in * Gets the number of OfflinePlayers that are included in
* statistic calculations * statistic calculations.
*
* @return the number of included OfflinePlayers
*/ */
public int getOfflinePlayerCount() { public int getOfflinePlayerCount() {
return offlinePlayerUUIDs.size(); return offlinePlayerUUIDs.size();
@ -54,6 +57,8 @@ public final class OfflinePlayerHandler {
/** /**
* Gets an ArrayList of names from all OfflinePlayers that should * Gets an ArrayList of names from all OfflinePlayers that should
* be included in statistic calculations. * be included in statistic calculations.
*
* @return the ArrayList
*/ */
public ArrayList<String> getOfflinePlayerNames() { public ArrayList<String> getOfflinePlayerNames() {
return playerNames; return playerNames;

View File

@ -1,4 +1,4 @@
package com.github.artemis.the.gr8.playerstats.utils; package com.artemis.the.gr8.playerstats.utils;
/** /**
* A small utility class that calculates with unix time. * A small utility class that calculates with unix time.

View File

@ -1,4 +0,0 @@
/**
* The PlayerStats API
*/
package com.github.artemis.the.gr8.playerstats.api;