diff --git a/build-number.txt b/build-number.txt index 1ead6050..45663c0b 100644 --- a/build-number.txt +++ b/build-number.txt @@ -1 +1 @@ -2393 \ No newline at end of file +2396 \ No newline at end of file diff --git a/src/main/java/me/chayapak1/chomens_bot/Bot.java b/src/main/java/me/chayapak1/chomens_bot/Bot.java index 81547f90..9dde67be 100644 --- a/src/main/java/me/chayapak1/chomens_bot/Bot.java +++ b/src/main/java/me/chayapak1/chomens_bot/Bot.java @@ -1,5 +1,6 @@ package me.chayapak1.chomens_bot; +import me.chayapak1.chomens_bot.data.color.ColorPalette; import me.chayapak1.chomens_bot.plugins.*; import me.chayapak1.chomens_bot.util.ComponentUtilities; import me.chayapak1.chomens_bot.util.RandomStringUtilities; @@ -48,6 +49,7 @@ public class Bot extends SessionAdapter { public final Configuration.BotOption options; public final Configuration config; + public final ColorPalette colorPalette; public final List bots; @@ -120,6 +122,7 @@ public class Bot extends SessionAdapter { this.bots = bots; this.config = config; + this.colorPalette = new ColorPalette(config.colorPalette); } public void connect () { @@ -158,7 +161,7 @@ public class Bot extends SessionAdapter { this.teamJoiner = new TeamJoinerPlugin(this); this.chomeNSMod = new ChomeNSModIntegrationPlugin(this); this.auth = new AuthPlugin(this); - // this.screenshare = new ScreensharePlugin(this); + // this.screenshare = new ScreensharePlugin(this); this.formatChecker = new FormatCheckerPlugin(this); this.clearChatNameAnnouncer = new ClearChatNameAnnouncerPlugin(this); this.whitelist = new WhitelistPlugin(this); diff --git a/src/main/java/me/chayapak1/chomens_bot/command/CommandContext.java b/src/main/java/me/chayapak1/chomens_bot/command/CommandContext.java index fd15dd1a..795f3b6b 100644 --- a/src/main/java/me/chayapak1/chomens_bot/command/CommandContext.java +++ b/src/main/java/me/chayapak1/chomens_bot/command/CommandContext.java @@ -2,7 +2,6 @@ package me.chayapak1.chomens_bot.command; import me.chayapak1.chomens_bot.Bot; import me.chayapak1.chomens_bot.data.player.PlayerEntry; -import me.chayapak1.chomens_bot.util.ColorUtilities; import net.kyori.adventure.text.Component; import net.kyori.adventure.text.event.ClickEvent; import net.kyori.adventure.text.format.NamedTextColor; @@ -109,7 +108,7 @@ public class CommandContext { .arguments( Component .text(greedyString) - .color(ColorUtilities.getColorByString(bot.config.colorPalette.string)), + .color(bot.colorPalette.string), Component .text(quote) .color(NamedTextColor.YELLOW) @@ -136,7 +135,7 @@ public class CommandContext { .arguments( Component .text(greedyString) - .color(ColorUtilities.getColorByString(bot.config.colorPalette.string)) + .color(bot.colorPalette.string) ) ); } diff --git a/src/main/java/me/chayapak1/chomens_bot/commands/BotVisibilityCommand.java b/src/main/java/me/chayapak1/chomens_bot/commands/BotVisibilityCommand.java index 4bc28395..84d0154b 100644 --- a/src/main/java/me/chayapak1/chomens_bot/commands/BotVisibilityCommand.java +++ b/src/main/java/me/chayapak1/chomens_bot/commands/BotVisibilityCommand.java @@ -5,7 +5,6 @@ import me.chayapak1.chomens_bot.command.Command; import me.chayapak1.chomens_bot.command.CommandContext; import me.chayapak1.chomens_bot.command.CommandException; import me.chayapak1.chomens_bot.command.TrustLevel; -import me.chayapak1.chomens_bot.util.ColorUtilities; import net.kyori.adventure.text.Component; import net.kyori.adventure.text.format.NamedTextColor; @@ -40,7 +39,7 @@ public class BotVisibilityCommand extends Command { return Component.empty() .append(Component.text("The bot's visibility is now ")) .append(Component.text(visibleOrInvisible).color(greenOrGold)) - .color(ColorUtilities.getColorByString(bot.config.colorPalette.defaultColor)); + .color(bot.colorPalette.defaultColor); } else { switch (action) { case "on", "true" -> { @@ -49,7 +48,7 @@ public class BotVisibilityCommand extends Command { return Component.empty() .append(Component.text("The bot's visibility is now ")) .append(Component.text("visible").color(NamedTextColor.GREEN)) - .color(ColorUtilities.getColorByString(bot.config.colorPalette.defaultColor)); + .color(bot.colorPalette.defaultColor); } case "off", "false" -> { bot.selfCare.visible = false; @@ -57,7 +56,7 @@ public class BotVisibilityCommand extends Command { return Component.empty() .append(Component.text("The bot's visibility is now ")) .append(Component.text("invisible").color(NamedTextColor.GOLD)) - .color(ColorUtilities.getColorByString(bot.config.colorPalette.defaultColor)); + .color(bot.colorPalette.defaultColor); } default -> throw new CommandException(Component.text("Invalid action")); } diff --git a/src/main/java/me/chayapak1/chomens_bot/commands/ClearChatQueueCommand.java b/src/main/java/me/chayapak1/chomens_bot/commands/ClearChatQueueCommand.java index 1f841f0a..e2ec37a9 100644 --- a/src/main/java/me/chayapak1/chomens_bot/commands/ClearChatQueueCommand.java +++ b/src/main/java/me/chayapak1/chomens_bot/commands/ClearChatQueueCommand.java @@ -5,7 +5,6 @@ import me.chayapak1.chomens_bot.command.Command; import me.chayapak1.chomens_bot.command.CommandContext; import me.chayapak1.chomens_bot.command.CommandException; import me.chayapak1.chomens_bot.command.TrustLevel; -import me.chayapak1.chomens_bot.util.ColorUtilities; import net.kyori.adventure.text.Component; public class ClearChatQueueCommand extends Command { @@ -30,6 +29,6 @@ public class ClearChatQueueCommand extends Command { return Component .text("Cleared the bot's chat queue") - .color(ColorUtilities.getColorByString(bot.config.colorPalette.defaultColor)); + .color(bot.colorPalette.defaultColor); } } diff --git a/src/main/java/me/chayapak1/chomens_bot/commands/CloopCommand.java b/src/main/java/me/chayapak1/chomens_bot/commands/CloopCommand.java index 54fc05e3..301211b2 100644 --- a/src/main/java/me/chayapak1/chomens_bot/commands/CloopCommand.java +++ b/src/main/java/me/chayapak1/chomens_bot/commands/CloopCommand.java @@ -6,7 +6,6 @@ import me.chayapak1.chomens_bot.command.CommandContext; import me.chayapak1.chomens_bot.command.CommandException; import me.chayapak1.chomens_bot.command.TrustLevel; import me.chayapak1.chomens_bot.data.cloop.CommandLoop; -import me.chayapak1.chomens_bot.util.ColorUtilities; import net.kyori.adventure.text.Component; import net.kyori.adventure.text.JoinConfiguration; import net.kyori.adventure.text.format.NamedTextColor; @@ -46,10 +45,10 @@ public class CloopCommand extends Command { return Component.translatable( "Added %s with interval %s %s to the cloops", - Component.text(command).color(ColorUtilities.getColorByString(bot.config.colorPalette.string)), - Component.text(interval).color(ColorUtilities.getColorByString(bot.config.colorPalette.number)), - Component.text(unit.toString()).color(ColorUtilities.getColorByString(bot.config.colorPalette.string)) - ).color(ColorUtilities.getColorByString(bot.config.colorPalette.defaultColor)); + Component.text(command).color(bot.colorPalette.string), + Component.text(interval).color(bot.colorPalette.number), + Component.text(unit.toString()).color(bot.colorPalette.string) + ).color(bot.colorPalette.defaultColor); } case "remove" -> { context.checkOverloadArgs(2); @@ -61,8 +60,8 @@ public class CloopCommand extends Command { return Component.translatable( "Removed cloop %s", - Component.text(cloop.command()).color(ColorUtilities.getColorByString(bot.config.colorPalette.string)) - ).color(ColorUtilities.getColorByString(bot.config.colorPalette.defaultColor)); + Component.text(cloop.command()).color(bot.colorPalette.string) + ).color(bot.colorPalette.defaultColor); } catch (IndexOutOfBoundsException | IllegalArgumentException | NullPointerException ignored) { throw new CommandException(Component.text("Invalid index")); } @@ -71,7 +70,7 @@ public class CloopCommand extends Command { context.checkOverloadArgs(1); bot.cloop.clear(); - return Component.text("Cleared all cloops").color(ColorUtilities.getColorByString(bot.config.colorPalette.defaultColor)); + return Component.text("Cleared all cloops").color(bot.colorPalette.defaultColor); } case "list" -> { context.checkOverloadArgs(1); @@ -83,10 +82,10 @@ public class CloopCommand extends Command { cloopsComponent.add( Component.translatable( "%s › %s (%s %s)", - 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)), - Component.text(command.unit().toString()).color(ColorUtilities.getColorByString(bot.config.colorPalette.string)) + Component.text(index).color(bot.colorPalette.number), + Component.text(command.command()).color(bot.colorPalette.string), + Component.text(command.interval()).color(bot.colorPalette.number), + Component.text(command.unit().toString()).color(bot.colorPalette.string) ).color(NamedTextColor.DARK_GRAY) ); index++; diff --git a/src/main/java/me/chayapak1/chomens_bot/commands/CommandBlockCommand.java b/src/main/java/me/chayapak1/chomens_bot/commands/CommandBlockCommand.java index 9513a54c..b1d4f862 100644 --- a/src/main/java/me/chayapak1/chomens_bot/commands/CommandBlockCommand.java +++ b/src/main/java/me/chayapak1/chomens_bot/commands/CommandBlockCommand.java @@ -6,7 +6,6 @@ import me.chayapak1.chomens_bot.command.CommandContext; import me.chayapak1.chomens_bot.command.CommandException; import me.chayapak1.chomens_bot.command.TrustLevel; import me.chayapak1.chomens_bot.data.player.PlayerEntry; -import me.chayapak1.chomens_bot.util.ColorUtilities; import net.kyori.adventure.text.Component; import net.kyori.adventure.text.event.ClickEvent; import net.kyori.adventure.text.event.HoverEvent; @@ -126,7 +125,7 @@ public class CommandBlockCommand extends Command { .append( Component .text(player.profile.getIdAsString()) - .color(ColorUtilities.getColorByString(bot.config.colorPalette.uuid)) + .color(bot.colorPalette.uuid) ) .append(Component.newline()) .append(Component.text("Click to copy the username to your clipboard").color(NamedTextColor.GREEN)) diff --git a/src/main/java/me/chayapak1/chomens_bot/commands/ConsoleCommand.java b/src/main/java/me/chayapak1/chomens_bot/commands/ConsoleCommand.java index a7dec2ed..4248f7ef 100644 --- a/src/main/java/me/chayapak1/chomens_bot/commands/ConsoleCommand.java +++ b/src/main/java/me/chayapak1/chomens_bot/commands/ConsoleCommand.java @@ -6,7 +6,6 @@ import me.chayapak1.chomens_bot.command.Command; import me.chayapak1.chomens_bot.command.CommandContext; import me.chayapak1.chomens_bot.command.CommandException; import me.chayapak1.chomens_bot.command.TrustLevel; -import me.chayapak1.chomens_bot.util.ColorUtilities; import net.kyori.adventure.text.Component; import net.kyori.adventure.text.format.NamedTextColor; @@ -49,7 +48,7 @@ public class ConsoleCommand extends Command { Main.console.consoleServer = "all"; return Component.text( "Set the console server to all servers" - ).color(ColorUtilities.getColorByString(bot.config.colorPalette.defaultColor)); + ).color(bot.colorPalette.defaultColor); } try { @@ -62,7 +61,7 @@ public class ConsoleCommand extends Command { return Component.translatable( "Set the console server to %s", Component.text(Main.console.consoleServer) - ).color(ColorUtilities.getColorByString(bot.config.colorPalette.defaultColor)); + ).color(bot.colorPalette.defaultColor); } catch (ArrayIndexOutOfBoundsException e) { throw new CommandException(Component.text("Invalid server: " + server)); } @@ -77,7 +76,7 @@ public class ConsoleCommand extends Command { return Component.translatable( "Logging to console is now %s", bool ? Component.text("enabled").color(NamedTextColor.GREEN) : Component.text("disabled").color(NamedTextColor.RED) - ).color(ColorUtilities.getColorByString(bot.config.colorPalette.defaultColor)); + ).color(bot.colorPalette.defaultColor); } case "printdisconnectedreason" -> { context.checkOverloadArgs(2); @@ -89,7 +88,7 @@ public class ConsoleCommand extends Command { return Component.translatable( "Printing the disconnected cause is now %s", bool ? Component.text("enabled").color(NamedTextColor.GREEN) : Component.text("disabled").color(NamedTextColor.RED) - ).color(ColorUtilities.getColorByString(bot.config.colorPalette.defaultColor)); + ).color(bot.colorPalette.defaultColor); } } diff --git a/src/main/java/me/chayapak1/chomens_bot/commands/EvalCommand.java b/src/main/java/me/chayapak1/chomens_bot/commands/EvalCommand.java index 53ed835d..79a68ea1 100644 --- a/src/main/java/me/chayapak1/chomens_bot/commands/EvalCommand.java +++ b/src/main/java/me/chayapak1/chomens_bot/commands/EvalCommand.java @@ -6,7 +6,6 @@ import me.chayapak1.chomens_bot.command.CommandContext; import me.chayapak1.chomens_bot.command.CommandException; import me.chayapak1.chomens_bot.command.TrustLevel; import me.chayapak1.chomens_bot.data.eval.EvalOutput; -import me.chayapak1.chomens_bot.util.ColorUtilities; import net.kyori.adventure.text.Component; import net.kyori.adventure.text.format.NamedTextColor; @@ -48,7 +47,7 @@ public class EvalCommand extends Command { case "reset" -> { bot.eval.reset(); - return Component.text("Reset the eval worker").color(ColorUtilities.getColorByString(bot.config.colorPalette.defaultColor)); + return Component.text("Reset the eval worker").color(bot.colorPalette.defaultColor); } default -> throw new CommandException(Component.text("Invalid action")); } diff --git a/src/main/java/me/chayapak1/chomens_bot/commands/FilterCommand.java b/src/main/java/me/chayapak1/chomens_bot/commands/FilterCommand.java index 077ff4e5..1a00f2c5 100644 --- a/src/main/java/me/chayapak1/chomens_bot/commands/FilterCommand.java +++ b/src/main/java/me/chayapak1/chomens_bot/commands/FilterCommand.java @@ -8,7 +8,6 @@ import me.chayapak1.chomens_bot.command.TrustLevel; import me.chayapak1.chomens_bot.data.filter.FilteredPlayer; import me.chayapak1.chomens_bot.plugins.DatabasePlugin; import me.chayapak1.chomens_bot.plugins.PlayerFilterPlugin; -import me.chayapak1.chomens_bot.util.ColorUtilities; import net.kyori.adventure.text.Component; import net.kyori.adventure.text.JoinConfiguration; import net.kyori.adventure.text.format.NamedTextColor; @@ -83,14 +82,14 @@ public class FilterCommand extends Command { if (reason.isEmpty()) { return Component.translatable( "Added %s to the filters", - Component.text(player).color(ColorUtilities.getColorByString(bot.config.colorPalette.username)) - ).color(ColorUtilities.getColorByString(bot.config.colorPalette.defaultColor)); + Component.text(player).color(bot.colorPalette.username) + ).color(bot.colorPalette.defaultColor); } else { return Component.translatable( "Added %s to the filters with reason %s", - Component.text(player).color(ColorUtilities.getColorByString(bot.config.colorPalette.username)), - Component.text(reason).color(ColorUtilities.getColorByString(bot.config.colorPalette.string)) - ).color(ColorUtilities.getColorByString(bot.config.colorPalette.defaultColor)); + Component.text(player).color(bot.colorPalette.username), + Component.text(reason).color(bot.colorPalette.string) + ).color(bot.colorPalette.defaultColor); } } case "remove" -> { @@ -106,14 +105,14 @@ public class FilterCommand extends Command { return Component.translatable( "Removed %s from the filters", - Component.text(player.playerName).color(ColorUtilities.getColorByString(bot.config.colorPalette.username)) - ).color(ColorUtilities.getColorByString(bot.config.colorPalette.defaultColor)); + Component.text(player.playerName).color(bot.colorPalette.username) + ).color(bot.colorPalette.defaultColor); } case "clear" -> { context.checkOverloadArgs(1); DatabasePlugin.EXECUTOR_SERVICE.submit(() -> bot.playerFilter.clear()); - return Component.text("Cleared the filter").color(ColorUtilities.getColorByString(bot.config.colorPalette.defaultColor)); + return Component.text("Cleared the filter").color(bot.colorPalette.defaultColor); } case "list" -> { context.checkOverloadArgs(1); @@ -138,7 +137,7 @@ public class FilterCommand extends Command { JoinConfiguration.commas(true), args ) - .color(ColorUtilities.getColorByString(bot.config.colorPalette.string)) + .color(bot.colorPalette.string) ) .append(Component.text(")")) .append(Component.space()); @@ -151,7 +150,7 @@ public class FilterCommand extends Command { .append( Component .text(player.reason) - .color(ColorUtilities.getColorByString(bot.config.colorPalette.string)) + .color(bot.colorPalette.string) ) .append(Component.text(")")); } @@ -159,8 +158,8 @@ public class FilterCommand extends Command { filtersComponents.add( Component.translatable( "%s › %s %s", - Component.text(index).color(ColorUtilities.getColorByString(bot.config.colorPalette.number)), - Component.text(player.playerName).color(ColorUtilities.getColorByString(bot.config.colorPalette.username)), + Component.text(index).color(bot.colorPalette.number), + Component.text(player.playerName).color(bot.colorPalette.username), options ).color(NamedTextColor.DARK_GRAY) ); diff --git a/src/main/java/me/chayapak1/chomens_bot/commands/FindAltsCommand.java b/src/main/java/me/chayapak1/chomens_bot/commands/FindAltsCommand.java index 82681368..5eea8c12 100644 --- a/src/main/java/me/chayapak1/chomens_bot/commands/FindAltsCommand.java +++ b/src/main/java/me/chayapak1/chomens_bot/commands/FindAltsCommand.java @@ -8,7 +8,6 @@ import me.chayapak1.chomens_bot.command.CommandContext; import me.chayapak1.chomens_bot.command.CommandException; import me.chayapak1.chomens_bot.command.TrustLevel; import me.chayapak1.chomens_bot.data.player.PlayerEntry; -import me.chayapak1.chomens_bot.util.ColorUtilities; import net.kyori.adventure.text.Component; import java.util.List; @@ -83,11 +82,11 @@ public class FindAltsCommand extends Command { final Component playerComponent = Component .text(player) - .color(ColorUtilities.getColorByString(bot.config.colorPalette.username)); + .color(bot.colorPalette.username); Component component = Component .translatable("Possible alts for the %s %s:") - .color(ColorUtilities.getColorByString(bot.config.colorPalette.defaultColor)) + .color(bot.colorPalette.defaultColor) .arguments( Component.text(argumentIsIP ? "IP" : "player"), argumentIsIP ? @@ -97,7 +96,7 @@ public class FindAltsCommand extends Command { playerComponent, Component .text(targetIP) - .color(ColorUtilities.getColorByString(bot.config.colorPalette.number)) + .color(bot.colorPalette.number) ) ) .appendNewline(); @@ -127,7 +126,7 @@ public class FindAltsCommand extends Command { .append( Component .text(username) - .color((i++ & 1) == 0 ? ColorUtilities.getColorByString(bot.config.colorPalette.primary) : ColorUtilities.getColorByString(bot.config.colorPalette.secondary)) + .color((i++ & 1) == 0 ? bot.colorPalette.primary : bot.colorPalette.secondary) ) .appendSpace(); } diff --git a/src/main/java/me/chayapak1/chomens_bot/commands/GrepLogCommand.java b/src/main/java/me/chayapak1/chomens_bot/commands/GrepLogCommand.java index c02dde87..ad622710 100644 --- a/src/main/java/me/chayapak1/chomens_bot/commands/GrepLogCommand.java +++ b/src/main/java/me/chayapak1/chomens_bot/commands/GrepLogCommand.java @@ -6,7 +6,6 @@ import me.chayapak1.chomens_bot.command.Command; import me.chayapak1.chomens_bot.command.CommandContext; import me.chayapak1.chomens_bot.command.CommandException; import me.chayapak1.chomens_bot.command.TrustLevel; -import me.chayapak1.chomens_bot.util.ColorUtilities; import net.kyori.adventure.text.Component; import net.kyori.adventure.text.format.NamedTextColor; @@ -61,7 +60,7 @@ public class GrepLogCommand extends Command { thread = null; - return Component.text("Stopped querying the logs").color(ColorUtilities.getColorByString(bot.config.colorPalette.defaultColor)); + return Component.text("Stopped querying the logs").color(bot.colorPalette.defaultColor); } if (thread != null) throw new CommandException(Component.text("Another query is already running")); @@ -69,11 +68,11 @@ public class GrepLogCommand extends Command { context.sendOutput( Component .translatable("Started querying the logs for %s") - .color(ColorUtilities.getColorByString(bot.config.colorPalette.defaultColor)) + .color(bot.colorPalette.defaultColor) .arguments( Component .text(input) - .color(ColorUtilities.getColorByString(bot.config.colorPalette.string)) + .color(bot.colorPalette.string) ) ); diff --git a/src/main/java/me/chayapak1/chomens_bot/commands/HelpCommand.java b/src/main/java/me/chayapak1/chomens_bot/commands/HelpCommand.java index 6cdce578..fb851397 100644 --- a/src/main/java/me/chayapak1/chomens_bot/commands/HelpCommand.java +++ b/src/main/java/me/chayapak1/chomens_bot/commands/HelpCommand.java @@ -7,7 +7,6 @@ import me.chayapak1.chomens_bot.command.CommandException; import me.chayapak1.chomens_bot.command.TrustLevel; import me.chayapak1.chomens_bot.command.contexts.ConsoleCommandContext; import me.chayapak1.chomens_bot.plugins.CommandHandlerPlugin; -import me.chayapak1.chomens_bot.util.ColorUtilities; import net.kyori.adventure.text.Component; import net.kyori.adventure.text.JoinConfiguration; import net.kyori.adventure.text.event.ClickEvent; @@ -119,7 +118,7 @@ public class HelpCommand extends Command { usages.add( Component.empty() - .append(Component.text(prefix + actualCommandName).color(ColorUtilities.getColorByString(bot.config.colorPalette.secondary))) + .append(Component.text(prefix + actualCommandName).color(bot.colorPalette.secondary)) .append(Component.text( (command.aliases.length > 0 && !command.aliases[0].isEmpty()) ? " (" + String.join(", ", command.aliases) + ")" : @@ -140,10 +139,10 @@ public class HelpCommand extends Command { for (String usage : command.usages) { Component usageComponent = Component.empty() - .append(Component.text(prefix + actualCommandName).color(ColorUtilities.getColorByString(bot.config.colorPalette.secondary))) + .append(Component.text(prefix + actualCommandName).color(bot.colorPalette.secondary)) .append(Component.text(" ")); - usageComponent = usageComponent.append(Component.text(usage).color(ColorUtilities.getColorByString(bot.config.colorPalette.string))); + usageComponent = usageComponent.append(Component.text(usage).color(bot.colorPalette.string)); usages.add(usageComponent); } diff --git a/src/main/java/me/chayapak1/chomens_bot/commands/IPFilterCommand.java b/src/main/java/me/chayapak1/chomens_bot/commands/IPFilterCommand.java index 154131c3..132e79c3 100644 --- a/src/main/java/me/chayapak1/chomens_bot/commands/IPFilterCommand.java +++ b/src/main/java/me/chayapak1/chomens_bot/commands/IPFilterCommand.java @@ -7,7 +7,6 @@ import me.chayapak1.chomens_bot.command.CommandException; import me.chayapak1.chomens_bot.command.TrustLevel; import me.chayapak1.chomens_bot.plugins.DatabasePlugin; import me.chayapak1.chomens_bot.plugins.IPFilterPlugin; -import me.chayapak1.chomens_bot.util.ColorUtilities; import net.kyori.adventure.text.Component; import net.kyori.adventure.text.JoinConfiguration; import net.kyori.adventure.text.format.NamedTextColor; @@ -59,14 +58,14 @@ public class IPFilterCommand extends Command { if (reason.isEmpty()) { return Component.translatable( "Added %s to the filters", - Component.text(ip).color(ColorUtilities.getColorByString(bot.config.colorPalette.number)) - ).color(ColorUtilities.getColorByString(bot.config.colorPalette.defaultColor)); + Component.text(ip).color(bot.colorPalette.number) + ).color(bot.colorPalette.defaultColor); } else { return Component.translatable( "Added %s to the filters with reason %s", - Component.text(ip).color(ColorUtilities.getColorByString(bot.config.colorPalette.number)), - Component.text(reason).color(ColorUtilities.getColorByString(bot.config.colorPalette.string)) - ).color(ColorUtilities.getColorByString(bot.config.colorPalette.defaultColor)); + Component.text(ip).color(bot.colorPalette.number), + Component.text(reason).color(bot.colorPalette.string) + ).color(bot.colorPalette.defaultColor); } } case "remove" -> { @@ -82,14 +81,14 @@ public class IPFilterCommand extends Command { return Component.translatable( "Removed %s from the filters", - Component.text(targetIP).color(ColorUtilities.getColorByString(bot.config.colorPalette.number)) - ).color(ColorUtilities.getColorByString(bot.config.colorPalette.defaultColor)); + Component.text(targetIP).color(bot.colorPalette.number) + ).color(bot.colorPalette.defaultColor); } case "clear" -> { context.checkOverloadArgs(1); DatabasePlugin.EXECUTOR_SERVICE.submit(() -> bot.ipFilter.clear()); - return Component.text("Cleared the filter").color(ColorUtilities.getColorByString(bot.config.colorPalette.defaultColor)); + return Component.text("Cleared the filter").color(bot.colorPalette.defaultColor); } case "list" -> { context.checkOverloadArgs(1); @@ -110,7 +109,7 @@ public class IPFilterCommand extends Command { .append( Component .text(reason) - .color(ColorUtilities.getColorByString(bot.config.colorPalette.string)) + .color(bot.colorPalette.string) ) .append(Component.text(")")); } @@ -118,8 +117,8 @@ public class IPFilterCommand extends Command { filtersComponents.add( Component.translatable( "%s › %s %s", - Component.text(index).color(ColorUtilities.getColorByString(bot.config.colorPalette.number)), - Component.text(ip).color(ColorUtilities.getColorByString(bot.config.colorPalette.username)), + Component.text(index).color(bot.colorPalette.number), + Component.text(ip).color(bot.colorPalette.username), reasonComponent ).color(NamedTextColor.DARK_GRAY) ); diff --git a/src/main/java/me/chayapak1/chomens_bot/commands/InfoCommand.java b/src/main/java/me/chayapak1/chomens_bot/commands/InfoCommand.java index 383822a6..e30a8cef 100644 --- a/src/main/java/me/chayapak1/chomens_bot/commands/InfoCommand.java +++ b/src/main/java/me/chayapak1/chomens_bot/commands/InfoCommand.java @@ -5,7 +5,6 @@ import me.chayapak1.chomens_bot.command.Command; import me.chayapak1.chomens_bot.command.CommandContext; import me.chayapak1.chomens_bot.command.CommandException; import me.chayapak1.chomens_bot.command.TrustLevel; -import me.chayapak1.chomens_bot.util.ColorUtilities; import me.chayapak1.chomens_bot.util.StringUtilities; import net.kyori.adventure.text.Component; import net.kyori.adventure.text.event.ClickEvent; @@ -77,14 +76,14 @@ public class InfoCommand extends Command { switch (action) { case "creator" -> { return Component.empty() - .append(Component.text("ChomeNS Bot ").color(ColorUtilities.getColorByString(bot.config.colorPalette.primary))) - .append(Component.text("is created by ").color(ColorUtilities.getColorByString(bot.config.colorPalette.defaultColor))) - .append(Component.text("chayapak").color(ColorUtilities.getColorByString(bot.config.colorPalette.ownerName))); + .append(Component.text("ChomeNS Bot ").color(bot.colorPalette.primary)) + .append(Component.text("is created by ").color(bot.colorPalette.defaultColor)) + .append(Component.text("chayapak").color(bot.colorPalette.ownerName)); } case "discord" -> { final String link = bot.config.discord.inviteLink; return Component.empty() - .append(Component.text("The Discord invite is ").color(ColorUtilities.getColorByString(bot.config.colorPalette.defaultColor))) + .append(Component.text("The Discord invite is ").color(bot.colorPalette.defaultColor)) .append( Component .text(link) @@ -123,7 +122,7 @@ public class InfoCommand extends Command { file.close(); } catch (IOException ignored) { } - final TextColor color = ColorUtilities.getColorByString(bot.config.colorPalette.string); + final TextColor color = bot.colorPalette.string; final String[] lines = builder.toString().split("\n"); final Optional modelName = Arrays.stream(lines) @@ -171,7 +170,7 @@ public class InfoCommand extends Command { Component.text((Runtime.getRuntime().totalMemory() - Runtime.getRuntime().freeMemory()) / 1024L / 1024L), Component.text(Runtime.getRuntime().totalMemory() / 1024L / 1024L) ).color(color) - ).color(ColorUtilities.getColorByString(bot.config.colorPalette.secondary)); + ).color(bot.colorPalette.secondary); return component; } @@ -193,7 +192,7 @@ public class InfoCommand extends Command { .clickEvent( ClickEvent.copyToClipboard(username) ) - .color(ColorUtilities.getColorByString(bot.config.colorPalette.username)), + .color(bot.colorPalette.username), Component .text(uuid) .hoverEvent( @@ -206,8 +205,8 @@ public class InfoCommand extends Command { .clickEvent( ClickEvent.copyToClipboard(uuid) ) - .color(ColorUtilities.getColorByString(bot.config.colorPalette.uuid)) - ).color(ColorUtilities.getColorByString(bot.config.colorPalette.defaultColor)); + .color(bot.colorPalette.uuid) + ).color(bot.colorPalette.defaultColor); } case "botlogintime" -> { final long loginTime = bot.loginTime; @@ -227,11 +226,11 @@ public class InfoCommand extends Command { "The bots login time is %s and has been on the server for %s", Component .text(formattedLoginTime) - .color(ColorUtilities.getColorByString(bot.config.colorPalette.string)), + .color(bot.colorPalette.string), Component .text(formattedTimeSince) - .color(ColorUtilities.getColorByString(bot.config.colorPalette.string)) - ).color(ColorUtilities.getColorByString(bot.config.colorPalette.defaultColor)); + .color(bot.colorPalette.string) + ).color(bot.colorPalette.defaultColor); } case "uptime" -> { final long uptime = ManagementFactory.getRuntimeMXBean().getUptime() / 1000; @@ -254,11 +253,11 @@ public class InfoCommand extends Command { Component.text(seconds), Component.text(StringUtilities.addPluralS(seconds, "second")) ).color(NamedTextColor.GREEN) - ).color(ColorUtilities.getColorByString(bot.config.colorPalette.defaultColor)); + ).color(bot.colorPalette.defaultColor); } default -> { return Component.empty() - .color(ColorUtilities.getColorByString(bot.config.colorPalette.defaultColor)) + .color(bot.colorPalette.defaultColor) .append(Component.text("ChomeNS Bot").color(NamedTextColor.YELLOW)) .append(Component.space()) .append( @@ -277,7 +276,7 @@ public class InfoCommand extends Command { .append( Component .text(ORIGINAL_REPOSITORY_URL) - .color(ColorUtilities.getColorByString(bot.config.colorPalette.string)) + .color(bot.colorPalette.string) .clickEvent( ClickEvent.openUrl(ORIGINAL_REPOSITORY_URL) ) @@ -287,7 +286,7 @@ public class InfoCommand extends Command { .append( Component .text(BUILD_INFO.getProperty("build.date", "unknown")) - .color(ColorUtilities.getColorByString(bot.config.colorPalette.string)) + .color(bot.colorPalette.string) ) .append( Component @@ -295,10 +294,10 @@ public class InfoCommand extends Command { ", Git commit %s (%s)", Component .text(BUILD_INFO.getProperty("build.git.commit.hash", "unknown")) - .color(ColorUtilities.getColorByString(bot.config.colorPalette.string)), + .color(bot.colorPalette.string), Component .text(BUILD_INFO.getProperty("build.git.commit.count", "unknown")) - .color(ColorUtilities.getColorByString(bot.config.colorPalette.number)) + .color(bot.colorPalette.number) ) ) .append(Component.newline()) @@ -308,7 +307,7 @@ public class InfoCommand extends Command { "Build %s", Component .text(BUILD_INFO.getProperty("build.number", "unknown")) - .color(ColorUtilities.getColorByString(bot.config.colorPalette.number)) + .color(bot.colorPalette.number) ) ); } diff --git a/src/main/java/me/chayapak1/chomens_bot/commands/KickCommand.java b/src/main/java/me/chayapak1/chomens_bot/commands/KickCommand.java index 02dfae73..34562f12 100644 --- a/src/main/java/me/chayapak1/chomens_bot/commands/KickCommand.java +++ b/src/main/java/me/chayapak1/chomens_bot/commands/KickCommand.java @@ -7,7 +7,6 @@ import me.chayapak1.chomens_bot.command.CommandException; import me.chayapak1.chomens_bot.command.TrustLevel; import me.chayapak1.chomens_bot.data.exploitMethods.Kick; import me.chayapak1.chomens_bot.data.player.PlayerEntry; -import me.chayapak1.chomens_bot.util.ColorUtilities; import net.kyori.adventure.text.Component; import java.util.Arrays; @@ -47,11 +46,11 @@ public class KickCommand extends Command { return Component.empty() .append(Component.text("Kicking player")) .append(Component.space()) - .append(Component.text(name).color(ColorUtilities.getColorByString(bot.config.colorPalette.username))) + .append(Component.text(name).color(bot.colorPalette.username)) .append(Component.space()) .append(Component.text("with method")) .append(Component.space()) - .append(Component.text(method.name()).color(ColorUtilities.getColorByString(bot.config.colorPalette.string))) - .color(ColorUtilities.getColorByString(bot.config.colorPalette.defaultColor)); + .append(Component.text(method.name()).color(bot.colorPalette.string)) + .color(bot.colorPalette.defaultColor); } } diff --git a/src/main/java/me/chayapak1/chomens_bot/commands/ListCommand.java b/src/main/java/me/chayapak1/chomens_bot/commands/ListCommand.java index a365b205..e461df7f 100644 --- a/src/main/java/me/chayapak1/chomens_bot/commands/ListCommand.java +++ b/src/main/java/me/chayapak1/chomens_bot/commands/ListCommand.java @@ -6,7 +6,6 @@ import me.chayapak1.chomens_bot.command.CommandContext; import me.chayapak1.chomens_bot.command.CommandException; import me.chayapak1.chomens_bot.command.TrustLevel; import me.chayapak1.chomens_bot.data.player.PlayerEntry; -import me.chayapak1.chomens_bot.util.ColorUtilities; import net.kyori.adventure.text.Component; import net.kyori.adventure.text.JoinConfiguration; import net.kyori.adventure.text.event.ClickEvent; @@ -54,7 +53,7 @@ public class ListCommand extends Command { final Component hoverEvent = Component .text(entry.profile.getName()) .append(Component.newline()) - .append(Component.text(entry.profile.getIdAsString()).color(ColorUtilities.getColorByString(bot.config.colorPalette.uuid))) + .append(Component.text(entry.profile.getIdAsString()).color(bot.colorPalette.uuid)) .append(Component.newline()) .append(Component.newline()) .append( @@ -72,8 +71,8 @@ public class ListCommand extends Command { .map(Component::text) .toList() ) - .color(ColorUtilities.getColorByString(bot.config.colorPalette.string)) - ).color(ColorUtilities.getColorByString(bot.config.colorPalette.secondary)) + .color(bot.colorPalette.string) + ).color(bot.colorPalette.secondary) ) .append(Component.newline()) .append( @@ -81,8 +80,8 @@ public class ListCommand extends Command { "Vanished: %s", Component .text(!entry.listed) - .color(ColorUtilities.getColorByString(bot.config.colorPalette.string)) - ).color(ColorUtilities.getColorByString(bot.config.colorPalette.secondary)) + .color(bot.colorPalette.string) + ).color(bot.colorPalette.secondary) ) .append(Component.newline()) .append( @@ -91,8 +90,8 @@ public class ListCommand extends Command { Component .text(entry.latency) .append(Component.text("ms")) - .color(ColorUtilities.getColorByString(bot.config.colorPalette.string)) // using number color palette will not blend in (GOLD) - ).color(ColorUtilities.getColorByString(bot.config.colorPalette.secondary)) + .color(bot.colorPalette.string) // using number color palette will not blend in (GOLD) + ).color(bot.colorPalette.secondary) ) .append(Component.newline()) .append( @@ -100,8 +99,8 @@ public class ListCommand extends Command { "Game Mode: %s", Component .text(entry.gamemode.name()) - .color(ColorUtilities.getColorByString(bot.config.colorPalette.string)) - ).color(ColorUtilities.getColorByString(bot.config.colorPalette.secondary)) + .color(bot.colorPalette.string) + ).color(bot.colorPalette.secondary) ) .append(Component.newline()) .append(Component.newline()) @@ -125,7 +124,7 @@ public class ListCommand extends Command { .clickEvent( ClickEvent.copyToClipboard(entry.profile.getIdAsString()) ) - .color(ColorUtilities.getColorByString(bot.config.colorPalette.uuid)) + .color(bot.colorPalette.uuid) ) .hoverEvent( HoverEvent.showText(hoverEvent) diff --git a/src/main/java/me/chayapak1/chomens_bot/commands/MailCommand.java b/src/main/java/me/chayapak1/chomens_bot/commands/MailCommand.java index 51ff7aae..73c24d0a 100644 --- a/src/main/java/me/chayapak1/chomens_bot/commands/MailCommand.java +++ b/src/main/java/me/chayapak1/chomens_bot/commands/MailCommand.java @@ -9,7 +9,6 @@ import me.chayapak1.chomens_bot.command.TrustLevel; import me.chayapak1.chomens_bot.data.mail.Mail; import me.chayapak1.chomens_bot.data.player.PlayerEntry; import me.chayapak1.chomens_bot.plugins.DatabasePlugin; -import me.chayapak1.chomens_bot.util.ColorUtilities; import net.kyori.adventure.text.Component; import net.kyori.adventure.text.JoinConfiguration; import net.kyori.adventure.text.event.HoverEvent; @@ -63,7 +62,7 @@ public class MailCommand extends Command { ) ); - context.sendOutput(Component.text("Mail sent!").color(ColorUtilities.getColorByString(bot.config.colorPalette.defaultColor))); + context.sendOutput(Component.text("Mail sent!").color(bot.colorPalette.defaultColor)); } catch (CommandException e) { context.sendOutput(e.message.color(NamedTextColor.RED)); } @@ -95,7 +94,7 @@ public class MailCommand extends Command { ); context.sendOutput( - Component.text("Mail sent!").color(ColorUtilities.getColorByString(bot.config.colorPalette.defaultColor)) + Component.text("Mail sent!").color(bot.colorPalette.defaultColor) ); } catch (CommandException e) { context.sendOutput(e.message.color(NamedTextColor.RED)); @@ -146,10 +145,10 @@ public class MailCommand extends Command { %s %s Sent by: %s %s Contents: %s""", - Component.text(count).color(ColorUtilities.getColorByString(bot.config.colorPalette.number)), + Component.text(count).color(bot.colorPalette.number), Component.text("-").color(NamedTextColor.DARK_GRAY), - Component.text(mail.sentBy()).color(ColorUtilities.getColorByString(bot.config.colorPalette.username)), + Component.text(mail.sentBy()).color(bot.colorPalette.username), Component .text("[Hover here for more info]") .color(NamedTextColor.GREEN) @@ -159,8 +158,8 @@ public class MailCommand extends Command { """ Time sent: %s Server: %s""", - Component.text(formattedTime).color(ColorUtilities.getColorByString(bot.config.colorPalette.string)), - Component.text(mail.server()).color(ColorUtilities.getColorByString(bot.config.colorPalette.string)) + Component.text(formattedTime).color(bot.colorPalette.string), + Component.text(mail.server()).color(bot.colorPalette.string) ).color(NamedTextColor.GREEN) ) ), diff --git a/src/main/java/me/chayapak1/chomens_bot/commands/MusicCommand.java b/src/main/java/me/chayapak1/chomens_bot/commands/MusicCommand.java index f1d5db3f..8c1097b5 100644 --- a/src/main/java/me/chayapak1/chomens_bot/commands/MusicCommand.java +++ b/src/main/java/me/chayapak1/chomens_bot/commands/MusicCommand.java @@ -12,7 +12,6 @@ import me.chayapak1.chomens_bot.song.Loop; import me.chayapak1.chomens_bot.song.Note; import me.chayapak1.chomens_bot.song.Song; import me.chayapak1.chomens_bot.util.Ascii85; -import me.chayapak1.chomens_bot.util.ColorUtilities; import me.chayapak1.chomens_bot.util.PathUtilities; import me.chayapak1.chomens_bot.util.TimestampUtilities; import net.kyori.adventure.text.Component; @@ -226,7 +225,7 @@ public class MusicCommand extends Command { bot.music.songQueue.clear(); bot.music.loaderThread = null; - return Component.text("Cleared the song queue").color(ColorUtilities.getColorByString(bot.config.colorPalette.defaultColor)); + return Component.text("Cleared the song queue").color(bot.colorPalette.defaultColor); } public Component loop (CommandContext context) throws CommandException { @@ -243,22 +242,22 @@ public class MusicCommand extends Command { return Component.empty() .append(Component.text("Looping is now ")) .append(Component.text("disabled").color(NamedTextColor.RED)) - .color(ColorUtilities.getColorByString(bot.config.colorPalette.defaultColor)); + .color(bot.colorPalette.defaultColor); } case CURRENT -> { if (bot.music.currentSong != null) { return Component.empty() .append(Component.text("Now looping ")) - .append(Component.text(bot.music.currentSong.name).color(ColorUtilities.getColorByString(bot.config.colorPalette.secondary))) - .color(ColorUtilities.getColorByString(bot.config.colorPalette.defaultColor)); + .append(Component.text(bot.music.currentSong.name).color(bot.colorPalette.secondary)) + .color(bot.colorPalette.defaultColor); } else { return Component.empty() .append(Component.text("Will now loop the next song")) - .color(ColorUtilities.getColorByString(bot.config.colorPalette.defaultColor)); + .color(bot.colorPalette.defaultColor); } } case ALL -> { - return Component.text("Now looping every song").color(ColorUtilities.getColorByString(bot.config.colorPalette.defaultColor)); + return Component.text("Now looping every song").color(bot.colorPalette.defaultColor); } default -> throw new CommandException(Component.text("Invalid action")); } @@ -305,7 +304,7 @@ public class MusicCommand extends Command { fullList.add( Component - .text(eachPath.getFileName().toString(), (i++ & 1) == 0 ? ColorUtilities.getColorByString(bot.config.colorPalette.primary) : ColorUtilities.getColorByString(bot.config.colorPalette.secondary)) + .text(eachPath.getFileName().toString(), (i++ & 1) == 0 ? bot.colorPalette.primary : bot.colorPalette.secondary) .clickEvent( ClickEvent.suggestCommand( prefix + @@ -348,8 +347,8 @@ public class MusicCommand extends Command { context.sendOutput( Component.empty() .append(Component.text("Skipping ")) - .append(Component.text(music.currentSong.name).color(ColorUtilities.getColorByString(bot.config.colorPalette.secondary))) - .color(ColorUtilities.getColorByString(bot.config.colorPalette.defaultColor)) + .append(Component.text(music.currentSong.name).color(bot.colorPalette.secondary)) + .color(bot.colorPalette.defaultColor) ); music.skip(); @@ -366,8 +365,8 @@ public class MusicCommand extends Command { return Component.empty() .append(Component.text("Now playing ")) - .append(Component.text(song.name).color(ColorUtilities.getColorByString(bot.config.colorPalette.secondary))) - .color(ColorUtilities.getColorByString(bot.config.colorPalette.defaultColor)); + .append(Component.text(song.name).color(bot.colorPalette.secondary)) + .color(bot.colorPalette.defaultColor); } public Component queue (CommandContext context) throws CommandException { @@ -380,7 +379,7 @@ public class MusicCommand extends Command { int i = 0; for (Song song : queue) { queueWithNames.add( - Component.text(song.name).color((i++ & 1) == 0 ? ColorUtilities.getColorByString(bot.config.colorPalette.primary) : ColorUtilities.getColorByString(bot.config.colorPalette.secondary)) + Component.text(song.name).color((i++ & 1) == 0 ? bot.colorPalette.primary : bot.colorPalette.secondary) ); } @@ -407,8 +406,8 @@ public class MusicCommand extends Command { return Component .text("Set the time to ") - .append(Component.text(input).color(ColorUtilities.getColorByString(bot.config.colorPalette.number))) - .color(ColorUtilities.getColorByString(bot.config.colorPalette.defaultColor)); + .append(Component.text(input).color(bot.colorPalette.number)) + .color(bot.colorPalette.defaultColor); } public Component pitch (CommandContext context) throws CommandException { @@ -422,8 +421,8 @@ public class MusicCommand extends Command { return Component.empty() .append(Component.text("Set the pitch to ")) - .append(Component.text(pitch).color(ColorUtilities.getColorByString(bot.config.colorPalette.number))) - .color(ColorUtilities.getColorByString(bot.config.colorPalette.defaultColor)); + .append(Component.text(pitch).color(bot.colorPalette.number)) + .color(bot.colorPalette.defaultColor); } public Component speed (CommandContext context) throws CommandException { @@ -446,8 +445,8 @@ public class MusicCommand extends Command { return Component.empty() .append(Component.text("Set the speed to ")) - .append(Component.text(speed).color(ColorUtilities.getColorByString(bot.config.colorPalette.number))) - .color(ColorUtilities.getColorByString(bot.config.colorPalette.defaultColor)); + .append(Component.text(speed).color(bot.colorPalette.number)) + .color(bot.colorPalette.defaultColor); } public Component amplify (CommandContext context) throws CommandException { @@ -463,8 +462,8 @@ public class MusicCommand extends Command { return Component.empty() .append(Component.text("Set the amplification to ")) - .append(Component.text(amplify).color(ColorUtilities.getColorByString(bot.config.colorPalette.number))) - .color(ColorUtilities.getColorByString(bot.config.colorPalette.defaultColor)); + .append(Component.text(amplify).color(bot.colorPalette.number)) + .color(bot.colorPalette.defaultColor); } public Component noteInstrument (CommandContext context) throws CommandException { @@ -477,10 +476,10 @@ public class MusicCommand extends Command { if (!instrument.equals("off")) { return Component.empty() .append(Component.text("Set the instrument for every note to ")) - .append(Component.text(instrument).color(ColorUtilities.getColorByString(bot.config.colorPalette.secondary))) - .color(ColorUtilities.getColorByString(bot.config.colorPalette.defaultColor)); + .append(Component.text(instrument).color(bot.colorPalette.secondary)) + .color(bot.colorPalette.defaultColor); } else { - return Component.text("Every notes are now using its instrument").color(ColorUtilities.getColorByString(bot.config.colorPalette.defaultColor)); + return Component.text("Every notes are now using its instrument").color(bot.colorPalette.defaultColor); } } @@ -494,10 +493,10 @@ public class MusicCommand extends Command { if (currentSong.paused) { currentSong.play(); - return Component.text("Resumed the current song").color(ColorUtilities.getColorByString(bot.config.colorPalette.defaultColor)); + return Component.text("Resumed the current song").color(bot.colorPalette.defaultColor); } else { currentSong.pause(); - return Component.text("Paused the current song").color(ColorUtilities.getColorByString(bot.config.colorPalette.defaultColor)); + return Component.text("Paused the current song").color(bot.colorPalette.defaultColor); } } @@ -511,8 +510,8 @@ public class MusicCommand extends Command { final List components = new ArrayList<>(); - final TextColor keyColor = ColorUtilities.getColorByString(bot.config.colorPalette.secondary); - final TextColor valueColor = ColorUtilities.getColorByString(bot.config.colorPalette.string); + final TextColor keyColor = bot.colorPalette.secondary; + final TextColor valueColor = bot.colorPalette.string; if (isNotNullAndNotBlank(currentSong.name)) components.add(Component.translatable("Title/Filename: %s", Component.text(currentSong.name).color(valueColor)).color(keyColor)); @@ -576,6 +575,6 @@ public class MusicCommand extends Command { bot.music.songQueue.add(song); - return Component.text("Test song has been added to the song queue").color(ColorUtilities.getColorByString(bot.config.colorPalette.defaultColor)); + return Component.text("Test song has been added to the song queue").color(bot.colorPalette.defaultColor); } } diff --git a/src/main/java/me/chayapak1/chomens_bot/commands/RandomTeleportCommand.java b/src/main/java/me/chayapak1/chomens_bot/commands/RandomTeleportCommand.java index 8f6c7c49..262964ce 100644 --- a/src/main/java/me/chayapak1/chomens_bot/commands/RandomTeleportCommand.java +++ b/src/main/java/me/chayapak1/chomens_bot/commands/RandomTeleportCommand.java @@ -6,7 +6,6 @@ import me.chayapak1.chomens_bot.command.CommandContext; import me.chayapak1.chomens_bot.command.CommandException; import me.chayapak1.chomens_bot.command.TrustLevel; import me.chayapak1.chomens_bot.data.player.PlayerEntry; -import me.chayapak1.chomens_bot.util.ColorUtilities; import me.chayapak1.chomens_bot.util.MathUtilities; import net.kyori.adventure.text.Component; import net.kyori.adventure.text.format.NamedTextColor; @@ -39,10 +38,10 @@ public class RandomTeleportCommand extends Command { return Component.empty() .append(Component.text("Teleporting ")) - .append(Component.text(sender.profile.getName()).color(ColorUtilities.getColorByString(bot.config.colorPalette.username))) + .append(Component.text(sender.profile.getName()).color(bot.colorPalette.username)) .append(Component.text(" to ")) .append(Component.text(stringPosition).color(NamedTextColor.GREEN)) .append(Component.text("...")) - .color(ColorUtilities.getColorByString(bot.config.colorPalette.defaultColor)); + .color(bot.colorPalette.defaultColor); } } diff --git a/src/main/java/me/chayapak1/chomens_bot/commands/RefillCoreCommand.java b/src/main/java/me/chayapak1/chomens_bot/commands/RefillCoreCommand.java index feef78d9..39738990 100644 --- a/src/main/java/me/chayapak1/chomens_bot/commands/RefillCoreCommand.java +++ b/src/main/java/me/chayapak1/chomens_bot/commands/RefillCoreCommand.java @@ -5,7 +5,6 @@ import me.chayapak1.chomens_bot.command.Command; import me.chayapak1.chomens_bot.command.CommandContext; import me.chayapak1.chomens_bot.command.CommandException; import me.chayapak1.chomens_bot.command.TrustLevel; -import me.chayapak1.chomens_bot.util.ColorUtilities; import net.kyori.adventure.text.Component; public class RefillCoreCommand extends Command { @@ -31,6 +30,6 @@ public class RefillCoreCommand extends Command { return Component .text("Refilled the command core") - .color(ColorUtilities.getColorByString(bot.config.colorPalette.defaultColor)); + .color(bot.colorPalette.defaultColor); } } diff --git a/src/main/java/me/chayapak1/chomens_bot/commands/RestartCommand.java b/src/main/java/me/chayapak1/chomens_bot/commands/RestartCommand.java index db8a444c..2e2ebd89 100644 --- a/src/main/java/me/chayapak1/chomens_bot/commands/RestartCommand.java +++ b/src/main/java/me/chayapak1/chomens_bot/commands/RestartCommand.java @@ -6,7 +6,6 @@ import me.chayapak1.chomens_bot.command.Command; import me.chayapak1.chomens_bot.command.CommandContext; import me.chayapak1.chomens_bot.command.CommandException; import me.chayapak1.chomens_bot.command.TrustLevel; -import me.chayapak1.chomens_bot.util.ColorUtilities; import net.kyori.adventure.text.Component; public class RestartCommand extends Command { @@ -29,6 +28,6 @@ public class RestartCommand extends Command { Main.stop(12, reason.isEmpty() ? null : reason, "Restarting.."); - return Component.text("Restarting").color(ColorUtilities.getColorByString(bot.config.colorPalette.defaultColor)); + return Component.text("Restarting").color(bot.colorPalette.defaultColor); } } diff --git a/src/main/java/me/chayapak1/chomens_bot/commands/ScreenshareCommand.java b/src/main/java/me/chayapak1/chomens_bot/commands/ScreenshareCommand.java index fa2f18d6..6583323b 100644 --- a/src/main/java/me/chayapak1/chomens_bot/commands/ScreenshareCommand.java +++ b/src/main/java/me/chayapak1/chomens_bot/commands/ScreenshareCommand.java @@ -5,7 +5,6 @@ import me.chayapak1.chomens_bot.command.Command; import me.chayapak1.chomens_bot.command.CommandContext; import me.chayapak1.chomens_bot.command.CommandException; import me.chayapak1.chomens_bot.command.TrustLevel; -import me.chayapak1.chomens_bot.util.ColorUtilities; import net.kyori.adventure.text.Component; import org.cloudburstmc.math.vector.Vector3i; @@ -45,7 +44,7 @@ public class ScreenshareCommand extends Command { return Component .text("Started screen sharing") - .color(ColorUtilities.getColorByString(bot.config.colorPalette.defaultColor)); + .color(bot.colorPalette.defaultColor); } case "stop" -> { context.checkOverloadArgs(1); @@ -54,7 +53,7 @@ public class ScreenshareCommand extends Command { return Component .text("Stopped screen sharing") - .color(ColorUtilities.getColorByString(bot.config.colorPalette.defaultColor)); + .color(bot.colorPalette.defaultColor); } case "setres" -> { context.checkOverloadArgs(3); @@ -69,8 +68,8 @@ public class ScreenshareCommand extends Command { return Component .text("Set the resolution to ") - .append(Component.text(width + "x" + height).color(ColorUtilities.getColorByString(bot.config.colorPalette.string))) - .color(ColorUtilities.getColorByString(bot.config.colorPalette.defaultColor)); + .append(Component.text(width + "x" + height).color(bot.colorPalette.string)) + .color(bot.colorPalette.defaultColor); } case "setfps" -> { context.checkOverloadArgs(2); @@ -81,8 +80,8 @@ public class ScreenshareCommand extends Command { return Component .text("Set the FPS to ") - .append(Component.text(fps).color(ColorUtilities.getColorByString(bot.config.colorPalette.number))) - .color(ColorUtilities.getColorByString(bot.config.colorPalette.defaultColor)); + .append(Component.text(fps).color(bot.colorPalette.number)) + .color(bot.colorPalette.defaultColor); } default -> throw new CommandException(Component.text("Invalid action")); } diff --git a/src/main/java/me/chayapak1/chomens_bot/commands/SeenCommand.java b/src/main/java/me/chayapak1/chomens_bot/commands/SeenCommand.java index f4b78c3a..aed48729 100644 --- a/src/main/java/me/chayapak1/chomens_bot/commands/SeenCommand.java +++ b/src/main/java/me/chayapak1/chomens_bot/commands/SeenCommand.java @@ -9,7 +9,6 @@ import me.chayapak1.chomens_bot.command.CommandContext; import me.chayapak1.chomens_bot.command.CommandException; import me.chayapak1.chomens_bot.command.TrustLevel; import me.chayapak1.chomens_bot.plugins.DatabasePlugin; -import me.chayapak1.chomens_bot.util.ColorUtilities; import net.kyori.adventure.text.Component; import net.kyori.adventure.text.JoinConfiguration; import net.kyori.adventure.text.format.NamedTextColor; @@ -93,10 +92,10 @@ public class SeenCommand extends Command { context.sendOutput(Component.translatable( "%s was last seen at %s on %s", - Component.text(player).color(ColorUtilities.getColorByString(bot.config.colorPalette.username)), - Component.text(formattedTime).color(ColorUtilities.getColorByString(bot.config.colorPalette.string)), - Component.text(server).color(ColorUtilities.getColorByString(bot.config.colorPalette.string)) - ).color(ColorUtilities.getColorByString(bot.config.colorPalette.defaultColor))); + Component.text(player).color(bot.colorPalette.username), + Component.text(formattedTime).color(bot.colorPalette.string), + Component.text(server).color(bot.colorPalette.string) + ).color(bot.colorPalette.defaultColor)); } catch (CommandException e) { context.sendOutput(e.message.color(NamedTextColor.RED)); } diff --git a/src/main/java/me/chayapak1/chomens_bot/commands/ServerEvalCommand.java b/src/main/java/me/chayapak1/chomens_bot/commands/ServerEvalCommand.java index 7479cf96..d1c8215d 100644 --- a/src/main/java/me/chayapak1/chomens_bot/commands/ServerEvalCommand.java +++ b/src/main/java/me/chayapak1/chomens_bot/commands/ServerEvalCommand.java @@ -5,7 +5,6 @@ import me.chayapak1.chomens_bot.command.Command; import me.chayapak1.chomens_bot.command.CommandContext; import me.chayapak1.chomens_bot.command.CommandException; import me.chayapak1.chomens_bot.command.TrustLevel; -import me.chayapak1.chomens_bot.util.ColorUtilities; import net.kyori.adventure.text.Component; import net.kyori.adventure.text.format.NamedTextColor; import party.iroiro.luajava.Lua; @@ -38,7 +37,7 @@ public class ServerEvalCommand extends Command { if (lua != null) lua.close(); lua = null; - return Component.text("Reset the Lua instance").color(ColorUtilities.getColorByString(bot.config.colorPalette.defaultColor)); + return Component.text("Reset the Lua instance").color(bot.colorPalette.defaultColor); } bot.executorService.submit(() -> { diff --git a/src/main/java/me/chayapak1/chomens_bot/commands/StopCommand.java b/src/main/java/me/chayapak1/chomens_bot/commands/StopCommand.java index c350eca6..03830803 100644 --- a/src/main/java/me/chayapak1/chomens_bot/commands/StopCommand.java +++ b/src/main/java/me/chayapak1/chomens_bot/commands/StopCommand.java @@ -6,7 +6,6 @@ import me.chayapak1.chomens_bot.command.Command; import me.chayapak1.chomens_bot.command.CommandContext; import me.chayapak1.chomens_bot.command.CommandException; import me.chayapak1.chomens_bot.command.TrustLevel; -import me.chayapak1.chomens_bot.util.ColorUtilities; import net.kyori.adventure.text.Component; public class StopCommand extends Command { @@ -29,6 +28,6 @@ public class StopCommand extends Command { Main.stop(0, reason.isEmpty() ? null : reason); - return Component.text("Stopping").color(ColorUtilities.getColorByString(bot.config.colorPalette.defaultColor)); + return Component.text("Stopping").color(bot.colorPalette.defaultColor); } } diff --git a/src/main/java/me/chayapak1/chomens_bot/commands/TPSBarCommand.java b/src/main/java/me/chayapak1/chomens_bot/commands/TPSBarCommand.java index cad9b62b..bfc8aec5 100644 --- a/src/main/java/me/chayapak1/chomens_bot/commands/TPSBarCommand.java +++ b/src/main/java/me/chayapak1/chomens_bot/commands/TPSBarCommand.java @@ -5,7 +5,6 @@ import me.chayapak1.chomens_bot.command.Command; import me.chayapak1.chomens_bot.command.CommandContext; import me.chayapak1.chomens_bot.command.CommandException; import me.chayapak1.chomens_bot.command.TrustLevel; -import me.chayapak1.chomens_bot.util.ColorUtilities; import net.kyori.adventure.text.Component; import net.kyori.adventure.text.format.NamedTextColor; @@ -35,14 +34,14 @@ public class TPSBarCommand extends Command { return Component.empty() .append(Component.text("TPSBar is now ")) .append(Component.text("enabled").color(NamedTextColor.GREEN)) - .color(ColorUtilities.getColorByString(bot.config.colorPalette.defaultColor)); + .color(bot.colorPalette.defaultColor); } case "off" -> { bot.tps.off(); return Component.empty() .append(Component.text("TPSBar is now ")) .append(Component.text("disabled").color(NamedTextColor.RED)) - .color(ColorUtilities.getColorByString(bot.config.colorPalette.defaultColor)); + .color(bot.colorPalette.defaultColor); } default -> throw new CommandException(Component.text("Invalid action")); } diff --git a/src/main/java/me/chayapak1/chomens_bot/commands/TimeCommand.java b/src/main/java/me/chayapak1/chomens_bot/commands/TimeCommand.java index 569b2e26..26d80869 100644 --- a/src/main/java/me/chayapak1/chomens_bot/commands/TimeCommand.java +++ b/src/main/java/me/chayapak1/chomens_bot/commands/TimeCommand.java @@ -5,7 +5,6 @@ import me.chayapak1.chomens_bot.command.Command; import me.chayapak1.chomens_bot.command.CommandContext; import me.chayapak1.chomens_bot.command.CommandException; import me.chayapak1.chomens_bot.command.TrustLevel; -import me.chayapak1.chomens_bot.util.ColorUtilities; import net.kyori.adventure.text.Component; import net.kyori.adventure.text.format.NamedTextColor; @@ -41,9 +40,9 @@ public class TimeCommand extends Command { return Component.translatable( "The current time for %s is: %s", - Component.text(timezone).color(ColorUtilities.getColorByString(bot.config.colorPalette.string)), + Component.text(timezone).color(bot.colorPalette.string), Component.text(formattedTime).color(NamedTextColor.GREEN) - ).color(ColorUtilities.getColorByString(bot.config.colorPalette.defaultColor)); + ).color(bot.colorPalette.defaultColor); } catch (DateTimeException e) { throw new CommandException(Component.text("Invalid timezone (case-sensitive)")); } diff --git a/src/main/java/me/chayapak1/chomens_bot/commands/TranslateCommand.java b/src/main/java/me/chayapak1/chomens_bot/commands/TranslateCommand.java index 3d791a79..07cb41d2 100644 --- a/src/main/java/me/chayapak1/chomens_bot/commands/TranslateCommand.java +++ b/src/main/java/me/chayapak1/chomens_bot/commands/TranslateCommand.java @@ -8,7 +8,6 @@ import me.chayapak1.chomens_bot.command.Command; import me.chayapak1.chomens_bot.command.CommandContext; import me.chayapak1.chomens_bot.command.CommandException; import me.chayapak1.chomens_bot.command.TrustLevel; -import me.chayapak1.chomens_bot.util.ColorUtilities; import me.chayapak1.chomens_bot.util.HttpUtilities; import net.kyori.adventure.text.Component; import net.kyori.adventure.text.format.NamedTextColor; @@ -73,7 +72,7 @@ public class TranslateCommand extends Command { "Result: %s", Component.text(output).color(NamedTextColor.GREEN) ) - .color(ColorUtilities.getColorByString(bot.config.colorPalette.secondary)) + .color(bot.colorPalette.secondary) ); } catch (Exception e) { context.sendOutput(Component.text(e.toString()).color(NamedTextColor.RED)); diff --git a/src/main/java/me/chayapak1/chomens_bot/commands/UUIDCommand.java b/src/main/java/me/chayapak1/chomens_bot/commands/UUIDCommand.java index fd5ec04b..35c8530d 100644 --- a/src/main/java/me/chayapak1/chomens_bot/commands/UUIDCommand.java +++ b/src/main/java/me/chayapak1/chomens_bot/commands/UUIDCommand.java @@ -6,7 +6,6 @@ import me.chayapak1.chomens_bot.command.CommandContext; import me.chayapak1.chomens_bot.command.CommandException; import me.chayapak1.chomens_bot.command.TrustLevel; import me.chayapak1.chomens_bot.data.player.PlayerEntry; -import me.chayapak1.chomens_bot.util.ColorUtilities; import me.chayapak1.chomens_bot.util.UUIDUtilities; import net.kyori.adventure.text.Component; import net.kyori.adventure.text.event.ClickEvent; @@ -58,7 +57,7 @@ public class UUIDCommand extends Command { .clickEvent( ClickEvent.copyToClipboard(uuid) ) - .color(ColorUtilities.getColorByString(bot.config.colorPalette.uuid)) + .color(bot.colorPalette.uuid) ).color(NamedTextColor.GREEN); } else { final PlayerEntry entry = context.sender; @@ -77,7 +76,7 @@ public class UUIDCommand extends Command { .clickEvent( ClickEvent.copyToClipboard(uuid) ) - .color(ColorUtilities.getColorByString(bot.config.colorPalette.uuid)) + .color(bot.colorPalette.uuid) ).color(NamedTextColor.GREEN); } } diff --git a/src/main/java/me/chayapak1/chomens_bot/commands/UrbanCommand.java b/src/main/java/me/chayapak1/chomens_bot/commands/UrbanCommand.java index 68aca7f0..123a1e40 100644 --- a/src/main/java/me/chayapak1/chomens_bot/commands/UrbanCommand.java +++ b/src/main/java/me/chayapak1/chomens_bot/commands/UrbanCommand.java @@ -11,7 +11,6 @@ import me.chayapak1.chomens_bot.command.CommandContext; import me.chayapak1.chomens_bot.command.CommandException; import me.chayapak1.chomens_bot.command.TrustLevel; import me.chayapak1.chomens_bot.command.contexts.DiscordCommandContext; -import me.chayapak1.chomens_bot.util.ColorUtilities; import me.chayapak1.chomens_bot.util.HttpUtilities; import net.kyori.adventure.text.Component; import net.kyori.adventure.text.event.ClickEvent; @@ -106,10 +105,10 @@ public class UrbanCommand extends Command { Thumbs up: %s Thumbs down: %s Example: %s""", - Component.text(author).color(ColorUtilities.getColorByString(bot.config.colorPalette.string)), + Component.text(author).color(bot.colorPalette.string), Component.text(thumbsUp).color(NamedTextColor.GREEN), Component.text(thumbsDown).color(NamedTextColor.RED), - Component.text(example.replaceAll("\r\n?", "\n")).color(ColorUtilities.getColorByString(bot.config.colorPalette.string)) + Component.text(example.replaceAll("\r\n?", "\n")).color(bot.colorPalette.string) ); if (even) { diff --git a/src/main/java/me/chayapak1/chomens_bot/commands/WeatherCommand.java b/src/main/java/me/chayapak1/chomens_bot/commands/WeatherCommand.java index c71ce762..362ed782 100644 --- a/src/main/java/me/chayapak1/chomens_bot/commands/WeatherCommand.java +++ b/src/main/java/me/chayapak1/chomens_bot/commands/WeatherCommand.java @@ -7,7 +7,6 @@ import me.chayapak1.chomens_bot.command.Command; import me.chayapak1.chomens_bot.command.CommandContext; import me.chayapak1.chomens_bot.command.CommandException; import me.chayapak1.chomens_bot.command.TrustLevel; -import me.chayapak1.chomens_bot.util.ColorUtilities; import me.chayapak1.chomens_bot.util.HttpUtilities; import net.kyori.adventure.text.Component; import net.kyori.adventure.text.format.NamedTextColor; @@ -51,8 +50,8 @@ public class WeatherCommand extends Command { return Component.translatable( "Current weather for %s, %s:\n%s (%s), feels like %s (%s)\nCondition: %s\nCloud cover: %s\nHumidity: %s\nTime: %s", - 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("location").getAsJsonObject().get("name").getAsString()).color(bot.colorPalette.string), + Component.text(jsonObject.get("location").getAsJsonObject().get("country").getAsString()).color(bot.colorPalette.string), Component .empty() .append( @@ -64,7 +63,7 @@ public class WeatherCommand extends Command { .get("temp_c") .getAsString() + "°C" ) - .color(ColorUtilities.getColorByString(bot.config.colorPalette.secondary)) + .color(bot.colorPalette.secondary) ), Component .text( @@ -74,7 +73,7 @@ public class WeatherCommand extends Command { .get("temp_f") .getAsString() + "°F" ) - .color(ColorUtilities.getColorByString(bot.config.colorPalette.secondary)), + .color(bot.colorPalette.secondary), Component .text( jsonObject @@ -103,7 +102,7 @@ public class WeatherCommand extends Command { .get("text") .getAsString() ) - .color(ColorUtilities.getColorByString(bot.config.colorPalette.string)), + .color(bot.colorPalette.string), Component .text( jsonObject @@ -113,7 +112,7 @@ public class WeatherCommand extends Command { .getAsInt() ) .append(Component.text("%")) - .color(ColorUtilities.getColorByString(bot.config.colorPalette.number)), + .color(bot.colorPalette.number), Component .text( jsonObject @@ -123,7 +122,7 @@ public class WeatherCommand extends Command { .getAsInt() ) .append(Component.text("%")) - .color(ColorUtilities.getColorByString(bot.config.colorPalette.number)), + .color(bot.colorPalette.number), Component .text( jsonObject @@ -132,8 +131,8 @@ public class WeatherCommand extends Command { .get("localtime") .getAsString() ) - .color(ColorUtilities.getColorByString(bot.config.colorPalette.string)) - ).color(ColorUtilities.getColorByString(bot.config.colorPalette.defaultColor)); + .color(bot.colorPalette.string) + ).color(bot.colorPalette.defaultColor); } catch (Exception e) { throw new CommandException(Component.text("Location \"" + location + "\" not found")); } diff --git a/src/main/java/me/chayapak1/chomens_bot/commands/WhitelistCommand.java b/src/main/java/me/chayapak1/chomens_bot/commands/WhitelistCommand.java index 24a40a1b..e250a3ff 100644 --- a/src/main/java/me/chayapak1/chomens_bot/commands/WhitelistCommand.java +++ b/src/main/java/me/chayapak1/chomens_bot/commands/WhitelistCommand.java @@ -5,7 +5,6 @@ import me.chayapak1.chomens_bot.command.Command; import me.chayapak1.chomens_bot.command.CommandContext; import me.chayapak1.chomens_bot.command.CommandException; import me.chayapak1.chomens_bot.command.TrustLevel; -import me.chayapak1.chomens_bot.util.ColorUtilities; import net.kyori.adventure.text.Component; import net.kyori.adventure.text.JoinConfiguration; import net.kyori.adventure.text.format.NamedTextColor; @@ -37,14 +36,14 @@ public class WhitelistCommand extends Command { bot.whitelist.enable(); - return Component.text("Enabled whitelist").color(ColorUtilities.getColorByString(bot.config.colorPalette.defaultColor)); + return Component.text("Enabled whitelist").color(bot.colorPalette.defaultColor); } case "disable" -> { context.checkOverloadArgs(1); bot.whitelist.disable(); - return Component.text("Disabled whitelist").color(ColorUtilities.getColorByString(bot.config.colorPalette.defaultColor)); + return Component.text("Disabled whitelist").color(bot.colorPalette.defaultColor); } case "add" -> { final String player = context.getString(true, true); @@ -53,8 +52,8 @@ public class WhitelistCommand extends Command { return Component.translatable( "Added %s to the whitelist", - Component.text(player).color(ColorUtilities.getColorByString(bot.config.colorPalette.username)) - ).color(ColorUtilities.getColorByString(bot.config.colorPalette.defaultColor)); + Component.text(player).color(bot.colorPalette.username) + ).color(bot.colorPalette.defaultColor); } case "remove" -> { try { @@ -64,8 +63,8 @@ public class WhitelistCommand extends Command { return Component.translatable( "Removed %s from the whitelist", - Component.text(player).color(ColorUtilities.getColorByString(bot.config.colorPalette.username)) - ).color(ColorUtilities.getColorByString(bot.config.colorPalette.defaultColor)); + Component.text(player).color(bot.colorPalette.username) + ).color(bot.colorPalette.defaultColor); } catch (IndexOutOfBoundsException | IllegalArgumentException | NullPointerException ignored) { throw new CommandException(Component.text("Invalid index")); } @@ -75,7 +74,7 @@ public class WhitelistCommand extends Command { bot.whitelist.clear(); - return Component.text("Cleared the whitelist").color(ColorUtilities.getColorByString(bot.config.colorPalette.defaultColor)); + return Component.text("Cleared the whitelist").color(bot.colorPalette.defaultColor); } case "list" -> { context.checkOverloadArgs(1); @@ -87,8 +86,8 @@ public class WhitelistCommand extends Command { playersComponent.add( Component.translatable( "%s › %s", - Component.text(index).color(ColorUtilities.getColorByString(bot.config.colorPalette.number)), - Component.text(player).color(ColorUtilities.getColorByString(bot.config.colorPalette.username)) + Component.text(index).color(bot.colorPalette.number), + Component.text(player).color(bot.colorPalette.username) ).color(NamedTextColor.DARK_GRAY) ); diff --git a/src/main/java/me/chayapak1/chomens_bot/commands/WikipediaCommand.java b/src/main/java/me/chayapak1/chomens_bot/commands/WikipediaCommand.java index ab2cad28..84fff108 100644 --- a/src/main/java/me/chayapak1/chomens_bot/commands/WikipediaCommand.java +++ b/src/main/java/me/chayapak1/chomens_bot/commands/WikipediaCommand.java @@ -9,7 +9,6 @@ import me.chayapak1.chomens_bot.command.Command; import me.chayapak1.chomens_bot.command.CommandContext; import me.chayapak1.chomens_bot.command.CommandException; import me.chayapak1.chomens_bot.command.TrustLevel; -import me.chayapak1.chomens_bot.util.ColorUtilities; import me.chayapak1.chomens_bot.util.HTMLUtilities; import me.chayapak1.chomens_bot.util.HttpUtilities; import net.kyori.adventure.text.Component; @@ -110,7 +109,7 @@ public class WikipediaCommand extends Command { .style( Style.style() .decorate(TextDecoration.BOLD) - .color(ColorUtilities.getColorByString(bot.config.colorPalette.secondary)) + .color(bot.colorPalette.secondary) ) ) .append(Component.newline()) diff --git a/src/main/java/me/chayapak1/chomens_bot/data/color/ColorPalette.java b/src/main/java/me/chayapak1/chomens_bot/data/color/ColorPalette.java new file mode 100644 index 00000000..ac7ce829 --- /dev/null +++ b/src/main/java/me/chayapak1/chomens_bot/data/color/ColorPalette.java @@ -0,0 +1,28 @@ +package me.chayapak1.chomens_bot.data.color; + +import me.chayapak1.chomens_bot.Configuration; +import net.kyori.adventure.text.format.TextColor; + +import static me.chayapak1.chomens_bot.util.ColorUtilities.getColorByString; + +public class ColorPalette { + public final TextColor primary; + public final TextColor secondary; + public final TextColor defaultColor; + public final TextColor username; + public final TextColor uuid; + public final TextColor string; + public final TextColor number; + public final TextColor ownerName; + + public ColorPalette (Configuration.ColorPalette configColorPalette) { + this.primary = getColorByString(configColorPalette.primary); + this.secondary = getColorByString(configColorPalette.secondary); + this.defaultColor = getColorByString(configColorPalette.defaultColor); + this.username = getColorByString(configColorPalette.username); + this.uuid = getColorByString(configColorPalette.uuid); + this.string = getColorByString(configColorPalette.string); + this.number = getColorByString(configColorPalette.number); + this.ownerName = getColorByString(configColorPalette.ownerName); + } +} \ No newline at end of file diff --git a/src/main/java/me/chayapak1/chomens_bot/plugins/CommandHandlerPlugin.java b/src/main/java/me/chayapak1/chomens_bot/plugins/CommandHandlerPlugin.java index 42d74338..11a6008b 100644 --- a/src/main/java/me/chayapak1/chomens_bot/plugins/CommandHandlerPlugin.java +++ b/src/main/java/me/chayapak1/chomens_bot/plugins/CommandHandlerPlugin.java @@ -133,7 +133,8 @@ public class CommandHandlerPlugin implements TickPlugin.Listener { // I think this is kinda annoying when you correct spelling mistakes or something, // so I made it return nothing if we're in game if (command == null) { - if (!inGame) context.sendOutput(Component.text("Unknown command: " + commandName).color(NamedTextColor.RED)); + if (!inGame) + context.sendOutput(Component.text("Unknown command: " + commandName).color(NamedTextColor.RED)); return; } diff --git a/src/main/java/me/chayapak1/chomens_bot/plugins/CorePlugin.java b/src/main/java/me/chayapak1/chomens_bot/plugins/CorePlugin.java index a383dbfd..bb3a45bd 100644 --- a/src/main/java/me/chayapak1/chomens_bot/plugins/CorePlugin.java +++ b/src/main/java/me/chayapak1/chomens_bot/plugins/CorePlugin.java @@ -194,6 +194,7 @@ public class CorePlugin // thanks chipmunk for this new tellraw method public CompletableFuture runTracked (String command) { return runTracked(false, command); } + public CompletableFuture runTracked (boolean useCargo, String command) { if (!ready || command.length() > 32767) return null; diff --git a/src/main/java/me/chayapak1/chomens_bot/plugins/DiscordPlugin.java b/src/main/java/me/chayapak1/chomens_bot/plugins/DiscordPlugin.java index 1ad9fc54..982b08ba 100644 --- a/src/main/java/me/chayapak1/chomens_bot/plugins/DiscordPlugin.java +++ b/src/main/java/me/chayapak1/chomens_bot/plugins/DiscordPlugin.java @@ -5,7 +5,6 @@ import me.chayapak1.chomens_bot.Configuration; import me.chayapak1.chomens_bot.Main; import me.chayapak1.chomens_bot.command.contexts.DiscordCommandContext; import me.chayapak1.chomens_bot.util.CodeBlockUtilities; -import me.chayapak1.chomens_bot.util.ColorUtilities; import me.chayapak1.chomens_bot.util.ComponentUtilities; import me.chayapak1.chomens_bot.util.LoggerUtilities; import net.dv8tion.jda.api.JDA; @@ -427,7 +426,7 @@ public class DiscordPlugin extends ListenerAdapter { %s""", embed.getTitle() == null ? Component.text("No title").color(NamedTextColor.GRAY) : - Component.text(embed.getTitle()).color(ColorUtilities.getColorByString(bot.config.colorPalette.string)), + Component.text(embed.getTitle()).color(bot.colorPalette.string), embed.getDescription() == null ? Component.text("No description").color(NamedTextColor.GRAY) : Component.text(embed.getDescription()).color(NamedTextColor.WHITE) diff --git a/src/main/java/me/chayapak1/chomens_bot/plugins/GrepLogPlugin.java b/src/main/java/me/chayapak1/chomens_bot/plugins/GrepLogPlugin.java index c17e2a4c..97bc56d6 100644 --- a/src/main/java/me/chayapak1/chomens_bot/plugins/GrepLogPlugin.java +++ b/src/main/java/me/chayapak1/chomens_bot/plugins/GrepLogPlugin.java @@ -4,7 +4,6 @@ import me.chayapak1.chomens_bot.Bot; import me.chayapak1.chomens_bot.Main; import me.chayapak1.chomens_bot.command.CommandContext; import me.chayapak1.chomens_bot.command.CommandException; -import me.chayapak1.chomens_bot.util.ColorUtilities; import me.chayapak1.chomens_bot.util.FileLoggerUtilities; import me.chayapak1.chomens_bot.util.StringUtilities; import net.dv8tion.jda.api.entities.channel.concrete.TextChannel; @@ -109,10 +108,10 @@ public class GrepLogPlugin { final DecimalFormat formatter = new DecimalFormat("#,###"); final Component component = Component.translatable("Found %s matches for %s. You can see the results by clicking %s or in the Discord server.") - .color(ColorUtilities.getColorByString(bot.config.colorPalette.defaultColor)) + .color(bot.colorPalette.defaultColor) .arguments( - Component.text(formatter.format(matches)).color(ColorUtilities.getColorByString(bot.config.colorPalette.number)), - Component.text(input).color(ColorUtilities.getColorByString(bot.config.colorPalette.string)), + Component.text(formatter.format(matches)).color(bot.colorPalette.number), + Component.text(input).color(bot.colorPalette.string), Component .text("here") .color(NamedTextColor.GREEN) @@ -120,7 +119,7 @@ public class GrepLogPlugin { HoverEvent.showText( Component .text("Click! :D") - .color(ColorUtilities.getColorByString(bot.config.colorPalette.secondary)) + .color(bot.colorPalette.secondary) ) ) .clickEvent( diff --git a/src/main/java/me/chayapak1/chomens_bot/plugins/MailPlugin.java b/src/main/java/me/chayapak1/chomens_bot/plugins/MailPlugin.java index 0137a309..fd60ff39 100644 --- a/src/main/java/me/chayapak1/chomens_bot/plugins/MailPlugin.java +++ b/src/main/java/me/chayapak1/chomens_bot/plugins/MailPlugin.java @@ -4,7 +4,6 @@ import me.chayapak1.chomens_bot.Bot; import me.chayapak1.chomens_bot.Main; import me.chayapak1.chomens_bot.data.mail.Mail; import me.chayapak1.chomens_bot.data.player.PlayerEntry; -import me.chayapak1.chomens_bot.util.ColorUtilities; import me.chayapak1.chomens_bot.util.LoggerUtilities; import net.kyori.adventure.text.Component; import net.kyori.adventure.text.format.NamedTextColor; @@ -64,8 +63,8 @@ public class MailPlugin implements PlayersPlugin.Listener { "Run %s or %s to read", Component.text(sendToTargetSize).color(NamedTextColor.GREEN), Component.text((sendToTargetSize > 1) ? "s" : ""), - Component.text(bot.config.commandSpyPrefixes.getFirst() + "mail read").color(ColorUtilities.getColorByString(bot.config.colorPalette.primary)), - Component.text(bot.config.prefixes.getFirst() + "mail read").color(ColorUtilities.getColorByString(bot.config.colorPalette.primary)) + Component.text(bot.config.commandSpyPrefixes.getFirst() + "mail read").color(bot.colorPalette.primary), + Component.text(bot.config.prefixes.getFirst() + "mail read").color(bot.colorPalette.primary) ).color(NamedTextColor.GOLD); bot.chat.tellraw(component, target.profile.getId()); diff --git a/src/main/java/me/chayapak1/chomens_bot/plugins/MusicPlayerPlugin.java b/src/main/java/me/chayapak1/chomens_bot/plugins/MusicPlayerPlugin.java index 7d18a88e..8122e9e3 100644 --- a/src/main/java/me/chayapak1/chomens_bot/plugins/MusicPlayerPlugin.java +++ b/src/main/java/me/chayapak1/chomens_bot/plugins/MusicPlayerPlugin.java @@ -7,7 +7,6 @@ import me.chayapak1.chomens_bot.song.Loop; import me.chayapak1.chomens_bot.song.Note; import me.chayapak1.chomens_bot.song.Song; import me.chayapak1.chomens_bot.song.SongLoaderThread; -import me.chayapak1.chomens_bot.util.ColorUtilities; import me.chayapak1.chomens_bot.util.LoggerUtilities; import me.chayapak1.chomens_bot.util.MathUtilities; import net.kyori.adventure.text.Component; @@ -119,9 +118,9 @@ public class MusicPlayerPlugin extends Bot.Listener implements CorePlugin.Listen Component .translatable( "Loading %s", - Component.text(songName, ColorUtilities.getColorByString(bot.config.colorPalette.secondary)) + Component.text(songName, bot.colorPalette.secondary) ) - .color(ColorUtilities.getColorByString(bot.config.colorPalette.defaultColor)), + .color(bot.colorPalette.defaultColor), BOTH_SELECTOR ); @@ -148,8 +147,8 @@ public class MusicPlayerPlugin extends Bot.Listener implements CorePlugin.Listen bot.chat.tellraw( Component.translatable( "Now playing %s", - Component.empty().append(Component.text(currentSong.name)).color(ColorUtilities.getColorByString(bot.config.colorPalette.secondary)) - ).color(ColorUtilities.getColorByString(bot.config.colorPalette.defaultColor)), + Component.empty().append(Component.text(currentSong.name)).color(bot.colorPalette.secondary) + ).color(bot.colorPalette.defaultColor), BOTH_SELECTOR ); currentSong.play(); @@ -185,8 +184,8 @@ public class MusicPlayerPlugin extends Bot.Listener implements CorePlugin.Listen bot.chat.tellraw( Component.translatable( "Finished playing %s", - Component.empty().append(Component.text(currentSong.name)).color(ColorUtilities.getColorByString(bot.config.colorPalette.secondary)) - ).color(ColorUtilities.getColorByString(bot.config.colorPalette.defaultColor)), + Component.empty().append(Component.text(currentSong.name)).color(bot.colorPalette.secondary) + ).color(bot.colorPalette.defaultColor), BOTH_SELECTOR ); diff --git a/src/main/java/me/chayapak1/chomens_bot/plugins/SelfCarePlugin.java b/src/main/java/me/chayapak1/chomens_bot/plugins/SelfCarePlugin.java index 6263c8a7..ca38d35c 100644 --- a/src/main/java/me/chayapak1/chomens_bot/plugins/SelfCarePlugin.java +++ b/src/main/java/me/chayapak1/chomens_bot/plugins/SelfCarePlugin.java @@ -56,7 +56,7 @@ public class SelfCarePlugin extends Bot.Listener implements ChatPlugin.Listener @Override public boolean systemMessageReceived (Component component, String string, String ansi) { final Configuration.BotOption.EssentialsMessages essentialsMessages = bot.options.essentialsMessages; - + if (string.equals("Successfully enabled CommandSpy")) cspy = true; else if (string.equals("Successfully disabled CommandSpy")) cspy = false; @@ -103,7 +103,7 @@ public class SelfCarePlugin extends Bot.Listener implements ChatPlugin.Listener else if (selfCares.gamemode && gamemode != GameMode.CREATIVE && !bot.options.creayun) bot.chat.send("/minecraft:gamemode creative @s[type=player]"); - // core + // core else if (selfCares.cspy && !cspy && kaboom) { if (bot.options.useChat || !bot.options.coreCommandSpy) bot.chat.sendCommandInstantly("commandspy:commandspy on"); diff --git a/src/main/java/me/chayapak1/chomens_bot/plugins/TrustedPlugin.java b/src/main/java/me/chayapak1/chomens_bot/plugins/TrustedPlugin.java index 5a939a34..9184d579 100644 --- a/src/main/java/me/chayapak1/chomens_bot/plugins/TrustedPlugin.java +++ b/src/main/java/me/chayapak1/chomens_bot/plugins/TrustedPlugin.java @@ -3,7 +3,6 @@ package me.chayapak1.chomens_bot.plugins; import me.chayapak1.chomens_bot.Bot; import me.chayapak1.chomens_bot.data.logging.LogType; import me.chayapak1.chomens_bot.data.player.PlayerEntry; -import me.chayapak1.chomens_bot.util.ColorUtilities; import me.chayapak1.chomens_bot.util.LoggerUtilities; import net.kyori.adventure.text.Component; import net.kyori.adventure.text.format.NamedTextColor; @@ -29,7 +28,7 @@ public class TrustedPlugin implements PlayersPlugin.Listener { public void broadcast (Component message, UUID exceptTarget) { final Component component = Component.translatable( "[%s] [%s] %s", - Component.text("ChomeNS Bot").color(ColorUtilities.getColorByString(this.bot.config.colorPalette.primary)), + Component.text("ChomeNS Bot").color(bot.colorPalette.primary), Component.text(this.bot.options.serverName).color(NamedTextColor.GRAY), message.color(NamedTextColor.WHITE) ).color(NamedTextColor.DARK_GRAY); @@ -62,7 +61,7 @@ public class TrustedPlugin implements PlayersPlugin.Listener { if (!target.profile.getName().equals(bot.config.ownerName)) { component = Component.translatable( "Hello, %s!", - Component.text(target.profile.getName()).color(ColorUtilities.getColorByString(bot.config.colorPalette.username)) + Component.text(target.profile.getName()).color(bot.colorPalette.username) ).color(NamedTextColor.GREEN); } else { final LocalDateTime now = LocalDateTime.now(); @@ -75,9 +74,9 @@ public class TrustedPlugin implements PlayersPlugin.Listener { Hello, %s! Time: %s Online players: %s""", - Component.text(target.profile.getName()).color(ColorUtilities.getColorByString(bot.config.colorPalette.username)), - Component.text(formattedTime).color(ColorUtilities.getColorByString(bot.config.colorPalette.string)), - Component.text(bot.players.list.size()).color(ColorUtilities.getColorByString(bot.config.colorPalette.number)) + Component.text(target.profile.getName()).color(bot.colorPalette.username), + Component.text(formattedTime).color(bot.colorPalette.string), + Component.text(bot.players.list.size()).color(bot.colorPalette.number) ).color(NamedTextColor.GREEN); } @@ -89,8 +88,8 @@ public class TrustedPlugin implements PlayersPlugin.Listener { broadcast( Component.translatable( "Trusted player %s is now online", - Component.text(target.profile.getName()).color(ColorUtilities.getColorByString(bot.config.colorPalette.username)) - ).color(ColorUtilities.getColorByString(bot.config.colorPalette.defaultColor)), + Component.text(target.profile.getName()).color(bot.colorPalette.username) + ).color(bot.colorPalette.defaultColor), target.profile.getId() ); } @@ -102,8 +101,8 @@ public class TrustedPlugin implements PlayersPlugin.Listener { broadcast( Component.translatable( "Trusted player %s is now offline", - Component.text(target.profile.getName()).color(ColorUtilities.getColorByString(bot.config.colorPalette.username)) - ).color(ColorUtilities.getColorByString(bot.config.colorPalette.defaultColor)) + Component.text(target.profile.getName()).color(bot.colorPalette.username) + ).color(bot.colorPalette.defaultColor) ); } } diff --git a/src/main/java/me/chayapak1/chomens_bot/song/SongLoaderThread.java b/src/main/java/me/chayapak1/chomens_bot/song/SongLoaderThread.java index 5351ff5e..37996993 100644 --- a/src/main/java/me/chayapak1/chomens_bot/song/SongLoaderThread.java +++ b/src/main/java/me/chayapak1/chomens_bot/song/SongLoaderThread.java @@ -1,7 +1,6 @@ package me.chayapak1.chomens_bot.song; import me.chayapak1.chomens_bot.Bot; -import me.chayapak1.chomens_bot.util.ColorUtilities; import me.chayapak1.chomens_bot.util.DownloadUtilities; import net.kyori.adventure.text.Component; import net.kyori.adventure.text.format.NamedTextColor; @@ -146,14 +145,14 @@ public class SongLoaderThread extends Thread { bot.chat.tellraw( Component.text( "Added folder to the song queue" - ).color(ColorUtilities.getColorByString(bot.config.colorPalette.defaultColor)) + ).color(bot.colorPalette.defaultColor) ); } else { bot.chat.tellraw( Component.translatable( "Added %s to the song queue", - Component.empty().append(Component.text(song.name)).color(ColorUtilities.getColorByString(bot.config.colorPalette.secondary)) - ).color(ColorUtilities.getColorByString(bot.config.colorPalette.defaultColor)) + Component.empty().append(Component.text(song.name)).color(bot.colorPalette.secondary) + ).color(bot.colorPalette.defaultColor) ); } }