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>
</dependency>
<dependency>
<groupId>net.kyori</groupId>
<artifactId>adventure-api</artifactId>
<version>4.11.0</version>
</dependency>
<dependency>
<groupId>net.kyori</groupId>
<artifactId>adventure-platform-bukkit</artifactId>

View File

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

View File

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

View File

@ -183,6 +183,6 @@ public class MyLogger {
@param methodName Name or description of the task
@param startTime Timestamp marking the beginning of the task */
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 # #
# # ------------------------------- # #
# 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)
# 2 = medium (detail all encountered exceptions, log main tasks and show 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
enable-hover-text: true
# Use special themed formatting for the duration of certain holidays or festivals
# The festive formatting automatically stops when the holiday/event is over
# Automatically use themed formatting for the duration of certain holidays or festivals
enable-festive-formatting: true
# 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
# Align the stat-numbers in the top list with dots
@ -74,17 +72,18 @@ your-server-name: 'this server'
# # gray dark_gray # #
# # black white # #
# # ------------------------------ # #
top-list:
title: yellow
title: '#FFD52B'
title-style: none
title-number: gold
title-number-style: none
stat-names: yellow
stat-names: '#FFD52B'
stat-names-style: none
sub-stat-names: '#FFD52B'
sub-stat-names: yellow
sub-stat-names-style: none
rank-numbers: gold
@ -104,10 +103,10 @@ individual-statistics:
player-names: gold
player-names-style: none
stat-names: yellow
stat-names: '#FFD52B'
stat-names-style: none
sub-stat-names: '#FFD52B'
sub-stat-names: yellow
sub-stat-names-style: none
stat-numbers: '#ADE7FF'
@ -115,16 +114,16 @@ individual-statistics:
total-server:
title: gold
title: '#55AAFF'
title-style: none
server-name: gold
server-name: '#55AAFF'
server-name-style: none
stat-names: yellow
stat-names: '#FFD52B'
stat-names-style: none
sub-stat-names: '#FFD52B'
sub-stat-names: yellow
sub-stat-names-style: none
stat-numbers: '#ADE7FF'