Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 7 additions & 9 deletions src/main/java/fr/alexdoru/mwe/commands/CommandAddAlias.java
Original file line number Diff line number Diff line change
Expand Up @@ -72,15 +72,13 @@ public List<String> 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 <player> <alias>" + EnumChatFormatting.GRAY + " - " + EnumChatFormatting.AQUA + "Adds an alias for the player\n"
+ EnumChatFormatting.YELLOW + "/addalias <remove> <player>" + 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 + " <player> <alias>", "Adds an alias for the player" },
{ slashCommand + " <remove> <player>", "Removes the alias for the player" },
{ slashCommand + " list", "Prints list of alias" }
});
}

private void listAlias(String[] args) {
Expand Down
16 changes: 7 additions & 9 deletions src/main/java/fr/alexdoru/mwe/commands/CommandFKCounter.java
Original file line number Diff line number Diff line change
Expand Up @@ -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])) {

this.printCommandHelp();

Expand Down Expand Up @@ -113,14 +113,12 @@ public List<String> 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) {
Expand Down
12 changes: 5 additions & 7 deletions src/main/java/fr/alexdoru/mwe/commands/CommandNocheaters.java
Original file line number Diff line number Diff line change
Expand Up @@ -58,13 +58,11 @@ public List<String> 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) {
Expand Down
25 changes: 11 additions & 14 deletions src/main/java/fr/alexdoru/mwe/commands/CommandPlancke.java
Original file line number Diff line number Diff line change
Expand Up @@ -151,19 +151,16 @@ public List<String> 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 <player>" + EnumChatFormatting.GRAY + " - " + EnumChatFormatting.AQUA + "General Hypixel stats\n"
+ EnumChatFormatting.YELLOW + "/plancke <player> bsg" + EnumChatFormatting.GRAY + " - " + EnumChatFormatting.AQUA + "Blitz stats\n"
+ EnumChatFormatting.YELLOW + "/plancke <player> sw" + EnumChatFormatting.GRAY + " - " + EnumChatFormatting.AQUA + "Skywars stats\n"
+ EnumChatFormatting.YELLOW + "/plancke <player> uhc" + EnumChatFormatting.GRAY + " - " + EnumChatFormatting.AQUA + "UHC stats\n"
+ EnumChatFormatting.YELLOW + "/plancke <player> mw" + EnumChatFormatting.GRAY + " - " + EnumChatFormatting.AQUA + "General Mega Walls stats\n"
+ EnumChatFormatting.YELLOW + "/plancke <player> mw classname" + EnumChatFormatting.GRAY + " - " + EnumChatFormatting.AQUA + "Class specific Mega Walls stats\n"
+ EnumChatFormatting.YELLOW + "/plancke <player> mw cp" + EnumChatFormatting.GRAY + " - " + EnumChatFormatting.AQUA + "Mega Walls classpoints\n"
+ EnumChatFormatting.YELLOW + "/plancke <player> 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 + " <player>", "General Hypixel stats" },
{ slashCommand + " <player> bsg", "Blitz stats" },
{ slashCommand + " <player> sw", "Skywars stats" },
{ slashCommand + " <player> uhc", "UHC stats" },
{ slashCommand + " <player> mw", "General Mega Walls stats" },
{ slashCommand + " <player> mw classname", "Class specific Mega Walls stats" },
{ slashCommand + " <player> mw cp", "Mega Walls classpoints" },
{ slashCommand + " <player> mw leg", "Mega Walls legendary skins" },
});
}

}
22 changes: 10 additions & 12 deletions src/main/java/fr/alexdoru/mwe/commands/CommandSquad.java
Original file line number Diff line number Diff line change
Expand Up @@ -93,18 +93,16 @@ public List<String> 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 <player>" + GRAY + " - " + AQUA + "add a player to the squad\n"
+ YELLOW + "/squad add <player> 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 <player>" + 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 <player>", "add a player to the squad" },
{ slashCommand + " add <player> 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 <player>", "remove a player from the squad" },
{ slashCommand + " list", "list players in the squad" },
{ slashCommand + " disband", "disband the squad" }
});
}

private static void addSquadMembers(String[] args) {
Expand Down
42 changes: 42 additions & 0 deletions src/main/java/fr/alexdoru/mwe/commands/MyAbstractCommand.java
Original file line number Diff line number Diff line change
@@ -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 {

Expand Down Expand Up @@ -33,4 +40,39 @@ protected static void sendChatMessage(String msg) {
}
}

protected static boolean isHelpSubcommand(String subcommand) {
return "h".equalsIgnoreCase(subcommand) || "help".equalsIgnoreCase(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)
);
}
}