From eb762c34414354123f62795e51edb0b47161edb4 Mon Sep 17 00:00:00 2001 From: Chip <65827213+ChipmunkMC@users.noreply.github.com> Date: Fri, 20 Jan 2023 18:36:57 -0500 Subject: [PATCH] info command --- .../chipmunkbot/commands/InfoCommand.java | 25 +++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) diff --git a/src/main/java/land/chipmunk/chipmunkbot/commands/InfoCommand.java b/src/main/java/land/chipmunk/chipmunkbot/commands/InfoCommand.java index 411eccb..9191297 100644 --- a/src/main/java/land/chipmunk/chipmunkbot/commands/InfoCommand.java +++ b/src/main/java/land/chipmunk/chipmunkbot/commands/InfoCommand.java @@ -11,8 +11,7 @@ import com.mojang.brigadier.tree.CommandNode; import com.mojang.brigadier.context.CommandContext; import net.kyori.adventure.text.Component; import net.kyori.adventure.text.format.NamedTextColor; -import net.kyori.adventure.text.event.HoverEvent; -import net.kyori.adventure.text.JoinConfiguration; +import net.kyori.adventure.text.event.ClickEvent; import java.util.List; import java.util.ArrayList; import java.net.InetAddress; @@ -20,11 +19,14 @@ import java.lang.management.*; import java.io.IOException; public class InfoCommand extends Command { + private static final String REPOSITORY_URL = "https://code.chipmunk.land/ChipmunkMC/chipmunkbot"; + public InfoCommand () { super(); this.node( literal("info") + .executes(this::sendBotInfo) .then( literal("server") .executes(this::sendServerInfo) @@ -32,6 +34,25 @@ public class InfoCommand extends Command { ); } + public int sendBotInfo (CommandContext context) { + final CommandSource source = context.getSource(); + + final Component component = Component.empty() + .append(Component.text("ChipmunkBot", NamedTextColor.GREEN)) + .append(Component.text(" - A utility bot for free-operator servers with minimal or no restrictions", NamedTextColor.GRAY)) + .append(Component.newline()) + .append(Component.text("Made by ", NamedTextColor.GRAY)) + .append(Component.text("_ChipMC_", NamedTextColor.DARK_GREEN)) + .append(Component.text(" and contributors", NamedTextColor.GRAY)) + .append(Component.newline()) + .append(Component.text("Repository: ", NamedTextColor.GRAY)) + .append(Component.text(REPOSITORY_URL, NamedTextColor.GREEN).clickEvent(ClickEvent.openUrl(REPOSITORY_URL))); + + source.sendOutput(component, false); + + return 1; + } + public int sendServerInfo (CommandContext context) { final CommandSource source = context.getSource();