From 78e7f7043a9ac4da3f88d82c17a8ef475442b11c Mon Sep 17 00:00:00 2001 From: shvaich <260186867+shvaich@users.noreply.github.com> Date: Mon, 20 Jul 2026 10:26:12 +0300 Subject: [PATCH 1/4] added helper methods to structure the command help message. i believe these methods should be available to other devs aswell --- .../mwe/commands/MyAbstractCommand.java | 42 +++++++++++++++++++ 1 file changed, 42 insertions(+) diff --git a/src/main/java/fr/alexdoru/mwe/commands/MyAbstractCommand.java b/src/main/java/fr/alexdoru/mwe/commands/MyAbstractCommand.java index 29130e64..13354857 100644 --- a/src/main/java/fr/alexdoru/mwe/commands/MyAbstractCommand.java +++ b/src/main/java/fr/alexdoru/mwe/commands/MyAbstractCommand.java @@ -1,8 +1,15 @@ package fr.alexdoru.mwe.commands; +import fr.alexdoru.mwe.chat.ChatUtil; import net.minecraft.client.Minecraft; import net.minecraft.command.CommandBase; import net.minecraft.command.ICommandSender; +import net.minecraft.event.ClickEvent; +import net.minecraft.event.HoverEvent; +import net.minecraft.util.ChatComponentText; +import net.minecraft.util.ChatStyle; +import net.minecraft.util.EnumChatFormatting; +import net.minecraft.util.IChatComponent; public abstract class MyAbstractCommand extends CommandBase { @@ -33,4 +40,39 @@ protected static void sendChatMessage(String msg) { } } + protected static boolean isHelpSubcommand(String subcommand) { + return "h".equals(subcommand) || "help".equals(subcommand); + } + + /** + * @param header Block Header + * @param commandLines Each command-line must be in this format: { command, description, [commandToPutOnClick] }. + * if (commandToPutOnClick) isn't provided will use (command) + */ + protected static IChatComponent getCommandHelpBlockText(String header, String[][] commandLines) { + final IChatComponent msg = new ChatComponentText(ChatUtil.centerLine(EnumChatFormatting.GOLD + header + "\n")); + for (final String[] line : commandLines) { + final String command = line[0]; + final String desc = line[1]; + final String commandToPutOnClick = line.length > 2 ? line[2] : command; + msg.appendSibling(new ChatComponentText("\n" + EnumChatFormatting.YELLOW + command + EnumChatFormatting.GRAY + " - " + EnumChatFormatting.AQUA + desc) + .setChatStyle(new ChatStyle() + .setChatHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new ChatComponentText(EnumChatFormatting.GRAY + "Click to put the command in chat."))) + .setChatClickEvent(new ClickEvent(ClickEvent.Action.SUGGEST_COMMAND, commandToPutOnClick)) + ) + ); + } + return msg; + } + + /** Prints command help lines grouped inside 2 horizontal bars + * @see #getCommandHelpBlockText(String, String[][]) + */ + protected static void printCommandHelpBlock(EnumChatFormatting barColor, String header, String[][] commandLines) { + final String bar = barColor + ChatUtil.bar(); + ChatUtil.addChatMessage(new ChatComponentText(bar + "\n") + .appendSibling(getCommandHelpBlockText(header, commandLines)) + .appendText("\n" + bar) + ); + } } From 3725c87e65dbf263f09e6c5f11107a6aa5cbd952 Mon Sep 17 00:00:00 2001 From: shvaich <260186867+shvaich@users.noreply.github.com> Date: Mon, 20 Jul 2026 10:34:43 +0300 Subject: [PATCH 2/4] updated all to use new method to print command help message --- .../mwe/commands/CommandAddAlias.java | 16 ++++++------ .../mwe/commands/CommandFKCounter.java | 16 ++++++------ .../mwe/commands/CommandNocheaters.java | 12 ++++----- .../alexdoru/mwe/commands/CommandPlancke.java | 25 ++++++++----------- .../alexdoru/mwe/commands/CommandSquad.java | 22 ++++++++-------- 5 files changed, 40 insertions(+), 51 deletions(-) diff --git a/src/main/java/fr/alexdoru/mwe/commands/CommandAddAlias.java b/src/main/java/fr/alexdoru/mwe/commands/CommandAddAlias.java index afffe57c..cdff3ca4 100644 --- a/src/main/java/fr/alexdoru/mwe/commands/CommandAddAlias.java +++ b/src/main/java/fr/alexdoru/mwe/commands/CommandAddAlias.java @@ -76,15 +76,13 @@ public List getCommandAliases() { @Override protected void printCommandHelp() { - ChatUtil.addChatMessage( - EnumChatFormatting.GREEN + ChatUtil.bar() + "\n" - + ChatUtil.centerLine(EnumChatFormatting.GOLD + "AddAlias Help\n\n") - + EnumChatFormatting.YELLOW + "/addalias" + EnumChatFormatting.GRAY + " - " + EnumChatFormatting.AQUA + "Lists the alias in the lobby\n" - + EnumChatFormatting.YELLOW + "/addalias " + EnumChatFormatting.GRAY + " - " + EnumChatFormatting.AQUA + "Adds an alias for the player\n" - + EnumChatFormatting.YELLOW + "/addalias " + EnumChatFormatting.GRAY + " - " + EnumChatFormatting.AQUA + "Removes the alias for the player\n" - + EnumChatFormatting.YELLOW + "/addalias list" + EnumChatFormatting.GRAY + " - " + EnumChatFormatting.AQUA + "Prints list of alias\n" - + EnumChatFormatting.GREEN + ChatUtil.bar() - ); + final String slashCommand = '/' + getCommandName(); + printCommandHelpBlock(EnumChatFormatting.GREEN, "AddAlias Help", new String[][]{ + { slashCommand, "Lists the alias in the lobby" }, + { slashCommand + " ", "Adds an alias for the player" }, + { slashCommand + " ", "Removes the alias for the player" }, + { slashCommand + " list", "Prints list of alias" } + }); } private void listAlias(String[] args) { diff --git a/src/main/java/fr/alexdoru/mwe/commands/CommandFKCounter.java b/src/main/java/fr/alexdoru/mwe/commands/CommandFKCounter.java index b2fb642e..8492885a 100644 --- a/src/main/java/fr/alexdoru/mwe/commands/CommandFKCounter.java +++ b/src/main/java/fr/alexdoru/mwe/commands/CommandFKCounter.java @@ -64,7 +64,7 @@ public void processCommand(ICommandSender sender, String[] args) { sendChatMessage("You shouldn't ask for finals and instead try to final kill everyone to win the game!"); - } else if (args.length > 0 && args[0].equalsIgnoreCase("help")) { + } else if (args.length > 0 && isHelpSubcommand(args[0].toLowerCase(Locale.ENGLISH))) { this.printCommandHelp(); @@ -113,14 +113,12 @@ public List addTabCompletionOptions(ICommandSender sender, String[] args @Override protected void printCommandHelp() { - ChatUtil.addChatMessage( - EnumChatFormatting.AQUA + ChatUtil.bar() + "\n" - + ChatUtil.centerLine(EnumChatFormatting.GOLD + "Fks Help") + "\n\n" - + EnumChatFormatting.YELLOW + "/fks" + EnumChatFormatting.GRAY + " - " + EnumChatFormatting.AQUA + "prints the amount of finals per team in the chat\n" - + EnumChatFormatting.YELLOW + "/fks players" + EnumChatFormatting.GRAY + " - " + EnumChatFormatting.AQUA + "prints the amount of finals per player in the chat\n" - + EnumChatFormatting.YELLOW + "/fks settings" + EnumChatFormatting.GRAY + " - " + EnumChatFormatting.AQUA + "opens the settings GUI\n" - + EnumChatFormatting.AQUA + ChatUtil.bar() - ); + final String slashCommand = '/' + getCommandName(); + printCommandHelpBlock(EnumChatFormatting.AQUA, "Fks Help", new String[][]{ + { slashCommand, "prints the amount of finals per team in the chat" }, + { slashCommand + " players", "prints the amount of finals per player in the chat" }, + { slashCommand + " settings", "opens the settings GUI" } + }); } private void removePlayer(String playerName) { diff --git a/src/main/java/fr/alexdoru/mwe/commands/CommandNocheaters.java b/src/main/java/fr/alexdoru/mwe/commands/CommandNocheaters.java index 3927cd79..ab182cb2 100644 --- a/src/main/java/fr/alexdoru/mwe/commands/CommandNocheaters.java +++ b/src/main/java/fr/alexdoru/mwe/commands/CommandNocheaters.java @@ -58,13 +58,11 @@ public List addTabCompletionOptions(ICommandSender sender, String[] args @Override protected void printCommandHelp() { - ChatUtil.addChatMessage( - RED + ChatUtil.bar() + "\n" - + ChatUtil.centerLine(GOLD + "NoCheaters Help\n\n") - + YELLOW + getCommandUsage(null) + GRAY + " - " + AQUA + "prints the list of reported players in your current world\n" - + YELLOW + getCommandUsage(null) + " reportlist" + GRAY + " - " + AQUA + "prints the list of reported players\n" - + RED + ChatUtil.bar() - ); + final String slashCommand = '/' + getCommandName(); + printCommandHelpBlock(RED, "NoCheaters Help", new String[][]{ + { slashCommand, "prints the list of reported players in your current world" }, + { slashCommand + " reportlist", "prints the list of reported players" } + }); } private void printReportList(String[] args) { diff --git a/src/main/java/fr/alexdoru/mwe/commands/CommandPlancke.java b/src/main/java/fr/alexdoru/mwe/commands/CommandPlancke.java index 79e221f1..a7a7f6dc 100644 --- a/src/main/java/fr/alexdoru/mwe/commands/CommandPlancke.java +++ b/src/main/java/fr/alexdoru/mwe/commands/CommandPlancke.java @@ -151,19 +151,16 @@ public List addTabCompletionOptions(ICommandSender sender, String[] args @Override protected void printCommandHelp() { - ChatUtil.addChatMessage( - EnumChatFormatting.AQUA + ChatUtil.bar() + "\n" - + ChatUtil.centerLine(EnumChatFormatting.GOLD + "Plancke Help\n\n") - + EnumChatFormatting.YELLOW + "/plancke " + EnumChatFormatting.GRAY + " - " + EnumChatFormatting.AQUA + "General Hypixel stats\n" - + EnumChatFormatting.YELLOW + "/plancke bsg" + EnumChatFormatting.GRAY + " - " + EnumChatFormatting.AQUA + "Blitz stats\n" - + EnumChatFormatting.YELLOW + "/plancke sw" + EnumChatFormatting.GRAY + " - " + EnumChatFormatting.AQUA + "Skywars stats\n" - + EnumChatFormatting.YELLOW + "/plancke uhc" + EnumChatFormatting.GRAY + " - " + EnumChatFormatting.AQUA + "UHC stats\n" - + EnumChatFormatting.YELLOW + "/plancke mw" + EnumChatFormatting.GRAY + " - " + EnumChatFormatting.AQUA + "General Mega Walls stats\n" - + EnumChatFormatting.YELLOW + "/plancke mw classname" + EnumChatFormatting.GRAY + " - " + EnumChatFormatting.AQUA + "Class specific Mega Walls stats\n" - + EnumChatFormatting.YELLOW + "/plancke mw cp" + EnumChatFormatting.GRAY + " - " + EnumChatFormatting.AQUA + "Mega Walls classpoints\n" - + EnumChatFormatting.YELLOW + "/plancke mw leg" + EnumChatFormatting.GRAY + " - " + EnumChatFormatting.AQUA + "Mega Walls legendary skins\n" - + EnumChatFormatting.AQUA + ChatUtil.bar() - ); + final String slashCommand = '/' + getCommandName(); + printCommandHelpBlock(EnumChatFormatting.AQUA, "Plancke Help", new String[][]{ + { slashCommand + " ", "General Hypixel stats" }, + { slashCommand + " bsg", "Blitz stats" }, + { slashCommand + " sw", "Skywars stats" }, + { slashCommand + " uhc", "UHC stats" }, + { slashCommand + " mw", "General Mega Walls stats" }, + { slashCommand + " mw classname", "Class specific Mega Walls stats" }, + { slashCommand + " mw cp", "Mega Walls classpoints" }, + { slashCommand + " mw leg", "Mega Walls legendary skins" }, + }); } - } diff --git a/src/main/java/fr/alexdoru/mwe/commands/CommandSquad.java b/src/main/java/fr/alexdoru/mwe/commands/CommandSquad.java index d425cffa..4797fb01 100644 --- a/src/main/java/fr/alexdoru/mwe/commands/CommandSquad.java +++ b/src/main/java/fr/alexdoru/mwe/commands/CommandSquad.java @@ -93,18 +93,16 @@ public List addTabCompletionOptions(ICommandSender sender, String[] args @Override protected void printCommandHelp() { - ChatUtil.addChatMessage( - GREEN + ChatUtil.bar() + "\n" - + ChatUtil.centerLine(GOLD + "Squad Help\n\n") - + YELLOW + "/squad add " + GRAY + " - " + AQUA + "add a player to the squad\n" - + YELLOW + "/squad add as Nickname" + GRAY + " - " + AQUA + "add a player to the squad and change their name\n" - + YELLOW + "/squad addteam" + GRAY + " - " + AQUA + "add all your teamates to the squad\n" - + YELLOW + "/squad formsquad" + GRAY + " - " + AQUA + "add your teamates to the squad when in a MW pre game\n" - + YELLOW + "/squad remove " + GRAY + " - " + AQUA + "remove a player from the squad\n" - + YELLOW + "/squad list" + GRAY + " - " + AQUA + "list players in the squad\n" - + YELLOW + "/squad disband" + GRAY + " - " + AQUA + "disband the squad\n" - + GREEN + ChatUtil.bar() - ); + final String slashCommand = '/' + getCommandName(); + printCommandHelpBlock(GREEN, "Squad Help", new String[][]{ + { slashCommand + " add ", "add a player to the squad" }, + { slashCommand + " add as Nickname", "add a player to the squad and change their name" }, + { slashCommand + " addteam", "add all your teammates to the squad" }, + { slashCommand + " formsquad", "add your teammates to the squad when in a MW pre game" }, + { slashCommand + " remove ", "remove a player from the squad" }, + { slashCommand + " list", "list players in the squad" }, + { slashCommand + " disband", "disband the squad" } + }); } private static void addSquadMembers(String[] args) { From 0d3e5d37e347244ac6f444696154e649dd5cb48d Mon Sep 17 00:00:00 2001 From: shvaich <260186867+shvaich@users.noreply.github.com> Date: Mon, 20 Jul 2026 10:51:34 +0300 Subject: [PATCH 3/4] updated 'isHelpSubcommand' method to ignore case by itself --- src/main/java/fr/alexdoru/mwe/commands/CommandFKCounter.java | 2 +- src/main/java/fr/alexdoru/mwe/commands/MyAbstractCommand.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/fr/alexdoru/mwe/commands/CommandFKCounter.java b/src/main/java/fr/alexdoru/mwe/commands/CommandFKCounter.java index 8492885a..f68caf12 100644 --- a/src/main/java/fr/alexdoru/mwe/commands/CommandFKCounter.java +++ b/src/main/java/fr/alexdoru/mwe/commands/CommandFKCounter.java @@ -64,7 +64,7 @@ public void processCommand(ICommandSender sender, String[] args) { sendChatMessage("You shouldn't ask for finals and instead try to final kill everyone to win the game!"); - } else if (args.length > 0 && isHelpSubcommand(args[0].toLowerCase(Locale.ENGLISH))) { + } else if (args.length > 0 && isHelpSubcommand(args[0])) { this.printCommandHelp(); diff --git a/src/main/java/fr/alexdoru/mwe/commands/MyAbstractCommand.java b/src/main/java/fr/alexdoru/mwe/commands/MyAbstractCommand.java index 13354857..72159947 100644 --- a/src/main/java/fr/alexdoru/mwe/commands/MyAbstractCommand.java +++ b/src/main/java/fr/alexdoru/mwe/commands/MyAbstractCommand.java @@ -41,7 +41,7 @@ protected static void sendChatMessage(String msg) { } protected static boolean isHelpSubcommand(String subcommand) { - return "h".equals(subcommand) || "help".equals(subcommand); + return "h".equalsIgnoreCase(subcommand) || "help".equalsIgnoreCase(subcommand); } /** From bfd22fffd4a77bf6b36d84460a0050d717c95921 Mon Sep 17 00:00:00 2001 From: Alexdoru <57050655+Alexdoru@users.noreply.github.com> Date: Wed, 22 Jul 2026 20:05:03 +0200 Subject: [PATCH 4/4] my changes --- .../alexdoru/mwe/commands/CommandSquad.java | 2 +- .../mwe/commands/MyAbstractCommand.java | 36 +++++++++---------- 2 files changed, 18 insertions(+), 20 deletions(-) diff --git a/src/main/java/fr/alexdoru/mwe/commands/CommandSquad.java b/src/main/java/fr/alexdoru/mwe/commands/CommandSquad.java index 4797fb01..924c454c 100644 --- a/src/main/java/fr/alexdoru/mwe/commands/CommandSquad.java +++ b/src/main/java/fr/alexdoru/mwe/commands/CommandSquad.java @@ -96,7 +96,7 @@ protected void printCommandHelp() { final String slashCommand = '/' + getCommandName(); printCommandHelpBlock(GREEN, "Squad Help", new String[][]{ { slashCommand + " add ", "add a player to the squad" }, - { slashCommand + " add as Nickname", "add a player to the squad and change their name" }, + {slashCommand + " add as ", "add a player to the squad and change their name"}, { slashCommand + " addteam", "add all your teammates to the squad" }, { slashCommand + " formsquad", "add your teammates to the squad when in a MW pre game" }, { slashCommand + " remove ", "remove a player from the squad" }, diff --git a/src/main/java/fr/alexdoru/mwe/commands/MyAbstractCommand.java b/src/main/java/fr/alexdoru/mwe/commands/MyAbstractCommand.java index 72159947..5ba0f106 100644 --- a/src/main/java/fr/alexdoru/mwe/commands/MyAbstractCommand.java +++ b/src/main/java/fr/alexdoru/mwe/commands/MyAbstractCommand.java @@ -9,7 +9,6 @@ import net.minecraft.util.ChatComponentText; import net.minecraft.util.ChatStyle; import net.minecraft.util.EnumChatFormatting; -import net.minecraft.util.IChatComponent; public abstract class MyAbstractCommand extends CommandBase { @@ -44,35 +43,34 @@ protected static boolean isHelpSubcommand(String subcommand) { return "h".equalsIgnoreCase(subcommand) || "help".equalsIgnoreCase(subcommand); } + /** + * Prints command help lines grouped inside 2 horizontal bars + * + * @see #printCommandHelpBlock(String, String[][]) + */ + protected static void printCommandHelpBlock(EnumChatFormatting barColor, String header, String[][] commandLines) { + final String bar = barColor + ChatUtil.bar(); + ChatUtil.addChatMessage(new ChatComponentText(bar)); + MyAbstractCommand.printCommandHelpBlock(header, commandLines); + ChatUtil.addChatMessage(new ChatComponentText(bar)); + } + /** * @param header Block Header * @param commandLines Each command-line must be in this format: { command, description, [commandToPutOnClick] }. * if (commandToPutOnClick) isn't provided will use (command) */ - protected static IChatComponent getCommandHelpBlockText(String header, String[][] commandLines) { - final IChatComponent msg = new ChatComponentText(ChatUtil.centerLine(EnumChatFormatting.GOLD + header + "\n")); + private static void printCommandHelpBlock(String header, String[][] commandLines) { + ChatUtil.addChatMessage(new ChatComponentText(ChatUtil.centerLine(EnumChatFormatting.GOLD + header))); for (final String[] line : commandLines) { + if (line.length!=2) continue; final String command = line[0]; final String desc = line[1]; - final String commandToPutOnClick = line.length > 2 ? line[2] : command; - msg.appendSibling(new ChatComponentText("\n" + EnumChatFormatting.YELLOW + command + EnumChatFormatting.GRAY + " - " + EnumChatFormatting.AQUA + desc) + ChatUtil.addChatMessage(new ChatComponentText(EnumChatFormatting.YELLOW + command + EnumChatFormatting.GRAY + " - " + EnumChatFormatting.AQUA + desc) .setChatStyle(new ChatStyle() .setChatHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new ChatComponentText(EnumChatFormatting.GRAY + "Click to put the command in chat."))) - .setChatClickEvent(new ClickEvent(ClickEvent.Action.SUGGEST_COMMAND, commandToPutOnClick)) - ) + .setChatClickEvent(new ClickEvent(ClickEvent.Action.SUGGEST_COMMAND, command))) ); } - return msg; - } - - /** Prints command help lines grouped inside 2 horizontal bars - * @see #getCommandHelpBlockText(String, String[][]) - */ - protected static void printCommandHelpBlock(EnumChatFormatting barColor, String header, String[][] commandLines) { - final String bar = barColor + ChatUtil.bar(); - ChatUtil.addChatMessage(new ChatComponentText(bar + "\n") - .appendSibling(getCommandHelpBlockText(header, commandLines)) - .appendText("\n" + bar) - ); } }