diff --git a/build-number.txt b/build-number.txt index ed8dd329..d9d09400 100644 --- a/build-number.txt +++ b/build-number.txt @@ -1 +1 @@ -3382 \ No newline at end of file +3385 \ No newline at end of file diff --git a/src/main/java/me/chayapak1/chomens_bot/command/TrustLevel.java b/src/main/java/me/chayapak1/chomens_bot/command/TrustLevel.java index b60ca36e..94cfd586 100644 --- a/src/main/java/me/chayapak1/chomens_bot/command/TrustLevel.java +++ b/src/main/java/me/chayapak1/chomens_bot/command/TrustLevel.java @@ -12,9 +12,9 @@ import java.util.Map; public enum TrustLevel { PUBLIC(0, Component.text(I18nUtilities.get("trust_level.public"), NamedTextColor.GREEN)), - TRUSTED(1, Component.text(I18nUtilities.get("trust_level.trusted")).color(NamedTextColor.RED)), - ADMIN(2, Component.text(I18nUtilities.get("trust_level.admin")).color(NamedTextColor.DARK_RED)), - OWNER(3, Component.text(I18nUtilities.get("trust_level.owner")).color(NamedTextColor.LIGHT_PURPLE)); + TRUSTED(1, Component.text(I18nUtilities.get("trust_level.trusted"), NamedTextColor.RED)), + ADMIN(2, Component.text(I18nUtilities.get("trust_level.admin"), NamedTextColor.DARK_RED)), + OWNER(3, Component.text(I18nUtilities.get("trust_level.owner"), NamedTextColor.LIGHT_PURPLE)); public static final TrustLevel MAX = values()[values().length - 1]; 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 e79f4c74..ca52698d 100644 --- a/src/main/java/me/chayapak1/chomens_bot/commands/CloopCommand.java +++ b/src/main/java/me/chayapak1/chomens_bot/commands/CloopCommand.java @@ -51,9 +51,9 @@ public class CloopCommand extends Command { return Component.translatable( "commands.cloop.add.output", bot.colorPalette.defaultColor, - Component.text(command).color(bot.colorPalette.string), - Component.text(interval).color(bot.colorPalette.number), - Component.text(unit.toString()).color(bot.colorPalette.string) + Component.text(command, bot.colorPalette.string), + Component.text(interval, bot.colorPalette.number), + Component.text(unit.toString(), bot.colorPalette.string) ); } case "remove" -> { @@ -66,8 +66,9 @@ public class CloopCommand extends Command { return Component.translatable( "commands.cloop.remove.output", - Component.text(cloop.command()).color(bot.colorPalette.string) - ).color(bot.colorPalette.defaultColor); + bot.colorPalette.defaultColor, + Component.text(cloop.command(), bot.colorPalette.string) + ); } catch (final IndexOutOfBoundsException | IllegalArgumentException | NullPointerException ignored) { throw new CommandException(Component.translatable("commands.generic.error.invalid_index")); } @@ -88,20 +89,21 @@ public class CloopCommand extends Command { cloopsComponent.add( Component.translatable( "%s › %s (%s %s)", - 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) + NamedTextColor.DARK_GRAY, + Component.text(index, bot.colorPalette.number), + Component.text(command.command(), bot.colorPalette.string), + Component.text(command.interval(), bot.colorPalette.number), + Component.text(command.unit().toString(), bot.colorPalette.string) + ) ); index++; } return Component.empty() - .append(Component.translatable("commands.cloop.list.cloops_text").color(NamedTextColor.GREEN)) - .append(Component.text("(").color(NamedTextColor.DARK_GRAY)) - .append(Component.text(bot.cloop.loops.size()).color(NamedTextColor.GRAY)) - .append(Component.text(")").color(NamedTextColor.DARK_GRAY)) + .append(Component.translatable("commands.cloop.list.cloops_text", NamedTextColor.GREEN)) + .append(Component.text("(", NamedTextColor.DARK_GRAY)) + .append(Component.text(bot.cloop.loops.size(), NamedTextColor.GRAY)) + .append(Component.text(")", NamedTextColor.DARK_GRAY)) .append(Component.newline()) .append( Component.join(JoinConfiguration.newlines(), cloopsComponent) 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 a4ee61ac..c39818e1 100644 --- a/src/main/java/me/chayapak1/chomens_bot/commands/CommandBlockCommand.java +++ b/src/main/java/me/chayapak1/chomens_bot/commands/CommandBlockCommand.java @@ -85,11 +85,11 @@ public class CommandBlockCommand extends Command { bot.colorPalette.string, Component.text(256 * layers) ), - Component.text(layers).color(bot.colorPalette.string), - Component.text(from.toString()).color(bot.colorPalette.string), - Component.text(to.toString()).color(bot.colorPalette.string), - Component.text(block.toString()).color(bot.colorPalette.string), - Component.text(bot.world.currentDimension).color(bot.colorPalette.string), + Component.text(layers, bot.colorPalette.string), + Component.text(from.toString(), bot.colorPalette.string), + Component.text(to.toString(), bot.colorPalette.string), + Component.text(block.toString(), bot.colorPalette.string), + Component.text(bot.world.currentDimension, bot.colorPalette.string), Component .translatable("commands.cb.info.click_to_teleport", NamedTextColor.GREEN) .hoverEvent(HoverEvent.showText(Component.text(command, bot.colorPalette.secondary))) 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 b715aa51..fb66eb7e 100644 --- a/src/main/java/me/chayapak1/chomens_bot/commands/ConsoleCommand.java +++ b/src/main/java/me/chayapak1/chomens_bot/commands/ConsoleCommand.java @@ -102,8 +102,8 @@ public class ConsoleCommand extends Command { "commands.console.logtoconsole.set", bot.colorPalette.defaultColor, bool - ? Component.translatable("commands.generic.enabled").color(NamedTextColor.GREEN) - : Component.translatable("commands.generic.disabled").color(NamedTextColor.RED) + ? Component.translatable("commands.generic.enabled", NamedTextColor.GREEN) + : Component.translatable("commands.generic.disabled", NamedTextColor.RED) ); } case "printdisconnectedreason" -> { @@ -117,8 +117,8 @@ public class ConsoleCommand extends Command { "commands.console.printdisconnectedreason.set", bot.colorPalette.defaultColor, bool - ? Component.translatable("commands.generic.enabled").color(NamedTextColor.GREEN) - : Component.translatable("commands.generic.disabled").color(NamedTextColor.RED) + ? Component.translatable("commands.generic.enabled", NamedTextColor.GREEN) + : Component.translatable("commands.generic.disabled", NamedTextColor.RED) ); } } 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 4c3825d0..72cdb3f7 100644 --- a/src/main/java/me/chayapak1/chomens_bot/commands/FilterCommand.java +++ b/src/main/java/me/chayapak1/chomens_bot/commands/FilterCommand.java @@ -82,14 +82,14 @@ public class FilterCommand extends Command { return Component.translatable( "commands.filter.add.no_reason", bot.colorPalette.defaultColor, - Component.text(player).color(bot.colorPalette.username) + Component.text(player, bot.colorPalette.username) ); } else { return Component.translatable( "commands.filter.add.reason", bot.colorPalette.defaultColor, - Component.text(player).color(bot.colorPalette.username), - Component.text(reason).color(bot.colorPalette.string) + Component.text(player, bot.colorPalette.username), + Component.text(reason, bot.colorPalette.string) ); } } @@ -114,7 +114,7 @@ public class FilterCommand extends Command { context.checkOverloadArgs(1); DatabasePlugin.EXECUTOR_SERVICE.execute(bot.playerFilter::clear); - return Component.translatable("commands.filter.clear.output").color(bot.colorPalette.defaultColor); + return Component.translatable("commands.filter.clear.output", bot.colorPalette.defaultColor); } case "list" -> { context.checkOverloadArgs(1); @@ -161,10 +161,11 @@ public class FilterCommand extends Command { filtersComponents.add( Component.translatable( "%s › %s %s", - Component.text(index).color(bot.colorPalette.number), - Component.text(player.playerName()).color(bot.colorPalette.username), + NamedTextColor.DARK_GRAY, + Component.text(index, bot.colorPalette.number), + Component.text(player.playerName(), bot.colorPalette.username), options - ).color(NamedTextColor.DARK_GRAY) + ) ); index++; 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 65818857..5af0a36f 100644 --- a/src/main/java/me/chayapak1/chomens_bot/commands/GrepLogCommand.java +++ b/src/main/java/me/chayapak1/chomens_bot/commands/GrepLogCommand.java @@ -43,7 +43,7 @@ public class GrepLogCommand extends Command { thread = null; - return Component.translatable("commands.greplog.stopped").color(bot.colorPalette.defaultColor); + return Component.translatable("commands.greplog.stopped", bot.colorPalette.defaultColor); } if (thread != null) throw new CommandException(Component.translatable("commands.greplog.error.already_running")); 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 2c8b8f67..74494969 100644 --- a/src/main/java/me/chayapak1/chomens_bot/commands/HelpCommand.java +++ b/src/main/java/me/chayapak1/chomens_bot/commands/HelpCommand.java @@ -56,13 +56,13 @@ public class HelpCommand extends Command { ); return Component.empty() - .append(Component.translatable("commands.help.commands_text").color(NamedTextColor.GRAY)) - .append(Component.text("(").color(NamedTextColor.DARK_GRAY)) - .append(Component.text(list.size()).color(NamedTextColor.GREEN)) - .append(Component.text(") ").color(NamedTextColor.DARK_GRAY)) - .append(Component.text("(").color(NamedTextColor.DARK_GRAY)) + .append(Component.translatable("commands.help.commands_text", NamedTextColor.GRAY)) + .append(Component.text("(", NamedTextColor.DARK_GRAY)) + .append(Component.text(list.size(), NamedTextColor.GREEN)) + .append(Component.text(") ", NamedTextColor.DARK_GRAY)) + .append(Component.text("(", NamedTextColor.DARK_GRAY)) .append(Component.translatable("%s", trustLevels)) - .append(Component.text(") - ").color(NamedTextColor.DARK_GRAY)) + .append(Component.text(") - ", NamedTextColor.DARK_GRAY)) .append(Component.join(JoinConfiguration.separator(Component.space()), list)); } @@ -142,7 +142,7 @@ public class HelpCommand extends Command { usages.add( Component.empty() .color(NamedTextColor.GRAY) - .append(Component.text(prefix + actualCommandName).color(bot.colorPalette.secondary)) + .append(Component.text(prefix + actualCommandName, bot.colorPalette.secondary)) .append( Component .text( @@ -165,7 +165,7 @@ public class HelpCommand extends Command { usages.add( Component.empty() - .append(Component.translatable("commands.help.trust_level").color(NamedTextColor.GREEN)) + .append(Component.translatable("commands.help.trust_level", NamedTextColor.GREEN)) .append( command.trustLevel.component .append(Component.text(" - ")) @@ -175,10 +175,10 @@ public class HelpCommand extends Command { for (final String usage : command.usages) { Component usageComponent = Component.empty() - .append(Component.text(prefix + actualCommandName).color(bot.colorPalette.secondary)) + .append(Component.text(prefix + actualCommandName, bot.colorPalette.secondary)) .append(Component.text(" ")); - usageComponent = usageComponent.append(Component.text(usage).color(bot.colorPalette.string)); + usageComponent = usageComponent.append(Component.text(usage, 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 15efbeb9..4f31d499 100644 --- a/src/main/java/me/chayapak1/chomens_bot/commands/IPFilterCommand.java +++ b/src/main/java/me/chayapak1/chomens_bot/commands/IPFilterCommand.java @@ -57,14 +57,14 @@ public class IPFilterCommand extends Command { return Component.translatable( "commands.filter.add.no_reason", bot.colorPalette.defaultColor, - Component.text(ip).color(bot.colorPalette.username) + Component.text(ip, bot.colorPalette.username) ); } else { return Component.translatable( "commands.filter.add.reason", bot.colorPalette.defaultColor, - Component.text(ip).color(bot.colorPalette.username), - Component.text(reason).color(bot.colorPalette.string) + Component.text(ip, bot.colorPalette.username), + Component.text(reason, bot.colorPalette.string) ); } } @@ -89,7 +89,7 @@ public class IPFilterCommand extends Command { context.checkOverloadArgs(1); DatabasePlugin.EXECUTOR_SERVICE.execute(bot.ipFilter::clear); - return Component.translatable("commands.ipfilter.clear.output").color(bot.colorPalette.defaultColor); + return Component.translatable("commands.ipfilter.clear.output", bot.colorPalette.defaultColor); } case "list" -> { context.checkOverloadArgs(1); @@ -119,10 +119,11 @@ public class IPFilterCommand extends Command { filtersComponents.add( Component.translatable( "%s › %s %s", - Component.text(index).color(bot.colorPalette.number), - Component.text(ip).color(bot.colorPalette.username), + NamedTextColor.DARK_GRAY, + Component.text(index, bot.colorPalette.number), + Component.text(ip, bot.colorPalette.username), reasonComponent - ).color(NamedTextColor.DARK_GRAY) + ) ); index++; 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 36eed00a..b7d0b8e9 100644 --- a/src/main/java/me/chayapak1/chomens_bot/commands/InfoCommand.java +++ b/src/main/java/me/chayapak1/chomens_bot/commands/InfoCommand.java @@ -85,9 +85,8 @@ public class InfoCommand extends Command { "commands.info.discord.output", bot.colorPalette.defaultColor, Component - .text(link) + .text(link, NamedTextColor.BLUE) .clickEvent(ClickEvent.openUrl(link)) - .color(NamedTextColor.BLUE) ); } case "server" -> { @@ -128,8 +127,8 @@ public class InfoCommand extends Command { .filter(line -> line.startsWith("model name")) .findFirst(); final Component cpuModel = modelName - .map(s -> Component.text(s.split("\t: ")[1]).color(color)) - .orElseGet(() -> Component.text("N/A").color(color)); + .map(s -> Component.text(s.split("\t: ")[1], color)) + .orElseGet(() -> Component.text("N/A", color)); InetAddress localHost = null; @@ -140,26 +139,28 @@ public class InfoCommand extends Command { component = Component.translatable( "commands.info.server.output", bot.colorPalette.secondary, - Component.text(localHost == null ? "N/A" : localHost.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), + Component.text(localHost == null ? "N/A" : localHost.getHostName(), color), + Component.text(System.getProperty("user.dir"), color), + Component.text(os.getArch(), color), + Component.text(os.getVersion(), color), + Component.text(os.getName(), color), + Component.text(String.valueOf(Runtime.getRuntime().availableProcessors()), color), cpuModel, - Component.text(String.valueOf(Thread.activeCount())).color(color), + Component.text(String.valueOf(Thread.activeCount()), color), Component .translatable( "%s MB / %s MB", + color, Component.text(heapUsage.getUsed() / 1024L / 1024L), Component.text(heapUsage.getMax() / 1024L / 1024L) - ).color(color), + ), Component .translatable( "%s MB / %s MB", + color, Component.text((Runtime.getRuntime().totalMemory() - Runtime.getRuntime().freeMemory()) / 1024L / 1024L), Component.text(Runtime.getRuntime().totalMemory() / 1024L / 1024L) - ).color(color) + ) ); return component; @@ -247,7 +248,7 @@ public class InfoCommand extends Command { .translatable( "commands.info.default.main_output", bot.colorPalette.defaultColor, - Component.text("ChomeNS Bot").color(NamedTextColor.YELLOW), + Component.text("ChomeNS Bot", NamedTextColor.YELLOW), Component .text("Kaboom") .style( 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 73bad9e0..d8b87b28 100644 --- a/src/main/java/me/chayapak1/chomens_bot/commands/ListCommand.java +++ b/src/main/java/me/chayapak1/chomens_bot/commands/ListCommand.java @@ -52,7 +52,7 @@ public class ListCommand extends Command { final Component hoverEvent = Component .text(entry.profile.getName()) .append(Component.newline()) - .append(Component.text(entry.profile.getIdAsString()).color(bot.colorPalette.uuid)) + .append(Component.text(entry.profile.getIdAsString(), bot.colorPalette.uuid)) .append(Component.newline()) .append(Component.newline()) .append( @@ -139,10 +139,10 @@ public class ListCommand extends Command { } return Component.empty() - .append(Component.translatable("commands.list.players_text").color(NamedTextColor.GREEN)) - .append(Component.text("(").color(NamedTextColor.DARK_GRAY)) - .append(Component.text(list.size()).color(NamedTextColor.GRAY)) - .append(Component.text(")").color(NamedTextColor.DARK_GRAY)) + .append(Component.translatable("commands.list.players_text", NamedTextColor.GREEN)) + .append(Component.text("(", NamedTextColor.DARK_GRAY)) + .append(Component.text(list.size(), NamedTextColor.GRAY)) + .append(Component.text(")", NamedTextColor.DARK_GRAY)) .append(Component.newline()) .append( Component.join(JoinConfiguration.newlines(), playersComponent) 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 02e4dce8..7957d22a 100644 --- a/src/main/java/me/chayapak1/chomens_bot/commands/MailCommand.java +++ b/src/main/java/me/chayapak1/chomens_bot/commands/MailCommand.java @@ -62,7 +62,7 @@ public class MailCommand extends Command { context.sendOutput(Component.translatable("commands.mail.sent", bot.colorPalette.defaultColor)); } catch (final CommandException e) { - context.sendOutput(e.message.color(NamedTextColor.RED)); + context.sendOutput(e.message.colorIfAbsent(NamedTextColor.RED)); } }); case "sendselecteditem" -> { @@ -93,11 +93,11 @@ public class MailCommand extends Command { context.sendOutput(Component.translatable("commands.mail.sent", bot.colorPalette.defaultColor)); } catch (final CommandException e) { - context.sendOutput(e.message.color(NamedTextColor.RED)); + context.sendOutput(e.message.colorIfAbsent(NamedTextColor.RED)); } }); } catch (final CommandException e) { - context.sendOutput(e.message.color(NamedTextColor.RED)); + context.sendOutput(e.message.colorIfAbsent(NamedTextColor.RED)); return null; } @@ -137,6 +137,7 @@ public class MailCommand extends Command { mailsComponent.add( Component.translatable( "commands.mail.read.mail_contents", + NamedTextColor.GREEN, Component.text(count, bot.colorPalette.number), Component.text("-", NamedTextColor.DARK_GRAY), @@ -154,17 +155,17 @@ public class MailCommand extends Command { ) ), Component.text(mail.contents(), NamedTextColor.WHITE) - ).color(NamedTextColor.GREEN) + ) ); count++; } final Component component = Component.empty() - .append(Component.translatable("commands.mail.read.mails_text").color(NamedTextColor.GREEN)) - .append(Component.text("(").color(NamedTextColor.DARK_GRAY)) - .append(Component.text(tempFinalSenderMailSize).color(NamedTextColor.GRAY)) - .append(Component.text(")").color(NamedTextColor.DARK_GRAY)) + .append(Component.translatable("commands.mail.read.mails_text", NamedTextColor.GREEN)) + .append(Component.text("(", NamedTextColor.DARK_GRAY)) + .append(Component.text(tempFinalSenderMailSize, NamedTextColor.GRAY)) + .append(Component.text(")", NamedTextColor.DARK_GRAY)) .append(Component.newline()) .append(Component.join(JoinConfiguration.newlines(), mailsComponent)); diff --git a/src/main/java/me/chayapak1/chomens_bot/commands/NetMessageCommand.java b/src/main/java/me/chayapak1/chomens_bot/commands/NetMessageCommand.java index bf60d1fa..d5273d0c 100644 --- a/src/main/java/me/chayapak1/chomens_bot/commands/NetMessageCommand.java +++ b/src/main/java/me/chayapak1/chomens_bot/commands/NetMessageCommand.java @@ -44,7 +44,7 @@ public class NetMessageCommand extends Command { .hoverEvent( HoverEvent.showText( Component.empty() - .append(Component.text(originServerAddress).color(NamedTextColor.GRAY)) + .append(Component.text(originServerAddress, NamedTextColor.GRAY)) .append(Component.newline()) .append(Component.translatable("commands.netmsg.hover.copy_server_to_clipboard", NamedTextColor.GREEN)) ) @@ -60,7 +60,7 @@ public class NetMessageCommand extends Command { serverNameComponent, Component.space(), context.sender.displayName == null ? - Component.text(context.sender.profile.getName()).color(NamedTextColor.GRAY) : + Component.text(context.sender.profile.getName(), NamedTextColor.GRAY) : context.sender.displayName.color(NamedTextColor.GRAY), Component.space(), Component.empty() 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 c8e0eac6..45d31077 100644 --- a/src/main/java/me/chayapak1/chomens_bot/commands/ScreenshareCommand.java +++ b/src/main/java/me/chayapak1/chomens_bot/commands/ScreenshareCommand.java @@ -67,7 +67,7 @@ public class ScreenshareCommand extends Command { return Component .text("Set the resolution to ") - .append(Component.text(width + "x" + height).color(bot.colorPalette.string)) + .append(Component.text(width + "x" + height, bot.colorPalette.string)) .color(bot.colorPalette.defaultColor); } case "setfps" -> { @@ -79,7 +79,7 @@ public class ScreenshareCommand extends Command { return Component .text("Set the FPS to ") - .append(Component.text(fps).color(bot.colorPalette.number)) + .append(Component.text(fps, bot.colorPalette.number)) .color(bot.colorPalette.defaultColor); } default -> throw new CommandException(Component.translatable("commands.generic.error.invalid_action")); 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 03449e70..979547a4 100644 --- a/src/main/java/me/chayapak1/chomens_bot/commands/StopCommand.java +++ b/src/main/java/me/chayapak1/chomens_bot/commands/StopCommand.java @@ -26,6 +26,6 @@ public class StopCommand extends Command { Main.stop(0, reason.isEmpty() ? null : reason); - return Component.translatable("commands.stop.output").color(bot.colorPalette.defaultColor); + return Component.translatable("commands.stop.output", bot.colorPalette.defaultColor); } } 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 19759e94..67cb45db 100644 --- a/src/main/java/me/chayapak1/chomens_bot/commands/TimeCommand.java +++ b/src/main/java/me/chayapak1/chomens_bot/commands/TimeCommand.java @@ -39,8 +39,8 @@ public class TimeCommand extends Command { return Component.translatable( "commands.time.output", bot.colorPalette.defaultColor, - Component.text(timezone).color(bot.colorPalette.string), - Component.text(formattedTime).color(NamedTextColor.GREEN) + Component.text(timezone, bot.colorPalette.string), + Component.text(formattedTime, NamedTextColor.GREEN) ); } catch (final DateTimeException e) { throw new CommandException(Component.translatable("commands.time.error.invalid_timezone")); 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 3a1952ff..6a1227d3 100644 --- a/src/main/java/me/chayapak1/chomens_bot/commands/TranslateCommand.java +++ b/src/main/java/me/chayapak1/chomens_bot/commands/TranslateCommand.java @@ -71,7 +71,7 @@ public class TranslateCommand extends Command { ) ); } catch (final Exception e) { - context.sendOutput(Component.text(e.toString()).color(NamedTextColor.RED)); + context.sendOutput(Component.text(e.toString(), NamedTextColor.RED)); } }); 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 75c9e1a5..82260264 100644 --- a/src/main/java/me/chayapak1/chomens_bot/commands/UrbanCommand.java +++ b/src/main/java/me/chayapak1/chomens_bot/commands/UrbanCommand.java @@ -159,9 +159,10 @@ public class UrbanCommand extends Command { .append( Component.translatable( "%s - %s", - Component.text(word).color(NamedTextColor.GRAY), + NamedTextColor.DARK_GRAY, + Component.text(word, NamedTextColor.GRAY), definitionComponent - ).color(NamedTextColor.DARK_GRAY) + ) ) .append(Component.newline()); @@ -169,10 +170,11 @@ public class UrbanCommand extends Command { } else { final Component component = Component.translatable( "[%s] %s - %s", - Component.text(index).color(NamedTextColor.GREEN), - Component.text(word).color(NamedTextColor.GRAY), + NamedTextColor.DARK_GRAY, + Component.text(index, NamedTextColor.GREEN), + Component.text(word, NamedTextColor.GRAY), definitionComponent - ).color(NamedTextColor.DARK_GRAY); + ); context.sendOutput(component); } @@ -183,7 +185,7 @@ public class UrbanCommand extends Command { if (discord && !list.isEmpty()) context.sendOutput(discordComponent); } catch (final Exception e) { bot.logger.error(e); - context.sendOutput(Component.text(e.toString()).color(NamedTextColor.RED)); + context.sendOutput(Component.text(e.toString(), NamedTextColor.RED)); } }); 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 8027918a..0726cabe 100644 --- a/src/main/java/me/chayapak1/chomens_bot/commands/WeatherCommand.java +++ b/src/main/java/me/chayapak1/chomens_bot/commands/WeatherCommand.java @@ -49,8 +49,8 @@ public class WeatherCommand extends Command { return Component.translatable( "commands.weather.info", bot.colorPalette.defaultColor, - 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.text(jsonObject.get("location").getAsJsonObject().get("name").getAsString(), bot.colorPalette.string), + Component.text(jsonObject.get("location").getAsJsonObject().get("country").getAsString(), bot.colorPalette.string), Component .empty() .append( 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 60289114..e136455f 100644 --- a/src/main/java/me/chayapak1/chomens_bot/commands/WhitelistCommand.java +++ b/src/main/java/me/chayapak1/chomens_bot/commands/WhitelistCommand.java @@ -86,19 +86,20 @@ public class WhitelistCommand extends Command { playersComponent.add( Component.translatable( "%s › %s", - Component.text(index).color(bot.colorPalette.number), - Component.text(player).color(bot.colorPalette.username) - ).color(NamedTextColor.DARK_GRAY) + NamedTextColor.DARK_GRAY, + Component.text(index, bot.colorPalette.number), + Component.text(player, bot.colorPalette.username) + ) ); index++; } return Component.empty() - .append(Component.translatable("commands.whitelist.whitelisted_players_text").color(NamedTextColor.GREEN)) - .append(Component.text("(").color(NamedTextColor.DARK_GRAY)) - .append(Component.text(bot.whitelist.list.size()).color(NamedTextColor.GRAY)) - .append(Component.text(")").color(NamedTextColor.DARK_GRAY)) + .append(Component.translatable("commands.whitelist.whitelisted_players_text", NamedTextColor.GREEN)) + .append(Component.text("(", NamedTextColor.DARK_GRAY)) + .append(Component.text(bot.whitelist.list.size(), NamedTextColor.GRAY)) + .append(Component.text(")", NamedTextColor.DARK_GRAY)) .append(Component.newline()) .append( Component.join(JoinConfiguration.newlines(), playersComponent) 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 1af64332..99131abe 100644 --- a/src/main/java/me/chayapak1/chomens_bot/commands/WikipediaCommand.java +++ b/src/main/java/me/chayapak1/chomens_bot/commands/WikipediaCommand.java @@ -114,16 +114,16 @@ public class WikipediaCommand extends Command { ) ) .append(Component.newline()) - .append(Component.text(extracted).color(NamedTextColor.GREEN)); + .append(Component.text(extracted, NamedTextColor.GREEN)); context.sendOutput(component); } catch (final NumberFormatException e) { - context.sendOutput(Component.translatable("commands.wikipedia.error.fail_page_id_parse").color(NamedTextColor.RED)); + context.sendOutput(Component.translatable("commands.wikipedia.error.fail_page_id_parse", NamedTextColor.RED)); bot.logger.error(e); } catch (final CommandException e) { context.sendOutput(e.message.color(NamedTextColor.RED)); } catch (final Exception e) { - context.sendOutput(Component.text(e.toString()).color(NamedTextColor.RED)); + context.sendOutput(Component.text(e.toString(), NamedTextColor.RED)); } }); diff --git a/src/main/java/me/chayapak1/chomens_bot/discord/GuildMessageEventHandler.java b/src/main/java/me/chayapak1/chomens_bot/discord/GuildMessageEventHandler.java index 0b1e6fa8..002b24b8 100644 --- a/src/main/java/me/chayapak1/chomens_bot/discord/GuildMessageEventHandler.java +++ b/src/main/java/me/chayapak1/chomens_bot/discord/GuildMessageEventHandler.java @@ -81,23 +81,23 @@ public class GuildMessageEventHandler extends ListenerAdapter { for (final MessageSnapshot snapshot : messageObject.getMessageSnapshots()) { final Component messageComponent = getForwardedMessageComponent(bot, snapshot); - output = Component - .translatable( - "[%s] %s › %s", - this.messagePrefix, - Component - .translatable( - "%s forwarded", - Component.text( - messageObject.getMember() == null ? - messageObject.getAuthor().getName() : - messageObject.getMember().getEffectiveName() - ).color(NamedTextColor.RED) + output = Component.translatable( + "[%s] %s › %s", + NamedTextColor.DARK_GRAY, + this.messagePrefix, + Component + .translatable( + "%s forwarded", + NamedTextColor.GRAY, + Component.text( + messageObject.getMember() == null ? + messageObject.getAuthor().getName() : + messageObject.getMember().getEffectiveName(), + NamedTextColor.RED ) - .color(NamedTextColor.GRAY), - messageComponent.color(NamedTextColor.GRAY) - ) - .color(NamedTextColor.DARK_GRAY); + ), + messageComponent.color(NamedTextColor.GRAY) + ); } } else { final Message reference = event.getMessage().getReferencedMessage(); @@ -106,7 +106,7 @@ public class GuildMessageEventHandler extends ListenerAdapter { output = output .append( Component.empty() - .append(Component.text("Replying to ").color(NamedTextColor.GRAY)) + .append(Component.text("Replying to ", NamedTextColor.GRAY)) .append(getMessageComponent(bot, reference)) .decorate(TextDecoration.ITALIC) ) @@ -175,7 +175,7 @@ public class GuildMessageEventHandler extends ListenerAdapter { Component rolesComponent = Component.empty(); if (!roles.isEmpty()) { rolesComponent = rolesComponent - .append(Component.text("Roles:").color(NamedTextColor.GRAY)) + .append(Component.text("Roles:", NamedTextColor.GRAY)) .append(Component.newline()); final List rolesList = new ArrayList<>(); @@ -200,7 +200,7 @@ public class GuildMessageEventHandler extends ListenerAdapter { rolesComponent = rolesComponent.append(Component.join(JoinConfiguration.newlines(), rolesList)); } else { - rolesComponent = rolesComponent.append(Component.text("No roles").color(NamedTextColor.GRAY)); + rolesComponent = rolesComponent.append(Component.text("No roles", NamedTextColor.GRAY)); } Component nameComponent = Component @@ -214,10 +214,11 @@ public class GuildMessageEventHandler extends ListenerAdapter { %s %s""", - Component.text(username).color(NamedTextColor.WHITE), + NamedTextColor.DARK_GRAY, + Component.text(username, NamedTextColor.WHITE), rolesComponent, - Component.text("Click here to copy the tag to your clipboard").color(NamedTextColor.GREEN) - ).color(NamedTextColor.DARK_GRAY) + Component.text("Click here to copy the tag to your clipboard", NamedTextColor.GREEN) + ) ) ); @@ -273,10 +274,11 @@ public class GuildMessageEventHandler extends ListenerAdapter { return Component.translatable( "[%s] %s › %s", + NamedTextColor.DARK_GRAY, messagePrefix, nameComponent, messageComponent - ).color(NamedTextColor.DARK_GRAY); + ); } private String replaceMessageContent (final String content) { @@ -327,11 +329,11 @@ public class GuildMessageEventHandler extends ListenerAdapter { %s""", NamedTextColor.GREEN, embed.getTitle() == null ? - Component.text("No title").color(NamedTextColor.GRAY) : - Component.text(embed.getTitle()).color(bot.colorPalette.string), + Component.text("No title", NamedTextColor.GRAY) : + Component.text(embed.getTitle(), bot.colorPalette.string), embed.getDescription() == null ? - Component.text("No description").color(NamedTextColor.GRAY) : - Component.text(ComponentUtilities.deserializeFromDiscordAnsi(embed.getDescription())).color(NamedTextColor.WHITE) + Component.text("No description", NamedTextColor.GRAY) : + Component.text(ComponentUtilities.deserializeFromDiscordAnsi(embed.getDescription()), NamedTextColor.WHITE) ); extraComponents.add( diff --git a/src/main/java/me/chayapak1/chomens_bot/plugins/AuthPlugin.java b/src/main/java/me/chayapak1/chomens_bot/plugins/AuthPlugin.java index 71d143a4..bd0feefc 100644 --- a/src/main/java/me/chayapak1/chomens_bot/plugins/AuthPlugin.java +++ b/src/main/java/me/chayapak1/chomens_bot/plugins/AuthPlugin.java @@ -48,15 +48,13 @@ public class AuthPlugin implements Listener { bot.logger.log( LogType.AUTH, Component - .text(I18nUtilities.get("auth.logger_verified")) - .color(NamedTextColor.GREEN) + .text(I18nUtilities.get("auth.logger_verified"), NamedTextColor.GREEN) ); bot.chomeNSMod.sendMessage( target, Component - .text(I18nUtilities.get("auth.player_verified")) - .color(NamedTextColor.GREEN) + .text(I18nUtilities.get("auth.player_verified"), NamedTextColor.GREEN) ); } 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 8f824b61..09c09df5 100644 --- a/src/main/java/me/chayapak1/chomens_bot/plugins/DiscordPlugin.java +++ b/src/main/java/me/chayapak1/chomens_bot/plugins/DiscordPlugin.java @@ -57,11 +57,11 @@ public class DiscordPlugin { this.serverId = config.discord.serverId; this.discordUrl = config.discord.inviteLink; this.messagePrefix = Component.empty() - .append(Component.text("ChomeNS ").color(NamedTextColor.YELLOW)) - .append(Component.text("Discord").color(NamedTextColor.BLUE)) + .append(Component.text("ChomeNS ", NamedTextColor.YELLOW)) + .append(Component.text("Discord", NamedTextColor.BLUE)) .hoverEvent( HoverEvent.showText( - Component.text("Click here to join the Discord server").color(NamedTextColor.GREEN) + Component.text("Click here to join the Discord server", NamedTextColor.GREEN) ) ) .clickEvent(ClickEvent.openUrl(discordUrl)); 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 331d9b0c..80709fe2 100644 --- a/src/main/java/me/chayapak1/chomens_bot/plugins/GrepLogPlugin.java +++ b/src/main/java/me/chayapak1/chomens_bot/plugins/GrepLogPlugin.java @@ -110,8 +110,8 @@ public class GrepLogPlugin { final Component component = Component.translatable("commands.greplog.found") .color(bot.colorPalette.defaultColor) .arguments( - Component.text(formatter.format(matches)).color(bot.colorPalette.number), - Component.text(input).color(bot.colorPalette.string), + Component.text(formatter.format(matches), bot.colorPalette.number), + Component.text(input, bot.colorPalette.string), Component .translatable("commands.greplog.here") .color(NamedTextColor.GREEN) diff --git a/src/main/java/me/chayapak1/chomens_bot/plugins/IRCPlugin.java b/src/main/java/me/chayapak1/chomens_bot/plugins/IRCPlugin.java index 4c99761a..627ff3a1 100644 --- a/src/main/java/me/chayapak1/chomens_bot/plugins/IRCPlugin.java +++ b/src/main/java/me/chayapak1/chomens_bot/plugins/IRCPlugin.java @@ -124,7 +124,7 @@ public class IRCPlugin extends ListenerAdapter { final Component username = Component .text(name) - .hoverEvent(HoverEvent.showText(Component.text(event.getUser().getHostname()).color(NamedTextColor.RED))) + .hoverEvent(HoverEvent.showText(Component.text(event.getUser().getHostname(), NamedTextColor.RED))) .color(NamedTextColor.RED); final Component messageComponent = Component @@ -133,10 +133,11 @@ public class IRCPlugin extends ListenerAdapter { final Component component = Component.translatable( "[%s] %s › %s", + NamedTextColor.DARK_GRAY, prefix, username, messageComponent - ).color(NamedTextColor.DARK_GRAY); + ); bot.chat.tellraw(component); } 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 bf358bd9..f387196f 100644 --- a/src/main/java/me/chayapak1/chomens_bot/plugins/MailPlugin.java +++ b/src/main/java/me/chayapak1/chomens_bot/plugins/MailPlugin.java @@ -62,11 +62,12 @@ public class MailPlugin implements Listener { final Component component = Component.translatable( "You have %s new mail%s!\n" + "Run %s or %s to read", - Component.text(sendToTargetSize).color(NamedTextColor.GREEN), + NamedTextColor.GOLD, + Component.text(sendToTargetSize, NamedTextColor.GREEN), Component.text((sendToTargetSize > 1) ? "s" : ""), - 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); + Component.text(bot.config.commandSpyPrefixes.getFirst() + "mail read", bot.colorPalette.primary), + Component.text(bot.config.prefixes.getFirst() + "mail read", bot.colorPalette.primary) + ); 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 fbfb3179..f3d4a425 100644 --- a/src/main/java/me/chayapak1/chomens_bot/plugins/MusicPlayerPlugin.java +++ b/src/main/java/me/chayapak1/chomens_bot/plugins/MusicPlayerPlugin.java @@ -159,7 +159,7 @@ public class MusicPlayerPlugin implements Listener { Component.translatable( "commands.music.nowplaying", bot.colorPalette.defaultColor, - Component.empty().append(Component.text(currentSong.name)).color(bot.colorPalette.secondary) + Component.empty().append(Component.text(currentSong.name, bot.colorPalette.secondary)) ) ); currentSong.play(); @@ -197,7 +197,7 @@ public class MusicPlayerPlugin implements Listener { Component.translatable( "commands.music.finished", bot.colorPalette.defaultColor, - Component.empty().append(Component.text(currentSong.name)).color(bot.colorPalette.secondary) + Component.empty().append(Component.text(currentSong.name, bot.colorPalette.secondary)) ) ); @@ -329,30 +329,34 @@ public class MusicPlayerPlugin implements Listener { } Component component = Component.empty() - .append(Component.empty().append(Component.text(currentSong.name)).color(nameColor)) - .append(Component.text(" | ").color(NamedTextColor.DARK_GRAY)) + .append(Component.empty().append(Component.text(currentSong.name, nameColor))) + .append(Component.text(" | ", NamedTextColor.DARK_GRAY)) .append( Component - .translatable("%s / %s", - formatTime((long) (currentSong.time / speed)).color(NamedTextColor.GRAY), - formatTime((long) (currentSong.length / speed)).color(NamedTextColor.GRAY)).color(NamedTextColor.DARK_GRAY) + .translatable( + "%s / %s", + NamedTextColor.DARK_GRAY, + formatTime((long) (currentSong.time / speed)).colorIfAbsent(NamedTextColor.GRAY), + formatTime((long) (currentSong.length / speed)).colorIfAbsent(NamedTextColor.GRAY) + ) ); if (!bot.core.hasRateLimit()) { component = component - .append(Component.text(" | ").color(NamedTextColor.DARK_GRAY)) + .append(Component.text(" | ", NamedTextColor.DARK_GRAY)) .append( Component.translatable( "%s / %s", + NamedTextColor.DARK_GRAY, Component.text(FORMATTER.format(currentSong.position), NamedTextColor.GRAY), Component.text(FORMATTER.format(currentSong.size()), NamedTextColor.GRAY) - ).color(NamedTextColor.DARK_GRAY) + ) ); if (!currentLyrics.isBlank()) { component = component .append(Component.text(" | ", NamedTextColor.DARK_GRAY)) - .append(Component.text(currentLyrics).color(NamedTextColor.BLUE)); + .append(Component.text(currentLyrics, NamedTextColor.BLUE)); } } diff --git a/src/main/java/me/chayapak1/chomens_bot/plugins/ScreensharePlugin.java b/src/main/java/me/chayapak1/chomens_bot/plugins/ScreensharePlugin.java index 9975554c..8988415b 100644 --- a/src/main/java/me/chayapak1/chomens_bot/plugins/ScreensharePlugin.java +++ b/src/main/java/me/chayapak1/chomens_bot/plugins/ScreensharePlugin.java @@ -132,7 +132,7 @@ public class ScreensharePlugin { Component name = Component.empty(); for (int x = 0; x < width; x++) { - final Component pixel = Component.text("█").color(TextColor.fromHexString(screen[x][y])); + final Component pixel = Component.text("█", TextColor.fromHexString(screen[x][y])); name = name.append(pixel); } diff --git a/src/main/java/me/chayapak1/chomens_bot/plugins/TPSPlugin.java b/src/main/java/me/chayapak1/chomens_bot/plugins/TPSPlugin.java index d5c10051..ef70595b 100644 --- a/src/main/java/me/chayapak1/chomens_bot/plugins/TPSPlugin.java +++ b/src/main/java/me/chayapak1/chomens_bot/plugins/TPSPlugin.java @@ -80,9 +80,10 @@ public class TPSPlugin implements Listener { final Component component = Component.translatable( "%s - %s", - Component.text("TPS").color(NamedTextColor.GRAY), - Component.text(formatter.format(tickRate)).color(getColor(tickRate)) - ).color(NamedTextColor.DARK_GRAY); + NamedTextColor.DARK_GRAY, + Component.text("TPS", NamedTextColor.GRAY), + Component.text(formatter.format(tickRate), getColor(tickRate)) + ); final BotBossBar bossBar = bot.bossbar.get(bossbarName); diff --git a/src/main/java/me/chayapak1/chomens_bot/util/LoggerUtilities.java b/src/main/java/me/chayapak1/chomens_bot/util/LoggerUtilities.java index bdcb6f67..6dd37749 100644 --- a/src/main/java/me/chayapak1/chomens_bot/util/LoggerUtilities.java +++ b/src/main/java/me/chayapak1/chomens_bot/util/LoggerUtilities.java @@ -19,20 +19,22 @@ public class LoggerUtilities { if (bot != null) { component = Component.translatable( "[%s %s] [%s] [%s] %s", - Component.text(dateTime.format(dateTimeFormatter)).color(NamedTextColor.GRAY), + NamedTextColor.DARK_GRAY, + Component.text(dateTime.format(dateTimeFormatter), NamedTextColor.GRAY), prefix, - Component.text(Thread.currentThread().getName()).color(NamedTextColor.GRAY), - Component.text(bot.options.serverName).color(NamedTextColor.GRAY), - Component.empty().append(message).color(NamedTextColor.WHITE) - ).color(NamedTextColor.DARK_GRAY); + Component.text(Thread.currentThread().getName(), NamedTextColor.GRAY), + Component.text(bot.options.serverName, NamedTextColor.GRAY), + Component.empty().append(message.colorIfAbsent(NamedTextColor.WHITE)) + ); } else { component = Component.translatable( "[%s %s] [%s] %s", - Component.text(dateTime.format(dateTimeFormatter)).color(NamedTextColor.GRAY), + NamedTextColor.DARK_GRAY, + Component.text(dateTime.format(dateTimeFormatter), NamedTextColor.GRAY), prefix, - Component.text(Thread.currentThread().getName()).color(NamedTextColor.GRAY), - Component.empty().append(message).color(NamedTextColor.WHITE) - ).color(NamedTextColor.DARK_GRAY); + Component.text(Thread.currentThread().getName(), NamedTextColor.GRAY), + Component.empty().append(message.colorIfAbsent(NamedTextColor.WHITE)) + ); } return component;