56 lines
1.8 KiB
Java
56 lines
1.8 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 NounsSetSubCommand
|
|
{
|
|
public static boolean run(@NotNull CommandSender sender,
|
|
@NotNull String[] args)
|
|
{
|
|
|
|
if(!PermissionManager.hasPermission(sender, Permission.NOUNS_SET))
|
|
{
|
|
sender.sendMessage(Cache.noPermissions);
|
|
return true;
|
|
}
|
|
|
|
if(args.length < 3)
|
|
{
|
|
sender.sendMessage("usage: /nouns set <main> <secondary>");
|
|
return true;
|
|
}
|
|
|
|
String mainPronoun = args[1].toLowerCase();
|
|
String secondaryPronoun = args[2].toLowerCase();
|
|
|
|
if(!Cache.dbManager.isPronounValid(mainPronoun))
|
|
{
|
|
sender.sendMessage("Invalid main pronoun!");
|
|
return true;
|
|
}
|
|
|
|
if(!Cache.dbManager.isPronounValid(secondaryPronoun))
|
|
{
|
|
sender.sendMessage("Invalid secondary pronoun!");
|
|
return true;
|
|
}
|
|
|
|
|
|
if(Cache.dbManager.setPlayerPronouns(sender.getName(), mainPronoun, secondaryPronoun)) {
|
|
|
|
mainPronoun = Cache.dbManager.getPronounFormat(Cache.dbManager.getPronounId(mainPronoun));
|
|
secondaryPronoun = Cache.dbManager.getPronounFormat(Cache.dbManager.getPronounId(secondaryPronoun));
|
|
|
|
sender.sendMessage("Your pronouns have correctly been set to " + mainPronoun + "/" + secondaryPronoun + "!");
|
|
return true;
|
|
} else {
|
|
sender.sendMessage("Error updating pronouns! Please contact an administrator.");
|
|
return true;
|
|
}
|
|
}
|
|
}
|