mirror of
https://github.com/itHotL/PlayerStats.git
synced 2025-01-09 19:47:43 +01:00
Finished rewrite of MessageWriter and ComponentFactory
This commit is contained in:
parent
97b653a67a
commit
b2bc509933
@ -7,7 +7,7 @@ import com.gmail.artemis.the.gr8.playerstats.config.ConfigHandler;
|
|||||||
import com.gmail.artemis.the.gr8.playerstats.listeners.JoinListener;
|
import com.gmail.artemis.the.gr8.playerstats.listeners.JoinListener;
|
||||||
import com.gmail.artemis.the.gr8.playerstats.msg.LanguageKeyHandler;
|
import com.gmail.artemis.the.gr8.playerstats.msg.LanguageKeyHandler;
|
||||||
import com.gmail.artemis.the.gr8.playerstats.msg.MessageWriter;
|
import com.gmail.artemis.the.gr8.playerstats.msg.MessageWriter;
|
||||||
import com.gmail.artemis.the.gr8.playerstats.msg.PrideMessageFactory;
|
import com.gmail.artemis.the.gr8.playerstats.msg.PrideComponentFactory;
|
||||||
import net.kyori.adventure.platform.bukkit.BukkitAudiences;
|
import net.kyori.adventure.platform.bukkit.BukkitAudiences;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.command.PluginCommand;
|
import org.bukkit.command.PluginCommand;
|
||||||
@ -35,8 +35,8 @@ public class Main extends JavaPlugin {
|
|||||||
ConfigHandler config = new ConfigHandler(this);
|
ConfigHandler config = new ConfigHandler(this);
|
||||||
LanguageKeyHandler language = new LanguageKeyHandler();
|
LanguageKeyHandler language = new LanguageKeyHandler();
|
||||||
|
|
||||||
//for now always use the PrideMessageFactory (it'll use the regular formatting when needed)
|
//for now always use the PrideComponentFactory (it'll use the regular formatting when needed)
|
||||||
MessageWriter messageWriter = new PrideMessageFactory(config, language);
|
MessageWriter messageWriter = new MessageWriter(config, language);
|
||||||
|
|
||||||
//initialize the threadManager
|
//initialize the threadManager
|
||||||
ThreadManager threadManager = new ThreadManager(adventure(), config, messageWriter, this);
|
ThreadManager threadManager = new ThreadManager(adventure(), config, messageWriter, this);
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
package com.gmail.artemis.the.gr8.playerstats.commands;
|
package com.gmail.artemis.the.gr8.playerstats.commands;
|
||||||
|
|
||||||
import com.gmail.artemis.the.gr8.playerstats.ThreadManager;
|
import com.gmail.artemis.the.gr8.playerstats.ThreadManager;
|
||||||
|
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.Target;
|
||||||
import com.gmail.artemis.the.gr8.playerstats.utils.EnumHandler;
|
import com.gmail.artemis.the.gr8.playerstats.utils.EnumHandler;
|
||||||
import com.gmail.artemis.the.gr8.playerstats.statistic.StatRequest;
|
import com.gmail.artemis.the.gr8.playerstats.statistic.StatRequest;
|
||||||
@ -8,6 +9,7 @@ import com.gmail.artemis.the.gr8.playerstats.utils.OfflinePlayerHandler;
|
|||||||
import com.gmail.artemis.the.gr8.playerstats.msg.MessageWriter;
|
import com.gmail.artemis.the.gr8.playerstats.msg.MessageWriter;
|
||||||
import net.kyori.adventure.platform.bukkit.BukkitAudiences;
|
import net.kyori.adventure.platform.bukkit.BukkitAudiences;
|
||||||
import net.kyori.adventure.text.TextComponent;
|
import net.kyori.adventure.text.TextComponent;
|
||||||
|
import net.kyori.adventure.text.format.TextColor;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.Statistic;
|
import org.bukkit.Statistic;
|
||||||
import org.bukkit.command.Command;
|
import org.bukkit.command.Command;
|
||||||
@ -19,6 +21,8 @@ import org.bukkit.entity.Player;
|
|||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
|
import static net.kyori.adventure.text.Component.text;
|
||||||
|
|
||||||
|
|
||||||
public class StatCommand implements CommandExecutor {
|
public class StatCommand implements CommandExecutor {
|
||||||
|
|
||||||
@ -41,6 +45,16 @@ public class StatCommand implements CommandExecutor {
|
|||||||
args[0].equalsIgnoreCase("example")) { //in case of "statistic examples", show examples
|
args[0].equalsIgnoreCase("example")) { //in case of "statistic examples", show examples
|
||||||
adventure.sender(sender).sendMessage(messageWriter.usageExamples(sender instanceof ConsoleCommandSender));
|
adventure.sender(sender).sendMessage(messageWriter.usageExamples(sender instanceof ConsoleCommandSender));
|
||||||
}
|
}
|
||||||
|
else if (args[0].equalsIgnoreCase("test")) {
|
||||||
|
TextComponent msg = text("Tier 1").color(PluginColor.GOLD.getColor())
|
||||||
|
.append(text("Tier 2").color(PluginColor.MEDIUM_GOLD.getColor())
|
||||||
|
.append(text("Tier 3").color(TextColor.fromHexString("#FFEA40"))
|
||||||
|
.append(text("Tier 4").color(PluginColor.YELLOW.getColor()))
|
||||||
|
.append(text("Tier 3?")))
|
||||||
|
.append(text("Tier 2?")))
|
||||||
|
.append(text("Tier 1?"));
|
||||||
|
adventure.sender(sender).sendMessage(msg);
|
||||||
|
}
|
||||||
else {
|
else {
|
||||||
StatRequest request = generateRequest(sender, args);
|
StatRequest request = generateRequest(sender, args);
|
||||||
TextComponent issues = checkRequest(request);
|
TextComponent issues = checkRequest(request);
|
||||||
|
@ -23,7 +23,7 @@ public class ConfigHandler {
|
|||||||
saveDefaultConfig();
|
saveDefaultConfig();
|
||||||
config = YamlConfiguration.loadConfiguration(configFile);
|
config = YamlConfiguration.loadConfiguration(configFile);
|
||||||
|
|
||||||
configVersion = 4;
|
configVersion = 4.1;
|
||||||
checkConfigVersion();
|
checkConfigVersion();
|
||||||
|
|
||||||
MyLogger.setDebugLevel(debugLevel());
|
MyLogger.setDebugLevel(debugLevel());
|
||||||
|
@ -34,11 +34,14 @@ public class ConfigUpdateHandler {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Adjusts some of the default colors to migrate from versions 2 or 3 to version 4.*/
|
/** Adjusts some of the default colors to migrate from versions 2 or 3 to version 4.1.*/
|
||||||
private void updateDefaultColors(YamlConfiguration configuration) {
|
private void updateDefaultColors(YamlConfiguration configuration) {
|
||||||
updateColor(configuration, "top-list.title", "yellow", "#FFD52B");
|
updateColor(configuration, "top-list.title", "yellow", "#FFEA40");
|
||||||
updateColor(configuration, "top-list.stat-names", "yellow", "#FFD52B");
|
updateColor(configuration, "top-list-title", "#FFD52B", "#FFEA40");
|
||||||
|
updateColor(configuration, "top-list.stat-names", "yellow", "#FFEA40");
|
||||||
|
updateColor(configuration, "top-list-stat-names", "#FFD52B", "#FFEA40");
|
||||||
updateColor(configuration, "top-list.sub-stat-names", "#FFD52B", "yellow");
|
updateColor(configuration, "top-list.sub-stat-names", "#FFD52B", "yellow");
|
||||||
|
|
||||||
updateColor(configuration, "individual-statistics.stat-names", "yellow", "#FFD52B");
|
updateColor(configuration, "individual-statistics.stat-names", "yellow", "#FFD52B");
|
||||||
updateColor(configuration, "individual-statistics.sub-stat-names", "#FFD52B", "yellow");
|
updateColor(configuration, "individual-statistics.sub-stat-names", "#FFD52B", "yellow");
|
||||||
updateColor(configuration, "total-server.title", "gold", "#55AAFF");
|
updateColor(configuration, "total-server.title", "gold", "#55AAFF");
|
||||||
|
@ -8,19 +8,21 @@ import net.kyori.adventure.text.format.TextColor;
|
|||||||
<p>DARK_PURPLE: #6E3485 (used for default sub-titles, title-underscores and brackets)</p>
|
<p>DARK_PURPLE: #6E3485 (used for default sub-titles, title-underscores and brackets)</p>
|
||||||
<p>MEDIUM_BLUE: #55AAFF (used for all plain feedback and error messages)</p>
|
<p>MEDIUM_BLUE: #55AAFF (used for all plain feedback and error messages)</p>
|
||||||
<p>LIGHT_BLUE: #55C6FF (used for default hover-text)</p>
|
<p>LIGHT_BLUE: #55C6FF (used for default hover-text)</p>
|
||||||
<p>DARK_GOLD: ChatColor Gold (used for first parts of usage messages and for first parts of hover-text accent)</p>
|
<p>GOLD: ChatColor Gold (used for first parts of usage messages and for first parts of hover-text accent)</p>
|
||||||
<p>MEDIUM_GOLD: #FFB80E (used for second parts of usage messages and for second parts of hover-text accent) </p>
|
<p>LIGHT_GOLD: #FFB80E (used for second parts of usage messages and for second parts of hover-text accent) </p>
|
||||||
<p>YELLOW: ChatColor Yellow (used for third parts of usage messages)</p>
|
<p>YELLOW: ChatColor Yellow (used for third parts of usage messages)</p>
|
||||||
*/
|
*/
|
||||||
public enum PluginColor {
|
public enum PluginColor {
|
||||||
GRAY (NamedTextColor.GRAY),
|
GRAY (NamedTextColor.GRAY),
|
||||||
DARK_PURPLE (TextColor.fromHexString("#6E3485")),
|
DARK_PURPLE (TextColor.fromHexString("#6E3485")),
|
||||||
MEDIUM_BLUE(TextColor.fromHexString("#55AAFF")),
|
MEDIUM_BLUE (TextColor.fromHexString("#55AAFF")),
|
||||||
LIGHT_BLUE (TextColor.fromHexString("#55C6FF")),
|
LIGHT_BLUE (TextColor.fromHexString("#55C6FF")),
|
||||||
DARK_GOLD (NamedTextColor.GOLD),
|
GOLD (NamedTextColor.GOLD),
|
||||||
MEDIUM_GOLD (TextColor.fromHexString("#FFD52B")),
|
MEDIUM_GOLD (TextColor.fromHexString("#FFD52B")),
|
||||||
YELLOW (NamedTextColor.YELLOW);
|
YELLOW (NamedTextColor.YELLOW),
|
||||||
|
LIGHT_YELLOW (TextColor.fromHexString("#FFFF8E"));
|
||||||
|
|
||||||
|
//TODO try "#55AAFF" for LIGHT_BLUE
|
||||||
private final TextColor color;
|
private final TextColor color;
|
||||||
|
|
||||||
PluginColor(TextColor color) {
|
PluginColor(TextColor color) {
|
||||||
@ -30,4 +32,8 @@ public enum PluginColor {
|
|||||||
public TextColor getColor() {
|
public TextColor getColor() {
|
||||||
return color;
|
return color;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public TextColor getConsoleColor() {
|
||||||
|
return NamedTextColor.nearestTo(color);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -35,7 +35,7 @@ public class ComponentFactory {
|
|||||||
public TextComponent pluginPrefix(boolean isConsoleSender) {
|
public TextComponent pluginPrefix(boolean isConsoleSender) {
|
||||||
return text("[")
|
return text("[")
|
||||||
.color(PluginColor.GRAY.getColor())
|
.color(PluginColor.GRAY.getColor())
|
||||||
.append(text("PlayerStats").color(PluginColor.DARK_GOLD.getColor()))
|
.append(text("PlayerStats").color(PluginColor.GOLD.getColor()))
|
||||||
.append(text("]"))
|
.append(text("]"))
|
||||||
.append(space());
|
.append(space());
|
||||||
}
|
}
|
||||||
@ -79,7 +79,7 @@ public class ComponentFactory {
|
|||||||
TextComponent.Builder msg = Component.text();
|
TextComponent.Builder msg = Component.text();
|
||||||
if (part1 != null) {
|
if (part1 != null) {
|
||||||
msg.append(text(part1)
|
msg.append(text(part1)
|
||||||
.color(PluginColor.DARK_GOLD.getColor()));
|
.color(PluginColor.GOLD.getColor()));
|
||||||
if (part2 != null || part3 != null || part4 != null) {
|
if (part2 != null || part3 != null || part4 != null) {
|
||||||
msg.append(space());
|
msg.append(space());
|
||||||
}
|
}
|
||||||
@ -105,6 +105,22 @@ public class ComponentFactory {
|
|||||||
return msg.build();
|
return msg.build();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public TextComponent simpleHoverPart(String plainText, String hoverText, PluginColor hoverColor) {
|
||||||
|
return simpleHoverPart(plainText, null, hoverText, hoverColor);
|
||||||
|
}
|
||||||
|
|
||||||
|
public TextComponent simpleHoverPart(String plainText, @Nullable PluginColor plainColor, String hoverText, PluginColor hoverColor) {
|
||||||
|
TextComponent.Builder msg = Component.text()
|
||||||
|
.append(text(plainText))
|
||||||
|
.hoverEvent(HoverEvent.showText(
|
||||||
|
text(hoverText)
|
||||||
|
.color(hoverColor.getColor())));
|
||||||
|
if (plainColor != null) {
|
||||||
|
msg.color(plainColor.getColor());
|
||||||
|
}
|
||||||
|
return msg.build();
|
||||||
|
}
|
||||||
|
|
||||||
/** Returns a TextComponent with hover-text that can consist of three different parts,
|
/** Returns a TextComponent with hover-text that can consist of three different parts,
|
||||||
divided over two different lines. Each part has its own designated color. If all the
|
divided over two different lines. Each part has its own designated color. If all the
|
||||||
input Strings are null, it will return an empty Component.
|
input Strings are null, it will return an empty Component.
|
||||||
@ -114,7 +130,7 @@ public class ComponentFactory {
|
|||||||
@param hoverLineTwoA text on the second line, with color DARK_GOLD
|
@param hoverLineTwoA text on the second line, with color DARK_GOLD
|
||||||
@param hoverLineTwoB text on the second part of the second line, with color MEDIUM_GOLD
|
@param hoverLineTwoB text on the second part of the second line, with color MEDIUM_GOLD
|
||||||
*/
|
*/
|
||||||
public TextComponent hoverMsgPart(@NotNull String plainText, @NotNull PluginColor color, @Nullable String hoverLineOne, @Nullable String hoverLineTwoA, @Nullable String hoverLineTwoB) {
|
public TextComponent complexHoverPart(@NotNull String plainText, @NotNull PluginColor color, @Nullable String hoverLineOne, @Nullable String hoverLineTwoA, @Nullable String hoverLineTwoB) {
|
||||||
TextComponent base = Component.text(plainText).color(color.getColor());
|
TextComponent base = Component.text(plainText).color(color.getColor());
|
||||||
TextComponent.Builder hoverText = Component.text();
|
TextComponent.Builder hoverText = Component.text();
|
||||||
if (hoverLineOne != null) {
|
if (hoverLineOne != null) {
|
||||||
@ -126,7 +142,7 @@ public class ComponentFactory {
|
|||||||
}
|
}
|
||||||
if (hoverLineTwoA != null) {
|
if (hoverLineTwoA != null) {
|
||||||
hoverText.append(text(hoverLineTwoA)
|
hoverText.append(text(hoverLineTwoA)
|
||||||
.color(PluginColor.DARK_GOLD.getColor()));
|
.color(PluginColor.GOLD.getColor()));
|
||||||
if (hoverLineTwoB != null) {
|
if (hoverLineTwoB != null) {
|
||||||
hoverText.append(space());
|
hoverText.append(space());
|
||||||
}
|
}
|
||||||
|
@ -7,7 +7,6 @@ import com.gmail.artemis.the.gr8.playerstats.statistic.StatRequest;
|
|||||||
import net.kyori.adventure.text.Component;
|
import net.kyori.adventure.text.Component;
|
||||||
import net.kyori.adventure.text.TextComponent;
|
import net.kyori.adventure.text.TextComponent;
|
||||||
import net.kyori.adventure.text.event.HoverEvent;
|
import net.kyori.adventure.text.event.HoverEvent;
|
||||||
import net.kyori.adventure.text.format.NamedTextColor;
|
|
||||||
import net.kyori.adventure.text.format.TextColor;
|
import net.kyori.adventure.text.format.TextColor;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.Statistic;
|
import org.bukkit.Statistic;
|
||||||
@ -26,17 +25,9 @@ public class MessageWriter {
|
|||||||
private static ConfigHandler config;
|
private static ConfigHandler config;
|
||||||
private static ComponentFactory componentFactory;
|
private static ComponentFactory componentFactory;
|
||||||
|
|
||||||
private final TextColor hoverBaseColor; //light blue - one shade lighter than msgColor
|
|
||||||
private final TextColor accentColor1; //gold - one shade lighter than standard gold
|
|
||||||
private final TextColor accentColor2; //yellow - a few shades darker than standard yellow
|
|
||||||
|
|
||||||
public MessageWriter(ConfigHandler c, LanguageKeyHandler l) {
|
public MessageWriter(ConfigHandler c, LanguageKeyHandler l) {
|
||||||
config = c;
|
config = c;
|
||||||
componentFactory = new ComponentFactory(c, l);
|
componentFactory = new ComponentFactory(c, l);
|
||||||
|
|
||||||
hoverBaseColor = TextColor.fromHexString("#55C6FF");
|
|
||||||
accentColor1 = TextColor.fromHexString("#FFB80E");
|
|
||||||
accentColor2 = TextColor.fromHexString("#FFD52B");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public TextComponent reloadedConfig(boolean isConsoleSender) {
|
public TextComponent reloadedConfig(boolean isConsoleSender) {
|
||||||
@ -182,29 +173,33 @@ public class MessageWriter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public TextComponent usageExamples(boolean isConsoleSender) {
|
public TextComponent usageExamples(boolean isConsoleSender) {
|
||||||
TextComponent spaces = text(" "); //4 spaces
|
boolean isBukkitConsole = (isConsoleSender && Bukkit.getName().equalsIgnoreCase("CraftBukkit"));
|
||||||
TextComponent arrow = text("→ ").color(NamedTextColor.GOLD);
|
TextColor mainColor = isBukkitConsole ? PluginColor.GOLD.getConsoleColor() : PluginColor.GOLD.getColor();
|
||||||
TextColor accentColor = TextColor.fromHexString("#FFE339");
|
TextColor accentColor1 = isBukkitConsole ? PluginColor.MEDIUM_GOLD.getConsoleColor() : PluginColor.MEDIUM_GOLD.getColor();
|
||||||
|
TextColor accentColor3 = isBukkitConsole ? PluginColor.LIGHT_YELLOW.getConsoleColor() : PluginColor.LIGHT_YELLOW.getColor();
|
||||||
if (isConsoleSender && Bukkit.getName().equalsIgnoreCase("CraftBukkit")) {
|
String arrow = isBukkitConsole ? " -> " : " → "; //4 spaces, alt + 26, 1 space
|
||||||
arrow = text("-> ").color(NamedTextColor.GOLD);
|
|
||||||
accentColor = NamedTextColor.YELLOW;
|
|
||||||
}
|
|
||||||
|
|
||||||
return Component.newline()
|
return Component.newline()
|
||||||
.append(componentFactory.prefixTitle(isConsoleSender))
|
.append(componentFactory.prefixTitle(isConsoleSender))
|
||||||
.append(newline())
|
.append(newline())
|
||||||
.append(text("Examples: ").color(NamedTextColor.GOLD))
|
.append(text("Examples: ").color(mainColor)
|
||||||
.append(newline())
|
.append(newline())
|
||||||
.append(spaces).append(arrow)
|
.append(text(arrow))
|
||||||
.append(text("/statistic animals_bred top").color(accentColor))
|
.append(text("/statistic ").color(mainColor)
|
||||||
.append(newline())
|
.append(text("animals_bred ").color(accentColor1)
|
||||||
.append(spaces).append(arrow)
|
.append(text("top").color(accentColor3))))
|
||||||
.append(text("/statistic mine_block diorite me").color(accentColor))
|
.append(newline())
|
||||||
.append(newline())
|
.append(text(arrow))
|
||||||
.append(spaces).append(arrow)
|
.append(text("/statistic ").color(mainColor)
|
||||||
.append(text("/statistic deaths player Artemis_the_gr8").color(accentColor))
|
.append(text("mine_block diorite ").color(accentColor1)
|
||||||
.append(newline());
|
.append(text("me").color(accentColor3))))
|
||||||
|
.append(newline())
|
||||||
|
.append(text(arrow))
|
||||||
|
.append(text("/statistic ").color(mainColor)
|
||||||
|
.append(text("deaths ").color(accentColor1)
|
||||||
|
.append(text("player ").color(accentColor3)
|
||||||
|
.append(text("Artemis_the_gr8")))))
|
||||||
|
.append(newline()));
|
||||||
}
|
}
|
||||||
|
|
||||||
public TextComponent helpMsg(boolean isConsoleSender) {
|
public TextComponent helpMsg(boolean isConsoleSender) {
|
||||||
@ -219,7 +214,6 @@ public class MessageWriter {
|
|||||||
/** Returns the usage-explanation with hovering text */
|
/** Returns the usage-explanation with hovering text */
|
||||||
private TextComponent helpMsgHover() {
|
private TextComponent helpMsgHover() {
|
||||||
String arrow = " → "; //4 spaces, alt + 26, 1 space
|
String arrow = " → "; //4 spaces, alt + 26, 1 space
|
||||||
|
|
||||||
return Component.newline()
|
return Component.newline()
|
||||||
.append(componentFactory.prefixTitle(false))
|
.append(componentFactory.prefixTitle(false))
|
||||||
.append(newline())
|
.append(newline())
|
||||||
@ -228,47 +222,44 @@ public class MessageWriter {
|
|||||||
.append(componentFactory.msgPart("Usage:", null, "/statistic", null))
|
.append(componentFactory.msgPart("Usage:", null, "/statistic", null))
|
||||||
.append(newline())
|
.append(newline())
|
||||||
.append(componentFactory.msgPart(arrow, null, null, null)
|
.append(componentFactory.msgPart(arrow, null, null, null)
|
||||||
.append(componentFactory.hoverMsgPart("name", PluginColor.YELLOW,
|
.append(componentFactory.complexHoverPart("name", PluginColor.YELLOW,
|
||||||
"The name that describes the statistic",
|
"The name that describes the statistic",
|
||||||
"Example:",
|
"Example:",
|
||||||
"\"animals_bred\"")))
|
"\"animals_bred\"")))
|
||||||
.append(newline())
|
.append(newline())
|
||||||
.append(spaces).append(arrow)
|
.append(componentFactory.msgPart(arrow, null, null, null)
|
||||||
.append(text("sub-statistic").color(arguments)
|
.append(componentFactory.complexHoverPart("sub-statistic", PluginColor.YELLOW,
|
||||||
.hoverEvent(HoverEvent.showText(
|
"Some statistics need an item, block or entity as extra input",
|
||||||
text("Some statistics need an item, block or entity as extra input").color(hoverBaseColor)
|
"Example:",
|
||||||
.append(newline())
|
"\"mine_block diorite\"")))
|
||||||
.append(text("Example: ").color(accentColor1)
|
|
||||||
.append(text("\"mine_block diorite\"").color(accentColor2))))))
|
|
||||||
.append(newline())
|
.append(newline())
|
||||||
.append(spaces)
|
.append(text(" ").color(PluginColor.YELLOW.getColor())
|
||||||
.append(text("→").color(NamedTextColor.GOLD)
|
.append(componentFactory.simpleHoverPart(
|
||||||
.hoverEvent(HoverEvent.showText(
|
"→", PluginColor.GOLD,
|
||||||
text("Choose one").color(TextColor.fromHexString("#6E3485")))))
|
"Choose one", PluginColor.DARK_PURPLE))
|
||||||
.append(space())
|
.append(space())
|
||||||
.append(text("me").color(arguments)
|
.append(componentFactory.simpleHoverPart(
|
||||||
.hoverEvent(HoverEvent.showText(
|
"me",
|
||||||
text("See your own statistic").color(hoverBaseColor))))
|
"See your own statistic", PluginColor.LIGHT_BLUE))
|
||||||
.append(text(" | ").color(arguments))
|
.append(text(" | "))
|
||||||
.append(text("player").color(arguments)
|
.append(componentFactory.simpleHoverPart(
|
||||||
.hoverEvent(HoverEvent.showText(
|
"player",
|
||||||
text("Choose any player that has played on your server").color(hoverBaseColor))))
|
"Choose any player that has played on your server", PluginColor.LIGHT_BLUE))
|
||||||
.append(text(" | ").color(arguments))
|
.append(text(" | "))
|
||||||
.append(text("server").color(arguments)
|
.append(componentFactory.simpleHoverPart(
|
||||||
.hoverEvent(HoverEvent.showText(
|
"server",
|
||||||
text("See the combined total for everyone on your server").color(hoverBaseColor))))
|
"See the combined total for everyone on your server", PluginColor.LIGHT_BLUE))
|
||||||
.append(text(" | ").color(arguments))
|
.append(text(" | "))
|
||||||
.append(text("top").color(arguments)
|
.append(componentFactory.simpleHoverPart(
|
||||||
.hoverEvent(HoverEvent.showText(
|
"top",
|
||||||
text("See the top ").color(hoverBaseColor)
|
"See the top " + config.getTopListMaxSize(), PluginColor.LIGHT_BLUE)))
|
||||||
.append(text(config.getTopListMaxSize()).color(hoverBaseColor)))))
|
|
||||||
.append(newline())
|
.append(newline())
|
||||||
.append(spaces).append(arrow)
|
.append(componentFactory.msgPart(arrow, null, null, null)
|
||||||
.append(text("player-name").color(arguments)
|
.append(text("player-name").color(PluginColor.YELLOW.getColor())
|
||||||
.hoverEvent(HoverEvent.showText(
|
.hoverEvent(HoverEvent.showText(
|
||||||
text("In case you typed ").color(hoverBaseColor)
|
text("In case you typed ").color(PluginColor.LIGHT_BLUE.getColor())
|
||||||
.append(text("\"player\"").color(accentColor2)
|
.append(text("\"player\"").color(PluginColor.MEDIUM_GOLD.getColor()))
|
||||||
.append(text(", add the player's name").color(hoverBaseColor))))));
|
.append(text(", add the player's name"))))));
|
||||||
}
|
}
|
||||||
|
|
||||||
//TODO create ConsoleComponentFactory for Bukkit
|
//TODO create ConsoleComponentFactory for Bukkit
|
||||||
@ -276,12 +267,10 @@ public class MessageWriter {
|
|||||||
/** Returns the usage-explanation without any hovering text.
|
/** Returns the usage-explanation without any hovering text.
|
||||||
If BukkitVersion is CraftBukkit, this doesn't use unicode symbols or hex colors */
|
If BukkitVersion is CraftBukkit, this doesn't use unicode symbols or hex colors */
|
||||||
private TextComponent helpMsgPlain(boolean isConsoleSender) {
|
private TextComponent helpMsgPlain(boolean isConsoleSender) {
|
||||||
String arrow = " →"; //4 spaces, alt + 26
|
boolean isBukkitConsole = (isConsoleSender && Bukkit.getName().equalsIgnoreCase("CraftBukkit"));
|
||||||
String bullet = " •"; //8 spaces, alt + 7
|
String arrow = isBukkitConsole ? " ->" : " →"; //4 spaces, alt + 26
|
||||||
if (isConsoleSender && Bukkit.getName().equalsIgnoreCase("CraftBukkit")) {
|
String bullet = isBukkitConsole ? " *" : " •"; //8 spaces, alt + 7
|
||||||
arrow = " ->";
|
|
||||||
bullet = " *";
|
|
||||||
}
|
|
||||||
return Component.newline()
|
return Component.newline()
|
||||||
.append(componentFactory.prefixTitle(isConsoleSender))
|
.append(componentFactory.prefixTitle(isConsoleSender))
|
||||||
.append(newline())
|
.append(newline())
|
||||||
@ -303,6 +292,6 @@ public class MessageWriter {
|
|||||||
.append(newline())
|
.append(newline())
|
||||||
.append(componentFactory.msgPart(bullet, "top:", null, "the top " + config.getTopListMaxSize()))
|
.append(componentFactory.msgPart(bullet, "top:", null, "the top " + config.getTopListMaxSize()))
|
||||||
.append(newline())
|
.append(newline())
|
||||||
.append(componentFactory.msgPart(arrow, null, "{player-name", null));
|
.append(componentFactory.msgPart(arrow, null, "{player-name}", null));
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -12,20 +12,20 @@ import java.time.Month;
|
|||||||
import static net.kyori.adventure.text.Component.*;
|
import static net.kyori.adventure.text.Component.*;
|
||||||
|
|
||||||
|
|
||||||
public class PrideMessageFactory extends MessageWriter {
|
public class PrideComponentFactory extends ComponentFactory {
|
||||||
|
|
||||||
private static ConfigHandler config;
|
private static ConfigHandler config;
|
||||||
|
|
||||||
public PrideMessageFactory(ConfigHandler c, LanguageKeyHandler l) {
|
public PrideComponentFactory(ConfigHandler c, LanguageKeyHandler l) {
|
||||||
super(c, l);
|
super(c, l);
|
||||||
config = c;
|
config = c;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected TextComponent getPrefixAsTitle(boolean isConsoleSender) {
|
public TextComponent prefixTitle(boolean isConsoleSender) {
|
||||||
if (cancelRainbow(isConsoleSender)) {
|
if (cancelRainbow(isConsoleSender)) {
|
||||||
return super.getPrefixAsTitle(isConsoleSender);
|
return super.prefixTitle(isConsoleSender);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
String title = "<rainbow:16>____________ [PlayerStats] ____________</rainbow>"; //12 underscores
|
String title = "<rainbow:16>____________ [PlayerStats] ____________</rainbow>"; //12 underscores
|
||||||
@ -36,7 +36,7 @@ public class PrideMessageFactory extends MessageWriter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected TextComponent pluginPrefix(boolean isConsoleSender) {
|
public TextComponent pluginPrefix(boolean isConsoleSender) {
|
||||||
if (cancelRainbow(isConsoleSender)) {
|
if (cancelRainbow(isConsoleSender)) {
|
||||||
return super.pluginPrefix(isConsoleSender);
|
return super.pluginPrefix(isConsoleSender);
|
||||||
}
|
}
|
@ -74,13 +74,13 @@ your-server-name: 'this server'
|
|||||||
# # ------------------------------ # #
|
# # ------------------------------ # #
|
||||||
|
|
||||||
top-list:
|
top-list:
|
||||||
title: '#FFD52B'
|
title: '#FFEA40'
|
||||||
title-style: none
|
title-style: none
|
||||||
|
|
||||||
title-number: gold
|
title-number: gold
|
||||||
title-number-style: none
|
title-number-style: none
|
||||||
|
|
||||||
stat-names: '#FFD52B'
|
stat-names: '#FFEA40'
|
||||||
stat-names-style: none
|
stat-names-style: none
|
||||||
|
|
||||||
sub-stat-names: yellow
|
sub-stat-names: yellow
|
||||||
|
Loading…
Reference in New Issue
Block a user