guild rank names must be alphanumeric

This commit is contained in:
speed 2020-10-11 14:47:36 -04:00
parent bd70b872dd
commit 78dcf76f5c
2 changed files with 12 additions and 1 deletions

View file

@ -1,5 +1,7 @@
package me.totalfreedom.tfguilds.command;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import me.totalfreedom.tfguilds.Common;
import me.totalfreedom.tfguilds.guild.Guild;
import me.totalfreedom.tfguilds.util.GUtil;
@ -56,6 +58,15 @@ public class CreateRankSubcommand extends Common implements CommandExecutor
}
}
Pattern pattern = Pattern.compile("^[A-Za-z0-9? ,_-]+$");
Matcher matcher = pattern.matcher(rank);
if (!matcher.matches())
{
sender.sendMessage(ChatColor.RED + "Guild rank names must be alphanumeric.");
return true;
}
if (rank.length() > 15)
{
sender.sendMessage(ChatColor.RED + "Guild rank names may not be over 15 characters.");

View file

@ -60,7 +60,7 @@ public class JoinSubcommand extends Common implements CommandExecutor
}
guild.addMember(player.getName());
guild.broadcast(tl("%s%" + player.getName() + " %p%has joined your guild!"));
guild.broadcast(tl("%s%" + player.getName() + " %p%has joined the guild."));
guild.save();
return true;
}