mirror of
https://github.com/itHotL/PlayerStats.git
synced 2025-01-23 21:51:19 +01:00
Implemented random chance for backwards rainbow prefix, fixed several config setting bugs, started fixing the separate message system for console
This commit is contained in:
parent
e23913e32e
commit
b7d1171d83
@ -33,15 +33,7 @@ public final class ShareManager {
|
||||
private ArrayBlockingQueue<UUID> sharedResults;
|
||||
|
||||
private ShareManager(ConfigHandler config) {
|
||||
isEnabled = config.enableStatSharing();
|
||||
waitingTime = config.getStatShareWaitingTime();
|
||||
|
||||
if (isEnabled) {
|
||||
resultID = new AtomicInteger(); //always starts with value 0
|
||||
statResultQueue = new ConcurrentHashMap<>();
|
||||
shareTimeStamp = new ConcurrentHashMap<>();
|
||||
sharedResults = new ArrayBlockingQueue<>(500);
|
||||
}
|
||||
updateSettings(config);
|
||||
}
|
||||
|
||||
public static ShareManager getInstance(ConfigHandler config) {
|
||||
@ -58,22 +50,27 @@ public final class ShareManager {
|
||||
}
|
||||
|
||||
public synchronized void updateSettings(ConfigHandler config) {
|
||||
isEnabled = config.enableStatSharing();
|
||||
isEnabled = config.allowStatSharing() && config.useHoverText();
|
||||
waitingTime = config.getStatShareWaitingTime();
|
||||
|
||||
|
||||
if (isEnabled) { //reset the sharedResultsQueue
|
||||
sharedResults = new ArrayBlockingQueue<>(500);
|
||||
if (statResultQueue == null) { //if we went from disabled to enabled, initialize the HashMaps
|
||||
if (isEnabled) {
|
||||
sharedResults = new ArrayBlockingQueue<>(500); //reset the sharedResultsQueue
|
||||
if (resultID == null) { //if we went from disabled to enabled, initialize
|
||||
resultID = new AtomicInteger(); //always starts with value 0
|
||||
statResultQueue = new ConcurrentHashMap<>();
|
||||
shareTimeStamp = new ConcurrentHashMap<>();
|
||||
}
|
||||
}
|
||||
//if we went from enabled to disabled, purge the existing data
|
||||
else if (statResultQueue != null) {
|
||||
statResultQueue = null;
|
||||
shareTimeStamp = null;
|
||||
sharedResults = null;
|
||||
} else {
|
||||
//if we went from enabled to disabled, purge the existing data
|
||||
if (statResultQueue != null) {
|
||||
statResultQueue = null;
|
||||
shareTimeStamp = null;
|
||||
sharedResults = null;
|
||||
}
|
||||
if (config.allowStatSharing() && !config.useHoverText()) {
|
||||
MyLogger.logMsg("Stat-sharing does not work without hover-text enabled! " +
|
||||
"Enable hover-text, or disable stat-sharing to stop seeing this message.", true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -81,7 +81,7 @@ public class ConfigHandler {
|
||||
|
||||
/** Returns true if stat-sharing is allowed.
|
||||
<p>Default: true</p>*/
|
||||
public boolean enableStatSharing() {
|
||||
public boolean allowStatSharing() {
|
||||
return config.getBoolean("enable-stat-sharing", true);
|
||||
}
|
||||
|
||||
@ -125,13 +125,13 @@ public class ConfigHandler {
|
||||
|
||||
/** Whether to use festive formatting, such as pride colors.
|
||||
<p>Default: true</p> */
|
||||
public boolean enableFestiveFormatting() {
|
||||
public boolean useFestiveFormatting() {
|
||||
return config.getBoolean("enable-festive-formatting", true);
|
||||
}
|
||||
|
||||
/** Whether to use rainbow colors for the [PlayerStats] prefix rather than the default gold/purple.
|
||||
<p>Default: false</p> */
|
||||
public boolean enableRainbowMode() {
|
||||
public boolean useRainbowMode() {
|
||||
return config.getBoolean("rainbow-mode", false);
|
||||
}
|
||||
|
||||
|
@ -19,6 +19,7 @@ public enum PluginColor {
|
||||
GRAY (NamedTextColor.GRAY), //#AAAAAA
|
||||
DARK_PURPLE (TextColor.fromHexString("#6E3485")),
|
||||
LIGHT_PURPLE (TextColor.fromHexString("#845EC2")),
|
||||
BLUE (NamedTextColor.BLUE),
|
||||
MEDIUM_BLUE (TextColor.fromHexString("#55AAFF")),
|
||||
LIGHT_BLUE (TextColor.fromHexString("#55C6FF")),
|
||||
GOLD (NamedTextColor.GOLD), //#FFAA00
|
||||
|
@ -1,17 +1,20 @@
|
||||
package com.gmail.artemis.the.gr8.playerstats.msg;
|
||||
|
||||
import com.gmail.artemis.the.gr8.playerstats.config.ConfigHandler;
|
||||
import com.gmail.artemis.the.gr8.playerstats.enums.DebugLevel;
|
||||
import com.gmail.artemis.the.gr8.playerstats.enums.PluginColor;
|
||||
import com.gmail.artemis.the.gr8.playerstats.utils.MyLogger;
|
||||
import net.kyori.adventure.text.TextComponent;
|
||||
import net.kyori.adventure.text.format.NamedTextColor;
|
||||
import net.kyori.adventure.text.format.TextColor;
|
||||
import net.kyori.adventure.text.format.TextDecoration;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import static net.kyori.adventure.text.Component.text;
|
||||
|
||||
public class BukkitConsoleComponentFactory extends ComponentFactory {
|
||||
|
||||
public BukkitConsoleComponentFactory(ConfigHandler config) {
|
||||
super(config);
|
||||
MyLogger.logMsg("BukkitConsoleFactory created!", DebugLevel.MEDIUM);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -21,8 +24,8 @@ public class BukkitConsoleComponentFactory extends ComponentFactory {
|
||||
UNDERSCORE = PluginColor.DARK_PURPLE.getConsoleColor();
|
||||
MSG_MAIN = PluginColor.MEDIUM_BLUE.getConsoleColor();
|
||||
MSG_MAIN_2 = PluginColor.GOLD.getConsoleColor();
|
||||
MSG_ACCENT = PluginColor.MEDIUM_GOLD.getConsoleColor();
|
||||
MSG_ACCENT_2 = PluginColor.LIGHT_YELLOW.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();
|
||||
@ -33,6 +36,25 @@ public class BukkitConsoleComponentFactory extends ComponentFactory {
|
||||
return PluginColor.NAME_5.getConsoleColor();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected TextComponent getComponent(String content, @NotNull TextColor color, @Nullable TextDecoration style) {
|
||||
return getComponentBuilder(content, NamedTextColor.nearestTo(color), style).build();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected TextComponent.Builder getComponentBuilder(@Nullable String content, @NotNull TextColor color, @Nullable TextDecoration style) {
|
||||
TextComponent.Builder builder = text()
|
||||
.decorations(TextDecoration.NAMES.values(), false)
|
||||
.color(NamedTextColor.nearestTo(color));
|
||||
if (content != null) {
|
||||
builder.append(text(content));
|
||||
}
|
||||
if (style != null) {
|
||||
builder.decorate(style);
|
||||
}
|
||||
return builder;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected TextColor getHexColor(String hexColor) {
|
||||
TextColor hex = TextColor.fromHexString(hexColor);
|
||||
|
@ -1,11 +1,9 @@
|
||||
package com.gmail.artemis.the.gr8.playerstats.msg;
|
||||
|
||||
import com.gmail.artemis.the.gr8.playerstats.config.ConfigHandler;
|
||||
import com.gmail.artemis.the.gr8.playerstats.enums.DebugLevel;
|
||||
import com.gmail.artemis.the.gr8.playerstats.enums.PluginColor;
|
||||
import com.gmail.artemis.the.gr8.playerstats.enums.Target;
|
||||
import com.gmail.artemis.the.gr8.playerstats.enums.Unit;
|
||||
import com.gmail.artemis.the.gr8.playerstats.utils.MyLogger;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.kyori.adventure.text.TextComponent;
|
||||
import net.kyori.adventure.text.TranslatableComponent;
|
||||
@ -36,10 +34,11 @@ public class ComponentFactory {
|
||||
protected static TextColor PREFIX; //gold
|
||||
protected static TextColor BRACKETS; //gray
|
||||
protected static TextColor UNDERSCORE; //dark_purple
|
||||
protected static TextColor MSG_MAIN; //blue
|
||||
protected static TextColor MSG_MAIN; //medium_blue
|
||||
protected static TextColor MSG_ACCENT; //blue
|
||||
protected static TextColor MSG_MAIN_2; //gold
|
||||
protected static TextColor MSG_ACCENT; //medium_gold
|
||||
protected static TextColor MSG_ACCENT_2; //light_yellow
|
||||
protected static TextColor MSG_ACCENT_2A; //medium_gold
|
||||
protected static TextColor MSG_ACCENT_2B; //light_yellow
|
||||
protected static TextColor HOVER_MSG; //light_blue
|
||||
protected static TextColor CLICKED_MSG; //light_purple
|
||||
protected static TextColor HOVER_ACCENT; //light_gold
|
||||
@ -48,8 +47,6 @@ public class ComponentFactory {
|
||||
public ComponentFactory(ConfigHandler c) {
|
||||
config = c;
|
||||
prepareColors();
|
||||
|
||||
MyLogger.logMsg("Regular ComponentFactory created!", DebugLevel.MEDIUM);
|
||||
}
|
||||
|
||||
protected void prepareColors() {
|
||||
@ -57,9 +54,10 @@ public class ComponentFactory {
|
||||
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 = PluginColor.MEDIUM_GOLD.getColor();
|
||||
MSG_ACCENT_2 = PluginColor.LIGHT_YELLOW.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();
|
||||
@ -77,14 +75,17 @@ public class ComponentFactory {
|
||||
public TextColor msgMain() {
|
||||
return MSG_MAIN;
|
||||
}
|
||||
public TextColor msgMain2() {
|
||||
return MSG_MAIN_2;
|
||||
}
|
||||
public TextColor msgAccent() {
|
||||
return MSG_ACCENT;
|
||||
}
|
||||
public TextColor msgAccent2() {
|
||||
return MSG_ACCENT_2;
|
||||
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;
|
||||
@ -96,6 +97,9 @@ public class ComponentFactory {
|
||||
return HOVER_ACCENT;
|
||||
}
|
||||
|
||||
public TextColor getExampleNameColor() {
|
||||
return MSG_ACCENT_2B;
|
||||
}
|
||||
public TextColor getSharerNameColor() {
|
||||
return getColorFromString(config.getSharerNameDecoration(false));
|
||||
}
|
||||
@ -294,8 +298,7 @@ public class ComponentFactory {
|
||||
if (config.useHoverText()) {
|
||||
heartComponent.hoverEvent(HoverEvent.showText(
|
||||
text(Unit.HEART.getLabel())
|
||||
.color(HOVER_ACCENT)
|
||||
.decorate(TextDecoration.ITALIC)));
|
||||
.color(HOVER_ACCENT)));
|
||||
}
|
||||
return surroundingBracketComponent(heartComponent.build());
|
||||
}
|
||||
@ -374,11 +377,11 @@ public class ComponentFactory {
|
||||
getStyleFromString(config.getDotsDecoration(true)));
|
||||
}
|
||||
|
||||
private TextComponent getComponent(String content, TextColor color, @Nullable TextDecoration style) {
|
||||
protected TextComponent getComponent(String content, @NotNull TextColor color, @Nullable TextDecoration style) {
|
||||
return getComponentBuilder(content, color, style).build();
|
||||
}
|
||||
|
||||
private TextComponent.Builder getComponentBuilder(@Nullable String content, TextColor color, @Nullable TextDecoration style) {
|
||||
protected TextComponent.Builder getComponentBuilder(@Nullable String content, TextColor color, @Nullable TextDecoration style) {
|
||||
TextComponent.Builder builder = text()
|
||||
.decorations(TextDecoration.NAMES.values(), false)
|
||||
.color(color);
|
||||
|
@ -1,41 +1,49 @@
|
||||
package com.gmail.artemis.the.gr8.playerstats.msg;
|
||||
|
||||
import com.gmail.artemis.the.gr8.playerstats.config.ConfigHandler;
|
||||
import com.gmail.artemis.the.gr8.playerstats.enums.DebugLevel;
|
||||
import com.gmail.artemis.the.gr8.playerstats.msg.msgutils.ExampleMessage;
|
||||
import com.gmail.artemis.the.gr8.playerstats.msg.msgutils.HelpMessage;
|
||||
import com.gmail.artemis.the.gr8.playerstats.utils.MyLogger;
|
||||
import net.kyori.adventure.text.TextComponent;
|
||||
import org.bukkit.Bukkit;
|
||||
|
||||
import java.time.LocalDate;
|
||||
import java.time.Month;
|
||||
|
||||
|
||||
/** Composes messages to send to a Console. This class is responsible
|
||||
for constructing a final Component with the text content of the desired message.
|
||||
The component parts (with appropriate formatting) are supplied by a ComponentFactory.*/
|
||||
public class ConsoleMessageWriter extends MessageWriter {
|
||||
|
||||
private final boolean isBukkit;
|
||||
|
||||
private static ComponentFactory componentFactory;
|
||||
private final ComponentFactory componentFactory;
|
||||
|
||||
public ConsoleMessageWriter(ConfigHandler c) {
|
||||
super(c);
|
||||
|
||||
isBukkit = Bukkit.getName().equalsIgnoreCase("CraftBukkit");
|
||||
}
|
||||
boolean isBukkit = Bukkit.getName().equalsIgnoreCase("CraftBukkit");
|
||||
MyLogger.logMsg("Bukkit name: " + Bukkit.getName(), DebugLevel.MEDIUM);
|
||||
|
||||
@Override
|
||||
protected void getComponentFactory() {
|
||||
if (isBukkit) {
|
||||
componentFactory = new BukkitConsoleComponentFactory(config);
|
||||
MyLogger.logMsg("ConsoleMessageWriter is using Bukkit-Factory", DebugLevel.MEDIUM);
|
||||
}
|
||||
else if (config.enableRainbowMode() ||
|
||||
(config.enableFestiveFormatting() && LocalDate.now().getMonth().equals(Month.JUNE))) {
|
||||
else if (config.useRainbowMode() ||
|
||||
(config.useFestiveFormatting() && LocalDate.now().getMonth().equals(Month.JUNE))) {
|
||||
componentFactory = new PrideComponentFactory(config);
|
||||
MyLogger.logMsg("ConsoleMessageWriter is using Pride-Factory", DebugLevel.MEDIUM);
|
||||
}
|
||||
else {
|
||||
componentFactory = new ComponentFactory(config);
|
||||
MyLogger.logMsg("ConsoleMessageWriter is using Default-Factory", DebugLevel.MEDIUM);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected ComponentFactory componentFactory() {
|
||||
return componentFactory;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TextComponent usageExamples() {
|
||||
return new ExampleMessage(componentFactory);
|
||||
|
@ -23,14 +23,14 @@ import java.util.function.BiFunction;
|
||||
|
||||
import static net.kyori.adventure.text.Component.*;
|
||||
|
||||
/** Composes messages to send to Players or Console. This class is responsible
|
||||
/** Composes messages to send to Players. This class is responsible
|
||||
for constructing a final Component with the text content of the desired message.
|
||||
The component parts (with appropriate formatting) are supplied by a ComponentFactory.*/
|
||||
public class MessageWriter {
|
||||
|
||||
protected static ConfigHandler config;
|
||||
|
||||
private static ComponentFactory componentFactory;
|
||||
private final ComponentFactory componentFactory;
|
||||
private final LanguageKeyHandler languageKeyHandler;
|
||||
private final NumberFormatter formatter;
|
||||
|
||||
@ -38,75 +38,78 @@ public class MessageWriter {
|
||||
config = c;
|
||||
formatter = new NumberFormatter();
|
||||
languageKeyHandler = new LanguageKeyHandler();
|
||||
getComponentFactory();
|
||||
}
|
||||
|
||||
protected void getComponentFactory() {
|
||||
if (config.enableRainbowMode() ||
|
||||
(config.enableFestiveFormatting() && LocalDate.now().getMonth().equals(Month.JUNE))) {
|
||||
if (config.useRainbowMode() ||
|
||||
(config.useFestiveFormatting() && LocalDate.now().getMonth().equals(Month.JUNE))) {
|
||||
|
||||
componentFactory = new PrideComponentFactory(config);
|
||||
componentFactory = new PrideComponentFactory(config);
|
||||
MyLogger.logMsg("MessageWriter is using Pride-Factory", DebugLevel.MEDIUM);
|
||||
}
|
||||
else {
|
||||
componentFactory = new ComponentFactory(config);
|
||||
MyLogger.logMsg("MessageWriter is using Default-Factory", DebugLevel.MEDIUM);
|
||||
}
|
||||
}
|
||||
|
||||
protected ComponentFactory componentFactory() {
|
||||
return componentFactory;
|
||||
}
|
||||
|
||||
public TextComponent reloadedConfig() {
|
||||
return componentFactory.pluginPrefixComponent()
|
||||
return componentFactory().pluginPrefixComponent()
|
||||
.append(space())
|
||||
.append(componentFactory.messageComponent().content("Config reloaded!"));
|
||||
.append(componentFactory().messageComponent().content("Config reloaded!"));
|
||||
}
|
||||
|
||||
public TextComponent stillReloading() {
|
||||
return componentFactory.pluginPrefixComponent()
|
||||
return componentFactory().pluginPrefixComponent()
|
||||
.append(space())
|
||||
.append(componentFactory.messageComponent().content(
|
||||
.append(componentFactory().messageComponent().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().pluginPrefixComponent()
|
||||
.append(space())
|
||||
.append(componentFactory.messageComponent().content(msg));
|
||||
.append(componentFactory().messageComponent().content(msg));
|
||||
}
|
||||
|
||||
public TextComponent missingStatName() {
|
||||
return componentFactory.pluginPrefixComponent()
|
||||
return componentFactory().pluginPrefixComponent()
|
||||
.append(space())
|
||||
.append(componentFactory.messageComponent().content(
|
||||
.append(componentFactory().messageComponent().content(
|
||||
"Please provide a valid statistic name!"));
|
||||
}
|
||||
|
||||
public TextComponent missingSubStatName(Statistic.Type statType) {
|
||||
return componentFactory.pluginPrefixComponent()
|
||||
return componentFactory().pluginPrefixComponent()
|
||||
.append(space())
|
||||
.append(componentFactory.messageComponent().content(
|
||||
.append(componentFactory().messageComponent().content(
|
||||
"Please add a valid " + EnumHandler.getSubStatTypeName(statType) + " to look up this statistic!"));
|
||||
}
|
||||
|
||||
public TextComponent missingPlayerName() {
|
||||
return componentFactory.pluginPrefixComponent()
|
||||
return componentFactory().pluginPrefixComponent()
|
||||
.append(space())
|
||||
.append(componentFactory.messageComponent().content(
|
||||
.append(componentFactory().messageComponent().content(
|
||||
"Please specify a valid player-name!"));
|
||||
}
|
||||
|
||||
public TextComponent wrongSubStatType(Statistic.Type statType, String subStatName) {
|
||||
return componentFactory.pluginPrefixComponent()
|
||||
return componentFactory().pluginPrefixComponent()
|
||||
.append(space())
|
||||
.append(componentFactory.messageAccentComponent().content(subStatName))
|
||||
.append(componentFactory().messageAccentComponent().content("\"" + subStatName + "\""))
|
||||
.append(space())
|
||||
.append(componentFactory.messageComponent().content(
|
||||
.append(componentFactory().messageComponent().content(
|
||||
"is not a valid " + EnumHandler.getSubStatTypeName(statType) + "!"));
|
||||
}
|
||||
|
||||
public TextComponent requestAlreadyRunning() {
|
||||
return componentFactory.pluginPrefixComponent()
|
||||
return componentFactory().pluginPrefixComponent()
|
||||
.append(space())
|
||||
.append(componentFactory.messageComponent().content(
|
||||
.append(componentFactory().messageComponent().content(
|
||||
"Please wait for your previous lookup to finish!"));
|
||||
}
|
||||
|
||||
@ -115,50 +118,50 @@ public class MessageWriter {
|
||||
int waitTime = config.getStatShareWaitingTime();
|
||||
String minutes = waitTime == 1 ? " minute" : " minutes";
|
||||
|
||||
return componentFactory.pluginPrefixComponent()
|
||||
return componentFactory().pluginPrefixComponent()
|
||||
.append(space())
|
||||
.append(componentFactory.messageComponent().content("You need to wait")
|
||||
.append(componentFactory().messageComponent().content("You need to wait")
|
||||
.append(space())
|
||||
.append(componentFactory.messageAccentComponent()
|
||||
.append(componentFactory().messageAccentComponent()
|
||||
.content(waitTime + minutes))
|
||||
.append(space())
|
||||
.append(text("between sharing!")));
|
||||
}
|
||||
|
||||
public TextComponent resultsAlreadyShared() {
|
||||
return componentFactory.pluginPrefixComponent()
|
||||
return componentFactory().pluginPrefixComponent()
|
||||
.append(space())
|
||||
.append(componentFactory.messageComponent().content("You already shared these results!"));
|
||||
.append(componentFactory().messageComponent().content("You already shared these results!"));
|
||||
}
|
||||
|
||||
public TextComponent statResultsTooOld() {
|
||||
return componentFactory.pluginPrefixComponent()
|
||||
return componentFactory().pluginPrefixComponent()
|
||||
.append(space())
|
||||
.append(componentFactory.messageComponent().content(
|
||||
"It has been too long since you looked up this statistic, please repeat the original look-up if you want to share it!"));
|
||||
.append(componentFactory().messageComponent().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().pluginPrefixComponent()
|
||||
.append(space())
|
||||
.append(componentFactory.messageComponent().content(
|
||||
.append(componentFactory().messageComponent().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 new ExampleMessage(componentFactory());
|
||||
}
|
||||
|
||||
public TextComponent helpMsg() {
|
||||
return new HelpMessage(componentFactory,
|
||||
return new HelpMessage(componentFactory(),
|
||||
config.useHoverText(),
|
||||
config.getTopListMaxSize());
|
||||
}
|
||||
|
||||
public BiFunction<UUID, CommandSender, TextComponent> formattedPlayerStatFunction(int stat, @NotNull StatRequest request) {
|
||||
TextComponent playerStat = Component.text()
|
||||
.append(componentFactory.playerNameBuilder(request.getPlayerName(), Target.PLAYER)
|
||||
.append(componentFactory().playerNameBuilder(request.getPlayerName(), Target.PLAYER)
|
||||
.append(text(":"))
|
||||
.append(space()))
|
||||
.append(getStatNumberComponent(request.getStatistic(), stat, Target.PLAYER, request.isConsoleSender()))
|
||||
@ -172,9 +175,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().titleComponent(config.getServerTitle(), Target.SERVER))
|
||||
.append(space())
|
||||
.append(componentFactory.serverNameComponent(config.getServerName()))
|
||||
.append(componentFactory().serverNameComponent(config.getServerName()))
|
||||
.append(space())
|
||||
.append(getStatNumberComponent(request.getStatistic(), stat, Target.SERVER, request.isConsoleSender()))
|
||||
.append(space())
|
||||
@ -202,7 +205,7 @@ public class MessageWriter {
|
||||
}
|
||||
topBuilder.append(title)
|
||||
.append(space())
|
||||
.append(componentFactory.shareButtonComponent(shareCode))
|
||||
.append(componentFactory().shareButtonComponent(shareCode))
|
||||
.append(list);
|
||||
}
|
||||
//if we're adding a "shared by" component
|
||||
@ -212,12 +215,12 @@ public class MessageWriter {
|
||||
}
|
||||
topBuilder.append(shortTitle)
|
||||
.append(space())
|
||||
.append(componentFactory.hoveringStatResultComponent(text()
|
||||
.append(componentFactory().hoveringStatResultComponent(text()
|
||||
.append(title)
|
||||
.append(list)
|
||||
.build()))
|
||||
.append(newline())
|
||||
.append(componentFactory.messageSharedComponent(
|
||||
.append(componentFactory().messageSharedComponent(
|
||||
getSharerNameComponent(sender)));
|
||||
}
|
||||
//if we're not adding a share-button or a "shared by" component
|
||||
@ -246,7 +249,7 @@ public class MessageWriter {
|
||||
}
|
||||
statBuilder.append(statResult)
|
||||
.append(space())
|
||||
.append(componentFactory.shareButtonComponent(shareCode));
|
||||
.append(componentFactory().shareButtonComponent(shareCode));
|
||||
}
|
||||
//if we're adding a "shared by" component
|
||||
else if (sender != null) {
|
||||
@ -255,7 +258,7 @@ public class MessageWriter {
|
||||
}
|
||||
statBuilder.append(statResult)
|
||||
.append(newline())
|
||||
.append(componentFactory.messageSharedComponent(
|
||||
.append(componentFactory().messageSharedComponent(
|
||||
getSharerNameComponent(sender)));
|
||||
}
|
||||
//if we're not adding a share-button or a "shared by" component
|
||||
@ -276,14 +279,14 @@ public class MessageWriter {
|
||||
return senderName;
|
||||
}
|
||||
}
|
||||
return componentFactory.sharerNameComponent(sender.getName());
|
||||
return componentFactory().sharerNameComponent(sender.getName());
|
||||
}
|
||||
|
||||
private TextComponent getTopStatsTitle(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().pluginPrefixComponent()).append(space())
|
||||
.append(componentFactory().titleComponent(config.getTopStatsTitle(), Target.TOP)).append(space())
|
||||
.append(componentFactory().titleNumberComponent(statListSize)).append(space())
|
||||
.append(getStatNameComponent(request)) //space is provided by statUnitComponent
|
||||
.append(getStatUnitComponent(request.getStatistic(), request.getSelection(), request.isConsoleSender()))
|
||||
.build();
|
||||
@ -291,8 +294,8 @@ public class MessageWriter {
|
||||
|
||||
private TextComponent getTopStatsTitleShort(StatRequest request, int statListSize) {
|
||||
return Component.text()
|
||||
.append(componentFactory.titleComponent(config.getTopStatsTitle(), Target.TOP)).append(space())
|
||||
.append(componentFactory.titleNumberComponent(statListSize)).append(space())
|
||||
.append(componentFactory().titleComponent(config.getTopStatsTitle(), Target.TOP)).append(space())
|
||||
.append(componentFactory().titleNumberComponent(statListSize)).append(space())
|
||||
.append(getStatNameComponent(request)) //space is provided by statUnitComponent
|
||||
.build();
|
||||
}
|
||||
@ -305,16 +308,16 @@ public class MessageWriter {
|
||||
|
||||
int count = 0;
|
||||
for (String playerName : playerNames) {
|
||||
TextComponent.Builder playerNameBuilder = componentFactory.playerNameBuilder(playerName, Target.TOP);
|
||||
TextComponent.Builder playerNameBuilder = componentFactory().playerNameBuilder(playerName, Target.TOP);
|
||||
topList.append(newline())
|
||||
.append(componentFactory.rankingNumberComponent(" " + ++count + "."))
|
||||
.append(componentFactory().rankingNumberComponent(" " + ++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().dotsBuilder().append(text((".".repeat(dots)))));
|
||||
}
|
||||
}
|
||||
else {
|
||||
@ -340,10 +343,10 @@ public class MessageWriter {
|
||||
}
|
||||
}
|
||||
}
|
||||
return componentFactory.statNameTransComponent(statKey, subStatKey, request.getSelection());
|
||||
return componentFactory().statNameTransComponent(statKey, subStatKey, request.getSelection());
|
||||
}
|
||||
else {
|
||||
return componentFactory.statNameTextComponent(
|
||||
return componentFactory().statNameTextComponent(
|
||||
StringUtils.prettify(request.getStatistic().toString()),
|
||||
StringUtils.prettify(request.getSubStatEntry()),
|
||||
request.getSelection());
|
||||
@ -363,7 +366,7 @@ public class MessageWriter {
|
||||
}
|
||||
String prettyNumber = formatter.format(statNumber, statUnit);
|
||||
if (!config.useHoverText() || statUnit == Unit.NUMBER) {
|
||||
return componentFactory.statNumberComponent(prettyNumber, selection);
|
||||
return componentFactory().statNumberComponent(prettyNumber, selection);
|
||||
}
|
||||
Unit hoverUnit = type == Unit.Type.DISTANCE ? Unit.fromString(config.getDistanceUnit(true)) :
|
||||
Unit.fromString(config.getDamageUnit(true));
|
||||
@ -371,17 +374,17 @@ public class MessageWriter {
|
||||
MyLogger.logMsg("mainNumber: " + prettyNumber + ", hoverNumber: " + prettyHoverNumber, DebugLevel.HIGH);
|
||||
|
||||
if (hoverUnit == Unit.HEART) {
|
||||
return componentFactory.damageNumberHoverComponent(
|
||||
return componentFactory().damageNumberHoverComponent(
|
||||
prettyNumber, prettyHoverNumber,
|
||||
componentFactory.heartComponent(isConsoleSender, true), selection);
|
||||
componentFactory().heartComponent(isConsoleSender, true), selection);
|
||||
}
|
||||
if (config.useTranslatableComponents()) {
|
||||
String unitKey = languageKeyHandler.getUnitKey(hoverUnit);
|
||||
if (unitKey != null) {
|
||||
return componentFactory.statNumberHoverComponent(prettyNumber, prettyHoverNumber, null, unitKey, selection);
|
||||
return componentFactory().statNumberHoverComponent(prettyNumber, prettyHoverNumber, null, unitKey, selection);
|
||||
}
|
||||
}
|
||||
return componentFactory.statNumberHoverComponent(prettyNumber, prettyHoverNumber, hoverUnit.getLabel(), null, selection);
|
||||
return componentFactory().statNumberHoverComponent(prettyNumber, prettyHoverNumber, hoverUnit.getLabel(), null, selection);
|
||||
}
|
||||
|
||||
private TextComponent getTimeNumberComponent(long statNumber, Target selection, ArrayList<Unit> unitRange) {
|
||||
@ -389,16 +392,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().statNumberComponent("-", selection);
|
||||
}
|
||||
else {
|
||||
String mainNumber = formatter.format(statNumber, unitRange.get(0), unitRange.get(1));
|
||||
if (!config.useHoverText()) {
|
||||
return componentFactory.statNumberComponent(mainNumber, selection);
|
||||
return componentFactory().statNumberComponent(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().statNumberHoverComponent(mainNumber, hoverNumber,
|
||||
null, null, selection);
|
||||
}
|
||||
}
|
||||
@ -448,15 +451,15 @@ public class MessageWriter {
|
||||
String unitKey = languageKeyHandler.getUnitKey(statUnit);
|
||||
if (unitKey != null) {
|
||||
return Component.space()
|
||||
.append(componentFactory.statUnitComponent(null, unitKey, selection));
|
||||
.append(componentFactory().statUnitComponent(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().heartComponent(isConsoleSender, false));
|
||||
}
|
||||
return Component.space()
|
||||
.append(componentFactory.statUnitComponent(statName, null, selection));
|
||||
.append(componentFactory().statUnitComponent(statName, null, selection));
|
||||
}
|
||||
}
|
@ -9,6 +9,8 @@ import net.kyori.adventure.text.TextComponent;
|
||||
import net.kyori.adventure.text.format.TextColor;
|
||||
import net.kyori.adventure.text.minimessage.MiniMessage;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
import static net.kyori.adventure.text.Component.*;
|
||||
|
||||
public class PrideComponentFactory extends ComponentFactory {
|
||||
@ -16,8 +18,6 @@ public class PrideComponentFactory extends ComponentFactory {
|
||||
|
||||
public PrideComponentFactory(ConfigHandler c) {
|
||||
super(c);
|
||||
|
||||
MyLogger.logMsg("PrideComponentFactory created!", DebugLevel.MEDIUM);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -25,15 +25,21 @@ public class PrideComponentFactory extends ComponentFactory {
|
||||
PREFIX = PluginColor.GOLD.getColor();
|
||||
BRACKETS = PluginColor.GRAY.getColor();
|
||||
UNDERSCORE = PluginColor.DARK_PURPLE.getColor();
|
||||
MSG_MAIN = PluginColor.MEDIUM_GOLD.getColor();
|
||||
MSG_MAIN = PluginColor.GRAY.getColor(); //difference 1
|
||||
MSG_ACCENT = PluginColor.LIGHT_GOLD.getColor(); //difference 2
|
||||
MSG_MAIN_2 = PluginColor.GOLD.getColor();
|
||||
MSG_ACCENT = PluginColor.GOLD.getColor();
|
||||
MSG_ACCENT_2 = PluginColor.LIGHT_YELLOW.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();
|
||||
}
|
||||
|
||||
@Override
|
||||
public TextColor getExampleNameColor() {
|
||||
return getSharerNameColor();
|
||||
}
|
||||
|
||||
@Override
|
||||
public TextColor getSharerNameColor() {
|
||||
return PluginColor.getRandomNameColor();
|
||||
@ -49,6 +55,10 @@ public class PrideComponentFactory extends ComponentFactory {
|
||||
|
||||
@Override
|
||||
public TextComponent pluginPrefixComponent() {
|
||||
Random randomizer = new Random();
|
||||
if (randomizer.nextBoolean()) {
|
||||
return backwardsPluginPrefixComponent();
|
||||
}
|
||||
return text()
|
||||
.append(MiniMessage.miniMessage()
|
||||
.deserialize("<#f74040>[</#f74040>" +
|
||||
@ -67,7 +77,7 @@ public class PrideComponentFactory extends ComponentFactory {
|
||||
.build();
|
||||
}
|
||||
|
||||
public TextComponent backwardsPluginPrefixComponents() {
|
||||
public TextComponent backwardsPluginPrefixComponent() {
|
||||
return text()
|
||||
.append(MiniMessage.miniMessage()
|
||||
.deserialize("<#631ae6>[</#631ae6>" +
|
||||
|
@ -33,20 +33,20 @@ public class ExampleMessage implements TextComponent {
|
||||
.append(Component.newline())
|
||||
.append(text(arrow).color(componentFactory.msgMain2())
|
||||
.append(text("/statistic ")
|
||||
.append(text("animals_bred ").color(componentFactory.msgAccent())
|
||||
.append(text("top").color(componentFactory.msgAccent2())))))
|
||||
.append(text("animals_bred ").color(componentFactory.msgAccent2A())
|
||||
.append(text("top").color(componentFactory.msgAccent2B())))))
|
||||
.append(Component.newline())
|
||||
.append(text(arrow).color(componentFactory.msgMain2())
|
||||
.append(text("/statistic ")
|
||||
.append(text("mine_block diorite ").color(componentFactory.msgAccent())
|
||||
.append(text("me").color(componentFactory.msgAccent2())))))
|
||||
.append(text("mine_block diorite ").color(componentFactory.msgAccent2A())
|
||||
.append(text("me").color(componentFactory.msgAccent2B())))))
|
||||
.append(Component.newline())
|
||||
.append(text(arrow).color(componentFactory.msgMain2())
|
||||
.append(text("/statistic ")
|
||||
.append(text("deaths ").color(componentFactory.msgAccent())
|
||||
.append(text("player ").color(componentFactory.msgAccent2())
|
||||
.append(text("deaths ").color(componentFactory.msgAccent2A())
|
||||
.append(text("player ").color(componentFactory.msgAccent2B())
|
||||
.append(text("Artemis_the_gr8")
|
||||
.color(componentFactory.getSharerNameColor()))))));
|
||||
.color(componentFactory.getExampleNameColor()))))));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -61,19 +61,19 @@ public class HelpMessage implements TextComponent {
|
||||
.append(text("me | player | server | top").color(componentFactory.hoverAccent()))
|
||||
.append(newline())
|
||||
.append(spaces).append(spaces).append(bullet).append(space())
|
||||
.append(text("me:").color(componentFactory.msgAccent())).append(space())
|
||||
.append(text("me:").color(componentFactory.msgAccent2A())).append(space())
|
||||
.append(text("your own statistic").color(componentFactory.brackets()))
|
||||
.append(newline())
|
||||
.append(spaces).append(spaces).append(bullet).append(space())
|
||||
.append(text("player:").color(componentFactory.msgAccent())).append(space())
|
||||
.append(text("player:").color(componentFactory.msgAccent2A())).append(space())
|
||||
.append(text("choose a player").color(componentFactory.brackets()))
|
||||
.append(newline())
|
||||
.append(spaces).append(spaces).append(bullet).append(space())
|
||||
.append(text("server:").color(componentFactory.msgAccent())).append(space())
|
||||
.append(text("server:").color(componentFactory.msgAccent2A())).append(space())
|
||||
.append(text("everyone on the server combined").color(componentFactory.brackets()))
|
||||
.append(newline())
|
||||
.append(spaces).append(spaces).append(bullet).append(space())
|
||||
.append(text("top:").color(componentFactory.msgAccent())).append(space())
|
||||
.append(text("top:").color(componentFactory.msgAccent2A())).append(space())
|
||||
.append(text("the top").color(componentFactory.brackets()).append(space()).append(text(listSize)))
|
||||
.append(newline())
|
||||
.append(spaces).append(arrow).append(space())
|
||||
|
@ -48,7 +48,7 @@ enable-hover-text: true
|
||||
# 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
|
||||
# Always use the rainbow theme
|
||||
rainbow-mode: false
|
||||
|
||||
# Start the below stat-results with an empty line in chat before the result
|
||||
@ -132,7 +132,7 @@ shared-stats:
|
||||
shared-by-style: italic
|
||||
|
||||
player-name: "#EE8A19"
|
||||
player-name-style: none
|
||||
player-name-style: italic
|
||||
|
||||
|
||||
top-list:
|
||||
|
Loading…
Reference in New Issue
Block a user