mirror of
https://github.com/itHotL/PlayerStats.git
synced 2025-02-16 01:41:30 +01:00
Made sharerName have a random rainbow gradient in rainbow mode
This commit is contained in:
parent
d5c1c44841
commit
260fad2d4a
@ -2,7 +2,6 @@ package com.artemis.the.gr8.playerstats.msg.components;
|
|||||||
|
|
||||||
import com.artemis.the.gr8.playerstats.config.ConfigHandler;
|
import com.artemis.the.gr8.playerstats.config.ConfigHandler;
|
||||||
|
|
||||||
import com.artemis.the.gr8.playerstats.msg.msgutils.EasterEggProvider;
|
|
||||||
import net.kyori.adventure.text.TextComponent;
|
import net.kyori.adventure.text.TextComponent;
|
||||||
import net.kyori.adventure.text.minimessage.MiniMessage;
|
import net.kyori.adventure.text.minimessage.MiniMessage;
|
||||||
import org.jetbrains.annotations.Contract;
|
import org.jetbrains.annotations.Contract;
|
||||||
@ -17,45 +16,39 @@ import static net.kyori.adventure.text.Component.*;
|
|||||||
*/
|
*/
|
||||||
public class PrideComponentFactory extends ComponentFactory {
|
public class PrideComponentFactory extends ComponentFactory {
|
||||||
|
|
||||||
|
private final Random random;
|
||||||
|
|
||||||
public PrideComponentFactory(ConfigHandler config) {
|
public PrideComponentFactory(ConfigHandler config) {
|
||||||
super(config);
|
super(config);
|
||||||
|
random = new Random();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public TextComponent getExampleName() {
|
public TextComponent getExampleName() {
|
||||||
return text()
|
return deserialize("<gradient:#f74040:gold:#FF6600:#f74040>Artemis_the_gr8</gradient>");
|
||||||
.append(EasterEggProvider.getFestiveName("Artemis_the_gr8"))
|
|
||||||
.build();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public TextComponent sharerName(String sharerName) {
|
public TextComponent sharerName(String sharerName) {
|
||||||
return text()
|
return deserialize(decorateWithRandomGradient(sharerName));
|
||||||
.append(EasterEggProvider.getFestiveName(sharerName))
|
|
||||||
.build();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
//12 underscores
|
||||||
public TextComponent pluginPrefixAsTitle() {
|
public TextComponent pluginPrefixAsTitle() {
|
||||||
String title = "<rainbow:16>____________ [PlayerStats] ____________</rainbow>"; //12 underscores
|
return deserialize("<rainbow:16>____________ [PlayerStats] ____________</rainbow>");
|
||||||
return text()
|
|
||||||
.append(MiniMessage.miniMessage().deserialize(title))
|
|
||||||
.build();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public TextComponent pluginPrefix() {
|
public TextComponent pluginPrefix() {
|
||||||
Random randomizer = new Random();
|
if (random.nextBoolean()) {
|
||||||
if (randomizer.nextBoolean()) {
|
|
||||||
return backwardsPluginPrefixComponent();
|
return backwardsPluginPrefixComponent();
|
||||||
}
|
}
|
||||||
return rainbowPrefix();
|
return rainbowPrefix();
|
||||||
}
|
}
|
||||||
|
|
||||||
public TextComponent rainbowPrefix() {
|
public TextComponent rainbowPrefix() {
|
||||||
return text()
|
return deserialize("<#f74040>[</#f74040>" +
|
||||||
.append(MiniMessage.miniMessage()
|
|
||||||
.deserialize("<#f74040>[</#f74040>" +
|
|
||||||
"<#F54D39>P</#F54D39>" +
|
"<#F54D39>P</#F54D39>" +
|
||||||
"<#F16E28>l</#F16E28>" +
|
"<#F16E28>l</#F16E28>" +
|
||||||
"<#ee8a19>a</#ee8a19>" +
|
"<#ee8a19>a</#ee8a19>" +
|
||||||
@ -67,15 +60,12 @@ public class PrideComponentFactory extends ComponentFactory {
|
|||||||
"<#01c1a7>a</#01c1a7>" +
|
"<#01c1a7>a</#01c1a7>" +
|
||||||
"<#1F8BEB>t</#1F8BEB>" +
|
"<#1F8BEB>t</#1F8BEB>" +
|
||||||
"<#3341E6>s</#3341E6>" +
|
"<#3341E6>s</#3341E6>" +
|
||||||
"<#631ae6>]</#631ae6>"))
|
"<#631ae6>]</#631ae6>");
|
||||||
.build();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Contract(" -> new")
|
@Contract(" -> new")
|
||||||
private @NotNull TextComponent backwardsPluginPrefixComponent() {
|
private @NotNull TextComponent backwardsPluginPrefixComponent() {
|
||||||
return text()
|
return deserialize("<#631ae6>[</#631ae6>" +
|
||||||
.append(MiniMessage.miniMessage()
|
|
||||||
.deserialize("<#631ae6>[</#631ae6>" +
|
|
||||||
"<#3341E6>P</#3341E6>" +
|
"<#3341E6>P</#3341E6>" +
|
||||||
"<#1F8BEB>l</#1F8BEB>" +
|
"<#1F8BEB>l</#1F8BEB>" +
|
||||||
"<#01c1a7>a</#01c1a7>" +
|
"<#01c1a7>a</#01c1a7>" +
|
||||||
@ -87,7 +77,28 @@ public class PrideComponentFactory extends ComponentFactory {
|
|||||||
"<#ee8a19>a</#ee8a19>" +
|
"<#ee8a19>a</#ee8a19>" +
|
||||||
"<#f67824>t</#f67824>" +
|
"<#f67824>t</#f67824>" +
|
||||||
"<#f76540>s</#f76540>" +
|
"<#f76540>s</#f76540>" +
|
||||||
"<#f74040>]</#f74040>"))
|
"<#f74040>]</#f74040>");
|
||||||
|
}
|
||||||
|
|
||||||
|
private @NotNull String decorateWithRandomGradient(@NotNull String input) {
|
||||||
|
String colorString = switch (random.nextInt(9)) {
|
||||||
|
case 0 -> "<gradient:#03b6fc:#f73bdb>";
|
||||||
|
case 1 -> "<gradient:#14f7a0:#4287f5>";
|
||||||
|
case 2 -> "<gradient:#a834eb:#f511da:#ad09ed>";
|
||||||
|
case 3 -> "<gradient:#FF6600:#f73bdb:#F7F438>";
|
||||||
|
case 4 -> "<gradient:#309de6:#a834eb>";
|
||||||
|
case 5 -> "<gradient:#F7F438:#fcad23:#FF6600>";
|
||||||
|
case 6 -> "<gradient:#309de6:#F7F438>";
|
||||||
|
case 7 -> "<gradient:#F79438:#F7389B>";
|
||||||
|
default -> "<gradient:#F7F438:#309de6>";
|
||||||
|
};
|
||||||
|
return colorString + input + "</gradient>";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Contract("_ -> new")
|
||||||
|
private @NotNull TextComponent deserialize(String input) {
|
||||||
|
return text()
|
||||||
|
.append(MiniMessage.miniMessage().deserialize(input))
|
||||||
.build();
|
.build();
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -27,10 +27,6 @@ public final class EasterEggProvider {
|
|||||||
random = new Random();
|
random = new Random();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static @NotNull Component getFestiveName(String playerName) {
|
|
||||||
return MiniMessage.miniMessage().deserialize(decorateWithRandomGradient(playerName));
|
|
||||||
}
|
|
||||||
|
|
||||||
public static @Nullable Component getPlayerName(@NotNull Player player) {
|
public static @Nullable Component getPlayerName(@NotNull Player player) {
|
||||||
int sillyNumber = getSillyNumber();
|
int sillyNumber = getSillyNumber();
|
||||||
String playerName = null;
|
String playerName = null;
|
||||||
@ -102,29 +98,6 @@ 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() {
|
private static int getSillyNumber() {
|
||||||
return random.nextInt(100);
|
return random.nextInt(100);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user