topStats);
}
\ No newline at end of file
diff --git a/src/main/java/com/github/artemis/the/gr8/playerstats/msg/MessageBuilder.java b/src/main/java/com/github/artemis/the/gr8/playerstats/msg/MessageBuilder.java
index 6c294a3..37c84fa 100644
--- a/src/main/java/com/github/artemis/the/gr8/playerstats/msg/MessageBuilder.java
+++ b/src/main/java/com/github/artemis/the/gr8/playerstats/msg/MessageBuilder.java
@@ -27,11 +27,13 @@ import java.util.function.BiFunction;
import static net.kyori.adventure.text.Component.*;
-/** 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.
- The component parts (with appropriate formatting) are supplied by a {@link ComponentFactory}.
- By default, this class works with the default ComponentFactory, but you can
- give it a different ComponentFactory upon creation.*/
+/**
+ * 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.
+ * The component parts (with appropriate formatting) are supplied by a
+ * {@link ComponentFactory}. By default, this class works with the default
+ * ComponentFactory, but you can give it a different ComponentFactory upon creation.
+ */
public final class MessageBuilder implements ApiFormatter {
private static ConfigHandler config;
@@ -63,8 +65,10 @@ public final class MessageBuilder implements ApiFormatter {
return new MessageBuilder(config, factory);
}
- /** Set whether this {@link MessageBuilder} should use hoverText.
- By default, this follows the setting specified in the {@link ConfigHandler}. */
+ /**
+ * Set whether this {@link MessageBuilder} should use hoverText.
+ * By default, this follows the setting specified in the {@link ConfigHandler}.
+ */
public void toggleHoverUse(boolean desiredSetting) {
useHoverText = desiredSetting;
}
@@ -223,11 +227,13 @@ public final class MessageBuilder implements ApiFormatter {
return getTopStatLineComponent(positionInTopList, playerName, statNumberComponent);
}
- /** Time-number does not hover */
+ /**
+ * Time-number does not hover
+ */
@Override
- public TextComponent formatTopStatLineForTypeTime(int positionInList, String playerName, long statNumber, Unit bigUnit, Unit smallUnit) {
+ public TextComponent formatTopStatLineForTypeTime(int positionInTopList, String playerName, long statNumber, Unit bigUnit, Unit smallUnit) {
TextComponent statNumberComponent = getBasicTimeNumberComponent(statNumber, Target.TOP, bigUnit, smallUnit);
- return getTopStatLineComponent(positionInList, playerName, statNumberComponent);
+ return getTopStatLineComponent(positionInTopList, playerName, statNumberComponent);
}
@Override
@@ -278,31 +284,49 @@ public final class MessageBuilder implements ApiFormatter {
return getPlayerStatComponent(playerName, statNumberComponent, statistic, null, null);
}
- /** Returns a BiFunction for a player statistic. This BiFunction will return a formattedComponent,
- the shape of which is determined by the 2 parameters the BiFunction gets.
- - Integer shareCode: if a shareCode is provided, a clickable "share" button will be added.
-
- CommandSender sender: if a sender is provided, a signature with "shared by sender-name" will be added.
-
- If both parameters are null, the formattedComponent will be returned as is.*/
+ /**
+ * Returns a BiFunction for a player statistic. This BiFunction will return
+ * a formattedComponent, the shape of which is determined by the 2 parameters
+ * the BiFunction gets.
+ *
- Integer shareCode: if a shareCode is provided, a clickable "share"
+ * button will be added.
+ *
- CommandSender sender: if a sender is provided, a signature with
+ * "shared by sender-name" will be added.
+ *
- If both parameters are null, the formattedComponent will be returned
+ * as is.
+ */
public BiFunction formattedPlayerStatFunction(int stat, @NotNull RequestSettings request) {
TextComponent playerStat = formatPlayerStat(request.getPlayerName(), stat, request.getStatistic(), request.getSubStatEntryName());
return getFormattingFunction(playerStat, Target.PLAYER);
}
- /** Returns a BiFunction for a server statistic. This BiFunction will return a formattedComponent,
- the shape of which is determined by the 2 parameters the BiFunction gets.
- - Integer shareCode: if a shareCode is provided, a clickable "share" button will be added.
-
- CommandSender sender: if a sender is provided, a signature with "shared by sender-name" will be added.
-
- If both parameters are null, the formattedComponent will be returned as is.*/
+ /**
+ * Returns a BiFunction for a server statistic. This BiFunction will return
+ * a formattedComponent, the shape of which is determined by the 2 parameters
+ * the BiFunction gets.
+ *
- Integer shareCode: if a shareCode is provided, a clickable "share"
+ * button will be added.
+ *
- CommandSender sender: if a sender is provided, a signature with
+ * "shared by sender-name" will be added.
+ *
- If both parameters are null, the formattedComponent will be returned
+ * as is.
+ */
public BiFunction formattedServerStatFunction(long stat, @NotNull RequestSettings request) {
TextComponent serverStat = formatServerStat(stat, request.getStatistic(), request.getSubStatEntryName());
return getFormattingFunction(serverStat, Target.SERVER);
}
- /** Returns a BiFunction for a top statistic. This BiFunction will return a formattedComponent,
- the shape of which is determined by the 2 parameters the BiFunction gets.
- - Integer shareCode: if a shareCode is provided, a clickable "share" button will be added.
-
- CommandSender sender: if a sender is provided, a signature with "shared by sender-name" will be added.
-
- If both parameters are null, the formattedComponent will be returned as is.*/
+ /**
+ * Returns a BiFunction for a top statistic. This BiFunction will return
+ * a formattedComponent, the shape of which is determined by the 2 parameters
+ * the BiFunction gets.
+ *
- Integer shareCode: if a shareCode is provided, a clickable "share"
+ * button will be added.
+ *
- CommandSender sender: if a sender is provided, a signature with
+ * "shared by sender-name" will be added.
+ *
- If both parameters are null, the formattedComponent will be returned
+ * as is.
+ */
public BiFunction formattedTopStatFunction(@NotNull LinkedHashMap topStats, @NotNull RequestSettings request) {
final TextComponent title = getTopStatTitle(topStats.size(), request.getStatistic(), request.getSubStatEntryName());
final TextComponent list = getTopStatListComponent(topStats, request.getStatistic());
@@ -562,7 +586,9 @@ public final class MessageBuilder implements ApiFormatter {
return componentFactory.statNumber(formatter.formatNumber(statNumber), target);
}
- /** Provides its own space in front of it! */
+ /**
+ * Provides its own space in front of it!
+ */
private TextComponent getStatUnitComponent(Statistic statistic, Target target) {
Unit unit = switch (Unit.getTypeFromStatistic(statistic)) {
case DAMAGE -> Unit.fromString(config.getDamageUnit(false));
@@ -580,7 +606,9 @@ public final class MessageBuilder implements ApiFormatter {
};
}
- /** Provides its own space in front of it! */
+ /**
+ * Provides its own space in front of it!
+ */
private TextComponent getDistanceUnitComponent(Unit unit, Target target) {
if (config.useTranslatableComponents()) {
String unitKey = languageKeyHandler.getUnitKey(unit);
@@ -593,7 +621,9 @@ public final class MessageBuilder implements ApiFormatter {
.append(componentFactory.statUnit(unit.getLabel(), target));
}
- /** Provides its own space in front of it! */
+ /**
+ * Provides its own space in front of it!
+ */
private TextComponent getDamageUnitComponent(Unit unit, Target target) {
if (unit == Unit.HEART) {
TextComponent heartUnit;
@@ -668,11 +698,13 @@ public final class MessageBuilder implements ApiFormatter {
}
}
- /** Get an ArrayList consisting of 2 or 4 timeUnits. The order of items is:
- 0. maxUnit
- 1. minUnit
- 2. maxHoverUnit
- 3. minHoverUnit
*/
+ /**
+ * Get an ArrayList consisting of 2 or 4 timeUnits. The order of items is:
+ * 0. maxUnit
+ * 1. minUnit
+ * 2. maxHoverUnit
+ * 3. minHoverUnit
+ */
private ArrayList getTimeUnitRange(long statNumber) {
ArrayList unitRange = new ArrayList<>();
if (!config.autoDetectTimeUnit(false)) {
diff --git a/src/main/java/com/github/artemis/the/gr8/playerstats/msg/OutputManager.java b/src/main/java/com/github/artemis/the/gr8/playerstats/msg/OutputManager.java
index fb3ec8b..98dac7d 100644
--- a/src/main/java/com/github/artemis/the/gr8/playerstats/msg/OutputManager.java
+++ b/src/main/java/com/github/artemis/the/gr8/playerstats/msg/OutputManager.java
@@ -24,9 +24,13 @@ import java.util.function.Function;
import static com.github.artemis.the.gr8.playerstats.enums.StandardMessage.*;
-/** This class manages all PlayerStats output. It is the only place where messages are sent.
- It gets its messages from a {@link MessageBuilder} configured for either a Console or for Players
- (mainly to deal with the lack of hover-text, and for Bukkit consoles to make up for the lack of hex-colors).*/
+/**
+ * This class manages all PlayerStats output. It is the only
+ * place where messages are sent. It gets its messages from a
+ * {@link MessageBuilder} configured for either a Console or
+ * for Players (mainly to deal with the lack of hover-text,
+ * and for Bukkit consoles to make up for the lack of hex-colors).
+ * */
public final class OutputManager implements InternalFormatter {
private static BukkitAudiences adventure;
diff --git a/src/main/java/com/github/artemis/the/gr8/playerstats/msg/components/BukkitConsoleComponentFactory.java b/src/main/java/com/github/artemis/the/gr8/playerstats/msg/components/BukkitConsoleComponentFactory.java
index 2ab8aaa..d5ef71e 100644
--- a/src/main/java/com/github/artemis/the/gr8/playerstats/msg/components/BukkitConsoleComponentFactory.java
+++ b/src/main/java/com/github/artemis/the/gr8/playerstats/msg/components/BukkitConsoleComponentFactory.java
@@ -11,8 +11,11 @@ import org.jetbrains.annotations.Nullable;
import static net.kyori.adventure.text.Component.text;
-/** The {@link ComponentFactory} that is used to build messages for a Bukkit Console.
- Bukkit consoles don't support hex colors, unlike Paper consoles.*/
+/**
+ * The {@link ComponentFactory} that is used to build messages for
+ * a Bukkit Console. Bukkit consoles don't support hex colors,
+ * unlike Paper consoles.
+ */
public class BukkitConsoleComponentFactory extends ComponentFactory {
public BukkitConsoleComponentFactory(ConfigHandler config) {
diff --git a/src/main/java/com/github/artemis/the/gr8/playerstats/msg/components/ComponentFactory.java b/src/main/java/com/github/artemis/the/gr8/playerstats/msg/components/ComponentFactory.java
index bc991ea..845f552 100644
--- a/src/main/java/com/github/artemis/the/gr8/playerstats/msg/components/ComponentFactory.java
+++ b/src/main/java/com/github/artemis/the/gr8/playerstats/msg/components/ComponentFactory.java
@@ -22,9 +22,12 @@ import org.jetbrains.annotations.Nullable;
import static net.kyori.adventure.text.Component.*;
-/** Creates Components with the desired formatting for the {@link MessageBuilder} to build messages with.
- This class can put Strings into formatted Components with TextColor
- and TextDecoration, or return empty Components with the desired formatting.*/
+/** Creates Components with the desired formatting for the
+ * {@link MessageBuilder} to build messages with. This class
+ * can put Strings into formatted Components with TextColor
+ * and TextDecoration, or return empty Components with the
+ * desired formatting.
+ * */
public class ComponentFactory {
private static ConfigHandler config;
@@ -76,7 +79,9 @@ public class ComponentFactory {
return getColorFromString(config.getSharerNameDecoration(false));
}
- /** Returns [PlayerStats]. */
+ /**
+ * Returns [PlayerStats].
+ */
public TextComponent pluginPrefix() {
return text("[")
.color(BRACKETS)
@@ -84,7 +89,9 @@ public class ComponentFactory {
.append(text("]"));
}
- /** Returns [PlayerStats] surrounded by underscores on both sides. */
+ /**
+ * Returns [PlayerStats] surrounded by underscores on both sides.
+ */
public TextComponent pluginPrefixAsTitle() {
//12 underscores for both console and in-game
return text("____________").color(UNDERSCORE)
@@ -94,12 +101,18 @@ public class ComponentFactory {
.append(text("____________"));
}
- /** Returns a TextComponent with the input String as content, with color Gray and decoration Italic.*/
+ /**
+ * Returns a TextComponent with the input String as content,
+ * with color Gray and decoration Italic.
+ */
public TextComponent subTitle(String content) {
return text(content).color(BRACKETS).decorate(TextDecoration.ITALIC);
}
- /** Returns a TextComponents in the style of a default plugin message, with color Medium_Blue. */
+ /**
+ * Returns a TextComponents in the style of a default plugin message,
+ * with color Medium_Blue.
+ */
public TextComponent message() {
return text().color(MSG_MAIN).build();
}
@@ -181,8 +194,12 @@ public class ComponentFactory {
.build());
}
- /** @param prettyStatName a statName with underscores removed and each word capitalized
- @param prettySubStatName if present, a subStatName with underscores removed and each word capitalized*/
+ /**
+ * @param prettyStatName a statName with underscores removed and each
+ * word capitalized
+ * @param prettySubStatName if present, a subStatName with underscores
+ * removed and each word capitalized
+ */
public TextComponent statAndSubStatName(String prettyStatName, @Nullable String prettySubStatName, Target target) {
TextComponent.Builder totalStatNameBuilder = getComponentBuilder(prettyStatName,
getColorFromString(config.getStatNameDecoration(target, false)),
@@ -197,7 +214,9 @@ public class ComponentFactory {
return totalStatNameBuilder.build();
}
- /** Returns a TextComponent with TranslatableComponent as a child.*/
+ /**
+ * Returns a TextComponent with TranslatableComponent as a child.
+ * */
public TextComponent statAndSubStatNameTranslatable(String statKey, @Nullable String subStatKey, Target target) {
TextComponent.Builder totalStatNameBuilder = getComponentBuilder(null,
getColorFromString(config.getStatNameDecoration(target, false)),
@@ -307,7 +326,9 @@ public class ComponentFactory {
.build();
}
- /** Returns a TextComponent for the subStatName, or an empty component.*/
+ /**
+ * Returns a TextComponent for the subStatName, or an empty component.
+ */
private TextComponent subStatName(@Nullable String prettySubStatName, Target target) {
if (prettySubStatName == null) {
return Component.empty();
@@ -322,7 +343,9 @@ public class ComponentFactory {
}
}
- /** Returns a TranslatableComponent for the subStatName, or an empty component.*/
+ /**
+ * Returns a TranslatableComponent for the subStatName, or an empty component.
+ */
private TextComponent subStatNameTranslatable(@Nullable String subStatKey, Target target) {
if (subStatKey != null) {
return getComponentBuilder(null,
@@ -337,18 +360,26 @@ public class ComponentFactory {
return Component.empty();
}
- /** Construct a custom translation for kill_entity with the language key for commands.kill.success.single ("Killed %s").
- @return a TranslatableComponent Builder with the subStat Component as args.*/
+ /**
+ * Construct a custom translation for kill_entity with the language key
+ * for commands.kill.success.single ("Killed %s").
+ *
+ * @return a TranslatableComponent Builder with the subStat Component as args.
+ */
private TranslatableComponent.Builder killEntityBuilder(@NotNull TextComponent subStat) {
return translatable()
.key(LanguageKeyHandler.getAlternativeKeyForKillEntity()) //"Killed %s"
.args(subStat);
}
- /** Construct a custom translation for entity_killed_by with the language keys for stat.minecraft.deaths
- ("Number of Deaths") and book.byAuthor ("by %s").
- @return a TranslatableComponent Builder with stat.minecraft.deaths as key, with a ChildComponent
- with book.byAuthor as key and the subStat Component as args.*/
+ /**
+ * Construct a custom translation for entity_killed_by with the language
+ * keys for stat.minecraft.deaths ("Number of Deaths") and book.byAuthor
+ * ("by %s").
+ *
+ * @return a TranslatableComponent Builder with stat.minecraft.deaths as key,
+ * with a ChildComponent with book.byAuthor as key and the subStat Component as args.
+ */
private TranslatableComponent.Builder entityKilledByBuilder(@NotNull TextComponent subStat) {
return translatable()
.key(LanguageKeyHandler.getAlternativeKeyForEntityKilledBy()) //"Number of Deaths"
diff --git a/src/main/java/com/github/artemis/the/gr8/playerstats/msg/components/ComponentUtils.java b/src/main/java/com/github/artemis/the/gr8/playerstats/msg/components/ComponentUtils.java
index 9d62a16..dcbd88b 100644
--- a/src/main/java/com/github/artemis/the/gr8/playerstats/msg/components/ComponentUtils.java
+++ b/src/main/java/com/github/artemis/the/gr8/playerstats/msg/components/ComponentUtils.java
@@ -6,13 +6,18 @@ import net.kyori.adventure.text.*;
import net.kyori.adventure.text.flattener.ComponentFlattener;
import net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer;
-/** A small utility class for turning PlayerStats' custom Components into String. */
+/**
+ * A small utility class for turning PlayerStats' custom Components into String.
+ */
public final class ComponentUtils {
- /** Returns a LegacyComponentSerializer that is capable of serializing TranslatableComponents,
- and capable of dealing with the custom language-keys I am using to improve the entity-related
- statistic names. This serializer will create a String with hex colors and styles, and it will
- turn language keys into prettified, readable English. */
+ /**
+ * Returns a LegacyComponentSerializer that is capable of serializing
+ * TranslatableComponents, and capable of dealing with the custom
+ * language-keys I am using to improve the entity-related statistic
+ * names. This serializer will create a String with hex colors and styles,
+ * and it will turn language keys into prettified, readable English.
+ */
public static LegacyComponentSerializer getTranslatableComponentSerializer() {
LegacyComponentSerializer serializer = getTextComponentSerializer();
diff --git a/src/main/java/com/github/artemis/the/gr8/playerstats/msg/components/ExampleMessage.java b/src/main/java/com/github/artemis/the/gr8/playerstats/msg/components/ExampleMessage.java
index 1d78e64..0363235 100644
--- a/src/main/java/com/github/artemis/the/gr8/playerstats/msg/components/ExampleMessage.java
+++ b/src/main/java/com/github/artemis/the/gr8/playerstats/msg/components/ExampleMessage.java
@@ -11,7 +11,9 @@ import java.util.List;
import static net.kyori.adventure.text.Component.text;
-/** A fully constructed message with examples on how to use PlayerStats.*/
+/**
+ * A fully constructed message with examples on how to use PlayerStats.
+ */
public final class ExampleMessage implements TextComponent {
private final TextComponent exampleMessage;
diff --git a/src/main/java/com/github/artemis/the/gr8/playerstats/msg/components/HelpMessage.java b/src/main/java/com/github/artemis/the/gr8/playerstats/msg/components/HelpMessage.java
index 4aecb37..01189c6 100644
--- a/src/main/java/com/github/artemis/the/gr8/playerstats/msg/components/HelpMessage.java
+++ b/src/main/java/com/github/artemis/the/gr8/playerstats/msg/components/HelpMessage.java
@@ -13,7 +13,9 @@ import java.util.List;
import static net.kyori.adventure.text.Component.text;
-/** The help message that explains how to use PlayerStats.*/
+/**
+ * The help message that explains how to use PlayerStats.
+ */
public final class HelpMessage implements TextComponent {
private final TextComponent helpMessage;
diff --git a/src/main/java/com/github/artemis/the/gr8/playerstats/msg/components/PrideComponentFactory.java b/src/main/java/com/github/artemis/the/gr8/playerstats/msg/components/PrideComponentFactory.java
index 8b34be9..9bd017e 100644
--- a/src/main/java/com/github/artemis/the/gr8/playerstats/msg/components/PrideComponentFactory.java
+++ b/src/main/java/com/github/artemis/the/gr8/playerstats/msg/components/PrideComponentFactory.java
@@ -11,7 +11,9 @@ import java.util.Random;
import static net.kyori.adventure.text.Component.*;
-/** A festive version of the {@link ComponentFactory}*/
+/**
+ * A festive version of the {@link ComponentFactory}
+ */
public class PrideComponentFactory extends ComponentFactory {
public PrideComponentFactory(ConfigHandler c) {
diff --git a/src/main/java/com/github/artemis/the/gr8/playerstats/msg/msgutils/EasterEggProvider.java b/src/main/java/com/github/artemis/the/gr8/playerstats/msg/msgutils/EasterEggProvider.java
index ede8e2b..7a9b2e7 100644
--- a/src/main/java/com/github/artemis/the/gr8/playerstats/msg/msgutils/EasterEggProvider.java
+++ b/src/main/java/com/github/artemis/the/gr8/playerstats/msg/msgutils/EasterEggProvider.java
@@ -12,8 +12,11 @@ import org.jetbrains.annotations.NotNull;
import java.util.Random;
-/**This class is just for fun and adds some silly names for players on my server.
-It does not impact the rest of the plugin, and will only be used for the players mentioned in here.*/
+/**
+ * This class is just for fun and adds some silly names for
+ * players on my server. It does not impact the rest of the plugin,
+ * and will only be used for the players mentioned in here.
+ */
public final class EasterEggProvider {
private static boolean isEnabled;
diff --git a/src/main/java/com/github/artemis/the/gr8/playerstats/msg/msgutils/FontUtils.java b/src/main/java/com/github/artemis/the/gr8/playerstats/msg/msgutils/FontUtils.java
index dd2bf82..c0fff85 100644
--- a/src/main/java/com/github/artemis/the/gr8/playerstats/msg/msgutils/FontUtils.java
+++ b/src/main/java/com/github/artemis/the/gr8/playerstats/msg/msgutils/FontUtils.java
@@ -2,7 +2,10 @@ package com.github.artemis.the.gr8.playerstats.msg.msgutils;
import org.bukkit.map.MinecraftFont;
-/** A small utility class that helps calculate how many dots to use to get the numbers of a top-statistic aligned. */
+/**
+ * A small utility class that helps calculate how many dots
+ * to use to get the numbers of a top-statistic aligned.
+ */
public final class FontUtils {
private FontUtils() {
diff --git a/src/main/java/com/github/artemis/the/gr8/playerstats/msg/msgutils/LanguageKeyHandler.java b/src/main/java/com/github/artemis/the/gr8/playerstats/msg/msgutils/LanguageKeyHandler.java
index 4548b8f..90db036 100644
--- a/src/main/java/com/github/artemis/the/gr8/playerstats/msg/msgutils/LanguageKeyHandler.java
+++ b/src/main/java/com/github/artemis/the/gr8/playerstats/msg/msgutils/LanguageKeyHandler.java
@@ -16,21 +16,25 @@ import java.io.File;
import java.util.Arrays;
import java.util.HashMap;
-/** A utility class that provides language keys to be put in a TranslatableComponent.*/
+/**
+ *
+ * A utility class that provides language keys to be
+ * put in a TranslatableComponent.
+ */
public final class LanguageKeyHandler {
+ private static Main plugin;
private static HashMap statNameKeys;
private static File languageKeyFile;
private static FileConfiguration languageKeys;
- public LanguageKeyHandler() {
+ public LanguageKeyHandler(Main plugin) {
+ LanguageKeyHandler.plugin = plugin;
statNameKeys = generateStatNameKeys();
-
loadFile();
}
private static void loadFile() {
- Main plugin = Main.getInstance();
languageKeyFile = new File(plugin.getDataFolder(), "language.yml");
if (!languageKeyFile.exists()) {
plugin.saveResource("language.yml", false);
@@ -47,42 +51,57 @@ public final class LanguageKeyHandler {
}
}
- /** Checks if a given Key is the language key "stat_type.minecraft.killed"
- or "commands.kill.success.single" (which results in "Killed %s").*/
+ /**
+ * Checks if a given Key is the language key "stat_type.minecraft.killed"
+ * or "commands.kill.success.single" (which results in "Killed %s").
+ */
public static boolean isKeyForKillEntity(String statKey) {
return statKey.equalsIgnoreCase("stat_type.minecraft.killed") ||
statKey.equalsIgnoreCase("commands.kill.success.single");
}
- /** Returns a language key to replace the default Statistic.Kill_Entity key.
- @return the key "commands.kill.success.single", which results in "Killed %s" */
+ /**
+ * Returns a language key to replace the default Statistic.Kill_Entity key.
+ *
+ * @return the key "commands.kill.success.single", which results in "Killed %s"
+ */
public static String getAlternativeKeyForKillEntity() {
return "commands.kill.success.single";
}
- /** Checks if a given Key is the language key "stat_type.minecraft.killed_by"
- or "stat.minecraft.deaths" (which results in "Number of Deaths").*/
+ /**
+ * Checks if a given Key is the language key "stat_type.minecraft.killed_by"
+ * or "stat.minecraft.deaths" (which results in "Number of Deaths").
+ */
public static boolean isKeyForEntityKilledBy(String statKey) {
return statKey.equalsIgnoreCase("stat_type.minecraft.killed_by") ||
statKey.equalsIgnoreCase("stat.minecraft.deaths");
}
- /** Returns a language key to replace the default Statistic.Entity_Killed_By key.
- @return the key "stat.minecraft.deaths", which results in "Number of Deaths"
- (meant to be followed by {@link #getAlternativeKeyForEntityKilledByArg()})*/
+ /**
+ * Returns a language key to replace the default Statistic.Entity_Killed_By key.
+ *
+ * @return the key "stat.minecraft.deaths", which results in "Number of Deaths"
+ * (meant to be followed by {@link #getAlternativeKeyForEntityKilledByArg()})
+ */
public static String getAlternativeKeyForEntityKilledBy() {
return "stat.minecraft.deaths";
}
- /** Checks if a given Key is the language key "book.byAuthor"
- (which results in "by %s"). */
+ /**
+ * Checks if a given Key is the language key "book.byAuthor"
+ * (which results in "by %s").
+ */
public static boolean isKeyForEntityKilledByArg(String statKey) {
return statKey.equalsIgnoreCase("book.byAuthor");
}
- /** Returns a language key to complete the alternative key for Statistic.Entity_Killed_By.
- @return the key "book.byAuthor", which results in "by %". If used after
- {@link #getAlternativeKeyForEntityKilledBy()}, you will get "Number of Deaths" "by %s"*/
+ /**
+ * Returns a language key to complete the alternative key for Statistic.Entity_Killed_By.
+ *
+ * @return the key "book.byAuthor", which results in "by %". If used after
+ * {@link #getAlternativeKeyForEntityKilledBy()}, you will get "Number of Deaths" "by %s"
+ */
public static String getAlternativeKeyForEntityKilledByArg() {
return "book.byAuthor";
}
@@ -144,8 +163,10 @@ public final class LanguageKeyHandler {
}
}
- /** Get the official Key from the NameSpacedKey for this entityType,
- or return null if no enum constant can be retrieved or entityType is UNKNOWN.*/
+ /**
+ * Get the official Key from the NameSpacedKey for this entityType,
+ * or return null if no enum constant can be retrieved or entityType is UNKNOWN.
+ */
public @Nullable String getEntityKey(EntityType entity) {
if (entity == null || entity == EntityType.UNKNOWN) return null;
else {
@@ -153,8 +174,10 @@ public final class LanguageKeyHandler {
}
}
- /** Get the official Key from the NameSpacedKey for this item Material,
- or return null if no enum constant can be retrieved.*/
+ /**
+ * Get the official Key from the NameSpacedKey for this item Material,
+ * or return null if no enum constant can be retrieved.
+ */
public @Nullable String getItemKey(Material item) {
if (item == null) return null;
else if (item.isBlock()) {
@@ -165,8 +188,10 @@ public final class LanguageKeyHandler {
}
}
- /** Returns the official Key from the NameSpacedKey for the block Material provided,
- or return null if no enum constant can be retrieved.*/
+ /**
+ * Returns the official Key from the NameSpacedKey for the block Material provided,
+ * or return null if no enum constant can be retrieved.
+ */
public @Nullable String getBlockKey(Material block) {
if (block == null) return null;
else if (block.toString().toLowerCase().contains("wall_banner")) { //replace wall_banner with regular banner, since there is no key for wall banners
diff --git a/src/main/java/com/github/artemis/the/gr8/playerstats/msg/msgutils/NumberFormatter.java b/src/main/java/com/github/artemis/the/gr8/playerstats/msg/msgutils/NumberFormatter.java
index ed4ebc8..411a162 100644
--- a/src/main/java/com/github/artemis/the/gr8/playerstats/msg/msgutils/NumberFormatter.java
+++ b/src/main/java/com/github/artemis/the/gr8/playerstats/msg/msgutils/NumberFormatter.java
@@ -5,9 +5,10 @@ import com.github.artemis.the.gr8.playerstats.enums.Unit;
import java.text.DecimalFormat;
/** A utility class that formats statistic numbers into something more readable.
- It transforms numbers of {@link Unit.Type} Time, Damage, and Distance into numbers
- that are easier to understand (for example: from ticks to hours) and adds commas
- to break up large numbers.*/
+ * It transforms numbers of {@link Unit.Type} Time, Damage, and Distance into numbers
+ * that are easier to understand (for example: from ticks to hours) and adds commas
+ * to break up large numbers.
+ */
public final class NumberFormatter {
private final DecimalFormat format;
@@ -19,14 +20,16 @@ public final class NumberFormatter {
}
/** Turns the input number into a more readable format depending on its type
- (number-of-times, time-, damage- or distance-based) according to the
- corresponding config settings, and adds commas in groups of 3.*/
+ * (number-of-times, time-, damage- or distance-based) according to the
+ * corresponding config settings, and adds commas in groups of 3.
+ */
public String formatNumber(long number) {
return format.format(number);
}
/** The unit of damage-based statistics is half a heart by default.
- This method turns the number into hearts. */
+ * This method turns the number into hearts.
+ */
public String formatDamageNumber(long number, Unit statUnit) { //7 statistics
if (statUnit == Unit.HEART) {
return format.format(Math.round(number / 2.0));
@@ -35,8 +38,11 @@ public final class NumberFormatter {
}
}
- /** The unit of distance-based statistics is cm by default. This method turns it into blocks by default,
- and turns it into km or leaves it as cm otherwise, depending on the config settings. */
+ /** The unit of distance-based statistics is cm by default.
+ * This method turns it into blocks by default,
+ * and turns it into km or leaves it as cm otherwise,
+ * depending on the config settings.
+ */
public String formatDistanceNumber(long number, Unit statUnit) { //15 statistics
switch (statUnit) {
case CM -> {
@@ -55,7 +61,10 @@ public final class NumberFormatter {
}
/** The unit of time-based statistics is ticks by default.
- @return a String with the form "1D 2H 3M 4S" (depending on the Unit range selected)*/
+ *
+ * @return a String with the form "1D 2H 3M 4S"
+ * (depending on the Unit range selected)
+ */
public String formatTimeNumber(long number, Unit bigUnit, Unit smallUnit) { //5 statistics
if (number == 0) {
return "-";
diff --git a/src/main/java/com/github/artemis/the/gr8/playerstats/msg/msgutils/StringUtils.java b/src/main/java/com/github/artemis/the/gr8/playerstats/msg/msgutils/StringUtils.java
index 5cd816f..4b9ec7a 100644
--- a/src/main/java/com/github/artemis/the/gr8/playerstats/msg/msgutils/StringUtils.java
+++ b/src/main/java/com/github/artemis/the/gr8/playerstats/msg/msgutils/StringUtils.java
@@ -2,14 +2,20 @@ package com.github.artemis.the.gr8.playerstats.msg.msgutils;
import com.github.artemis.the.gr8.playerstats.utils.MyLogger;
-/** A small utility class that helps make enum constant names prettier for output in stat-messages.*/
+/**
+ * A small utility class that helps make enum constant
+ * names prettier for output in stat-messages.
+ */
public final class StringUtils {
private StringUtils() {
}
- /** Replace "_" with " " and capitalize each first letter of the input.
- @param input String to prettify, case-insensitive*/
+ /**
+ * Replace "_" with " " and capitalize each first letter of the input.
+ *
+ * @param input String to prettify, case-insensitive
+ */
public static String prettify(String input) {
if (input == null) return null;
StringBuilder capitals = new StringBuilder(input.toLowerCase());
diff --git a/src/main/java/com/github/artemis/the/gr8/playerstats/reload/ReloadAction.java b/src/main/java/com/github/artemis/the/gr8/playerstats/reload/ReloadAction.java
index 5e8c8c8..e81caa0 100644
--- a/src/main/java/com/github/artemis/the/gr8/playerstats/reload/ReloadAction.java
+++ b/src/main/java/com/github/artemis/the/gr8/playerstats/reload/ReloadAction.java
@@ -9,7 +9,9 @@ import java.util.UUID;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.RecursiveAction;
-/** The action that is executed when a reload-command is triggered. */
+/**
+ * The action that is executed when a reload-command is triggered.
+ */
final class ReloadAction extends RecursiveAction {
private static int threshold;
@@ -21,10 +23,13 @@ final class ReloadAction extends RecursiveAction {
private final int lastPlayedLimit;
private final ConcurrentHashMap offlinePlayerUUIDs;
- /** Fills a ConcurrentHashMap with PlayerNames and UUIDs for all OfflinePlayers that should be included in statistic calculations.
+ /**
+ * Fills a ConcurrentHashMap with PlayerNames and UUIDs for all OfflinePlayers
+ * that should be included in statistic calculations.
+ *
* @param players array of all OfflinePlayers (straight from Bukkit)
* @param lastPlayedLimit whether to set a limit based on last-played-date
- * @param offlinePlayerUUIDs the ConcurrentHashMap to put resulting playerNames and UUIDs on
+ * @param offlinePlayerUUIDs the ConcurrentHashMap to put playerNames and UUIDs in
*/
public ReloadAction(OfflinePlayer[] players,
int lastPlayedLimit, ConcurrentHashMap offlinePlayerUUIDs) {
diff --git a/src/main/java/com/github/artemis/the/gr8/playerstats/reload/ReloadThread.java b/src/main/java/com/github/artemis/the/gr8/playerstats/reload/ReloadThread.java
index 0d6eba8..dfe7c6b 100644
--- a/src/main/java/com/github/artemis/the/gr8/playerstats/reload/ReloadThread.java
+++ b/src/main/java/com/github/artemis/the/gr8/playerstats/reload/ReloadThread.java
@@ -45,11 +45,15 @@ public final class ReloadThread extends Thread {
MyLogger.logHighLevelMsg(this.getName() + " created!");
}
- /** This method will perform a series of tasks. If a {@link StatThread} is still running,
- it will join the statThread and wait for it to finish. Then, it will reload the config,
- update the offlinePlayerList in the {@link OfflinePlayerHandler}, update the {@link DebugLevel},
- update the share-settings in {@link ShareManager} and topListSize-settings in {@link StatCalculator},
- and update the MessageBuilders in the {@link OutputManager}.*/
+ /**
+ * This method will perform a series of tasks. If a {@link StatThread}
+ * is still running, it will join the statThread and wait for it to finish.
+ * Then, it will reload the config, update the offlinePlayerList in the
+ * {@link OfflinePlayerHandler}, update the {@link DebugLevel}, update
+ * the share-settings in {@link ShareManager} and topListSize-settings
+ * in {@link StatCalculator}, and update the MessageBuilders in the
+ * {@link OutputManager}.
+ */
@Override
public void run() {
long time = System.currentTimeMillis();
diff --git a/src/main/java/com/github/artemis/the/gr8/playerstats/statistic/StatAction.java b/src/main/java/com/github/artemis/the/gr8/playerstats/statistic/StatAction.java
index 707d780..9e28075 100644
--- a/src/main/java/com/github/artemis/the/gr8/playerstats/statistic/StatAction.java
+++ b/src/main/java/com/github/artemis/the/gr8/playerstats/statistic/StatAction.java
@@ -11,7 +11,9 @@ import java.util.*;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.RecursiveTask;
-/** The action that is executed when a stat-command is triggered. */
+/**
+ * The action that is executed when a stat-command is triggered.
+ */
final class StatAction extends RecursiveTask> {
private static int threshold;
@@ -23,7 +25,8 @@ final class StatAction extends RecursiveTask>
/**
* Gets the statistic numbers for all players whose name is on the list, puts them in a ConcurrentHashMap
- * using the default ForkJoinPool, and returns the ConcurrentHashMap when everything is done
+ * using the default ForkJoinPool, and returns the ConcurrentHashMap when everything is done.
+ *
* @param offlinePlayerHandler the OfflinePlayerHandler to convert playerNames into Players
* @param playerNames ImmutableList of playerNames for players that should be included in stat calculations
* @param requestSettings a validated requestSettings
diff --git a/src/main/java/com/github/artemis/the/gr8/playerstats/statistic/StatCalculator.java b/src/main/java/com/github/artemis/the/gr8/playerstats/statistic/StatCalculator.java
index b104f01..47c542d 100644
--- a/src/main/java/com/github/artemis/the/gr8/playerstats/statistic/StatCalculator.java
+++ b/src/main/java/com/github/artemis/the/gr8/playerstats/statistic/StatCalculator.java
@@ -46,8 +46,11 @@ public final class StatCalculator {
return numbers.parallelStream().mapToLong(Integer::longValue).sum();
}
- /** Invokes a bunch of worker pool threads to divide and conquer (get the statistics for all players
- that are stored in the {@link OfflinePlayerHandler}) */
+ /**
+ * Invokes a bunch of worker pool threads to divide and conquer
+ * (get the statistics for all players that are stored in the
+ * {@link OfflinePlayerHandler})
+ */
private @NotNull ConcurrentHashMap getAllStatsAsync(RequestSettings requestSettings) {
long time = System.currentTimeMillis();
diff --git a/src/main/java/com/github/artemis/the/gr8/playerstats/statistic/StatThread.java b/src/main/java/com/github/artemis/the/gr8/playerstats/statistic/StatThread.java
index e61ff13..f078242 100644
--- a/src/main/java/com/github/artemis/the/gr8/playerstats/statistic/StatThread.java
+++ b/src/main/java/com/github/artemis/the/gr8/playerstats/statistic/StatThread.java
@@ -12,7 +12,9 @@ import org.jetbrains.annotations.Nullable;
import java.util.*;
-/** The Thread that is in charge of getting and calculating statistics.*/
+/**
+ * The Thread that is in charge of getting and calculating statistics.
+ */
public final class StatThread extends Thread {
private static OutputManager outputManager;
diff --git a/src/main/java/com/github/artemis/the/gr8/playerstats/statistic/request/RequestHandler.java b/src/main/java/com/github/artemis/the/gr8/playerstats/statistic/request/RequestHandler.java
index 5dbcd76..37b520b 100644
--- a/src/main/java/com/github/artemis/the/gr8/playerstats/statistic/request/RequestHandler.java
+++ b/src/main/java/com/github/artemis/the/gr8/playerstats/statistic/request/RequestHandler.java
@@ -1,9 +1,9 @@
package com.github.artemis.the.gr8.playerstats.statistic.request;
import com.github.artemis.the.gr8.playerstats.Main;
+import com.github.artemis.the.gr8.playerstats.enums.Target;
import com.github.artemis.the.gr8.playerstats.utils.EnumHandler;
import com.github.artemis.the.gr8.playerstats.utils.OfflinePlayerHandler;
-import com.github.artemis.the.gr8.playerstats.enums.Target;
import org.bukkit.Material;
import org.bukkit.Statistic;
import org.bukkit.command.CommandSender;
@@ -41,7 +41,7 @@ public final class RequestHandler {
}
/**
- @param sender the CommandSender that requested this specific statistic
+ * @param sender the CommandSender that requested this specific statistic
*/
public static RequestSettings getBasicInternalStatRequest(CommandSender sender) {
RequestSettings request = RequestSettings.getBasicRequest(sender);
@@ -84,15 +84,19 @@ public final class RequestHandler {
}
/**
- This will create a {@link RequestSettings} object from the provided args, with the requesting Player (or Console)
- as CommandSender. This CommandSender will receive feedback messages if the RequestSettings could not be created.
-
- @param args an Array of args such as a CommandSender would put in Minecraft chat:
- - a statName
(example: "mine_block")
- - if applicable, a subStatEntryName
(example: diorite)(
- - a target
for this lookup: can be "top", "server", "player" (or "me" to indicate the current CommandSender)
- - if "player" was chosen, include a playerName
- @return the generated RequestSettings
+ * This will create a {@link RequestSettings} object from the provided args,
+ * with the requesting Player (or Console) as CommandSender. This CommandSender
+ * will receive feedback messages if the RequestSettings could not be created.
+ *
+ * @param args an Array of args such as a CommandSender would put in Minecraft chat:
+ *
+ * - a
statName
(example: "mine_block")
+ * - if applicable, a
subStatEntryName
(example: diorite)
+ * - a
target
for this lookup: can be "top", "server", "player"
+ * (or "me" to indicate the current CommandSender)
+ * - if "player" was chosen, include a
playerName
+ *
+ * @return the generated RequestSettings
*/
public RequestSettings getRequestFromArgs(String[] args) {
EnumHandler enumHandler = Main.getEnumHandler();
@@ -134,9 +138,10 @@ public final class RequestHandler {
}
/**
- Adjust the RequestSettings object if needed: unpack the playerFlag into a subStatEntry,
- try to retrieve the corresponding Enum Constant for any relevant block/entity/item,
- and remove any unnecessary subStatEntries.
+ * Adjust the RequestSettings object if needed: unpack the playerFlag
+ * into a subStatEntry, try to retrieve the corresponding Enum Constant
+ * for any relevant block/entity/item, and remove any unnecessary
+ * subStatEntries.
*/
private void patchRequest(RequestSettings requestSettings) {
if (requestSettings.getStatistic() != null) {
diff --git a/src/main/java/com/github/artemis/the/gr8/playerstats/statistic/request/RequestSettings.java b/src/main/java/com/github/artemis/the/gr8/playerstats/statistic/request/RequestSettings.java
index b429021..aac7aac 100644
--- a/src/main/java/com/github/artemis/the/gr8/playerstats/statistic/request/RequestSettings.java
+++ b/src/main/java/com/github/artemis/the/gr8/playerstats/statistic/request/RequestSettings.java
@@ -10,22 +10,30 @@ import org.bukkit.command.ConsoleCommandSender;
import org.bukkit.entity.EntityType;
import org.jetbrains.annotations.NotNull;
-/** The object PlayerStats uses to calculate and format the requested statistic.
- The settings in this RequestSettings object can be configured from two different sources:
-
- Internally: by PlayerStats itself when /stat is called, using the args provided by the CommandSender.
-
- Externally: through the API methods provided by the {@link RequestGenerator} interface.
-
-
For this RequestSettings object to be valid, the following values need to be set:
-
- - a {@link Statistic}
statistic
- - if this Statistic is not of {@link Statistic.Type} Untyped, a
subStatEntryName
needs to be set,
- together with one of the following values:
-
- for Type.Block: a {@link Material} blockMaterial
-
- for Type.Item: a {@link Material} itemMaterial
-
- for Type.Entity: an {@link EntityType} entityType
- - a {@link Target}
target
(automatically set for all API-requests)
- - if the
target
is Target.Player, a playerName
needs to be added
-
*/
+/**
+ * The object PlayerStats uses to calculate and format the requested
+ * statistic. The settings in this RequestSettings object can be
+ * configured from two different sources:
+ *
- Internally: by PlayerStats itself when /stat is called,
+ * using the args provided by the CommandSender.
+ *
- Externally: through the API methods provided by the
+ * {@link RequestGenerator} interface.
+ *
+ *
For this RequestSettings object to be valid, the following
+ * values need to be set:
+ *
+ * - a {@link Statistic}
statistic
+ * - if this Statistic is not of {@link Statistic.Type} Untyped,
+ * a
subStatEntryName
needs to be set, together with one
+ * of the following values:
+ *
- for Type.Block: a {@link Material} blockMaterial
+ *
- for Type.Item: a {@link Material} itemMaterial
+ *
- for Type.Entity: an {@link EntityType} entityType
+ * - a {@link Target}
target
(defaults to Top)
+ * - if the
target
is Target.Player, a
+ * playerName
needs to be added
+ *
+ */
public final class RequestSettings {
private final CommandSender sender;
@@ -40,14 +48,15 @@ public final class RequestSettings {
private Material item;
private boolean playerFlag;
- /** Create a new {@link RequestSettings} with default values:
-
- CommandSender sender (provided)
-
- Target target = {@link Target#TOP}
-
- int topListSize = 10
-
- boolean playerFlag = false
-
- boolean isAPIRequest
-
- @param sender the CommandSender who prompted this RequestGenerator
+ /**
+ * Create a new {@link RequestSettings} with default values:
+ *
- CommandSender sender (provided)
+ *
- Target target = {@link Target#TOP}
+ *
- int topListSize = 10
+ *
- boolean playerFlag = false
+ *
- boolean isAPIRequest
+ *
+ * @param sender the CommandSender who prompted this RequestGenerator
*/
private RequestSettings(@NotNull CommandSender sender) {
this.sender = sender;
diff --git a/src/main/java/com/github/artemis/the/gr8/playerstats/statistic/request/StatRequest.java b/src/main/java/com/github/artemis/the/gr8/playerstats/statistic/request/StatRequest.java
index baaa848..39d5e9f 100644
--- a/src/main/java/com/github/artemis/the/gr8/playerstats/statistic/request/StatRequest.java
+++ b/src/main/java/com/github/artemis/the/gr8/playerstats/statistic/request/StatRequest.java
@@ -7,10 +7,14 @@ import org.bukkit.Statistic;
import org.bukkit.entity.EntityType;
import org.jetbrains.annotations.Nullable;
-/** Holds all the information PlayerStats needs to perform a lookup, and can be executed
- to get the results. Calling {@link #execute()} on a Top- or ServerRequest can take some
- time (especially if there is a substantial amount of OfflinePlayers on this particular server),
- so I strongly advice you to call this asynchronously! */
+/**
+ * Holds all the information PlayerStats needs to perform
+ * a lookup, and can be executed to get the results. Calling
+ * {@link #execute()} on a Top- or ServerRequest can take some
+ * time (especially if there is a substantial amount of
+ * OfflinePlayers on this particular server), so I strongly
+ * advice you to call this asynchronously!
+ */
public abstract class StatRequest {
protected final RequestSettings requestSettings;
@@ -19,38 +23,56 @@ public abstract class StatRequest {
requestSettings = request;
}
- /** Executes this StatRequest. Don't call this from the Main Thread!
- @return a StatResult containing the value of this lookup, both as numerical value
- and as formatted message*/
+ /**
+ * Executes this StatRequest. Don't call this from the Main Thread!
+ *
+ * @return a StatResult containing the value of this lookup, both as
+ * numerical value and as formatted message
+ */
public abstract StatResult execute();
- /** @return the Statistic this StatRequest will get the data of */
+ /**
+ * @return the Statistic this StatRequest will get the data of
+ * */
public Statistic getStatisticSetting() {
return requestSettings.getStatistic();
}
- /** If the Statistic setting for this StatRequest is of Type.Block,
- this will get the Material that was set
- @return a Material for which #isBlock is true, or null if no Material was set*/
+ /**
+ * If the Statistic setting for this StatRequest is of Type.Block,
+ * this will get the Material that was set.
+ *
+ * @return a Material for which #isBlock is true, or null if no
+ * Material was set
+ */
public @Nullable Material getBlockSetting() {
return requestSettings.getBlock();
}
- /** If the Statistic setting for this StatRequest is of Type.Item,
- this will get the Material that was set
- @return a Material for which #isItem is true, or null if no Material was set*/
+ /**
+ * If the Statistic setting for this StatRequest is of Type.Item,
+ * this will get the Material that was set.
+ *
+ * @return a Material for which #isItem is true, or null if no
+ * Material was set
+ */
public @Nullable Material getItemSetting() {
return requestSettings.getItem();
}
- /** If the Statistic setting for this StatRequest is of Type.Entity,
- this will get the EntityType that was set
- @return an EntityType, or null if no EntityType was set*/
+ /**
+ * If the Statistic setting for this StatRequest is of Type.Entity,
+ * this will get the EntityType that was set.
+ *
+ * @return an EntityType, or null if no EntityType was set
+ */
public @Nullable EntityType getEntitySetting() {
return requestSettings.getEntity();
}
- /** @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() {
return requestSettings.getTarget();
}
diff --git a/src/main/java/com/github/artemis/the/gr8/playerstats/statistic/result/InternalStatResult.java b/src/main/java/com/github/artemis/the/gr8/playerstats/statistic/result/InternalStatResult.java
index 53175a5..51e6c06 100644
--- a/src/main/java/com/github/artemis/the/gr8/playerstats/statistic/result/InternalStatResult.java
+++ b/src/main/java/com/github/artemis/the/gr8/playerstats/statistic/result/InternalStatResult.java
@@ -3,13 +3,20 @@ package com.github.artemis.the.gr8.playerstats.statistic.result;
import com.github.artemis.the.gr8.playerstats.msg.components.ComponentUtils;
import net.kyori.adventure.text.TextComponent;
-/** This Record is used to store stat-results internally, so Players can share them by clicking a share-button.*/
+/**
+ * This Record is used to store stat-results internally,
+ * so Players can share them by clicking a share-button.
+ */
public record InternalStatResult(String executorName, TextComponent formattedValue, int ID) implements StatResult {
- /** Gets the ID number for this StatResult. Unlike for the other {@link StatResult} implementations,
- this one does not return the actual statistic data, because this implementation is meant for internal
- saving-and-sharing only. This method is only for Interface-consistency, InternalStatResult#ID is better.
-
+ /**
+ * Gets the ID number for this StatResult. Unlike for the
+ * other {@link StatResult} implementations, this one does
+ * not return the actual statistic data, because this
+ * implementation is meant for internal saving-and-sharing only.
+ * This method is only for Interface-consistency,
+ * InternalStatResult#ID is better.
+ *
@return Integer that represents this StatResult's ID number
*/
@Override
diff --git a/src/main/java/com/github/artemis/the/gr8/playerstats/statistic/result/StatResult.java b/src/main/java/com/github/artemis/the/gr8/playerstats/statistic/result/StatResult.java
index 1a8e198..3101ed1 100644
--- a/src/main/java/com/github/artemis/the/gr8/playerstats/statistic/result/StatResult.java
+++ b/src/main/java/com/github/artemis/the/gr8/playerstats/statistic/result/StatResult.java
@@ -4,60 +4,73 @@ import com.github.artemis.the.gr8.playerstats.api.ApiFormatter;
import net.kyori.adventure.platform.bukkit.BukkitAudiences;
import net.kyori.adventure.text.TextComponent;
-/** Holds the result of a completed stat-lookup. The Type
parameter
- T
of this StatResult represents the data type of the stored number:
-
- -
Integer
for playerStat
- -
Long
for serverStat
- -
LinkedHashMap(String, Integer)
for topStat
-
- You can get these raw numbers with {@link #getNumericalValue()}. Additionally,
- you can get a formatted message that contains the following information:
-
- - for playerStat:
-
[player-name]: [formatted-number] [stat-name] [sub-stat-name]
- - for serverStat:
-
[Total on] [server-name]: [formatted-number] [stat-name] [sub-stat-name]
- - for topStat:
-
[PlayerStats] [Top x] [stat-name] [sub-stat-name]
-
[1.] [player-name] [.....] [formatted-number]
-
[2.] [player-name] [.....] [formatted-number]
-
[3.] etc...
-
+/**
+ * Holds the result of a completed stat-lookup. The Type
parameter
+ * T
of this StatResult represents the data type of the stored number:
+ *
+ * -
Integer
for playerStat
+ * -
Long
for serverStat
+ * -
LinkedHashMap(String, Integer)
for topStat
+ *
+ * You can get these raw numbers with {@link #getNumericalValue()}. Additionally,
+ * you can get a formatted message that contains the following information:
+ *
+ * - for playerStat:
+ *
[player-name]: [formatted-number] [stat-name] [sub-stat-name]
+ * - for serverStat:
+ *
[Total on] [server-name]: [formatted-number] [stat-name] [sub-stat-name]
+ * - for topStat:
+ *
[PlayerStats] [Top x] [stat-name] [sub-stat-name]
+ *
[1.] [player-name] [.....] [formatted-number]
+ *
[2.] [player-name] [.....] [formatted-number]
+ *
[3.] etc...
+ *
- By default, the resulting message is a {@link TextComponent}, which can be sent directly
- to a Minecraft client or console with the Adventure library. To send a Component,
- you need to get a {@link BukkitAudiences} object, and use that to send the desired Component.
- Normally you would have to add Adventure as a dependency to your project,
- but since the library is included in PlayerStats, you can access it directly.
- Information on how to get and use the BukkitAudiences object can be
- found on Adventure's website.
-
- You can also use the provided {@link #getFormattedString()} method to get the same information
- in String-format. Don't use Adventure's .content() or .toString() methods on the Components
- - those won't get the actual message. And finally, if you want the results to be
- formatted differently, you can get an instance of the {@link ApiFormatter}.
+ * By default, the resulting message is a {@link TextComponent}, which can be
+ * sent directly to a Minecraft client or console with the Adventure library.
+ * To send a Component, you need to get a {@link BukkitAudiences} object,
+ * and use that to send the desired Component. Normally you would have to add
+ * Adventure as a dependency to your project, but since the library is included
+ * in PlayerStats, you can access it through the PlayerStatsAPI. Information
+ * on how to get and use the BukkitAudiences object can be found on
+ * Adventure's website.
+ *
+ *
You can also use the provided {@link #getFormattedString()} method to
+ * get the same information in String-format. Don't use Adventure's .content()
+ * or .toString() methods on the Components - those won't get the actual
+ * message. And finally, if you want the results to be formatted differently,
+ * you can get an instance of the {@link ApiFormatter}.
*/
public interface StatResult {
- /** Gets the raw number for the completed stat-lookup this {@link StatResult} stores.
-
- @return {@code Integer} for playerStat, {@code Long} for serverStat,
- and {@code LinkedHashMap} for topStat*/
+ /**
+ * Gets the raw number for the completed stat-lookup this {@link StatResult}
+ * stores.
+ *
+ * @return {@code Integer} for playerStat, {@code Long} for serverStat,
+ * and {@code LinkedHashMap} for topStat
+ */
T getNumericalValue();
- /** Gets the formatted message for the completed stat-lookup this {@link StatResult} stores.
+ /**
+ * Gets the formatted message for the completed stat-lookup this
+ * {@link StatResult} stores.
- @return a {@code TextComponent} message containing the formatted number.
- This message follows the same style/color/language settings that are specified in the
- PlayerStats config. See class description for more information. */
+ * @return a {@code TextComponent} message containing the formatted number.
+ * This message follows the same style/color/language settings that are
+ * specified in the PlayerStats config. See class description for more
+ * information.
+ */
TextComponent getFormattedTextComponent();
- /** Gets the formatted message for the completed stat-lookup this {@link StatResult} stores.
+ /**
+ * Gets the formatted message for the completed stat-lookup this
+ * {@link StatResult} stores.
- @return a String message containing the formatted number. This message follows
- the same style and color settings that are specified in the PlayerStats config,
- but it is not translatable (it is always plain English). See class description
- for more information.*/
+ * @return a String message containing the formatted number. This message
+ * follows the same style and color settings that are specified in the
+ * PlayerStats config, but it is not translatable (it is always plain English).
+ * See class description for more information.
+ */
String getFormattedString();
}
\ No newline at end of file
diff --git a/src/main/java/com/github/artemis/the/gr8/playerstats/utils/EnumHandler.java b/src/main/java/com/github/artemis/the/gr8/playerstats/utils/EnumHandler.java
index 9c0c28c..0c80b1f 100644
--- a/src/main/java/com/github/artemis/the/gr8/playerstats/utils/EnumHandler.java
+++ b/src/main/java/com/github/artemis/the/gr8/playerstats/utils/EnumHandler.java
@@ -12,11 +12,13 @@ import java.util.List;
import java.util.stream.Collectors;
import java.util.stream.Stream;
-/** This class deals with Bukkit Enumerators. It holds private lists of all
- block-, item-, entity- and statistic-names, and has one big list of all
- possible sub-statistic-entries (block/item/entity). It can give the names
- of all aforementioned enums, check if something is a valid enum constant,
- and turn a name into its corresponding enum constant. */
+/**
+ * This class deals with Bukkit Enumerators. It holds private lists of all
+ * block-, item-, entity- and statistic-names, and has one big list of all
+ * possible sub-statistic-entries (block/item/entity). It can give the names
+ * of all aforementioned enums, check if something is a valid enum constant,
+ * and turn a name into its corresponding enum constant.
+ */
public final class EnumHandler {
private static List blockNames;
@@ -28,24 +30,33 @@ public final class EnumHandler {
prepareLists();
}
- /** Returns all block-names in lowercase */
+ /**
+ * Returns all block-names in lowercase.
+ */
public List getBlockNames() {
return blockNames;
}
- /** Returns all item-names in lowercase*/
+ /**
+ * Returns all item-names in lowercase.
+ */
public List getItemNames() {
return itemNames;
}
- /** Returns all statistic-names in lowercase */
+ /**
+ * Returns all statistic-names in lowercase.
+ */
public List getStatNames() {
return statNames;
}
- /** Returns the corresponding Material enum constant for an itemName
- @param itemName String, case-insensitive
- @return Material enum constant, uppercase */
+ /**
+ * Returns the corresponding Material enum constant for an itemName.
+ *
+ * @param itemName String, case-insensitive
+ * @return Material enum constant, uppercase
+ */
public static @Nullable Material getItemEnum(String itemName) {
if (itemName == null) return null;
@@ -53,9 +64,12 @@ public final class EnumHandler {
return (item != null && item.isItem()) ? item : null;
}
- /** Returns the corresponding EntityType enum constant for an entityName
- @param entityName String, case-insensitive
- @return EntityType enum constant, uppercase */
+ /**
+ * Returns the corresponding EntityType enum constant for an entityName.
+ *
+ * @param entityName String, case-insensitive
+ * @return EntityType enum constant, uppercase
+ */
public static @Nullable EntityType getEntityEnum(String entityName) {
try {
return EntityType.valueOf(entityName.toUpperCase());
@@ -65,9 +79,12 @@ public final class EnumHandler {
}
}
- /** Returns the corresponding Material enum constant for a materialName
- @param materialName String, case-insensitive
- @return Material enum constant, uppercase */
+ /**
+ * Returns the corresponding Material enum constant for a materialName.
+ *
+ * @param materialName String, case-insensitive
+ * @return Material enum constant, uppercase
+ */
public static @Nullable Material getBlockEnum(String materialName) {
if (materialName == null) return null;
@@ -75,8 +92,11 @@ public final class EnumHandler {
return (block != null && block.isBlock()) ? block : null;
}
- /** Returns the statistic enum constant, or null if that failed.
- @param statName String, case-insensitive */
+ /**
+ * Returns the statistic enum constant, or null if that failed.
+ *
+ * @param statName String, case-insensitive
+ */
public static @Nullable Statistic getStatEnum(@NotNull String statName) {
try {
return Statistic.valueOf(statName.toUpperCase());
@@ -86,25 +106,37 @@ public final class EnumHandler {
}
}
- /** Checks if string is a valid statistic
- @param statName String, case-insensitive */
+ /**
+ * Checks if string is a valid statistic.
+ *
+ * @param statName String, case-insensitive
+ */
public boolean isStatistic(@NotNull String statName) {
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 an entity-type statistic.
+ */
public boolean isEntityStatistic(String statName) {
return statName.equalsIgnoreCase(Statistic.ENTITY_KILLED_BY.toString()) ||
statName.equalsIgnoreCase(Statistic.KILL_ENTITY.toString());
}
- /** Checks if this statistic is a subStatEntry, meaning it is a block, item or entity
- @param statName String, case-insensitive*/
+ /**
+ * Checks if this statistic is a subStatEntry, meaning it is a block,
+ * item or entity.
+ *
+ * @param statName String, case-insensitive
+ */
public boolean isSubStatEntry(@NotNull String statName) {
return subStatNames.contains(statName.toLowerCase());
}
- /** Returns "block", "entity", "item", or "sub-statistic" if the provided Type is null. */
+ /**
+ * Returns "block", "entity", "item", or "sub-statistic" if the
+ * provided Type is null.
+ */
public static String getSubStatTypeName(Statistic.Type statType) {
String subStat = "sub-statistic";
if (statType == null) return subStat;
diff --git a/src/main/java/com/github/artemis/the/gr8/playerstats/utils/MyLogger.java b/src/main/java/com/github/artemis/the/gr8/playerstats/utils/MyLogger.java
index a233f44..fbaf3b0 100644
--- a/src/main/java/com/github/artemis/the/gr8/playerstats/utils/MyLogger.java
+++ b/src/main/java/com/github/artemis/the/gr8/playerstats/utils/MyLogger.java
@@ -10,7 +10,9 @@ import java.util.Collections;
import java.util.concurrent.ConcurrentHashMap;
import java.util.logging.Logger;
-/** The PlayerStats Logger*/
+/**
+ * The PlayerStats Logger
+ */
public final class MyLogger {
private static final Logger logger;
@@ -28,11 +30,13 @@ public final class MyLogger {
private MyLogger() {
}
- /** Sets the desired debugging level.
-
1 = low (only show unexpected errors)
-
2 = medium (detail all encountered exceptions, log main tasks and show time taken)
-
3 = high (log all tasks and time taken)
-
Default: 1*/
+ /**
+ * Sets the desired debugging level.
+ *
1 = low (only show unexpected errors)
+ *
2 = medium (detail all encountered exceptions, log main tasks and show time taken)
+ *
3 = high (log all tasks and time taken)
+ *
Default: 1
+ */
public static void setDebugLevel(int level) {
if (level == 2) {
debugLevel = DebugLevel.MEDIUM;
@@ -65,12 +69,16 @@ public final class MyLogger {
logger.warning(content);
}
- /** Log the encountered exception as a warning to console,
- with some information about which class/method caught it
- and with a printStackTrace if DebugLevel is HIGH.
- @param exception The encountered exception
- @param caughtBy The name of the class that caught the exception
- @param additionalInfo e.g. the method-name or line where the exception is caught */
+ /**
+ * Log the encountered exception as a warning to console,
+ * with some information about which class/method caught it
+ * and with a printStackTrace if DebugLevel is HIGH.
+ *
+ * @param exception The encountered exception
+ * @param caughtBy The name of the class that caught the exception
+ * @param additionalInfo e.g. the method-name or line where the
+ * exception is caught
+ */
public static void logException(@NotNull Exception exception, String caughtBy, @Nullable String additionalInfo) {
String extraInfo = (additionalInfo != null) ? " [" + additionalInfo + "]" : "";
String info = " (" + caughtBy + extraInfo + ")";
@@ -81,8 +89,13 @@ public final class MyLogger {
}
}
- /** If DebugLevel is MEDIUM or HIGH, output to console that an action has started.
- @param taskLength Length of the action (in terms of units-to-process)*/
+ /**
+ * If DebugLevel is MEDIUM or HIGH, output to console that an
+ * action has started.
+ *
+ * @param taskLength Length of the action (in terms of
+ * units-to-process)
+ */
public static void actionCreated(int taskLength) {
if (debugLevel != DebugLevel.LOW) {
threadNames = new ConcurrentHashMap<>();
@@ -90,9 +103,13 @@ public final class MyLogger {
}
}
- /** Internally save the name of the executing thread for later logging of this action.
- The list of names is reset upon the start of every new action.
- @param threadName Name of the executing thread*/
+ /**
+ * Internally save the name of the executing thread for later
+ * logging of this action. The list of names is reset upon the
+ * start of every new action.
+ *
+ * @param threadName Name of the executing thread
+ */
public static void subActionCreated(String threadName) {
if (debugLevel == DebugLevel.HIGH) {
if (!threadNames.containsKey(threadName)) {
@@ -101,8 +118,11 @@ public final class MyLogger {
}
}
- /** Internally save the name of the executing thread for logging.
- @param threadName Name of the executing thread */
+ /**
+ * Internally save the name of the executing thread for logging.
+ *
+ * @param threadName Name of the executing thread
+ */
public static void actionRunning(String threadName) {
if (debugLevel != DebugLevel.LOW) {
if (!threadNames.containsKey(threadName)) {
@@ -111,8 +131,11 @@ public final class MyLogger {
}
}
- /** Output to console that an action has finished if DebugLevel is MEDIUM or higher.
- If DebugLevel is HIGH, also output the names of the threads that were used. */
+ /**
+ * Output to console that an action has finished if DebugLevel is
+ * MEDIUM or higher. If DebugLevel is HIGH, also output the names
+ * of the threads that were used.
+ */
public static void actionFinished() {
if (debugLevel != DebugLevel.LOW) {
logger.info("Finished Recursive Action! In total " +
@@ -133,10 +156,13 @@ public final class MyLogger {
printTime(className, methodName, startTime);
}
- /** Output to console how long a certain task has taken.
- @param className Name of the class executing the task
- @param methodName Name or description of the task
- @param startTime Timestamp marking the beginning of the task */
+ /**
+ * Output to console how long a certain task has taken.
+ *
+ * @param className Name of the class executing the task
+ * @param methodName Name or description of the task
+ * @param startTime Timestamp marking the beginning of the task
+ */
private static void printTime(String className, String methodName, long startTime) {
logger.info(className + " " + methodName + ": " + (System.currentTimeMillis() - startTime) + "ms");
}
diff --git a/src/main/java/com/github/artemis/the/gr8/playerstats/utils/OfflinePlayerHandler.java b/src/main/java/com/github/artemis/the/gr8/playerstats/utils/OfflinePlayerHandler.java
index 49abbf2..11a4562 100644
--- a/src/main/java/com/github/artemis/the/gr8/playerstats/utils/OfflinePlayerHandler.java
+++ b/src/main/java/com/github/artemis/the/gr8/playerstats/utils/OfflinePlayerHandler.java
@@ -6,9 +6,12 @@ import org.bukkit.OfflinePlayer;
import java.util.*;
import java.util.concurrent.ConcurrentHashMap;
-/** A utility class that deals with OfflinePlayers. It stores a list of all OfflinePlayer-names
- that need to be included in statistic calculations, and can retrieve the corresponding OfflinePlayer
- object for a given player-name.*/
+/**
+ * A utility class that deals with OfflinePlayers. It stores a list
+ * of all OfflinePlayer-names that need to be included in statistic
+ * calculations, and can retrieve the corresponding OfflinePlayer
+ * object for a given player-name.
+ */
public final class OfflinePlayerHandler {
private static ConcurrentHashMap offlinePlayerUUIDs;
@@ -22,6 +25,7 @@ public final class OfflinePlayerHandler {
/**
* Get a new HashMap that stores the players to include in stat calculations.
* This HashMap is stored as a private variable in OfflinePlayerHandler.
+ *
* @param playerList ConcurrentHashMap with keys: playerNames and values: UUIDs
*/
public static void updateOfflinePlayerList(ConcurrentHashMap playerList) {
@@ -29,27 +33,40 @@ public final class OfflinePlayerHandler {
playerNames = Collections.list(offlinePlayerUUIDs.keys());
}
- /** Checks if a given playerName is on the private HashMap of players that should be included in statistic calculations
- @param playerName String, case-sensitive */
+ /**
+ * Checks if a given playerName is on the private HashMap of players
+ * that should be included in statistic calculations.
+ *
+ * @param playerName String, case-sensitive
+ */
public boolean isRelevantPlayer(String playerName) {
return offlinePlayerUUIDs.containsKey(playerName);
}
- /** Returns the number of OfflinePlayers that are included in statistic calculations */
+ /**
+ * Returns the number of OfflinePlayers that are included in
+ * statistic calculations
+ */
public int getOfflinePlayerCount() {
return offlinePlayerUUIDs.size();
}
- /** Get an ArrayList of names from all OfflinePlayers that should be included in statistic calculations */
+ /**
+ * Gets an ArrayList of names from all OfflinePlayers that should
+ * be included in statistic calculations.
+ */
public ArrayList getOfflinePlayerNames() {
return playerNames;
}
/**
- * Uses the playerName to get the player's UUID from a private HashMap, and uses the UUID to get the corresponding OfflinePlayer Object.
+ * Uses the playerName to get the player's UUID from a private HashMap,
+ * and uses the UUID to get the corresponding OfflinePlayer Object.
+ *
* @param playerName name of the target player (case-sensitive)
* @return OfflinePlayer
- * @throws IllegalArgumentException if this player is not on the list of players that should be included in statistic calculations
+ * @throws IllegalArgumentException if this player is not on the list
+ * of players that should be included in statistic calculations
*/
public OfflinePlayer getOfflinePlayer(String playerName) throws IllegalArgumentException {
if (offlinePlayerUUIDs.get(playerName) != null) {
diff --git a/src/main/java/com/github/artemis/the/gr8/playerstats/utils/UnixTimeHandler.java b/src/main/java/com/github/artemis/the/gr8/playerstats/utils/UnixTimeHandler.java
index 6275351..415aa6e 100644
--- a/src/main/java/com/github/artemis/the/gr8/playerstats/utils/UnixTimeHandler.java
+++ b/src/main/java/com/github/artemis/the/gr8/playerstats/utils/UnixTimeHandler.java
@@ -1,15 +1,24 @@
package com.github.artemis.the.gr8.playerstats.utils;
-/** A small utility class that calculates with unix time.*/
+/**
+ * A small utility class that calculates with unix time.
+ */
public final class UnixTimeHandler {
private UnixTimeHandler() {
}
- /** Calculates whether a player has played recently enough to fall within the lastPlayedLimit.
- If lastPlayedLimit == 0, this always returns true (since there is no limit).
- @param lastPlayed a long that represents the amount of milliseconds between the unix start point and the time this player last joined
- @param lastPlayedLimit a long that represents the maximum-number-of-days-since-last-joined */
+ /**
+ * Calculates whether a player has played recently enough
+ * to fall within the lastPlayedLimit. If lastPlayedLimit == 0,
+ * this always returns true (since there is no limit).
+ *
+ * @param lastPlayed a long that represents the amount of
+ * milliseconds between the unix start point
+ * and the time this player last joined
+ * @param lastPlayedLimit a long that represents the maximum-
+ * number-of-days-since-last-joined
+ */
public static boolean hasPlayedSince(long lastPlayedLimit, long lastPlayed) {
long maxLastPlayed = System.currentTimeMillis() - lastPlayedLimit * 24 * 60 * 60 * 1000;
return lastPlayedLimit == 0 || lastPlayed >= maxLastPlayed;
diff --git a/src/main/resources/plugin.yml b/src/main/resources/plugin.yml
index 3b2d77e..791b87e 100644
--- a/src/main/resources/plugin.yml
+++ b/src/main/resources/plugin.yml
@@ -1,6 +1,6 @@
main: com.github.artemis.the.gr8.playerstats.Main
name: PlayerStats
-version: 1.6.1
+version: 1.7
api-version: 1.13
description: adds commands to view player statistics in chat
author: Artemis_the_gr8