mirror of
https://github.com/TotalFreedomMC/TFGuilds.git
synced 2024-12-22 16:05:00 +00:00
guild rank names must be alphanumeric
This commit is contained in:
parent
bd70b872dd
commit
78dcf76f5c
2 changed files with 12 additions and 1 deletions
|
@ -1,5 +1,7 @@
|
||||||
package me.totalfreedom.tfguilds.command;
|
package me.totalfreedom.tfguilds.command;
|
||||||
|
|
||||||
|
import java.util.regex.Matcher;
|
||||||
|
import java.util.regex.Pattern;
|
||||||
import me.totalfreedom.tfguilds.Common;
|
import me.totalfreedom.tfguilds.Common;
|
||||||
import me.totalfreedom.tfguilds.guild.Guild;
|
import me.totalfreedom.tfguilds.guild.Guild;
|
||||||
import me.totalfreedom.tfguilds.util.GUtil;
|
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)
|
if (rank.length() > 15)
|
||||||
{
|
{
|
||||||
sender.sendMessage(ChatColor.RED + "Guild rank names may not be over 15 characters.");
|
sender.sendMessage(ChatColor.RED + "Guild rank names may not be over 15 characters.");
|
||||||
|
|
|
@ -60,7 +60,7 @@ public class JoinSubcommand extends Common implements CommandExecutor
|
||||||
}
|
}
|
||||||
|
|
||||||
guild.addMember(player.getName());
|
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();
|
guild.save();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue