Re-organized MessageWriter and ComponentFactory relationship (moved factory into their own package), improved method names

This commit is contained in:
Artemis-the-gr8 2022-07-21 17:30:10 +02:00
parent f760cd2fd5
commit 3a3084978a
7 changed files with 346 additions and 348 deletions

View File

@ -5,6 +5,9 @@ import com.gmail.artemis.the.gr8.playerstats.enums.Target;
import com.gmail.artemis.the.gr8.playerstats.config.ConfigHandler;
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.msg.components.ExampleMessage;
import com.gmail.artemis.the.gr8.playerstats.msg.components.HelpMessage;
import com.gmail.artemis.the.gr8.playerstats.msg.msgutils.*;
import com.gmail.artemis.the.gr8.playerstats.models.StatRequest;
import com.gmail.artemis.the.gr8.playerstats.utils.EnumHandler;
@ -34,11 +37,11 @@ public class MessageWriter {
private final LanguageKeyHandler languageKeyHandler;
private final NumberFormatter formatter;
public MessageWriter(ConfigHandler config) {
private MessageWriter(ConfigHandler config) {
this (config, new ComponentFactory(config));
}
public MessageWriter(ConfigHandler configHandler, ComponentFactory factory) {
private MessageWriter(ConfigHandler configHandler, ComponentFactory factory) {
config = configHandler;
componentFactory = factory;
@ -47,61 +50,69 @@ public class MessageWriter {
MyLogger.logMsg("MessageWriter created with factory: " + componentFactory.getClass().getSimpleName(), DebugLevel.MEDIUM);
}
public static MessageWriter defaultWriter(ConfigHandler config) {
return new MessageWriter(config);
}
public static MessageWriter fromComponentFactory(ConfigHandler config, ComponentFactory factory) {
return new MessageWriter(config, factory);
}
public TextComponent reloadedConfig() {
return componentFactory.pluginPrefixComponent()
return componentFactory.pluginPrefix()
.append(space())
.append(componentFactory.messageComponent().content("Config reloaded!"));
.append(componentFactory.message().content("Config reloaded!"));
}
public TextComponent stillReloading() {
return componentFactory.pluginPrefixComponent()
return componentFactory.pluginPrefix()
.append(space())
.append(componentFactory.messageComponent().content(
.append(componentFactory.message().content(
"The plugin is (re)loading, your request will be processed when it is done!"));
}
public TextComponent waitAMoment(boolean longWait) {
String msg = longWait ? "Calculating statistics, this may take a minute..." :
"Calculating statistics, this may take a few moments...";
return componentFactory.pluginPrefixComponent()
return componentFactory.pluginPrefix()
.append(space())
.append(componentFactory.messageComponent().content(msg));
.append(componentFactory.message().content(msg));
}
public TextComponent missingStatName() {
return componentFactory.pluginPrefixComponent()
return componentFactory.pluginPrefix()
.append(space())
.append(componentFactory.messageComponent().content(
.append(componentFactory.message().content(
"Please provide a valid statistic name!"));
}
public TextComponent missingSubStatName(Statistic.Type statType) {
return componentFactory.pluginPrefixComponent()
return componentFactory.pluginPrefix()
.append(space())
.append(componentFactory.messageComponent().content(
.append(componentFactory.message().content(
"Please add a valid " + EnumHandler.getSubStatTypeName(statType) + " to look up this statistic!"));
}
public TextComponent missingPlayerName() {
return componentFactory.pluginPrefixComponent()
return componentFactory.pluginPrefix()
.append(space())
.append(componentFactory.messageComponent().content(
.append(componentFactory.message().content(
"Please specify a valid player-name!"));
}
public TextComponent wrongSubStatType(Statistic.Type statType, String subStatName) {
return componentFactory.pluginPrefixComponent()
return componentFactory.pluginPrefix()
.append(space())
.append(componentFactory.messageAccentComponent().content("\"" + subStatName + "\""))
.append(componentFactory.messageAccent().content("\"" + subStatName + "\""))
.append(space())
.append(componentFactory.messageComponent().content(
.append(componentFactory.message().content(
"is not a valid " + EnumHandler.getSubStatTypeName(statType) + "!"));
}
public TextComponent requestAlreadyRunning() {
return componentFactory.pluginPrefixComponent()
return componentFactory.pluginPrefix()
.append(space())
.append(componentFactory.messageComponent().content(
.append(componentFactory.message().content(
"Please wait for your previous lookup to finish!"));
}
@ -110,50 +121,53 @@ public class MessageWriter {
int waitTime = config.getStatShareWaitingTime();
String minutes = waitTime == 1 ? " minute" : " minutes";
return componentFactory.pluginPrefixComponent()
return componentFactory.pluginPrefix()
.append(space())
.append(componentFactory.messageComponent().content("You need to wait")
.append(componentFactory.message().content("You need to wait")
.append(space())
.append(componentFactory.messageAccentComponent()
.append(componentFactory.messageAccent()
.content(waitTime + minutes))
.append(space())
.append(text("between sharing!")));
}
public TextComponent resultsAlreadyShared() {
return componentFactory.pluginPrefixComponent()
return componentFactory.pluginPrefix()
.append(space())
.append(componentFactory.messageComponent().content("You already shared these results!"));
.append(componentFactory.message().content("You already shared these results!"));
}
public TextComponent statResultsTooOld() {
return componentFactory.pluginPrefixComponent()
return componentFactory.pluginPrefix()
.append(space())
.append(componentFactory.messageComponent().content(
.append(componentFactory.message().content(
"It has been too long since you looked up this statistic, please repeat the original command!"));
}
public TextComponent unknownError() {
return componentFactory.pluginPrefixComponent()
return componentFactory.pluginPrefix()
.append(space())
.append(componentFactory.messageComponent().content(
.append(componentFactory.message().content(
"Something went wrong with your request, " +
"please try again or see /statistic for a usage explanation!"));
}
public TextComponent usageExamples() {
return new ExampleMessage(componentFactory);
return ExampleMessage.construct(componentFactory);
}
public TextComponent helpMsg(boolean isConsoleSender) {
return new HelpMessage(componentFactory,
(!isConsoleSender && config.useHoverText()),
config.getTopListMaxSize());
int listSize = config.getTopListMaxSize();
if (!isConsoleSender && config.useHoverText()) {
return HelpMessage.constructHoverMsg(componentFactory, listSize);
} else {
return HelpMessage.constructPlainMsg(componentFactory, listSize);
}
}
public BiFunction<UUID, CommandSender, TextComponent> formattedPlayerStatFunction(int stat, @NotNull StatRequest request) {
TextComponent playerStat = Component.text()
.append(componentFactory.playerNameBuilder(request.getPlayerName(), Target.PLAYER)
.append(componentFactory.playerName(request.getPlayerName(), Target.PLAYER)
.append(text(":"))
.append(space()))
.append(getStatNumberComponent(request.getStatistic(), stat, Target.PLAYER, request.isConsoleSender()))
@ -167,9 +181,9 @@ public class MessageWriter {
public BiFunction<UUID, CommandSender, TextComponent> formattedServerStatFunction(long stat, @NotNull StatRequest request) {
TextComponent serverStat = text()
.append(componentFactory.titleComponent(config.getServerTitle(), Target.SERVER))
.append(componentFactory.title(config.getServerTitle(), Target.SERVER))
.append(space())
.append(componentFactory.serverNameComponent(config.getServerName()))
.append(componentFactory.serverName(config.getServerName()))
.append(space())
.append(getStatNumberComponent(request.getStatistic(), stat, Target.SERVER, request.isConsoleSender()))
.append(space())
@ -181,9 +195,9 @@ public class MessageWriter {
}
public BiFunction<UUID, CommandSender, TextComponent> formattedTopStatFunction(@NotNull LinkedHashMap<String, Integer> topStats, @NotNull StatRequest request) {
final TextComponent title = getTopStatsTitle(request, topStats.size());
final TextComponent shortTitle = getTopStatsTitleShort(request, topStats.size());
final TextComponent list = getTopStatList(topStats, request);
final TextComponent title = getTopStatsTitleComponent(request, topStats.size());
final TextComponent shortTitle = getTopStatsTitleShortComponent(request, topStats.size());
final TextComponent list = getTopStatListComponent(topStats, request);
final boolean useEnters = config.useEnters(Target.TOP, false);
final boolean useEntersForShared = config.useEnters(Target.TOP, true);
@ -197,7 +211,7 @@ public class MessageWriter {
}
topBuilder.append(title)
.append(space())
.append(componentFactory.shareButtonComponent(shareCode))
.append(componentFactory.shareButton(shareCode))
.append(list);
}
//if we're adding a "shared by" component
@ -207,12 +221,12 @@ public class MessageWriter {
}
topBuilder.append(shortTitle)
.append(space())
.append(componentFactory.hoveringStatResultComponent(text()
.append(componentFactory.statResultInHoverText(text()
.append(title)
.append(list)
.build()))
.append(newline())
.append(componentFactory.messageSharedComponent(
.append(componentFactory.sharedByMessage(
getSharerNameComponent(sender)));
}
//if we're not adding a share-button or a "shared by" component
@ -241,7 +255,7 @@ public class MessageWriter {
}
statBuilder.append(statResult)
.append(space())
.append(componentFactory.shareButtonComponent(shareCode));
.append(componentFactory.shareButton(shareCode));
}
//if we're adding a "shared by" component
else if (sender != null) {
@ -250,7 +264,7 @@ public class MessageWriter {
}
statBuilder.append(statResult)
.append(newline())
.append(componentFactory.messageSharedComponent(
.append(componentFactory.sharedByMessage(
getSharerNameComponent(sender)));
}
//if we're not adding a share-button or a "shared by" component
@ -271,28 +285,28 @@ public class MessageWriter {
return senderName;
}
}
return componentFactory.sharerNameComponent(sender.getName());
return componentFactory.sharerName(sender.getName());
}
private TextComponent getTopStatsTitle(StatRequest request, int statListSize) {
private TextComponent getTopStatsTitleComponent(StatRequest request, int statListSize) {
return Component.text()
.append(componentFactory.pluginPrefixComponent()).append(space())
.append(componentFactory.titleComponent(config.getTopStatsTitle(), Target.TOP)).append(space())
.append(componentFactory.titleNumberComponent(statListSize)).append(space())
.append(componentFactory.pluginPrefix()).append(space())
.append(componentFactory.title(config.getTopStatsTitle(), Target.TOP)).append(space())
.append(componentFactory.titleNumber(statListSize)).append(space())
.append(getStatNameComponent(request)) //space is provided by statUnitComponent
.append(getStatUnitComponent(request.getStatistic(), request.getSelection(), request.isConsoleSender()))
.build();
}
private TextComponent getTopStatsTitleShort(StatRequest request, int statListSize) {
private TextComponent getTopStatsTitleShortComponent(StatRequest request, int statListSize) {
return Component.text()
.append(componentFactory.titleComponent(config.getTopStatsTitle(), Target.TOP)).append(space())
.append(componentFactory.titleNumberComponent(statListSize)).append(space())
.append(componentFactory.title(config.getTopStatsTitle(), Target.TOP)).append(space())
.append(componentFactory.titleNumber(statListSize)).append(space())
.append(getStatNameComponent(request)) //space is provided by statUnitComponent
.build();
}
private TextComponent getTopStatList(LinkedHashMap<String, Integer> topStats, StatRequest request) {
private TextComponent getTopStatListComponent(LinkedHashMap<String, Integer> topStats, StatRequest request) {
TextComponent.Builder topList = Component.text();
boolean useDots = config.useDots();
boolean boldNames = config.playerNameIsBold();
@ -300,16 +314,16 @@ public class MessageWriter {
int count = 0;
for (String playerName : playerNames) {
TextComponent.Builder playerNameBuilder = componentFactory.playerNameBuilder(playerName, Target.TOP);
TextComponent.Builder playerNameBuilder = componentFactory.playerName(playerName, Target.TOP).toBuilder();
topList.append(newline())
.append(componentFactory.rankingNumberComponent(" " + ++count + "."))
.append(componentFactory.rankNumber(" " + ++count + "."))
.append(space());
if (useDots) {
topList.append(playerNameBuilder)
.append(space());
int dots = FontUtils.getNumberOfDotsToAlign(count + ". " + playerName, request.isConsoleSender(), boldNames);
if (dots >= 1) {
topList.append(componentFactory.dotsBuilder().append(text((".".repeat(dots)))));
topList.append(componentFactory.dots().append(text((".".repeat(dots)))));
}
}
else {
@ -335,10 +349,10 @@ public class MessageWriter {
}
}
}
return componentFactory.statNameTransComponent(statKey, subStatKey, request.getSelection());
return componentFactory.statAndSubStatNameTranslatable(statKey, subStatKey, request.getSelection());
}
else {
return componentFactory.statNameTextComponent(
return componentFactory.statAndSubStatName(
StringUtils.prettify(request.getStatistic().toString()),
StringUtils.prettify(request.getSubStatEntry()),
request.getSelection());
@ -358,7 +372,7 @@ public class MessageWriter {
}
String prettyNumber = formatter.format(statNumber, statUnit);
if (!config.useHoverText() || statUnit == Unit.NUMBER) {
return componentFactory.statNumberComponent(prettyNumber, selection);
return componentFactory.statNumber(prettyNumber, selection);
}
Unit hoverUnit = type == Unit.Type.DISTANCE ? Unit.fromString(config.getDistanceUnit(true)) :
Unit.fromString(config.getDamageUnit(true));
@ -366,17 +380,17 @@ public class MessageWriter {
MyLogger.logMsg("mainNumber: " + prettyNumber + ", hoverNumber: " + prettyHoverNumber, DebugLevel.HIGH);
if (hoverUnit == Unit.HEART) {
return componentFactory.damageNumberHoverComponent(
return componentFactory.damageNumberWithHoverText(
prettyNumber, prettyHoverNumber,
componentFactory.heartComponent(isConsoleSender, true), selection);
componentFactory.heart(isConsoleSender, true), selection);
}
if (config.useTranslatableComponents()) {
String unitKey = languageKeyHandler.getUnitKey(hoverUnit);
if (unitKey != null) {
return componentFactory.statNumberHoverComponent(prettyNumber, prettyHoverNumber, null, unitKey, selection);
return componentFactory.statNumberWithHoverText(prettyNumber, prettyHoverNumber, null, unitKey, selection);
}
}
return componentFactory.statNumberHoverComponent(prettyNumber, prettyHoverNumber, hoverUnit.getLabel(), null, selection);
return componentFactory.statNumberWithHoverText(prettyNumber, prettyHoverNumber, hoverUnit.getLabel(), null, selection);
}
private TextComponent getTimeNumberComponent(long statNumber, Target selection, ArrayList<Unit> unitRange) {
@ -384,16 +398,16 @@ public class MessageWriter {
MyLogger.logMsg(
"There is something wrong with the time-units you specified, please check your config!",
true);
return componentFactory.statNumberComponent("-", selection);
return componentFactory.statNumber("-", selection);
}
else {
String mainNumber = formatter.format(statNumber, unitRange.get(0), unitRange.get(1));
if (!config.useHoverText()) {
return componentFactory.statNumberComponent(mainNumber, selection);
return componentFactory.statNumber(mainNumber, selection);
} else {
String hoverNumber = formatter.format(statNumber, unitRange.get(2), unitRange.get(3));
MyLogger.logMsg("mainNumber: " + mainNumber + ", hoverNumber: " + hoverNumber, DebugLevel.HIGH);
return componentFactory.statNumberHoverComponent(mainNumber, hoverNumber,
return componentFactory.statNumberWithHoverText(mainNumber, hoverNumber,
null, null, selection);
}
}
@ -443,15 +457,15 @@ public class MessageWriter {
String unitKey = languageKeyHandler.getUnitKey(statUnit);
if (unitKey != null) {
return Component.space()
.append(componentFactory.statUnitComponent(null, unitKey, selection));
.append(componentFactory.statUnit(null, unitKey, selection));
}
}
String statName = statUnit.getLabel();
if (statUnit == Unit.HEART) { //console can do u2665, u2764 looks better in-game
return Component.space()
.append(componentFactory.heartComponent(isConsoleSender, false));
.append(componentFactory.heart(isConsoleSender, false));
}
return Component.space()
.append(componentFactory.statUnitComponent(statName, null, selection));
.append(componentFactory.statUnit(statName, null, selection));
}
}

View File

@ -5,6 +5,8 @@ import com.gmail.artemis.the.gr8.playerstats.ShareManager;
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.models.StatRequest;
import com.gmail.artemis.the.gr8.playerstats.msg.components.BukkitConsoleComponentFactory;
import com.gmail.artemis.the.gr8.playerstats.msg.components.PrideComponentFactory;
import net.kyori.adventure.platform.bukkit.BukkitAudiences;
import net.kyori.adventure.text.TextComponent;
import org.bukkit.Bukkit;
@ -129,16 +131,16 @@ public class OutputManager {
boolean isBukkit = Bukkit.getName().equalsIgnoreCase("CraftBukkit");
if (config.useRainbowMode() ||
(config.useFestiveFormatting() && LocalDate.now().getMonth().equals(Month.JUNE))) {
msg = new MessageWriter(config, new PrideComponentFactory(config));
msg = MessageWriter.fromComponentFactory(config, new PrideComponentFactory(config));
}
else {
msg = new MessageWriter(config);
msg = MessageWriter.defaultWriter(config);
}
if (!isBukkit) {
consoleMsg = msg;
} else {
consoleMsg = new MessageWriter(config, new BukkitConsoleComponentFactory(config));
consoleMsg = MessageWriter.fromComponentFactory(config, new BukkitConsoleComponentFactory(config));
}
}

View File

@ -1,4 +1,4 @@
package com.gmail.artemis.the.gr8.playerstats.msg;
package com.gmail.artemis.the.gr8.playerstats.msg.components;
import com.gmail.artemis.the.gr8.playerstats.config.ConfigHandler;
import com.gmail.artemis.the.gr8.playerstats.enums.PluginColor;
@ -22,13 +22,17 @@ public class BukkitConsoleComponentFactory extends ComponentFactory {
PREFIX = PluginColor.GOLD.getConsoleColor();
BRACKETS = PluginColor.GRAY.getConsoleColor();
UNDERSCORE = PluginColor.DARK_PURPLE.getConsoleColor();
MSG_MAIN = PluginColor.MEDIUM_BLUE.getConsoleColor();
MSG_ACCENT = PluginColor.BLUE.getConsoleColor();
MSG_MAIN_2 = PluginColor.GOLD.getConsoleColor();
MSG_ACCENT_2A = PluginColor.MEDIUM_GOLD.getConsoleColor();
MSG_ACCENT_2B = PluginColor.LIGHT_YELLOW.getConsoleColor();
CLICKED_MSG = PluginColor.LIGHT_PURPLE.getConsoleColor();
HOVER_MSG = PluginColor.LIGHT_BLUE.getConsoleColor();
HOVER_ACCENT = PluginColor.LIGHT_GOLD.getConsoleColor();
MSG_HOVER = PluginColor.LIGHT_BLUE.getConsoleColor();
MSG_CLICKED = PluginColor.LIGHT_PURPLE.getConsoleColor();
MSG_HOVER_ACCENT = PluginColor.LIGHT_GOLD.getConsoleColor();
}
@Override

View File

@ -1,4 +1,4 @@
package com.gmail.artemis.the.gr8.playerstats.msg;
package com.gmail.artemis.the.gr8.playerstats.msg.components;
import com.gmail.artemis.the.gr8.playerstats.config.ConfigHandler;
import com.gmail.artemis.the.gr8.playerstats.enums.PluginColor;
@ -34,14 +34,17 @@ public class ComponentFactory {
protected TextColor PREFIX; //gold
protected TextColor BRACKETS; //gray
protected TextColor UNDERSCORE; //dark_purple
protected TextColor MSG_MAIN; //medium_blue
protected TextColor MSG_ACCENT; //blue
protected TextColor MSG_MAIN_2; //gold
protected TextColor MSG_ACCENT_2A; //medium_gold
protected TextColor MSG_ACCENT_2B; //light_yellow
protected TextColor HOVER_MSG; //light_blue
protected TextColor CLICKED_MSG; //light_purple
protected TextColor HOVER_ACCENT; //light_gold
protected TextColor MSG_HOVER; //light_blue
protected TextColor MSG_CLICKED; //light_purple
protected TextColor MSG_HOVER_ACCENT; //light_gold
public ComponentFactory(ConfigHandler c) {
@ -53,48 +56,17 @@ public class ComponentFactory {
PREFIX = PluginColor.GOLD.getColor();
BRACKETS = PluginColor.GRAY.getColor();
UNDERSCORE = PluginColor.DARK_PURPLE.getColor();
MSG_MAIN = PluginColor.MEDIUM_BLUE.getColor();
MSG_ACCENT = PluginColor.BLUE.getColor();
MSG_MAIN_2 = PluginColor.GOLD.getColor();
MSG_ACCENT_2A = PluginColor.MEDIUM_GOLD.getColor();
MSG_ACCENT_2B = PluginColor.LIGHT_YELLOW.getColor();
CLICKED_MSG = PluginColor.LIGHT_PURPLE.getColor();
HOVER_MSG = PluginColor.LIGHT_BLUE.getColor();
HOVER_ACCENT = PluginColor.LIGHT_GOLD.getColor();
}
public TextColor prefix() {
return PREFIX;
}
public TextColor brackets() {
return BRACKETS;
}
public TextColor underscore() {
return UNDERSCORE;
}
public TextColor msgMain() {
return MSG_MAIN;
}
public TextColor msgAccent() {
return MSG_ACCENT;
}
public TextColor msgMain2() {
return MSG_MAIN_2;
}
public TextColor msgAccent2A() {
return MSG_ACCENT_2A;
}
public TextColor msgAccent2B() {
return MSG_ACCENT_2B;
}
public TextColor clickedMsg() {
return CLICKED_MSG;
}
public TextColor hoverMsg() {
return HOVER_MSG;
}
public TextColor hoverAccent() {
return HOVER_ACCENT;
MSG_HOVER = PluginColor.LIGHT_BLUE.getColor();
MSG_HOVER_ACCENT = PluginColor.LIGHT_GOLD.getColor();
MSG_CLICKED = PluginColor.LIGHT_PURPLE.getColor();
}
public TextColor getExampleNameColor() {
@ -106,7 +78,7 @@ public class ComponentFactory {
/** Returns [PlayerStats]. */
public TextComponent pluginPrefixComponent() {
public TextComponent pluginPrefix() {
return text("[")
.color(BRACKETS)
.append(text("PlayerStats").color(PREFIX))
@ -114,73 +86,125 @@ public class ComponentFactory {
}
/** Returns [PlayerStats] surrounded by underscores on both sides. */
public TextComponent prefixTitleComponent() {
public TextComponent pluginPrefixAsTitle() {
//12 underscores for both console and in-game
return text("____________").color(UNDERSCORE)
.append(text(" ")) //4 spaces
.append(pluginPrefixComponent())
.append(pluginPrefix())
.append(text(" ")) //4 spaces
.append(text("____________"));
}
/** Returns a TextComponent with the input String as content, with color Gray and decoration Italic.*/
public TextComponent subTitleComponent(String content) {
public TextComponent subTitle(String content) {
return text(content).color(BRACKETS).decorate(TextDecoration.ITALIC);
}
/** Returns a TextComponents in the style of a default plugin message, with color Medium_Blue. */
public TextComponent messageComponent() {
public TextComponent message() {
return text().color(MSG_MAIN).build();
}
public TextComponent messageAccentComponent() {
public TextComponent messageAccent() {
return text().color(MSG_ACCENT).build();
}
public TextComponent.Builder playerNameBuilder(String playerName, Target selection) {
return getComponentBuilder(playerName,
public TextComponent title(String content, Target selection) {
return getComponent(content,
getColorFromString(config.getTitleDecoration(selection, false)),
getStyleFromString(config.getTitleDecoration(selection, true)));
}
public TextComponent titleNumber(int number) {
return getComponent(number + "",
getColorFromString(config.getTitleNumberDecoration(false)),
getStyleFromString(config.getTitleNumberDecoration(true)));
}
public TextComponent rankNumber(String number) {
return getComponent(number,
getColorFromString(config.getRankNumberDecoration(false)),
getStyleFromString(config.getRankNumberDecoration(true)));
}
public TextComponent dots() {
return getComponent(null,
getColorFromString(config.getDotsDecoration(false)),
getStyleFromString(config.getDotsDecoration(true)));
}
public TextComponent serverName(String serverName) {
TextComponent colon = text(":").color(getColorFromString(config.getServerNameDecoration(false)));
return getComponent(serverName,
getColorFromString(config.getServerNameDecoration(false)),
getStyleFromString(config.getServerNameDecoration(true)))
.append(colon);
}
public TextComponent playerName(String playerName, Target selection) {
return getComponent(playerName,
getColorFromString(config.getPlayerNameDecoration(selection, false)),
getStyleFromString(config.getPlayerNameDecoration(selection, true)));
}
public TextComponent sharerName(String sharerName) {
return getComponent(sharerName,
getSharerNameColor(),
getStyleFromString(config.getSharerNameDecoration(true)));
}
public TextComponent shareButton(UUID shareCode) {
return surroundingBrackets(
text("Share")
.color(MSG_HOVER)
.clickEvent(ClickEvent.runCommand("/statshare " + shareCode))
.hoverEvent(HoverEvent.showText(text("Click here to share this statistic in chat!")
.color(MSG_HOVER_ACCENT))));
}
public TextComponent sharedByMessage(Component playerName) {
return surroundingBrackets(
text().append(
getComponent("Shared by",
getColorFromString(config.getSharedByTextDecoration(false)),
getStyleFromString(config.getSharedByTextDecoration(true))))
.append(space())
.append(playerName)
.build());
}
public TextComponent statResultInHoverText(TextComponent statResult) {
return surroundingBrackets(
text().append(text("Hover Here")
.color(MSG_CLICKED)
.decorate(TextDecoration.ITALIC)
.hoverEvent(HoverEvent.showText(statResult)))
.build());
}
/** @param prettyStatName a statName with underscores removed and each word capitalized
@param prettySubStatName if present, a subStatName with underscores removed and each word capitalized*/
public TextComponent statNameTextComponent(String prettyStatName, @Nullable String prettySubStatName, Target selection) {
public TextComponent statAndSubStatName(String prettyStatName, @Nullable String prettySubStatName, Target selection) {
TextComponent.Builder totalStatNameBuilder = getComponentBuilder(prettyStatName,
getColorFromString(config.getStatNameDecoration(selection, false)),
getStyleFromString(config.getStatNameDecoration(selection, true)));
TextComponent subStat = subStatNameTextComponent(prettySubStatName, selection);
TextComponent subStat = subStatName(prettySubStatName, selection);
if (!subStat.equals(Component.empty())) {
totalStatNameBuilder
.append(space().decorations(TextDecoration.NAMES.values(), false))
.append(subStatNameTextComponent(prettySubStatName, selection));
.append(subStatName(prettySubStatName, selection));
}
return totalStatNameBuilder.build();
}
/** Returns a TextComponent for the subStatName, or an empty component.*/
private TextComponent subStatNameTextComponent(@Nullable String prettySubStatName, Target selection) {
if (prettySubStatName == null) {
return Component.empty();
} else {
return getComponentBuilder(null,
getColorFromString(config.getSubStatNameDecoration(selection, false)),
getStyleFromString(config.getSubStatNameDecoration(selection, true)))
.append(text("("))
.append(text(prettySubStatName))
.append(text(")"))
.build();
}
}
/** Returns a TextComponent with TranslatableComponent as a child.*/
public TextComponent statNameTransComponent(String statKey, String subStatKey, Target selection) {
public TextComponent statAndSubStatNameTranslatable(String statKey, String subStatKey, Target selection) {
TextComponent.Builder totalStatNameBuilder = getComponentBuilder(null,
getColorFromString(config.getStatNameDecoration(selection, false)),
getStyleFromString(config.getStatNameDecoration(selection, true)));
TextComponent subStat = subStatNameTransComponent(subStatKey, selection);
TextComponent subStat = subStatNameTranslatable(subStatKey, selection);
if (statKey.equalsIgnoreCase("stat_type.minecraft.killed")) {
return totalStatNameBuilder.append(killEntityBuilder(subStat)).build();
}
@ -198,8 +222,72 @@ public class ComponentFactory {
}
}
public TextComponent statNumber(String prettyNumber, Target selection) {
return getComponent(prettyNumber,
getColorFromString(config.getStatNumberDecoration(selection, false)),
getStyleFromString(config.getStatNumberDecoration(selection, true)));
}
public TextComponent statNumberWithHoverText(String mainNumber, String hoverNumber, @Nullable String hoverUnitName, @Nullable String hoverUnitKey, Target selection) {
return statNumberWithHoverText(mainNumber, hoverNumber, hoverUnitName, hoverUnitKey, null, selection);
}
public TextComponent damageNumberWithHoverText(String mainNumber, String hoverNumber, TextComponent heart, Target selection) {
return statNumberWithHoverText(mainNumber, hoverNumber, null, null, heart, selection);
}
public TextComponent statUnit(String unitName, String unitKey, Target selection) {
if (!(unitName == null && unitKey == null)) {
TextComponent.Builder statUnitBuilder = getComponentBuilder(null,
getColorFromString(config.getSubStatNameDecoration(selection, false)),
getStyleFromString(config.getSubStatNameDecoration(selection, true)));
if (unitKey != null) {
statUnitBuilder.append(translatable()
.key(unitKey));
} else {
statUnitBuilder.append(text(unitName));
}
return surroundingBrackets(statUnitBuilder.build());
}
else {
return Component.empty();
}
}
public TextComponent heart(boolean isConsoleSender, boolean isHoverUnit) {
TextColor heartColor = TextColor.fromHexString("#FF1313");
char heart = isConsoleSender ? '\u2665' : '\u2764';
if (isHoverUnit) {
return Component.text(heart).color(heartColor);
}
TextComponent.Builder heartComponent = Component.text()
.content(String.valueOf(heart))
.color(heartColor);
if (config.useHoverText()) {
heartComponent.hoverEvent(HoverEvent.showText(
text(Unit.HEART.getLabel())
.color(MSG_HOVER_ACCENT)));
}
return surroundingBrackets(heartComponent.build());
}
/** Returns a TextComponent for the subStatName, or an empty component.*/
private TextComponent subStatName(@Nullable String prettySubStatName, Target selection) {
if (prettySubStatName == null) {
return Component.empty();
} else {
return getComponentBuilder(null,
getColorFromString(config.getSubStatNameDecoration(selection, false)),
getStyleFromString(config.getSubStatNameDecoration(selection, true)))
.append(text("("))
.append(text(prettySubStatName))
.append(text(")"))
.build();
}
}
/** Returns a TranslatableComponent for the subStatName, or an empty component.*/
private TextComponent subStatNameTransComponent(String subStatKey, Target selection) {
private TextComponent subStatNameTranslatable(String subStatKey, Target selection) {
if (subStatKey != null) {
return getComponentBuilder(null,
getColorFromString(config.getSubStatNameDecoration(selection, false)),
@ -234,21 +322,7 @@ public class ComponentFactory {
.args(subStat));
}
public TextComponent statNumberComponent(String prettyNumber, Target selection) {
return getComponent(prettyNumber,
getColorFromString(config.getStatNumberDecoration(selection, false)),
getStyleFromString(config.getStatNumberDecoration(selection, true)));
}
public TextComponent damageNumberHoverComponent(String mainNumber, String hoverNumber, TextComponent heart, Target selection) {
return statNumberHoverComponent(mainNumber, hoverNumber, null, null, heart, selection);
}
public TextComponent statNumberHoverComponent(String mainNumber, String hoverNumber, @Nullable String hoverUnitName, @Nullable String hoverUnitKey, Target selection) {
return statNumberHoverComponent(mainNumber, hoverNumber, hoverUnitName, hoverUnitKey, null, selection);
}
private TextComponent statNumberHoverComponent(String mainNumber, String hoverNumber, @Nullable String hoverUnitName, @Nullable String hoverUnitKey, @Nullable TextComponent heart, Target selection) {
private TextComponent statNumberWithHoverText(String mainNumber, String hoverNumber, @Nullable String hoverUnitName, @Nullable String hoverUnitKey, @Nullable TextComponent heart, Target selection) {
TextColor baseColor = getColorFromString(config.getStatNumberDecoration(selection, false));
TextDecoration style = getStyleFromString(config.getStatNumberDecoration(selection, true));
@ -268,115 +342,13 @@ public class ComponentFactory {
return getComponent(mainNumber, baseColor, style).hoverEvent(HoverEvent.showText(hoverText));
}
public TextComponent statUnitComponent(String unitName, String unitKey, Target selection) {
if (!(unitName == null && unitKey == null)) {
TextComponent.Builder statUnitBuilder = getComponentBuilder(null,
getColorFromString(config.getSubStatNameDecoration(selection, false)),
getStyleFromString(config.getSubStatNameDecoration(selection, true)));
if (unitKey != null) {
statUnitBuilder.append(translatable()
.key(unitKey));
} else {
statUnitBuilder.append(text(unitName));
}
return surroundingBracketComponent(statUnitBuilder.build());
}
else {
return Component.empty();
}
}
public TextComponent heartComponent(boolean isConsoleSender, boolean isHoverUnit) {
TextColor heartColor = TextColor.fromHexString("#FF1313");
char heart = isConsoleSender ? '\u2665' : '\u2764';
if (isHoverUnit) {
return Component.text(heart).color(heartColor);
}
TextComponent.Builder heartComponent = Component.text()
.content(String.valueOf(heart))
.color(heartColor);
if (config.useHoverText()) {
heartComponent.hoverEvent(HoverEvent.showText(
text(Unit.HEART.getLabel())
.color(HOVER_ACCENT)));
}
return surroundingBracketComponent(heartComponent.build());
}
public TextComponent shareButtonComponent(UUID shareCode) {
return surroundingBracketComponent(
text("Share")
.color(HOVER_MSG)
.clickEvent(ClickEvent.runCommand("/statshare " + shareCode))
.hoverEvent(HoverEvent.showText(text("Click here to share this statistic in chat!")
.color(HOVER_ACCENT))));
}
public TextComponent hoveringStatResultComponent(TextComponent statResult) {
return surroundingBracketComponent(
text().append(text("Hover Here")
.color(CLICKED_MSG)
.decorate(TextDecoration.ITALIC)
.hoverEvent(HoverEvent.showText(statResult)))
.build());
}
public TextComponent messageSharedComponent(Component playerName) {
return surroundingBracketComponent(
text().append(
getComponent("Shared by",
getColorFromString(config.getSharedByTextDecoration(false)),
getStyleFromString(config.getSharedByTextDecoration(true))))
.append(space())
.append(playerName)
.build());
}
public TextComponent sharerNameComponent(String sharerName) {
return getComponent(sharerName,
getSharerNameColor(),
getStyleFromString(config.getSharerNameDecoration(true)));
}
private TextComponent surroundingBracketComponent(TextComponent component) {
private TextComponent surroundingBrackets(TextComponent component) {
return getComponent(null, BRACKETS, null)
.append(text("["))
.append(component)
.append(text("]"));
}
public TextComponent titleComponent(String content, Target selection) {
return getComponent(content,
getColorFromString(config.getTitleDecoration(selection, false)),
getStyleFromString(config.getTitleDecoration(selection, true)));
}
public TextComponent titleNumberComponent(int number) {
return getComponent(number + "",
getColorFromString(config.getTitleNumberDecoration(false)),
getStyleFromString(config.getTitleNumberDecoration(true)));
}
public TextComponent serverNameComponent(String serverName) {
TextComponent colon = text(":").color(getColorFromString(config.getServerNameDecoration(false)));
return getComponent(serverName,
getColorFromString(config.getServerNameDecoration(false)),
getStyleFromString(config.getServerNameDecoration(true)))
.append(colon);
}
public TextComponent rankingNumberComponent(String number) {
return getComponent(number,
getColorFromString(config.getRankNumberDecoration(false)),
getStyleFromString(config.getRankNumberDecoration(true)));
}
public TextComponent.Builder dotsBuilder() {
return getComponentBuilder(null,
getColorFromString(config.getDotsDecoration(false)),
getStyleFromString(config.getDotsDecoration(true)));
}
protected TextComponent getComponent(String content, @NotNull TextColor color, @Nullable TextDecoration style) {
return getComponentBuilder(content, color, style).build();
}

View File

@ -1,7 +1,5 @@
package com.gmail.artemis.the.gr8.playerstats.msg.msgutils;
package com.gmail.artemis.the.gr8.playerstats.msg.components;
import com.gmail.artemis.the.gr8.playerstats.msg.BukkitConsoleComponentFactory;
import com.gmail.artemis.the.gr8.playerstats.msg.ComponentFactory;
import net.kyori.adventure.text.Component;
import net.kyori.adventure.text.ComponentLike;
import net.kyori.adventure.text.TextComponent;
@ -16,37 +14,39 @@ import static net.kyori.adventure.text.Component.text;
public class ExampleMessage implements TextComponent {
private final TextComponent exampleMessage;
private final ComponentFactory componentFactory;
public ExampleMessage(ComponentFactory factory) {
componentFactory = factory;
exampleMessage = getExampleMessage();
private ExampleMessage(ComponentFactory factory) {
exampleMessage = buildMessage(factory);
}
public TextComponent getExampleMessage() {
String arrow = componentFactory instanceof BukkitConsoleComponentFactory ? " -> " : ""; //4 spaces, alt + 26, 1 space
public static ExampleMessage construct(ComponentFactory factory) {
return new ExampleMessage(factory);
}
private TextComponent buildMessage(ComponentFactory factory) {
String arrow = factory instanceof BukkitConsoleComponentFactory ? " -> " : ""; //4 spaces, alt + 26, 1 space
return Component.newline()
.append(componentFactory.prefixTitleComponent())
.append(factory.pluginPrefixAsTitle())
.append(Component.newline())
.append(text("Examples: ").color(componentFactory.msgMain2()))
.append(text("Examples: ").color(factory.MSG_MAIN_2))
.append(Component.newline())
.append(text(arrow).color(componentFactory.msgMain2())
.append(text(arrow).color(factory.MSG_MAIN_2)
.append(text("/statistic ")
.append(text("animals_bred ").color(componentFactory.msgAccent2A())
.append(text("top").color(componentFactory.msgAccent2B())))))
.append(text("animals_bred ").color(factory.MSG_ACCENT_2A)
.append(text("top").color(factory.MSG_ACCENT_2B)))))
.append(Component.newline())
.append(text(arrow).color(componentFactory.msgMain2())
.append(text(arrow).color(factory.MSG_MAIN_2)
.append(text("/statistic ")
.append(text("mine_block diorite ").color(componentFactory.msgAccent2A())
.append(text("me").color(componentFactory.msgAccent2B())))))
.append(text("mine_block diorite ").color(factory.MSG_ACCENT_2A)
.append(text("me").color(factory.MSG_ACCENT_2B)))))
.append(Component.newline())
.append(text(arrow).color(componentFactory.msgMain2())
.append(text(arrow).color(factory.MSG_MAIN_2)
.append(text("/statistic ")
.append(text("deaths ").color(componentFactory.msgAccent2A())
.append(text("player ").color(componentFactory.msgAccent2B())
.append(text("deaths ").color(factory.MSG_ACCENT_2A)
.append(text("player ").color(factory.MSG_ACCENT_2B)
.append(text("Artemis_the_gr8")
.color(componentFactory.getExampleNameColor()))))));
.color(factory.getExampleNameColor()))))));
}
@Override

View File

@ -1,7 +1,5 @@
package com.gmail.artemis.the.gr8.playerstats.msg.msgutils;
package com.gmail.artemis.the.gr8.playerstats.msg.components;
import com.gmail.artemis.the.gr8.playerstats.msg.BukkitConsoleComponentFactory;
import com.gmail.artemis.the.gr8.playerstats.msg.ComponentFactory;
import net.kyori.adventure.text.Component;
import net.kyori.adventure.text.ComponentLike;
import net.kyori.adventure.text.TextComponent;
@ -17,121 +15,126 @@ import static net.kyori.adventure.text.Component.text;
public class HelpMessage implements TextComponent {
private final ComponentFactory componentFactory;
private final TextComponent helpMessage;
public HelpMessage(ComponentFactory componentFactory, boolean useHover, int listSize) {
this.componentFactory = componentFactory;
private HelpMessage(ComponentFactory factory, boolean useHover, int listSize) {
if (!useHover) {
helpMessage = getPlainHelpMsg(listSize);
helpMessage = buildPlainMsg(factory, listSize);
} else {
helpMessage = helpMsgHover(listSize);
helpMessage = buildHoverMsg(factory, listSize);
}
}
private TextComponent getPlainHelpMsg(int listSize) {
public static HelpMessage constructPlainMsg(ComponentFactory factory, int listSize) {
return new HelpMessage(factory, false, listSize);
}
public static HelpMessage constructHoverMsg(ComponentFactory factory, int listSize) {
return new HelpMessage(factory, true, listSize);
}
private TextComponent buildPlainMsg(ComponentFactory factory, int listSize) {
String arrowSymbol = ""; //alt + 26
String bulletSymbol = ""; //alt + 7
if (componentFactory instanceof BukkitConsoleComponentFactory) {
if (factory instanceof BukkitConsoleComponentFactory) {
arrowSymbol = "->";
bulletSymbol = "*";
}
TextComponent spaces = text(" "); //4 spaces
TextComponent arrow = text(arrowSymbol).color(componentFactory.msgMain2());
TextComponent bullet = text(bulletSymbol).color(componentFactory.msgMain2());
TextComponent arrow = text(arrowSymbol).color(factory.MSG_MAIN_2);
TextComponent bullet = text(bulletSymbol).color(factory.MSG_MAIN_2);
return Component.newline()
.append(componentFactory.prefixTitleComponent())
.append(factory.pluginPrefixAsTitle())
.append(newline())
.append(text("Type \"/statistic examples\" to see examples!").color(componentFactory.brackets()).decorate(TextDecoration.ITALIC))
.append(text("Type \"/statistic examples\" to see examples!").color(factory.BRACKETS).decorate(TextDecoration.ITALIC))
.append(newline())
.append(text("Usage:").color(componentFactory.msgMain2())).append(space())
.append(text("/statistic").color(componentFactory.hoverAccent()))
.append(text("Usage:").color(factory.MSG_MAIN_2)).append(space())
.append(text("/statistic").color(factory.MSG_HOVER_ACCENT))
.append(newline())
.append(spaces).append(arrow).append(space())
.append(text("name").color(componentFactory.hoverAccent()))
.append(text("name").color(factory.MSG_HOVER_ACCENT))
.append(newline())
.append(spaces).append(arrow).append(space())
.append(text("{sub-statistic}").color(componentFactory.hoverAccent())).append(space())
.append(text("(a block, item or entity)").color(componentFactory.brackets()))
.append(text("{sub-statistic}").color(factory.MSG_HOVER_ACCENT)).append(space())
.append(text("(a block, item or entity)").color(factory.BRACKETS))
.append(newline())
.append(spaces).append(arrow).append(space())
.append(text("me | player | server | top").color(componentFactory.hoverAccent()))
.append(text("me | player | server | top").color(factory.MSG_HOVER_ACCENT))
.append(newline())
.append(spaces).append(spaces).append(bullet).append(space())
.append(text("me:").color(componentFactory.msgAccent2A())).append(space())
.append(text("your own statistic").color(componentFactory.brackets()))
.append(text("me:").color(factory.MSG_ACCENT_2A)).append(space())
.append(text("your own statistic").color(factory.BRACKETS))
.append(newline())
.append(spaces).append(spaces).append(bullet).append(space())
.append(text("player:").color(componentFactory.msgAccent2A())).append(space())
.append(text("choose a player").color(componentFactory.brackets()))
.append(text("player:").color(factory.MSG_ACCENT_2A)).append(space())
.append(text("choose a player").color(factory.BRACKETS))
.append(newline())
.append(spaces).append(spaces).append(bullet).append(space())
.append(text("server:").color(componentFactory.msgAccent2A())).append(space())
.append(text("everyone on the server combined").color(componentFactory.brackets()))
.append(text("server:").color(factory.MSG_ACCENT_2A)).append(space())
.append(text("everyone on the server combined").color(factory.BRACKETS))
.append(newline())
.append(spaces).append(spaces).append(bullet).append(space())
.append(text("top:").color(componentFactory.msgAccent2A())).append(space())
.append(text("the top").color(componentFactory.brackets()).append(space()).append(text(listSize)))
.append(text("top:").color(factory.MSG_ACCENT_2A)).append(space())
.append(text("the top").color(factory.BRACKETS).append(space()).append(text(listSize)))
.append(newline())
.append(spaces).append(arrow).append(space())
.append(text("{player-name}").color(componentFactory.hoverAccent()));
.append(text("{player-name}").color(factory.MSG_HOVER_ACCENT));
}
private TextComponent helpMsgHover(int listSize) {
private TextComponent buildHoverMsg(ComponentFactory factory, int listSize) {
TextComponent spaces = text(" ");
TextComponent arrow = text("").color(componentFactory.msgMain2());
TextComponent arrow = text("").color(factory.MSG_MAIN_2);
return Component.newline()
.append(componentFactory.prefixTitleComponent())
.append(factory.pluginPrefixAsTitle())
.append(newline())
.append(componentFactory.subTitleComponent("Hover over the arguments for more information!"))
.append(factory.subTitle("Hover over the arguments for more information!"))
.append(newline())
.append(text("Usage:").color(componentFactory.msgMain2())).append(space())
.append(text("/statistic").color(componentFactory.hoverAccent()))
.append(text("Usage:").color(factory.MSG_MAIN_2)).append(space())
.append(text("/statistic").color(factory.MSG_HOVER_ACCENT))
.append(newline())
.append(spaces).append(arrow).append(space())
.append(text("name").color(componentFactory.hoverAccent())
.hoverEvent(HoverEvent.showText(text("The name that describes the statistic").color(componentFactory.hoverMsg())
.append(text("name").color(factory.MSG_HOVER_ACCENT)
.hoverEvent(HoverEvent.showText(text("The name that describes the statistic").color(factory.MSG_HOVER)
.append(newline())
.append(text("Example: ").color(componentFactory.msgMain2()))
.append(text("\"animals_bred\"").color(componentFactory.hoverAccent())))))
.append(text("Example: ").color(factory.MSG_MAIN_2))
.append(text("\"animals_bred\"").color(factory.MSG_HOVER_ACCENT)))))
.append(newline())
.append(spaces).append(arrow).append(space())
.append(text("sub-statistic").color(componentFactory.hoverAccent())
.append(text("sub-statistic").color(factory.MSG_HOVER_ACCENT)
.hoverEvent(HoverEvent.showText(
text("Some statistics need an item, block or entity as extra input").color(componentFactory.hoverMsg())
text("Some statistics need an item, block or entity as extra input").color(factory.MSG_HOVER)
.append(newline())
.append(text("Example: ").color(componentFactory.msgMain2())
.append(text("\"mine_block diorite\"").color(componentFactory.hoverAccent()))))))
.append(text("Example: ").color(factory.MSG_MAIN_2)
.append(text("\"mine_block diorite\"").color(factory.MSG_HOVER_ACCENT))))))
.append(newline())
.append(spaces).append(arrow
.hoverEvent(HoverEvent.showText(
text("Choose one").color(componentFactory.underscore())))).append(space())
.append(text("me").color(componentFactory.hoverAccent())
text("Choose one").color(factory.UNDERSCORE)))).append(space())
.append(text("me").color(factory.MSG_HOVER_ACCENT)
.hoverEvent(HoverEvent.showText(
text("See your own statistic").color(componentFactory.hoverMsg()))))
.append(text(" | ").color(componentFactory.hoverAccent()))
.append(text("player").color(componentFactory.hoverAccent())
text("See your own statistic").color(factory.MSG_HOVER))))
.append(text(" | ").color(factory.MSG_HOVER_ACCENT))
.append(text("player").color(factory.MSG_HOVER_ACCENT)
.hoverEvent(HoverEvent.showText(
text("Choose any player that has played on your server").color(componentFactory.hoverMsg()))))
.append(text(" | ").color(componentFactory.hoverAccent()))
.append(text("server").color(componentFactory.hoverAccent())
text("Choose any player that has played on your server").color(factory.MSG_HOVER))))
.append(text(" | ").color(factory.MSG_HOVER_ACCENT))
.append(text("server").color(factory.MSG_HOVER_ACCENT)
.hoverEvent(HoverEvent.showText(
text("See the combined total for everyone on your server").color(componentFactory.hoverMsg()))))
.append(text(" | ").color(componentFactory.hoverAccent()))
.append(text("top").color(componentFactory.hoverAccent())
text("See the combined total for everyone on your server").color(factory.MSG_HOVER))))
.append(text(" | ").color(factory.MSG_HOVER_ACCENT))
.append(text("top").color(factory.MSG_HOVER_ACCENT)
.hoverEvent(HoverEvent.showText(
text("See the top").color(componentFactory.hoverMsg()).append(space())
text("See the top").color(factory.MSG_HOVER).append(space())
.append(text(listSize)))))
.append(newline())
.append(spaces).append(arrow).append(space())
.append(text("player-name").color(componentFactory.hoverAccent())
.append(text("player-name").color(factory.MSG_HOVER_ACCENT)
.hoverEvent(HoverEvent.showText(
text("In case you typed").color(componentFactory.hoverMsg()).append(space())
.append(text("\"player\"").color(componentFactory.hoverAccent()))
text("In case you typed").color(factory.MSG_HOVER).append(space())
.append(text("\"player\"").color(factory.MSG_HOVER_ACCENT))
.append(text(", add the player's name")))));
}

View File

@ -1,4 +1,4 @@
package com.gmail.artemis.the.gr8.playerstats.msg;
package com.gmail.artemis.the.gr8.playerstats.msg.components;
import com.gmail.artemis.the.gr8.playerstats.config.ConfigHandler;
@ -23,14 +23,17 @@ public class PrideComponentFactory extends ComponentFactory {
PREFIX = PluginColor.GOLD.getColor();
BRACKETS = PluginColor.GRAY.getColor();
UNDERSCORE = PluginColor.DARK_PURPLE.getColor();
MSG_MAIN = PluginColor.GRAY.getColor(); //difference 1
MSG_ACCENT = PluginColor.LIGHT_GOLD.getColor(); //difference 2
MSG_MAIN_2 = PluginColor.GOLD.getColor();
MSG_ACCENT_2A = PluginColor.MEDIUM_GOLD.getColor();
MSG_ACCENT_2B = PluginColor.LIGHT_YELLOW.getColor();
CLICKED_MSG = PluginColor.LIGHT_PURPLE.getColor();
HOVER_MSG = PluginColor.LIGHT_BLUE.getColor();
HOVER_ACCENT = PluginColor.LIGHT_GOLD.getColor();
MSG_HOVER = PluginColor.LIGHT_BLUE.getColor();
MSG_CLICKED = PluginColor.LIGHT_PURPLE.getColor();
MSG_HOVER_ACCENT = PluginColor.LIGHT_GOLD.getColor();
}
@Override
@ -44,7 +47,7 @@ public class PrideComponentFactory extends ComponentFactory {
}
@Override
public TextComponent prefixTitleComponent() {
public TextComponent pluginPrefixAsTitle() {
String title = "<rainbow:16>____________ [PlayerStats] ____________</rainbow>"; //12 underscores
return text()
.append(MiniMessage.miniMessage().deserialize(title))
@ -52,7 +55,7 @@ public class PrideComponentFactory extends ComponentFactory {
}
@Override
public TextComponent pluginPrefixComponent() {
public TextComponent pluginPrefix() {
Random randomizer = new Random();
if (randomizer.nextBoolean()) {
return backwardsPluginPrefixComponent();