58 lines
2.0 KiB
Java
58 lines
2.0 KiB
Java
package wtf.beatrice.nounspicker.commands.subcommands;
|
|
|
|
import org.bukkit.ChatColor;
|
|
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(ChatColor.RED + "Usage: /nouns set <main> <secondary>");
|
|
return true;
|
|
}
|
|
|
|
String mainPronoun = args[1].toLowerCase();
|
|
String secondaryPronoun = args[2].toLowerCase();
|
|
|
|
if(!Cache.dbManager.isPronounValid(mainPronoun))
|
|
{
|
|
sender.sendMessage(ChatColor.RED + "Main pronoun '" + mainPronoun + "' not recognized!");
|
|
return true;
|
|
}
|
|
|
|
if(!Cache.dbManager.isPronounValid(secondaryPronoun))
|
|
{
|
|
sender.sendMessage(ChatColor.RED + "Secondary pronoun '" + secondaryPronoun + "' not recognized!");
|
|
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(ChatColor.YELLOW + "Your pronouns have correctly been set to " +
|
|
mainPronoun + ChatColor.YELLOW + "/" + secondaryPronoun + ChatColor.YELLOW + "!");
|
|
return true;
|
|
} else {
|
|
sender.sendMessage(ChatColor.RED + "Error updating pronouns! Please contact an administrator.");
|
|
return true;
|
|
}
|
|
}
|
|
}
|