package gq.unurled.raxen.commands; import gq.unurled.raxen.Raxen; import gq.unurled.raxen.manager.entity.StorageManager; import net.kyori.adventure.text.TextComponent; import net.kyori.adventure.text.event.ClickEvent; import org.bukkit.command.Command; import org.bukkit.command.CommandSender; import org.bukkit.command.TabExecutor; import org.bukkit.entity.Player; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import java.util.List; import static gq.unurled.raxen.utils.Utils.*; public class RaxenCommand implements TabExecutor { private Raxen main; public RaxenCommand(Raxen main) { this.main = main; } @Override public boolean onCommand(@NotNull CommandSender sender, @NotNull Command cmd, @NotNull String msg, @NotNull String[] args) { if(sender instanceof Player) { Player player = (Player) sender; if(!(player.hasPermission("raxen."))) { msgPlayer(player, coloredString(Raxen.getPrefix()) + colorTextComp("You can't execute this command. Insufficient permission.")); } switch (args.length) { case 0 -> msgPl(player, 0); case 1 -> { switch (args[0]) { case "mongodb", "mongo", "MONGODB", "MONGO" -> { //print info about connection sender.sendMessage(coloredString(Raxen.getPrefix()) + colorTextComp("Printing About Raxen's MongoDB connection...")); msgPlayer(player, coloredString(Raxen.getPrefix()) + colorTextComp("---------------------------------------------")); msgPlayer(player, colorTextComp("MONGO DB")); msgPlayer(player, StorageManager.getMongodb().getMongoClient().getClusterDescription().toString()); msgPlayer(player, StorageManager.getMongodb().getMongoDatabase().getName()); msgPlayer(player, StorageManager.getMongodb().getMongoCollection().getNamespace().toString()); msgPlayer(player, "---------------------------------------------"); } case "v", "version", "ver" -> { msgPl(player, 0); } case "hemlp", "?", "h" -> { //print help } } } } } else { log(String.valueOf(args.length)); switch (args.length) { case 0 -> { msgSender(sender, Raxen.getPrefix() + "Printing About Raxen...", "---------------------------------------------", " Raxen ", " - Version: " + Raxen.getVersion(), " - Author: Unurled"); TextComponent txt = colorTextComp(" - Website: https://unurled.gq"); sender.sendMessage(txt); sender.sendMessage(coloredString("---------------------------------------------")); return true; } case 1 -> { switch (args[0]) { case "mongodb", "mongo", "MONGODB", "MONGO" -> { //print info about connection msgSender(sender, Raxen.getPrefix() + "Printing About Raxen's MongoDB connection...", "---------------------------------------------" + "MONGO DB"); sender.sendMessage(StorageManager.getMongodb().getMongoClient().getClusterDescription().toString()); sender.sendMessage(StorageManager.getMongodb().getMongoDatabase().getName()); sender.sendMessage(StorageManager.getMongodb().getMongoCollection().getNamespace().toString()); sender.sendMessage(coloredString("---------------------------------------------")); return true; } case "v", "version", "ver" -> { msgSender(sender, Raxen.getPrefix() + "Printing About Raxen...", "---------------------------------------------", " Raxen ", " - Version: " + Raxen.getVersion(), " - Author: Un&eurled"); TextComponent txt=colorTextComp(" - Website: https://unurled.gq"); sender.sendMessage(txt); sender.sendMessage(coloredString("---------------------------------------------")); return true; } case "hemlp", "?", "h" -> //print help debug(main, "print help"); } } } } return false; } public void msgPl(Player player, Integer in) { switch(in) { case 0: msgPlayer(player, Raxen.getPrefix() + "Printing About Raxen...", "---------------------------------------------", " Raxen ", " - Version: " + Raxen.getVersion(), " - Author: Un&eurled"); TextComponent txt = (TextComponent) colorComp(" - Website: https://unurled.gq") .clickEvent(ClickEvent.openUrl("https://unurled.gq")); player.sendMessage(txt); msgPlayer(player, "", "---------------------------------------------"); } } @Override public @Nullable List onTabComplete(@NotNull CommandSender sender, @NotNull Command command, @NotNull String alias, @NotNull String[] args) { return null; } }