Beatrice DellacĂ
cf11743a44
All checks were successful
continuous-integration/drone/push Build is passing
48 lines
1.5 KiB
Java
48 lines
1.5 KiB
Java
package wtf.beatrice.nounspicker.commands.subcommands;
|
|
|
|
import org.bukkit.command.CommandSender;
|
|
import org.jetbrains.annotations.NotNull;
|
|
import wtf.beatrice.nounspicker.objects.Permission;
|
|
import wtf.beatrice.nounspicker.utils.Cache;
|
|
import wtf.beatrice.nounspicker.utils.PermissionManager;
|
|
|
|
public class NounsUpdateSubCmd
|
|
{
|
|
|
|
|
|
public static boolean run(@NotNull CommandSender sender,
|
|
@NotNull String[] args) {
|
|
|
|
if(!PermissionManager.hasPermission(sender, Permission.NOUNS_UPDATE))
|
|
{
|
|
sender.sendMessage("No permission!");
|
|
return false;
|
|
}
|
|
|
|
|
|
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;
|
|
}
|
|
|
|
}
|
|
}
|