Wrote exclude info message and added more rainbow easter eggs
This commit is contained in:
parent
c7a6160cc8
commit
d5c1c44841
|
@ -22,14 +22,20 @@ public final class ExcludeCommand implements CommandExecutor {
|
|||
|
||||
@Override
|
||||
public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, @NotNull String[] args) {
|
||||
if (args.length == 1 && args[0].equalsIgnoreCase("list")) {
|
||||
ArrayList<String> excludedPlayers = offlinePlayerHandler.getExcludedPlayerNames();
|
||||
sender.sendMessage(String.valueOf(excludedPlayers));
|
||||
return true;
|
||||
if (args.length == 1) {
|
||||
switch (args[0]) {
|
||||
case "list" -> {
|
||||
ArrayList<String> excludedPlayers = offlinePlayerHandler.getExcludedPlayerNames();
|
||||
sender.sendMessage(String.valueOf(excludedPlayers));
|
||||
return true;
|
||||
}
|
||||
case "info" -> {
|
||||
outputManager.sendExcludeInfo(sender);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
//this is going to return false for all UUIDs in file at boot-up - that's an issue
|
||||
else if (args.length >= 2) {
|
||||
|
||||
String playerName = args[1];
|
||||
switch (args[0]) {
|
||||
case "add" -> {
|
||||
|
@ -46,10 +52,6 @@ public final class ExcludeCommand implements CommandExecutor {
|
|||
return true;
|
||||
}
|
||||
}
|
||||
case "info" -> {
|
||||
outputManager.sendExcludeInfo(sender);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
|
|
|
@ -29,20 +29,15 @@ public enum PluginColor {
|
|||
LIGHT_PURPLE (TextColor.fromHexString("#845EC2")),
|
||||
|
||||
/**
|
||||
* ChatColor Blue (#5555FF)
|
||||
*/
|
||||
BLUE (NamedTextColor.BLUE),
|
||||
|
||||
/**
|
||||
* A Medium Blue that is used for default feedback and error messages (#55AAFF).
|
||||
*/
|
||||
MEDIUM_BLUE (TextColor.fromHexString("#55AAFF")),
|
||||
|
||||
/**
|
||||
* A Light Blue that is used for hover-messages and the share-button (#55C6FF).
|
||||
* A Light Blue that is used for the share-button and feedback message accents (#55C6FF).
|
||||
*/
|
||||
LIGHT_BLUE (TextColor.fromHexString("#55C6FF")),
|
||||
|
||||
/**
|
||||
* A very light blue that is used for feedback messages and hover-text (#ADE7FF)
|
||||
*/
|
||||
LIGHTEST_BLUE(TextColor.fromHexString("#ADE7FF")),
|
||||
|
||||
/**
|
||||
* ChatColor Gold (#FFAA00)
|
||||
*/
|
||||
|
|
|
@ -1,11 +1,7 @@
|
|||
package com.artemis.the.gr8.playerstats.msg;
|
||||
|
||||
import com.artemis.the.gr8.playerstats.api.StatFormatter;
|
||||
import com.artemis.the.gr8.playerstats.msg.components.ComponentFactory;
|
||||
import com.artemis.the.gr8.playerstats.msg.components.ExampleMessage;
|
||||
import com.artemis.the.gr8.playerstats.msg.components.HelpMessage;
|
||||
import com.artemis.the.gr8.playerstats.msg.components.BukkitConsoleComponentFactory;
|
||||
import com.artemis.the.gr8.playerstats.msg.components.PrideComponentFactory;
|
||||
import com.artemis.the.gr8.playerstats.msg.components.*;
|
||||
import com.artemis.the.gr8.playerstats.msg.msgutils.*;
|
||||
import com.artemis.the.gr8.playerstats.statistic.StatRequest;
|
||||
import com.artemis.the.gr8.playerstats.utils.EnumHandler;
|
||||
|
@ -202,13 +198,7 @@ public final class MessageBuilder implements StatFormatter {
|
|||
}
|
||||
|
||||
public @NotNull TextComponent excludeInfoMsg() {
|
||||
return getPluginPrefixAsTitle()
|
||||
.append(newline())
|
||||
.append(componentFactory.subTitle("The /statexclude command " +
|
||||
"can be used to exclude individual players from /statistic lookups.")
|
||||
.append(newline())
|
||||
.append(text("This means their results won't show up in top-10 results, " +
|
||||
"and they won't be counted for the server total.")));
|
||||
return ExcludeInfoMessage.construct(componentFactory);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -29,14 +29,14 @@ public class BukkitConsoleComponentFactory extends ComponentFactory {
|
|||
UNDERSCORE = PluginColor.DARK_PURPLE.getConsoleColor();
|
||||
HEARTS = PluginColor.RED.getConsoleColor();
|
||||
|
||||
MSG_MAIN = PluginColor.MEDIUM_BLUE.getConsoleColor();
|
||||
MSG_ACCENT = PluginColor.BLUE.getConsoleColor();
|
||||
FEEDBACK_MSG = PluginColor.LIGHTEST_BLUE.getConsoleColor();
|
||||
FEEDBACK_MSG_ACCENT = PluginColor.LIGHT_BLUE.getConsoleColor();
|
||||
|
||||
MSG_MAIN_2 = PluginColor.GOLD.getConsoleColor();
|
||||
MSG_ACCENT_2A = PluginColor.MEDIUM_GOLD.getConsoleColor();
|
||||
MSG_ACCENT_2B = PluginColor.LIGHT_YELLOW.getConsoleColor();
|
||||
INFO_MSG = PluginColor.GOLD.getConsoleColor();
|
||||
INFO_MSG_ACCENT_1 = PluginColor.MEDIUM_GOLD.getConsoleColor();
|
||||
INFO_MSG_ACCENT_2 = PluginColor.LIGHT_YELLOW.getConsoleColor();
|
||||
|
||||
MSG_HOVER = PluginColor.LIGHT_BLUE.getConsoleColor();
|
||||
MSG_HOVER = PluginColor.LIGHTEST_BLUE.getConsoleColor();
|
||||
MSG_CLICKED = PluginColor.LIGHT_PURPLE.getConsoleColor();
|
||||
MSG_HOVER_ACCENT = PluginColor.LIGHT_GOLD.getConsoleColor();
|
||||
}
|
||||
|
|
|
@ -40,16 +40,16 @@ public class ComponentFactory {
|
|||
protected TextColor UNDERSCORE; //dark_purple
|
||||
protected TextColor HEARTS; //red
|
||||
|
||||
protected TextColor MSG_MAIN; //medium_blue
|
||||
protected TextColor MSG_ACCENT; //blue
|
||||
protected TextColor FEEDBACK_MSG; //lightest_blue
|
||||
protected TextColor FEEDBACK_MSG_ACCENT; //light_blue
|
||||
|
||||
protected TextColor MSG_MAIN_2; //gold
|
||||
protected TextColor MSG_ACCENT_2A; //medium_gold
|
||||
protected TextColor MSG_ACCENT_2B; //light_yellow
|
||||
protected TextColor INFO_MSG; //gold
|
||||
protected TextColor INFO_MSG_ACCENT_1; //medium_gold
|
||||
protected TextColor INFO_MSG_ACCENT_2; //light_yellow
|
||||
|
||||
protected TextColor MSG_HOVER; //light_blue
|
||||
protected TextColor MSG_CLICKED; //light_purple
|
||||
protected TextColor MSG_HOVER; //lightest_blue
|
||||
protected TextColor MSG_HOVER_ACCENT; //light_gold
|
||||
protected TextColor MSG_CLICKED; //light_purple
|
||||
|
||||
|
||||
public ComponentFactory(ConfigHandler c) {
|
||||
|
@ -63,20 +63,20 @@ public class ComponentFactory {
|
|||
UNDERSCORE = PluginColor.DARK_PURPLE.getColor();
|
||||
HEARTS = PluginColor.RED.getColor();
|
||||
|
||||
MSG_MAIN = PluginColor.MEDIUM_BLUE.getColor();
|
||||
MSG_ACCENT = PluginColor.BLUE.getColor();
|
||||
FEEDBACK_MSG = PluginColor.LIGHTEST_BLUE.getColor();
|
||||
FEEDBACK_MSG_ACCENT = PluginColor.LIGHT_BLUE.getColor();
|
||||
|
||||
MSG_MAIN_2 = PluginColor.GOLD.getColor();
|
||||
MSG_ACCENT_2A = PluginColor.MEDIUM_GOLD.getColor();
|
||||
MSG_ACCENT_2B = PluginColor.LIGHT_YELLOW.getColor();
|
||||
INFO_MSG = PluginColor.GOLD.getColor();
|
||||
INFO_MSG_ACCENT_1 = PluginColor.MEDIUM_GOLD.getColor();
|
||||
INFO_MSG_ACCENT_2 = PluginColor.LIGHT_YELLOW.getColor();
|
||||
|
||||
MSG_HOVER = PluginColor.LIGHT_BLUE.getColor();
|
||||
MSG_HOVER = PluginColor.LIGHTEST_BLUE.getColor();
|
||||
MSG_HOVER_ACCENT = PluginColor.LIGHT_GOLD.getColor();
|
||||
MSG_CLICKED = PluginColor.LIGHT_PURPLE.getColor();
|
||||
}
|
||||
|
||||
public TextColor getExampleNameColor() {
|
||||
return MSG_ACCENT_2B;
|
||||
public TextComponent getExampleName() {
|
||||
return text("Artemis_the_gr8").color(INFO_MSG_ACCENT_2);
|
||||
}
|
||||
|
||||
public TextColor getSharerNameColor() {
|
||||
|
@ -105,19 +105,11 @@ public class ComponentFactory {
|
|||
.append(text("____________"));
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a TextComponent with the input String as content,
|
||||
* with color Gray.
|
||||
*/
|
||||
public TextComponent subTitle(String content) {
|
||||
return text(content).color(BRACKETS);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a TextComponent with the input String as content,
|
||||
* with color Gray and decoration Italic.
|
||||
*/
|
||||
public TextComponent italicSubTitle(String content) {
|
||||
public TextComponent subTitle(String content) {
|
||||
return text(content).color(BRACKETS).decorate(TextDecoration.ITALIC);
|
||||
}
|
||||
|
||||
|
@ -126,11 +118,11 @@ public class ComponentFactory {
|
|||
* with color Medium_Blue.
|
||||
*/
|
||||
public TextComponent message() {
|
||||
return text().color(MSG_MAIN).build();
|
||||
return text().color(FEEDBACK_MSG).build();
|
||||
}
|
||||
|
||||
public TextComponent messageAccent() {
|
||||
return text().color(MSG_ACCENT).build();
|
||||
return text().color(FEEDBACK_MSG_ACCENT).build();
|
||||
}
|
||||
|
||||
public TextComponent title(String content, Target target) {
|
||||
|
@ -173,14 +165,14 @@ public class ComponentFactory {
|
|||
|
||||
public TextComponent sharerName(String sharerName) {
|
||||
return getComponent(sharerName,
|
||||
getSharerNameColor(),
|
||||
getColorFromString(config.getSharerNameDecoration(false)),
|
||||
getStyleFromString(config.getSharerNameDecoration(true)));
|
||||
}
|
||||
|
||||
public TextComponent shareButton(int shareCode) {
|
||||
return surroundWithBrackets(
|
||||
text("Share")
|
||||
.color(MSG_HOVER)
|
||||
.color(FEEDBACK_MSG_ACCENT)
|
||||
.clickEvent(ClickEvent.runCommand("/statshare " + shareCode))
|
||||
.hoverEvent(HoverEvent.showText(text("Click here to share this statistic in chat!")
|
||||
.color(MSG_HOVER_ACCENT))));
|
||||
|
|
|
@ -4,6 +4,7 @@ import net.kyori.adventure.text.Component;
|
|||
import net.kyori.adventure.text.ComponentLike;
|
||||
import net.kyori.adventure.text.TextComponent;
|
||||
import net.kyori.adventure.text.format.Style;
|
||||
import org.jetbrains.annotations.Contract;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Unmodifiable;
|
||||
|
||||
|
@ -22,34 +23,35 @@ public final class ExampleMessage implements TextComponent {
|
|||
exampleMessage = buildMessage(factory);
|
||||
}
|
||||
|
||||
public static ExampleMessage construct(ComponentFactory factory) {
|
||||
@Contract("_ -> new")
|
||||
public static @NotNull ExampleMessage construct(ComponentFactory factory) {
|
||||
return new ExampleMessage(factory);
|
||||
}
|
||||
|
||||
private TextComponent buildMessage(ComponentFactory factory) {
|
||||
String arrow = factory instanceof BukkitConsoleComponentFactory ? " -> " : " → "; //4 spaces, alt + 26, 1 space
|
||||
private @NotNull TextComponent buildMessage(@NotNull ComponentFactory factory) {
|
||||
String arrowString = factory instanceof BukkitConsoleComponentFactory ? " -> " : " → "; //4 spaces, alt + 26, 1 space
|
||||
TextComponent arrow = text(arrowString).color(factory.INFO_MSG);
|
||||
|
||||
return Component.newline()
|
||||
.append(factory.pluginPrefixAsTitle())
|
||||
.append(Component.newline())
|
||||
.append(text("Examples: ").color(factory.MSG_MAIN_2))
|
||||
.append(factory.subTitle("Examples: "))
|
||||
.append(Component.newline())
|
||||
.append(text(arrow).color(factory.MSG_MAIN_2)
|
||||
.append(text("/statistic ")
|
||||
.append(text("animals_bred ").color(factory.MSG_ACCENT_2A)
|
||||
.append(text("top").color(factory.MSG_ACCENT_2B)))))
|
||||
.append(arrow)
|
||||
.append(text("/stat ").color(factory.INFO_MSG)
|
||||
.append(text("animals_bred ").color(factory.INFO_MSG_ACCENT_1)
|
||||
.append(text("top").color(factory.INFO_MSG_ACCENT_2))))
|
||||
.append(Component.newline())
|
||||
.append(text(arrow).color(factory.MSG_MAIN_2)
|
||||
.append(text("/statistic ")
|
||||
.append(text("mine_block diorite ").color(factory.MSG_ACCENT_2A)
|
||||
.append(text("me").color(factory.MSG_ACCENT_2B)))))
|
||||
.append(arrow)
|
||||
.append(text("/stat ").color(factory.INFO_MSG)
|
||||
.append(text("mine_block diorite ").color(factory.INFO_MSG_ACCENT_1)
|
||||
.append(text("me").color(factory.INFO_MSG_ACCENT_2))))
|
||||
.append(Component.newline())
|
||||
.append(text(arrow).color(factory.MSG_MAIN_2)
|
||||
.append(text("/statistic ")
|
||||
.append(text("deaths ").color(factory.MSG_ACCENT_2A)
|
||||
.append(text("player ").color(factory.MSG_ACCENT_2B)
|
||||
.append(text("Artemis_the_gr8")
|
||||
.color(factory.getExampleNameColor()))))));
|
||||
.append(arrow)
|
||||
.append(text("/stat ").color(factory.INFO_MSG)
|
||||
.append(text("deaths ").color(factory.INFO_MSG_ACCENT_1)
|
||||
.append(text("player ").color(factory.INFO_MSG_ACCENT_2)
|
||||
.append(factory.getExampleName()))));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -0,0 +1,80 @@
|
|||
package com.artemis.the.gr8.playerstats.msg.components;
|
||||
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.kyori.adventure.text.ComponentLike;
|
||||
import net.kyori.adventure.text.TextComponent;
|
||||
import net.kyori.adventure.text.format.Style;
|
||||
import org.jetbrains.annotations.Contract;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Unmodifiable;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import static net.kyori.adventure.text.Component.text;
|
||||
|
||||
public class ExcludeInfoMessage implements TextComponent {
|
||||
|
||||
private final TextComponent excludeInfo;
|
||||
|
||||
private ExcludeInfoMessage(ComponentFactory factory) {
|
||||
excludeInfo = buildMessage(factory);
|
||||
}
|
||||
|
||||
@Contract("_ -> new")
|
||||
public static @NotNull ExcludeInfoMessage construct(ComponentFactory factory) {
|
||||
return new ExcludeInfoMessage(factory);
|
||||
}
|
||||
|
||||
private @NotNull TextComponent buildMessage(@NotNull ComponentFactory factory) {
|
||||
String arrowString = factory instanceof BukkitConsoleComponentFactory ? " -> " : " → "; //4 spaces, alt + 26, 1 space
|
||||
TextComponent arrow = text(arrowString).color(factory.INFO_MSG);
|
||||
|
||||
return Component.newline()
|
||||
.append(factory.pluginPrefixAsTitle())
|
||||
.append(Component.newline())
|
||||
.append(factory.subTitle("The /statexclude command is used to hide"))
|
||||
.append(Component.newline())
|
||||
.append(factory.subTitle("specific players' results from /stat lookups"))
|
||||
.append(Component.newline())
|
||||
.append(text("Excluded players are:").color(factory.INFO_MSG))
|
||||
.append(Component.newline())
|
||||
.append(arrow).append(text("not visible in the top 10").color(factory.INFO_MSG_ACCENT_1))
|
||||
.append(Component.newline())
|
||||
.append(arrow).append(text("not counted for the server total").color(factory.INFO_MSG_ACCENT_1));
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull String content() {
|
||||
return excludeInfo.content();
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull TextComponent content(@NotNull String content) {
|
||||
return excludeInfo.content(content);
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull Builder toBuilder() {
|
||||
return excludeInfo.toBuilder();
|
||||
}
|
||||
|
||||
@Override
|
||||
public @Unmodifiable @NotNull List<Component> children() {
|
||||
return excludeInfo.children();
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull TextComponent children(@NotNull List<? extends ComponentLike> children) {
|
||||
return excludeInfo.children(children);
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull Style style() {
|
||||
return excludeInfo.style();
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull TextComponent style(@NotNull Style style) {
|
||||
return excludeInfo.style(style);
|
||||
}
|
||||
}
|
|
@ -6,6 +6,7 @@ import net.kyori.adventure.text.TextComponent;
|
|||
import net.kyori.adventure.text.event.HoverEvent;
|
||||
import net.kyori.adventure.text.format.Style;
|
||||
import net.kyori.adventure.text.format.TextDecoration;
|
||||
import org.jetbrains.annotations.Contract;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Unmodifiable;
|
||||
|
||||
|
@ -28,15 +29,17 @@ public final class HelpMessage implements TextComponent {
|
|||
}
|
||||
}
|
||||
|
||||
public static HelpMessage constructPlainMsg(ComponentFactory factory, int listSize) {
|
||||
@Contract("_, _ -> new")
|
||||
public static @NotNull HelpMessage constructPlainMsg(ComponentFactory factory, int listSize) {
|
||||
return new HelpMessage(factory, false, listSize);
|
||||
}
|
||||
|
||||
public static HelpMessage constructHoverMsg(ComponentFactory factory, int listSize) {
|
||||
@Contract("_, _ -> new")
|
||||
public static @NotNull HelpMessage constructHoverMsg(ComponentFactory factory, int listSize) {
|
||||
return new HelpMessage(factory, true, listSize);
|
||||
}
|
||||
|
||||
private TextComponent buildPlainMsg(ComponentFactory factory, int listSize) {
|
||||
private @NotNull TextComponent buildPlainMsg(ComponentFactory factory, int listSize) {
|
||||
String arrowSymbol = "→"; //alt + 26
|
||||
String bulletSymbol = "•"; //alt + 7
|
||||
|
||||
|
@ -45,15 +48,15 @@ public final class HelpMessage implements TextComponent {
|
|||
bulletSymbol = "*";
|
||||
}
|
||||
TextComponent spaces = text(" "); //4 spaces
|
||||
TextComponent arrow = text(arrowSymbol).color(factory.MSG_MAIN_2);
|
||||
TextComponent bullet = text(bulletSymbol).color(factory.MSG_MAIN_2);
|
||||
TextComponent arrow = text(arrowSymbol).color(factory.INFO_MSG);
|
||||
TextComponent bullet = text(bulletSymbol).color(factory.INFO_MSG);
|
||||
|
||||
return Component.newline()
|
||||
.append(factory.pluginPrefixAsTitle())
|
||||
.append(newline())
|
||||
.append(text("Type \"/statistic examples\" to see examples!").color(factory.BRACKETS).decorate(TextDecoration.ITALIC))
|
||||
.append(newline())
|
||||
.append(text("Usage:").color(factory.MSG_MAIN_2)).append(space())
|
||||
.append(text("Usage:").color(factory.INFO_MSG)).append(space())
|
||||
.append(text("/statistic").color(factory.MSG_HOVER_ACCENT))
|
||||
.append(newline())
|
||||
.append(spaces).append(arrow).append(space())
|
||||
|
@ -67,42 +70,42 @@ public final class HelpMessage implements TextComponent {
|
|||
.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(factory.MSG_ACCENT_2A)).append(space())
|
||||
.append(text("me:").color(factory.INFO_MSG_ACCENT_1)).append(space())
|
||||
.append(text("your own statistic").color(factory.BRACKETS))
|
||||
.append(newline())
|
||||
.append(spaces).append(spaces).append(bullet).append(space())
|
||||
.append(text("player:").color(factory.MSG_ACCENT_2A)).append(space())
|
||||
.append(text("player:").color(factory.INFO_MSG_ACCENT_1)).append(space())
|
||||
.append(text("choose a player").color(factory.BRACKETS))
|
||||
.append(newline())
|
||||
.append(spaces).append(spaces).append(bullet).append(space())
|
||||
.append(text("server:").color(factory.MSG_ACCENT_2A)).append(space())
|
||||
.append(text("server:").color(factory.INFO_MSG_ACCENT_1)).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(factory.MSG_ACCENT_2A)).append(space())
|
||||
.append(text("top:").color(factory.INFO_MSG_ACCENT_1)).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(factory.MSG_HOVER_ACCENT));
|
||||
}
|
||||
|
||||
private TextComponent buildHoverMsg(ComponentFactory factory, int listSize) {
|
||||
private @NotNull TextComponent buildHoverMsg(@NotNull ComponentFactory factory, int listSize) {
|
||||
TextComponent spaces = text(" ");
|
||||
TextComponent arrow = text("→").color(factory.MSG_MAIN_2);
|
||||
TextComponent arrow = text("→").color(factory.INFO_MSG);
|
||||
|
||||
return Component.newline()
|
||||
.append(factory.pluginPrefixAsTitle())
|
||||
.append(newline())
|
||||
.append(factory.italicSubTitle("Hover over the arguments for more information!"))
|
||||
.append(factory.subTitle("Hover over the arguments for more information!"))
|
||||
.append(newline())
|
||||
.append(text("Usage:").color(factory.MSG_MAIN_2)).append(space())
|
||||
.append(text("Usage:").color(factory.INFO_MSG)).append(space())
|
||||
.append(text("/statistic").color(factory.MSG_HOVER_ACCENT))
|
||||
.append(newline())
|
||||
.append(spaces).append(arrow).append(space())
|
||||
.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(factory.MSG_MAIN_2))
|
||||
.append(text("Example: ").color(factory.INFO_MSG))
|
||||
.append(text("\"animals_bred\"").color(factory.MSG_HOVER_ACCENT)))))
|
||||
.append(newline())
|
||||
.append(spaces).append(arrow).append(space())
|
||||
|
@ -110,12 +113,12 @@ public final class HelpMessage implements TextComponent {
|
|||
.hoverEvent(HoverEvent.showText(
|
||||
text("Some statistics need an item, block or entity as extra input").color(factory.MSG_HOVER)
|
||||
.append(newline())
|
||||
.append(text("Example: ").color(factory.MSG_MAIN_2)
|
||||
.append(text("Example: ").color(factory.INFO_MSG)
|
||||
.append(text("\"mine_block diorite\"").color(factory.MSG_HOVER_ACCENT))))))
|
||||
.append(newline())
|
||||
.append(spaces).append(arrow
|
||||
.hoverEvent(HoverEvent.showText(
|
||||
text("Choose one").color(factory.UNDERSCORE)))).append(space())
|
||||
text("Choose one").color(factory.MSG_CLICKED)))).append(space())
|
||||
.append(text("me").color(factory.MSG_HOVER_ACCENT)
|
||||
.hoverEvent(HoverEvent.showText(
|
||||
text("See your own statistic").color(factory.MSG_HOVER))))
|
||||
|
|
|
@ -2,9 +2,8 @@ package com.artemis.the.gr8.playerstats.msg.components;
|
|||
|
||||
import com.artemis.the.gr8.playerstats.config.ConfigHandler;
|
||||
|
||||
import com.artemis.the.gr8.playerstats.enums.PluginColor;
|
||||
import com.artemis.the.gr8.playerstats.msg.msgutils.EasterEggProvider;
|
||||
import net.kyori.adventure.text.TextComponent;
|
||||
import net.kyori.adventure.text.format.TextColor;
|
||||
import net.kyori.adventure.text.minimessage.MiniMessage;
|
||||
import org.jetbrains.annotations.Contract;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
@ -18,37 +17,22 @@ import static net.kyori.adventure.text.Component.*;
|
|||
*/
|
||||
public class PrideComponentFactory extends ComponentFactory {
|
||||
|
||||
public PrideComponentFactory(ConfigHandler c) {
|
||||
super(c);
|
||||
public PrideComponentFactory(ConfigHandler config) {
|
||||
super(config);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void prepareColors() {
|
||||
PREFIX = PluginColor.GOLD.getColor();
|
||||
BRACKETS = PluginColor.GRAY.getColor();
|
||||
UNDERSCORE = PluginColor.DARK_PURPLE.getColor();
|
||||
HEARTS = PluginColor.RED.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();
|
||||
|
||||
MSG_HOVER = PluginColor.LIGHT_BLUE.getColor();
|
||||
MSG_CLICKED = PluginColor.LIGHT_PURPLE.getColor();
|
||||
MSG_HOVER_ACCENT = PluginColor.LIGHT_GOLD.getColor();
|
||||
public TextComponent getExampleName() {
|
||||
return text()
|
||||
.append(EasterEggProvider.getFestiveName("Artemis_the_gr8"))
|
||||
.build();
|
||||
}
|
||||
|
||||
@Override
|
||||
public TextColor getExampleNameColor() {
|
||||
return getSharerNameColor();
|
||||
}
|
||||
|
||||
@Override
|
||||
public TextColor getSharerNameColor() {
|
||||
return PluginColor.getRandomNameColor();
|
||||
public TextComponent sharerName(String sharerName) {
|
||||
return text()
|
||||
.append(EasterEggProvider.getFestiveName(sharerName))
|
||||
.build();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -8,7 +8,9 @@ import net.kyori.adventure.text.minimessage.tag.Tag;
|
|||
import net.kyori.adventure.text.minimessage.tag.resolver.TagResolver;
|
||||
import net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.jetbrains.annotations.Contract;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
|
@ -19,26 +21,17 @@ import java.util.Random;
|
|||
*/
|
||||
public final class EasterEggProvider {
|
||||
|
||||
private static boolean isEnabled;
|
||||
private static final Random random;
|
||||
|
||||
static{
|
||||
enable();
|
||||
static {
|
||||
random = new Random();
|
||||
}
|
||||
|
||||
public static void enable() {
|
||||
isEnabled = true;
|
||||
}
|
||||
public static void disable() {
|
||||
isEnabled = false;
|
||||
public static @NotNull Component getFestiveName(String playerName) {
|
||||
return MiniMessage.miniMessage().deserialize(decorateWithRandomGradient(playerName));
|
||||
}
|
||||
|
||||
public static Component getPlayerName(Player player) {
|
||||
if (!isEnabled) {
|
||||
return null;
|
||||
}
|
||||
|
||||
public static @Nullable Component getPlayerName(@NotNull Player player) {
|
||||
int sillyNumber = getSillyNumber();
|
||||
String playerName = null;
|
||||
switch (player.getUniqueId().toString()) {
|
||||
|
@ -109,6 +102,29 @@ public final class EasterEggProvider {
|
|||
}
|
||||
}
|
||||
|
||||
private static @NotNull String decorateWithRandomGradient(String input) {
|
||||
String colorString = switch (random.nextInt(9)) {
|
||||
case 0 -> {
|
||||
if (input.equalsIgnoreCase("Artemis_the_gr8")) {
|
||||
yield "<gradient:#f74040:gold:#FF6600:#f74040>";
|
||||
}
|
||||
else {
|
||||
yield "<gradient:#F7F438:#309de6>";
|
||||
}
|
||||
}
|
||||
case 1 -> "<gradient:#03b6fc:#f73bdb>";
|
||||
case 2 -> "<gradient:#14f7a0:#4287f5>";
|
||||
case 3 -> "<gradient:#a834eb:#f511da:#ad09ed>";
|
||||
case 4 -> "<gradient:#FF6600:#fcad23:#F7F438>";
|
||||
case 5 -> "<gradient:#309de6:#a834eb>";
|
||||
case 6 -> "<gradient:#F7F438:#fcad23:#FF6600>";
|
||||
case 7 -> "<gradient:#309de6:#F7F438>";
|
||||
case 8 -> "<gradient:#F79438:#F7389B>";
|
||||
default -> "<gradient:#F7F438:#309de6>";
|
||||
};
|
||||
return colorString + input + "</gradient>";
|
||||
}
|
||||
|
||||
private static int getSillyNumber() {
|
||||
return random.nextInt(100);
|
||||
}
|
||||
|
@ -117,7 +133,8 @@ public final class EasterEggProvider {
|
|||
return sillyNumber >= lowerBound && sillyNumber <= upperBound;
|
||||
}
|
||||
|
||||
private static TagResolver papiTag(final @NotNull Player player) {
|
||||
@Contract("_ -> new")
|
||||
private static @NotNull TagResolver papiTag(final @NotNull Player player) {
|
||||
return TagResolver.resolver("papi", (argumentQueue, context) -> {
|
||||
final String papiPlaceholder = argumentQueue.popOr("papi tag requires an argument").value();
|
||||
final String parsedPlaceholder = PlaceholderAPI.setPlaceholders(player, '%' + papiPlaceholder + '%');
|
||||
|
|
Loading…
Reference in New Issue