diff --git a/src/main/java/com/gmail/artemis/the/gr8/playerstats/config/ConfigHandler.java b/src/main/java/com/gmail/artemis/the/gr8/playerstats/config/ConfigHandler.java index a52494f..8244505 100644 --- a/src/main/java/com/gmail/artemis/the/gr8/playerstats/config/ConfigHandler.java +++ b/src/main/java/com/gmail/artemis/the/gr8/playerstats/config/ConfigHandler.java @@ -89,6 +89,11 @@ public class ConfigHandler { return config.getInt("top-list-max-size", 10); } + /** Returns a String that represents the title for a top statistic. +

Default: "Top"

*/ + public String getTopStatsTitel() { + return config.getString("top-list-title", "Top"); + } /** Returns a String that represents the title for a server stat.

Default: "Total on"

*/ public String getServerTitle() { diff --git a/src/main/java/com/gmail/artemis/the/gr8/playerstats/msg/MessageFactory.java b/src/main/java/com/gmail/artemis/the/gr8/playerstats/msg/MessageFactory.java index 9dc1b50..e4de42d 100644 --- a/src/main/java/com/gmail/artemis/the/gr8/playerstats/msg/MessageFactory.java +++ b/src/main/java/com/gmail/artemis/the/gr8/playerstats/msg/MessageFactory.java @@ -236,7 +236,7 @@ public class MessageFactory { protected TextComponent getTopStatTitle(int topLength, String statName, String subStatEntryName, boolean isConsoleSender) { return Component.newline() .append(pluginPrefix()) - .append(titleComponent(Query.TOP, "Top")).append(space()) + .append(titleComponent(Query.TOP, config.getTopStatsTitel())).append(space()) .append(titleNumberComponent(topLength)).append(space()) .append(statNameComponent(Query.TOP, statName)).append(space()) .append(subStatNameComponent(Query.TOP, subStatEntryName)); diff --git a/src/main/java/com/gmail/artemis/the/gr8/playerstats/msg/PrideMessageFactory.java b/src/main/java/com/gmail/artemis/the/gr8/playerstats/msg/PrideMessageFactory.java index c7bf8cb..7bfaf29 100644 --- a/src/main/java/com/gmail/artemis/the/gr8/playerstats/msg/PrideMessageFactory.java +++ b/src/main/java/com/gmail/artemis/the/gr8/playerstats/msg/PrideMessageFactory.java @@ -15,6 +15,7 @@ import static net.kyori.adventure.text.Component.*; public class PrideMessageFactory extends MessageFactory { private static ConfigHandler config; + private final String prefixTitle = "____________ [PlayerStats] ____________"; //12 underscores public PrideMessageFactory(ConfigHandler c) { super(c); @@ -27,14 +28,78 @@ public class PrideMessageFactory extends MessageFactory { return super.getPrefixAsTitle(true); } else { - String underscores = "____________"; //12 underscores - String title = "" + underscores + " [PlayerStats] " + underscores + ""; + String title = "" + prefixTitle + ""; return text() .append(MiniMessage.miniMessage().deserialize(title)) .build(); } } + @Override + protected TextComponent pluginPrefix() { + return text().append(MiniMessage.miniMessage().deserialize("<#fc3661>[" + + "<#fe4550>P" + + "<#fe5640>l" + + "<#fb6731>a" + + "<#f67824>y" + + "<#ee8a19>e" + + "<#e49b0f>r" + + "<#d9ac08>S" + + "<#cbbd03>t" + + "<#bccb01>a" + + "<#acd901>t" + + "<#9be503>s" + + "<#8aee08>] ")).build(); + // <#fe4550><#fe5640>P<#fb6731>l<#f67824>a<#ee8a19>y<#e49b0f>e<#FFB80E><#cbbd03>S<#bccb01>t<#acd901><#9be503><#8BD448>s<#2AA8F2>]]] + // <#205bf3>_ + // <#2d4afa>_ + // <#3b3bfd>_ + // <#4a2dfe>_ + // <#5b20fd>_ + // <#6c15fa>_ + // <#7e0df4>_ + // <#9006eb>_ + // <#a102e1>_ + // <#b201d5>_ + // <#c201c7>_ + // <#d005b7>_ + // <#dd0aa7> + // <#e81296> + // <#f11c84> + // <#f82872> + // <#fc3661>[ + // <#fe4550>P + // <#fe5640>l + // <#fb6731>a + // <#f67824>y + // <#ee8a19>e + // <#e49b0f>r + // <#d9ac08>S + // <#cbbd03>t + // <#bccb01>a + // <#acd901>t + // <#9be503>s + // <#8aee08>] + // <#78f60f> + // <#67fb19> + // <#55fe24> + // <#45fe31> + // <#36fc40>_ + // <#28f850>_ + // <#1cf161>_ + // <#12e872>_ + // <#0add84>_ + // <#05d095>_ + // <#01c1a7>_ + // <#01b2b7>_ + // <#02a1c6>_ + // <#0690d4>_ + // <#0d7ee1>_ + // <#156ceb>_ + + } + + /* @Override protected TextComponent getTopStatTitle(int topLength, String statName, String subStatEntryName, boolean isConsoleSender) { if (isConsoleSender && Bukkit.getName().equalsIgnoreCase("CraftBukkit")) { @@ -42,32 +107,36 @@ public class PrideMessageFactory extends MessageFactory { } else { MinecraftFont font = new MinecraftFont(); - TextComponent prefixTitle = getPrefixAsTitle(false); TextComponent statTitle = Component.text() - .append(titleComponent(Query.TOP, "Top")).append(space()) + .append(titleComponent(Query.TOP, config.getTopStatsTitel())).append(space()) .append(titleNumberComponent(topLength)).append(space()) .append(statNameComponent(Query.TOP, statName)).append(space()) .append(subStatNameComponent(Query.TOP, subStatEntryName)) .build(); - - if (font.getWidth(prefixTitle.content()) > font.getWidth(statTitle.content())) { + String title = config.getTopStatsTitel() + " " + topLength + " " + statName + " " + subStatEntryName; + if (font.getWidth(prefixTitle) > font.getWidth(title)) { //divide by 4 to get spaces, then by 2 to get distance needed at the front - int spaces = (int) Math.round((double) (font.getWidth(prefixTitle.content()) - font.getWidth(statTitle.content()))/8); + int spaces = (int) Math.round((double) (font.getWidth(prefixTitle) - font.getWidth(title))/8); + Bukkit.getLogger().info("Width of prefixTitle: " + font.getWidth(prefixTitle)); + Bukkit.getLogger().info("Width of statTitle: " + font.getWidth(title)); + Bukkit.getLogger().info("Spaces: " + spaces); + String space = " ".repeat(spaces); return Component.newline() - .append(prefixTitle) + .append(getPrefixAsTitle(false)) .append(newline()) .append(text(space)) .append(statTitle); } else { return Component.newline() - .append(prefixTitle) + .append(getPrefixAsTitle(false)) .append(newline()) .append(statTitle); } } } + */ @Override protected TextComponent dotsComponent(String dots, boolean isConsoleSender) { diff --git a/src/main/resources/config.yml b/src/main/resources/config.yml index 920c8bc..163a6be 100644 --- a/src/main/resources/config.yml +++ b/src/main/resources/config.yml @@ -37,7 +37,7 @@ use-dots: true top-list-max-size: 10 # The title above the top list (this will become 'Top 10 animals bred', for example) -top-list-title: 'Top [x]' +top-list-title: 'Top' # The title in front of a total-on-this-server statistic # This will become 'Total on this server: [n] animals bred', for example