Advertisement
Guest User

Untitled

a guest
Sep 14th, 2018
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.20 KB | None | 0 0
  1. public FilterType isValid(String message, Player p)
  2. {
  3. int i = 0;
  4. int points = 0;
  5. if (ChatFilterClientMain.getInstance().nospam.containsKey(p)) {
  6. return FilterType.SPAM;
  7. }
  8. char[] arrayOfChar;
  9. int j = (arrayOfChar = message.toCharArray()).length;
  10. for (int i = 0; i < j; i++)
  11. {
  12. char c = arrayOfChar[i];
  13. if ((Character.isLetter(c)) && (Character.isUpperCase(c))) {
  14. i++;
  15. }
  16. if (c == '.') {
  17. points++;
  18. }
  19. }
  20. List<String> allowed = ChatFilterClientMain.getInstance().getConfig().getStringList("allowed_domains");
  21. String[] arrayOfString;
  22. int k = (arrayOfString = message.split(" ")).length;
  23. boolean adressAllowed;
  24. Pattern pattern;
  25. for (j = 0; j < k; j++)
  26. {
  27. String s = arrayOfString[j];
  28. adressAllowed = false;
  29. for (String a : allowed) {
  30. if (a.trim().startsWith("*"))
  31. {
  32. if (s.toLowerCase().contains(a.toLowerCase().replace("*", new String())))
  33. {
  34. adressAllowed = true;
  35. break;
  36. }
  37. }
  38. else if (s.equalsIgnoreCase(a))
  39. {
  40. adressAllowed = true;
  41. break;
  42. }
  43. }
  44. if (!adressAllowed)
  45. {
  46. s = s.toLowerCase();
  47. if ((s.endsWith(".de")) ||
  48. (s.endsWith(".com")) ||
  49. (s.endsWith(".net")) ||
  50. (s.endsWith(".cc")) ||
  51. (s.endsWith(".tk")) ||
  52. (s.endsWith(".eu"))) {
  53. return FilterType.SERVER_ADDRESS;
  54. }
  55. pattern = Pattern.compile("(@)?(href=')?(HREF=')?(HREF=\")?(href=\")?(http://)?[a-zA-Z_0-9\\-]+(\\.\\w[a-zA-Z_0-9\\-]+)+(/[#&\\n\\-=?\\+\\%/\\.\\w]+)?");
  56. Matcher matcher = pattern.matcher(s);
  57. if (matcher.matches()) {
  58. return FilterType.SERVER_ADDRESS;
  59. }
  60. if (matcher.find()) {
  61. return FilterType.SERVER_ADDRESS;
  62. }
  63. }
  64. }
  65. for (String filterwords : ChatFilterClientMain.getInstance().getWords())
  66. {
  67. adressAllowed = (pattern = message.split(" ")).length;
  68. for (boolean bool1 = false; bool1 < adressAllowed; bool1++)
  69. {
  70. String s = pattern[bool1];
  71. if ((s.equalsIgnoreCase(filterwords)) ||
  72. (s.toLowerCase().contains(filterwords.toLowerCase())) ||
  73. (s.toLowerCase().contains(filterwords.toLowerCase().toLowerCase())) ||
  74. (s.toLowerCase().contains(filterwords.toUpperCase().toLowerCase()))) {
  75. return FilterType.BLACKLIST;
  76. }
  77. }
  78. if ((!ChatFilterClientMain.getInstance().getAllowWriteInsultsWithBlank()) &&
  79. (message.toLowerCase().replace(" ", "").contains(filterwords.toLowerCase()))) {
  80. return FilterType.BLACKLIST;
  81. }
  82. if ((message.toLowerCase().contains(filterwords.toLowerCase())) ||
  83. (message.equalsIgnoreCase(filterwords))) {
  84. return FilterType.BLACKLIST;
  85. }
  86. }
  87. if (i > ChatFilterClientMain.getInstance().getUppercaseLetterCount().intValue()) {
  88. return FilterType.CAPS;
  89. }
  90. if (points > ChatFilterClientMain.getInstance().getMaxPointsInSentenceCount().intValue()) {
  91. return FilterType.SERVER_ADDRESS;
  92. }
  93. return null;
  94. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement