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

43 lines
1.1 KiB
Java

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
{
public static boolean run(@NotNull CommandSender sender,
@NotNull String[] args)
{
if(args.length < 3)
{
sender.sendMessage("usage: /nouns create <pronoun> <format>");
return true;
}
String pronoun = args[1].toLowerCase();
if(Cache.dbManager.isPronounValid(pronoun))
{
sender.sendMessage("Pronoun already exists!");
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);
return true;
} else {
sender.sendMessage("Error creating new pronoun! Check console for details.");
return true;
}
}
}