From 928aae3173b9d70faa5d5e85597134559b6add91 Mon Sep 17 00:00:00 2001 From: Artemis-the-gr8 Date: Sat, 20 Aug 2022 21:17:14 +0200 Subject: [PATCH] Added another formatting method to the API --- dependency-reduced-pom.xml | 2 +- pom.xml | 2 +- .../the/gr8/playerstats/api/ApiFormatter.java | 22 +++++++++++++++++++ .../gr8/playerstats/msg/MessageBuilder.java | 10 +++++++++ src/main/resources/plugin.yml | 2 +- 5 files changed, 35 insertions(+), 3 deletions(-) diff --git a/dependency-reduced-pom.xml b/dependency-reduced-pom.xml index 3e03ef8..342c928 100644 --- a/dependency-reduced-pom.xml +++ b/dependency-reduced-pom.xml @@ -4,7 +4,7 @@ io.github.ithotl PlayerStats PlayerStats - 1.7.1 + 1.7.2-SNAPSHOT Statistics Plugin https://www.spigotmc.org/resources/playerstats.102347/ diff --git a/pom.xml b/pom.xml index fbb7e18..64025d6 100644 --- a/pom.xml +++ b/pom.xml @@ -6,7 +6,7 @@ io.github.ithotl PlayerStats - 1.7.1 + 1.7.2-SNAPSHOT PlayerStats Statistics Plugin diff --git a/src/main/java/com/artemis/the/gr8/playerstats/api/ApiFormatter.java b/src/main/java/com/artemis/the/gr8/playerstats/api/ApiFormatter.java index 3431afc..e6f8b1f 100644 --- a/src/main/java/com/artemis/the/gr8/playerstats/api/ApiFormatter.java +++ b/src/main/java/com/artemis/the/gr8/playerstats/api/ApiFormatter.java @@ -80,6 +80,16 @@ public interface ApiFormatter { */ TextComponent getStatTitle(Statistic statistic, @Nullable String subStatName); + /** + * 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, + * include the name of the relevant sub-statistic (block, item or entity). + * + * @param statistic the Statistic enum constant to display the name of + * @param unit the Unit to display + * @return [stat-name] [unit] + */ + TextComponent getStatTitle(Statistic statistic, Unit unit); /** * Gets a formatted message that displays the name of this Statistic as it is * displayed by PlayerStats in a top-stat-message. If this Statistic is not @@ -94,6 +104,18 @@ public interface ApiFormatter { */ TextComponent getTopStatTitle(int topStatSize, Statistic statistic, @Nullable String subStatName); + /** + * Gets a formatted message that displays the name of this Statistic as it is + * displayed by PlayerStats in a top-stat-message, with the specified + * Unit in the name. + * + * @param topStatSize the size of the top-list this title is for + * @param statistic the Statistic enum constant for this message + * @param unit the Unit to display + * @return Top [topStatSize] [stat-name] [unit-name] + */ + TextComponent getTopStatTitle(int topStatSize, Statistic statistic, Unit unit); + /** * Formats the input into a single top-statistic line. The stat-number * is formatted into the most suitable {@link Unit} based on the provided diff --git a/src/main/java/com/artemis/the/gr8/playerstats/msg/MessageBuilder.java b/src/main/java/com/artemis/the/gr8/playerstats/msg/MessageBuilder.java index 4a65ed9..3f73883 100644 --- a/src/main/java/com/artemis/the/gr8/playerstats/msg/MessageBuilder.java +++ b/src/main/java/com/artemis/the/gr8/playerstats/msg/MessageBuilder.java @@ -214,11 +214,21 @@ public final class MessageBuilder implements ApiFormatter { return getTopStatTitleComponent(0, statistic, subStatName, null); } + @Override + public TextComponent getStatTitle(Statistic statistic, Unit unit) { + return getTopStatTitleComponent(0, statistic, null, unit); + } + @Override public TextComponent getTopStatTitle(int topListSize, Statistic statistic, @Nullable String subStatName) { return getTopStatTitleComponent(topListSize, statistic, subStatName, null); } + @Override + public TextComponent getTopStatTitle(int topStatSize, Statistic statistic, Unit unit) { + return getTopStatTitleComponent(topStatSize, statistic, null, unit); + } + @Override public TextComponent formatTopStatLine(int positionInTopList, String playerName, long statNumber, Statistic statistic) { TextComponent statNumberComponent = getStatNumberComponent(statNumber, Target.TOP, statistic); diff --git a/src/main/resources/plugin.yml b/src/main/resources/plugin.yml index dda8bef..f10218a 100644 --- a/src/main/resources/plugin.yml +++ b/src/main/resources/plugin.yml @@ -1,6 +1,6 @@ main: com.artemis.the.gr8.playerstats.Main name: PlayerStats -version: 1.7.1 +version: 1.7.2 api-version: 1.13 description: adds commands to view player statistics in chat author: Artemis_the_gr8