Files
Tplus/src/main/java/net/nuggetmc/tplus/command/commands/MainCommand.java

69 lines
2.9 KiB
Java
Raw Normal View History

2021-08-24 19:54:46 -05:00
package net.nuggetmc.tplus.command.commands;
2021-07-21 13:52:21 -05:00
import net.md_5.bungee.api.chat.BaseComponent;
import net.md_5.bungee.api.chat.ClickEvent;
import net.md_5.bungee.api.chat.ComponentBuilder;
import net.md_5.bungee.api.chat.HoverEvent;
import net.md_5.bungee.api.chat.hover.content.Text;
2021-08-24 19:54:46 -05:00
import net.nuggetmc.tplus.TerminatorPlus;
import net.nuggetmc.tplus.command.CommandHandler;
import net.nuggetmc.tplus.command.CommandInstance;
import net.nuggetmc.tplus.command.annotation.Command;
import net.nuggetmc.tplus.utils.ChatUtils;
import org.bukkit.ChatColor;
2021-07-21 17:18:36 -05:00
import org.bukkit.command.CommandSender;
2021-08-24 19:54:46 -05:00
import java.util.List;
2021-08-24 19:54:46 -05:00
public class MainCommand extends CommandInstance {
2021-07-21 13:52:21 -05:00
private BaseComponent[] rootInfo;
2021-08-24 19:54:46 -05:00
public MainCommand(CommandHandler handler, String name, String description, String... aliases) {
super(handler, name, description, aliases);
}
2021-08-24 19:54:46 -05:00
@Command
public void root(CommandSender sender, List<String> args) {
2021-07-21 17:18:36 -05:00
if (rootInfo == null) {
rootInfoSetup();
}
2021-07-21 13:52:21 -05:00
sender.spigot().sendMessage(rootInfo);
}
2021-07-21 13:52:21 -05:00
private void rootInfoSetup() {
ComponentBuilder message = new ComponentBuilder();
String pluginName = TerminatorPlus.getInstance().getName();
message.append(ChatUtils.LINE + "\n");
message.append(ChatColor.GOLD + pluginName + ChatColor.GRAY + " [v" + TerminatorPlus.getVersion() + "]\n");
message.append("\nPlugin Information:\n");
message.append(ChatUtils.BULLET_FORMATTED + "Author" + ChatUtils.BULLET_FORMATTED + ChatColor.YELLOW + "HorseNuggets\n");
message.append(ChatUtils.BULLET_FORMATTED + "Links" + ChatUtils.BULLET_FORMATTED);
message.append(ChatColor.RED + "YouTube");
2021-08-24 19:54:46 -05:00
message.event(new ClickEvent(ClickEvent.Action.OPEN_URL, "https://youtube.com/horsenuggets"));
2021-07-21 13:52:21 -05:00
message.event(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new Text("Click to visit HorseNuggets' " + ChatColor.RED + "YouTube" + ChatColor.RESET + "!")));
message.append(", ");
message.event((ClickEvent) null);
message.event((HoverEvent) null);
message.append(ChatColor.BLUE + "Discord");
2021-08-21 13:36:10 -05:00
message.event(new ClickEvent(ClickEvent.Action.OPEN_URL, "https://discord.gg/horsenuggets"));
2021-07-21 13:52:21 -05:00
message.event(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new Text("Click to visit HorseNuggets' " + ChatColor.BLUE + "Discord" + ChatColor.RESET + "!")));
message.append("\n");
message.event((ClickEvent) null);
message.event((HoverEvent) null);
message.append("\nPlugin Commands:\n");
2021-08-24 19:54:46 -05:00
commandHandler.getCommands().forEach((name, command) -> {
2021-07-21 13:52:21 -05:00
if (!name.equalsIgnoreCase(pluginName)) {
message.append(ChatUtils.BULLET_FORMATTED + ChatColor.YELLOW + "/" + name + ChatUtils.BULLET_FORMATTED + command.getDescription() + "\n");
2021-07-19 17:35:28 -05:00
}
});
2021-06-26 23:58:51 -05:00
2021-07-21 13:52:21 -05:00
message.append(ChatUtils.LINE);
2021-06-26 23:58:51 -05:00
2021-07-21 13:52:21 -05:00
this.rootInfo = message.create();
}
}