Put brackets around subStatNames (#65), made nicer default color scheme, fixed entityNames appearing twice (#68), half-fixed Style issues with stat/subStat Components (#67)

This commit is contained in:
Artemis-the-gr8 2022-06-23 17:30:52 +02:00
parent d225b1e235
commit 8e0666bceb
5 changed files with 33 additions and 27 deletions

View File

@ -40,6 +40,12 @@
<scope>provided</scope> <scope>provided</scope>
</dependency> </dependency>
<dependency>
<groupId>net.kyori</groupId>
<artifactId>adventure-api</artifactId>
<version>4.11.0</version>
</dependency>
<dependency> <dependency>
<groupId>net.kyori</groupId> <groupId>net.kyori</groupId>
<artifactId>adventure-platform-bukkit</artifactId> <artifactId>adventure-platform-bukkit</artifactId>

View File

@ -14,9 +14,6 @@ import org.bukkit.command.PluginCommand;
import org.bukkit.plugin.java.JavaPlugin; import org.bukkit.plugin.java.JavaPlugin;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import java.time.LocalDate;
import java.time.Month;
public class Main extends JavaPlugin { public class Main extends JavaPlugin {

View File

@ -53,7 +53,7 @@ public class MessageFactory {
public TextComponent reloadedConfig(boolean isConsoleSender) { public TextComponent reloadedConfig(boolean isConsoleSender) {
return pluginPrefix(isConsoleSender) return pluginPrefix(isConsoleSender)
.append(text("Config reloaded!") .append(text("Config reloaded!")
.color(NamedTextColor.GREEN)); .color(msgColor));
} }
public TextComponent stillReloading(boolean isConsoleSender) { public TextComponent stillReloading(boolean isConsoleSender) {
@ -257,7 +257,7 @@ public class MessageFactory {
TextDecoration statNameStyle = getStyleFromString(config.getStatNameFormatting(selection, true)); TextDecoration statNameStyle = getStyleFromString(config.getStatNameFormatting(selection, true));
Statistic.Type statType = EnumHandler.getStatType(statName); Statistic.Type statType = EnumHandler.getStatType(statName);
TranslatableComponent subStat = subStatNameComponent(selection, subStatName, statType); TextComponent subStat = subStatNameComponent(selection, subStatName, statType);
TranslatableComponent.Builder totalName; TranslatableComponent.Builder totalName;
String key = getLanguageKey(statName, null, statType); String key = getLanguageKey(statName, null, statType);
@ -271,17 +271,17 @@ public class MessageFactory {
} }
else { else {
totalName = translatable().key(key); totalName = translatable().key(key);
if (subStat != null) totalName.append(space()).append(subStat);
} }
if (statNameStyle != null) totalName.decoration(statNameStyle, TextDecoration.State.TRUE); if (statNameStyle != null) totalName.decoration(statNameStyle, TextDecoration.State.TRUE);
if (subStat != null) totalName.append(space()).append(subStat);
return totalName return totalName
.color(statNameColor) .color(statNameColor)
.build(); .build();
} }
/** Construct a custom translation for kill_entity */ /** Construct a custom translation for kill_entity */
private TranslatableComponent.@NotNull Builder killEntityComponent(TranslatableComponent subStat) { private TranslatableComponent.@NotNull Builder killEntityComponent(TextComponent subStat) {
TranslatableComponent.Builder totalName = translatable() TranslatableComponent.Builder totalName = translatable()
.key("commands.kill.success.single"); //"Killed %s" .key("commands.kill.success.single"); //"Killed %s"
@ -290,7 +290,7 @@ public class MessageFactory {
} }
/** Construct a custom translation for entity_killed_by */ /** Construct a custom translation for entity_killed_by */
private TranslatableComponent.@NotNull Builder entityKilledByComponent(Query selection, TranslatableComponent subStat) { private TranslatableComponent.@NotNull Builder entityKilledByComponent(Query selection, TextComponent subStat) {
String key = "stat.minecraft.player_kills"; //"Player Kills" String key = "stat.minecraft.player_kills"; //"Player Kills"
if (selection == Query.PLAYER) { if (selection == Query.PLAYER) {
key = "stat.minecraft.deaths"; //"Number of Deaths" key = "stat.minecraft.deaths"; //"Number of Deaths"
@ -305,17 +305,21 @@ public class MessageFactory {
return totalName; return totalName;
} }
protected @Nullable TranslatableComponent subStatNameComponent(Query selection, @Nullable String subStatName, Statistic.Type statType) { protected @Nullable TextComponent subStatNameComponent(Query selection, @Nullable String subStatName, Statistic.Type statType) {
String key = getLanguageKey(null, subStatName, statType); String key = getLanguageKey(null, subStatName, statType);
if (key != null) { if (key != null) {
TextDecoration style = getStyleFromString(config.getSubStatNameFormatting(selection, true)); TextDecoration style = getStyleFromString(config.getSubStatNameFormatting(selection, true));
TranslatableComponent.Builder subStat = translatable() TextComponent.Builder subStat = text()
.key(key) .append(text("("))
.append(translatable()
.key(key))
.append(text(")"))
.color(getColorFromString(config.getSubStatNameFormatting(selection, false))); .color(getColorFromString(config.getSubStatNameFormatting(selection, false)));
if (style != null) { if (style != null) subStat.decoration(style, TextDecoration.State.TRUE);
subStat.decoration(style, TextDecoration.State.TRUE); else {
subStat.decorations(TextDecoration.NAMES.values(), false);
} }
return subStat.build(); return subStat.build();
} }

View File

@ -183,6 +183,6 @@ public class MyLogger {
@param methodName Name or description of the task @param methodName Name or description of the task
@param startTime Timestamp marking the beginning of the task */ @param startTime Timestamp marking the beginning of the task */
public static void logTimeTakenDefault(String className, String methodName, long startTime) { public static void logTimeTakenDefault(String className, String methodName, long startTime) {
logger.info(className + " " + methodName + ":" + (System.currentTimeMillis() - startTime) + "ms"); logger.info(className + " " + methodName + ": " + (System.currentTimeMillis() - startTime) + "ms");
} }
} }

View File

@ -8,7 +8,7 @@ config-version: 3.1
# # General # # # # General # #
# # ------------------------------- # # # # ------------------------------- # #
# How much output in console you'll get while PlayerStats is processing # How much output you'll get in the server console while PlayerStats is processing
# 1 = low (only show unexpected errors) # 1 = low (only show unexpected errors)
# 2 = medium (detail all encountered exceptions, log main tasks and show time taken) # 2 = medium (detail all encountered exceptions, log main tasks and show time taken)
# 3 = high (log all tasks and time taken) # 3 = high (log all tasks and time taken)
@ -34,12 +34,10 @@ translate-to-client-language: true
# Use hover-text for additional info in the usage explanation # Use hover-text for additional info in the usage explanation
enable-hover-text: true enable-hover-text: true
# Use special themed formatting for the duration of certain holidays or festivals # Automatically use themed formatting for the duration of certain holidays or festivals
# The festive formatting automatically stops when the holiday/event is over
enable-festive-formatting: true enable-festive-formatting: true
# Always use rainbow for the [PlayerStats] prefix instead of the default gold/purple # Always use rainbow for the [PlayerStats] prefix instead of the default gold/purple
# Changing this from false to true needs a server reboot to take full effect!
rainbow-mode: false rainbow-mode: false
# Align the stat-numbers in the top list with dots # Align the stat-numbers in the top list with dots
@ -74,17 +72,18 @@ your-server-name: 'this server'
# # gray dark_gray # # # # gray dark_gray # #
# # black white # # # # black white # #
# # ------------------------------ # # # # ------------------------------ # #
top-list: top-list:
title: yellow title: '#FFD52B'
title-style: none title-style: none
title-number: gold title-number: gold
title-number-style: none title-number-style: none
stat-names: yellow stat-names: '#FFD52B'
stat-names-style: none stat-names-style: none
sub-stat-names: '#FFD52B' sub-stat-names: yellow
sub-stat-names-style: none sub-stat-names-style: none
rank-numbers: gold rank-numbers: gold
@ -104,10 +103,10 @@ individual-statistics:
player-names: gold player-names: gold
player-names-style: none player-names-style: none
stat-names: yellow stat-names: '#FFD52B'
stat-names-style: none stat-names-style: none
sub-stat-names: '#FFD52B' sub-stat-names: yellow
sub-stat-names-style: none sub-stat-names-style: none
stat-numbers: '#ADE7FF' stat-numbers: '#ADE7FF'
@ -115,16 +114,16 @@ individual-statistics:
total-server: total-server:
title: gold title: '#55AAFF'
title-style: none title-style: none
server-name: gold server-name: '#55AAFF'
server-name-style: none server-name-style: none
stat-names: yellow stat-names: '#FFD52B'
stat-names-style: none stat-names-style: none
sub-stat-names: '#FFD52B' sub-stat-names: yellow
sub-stat-names-style: none sub-stat-names-style: none
stat-numbers: '#ADE7FF' stat-numbers: '#ADE7FF'