More color experimentations

This commit is contained in:
Artemis-the-gr8 2022-06-16 22:51:04 +02:00
parent f26a9d24b1
commit 5790c697a3
4 changed files with 85 additions and 11 deletions

View File

@ -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.
<p>Default: "Top"</p>*/
public String getTopStatsTitel() {
return config.getString("top-list-title", "Top");
}
/** Returns a String that represents the title for a server stat.
<p>Default: "Total on"</p> */
public String getServerTitle() {

View File

@ -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));

View File

@ -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 = "<rainbow:16>" + underscores + " [PlayerStats] " + underscores + "</rainbow>";
String title = "<rainbow:16>" + prefixTitle + "</rainbow>";
return text()
.append(MiniMessage.miniMessage().deserialize(title))
.build();
}
}
@Override
protected TextComponent pluginPrefix() {
return text().append(MiniMessage.miniMessage().deserialize("<#fc3661>[</#fc3661>" +
"<#fe4550>P</#fe4550>" +
"<#fe5640>l</#fe5640>" +
"<#fb6731>a</#fb6731>" +
"<#f67824>y</#f67824>" +
"<#ee8a19>e</#ee8a19>" +
"<#e49b0f>r</#e49b0f>" +
"<#d9ac08>S</#d9ac08>" +
"<#cbbd03>t</#cbbd03>" +
"<#bccb01>a</#bccb01>" +
"<#acd901>t</#acd901>" +
"<#9be503>s</#9be503>" +
"<#8aee08>] </#8aee08>")).build();
// <#fe4550></#fe4550><#fe5640>P</#fe5640><#fb6731>l</#fb6731><#f67824>a</#f67824><#ee8a19>y</#ee8a19><#e49b0f>e</#e49b0f><#FFB80E></#FFB80E><#cbbd03>S</#cbbd03><#bccb01>t</#bccb01><#acd901></#acd901><#9be503></#9be503><#8BD448>s</#8BD448><#2AA8F2>]</#2AA8F2>]]
// <#205bf3>_</#205bf3>
// <#2d4afa>_</#2d4afa>
// <#3b3bfd>_</#3b3bfd>
// <#4a2dfe>_</#4a2dfe>
// <#5b20fd>_</#5b20fd>
// <#6c15fa>_</#6c15fa>
// <#7e0df4>_</#7e0df4>
// <#9006eb>_</#9006eb>
// <#a102e1>_</#a102e1>
// <#b201d5>_</#b201d5>
// <#c201c7>_</#c201c7>
// <#d005b7>_</#d005b7>
// <#dd0aa7> </#dd0aa7>
// <#e81296> </#e81296>
// <#f11c84> </#f11c84>
// <#f82872> </#f82872>
// <#fc3661>[</#fc3661>
// <#fe4550>P</#fe4550>
// <#fe5640>l</#fe5640>
// <#fb6731>a</#fb6731>
// <#f67824>y</#f67824>
// <#ee8a19>e</#ee8a19>
// <#e49b0f>r</#e49b0f>
// <#d9ac08>S</#d9ac08>
// <#cbbd03>t</#cbbd03>
// <#bccb01>a</#bccb01>
// <#acd901>t</#acd901>
// <#9be503>s</#9be503>
// <#8aee08>]</#8aee08>
// <#78f60f> </#78f60f>
// <#67fb19> </#67fb19>
// <#55fe24> </#55fe24>
// <#45fe31> </#45fe31>
// <#36fc40>_</#36fc40>
// <#28f850>_</#28f850>
// <#1cf161>_</#1cf161>
// <#12e872>_</#12e872>
// <#0add84>_</#0add84>
// <#05d095>_</#05d095>
// <#01c1a7>_</#01c1a7>
// <#01b2b7>_</#01b2b7>
// <#02a1c6>_</#02a1c6>
// <#0690d4>_</#0690d4>
// <#0d7ee1>_</#0d7ee1>
// <#156ceb>_</#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) {

View File

@ -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