2021-07-01 01:12:18 -05:00
|
|
|
package net.nuggetmc.ai.command.commands;
|
2021-06-26 19:08:15 -07:00
|
|
|
|
2021-07-16 03:41:21 -05:00
|
|
|
import com.jonahseguin.drink.annotation.Command;
|
|
|
|
|
import com.jonahseguin.drink.annotation.Sender;
|
2021-07-21 13:52:21 -05:00
|
|
|
import com.jonahseguin.drink.command.DrinkCommandService;
|
2021-07-01 01:12:18 -05:00
|
|
|
import com.jonahseguin.drink.utils.ChatUtils;
|
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;
|
|
|
|
|
import net.nuggetmc.ai.TerminatorPlus;
|
2021-07-01 01:12:18 -05:00
|
|
|
import net.nuggetmc.ai.command.CommandHandler;
|
|
|
|
|
import net.nuggetmc.ai.command.CommandInstance;
|
2021-07-19 17:35:28 -05:00
|
|
|
import org.bukkit.Bukkit;
|
2021-06-26 19:08:15 -07:00
|
|
|
import org.bukkit.ChatColor;
|
2021-07-21 17:18:36 -05:00
|
|
|
import org.bukkit.command.CommandSender;
|
2021-06-26 19:08:15 -07:00
|
|
|
|
2021-07-10 23:51:14 -05:00
|
|
|
public class MainCommand extends CommandInstance {
|
2021-06-26 19:08:15 -07:00
|
|
|
|
2021-07-21 13:52:21 -05:00
|
|
|
private final DrinkCommandService drink;
|
2021-06-28 13:18:49 -05:00
|
|
|
|
2021-07-21 13:52:21 -05:00
|
|
|
private BaseComponent[] rootInfo;
|
2021-06-26 19:08:15 -07:00
|
|
|
|
2021-07-21 13:52:21 -05:00
|
|
|
public MainCommand(CommandHandler commandHandler, DrinkCommandService drink) {
|
|
|
|
|
super(commandHandler);
|
2021-06-26 19:08:15 -07:00
|
|
|
|
2021-07-21 13:52:21 -05:00
|
|
|
this.drink = drink;
|
2021-06-28 13:18:49 -05:00
|
|
|
|
2021-07-21 13:52:21 -05:00
|
|
|
Bukkit.getScheduler().runTask(TerminatorPlus.getInstance(), this::rootInfoSetup);
|
2021-06-26 19:08:15 -07:00
|
|
|
}
|
|
|
|
|
|
2021-07-04 03:15:30 -05:00
|
|
|
@Command(
|
2021-07-21 13:52:21 -05:00
|
|
|
desc = "The TerminatorPlus main command."
|
2021-07-04 03:15:30 -05:00
|
|
|
)
|
2021-07-21 17:18:36 -05:00
|
|
|
public void root(@Sender CommandSender sender) {
|
|
|
|
|
if (rootInfo == null) {
|
|
|
|
|
rootInfoSetup();
|
|
|
|
|
}
|
|
|
|
|
|
2021-07-21 13:52:21 -05:00
|
|
|
sender.spigot().sendMessage(rootInfo);
|
2021-06-26 19:08:15 -07:00
|
|
|
}
|
|
|
|
|
|
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");
|
|
|
|
|
message.event(new ClickEvent(ClickEvent.Action.OPEN_URL, "https://www.youtube.com/horsenuggets"));
|
|
|
|
|
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");
|
|
|
|
|
|
|
|
|
|
drink.getCommands().forEach((name, command) -> {
|
|
|
|
|
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();
|
2021-06-26 19:08:15 -07:00
|
|
|
}
|
|
|
|
|
}
|