Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public FilterType isValid(String message, Player p)
- {
- int i = 0;
- int points = 0;
- if (ChatFilterClientMain.getInstance().nospam.containsKey(p)) {
- return FilterType.SPAM;
- }
- char[] arrayOfChar;
- int j = (arrayOfChar = message.toCharArray()).length;
- for (int i = 0; i < j; i++)
- {
- char c = arrayOfChar[i];
- if ((Character.isLetter(c)) && (Character.isUpperCase(c))) {
- i++;
- }
- if (c == '.') {
- points++;
- }
- }
- List<String> allowed = ChatFilterClientMain.getInstance().getConfig().getStringList("allowed_domains");
- String[] arrayOfString;
- int k = (arrayOfString = message.split(" ")).length;
- boolean adressAllowed;
- Pattern pattern;
- for (j = 0; j < k; j++)
- {
- String s = arrayOfString[j];
- adressAllowed = false;
- for (String a : allowed) {
- if (a.trim().startsWith("*"))
- {
- if (s.toLowerCase().contains(a.toLowerCase().replace("*", new String())))
- {
- adressAllowed = true;
- break;
- }
- }
- else if (s.equalsIgnoreCase(a))
- {
- adressAllowed = true;
- break;
- }
- }
- if (!adressAllowed)
- {
- s = s.toLowerCase();
- if ((s.endsWith(".de")) ||
- (s.endsWith(".com")) ||
- (s.endsWith(".net")) ||
- (s.endsWith(".cc")) ||
- (s.endsWith(".tk")) ||
- (s.endsWith(".eu"))) {
- return FilterType.SERVER_ADDRESS;
- }
- pattern = Pattern.compile("(@)?(href=')?(HREF=')?(HREF=\")?(href=\")?(http://)?[a-zA-Z_0-9\\-]+(\\.\\w[a-zA-Z_0-9\\-]+)+(/[#&\\n\\-=?\\+\\%/\\.\\w]+)?");
- Matcher matcher = pattern.matcher(s);
- if (matcher.matches()) {
- return FilterType.SERVER_ADDRESS;
- }
- if (matcher.find()) {
- return FilterType.SERVER_ADDRESS;
- }
- }
- }
- for (String filterwords : ChatFilterClientMain.getInstance().getWords())
- {
- adressAllowed = (pattern = message.split(" ")).length;
- for (boolean bool1 = false; bool1 < adressAllowed; bool1++)
- {
- String s = pattern[bool1];
- if ((s.equalsIgnoreCase(filterwords)) ||
- (s.toLowerCase().contains(filterwords.toLowerCase())) ||
- (s.toLowerCase().contains(filterwords.toLowerCase().toLowerCase())) ||
- (s.toLowerCase().contains(filterwords.toUpperCase().toLowerCase()))) {
- return FilterType.BLACKLIST;
- }
- }
- if ((!ChatFilterClientMain.getInstance().getAllowWriteInsultsWithBlank()) &&
- (message.toLowerCase().replace(" ", "").contains(filterwords.toLowerCase()))) {
- return FilterType.BLACKLIST;
- }
- if ((message.toLowerCase().contains(filterwords.toLowerCase())) ||
- (message.equalsIgnoreCase(filterwords))) {
- return FilterType.BLACKLIST;
- }
- }
- if (i > ChatFilterClientMain.getInstance().getUppercaseLetterCount().intValue()) {
- return FilterType.CAPS;
- }
- if (points > ChatFilterClientMain.getInstance().getMaxPointsInSentenceCount().intValue()) {
- return FilterType.SERVER_ADDRESS;
- }
- return null;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement