diff --git a/src/main/java/land/chipmunk/chayapak/chomens_bot/Configuration.java b/src/main/java/land/chipmunk/chayapak/chomens_bot/Configuration.java index a454c396..a5da36af 100644 --- a/src/main/java/land/chipmunk/chayapak/chomens_bot/Configuration.java +++ b/src/main/java/land/chipmunk/chayapak/chomens_bot/Configuration.java @@ -24,6 +24,8 @@ public class Configuration { @Getter public Core core = new Core(); @Getter public Discord discord = new Discord(); + + @Getter public ColorPalette colorPalette = new ColorPalette(); @Getter public String ownerName = "chayapak"; // mabe mabe @@ -44,6 +46,17 @@ public class Configuration { @Getter public int z = 0; } + public static class ColorPalette { + @Getter public String primary = "yellow"; + @Getter public String secondary = "gold"; + @Getter public String defaultColor = "white"; + @Getter public String username = "gold"; + @Getter public String uuid = "aqua"; + @Getter public String string = "aqua"; + @Getter public String number = "gold"; + @Getter public String ownerName = "green"; + } + public static class Discord { @Getter public boolean enabled = true; @Getter public String prefix = "default!"; diff --git a/src/main/java/land/chipmunk/chayapak/chomens_bot/commands/BotUserCommand.java b/src/main/java/land/chipmunk/chayapak/chomens_bot/commands/BotUserCommand.java index 44e548bc..3b32b030 100644 --- a/src/main/java/land/chipmunk/chayapak/chomens_bot/commands/BotUserCommand.java +++ b/src/main/java/land/chipmunk/chayapak/chomens_bot/commands/BotUserCommand.java @@ -3,6 +3,7 @@ package land.chipmunk.chayapak.chomens_bot.commands; import land.chipmunk.chayapak.chomens_bot.Bot; import land.chipmunk.chayapak.chomens_bot.command.Command; import land.chipmunk.chayapak.chomens_bot.command.CommandContext; +import land.chipmunk.chayapak.chomens_bot.util.ColorUtilities; import net.kyori.adventure.text.Component; import net.kyori.adventure.text.event.ClickEvent; import net.kyori.adventure.text.event.HoverEvent; @@ -56,7 +57,7 @@ public class BotUserCommand implements Command { .clickEvent( ClickEvent.copyToClipboard(username) ) - .color(NamedTextColor.GOLD), + .color(ColorUtilities.getColorByString(bot.config().colorPalette().username())), Component .text(uuid) .hoverEvent( @@ -69,7 +70,7 @@ public class BotUserCommand implements Command { .clickEvent( ClickEvent.copyToClipboard(uuid) ) - .color(NamedTextColor.AQUA) - ); + .color(ColorUtilities.getColorByString(bot.config().colorPalette().uuid())) + ).color(ColorUtilities.getColorByString(bot.config().colorPalette().defaultColor())); } } diff --git a/src/main/java/land/chipmunk/chayapak/chomens_bot/commands/BotVisibilityCommand.java b/src/main/java/land/chipmunk/chayapak/chomens_bot/commands/BotVisibilityCommand.java index 50a7d051..a2b8f5bb 100644 --- a/src/main/java/land/chipmunk/chayapak/chomens_bot/commands/BotVisibilityCommand.java +++ b/src/main/java/land/chipmunk/chayapak/chomens_bot/commands/BotVisibilityCommand.java @@ -3,6 +3,7 @@ package land.chipmunk.chayapak.chomens_bot.commands; import land.chipmunk.chayapak.chomens_bot.Bot; import land.chipmunk.chayapak.chomens_bot.command.Command; import land.chipmunk.chayapak.chomens_bot.command.CommandContext; +import land.chipmunk.chayapak.chomens_bot.util.ColorUtilities; import net.kyori.adventure.text.Component; import net.kyori.adventure.text.format.NamedTextColor; @@ -59,14 +60,16 @@ public class BotVisibilityCommand implements Command { bot.chat().send("/essentials:vanish disable"); return Component.empty() .append(Component.text("The bot's visibility is now ")) - .append(Component.text("visible").color(NamedTextColor.GREEN)); + .append(Component.text("visible").color(NamedTextColor.GREEN)) + .color(ColorUtilities.getColorByString(bot.config().colorPalette().defaultColor())); } case "off", "false" -> { bot.selfCare().visibility(false); bot.chat().send("/essentials:vanish enable"); return Component.empty() .append(Component.text("The bot's visibility is now ")) - .append(Component.text("invisible").color(NamedTextColor.GOLD)); + .append(Component.text("invisible").color(NamedTextColor.GOLD)) + .color(ColorUtilities.getColorByString(bot.config().colorPalette().defaultColor())); } default -> { return Component.text("Invalid argument").color(NamedTextColor.RED); diff --git a/src/main/java/land/chipmunk/chayapak/chomens_bot/commands/CloopCommand.java b/src/main/java/land/chipmunk/chayapak/chomens_bot/commands/CloopCommand.java index b86eedaf..ec390d6b 100644 --- a/src/main/java/land/chipmunk/chayapak/chomens_bot/commands/CloopCommand.java +++ b/src/main/java/land/chipmunk/chayapak/chomens_bot/commands/CloopCommand.java @@ -4,6 +4,7 @@ import land.chipmunk.chayapak.chomens_bot.Bot; import land.chipmunk.chayapak.chomens_bot.command.Command; import land.chipmunk.chayapak.chomens_bot.command.CommandContext; import land.chipmunk.chayapak.chomens_bot.data.CommandLoop; +import land.chipmunk.chayapak.chomens_bot.util.ColorUtilities; import net.kyori.adventure.text.Component; import net.kyori.adventure.text.JoinConfiguration; import net.kyori.adventure.text.format.NamedTextColor; @@ -60,9 +61,9 @@ public class CloopCommand implements Command { return Component.translatable( "Added %s with interval %s to the cloops", - Component.text(command).color(NamedTextColor.AQUA), - Component.text(interval).color(NamedTextColor.GOLD) - ); + Component.text(command).color(ColorUtilities.getColorByString(bot.config().colorPalette().string())), + Component.text(interval).color(ColorUtilities.getColorByString(bot.config().colorPalette().number())) + ).color(ColorUtilities.getColorByString(bot.config().colorPalette().defaultColor())); } case "remove" -> { try { @@ -71,15 +72,15 @@ public class CloopCommand implements Command { return Component.translatable( "Removed cloop %s", - Component.text(index).color(NamedTextColor.GOLD) - ); + Component.text(index).color(ColorUtilities.getColorByString(bot.config().colorPalette().number())) + ).color(ColorUtilities.getColorByString(bot.config().colorPalette().defaultColor())); } catch (IndexOutOfBoundsException | IllegalArgumentException | NullPointerException ignored) { return Component.text("Invalid index").color(NamedTextColor.RED); } } case "clear" -> { bot.cloop().clear(); - return Component.text("Cleared all cloops"); + return Component.text("Cleared all cloops").color(ColorUtilities.getColorByString(bot.config().colorPalette().defaultColor())); } case "list" -> { final List cloopsComponent = new ArrayList<>(); @@ -89,9 +90,9 @@ public class CloopCommand implements Command { cloopsComponent.add( Component.translatable( "%s › %s (%s)", - Component.text(index).color(NamedTextColor.GREEN), - Component.text(command.command()).color(NamedTextColor.AQUA), - Component.text(command.interval()).color(NamedTextColor.GOLD) + Component.text(index).color(ColorUtilities.getColorByString(bot.config().colorPalette().number())), + Component.text(command.command()).color(ColorUtilities.getColorByString(bot.config().colorPalette().string())), + Component.text(command.interval()).color(ColorUtilities.getColorByString(bot.config().colorPalette().number())) ).color(NamedTextColor.DARK_GRAY) ); index++; diff --git a/src/main/java/land/chipmunk/chayapak/chomens_bot/commands/CreatorCommand.java b/src/main/java/land/chipmunk/chayapak/chomens_bot/commands/CreatorCommand.java index 07479ea2..fb0f1eb9 100644 --- a/src/main/java/land/chipmunk/chayapak/chomens_bot/commands/CreatorCommand.java +++ b/src/main/java/land/chipmunk/chayapak/chomens_bot/commands/CreatorCommand.java @@ -3,6 +3,7 @@ package land.chipmunk.chayapak.chomens_bot.commands; import land.chipmunk.chayapak.chomens_bot.Bot; import land.chipmunk.chayapak.chomens_bot.command.Command; import land.chipmunk.chayapak.chomens_bot.command.CommandContext; +import land.chipmunk.chayapak.chomens_bot.util.ColorUtilities; import net.kyori.adventure.text.Component; import net.kyori.adventure.text.format.NamedTextColor; @@ -38,8 +39,8 @@ public class CreatorCommand implements Command { final Bot bot = context.bot(); return Component.empty() - .append(Component.text("ChomeNS Bot ").color(NamedTextColor.YELLOW)) - .append(Component.text("was created by ").color(NamedTextColor.WHITE)) - .append(Component.text("chayapak").color(NamedTextColor.GREEN)); + .append(Component.text("ChomeNS Bot ").color(ColorUtilities.getColorByString(bot.config().colorPalette().primary()))) + .append(Component.text("was created by ").color(ColorUtilities.getColorByString(bot.config().colorPalette().defaultColor()))) + .append(Component.text("chayapak").color(ColorUtilities.getColorByString(bot.config().colorPalette().ownerName()))); } } diff --git a/src/main/java/land/chipmunk/chayapak/chomens_bot/commands/DiscordCommand.java b/src/main/java/land/chipmunk/chayapak/chomens_bot/commands/DiscordCommand.java index dc5dc091..2ddba479 100644 --- a/src/main/java/land/chipmunk/chayapak/chomens_bot/commands/DiscordCommand.java +++ b/src/main/java/land/chipmunk/chayapak/chomens_bot/commands/DiscordCommand.java @@ -3,6 +3,7 @@ package land.chipmunk.chayapak.chomens_bot.commands; import land.chipmunk.chayapak.chomens_bot.Bot; import land.chipmunk.chayapak.chomens_bot.command.Command; import land.chipmunk.chayapak.chomens_bot.command.CommandContext; +import land.chipmunk.chayapak.chomens_bot.util.ColorUtilities; import net.kyori.adventure.text.Component; import net.kyori.adventure.text.event.ClickEvent; import net.kyori.adventure.text.format.NamedTextColor; @@ -40,7 +41,7 @@ public class DiscordCommand implements Command { final String link = bot.config().discord().inviteLink(); return Component.empty() - .append(Component.text("The Discord invite is ").color(NamedTextColor.WHITE)) + .append(Component.text("The Discord invite is ").color(ColorUtilities.getColorByString(bot.config().colorPalette().defaultColor()))) .append( Component .text(link) diff --git a/src/main/java/land/chipmunk/chayapak/chomens_bot/commands/FilterCommand.java b/src/main/java/land/chipmunk/chayapak/chomens_bot/commands/FilterCommand.java index b6446410..3e343873 100644 --- a/src/main/java/land/chipmunk/chayapak/chomens_bot/commands/FilterCommand.java +++ b/src/main/java/land/chipmunk/chayapak/chomens_bot/commands/FilterCommand.java @@ -4,6 +4,7 @@ import land.chipmunk.chayapak.chomens_bot.Bot; import land.chipmunk.chayapak.chomens_bot.command.Command; import land.chipmunk.chayapak.chomens_bot.command.CommandContext; import land.chipmunk.chayapak.chomens_bot.data.FilteredPlayer; +import land.chipmunk.chayapak.chomens_bot.util.ColorUtilities; import net.kyori.adventure.text.Component; import net.kyori.adventure.text.JoinConfiguration; import net.kyori.adventure.text.format.NamedTextColor; @@ -76,8 +77,8 @@ public class FilterCommand implements Command { bot.filter().add(player, regex, ignoreCase); return Component.translatable( "Added %s to the filters", - Component.text(player).color(NamedTextColor.AQUA) - ); + Component.text(player).color(ColorUtilities.getColorByString(bot.config().colorPalette().username())) + ).color(ColorUtilities.getColorByString(bot.config().colorPalette().defaultColor())); } case "remove" -> { try { @@ -87,15 +88,15 @@ public class FilterCommand implements Command { return Component.translatable( "Removed %s from the filters", - Component.text(removed.playerName).color(NamedTextColor.AQUA) - ); + Component.text(removed.playerName).color(ColorUtilities.getColorByString(bot.config().colorPalette().username())) + ).color(ColorUtilities.getColorByString(bot.config().colorPalette().defaultColor())); } catch (IndexOutOfBoundsException | IllegalArgumentException | NullPointerException ignored) { return Component.text("Invalid index").color(NamedTextColor.RED); } } case "clear" -> { bot.filter().clear(); - return Component.text("Cleared the filter"); + return Component.text("Cleared the filter").color(ColorUtilities.getColorByString(bot.config().colorPalette().defaultColor())); } case "list" -> { final List filtersComponents = new ArrayList<>(); @@ -105,8 +106,8 @@ public class FilterCommand implements Command { filtersComponents.add( Component.translatable( "%s › %s", - Component.text(index).color(NamedTextColor.GREEN), - Component.text(player.playerName).color(NamedTextColor.AQUA) + Component.text(index).color(ColorUtilities.getColorByString(bot.config().colorPalette().number())), + Component.text(player.playerName).color(ColorUtilities.getColorByString(bot.config().colorPalette().username())) ).color(NamedTextColor.DARK_GRAY) ); diff --git a/src/main/java/land/chipmunk/chayapak/chomens_bot/commands/HelpCommand.java b/src/main/java/land/chipmunk/chayapak/chomens_bot/commands/HelpCommand.java index cbcba8c1..c3bca3fd 100644 --- a/src/main/java/land/chipmunk/chayapak/chomens_bot/commands/HelpCommand.java +++ b/src/main/java/land/chipmunk/chayapak/chomens_bot/commands/HelpCommand.java @@ -3,6 +3,7 @@ package land.chipmunk.chayapak.chomens_bot.commands; import land.chipmunk.chayapak.chomens_bot.Bot; import land.chipmunk.chayapak.chomens_bot.command.Command; import land.chipmunk.chayapak.chomens_bot.command.CommandContext; +import land.chipmunk.chayapak.chomens_bot.util.ColorUtilities; import net.kyori.adventure.text.Component; import net.kyori.adventure.text.JoinConfiguration; import net.kyori.adventure.text.event.HoverEvent; @@ -124,7 +125,7 @@ public class HelpCommand implements Command { usages.add( Component.empty() - .append(Component.text(prefix + commandName).color(NamedTextColor.GOLD)) + .append(Component.text(prefix + commandName).color(ColorUtilities.getColorByString(bot.config().colorPalette().secondary()))) .append(Component.text( (command.alias().size() > 0 && !command.alias().get(0).equals("")) ? " (" + String.join(", ", command.alias()) + ")" : @@ -144,7 +145,7 @@ public class HelpCommand implements Command { Component.empty() .append(Component.text(prefix + commandName).color(NamedTextColor.GOLD)) .append(Component.text(" ")) - .append(Component.text(usage).color(NamedTextColor.AQUA)) + .append(Component.text(usage).color(ColorUtilities.getColorByString(bot.config().colorPalette().string()))) ); } diff --git a/src/main/java/land/chipmunk/chayapak/chomens_bot/commands/KickCommand.java b/src/main/java/land/chipmunk/chayapak/chomens_bot/commands/KickCommand.java index 840cb5c9..09ac348e 100644 --- a/src/main/java/land/chipmunk/chayapak/chomens_bot/commands/KickCommand.java +++ b/src/main/java/land/chipmunk/chayapak/chomens_bot/commands/KickCommand.java @@ -4,6 +4,7 @@ import land.chipmunk.chayapak.chomens_bot.Bot; import land.chipmunk.chayapak.chomens_bot.data.chat.MutablePlayerListEntry; import land.chipmunk.chayapak.chomens_bot.command.Command; import land.chipmunk.chayapak.chomens_bot.command.CommandContext; +import land.chipmunk.chayapak.chomens_bot.util.ColorUtilities; import net.kyori.adventure.text.Component; import net.kyori.adventure.text.format.NamedTextColor; @@ -50,6 +51,7 @@ public class KickCommand implements Command { return Component.empty() .append(Component.text("Kicking player ")) - .append(Component.text(name).color(NamedTextColor.GOLD)); + .append(Component.text(name).color(ColorUtilities.getColorByString(bot.config().colorPalette().username()))) + .color(ColorUtilities.getColorByString(bot.config().colorPalette().defaultColor())); } } diff --git a/src/main/java/land/chipmunk/chayapak/chomens_bot/commands/ListCommand.java b/src/main/java/land/chipmunk/chayapak/chomens_bot/commands/ListCommand.java index 7a056671..549db8dc 100644 --- a/src/main/java/land/chipmunk/chayapak/chomens_bot/commands/ListCommand.java +++ b/src/main/java/land/chipmunk/chayapak/chomens_bot/commands/ListCommand.java @@ -4,6 +4,7 @@ import land.chipmunk.chayapak.chomens_bot.Bot; import land.chipmunk.chayapak.chomens_bot.data.chat.MutablePlayerListEntry; import land.chipmunk.chayapak.chomens_bot.command.Command; import land.chipmunk.chayapak.chomens_bot.command.CommandContext; +import land.chipmunk.chayapak.chomens_bot.util.ColorUtilities; import net.kyori.adventure.text.Component; import net.kyori.adventure.text.JoinConfiguration; import net.kyori.adventure.text.event.ClickEvent; @@ -59,7 +60,7 @@ public class ListCommand implements Command { .clickEvent( ClickEvent.copyToClipboard(entry.profile().getName()) ) - .color(NamedTextColor.YELLOW), + .color(ColorUtilities.getColorByString(bot.config().colorPalette().username())), Component .text(entry.profile().getIdAsString()) .hoverEvent( @@ -70,7 +71,7 @@ public class ListCommand implements Command { .clickEvent( ClickEvent.copyToClipboard(entry.profile().getIdAsString()) ) - .color(NamedTextColor.AQUA) + .color(ColorUtilities.getColorByString(bot.config().colorPalette().uuid())) ).color(NamedTextColor.DARK_GRAY) ); } diff --git a/src/main/java/land/chipmunk/chayapak/chomens_bot/commands/MusicCommand.java b/src/main/java/land/chipmunk/chayapak/chomens_bot/commands/MusicCommand.java index 43ebd16c..e11f8a15 100644 --- a/src/main/java/land/chipmunk/chayapak/chomens_bot/commands/MusicCommand.java +++ b/src/main/java/land/chipmunk/chayapak/chomens_bot/commands/MusicCommand.java @@ -6,6 +6,7 @@ import land.chipmunk.chayapak.chomens_bot.command.CommandContext; import land.chipmunk.chayapak.chomens_bot.plugins.MusicPlayerPlugin; import land.chipmunk.chayapak.chomens_bot.song.Loop; import land.chipmunk.chayapak.chomens_bot.song.Song; +import land.chipmunk.chayapak.chomens_bot.util.ColorUtilities; import net.kyori.adventure.text.Component; import net.kyori.adventure.text.JoinConfiguration; import net.kyori.adventure.text.event.ClickEvent; @@ -167,7 +168,7 @@ public class MusicCommand implements Command { bot.music().stopPlaying(); bot.music().songQueue().clear(); - return Component.text("Cleared the song queue"); + return Component.text("Cleared the song queue").color(ColorUtilities.getColorByString(bot.config().colorPalette().defaultColor())); } public Component loop (CommandContext context, String[] args) { @@ -183,6 +184,7 @@ public class MusicCommand implements Command { Component.empty() .append(Component.text("Looping is now ")) .append(Component.text("disabled").color(NamedTextColor.RED)) + .color(ColorUtilities.getColorByString(bot.config().colorPalette().defaultColor())) ); } case "current" -> { @@ -190,12 +192,13 @@ public class MusicCommand implements Command { context.sendOutput( Component.empty() .append(Component.text("Now looping ")) - .append(bot.music().currentSong().name.color(NamedTextColor.GOLD)) + .append(bot.music().currentSong().name.color(ColorUtilities.getColorByString(bot.config().colorPalette().secondary()))) + .color(ColorUtilities.getColorByString(bot.config().colorPalette().defaultColor())) ); } case "all" -> { loop = Loop.ALL; - context.sendOutput(Component.text("Now looping every song")); + context.sendOutput(Component.text("Now looping every song").color(ColorUtilities.getColorByString(bot.config().colorPalette().defaultColor()))); } default -> { return Component.text("Invalid argument").color(NamedTextColor.RED); @@ -208,6 +211,8 @@ public class MusicCommand implements Command { } public Component list (CommandContext context, String[] args) { + final Bot bot = context.bot(); + final String prefix = context.prefix(); final Path _path = Path.of(root.toString(), String.join(" ", Arrays.copyOfRange(args, 1, args.length))); @@ -241,7 +246,7 @@ public class MusicCommand implements Command { final String joinedPath = (args.length < 2) ? filename : Paths.get(location.getFileName().toString(), filename).toString(); fullList.add( Component - .text(filename, (i++ & 1) == 0 ? NamedTextColor.YELLOW : NamedTextColor.GOLD) + .text(filename, (i++ & 1) == 0 ? ColorUtilities.getColorByString(bot.config().colorPalette().primary()) : ColorUtilities.getColorByString(bot.config().colorPalette().secondary())) .clickEvent( ClickEvent.suggestCommand( prefix + @@ -272,13 +277,15 @@ public class MusicCommand implements Command { } public Component skip (CommandContext context) { - final MusicPlayerPlugin music = context.bot().music(); + final Bot bot = context.bot(); + final MusicPlayerPlugin music = bot.music(); if (music.currentSong() == null) return Component.text("No song is currently playing").color(NamedTextColor.RED); context.sendOutput( Component.empty() .append(Component.text("Skipping ")) - .append(music.currentSong().name.color(NamedTextColor.GOLD)) + .append(music.currentSong().name.color(ColorUtilities.getColorByString(bot.config().colorPalette().secondary()))) + .color(ColorUtilities.getColorByString(bot.config().colorPalette().defaultColor())) ); music.skip(); @@ -293,7 +300,8 @@ public class MusicCommand implements Command { return Component.empty() .append(Component.text("Now playing ")) - .append(song.name.color(NamedTextColor.GOLD)); + .append(song.name.color(ColorUtilities.getColorByString(bot.config().colorPalette().secondary()))) + .color(ColorUtilities.getColorByString(bot.config().colorPalette().defaultColor())); } public Component queue (CommandContext context) { @@ -301,11 +309,16 @@ public class MusicCommand implements Command { final LinkedList queue = bot.music().songQueue(); final List queueWithNames = new ArrayList<>(); - for (Song song : queue) queueWithNames.add(song.name); + int i = 0; + for (Song song : queue) { + queueWithNames.add( + song.name.color((i++ & 1) == 0 ? ColorUtilities.getColorByString(bot.config().colorPalette().primary()) : ColorUtilities.getColorByString(bot.config().colorPalette().secondary())) + ); + } return Component.empty() .append(Component.text("Queue: ").color(NamedTextColor.GREEN)) - .append(Component.join(JoinConfiguration.separator(Component.text(", ")), queueWithNames).color(NamedTextColor.AQUA)); + .append(Component.join(JoinConfiguration.separator(Component.text(", ")), queueWithNames)); } // lazy fix for java using "goto" as keyword real @@ -342,7 +355,8 @@ public class MusicCommand implements Command { return Component.empty() .append(Component.text("Set the pitch to ")) - .append(Component.text(pitch).color(NamedTextColor.GOLD)); + .append(Component.text(pitch).color(ColorUtilities.getColorByString(bot.config().colorPalette().number()))) + .color(ColorUtilities.getColorByString(bot.config().colorPalette().defaultColor())); } public Component speed (CommandContext context, String[] args) { @@ -359,7 +373,8 @@ public class MusicCommand implements Command { return Component.empty() .append(Component.text("Set the speed to ")) - .append(Component.text(speed).color(NamedTextColor.GOLD)); + .append(Component.text(speed).color(ColorUtilities.getColorByString(bot.config().colorPalette().number()))) + .color(ColorUtilities.getColorByString(bot.config().colorPalette().defaultColor())); } public Component pause (CommandContext context) { diff --git a/src/main/java/land/chipmunk/chayapak/chomens_bot/commands/NetMessageCommand.java b/src/main/java/land/chipmunk/chayapak/chomens_bot/commands/NetMessageCommand.java index d021c610..77620cf4 100644 --- a/src/main/java/land/chipmunk/chayapak/chomens_bot/commands/NetMessageCommand.java +++ b/src/main/java/land/chipmunk/chayapak/chomens_bot/commands/NetMessageCommand.java @@ -4,6 +4,7 @@ import land.chipmunk.chayapak.chomens_bot.Bot; import land.chipmunk.chayapak.chomens_bot.command.Command; import land.chipmunk.chayapak.chomens_bot.command.CommandContext; import net.kyori.adventure.text.Component; +import net.kyori.adventure.text.JoinConfiguration; import net.kyori.adventure.text.event.ClickEvent; import net.kyori.adventure.text.event.HoverEvent; import net.kyori.adventure.text.format.NamedTextColor; @@ -58,7 +59,7 @@ public class NetMessageCommand implements Command { ) ), Component.text(" "), - Component.text(context.sender().profile().getName()).color(NamedTextColor.GRAY), + context.sender().displayName().color(NamedTextColor.GRAY), Component.text(" "), Component.text(String.join(" ", args)).color(NamedTextColor.GRAY) ).color(NamedTextColor.DARK_GRAY); diff --git a/src/main/java/land/chipmunk/chayapak/chomens_bot/commands/RandomTeleportCommand.java b/src/main/java/land/chipmunk/chayapak/chomens_bot/commands/RandomTeleportCommand.java index 951b7463..0a22d597 100644 --- a/src/main/java/land/chipmunk/chayapak/chomens_bot/commands/RandomTeleportCommand.java +++ b/src/main/java/land/chipmunk/chayapak/chomens_bot/commands/RandomTeleportCommand.java @@ -4,6 +4,7 @@ import land.chipmunk.chayapak.chomens_bot.Bot; import land.chipmunk.chayapak.chomens_bot.data.chat.MutablePlayerListEntry; import land.chipmunk.chayapak.chomens_bot.command.Command; import land.chipmunk.chayapak.chomens_bot.command.CommandContext; +import land.chipmunk.chayapak.chomens_bot.util.ColorUtilities; import land.chipmunk.chayapak.chomens_bot.util.MathUtilities; import net.kyori.adventure.text.Component; import net.kyori.adventure.text.format.NamedTextColor; @@ -49,9 +50,10 @@ public class RandomTeleportCommand implements Command { return Component.empty() .append(Component.text("Teleporting ")) - .append(Component.text(sender.profile().getName()).color(NamedTextColor.AQUA)) + .append(Component.text(sender.profile().getName()).color(ColorUtilities.getColorByString(bot.config().colorPalette().username()))) .append(Component.text(" to ").color(NamedTextColor.WHITE)) .append(Component.text(stringPosition).color(NamedTextColor.GREEN)) - .append(Component.text("...").color(NamedTextColor.WHITE)); + .append(Component.text("...").color(NamedTextColor.WHITE)) + .color(ColorUtilities.getColorByString(bot.config().colorPalette().defaultColor())); } } diff --git a/src/main/java/land/chipmunk/chayapak/chomens_bot/commands/ServerInfoCommand.java b/src/main/java/land/chipmunk/chayapak/chomens_bot/commands/ServerInfoCommand.java index 9591a00b..1f275be6 100644 --- a/src/main/java/land/chipmunk/chayapak/chomens_bot/commands/ServerInfoCommand.java +++ b/src/main/java/land/chipmunk/chayapak/chomens_bot/commands/ServerInfoCommand.java @@ -1,9 +1,12 @@ package land.chipmunk.chayapak.chomens_bot.commands; +import land.chipmunk.chayapak.chomens_bot.Bot; import land.chipmunk.chayapak.chomens_bot.command.Command; import land.chipmunk.chayapak.chomens_bot.command.CommandContext; +import land.chipmunk.chayapak.chomens_bot.util.ColorUtilities; import net.kyori.adventure.text.Component; import net.kyori.adventure.text.format.NamedTextColor; +import net.kyori.adventure.text.format.TextColor; import java.io.IOException; import java.io.RandomAccessFile; @@ -45,6 +48,8 @@ public class ServerInfoCommand implements Command { } public Component execute(CommandContext context, String[] args, String[] fullArgs) throws UnknownHostException { + final Bot bot = context.bot(); + // totallynotskidded™ from extras' serverinfo final Component component; @@ -75,13 +80,15 @@ public class ServerInfoCommand implements Command { file.close(); } catch (IOException ignored) {} + final TextColor color = ColorUtilities.getColorByString(bot.config().colorPalette().string()); + final String[] lines = builder.toString().split("\n"); final Optional modelName = Arrays.stream(lines) .filter(line -> line.startsWith("model name")) .findFirst(); final Component cpuModel = modelName - .map(s -> Component.text(s.split("\t: ")[1]).color(NamedTextColor.AQUA)) - .orElseGet(() -> Component.text("N/A").color(NamedTextColor.AQUA)); + .map(s -> Component.text(s.split("\t: ")[1]).color(color)) + .orElseGet(() -> Component.text("N/A").color(color)); component = Component.translatable( """ @@ -93,20 +100,20 @@ public class ServerInfoCommand implements Command { CPU cores: %s CPU model: %s Heap memory usage: %s""", - Component.text(InetAddress.getLocalHost().getHostName()).color(NamedTextColor.AQUA), - Component.text(System.getProperty("user.dir")).color(NamedTextColor.AQUA), - Component.text(os.getArch()).color(NamedTextColor.AQUA), - Component.text(os.getVersion()).color(NamedTextColor.AQUA), - Component.text(os.getName()).color(NamedTextColor.AQUA), - Component.text(String.valueOf(Runtime.getRuntime().availableProcessors())).color(NamedTextColor.AQUA), + Component.text(InetAddress.getLocalHost().getHostName()).color(color), + Component.text(System.getProperty("user.dir")).color(color), + Component.text(os.getArch()).color(color), + Component.text(os.getVersion()).color(color), + Component.text(os.getName()).color(color), + Component.text(String.valueOf(Runtime.getRuntime().availableProcessors())).color(color), cpuModel, Component .translatable( "%s MB / %s MB", Component.text(heapUsage.getUsed() / 1024L / 1024L), Component.text(heapUsage.getMax() / 1024L / 1024L) - ).color(NamedTextColor.AQUA) - ).color(NamedTextColor.GOLD); + ).color(color) + ).color(ColorUtilities.getColorByString(bot.config().colorPalette().secondary())); return component; } diff --git a/src/main/java/land/chipmunk/chayapak/chomens_bot/commands/TPSBarCommand.java b/src/main/java/land/chipmunk/chayapak/chomens_bot/commands/TPSBarCommand.java index c7dc1dda..5c01d650 100644 --- a/src/main/java/land/chipmunk/chayapak/chomens_bot/commands/TPSBarCommand.java +++ b/src/main/java/land/chipmunk/chayapak/chomens_bot/commands/TPSBarCommand.java @@ -3,6 +3,7 @@ package land.chipmunk.chayapak.chomens_bot.commands; import land.chipmunk.chayapak.chomens_bot.Bot; import land.chipmunk.chayapak.chomens_bot.command.Command; import land.chipmunk.chayapak.chomens_bot.command.CommandContext; +import land.chipmunk.chayapak.chomens_bot.util.ColorUtilities; import net.kyori.adventure.text.Component; import net.kyori.adventure.text.format.NamedTextColor; @@ -42,13 +43,15 @@ public class TPSBarCommand implements Command { bot.tps().on(); return Component.empty() .append(Component.text("TPSBar is now ")) - .append(Component.text("enabled").color(NamedTextColor.GREEN)); + .append(Component.text("enabled").color(NamedTextColor.GREEN)) + .color(ColorUtilities.getColorByString(bot.config().colorPalette().defaultColor())); } case "off" -> { bot.tps().off(); return Component.empty() .append(Component.text("TPSBar is now ")) - .append(Component.text("disabled").color(NamedTextColor.RED)); + .append(Component.text("disabled").color(NamedTextColor.RED)) + .color(ColorUtilities.getColorByString(bot.config().colorPalette().defaultColor())); } default -> { return Component.text("Invalid argument").color(NamedTextColor.RED); diff --git a/src/main/java/land/chipmunk/chayapak/chomens_bot/commands/TimeCommand.java b/src/main/java/land/chipmunk/chayapak/chomens_bot/commands/TimeCommand.java index 980ae4d7..4df61610 100644 --- a/src/main/java/land/chipmunk/chayapak/chomens_bot/commands/TimeCommand.java +++ b/src/main/java/land/chipmunk/chayapak/chomens_bot/commands/TimeCommand.java @@ -1,7 +1,9 @@ package land.chipmunk.chayapak.chomens_bot.commands; +import land.chipmunk.chayapak.chomens_bot.Bot; import land.chipmunk.chayapak.chomens_bot.command.Command; import land.chipmunk.chayapak.chomens_bot.command.CommandContext; +import land.chipmunk.chayapak.chomens_bot.util.ColorUtilities; import net.kyori.adventure.text.Component; import net.kyori.adventure.text.format.NamedTextColor; import org.joda.time.DateTime; @@ -39,6 +41,8 @@ public class TimeCommand implements Command { } public Component execute(CommandContext context, String[] args, String[] fullArgs) { + final Bot bot = context.bot(); + final String timezone = args[0]; DateTimeZone zone; @@ -55,8 +59,8 @@ public class TimeCommand implements Command { return Component.translatable( "The current time for %s is: %s", - Component.text(timezone).color(NamedTextColor.AQUA), + Component.text(timezone).color(ColorUtilities.getColorByString(bot.config().colorPalette().string())), Component.text(formattedTime).color(NamedTextColor.GREEN) - ); + ).color(ColorUtilities.getColorByString(bot.config().colorPalette().defaultColor())); } } diff --git a/src/main/java/land/chipmunk/chayapak/chomens_bot/commands/TranslateCommand.java b/src/main/java/land/chipmunk/chayapak/chomens_bot/commands/TranslateCommand.java index 400c3f2e..89d22cb0 100644 --- a/src/main/java/land/chipmunk/chayapak/chomens_bot/commands/TranslateCommand.java +++ b/src/main/java/land/chipmunk/chayapak/chomens_bot/commands/TranslateCommand.java @@ -3,8 +3,10 @@ package land.chipmunk.chayapak.chomens_bot.commands; import com.google.gson.Gson; import com.google.gson.JsonArray; import com.google.gson.JsonObject; +import land.chipmunk.chayapak.chomens_bot.Bot; import land.chipmunk.chayapak.chomens_bot.command.Command; import land.chipmunk.chayapak.chomens_bot.command.CommandContext; +import land.chipmunk.chayapak.chomens_bot.util.ColorUtilities; import land.chipmunk.chayapak.chomens_bot.util.HttpUtilities; import net.kyori.adventure.text.Component; import net.kyori.adventure.text.format.NamedTextColor; @@ -42,6 +44,8 @@ public class TranslateCommand implements Command { } public Component execute(CommandContext context, String[] args, String[] fullArgs) { + final Bot bot = context.bot(); + final String from = args[0]; final String to = args[1]; @@ -79,7 +83,7 @@ public class TranslateCommand implements Command { "Result: %s", Component.text(output).color(NamedTextColor.GREEN) ) - .color(NamedTextColor.GOLD); + .color(ColorUtilities.getColorByString(bot.config().colorPalette().secondary())); } catch (Exception e) { return Component.text(e.toString()).color(NamedTextColor.RED); } diff --git a/src/main/java/land/chipmunk/chayapak/chomens_bot/commands/UUIDCommand.java b/src/main/java/land/chipmunk/chayapak/chomens_bot/commands/UUIDCommand.java index 56658af3..5d482706 100644 --- a/src/main/java/land/chipmunk/chayapak/chomens_bot/commands/UUIDCommand.java +++ b/src/main/java/land/chipmunk/chayapak/chomens_bot/commands/UUIDCommand.java @@ -4,6 +4,7 @@ import land.chipmunk.chayapak.chomens_bot.data.chat.MutablePlayerListEntry; import land.chipmunk.chayapak.chomens_bot.Bot; import land.chipmunk.chayapak.chomens_bot.command.Command; import land.chipmunk.chayapak.chomens_bot.command.CommandContext; +import land.chipmunk.chayapak.chomens_bot.util.ColorUtilities; import net.kyori.adventure.text.Component; import net.kyori.adventure.text.event.ClickEvent; import net.kyori.adventure.text.event.HoverEvent; @@ -61,7 +62,7 @@ public class UUIDCommand implements Command { .clickEvent( ClickEvent.copyToClipboard(uuid) ) - .color(NamedTextColor.AQUA) + .color(ColorUtilities.getColorByString(bot.config().colorPalette().uuid())) ).color(NamedTextColor.GREEN); } else { final MutablePlayerListEntry entry = context.sender(); @@ -80,7 +81,7 @@ public class UUIDCommand implements Command { .clickEvent( ClickEvent.copyToClipboard(uuid) ) - .color(NamedTextColor.AQUA) + .color(ColorUtilities.getColorByString(bot.config().colorPalette().uuid())) ).color(NamedTextColor.GREEN); } } diff --git a/src/main/java/land/chipmunk/chayapak/chomens_bot/commands/UptimeCommand.java b/src/main/java/land/chipmunk/chayapak/chomens_bot/commands/UptimeCommand.java index 91e12971..32f33bbb 100644 --- a/src/main/java/land/chipmunk/chayapak/chomens_bot/commands/UptimeCommand.java +++ b/src/main/java/land/chipmunk/chayapak/chomens_bot/commands/UptimeCommand.java @@ -1,7 +1,9 @@ package land.chipmunk.chayapak.chomens_bot.commands; +import land.chipmunk.chayapak.chomens_bot.Bot; import land.chipmunk.chayapak.chomens_bot.command.Command; import land.chipmunk.chayapak.chomens_bot.command.CommandContext; +import land.chipmunk.chayapak.chomens_bot.util.ColorUtilities; import net.kyori.adventure.text.Component; import net.kyori.adventure.text.format.NamedTextColor; @@ -36,6 +38,8 @@ public class UptimeCommand implements Command { } public Component execute(CommandContext context, String[] args, String[] fullArgs) { + final Bot bot = context.bot(); + final long uptime = ManagementFactory.getRuntimeMXBean().getUptime() / 1000; long days = TimeUnit.SECONDS.toDays(uptime); @@ -44,7 +48,7 @@ public class UptimeCommand implements Command { long seconds = TimeUnit.SECONDS.toSeconds(uptime) - (TimeUnit.SECONDS.toMinutes(uptime) * 60); return Component.translatable( - "The bot's uptime is: %s", + "The bots uptime is: %s", Component.translatable( "%s days, %s hours, %s minutes, %s seconds", Component.text(days), @@ -52,6 +56,6 @@ public class UptimeCommand implements Command { Component.text(minutes), Component.text(seconds) ).color(NamedTextColor.GREEN) - ); + ).color(ColorUtilities.getColorByString(bot.config().colorPalette().defaultColor())); } } diff --git a/src/main/java/land/chipmunk/chayapak/chomens_bot/commands/WeatherCommand.java b/src/main/java/land/chipmunk/chayapak/chomens_bot/commands/WeatherCommand.java index 74bfb407..90f0fdba 100644 --- a/src/main/java/land/chipmunk/chayapak/chomens_bot/commands/WeatherCommand.java +++ b/src/main/java/land/chipmunk/chayapak/chomens_bot/commands/WeatherCommand.java @@ -5,6 +5,7 @@ import com.google.gson.JsonObject; import land.chipmunk.chayapak.chomens_bot.Bot; import land.chipmunk.chayapak.chomens_bot.command.Command; import land.chipmunk.chayapak.chomens_bot.command.CommandContext; +import land.chipmunk.chayapak.chomens_bot.util.ColorUtilities; import land.chipmunk.chayapak.chomens_bot.util.HttpUtilities; import net.kyori.adventure.text.Component; import net.kyori.adventure.text.format.NamedTextColor; @@ -75,13 +76,12 @@ public class WeatherCommand implements Command { return Component.translatable( "Weather forecast for %s, %s:\n%s, feels like %s\nTime: %s", - Component.text(jsonObject.get("location").getAsJsonObject().get("name").getAsString()).color(NamedTextColor.AQUA), - Component.text(jsonObject.get("location").getAsJsonObject().get("country").getAsString()).color(NamedTextColor.AQUA), - Component.text(jsonObject.get("current").getAsJsonObject().get("temp_c").getAsString() + "°C").color(NamedTextColor.GOLD), + Component.text(jsonObject.get("location").getAsJsonObject().get("name").getAsString()).color(ColorUtilities.getColorByString(bot.config().colorPalette().string())), + Component.text(jsonObject.get("location").getAsJsonObject().get("country").getAsString()).color(ColorUtilities.getColorByString(bot.config().colorPalette().string())), + Component.text(jsonObject.get("current").getAsJsonObject().get("temp_c").getAsString() + "°C").color(ColorUtilities.getColorByString(bot.config().colorPalette().secondary())), Component.text(jsonObject.get("current").getAsJsonObject().get("feelslike_c").getAsString() + "°C").color(NamedTextColor.GREEN), - Component.text(time).color(NamedTextColor.AQUA) - - ); + Component.text(time).color(ColorUtilities.getColorByString(bot.config().colorPalette().string())) + ).color(ColorUtilities.getColorByString(bot.config().colorPalette().defaultColor())); } catch (Exception e) { return Component.text("Location \"" + location + "\" not found").color(NamedTextColor.RED); } diff --git a/src/main/java/land/chipmunk/chayapak/chomens_bot/plugins/ConsolePlugin.java b/src/main/java/land/chipmunk/chayapak/chomens_bot/plugins/ConsolePlugin.java index 5b1648c0..479e9ddb 100644 --- a/src/main/java/land/chipmunk/chayapak/chomens_bot/plugins/ConsolePlugin.java +++ b/src/main/java/land/chipmunk/chayapak/chomens_bot/plugins/ConsolePlugin.java @@ -3,6 +3,7 @@ package land.chipmunk.chayapak.chomens_bot.plugins; import land.chipmunk.chayapak.chomens_bot.Bot; import land.chipmunk.chayapak.chomens_bot.Configuration; import land.chipmunk.chayapak.chomens_bot.command.ConsoleCommandContext; +import land.chipmunk.chayapak.chomens_bot.util.ColorUtilities; import lombok.Getter; import net.dv8tion.jda.api.JDA; import net.kyori.adventure.text.Component; @@ -101,7 +102,7 @@ public class ConsolePlugin { Component.translatable( "[%s] %s › %s", Component.text(bot.username() + " Console").color(NamedTextColor.GRAY), - Component.text(bot.config().ownerName()).color(NamedTextColor.GREEN), + Component.text(bot.config().ownerName()).color(ColorUtilities.getColorByString(bot.config().colorPalette().ownerName())), Component.text(line).color(NamedTextColor.GRAY) ).color(NamedTextColor.DARK_GRAY) ); diff --git a/src/main/java/land/chipmunk/chayapak/chomens_bot/plugins/GrepLogPlugin.java b/src/main/java/land/chipmunk/chayapak/chomens_bot/plugins/GrepLogPlugin.java index 1ba3eb1a..2d19c484 100644 --- a/src/main/java/land/chipmunk/chayapak/chomens_bot/plugins/GrepLogPlugin.java +++ b/src/main/java/land/chipmunk/chayapak/chomens_bot/plugins/GrepLogPlugin.java @@ -2,6 +2,7 @@ package land.chipmunk.chayapak.chomens_bot.plugins; import land.chipmunk.chayapak.chomens_bot.Bot; import land.chipmunk.chayapak.chomens_bot.Logger; +import land.chipmunk.chayapak.chomens_bot.util.ColorUtilities; import lombok.Getter; import lombok.Setter; import net.dv8tion.jda.api.entities.TextChannel; @@ -71,8 +72,8 @@ public class GrepLogPlugin { bot.chat().tellraw( Component.translatable( "Collecting %s in logs...", - Component.text(query).color(NamedTextColor.GOLD) - ) + Component.text(query).color(ColorUtilities.getColorByString(bot.config().colorPalette().secondary())) + ).color(ColorUtilities.getColorByString(bot.config().colorPalette().defaultColor())) ); final File[] fileList = Logger.logDir.listFiles(); @@ -170,7 +171,7 @@ public class GrepLogPlugin { bot.chat().tellraw( Component.translatable( "Log query finished, found %s matches. Results were sent in Discord", - Component.text(matches).color(NamedTextColor.AQUA) + Component.text(matches).color(ColorUtilities.getColorByString(bot.config().colorPalette().number())) ) ); diff --git a/src/main/java/land/chipmunk/chayapak/chomens_bot/plugins/MazePlugin.java b/src/main/java/land/chipmunk/chayapak/chomens_bot/plugins/MazePlugin.java index a9128c8c..1bd89e2b 100644 --- a/src/main/java/land/chipmunk/chayapak/chomens_bot/plugins/MazePlugin.java +++ b/src/main/java/land/chipmunk/chayapak/chomens_bot/plugins/MazePlugin.java @@ -1,6 +1,7 @@ package land.chipmunk.chayapak.chomens_bot.plugins; import land.chipmunk.chayapak.chomens_bot.Bot; +import land.chipmunk.chayapak.chomens_bot.util.ColorUtilities; import land.chipmunk.chayapak.chomens_bot.util.MazeGenerator; import net.kyori.adventure.text.Component; import net.kyori.adventure.text.event.ClickEvent; @@ -18,10 +19,10 @@ public class MazePlugin { bot.chat().tellraw( Component.translatable( "Generating maze at %s %s %s...", - Component.text(startX).color(NamedTextColor.AQUA), - Component.text(startY).color(NamedTextColor.AQUA), - Component.text(startZ).color(NamedTextColor.AQUA) - ) + Component.text(startX).color(ColorUtilities.getColorByString(bot.config().colorPalette().number())), + Component.text(startY).color(ColorUtilities.getColorByString(bot.config().colorPalette().number())), + Component.text(startZ).color(ColorUtilities.getColorByString(bot.config().colorPalette().number())) + ).color(ColorUtilities.getColorByString(bot.config().colorPalette().defaultColor())) ); final int[][] maze = generator.maze(); @@ -168,6 +169,7 @@ public class MazePlugin { ) ) ) + .color(ColorUtilities.getColorByString(bot.config().colorPalette().defaultColor())) ); } } diff --git a/src/main/java/land/chipmunk/chayapak/chomens_bot/plugins/MusicPlayerPlugin.java b/src/main/java/land/chipmunk/chayapak/chomens_bot/plugins/MusicPlayerPlugin.java index cfd110b5..e9863fe6 100644 --- a/src/main/java/land/chipmunk/chayapak/chomens_bot/plugins/MusicPlayerPlugin.java +++ b/src/main/java/land/chipmunk/chayapak/chomens_bot/plugins/MusicPlayerPlugin.java @@ -6,6 +6,7 @@ import land.chipmunk.chayapak.chomens_bot.data.BossBar; import land.chipmunk.chayapak.chomens_bot.data.BossBarColor; import land.chipmunk.chayapak.chomens_bot.data.BossBarStyle; import land.chipmunk.chayapak.chomens_bot.song.*; +import land.chipmunk.chayapak.chomens_bot.util.ColorUtilities; import land.chipmunk.chayapak.chomens_bot.util.MathUtilities; import lombok.Getter; import lombok.Setter; @@ -18,7 +19,7 @@ import java.nio.file.Path; import java.text.DecimalFormat; import java.util.LinkedList; -// Author: _ChipMC_ with some stuff added +// Author: _ChipMC_ & chayapak <3 public class MusicPlayerPlugin extends Bot.Listener { private final Bot bot; @@ -59,7 +60,14 @@ public class MusicPlayerPlugin extends Bot.Listener { try { final SongLoaderThread _loaderThread = new SongLoaderThread(location, bot); - bot.chat().tellraw(Component.translatable("Loading %s", Component.text(location.getFileName().toString(), NamedTextColor.GOLD))); + bot.chat().tellraw( + Component + .translatable( + "Loading %s", + Component.text(location.getFileName().toString(), ColorUtilities.getColorByString(bot.config().colorPalette().secondary())) + ) + .color(ColorUtilities.getColorByString(bot.config().colorPalette().defaultColor())) + ); _loaderThread.start(); loaderThread = _loaderThread; } catch (SongLoaderException e) { @@ -77,7 +85,14 @@ public class MusicPlayerPlugin extends Bot.Listener { try { final SongLoaderThread _loaderThread = new SongLoaderThread(location, bot); - bot.chat().tellraw(Component.translatable("Loading %s", Component.text(location.toString(), NamedTextColor.GOLD))); + bot.chat().tellraw( + Component + .translatable( + "Loading %s", + Component.text(location.toString(), ColorUtilities.getColorByString(bot.config().colorPalette().secondary())) + ) + .color(ColorUtilities.getColorByString(bot.config().colorPalette().defaultColor())) + ); _loaderThread.start(); loaderThread = _loaderThread; } catch (SongLoaderException e) { @@ -95,7 +110,12 @@ public class MusicPlayerPlugin extends Bot.Listener { bot.chat().tellraw(Component.translatable("Failed to load song: %s", loaderThread.exception.message()).color(NamedTextColor.RED)); } else { songQueue.add(loaderThread.song); - bot.chat().tellraw(Component.translatable("Added %s to the song queue", Component.empty().append(loaderThread.song.name).color(NamedTextColor.GOLD))); + bot.chat().tellraw( + Component.translatable( + "Added %s to the song queue", + Component.empty().append(loaderThread.song.name).color(ColorUtilities.getColorByString(bot.config().colorPalette().secondary())) + ).color(ColorUtilities.getColorByString(bot.config().colorPalette().defaultColor())) + ); } loaderThread = null; } @@ -106,7 +126,12 @@ public class MusicPlayerPlugin extends Bot.Listener { addBossBar(); currentSong = songQueue.get(0); // songQueue.poll(); - bot.chat().tellraw(Component.translatable("Now playing %s", Component.empty().append(currentSong.name).color(NamedTextColor.GOLD))); + bot.chat().tellraw( + Component.translatable( + "Now playing %s", + Component.empty().append(currentSong.name).color(ColorUtilities.getColorByString(bot.config().colorPalette().secondary())) + ).color(ColorUtilities.getColorByString(bot.config().colorPalette().defaultColor())) + ); currentSong.play(); } @@ -135,7 +160,12 @@ public class MusicPlayerPlugin extends Bot.Listener { return; } - bot.chat().tellraw(Component.translatable("Finished playing %s", Component.empty().append(currentSong.name).color(NamedTextColor.GOLD))); + bot.chat().tellraw( + Component.translatable( + "Finished playing %s", + Component.empty().append(currentSong.name).color(ColorUtilities.getColorByString(bot.config().colorPalette().secondary())) + ).color(ColorUtilities.getColorByString(bot.config().colorPalette().defaultColor())) + ); if (loop == Loop.ALL) { skip(); @@ -147,7 +177,11 @@ public class MusicPlayerPlugin extends Bot.Listener { if (songQueue.size() == 0) { stopPlaying(); removeBossBar(); - bot.chat().tellraw(Component.text("Finished playing every song in the queue")); + bot.chat().tellraw( + Component + .text("Finished playing every song in the queue") + .color(ColorUtilities.getColorByString(bot.config().colorPalette().defaultColor())) + ); return; } if (currentSong.size() > 0) { diff --git a/src/main/java/land/chipmunk/chayapak/chomens_bot/plugins/TrustedPlugin.java b/src/main/java/land/chipmunk/chayapak/chomens_bot/plugins/TrustedPlugin.java index 1184a05c..e8466ca1 100644 --- a/src/main/java/land/chipmunk/chayapak/chomens_bot/plugins/TrustedPlugin.java +++ b/src/main/java/land/chipmunk/chayapak/chomens_bot/plugins/TrustedPlugin.java @@ -2,6 +2,7 @@ package land.chipmunk.chayapak.chomens_bot.plugins; import land.chipmunk.chayapak.chomens_bot.Bot; import land.chipmunk.chayapak.chomens_bot.data.chat.MutablePlayerListEntry; +import land.chipmunk.chayapak.chomens_bot.util.ColorUtilities; import lombok.Getter; import net.kyori.adventure.text.Component; import net.kyori.adventure.text.format.NamedTextColor; @@ -28,7 +29,7 @@ public class TrustedPlugin extends PlayersPlugin.Listener { final Component component = Component.translatable( "[%s] [%s] %s", - Component.text("ChomeNS Bot").color(NamedTextColor.YELLOW), + Component.text("ChomeNS Bot").color(ColorUtilities.getColorByString(bot.config().colorPalette().primary())), Component.text(this.bot.options().serverName()).color(NamedTextColor.GRAY), message.color(NamedTextColor.WHITE) ).color(NamedTextColor.DARK_GRAY); @@ -60,7 +61,7 @@ public class TrustedPlugin extends PlayersPlugin.Listener { bot.chat().tellraw( Component.empty() .append(Component.text("Hello, ").color(NamedTextColor.GREEN)) - .append(Component.text(target.profile().getName()).color(NamedTextColor.GOLD)) + .append(Component.text(target.profile().getName()).color(ColorUtilities.getColorByString(bot.config().colorPalette().username()))) .append(Component.text("!").color(NamedTextColor.GREEN)), target.profile().getId() ); @@ -81,8 +82,8 @@ public class TrustedPlugin extends PlayersPlugin.Listener { broadcast( Component.translatable( "Trusted player %s is now offline", - Component.text(target.profile().getName()).color(NamedTextColor.GREEN) - ) + Component.text(target.profile().getName()).color(ColorUtilities.getColorByString(bot.config().colorPalette().username())) + ).color(ColorUtilities.getColorByString(bot.config().colorPalette().defaultColor())) ); } } diff --git a/src/main/java/land/chipmunk/chayapak/chomens_bot/util/ColorUtilities.java b/src/main/java/land/chipmunk/chayapak/chomens_bot/util/ColorUtilities.java index 53a5dac5..5447a039 100644 --- a/src/main/java/land/chipmunk/chayapak/chomens_bot/util/ColorUtilities.java +++ b/src/main/java/land/chipmunk/chayapak/chomens_bot/util/ColorUtilities.java @@ -1,9 +1,39 @@ package land.chipmunk.chayapak.chomens_bot.util; +import net.kyori.adventure.text.format.NamedTextColor; +import net.kyori.adventure.text.format.TextColor; + import java.awt.*; -// Author: ChatGPT public class ColorUtilities { + public static TextColor getColorByString (String _color) { + final String color = _color.toLowerCase(); + + if (color.startsWith("#")) return TextColor.fromHexString(color); + else { + // am i reinventing the wheel here? + return switch (color) { + case "black" -> NamedTextColor.BLACK; + case "dark_blue" -> NamedTextColor.DARK_BLUE; + case "dark_green" -> NamedTextColor.DARK_GREEN; + case "dark_aqua" -> NamedTextColor.DARK_AQUA; + case "dark_red" -> NamedTextColor.DARK_RED; + case "dark_purple" -> NamedTextColor.DARK_PURPLE; + case "gold" -> NamedTextColor.GOLD; + case "gray" -> NamedTextColor.GRAY; + case "dark_gray" -> NamedTextColor.DARK_GRAY; + case "blue" -> NamedTextColor.BLUE; + case "green" -> NamedTextColor.GREEN; + case "aqua" -> NamedTextColor.AQUA; + case "red" -> NamedTextColor.RED; + case "light_purple" -> NamedTextColor.LIGHT_PURPLE; + case "yellow" -> NamedTextColor.YELLOW; + default -> NamedTextColor.WHITE; + }; + } + } + + // Author: ChatGPT public static int hsvToRgb (int hue, int saturation, int value) { Color color = Color.getHSBColor(hue / 360.0f, saturation / 100.0f, value / 100.0f); return color.getRGB() & 0xFFFFFF; diff --git a/src/main/resources/default-config.yml b/src/main/resources/default-config.yml index cdb6a315..4c654366 100644 --- a/src/main/resources/default-config.yml +++ b/src/main/resources/default-config.yml @@ -24,6 +24,16 @@ discord: servers: localhost:25565: 'channel id' +colorPalette: + primary: 'yellow' + secondary: 'gold' + defaultColor: 'white' # ig java has the `default` keyword so i need to use defaultColor + username: 'gold' + uuid: 'aqua' + string: 'aqua' + number: 'gold' + ownerName: 'green' + ownerName: 'chayapak' # currently this is only used in the console trusted: