2022-10-22 16:11:37 +02:00
|
|
|
package wtf.beatrice.nounspicker.commands.subcommands;
|
|
|
|
|
|
|
|
import org.bukkit.command.CommandSender;
|
|
|
|
import org.jetbrains.annotations.NotNull;
|
2022-10-24 22:48:16 +02:00
|
|
|
import wtf.beatrice.nounspicker.objects.Permission;
|
2022-10-22 16:12:46 +02:00
|
|
|
import wtf.beatrice.nounspicker.utils.Cache;
|
2022-10-24 22:48:16 +02:00
|
|
|
import wtf.beatrice.nounspicker.utils.PermissionManager;
|
2022-10-22 16:11:37 +02:00
|
|
|
|
|
|
|
public class NounsSetSubCommand
|
|
|
|
{
|
|
|
|
public static boolean run(@NotNull CommandSender sender,
|
|
|
|
@NotNull String[] args)
|
|
|
|
{
|
|
|
|
|
2022-10-24 22:48:16 +02:00
|
|
|
if(!PermissionManager.hasPermission(sender, Permission.NOUNS_SET))
|
|
|
|
{
|
2022-10-24 22:50:31 +02:00
|
|
|
sender.sendMessage(Cache.noPermissions);
|
|
|
|
return true;
|
2022-10-24 22:48:16 +02:00
|
|
|
}
|
|
|
|
|
2022-10-22 16:11:37 +02:00
|
|
|
if(args.length < 3)
|
|
|
|
{
|
|
|
|
sender.sendMessage("usage: /nouns set <main> <secondary>");
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
String mainPronoun = args[1].toLowerCase();
|
|
|
|
String secondaryPronoun = args[2].toLowerCase();
|
|
|
|
|
2022-10-24 20:58:44 +02:00
|
|
|
if(!Cache.dbManager.isPronounValid(mainPronoun))
|
2022-10-22 16:11:37 +02:00
|
|
|
{
|
|
|
|
sender.sendMessage("Invalid main pronoun!");
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2022-10-24 20:58:44 +02:00
|
|
|
if(!Cache.dbManager.isPronounValid(secondaryPronoun))
|
2022-10-22 16:11:37 +02:00
|
|
|
{
|
|
|
|
sender.sendMessage("Invalid secondary pronoun!");
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2022-10-24 21:22:27 +02:00
|
|
|
if(Cache.dbManager.setPlayerPronouns(sender.getName(), mainPronoun, secondaryPronoun)) {
|
2022-10-24 21:28:32 +02:00
|
|
|
|
2022-10-24 21:22:27 +02:00
|
|
|
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;
|
|
|
|
}
|
2022-10-22 16:11:37 +02:00
|
|
|
}
|
|
|
|
}
|