NounsPicker/src/main/java/wtf/beatrice/nounspicker/commands/subcommands/NounsCreateSubCommand.java

42 lines
1.1 KiB
Java
Raw Normal View History

2022-10-24 20:35:57 +02:00
package wtf.beatrice.nounspicker.commands.subcommands;
import org.bukkit.command.CommandSender;
import org.jetbrains.annotations.NotNull;
import wtf.beatrice.nounspicker.utils.Cache;
public class NounsCreateSubCommand
2022-10-24 20:35:57 +02:00
{
public static boolean run(@NotNull CommandSender sender,
@NotNull String[] args)
{
if(args.length < 3)
{
sender.sendMessage("usage: /nouns create <pronoun> <format>");
2022-10-24 20:35:57 +02:00
return true;
}
String pronoun = args[1].toLowerCase();
2022-10-24 20:58:44 +02:00
if(Cache.dbManager.isPronounValid(pronoun))
2022-10-24 20:35:57 +02:00
{
sender.sendMessage("Pronoun already exists!");
2022-10-24 20:56:16 +02:00
return true;
}
String format = args[2];
if(Cache.dbManager.addNewPronoun(pronoun, format)) {
int id = Cache.dbManager.getPronounId(pronoun);
sender.sendMessage("New pronoun " + pronoun + " added with id " + id + "! Format is " + format);
2022-10-24 21:11:50 +02:00
return true;
2022-10-24 20:56:16 +02:00
} else {
sender.sendMessage("Error creating new pronoun! Check console for details.");
2022-10-24 21:11:50 +02:00
return true;
2022-10-24 20:35:57 +02:00
}
}
}