get MiniMessage to work, modified some classes and update in build.gradle, update of gradle wrapper
124 lines
6.5 KiB
Java
124 lines
6.5 KiB
Java
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("<red>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("<gold>Printing About Raxen's MongoDB connection..."));
|
|
msgPlayer(player, coloredString(Raxen.getPrefix()) +
|
|
colorTextComp("<gold>---------------------------------------------"));
|
|
msgPlayer(player, colorTextComp("<red>MONGO DB<white>"));
|
|
msgPlayer(player, StorageManager.getMongodb().getMongoClient().getClusterDescription().toString());
|
|
msgPlayer(player, StorageManager.getMongodb().getMongoDatabase().getName());
|
|
msgPlayer(player, StorageManager.getMongodb().getMongoCollection().getNamespace().toString());
|
|
msgPlayer(player, "<gold>---------------------------------------------");
|
|
}
|
|
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() + "<gold>Printing About Raxen...",
|
|
"<gold>---------------------------------------------",
|
|
"<dark_aqua> Raxen ",
|
|
"<dark_aqua> - Version: " + Raxen.getVersion(),
|
|
"<dark_aqua> - Author: <b><red>U<gold>n<yellow>u<dark_green>r<green>l<aqua>e<dark_aqua>d<reset>");
|
|
TextComponent txt = colorTextComp("<dark_aqua> - Website: https://unurled.gq");
|
|
sender.sendMessage(txt);
|
|
sender.sendMessage(coloredString("<gold>---------------------------------------------"));
|
|
return true;
|
|
}
|
|
case 1 -> {
|
|
switch (args[0]) {
|
|
case "mongodb", "mongo", "MONGODB", "MONGO" -> {
|
|
//print info about connection
|
|
msgSender(sender, Raxen.getPrefix() + "<gold>Printing About Raxen's MongoDB connection...",
|
|
"<gold>---------------------------------------------" + "<red>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("<gold>---------------------------------------------"));
|
|
return true;
|
|
}
|
|
case "v", "version", "ver" -> {
|
|
msgSender(sender, Raxen.getPrefix() + "<gold>Printing About Raxen...",
|
|
"<gold>---------------------------------------------",
|
|
"<dark_aqua> Raxen ",
|
|
"<dark_aqua> - Version: " + Raxen.getVersion(),
|
|
"<dark_aqua> - Author: <b><red>U<gold>n&eu<dark_green>r<green>l<aqua>e<dark_aqua>d<reset>");
|
|
TextComponent txt=colorTextComp("<dark_aqua> - Website: https://unurled.gq");
|
|
sender.sendMessage(txt);
|
|
sender.sendMessage(coloredString("<gold>---------------------------------------------"));
|
|
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() + "<gold>Printing About Raxen...",
|
|
"<gold>---------------------------------------------",
|
|
"<dark_aqua> Raxen ",
|
|
"<dark_aqua> - Version: " + Raxen.getVersion(),
|
|
"<dark_aqua> - Author: <b><red>U<gold>n&eu<dark_green>r<green>l<aqua>e<dark_aqua>d<reset>");
|
|
TextComponent txt = (TextComponent) colorComp("<dark_aqua> - Website: https://unurled.gq")
|
|
.clickEvent(ClickEvent.openUrl("https://unurled.gq"));
|
|
player.sendMessage(txt);
|
|
msgPlayer(player, "", "<gold>---------------------------------------------");
|
|
}
|
|
}
|
|
|
|
@Override
|
|
public @Nullable List<String> onTabComplete(@NotNull CommandSender sender, @NotNull Command command, @NotNull String alias, @NotNull String[] args) {
|
|
return null;
|
|
}
|
|
}
|