40 lines
1.2 KiB
Java
40 lines
1.2 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 NounsUpdateSubCmd
|
||
|
{
|
||
|
|
||
|
|
||
|
public static boolean run(@NotNull CommandSender sender,
|
||
|
@NotNull String[] args) {
|
||
|
|
||
|
|
||
|
if (args.length < 3) {
|
||
|
sender.sendMessage("usage: /nouns update <pronoun> <format>");
|
||
|
return true;
|
||
|
}
|
||
|
|
||
|
String pronoun = args[1].toLowerCase();
|
||
|
if(!Cache.dbManager.isPronounValid(pronoun)) {
|
||
|
sender.sendMessage("Invalid pronoun " + pronoun + "!");
|
||
|
return true;
|
||
|
}
|
||
|
|
||
|
int pronounId = Cache.dbManager.getPronounId(pronoun);
|
||
|
String oldFormat = Cache.dbManager.getPronounFormat(pronounId);
|
||
|
String newFormat = args[2];
|
||
|
|
||
|
if(Cache.dbManager.updatePronounFormat(pronounId, newFormat)) {
|
||
|
sender.sendMessage("Format of pronoun " + pronoun + " updated from " + oldFormat + " to " + newFormat + "!");
|
||
|
return true;
|
||
|
} else {
|
||
|
sender.sendMessage("Error updating pronoun format! Please check console for details.");
|
||
|
return true;
|
||
|
}
|
||
|
|
||
|
}
|
||
|
}
|