diff --git a/src/main/java/com/gmail/artemis/the/gr8/playerstats/api/Formatter.java b/src/main/java/com/gmail/artemis/the/gr8/playerstats/api/Formatter.java index 86573ac..a1d6d11 100644 --- a/src/main/java/com/gmail/artemis/the/gr8/playerstats/api/Formatter.java +++ b/src/main/java/com/gmail/artemis/the/gr8/playerstats/api/Formatter.java @@ -1,7 +1,7 @@ package com.gmail.artemis.the.gr8.playerstats.api; -import com.gmail.artemis.the.gr8.playerstats.enums.Unit; import net.kyori.adventure.text.TextComponent; +import org.bukkit.Statistic; public interface Formatter extends StatFormatter { @@ -15,5 +15,7 @@ public interface Formatter extends StatFormatter { TextComponent getRainbowPluginPrefixAsTitle(); - TextComponent formatSingleTopStatLine(int positionInTopList, String playerName, long statNumber, Unit statNumberUnit); -} + /** @return a single line from a top-x statistic: + *
x. Player-name ......... number */ + TextComponent formatSingleTopStatLine(int positionInTopList, String playerName, long statNumber, Statistic statistic); +} \ No newline at end of file diff --git a/src/main/java/com/gmail/artemis/the/gr8/playerstats/api/RequestGenerator.java b/src/main/java/com/gmail/artemis/the/gr8/playerstats/api/RequestGenerator.java index abd6ff0..2b8efc6 100644 --- a/src/main/java/com/gmail/artemis/the/gr8/playerstats/api/RequestGenerator.java +++ b/src/main/java/com/gmail/artemis/the/gr8/playerstats/api/RequestGenerator.java @@ -1,7 +1,6 @@ package com.gmail.artemis.the.gr8.playerstats.api; import com.gmail.artemis.the.gr8.playerstats.statistic.request.StatRequest; -import com.gmail.artemis.the.gr8.playerstats.statistic.result.StatResult; import org.bukkit.Material; import org.bukkit.Statistic; import org.bukkit.entity.EntityType; diff --git a/src/main/java/com/gmail/artemis/the/gr8/playerstats/msg/MessageBuilder.java b/src/main/java/com/gmail/artemis/the/gr8/playerstats/msg/MessageBuilder.java index cce5776..d8f68f8 100644 --- a/src/main/java/com/gmail/artemis/the/gr8/playerstats/msg/MessageBuilder.java +++ b/src/main/java/com/gmail/artemis/the/gr8/playerstats/msg/MessageBuilder.java @@ -268,7 +268,7 @@ public final class MessageBuilder { }; } - public TextComponent singleTopStatLine(int positionInTopList, String playerName, long statNumber, Unit statNumberUnit) { + public TextComponent singleTopStatLine(int positionInTopList, String playerName, long statNumber, Statistic statistic) { TextComponent.Builder topStatLineBuilder = Component.text() .append(space()) .append(componentFactory.rankNumber(positionInTopList)) @@ -279,7 +279,11 @@ public final class MessageBuilder { } else { topStatLineBuilder.append(componentFactory.playerName(playerName + ":", Target.TOP)); } - //TODO add formatted number here + + return topStatLineBuilder + .append(space()) + .append(getStatNumberComponent(statistic, Target.TOP, statNumber)) + .build(); } private Component getSharerNameComponent(CommandSender sender) { @@ -370,8 +374,11 @@ public final class MessageBuilder { } private TextComponent getStatNumberComponent(StatRequest request, long statNumber) { - Unit.Type statUnitType = Unit.getTypeFromStatistic(request.getStatistic()); - Target target = request.getTarget(); + return getStatNumberComponent(request.getStatistic(), request.getTarget(), statNumber); + } + + private TextComponent getStatNumberComponent(Statistic statistic, Target target, long statNumber) { + Unit.Type statUnitType = Unit.getTypeFromStatistic(statistic); return switch (statUnitType) { case DISTANCE -> getDistanceNumberComponent(statNumber, target); case DAMAGE -> getDamageNumberComponent(statNumber, target); @@ -380,12 +387,6 @@ public final class MessageBuilder { }; } - private TextComponent getStatNumberComponent(Unit unit, Target target, long statNumber) { - return switch (unit.getType()) { - case DISTANCE -> - } - } - private TextComponent getDistanceNumberComponent(long statNumber, Target target) { Unit statUnit = Unit.fromString(config.getDistanceUnit(false)); String prettyNumber = formatter.formatDistanceNumber(statNumber, statUnit); diff --git a/src/main/java/com/gmail/artemis/the/gr8/playerstats/msg/OutputManager.java b/src/main/java/com/gmail/artemis/the/gr8/playerstats/msg/OutputManager.java index b17dd4a..00066dc 100644 --- a/src/main/java/com/gmail/artemis/the/gr8/playerstats/msg/OutputManager.java +++ b/src/main/java/com/gmail/artemis/the/gr8/playerstats/msg/OutputManager.java @@ -4,7 +4,6 @@ import com.gmail.artemis.the.gr8.playerstats.ShareManager; import com.gmail.artemis.the.gr8.playerstats.api.Formatter; import com.gmail.artemis.the.gr8.playerstats.config.ConfigHandler; import com.gmail.artemis.the.gr8.playerstats.enums.StandardMessage; -import com.gmail.artemis.the.gr8.playerstats.enums.Unit; import com.gmail.artemis.the.gr8.playerstats.msg.components.ComponentFactory; import com.gmail.artemis.the.gr8.playerstats.statistic.request.StatRequest; import com.gmail.artemis.the.gr8.playerstats.msg.components.BukkitConsoleComponentFactory; @@ -78,8 +77,8 @@ public final class OutputManager implements Formatter { } @Override - public TextComponent formatSingleTopStatLine(int positionInTopList, String playerName, long statNumber, Unit statNumberUnit) { - return null; + public TextComponent formatSingleTopStatLine(int positionInTopList, String playerName, long statNumber, Statistic statistic) { + return messageBuilder.singleTopStatLine(positionInTopList, playerName, statNumber, statistic); } @Override @@ -139,7 +138,7 @@ public final class OutputManager implements Formatter { public void sendHelp(@NotNull CommandSender sender) { adventure.sender(sender).sendMessage(getMessageBuilder(sender) - .helpMsg(); + .helpMsg()); } public void sendToAllPlayers(@NotNull TextComponent component) {