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

74 lines
3.1 KiB
Java
Raw Normal View History

2021-07-01 01:12:18 -05:00
package net.nuggetmc.ai.command.commands;
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;
import org.bukkit.ChatColor;
import org.bukkit.entity.Player;
public class MainCommand extends CommandInstance {
2021-07-21 13:52:21 -05:00
private final DrinkCommandService drink;
2021-07-21 13:52:21 -05:00
private BaseComponent[] rootInfo;
2021-07-21 13:52:21 -05:00
public MainCommand(CommandHandler commandHandler, DrinkCommandService drink) {
super(commandHandler);
2021-07-21 13:52:21 -05:00
this.drink = drink;
2021-07-21 13:52:21 -05:00
Bukkit.getScheduler().runTask(TerminatorPlus.getInstance(), this::rootInfoSetup);
}
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 13:52:21 -05:00
public void root(@Sender Player sender) {
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");
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");
message.event(new ClickEvent(ClickEvent.Action.SUGGEST_COMMAND, "lol okay this isn't actually ready yet"));
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();
}
}