45 lines
1.3 KiB
Java
45 lines
1.3 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 NounsDeleteSubCommand
|
|
{
|
|
|
|
public static boolean run(@NotNull CommandSender sender,
|
|
@NotNull String[] args)
|
|
{
|
|
if(!PermissionManager.hasPermission(sender, Permission.NOUNS_DELETE))
|
|
{
|
|
sender.sendMessage("No permission!");
|
|
return false;
|
|
}
|
|
|
|
if(args.length < 2) {
|
|
sender.sendMessage("usage: /nouns delete <pronoun>");
|
|
return true;
|
|
}
|
|
|
|
String pronoun = args[1].toLowerCase();
|
|
|
|
if(!Cache.dbManager.isPronounValid(pronoun))
|
|
{
|
|
sender.sendMessage("The pronoun " + pronoun + " doesn't exist!");
|
|
return true;
|
|
}
|
|
|
|
if(Cache.dbManager.deletePronoun(pronoun))
|
|
{
|
|
sender.sendMessage("Pronoun deleted successfully and removed from all users!");
|
|
return true;
|
|
} else {
|
|
sender.sendMessage("Could not delete pronoun " + pronoun + "! Check console for details.");
|
|
return true;
|
|
}
|
|
|
|
}
|
|
}
|