Advertisement
pascal25565

Untitled

Apr 15th, 2017
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 11.76 KB | None | 0 0
  1. public class AsyncPlayerPreLogin implements Listener
  2. {
  3. public static List<String> maxpersec;
  4.  
  5. static {
  6. AsyncPlayerPreLogin.maxpersec = new ArrayList<String>();
  7. }
  8.  
  9. @EventHandler(priority = EventPriority.HIGHEST)
  10. public void onJoin(final AsyncPlayerPreLoginEvent asyncPlayerPreLoginEvent) {
  11. if (!Main.getInstance().warmup) {
  12. return;
  13. }
  14. final String hostAddress = asyncPlayerPreLoginEvent.getAddress().getHostAddress();
  15. final String name = asyncPlayerPreLoginEvent.getName();
  16. final double round = JoinListener.round(TPSSample.getTPS(), 1);
  17. if (WhiteList.isWhitelisted(name)) {
  18. return;
  19. }
  20. if (WhiteList.isWhitelisted(hostAddress)) {
  21. return;
  22. }
  23. if (ConfigHandler.getBoolean("config.yml", "BlackListSettings.BlacklistGeneral")) {
  24. if (Blacklist.isBlacklisted(hostAddress)) {
  25. asyncPlayerPreLoginEvent.disallow(AsyncPlayerPreLoginEvent.Result.KICK_BANNED, ConfigHandler.getRowList("config.yml", "KickMessages.BlackListed"));
  26. GUIUtils.bots.add(name);
  27. for (final Player player : Bukkit.getOnlinePlayers()) {
  28. if (Utils.getMessage.contains(player.getName())) {
  29. ActionBarAPI.sendActionBar(player, ConfigHandler.getString("config.yml", "AdminAlert.Blacklisted").replace("%player%", name).replace("%ip%", hostAddress));
  30. }
  31. }
  32. return;
  33. }
  34. if (Blacklist.isPlayerBlacklisted(name)) {
  35. asyncPlayerPreLoginEvent.disallow(AsyncPlayerPreLoginEvent.Result.KICK_BANNED, ConfigHandler.getRowList("config.yml", "KickMessages.BlackListed"));
  36. GUIUtils.bots.add(name);
  37. for (final Player player2 : Bukkit.getOnlinePlayers()) {
  38. if (Utils.getMessage.contains(player2.getName())) {
  39. ActionBarAPI.sendActionBar(player2, ConfigHandler.getString("config.yml", "AdminAlert.Blacklisted").replace("%player%", name).replace("%ip%", hostAddress));
  40. }
  41. }
  42. return;
  43. }
  44. }
  45. if (ConfigHandler.getBoolean("config.yml", "PingSettings.PingCheck") && !Utils.pinged.contains(hostAddress)) {
  46. asyncPlayerPreLoginEvent.disallow(AsyncPlayerPreLoginEvent.Result.KICK_BANNED, ConfigHandler.getRowList("config.yml", "KickMessages.NotPinged"));
  47. GUIUtils.bots.add(name);
  48. for (final Player player3 : Bukkit.getOnlinePlayers()) {
  49. if (Utils.getMessage.contains(player3.getName())) {
  50. ActionBarAPI.sendActionBar(player3, ConfigHandler.getString("config.yml", "AdminAlert.NotPinged").replace("%player%", name).replace("%ip%", hostAddress));
  51. }
  52. }
  53. return;
  54. }
  55. if (ConfigHandler.getBoolean("config.yml", "AlreadyOnlineSettings.AlreadyOnlineCheck")) {
  56. final Iterator<Player> iterator4 = (Iterator<Player>) Bukkit.getOnlinePlayers().iterator();
  57. while (iterator4.hasNext()) {
  58. if (iterator4.next().getName().equals(name)) {
  59. asyncPlayerPreLoginEvent.disallow(AsyncPlayerPreLoginEvent.Result.KICK_BANNED, ConfigHandler.getRowList("config.yml", "KickMessages.AlreadyOnline"));
  60. GUIUtils.bots.add(name);
  61. Utils.pinged.remove(hostAddress);
  62. for (final Player player4 : Bukkit.getOnlinePlayers()) {
  63. if (Utils.getMessage.contains(player4.getName())) {
  64. ActionBarAPI.sendActionBar(player4, ConfigHandler.getString("config.yml", "AdminAlert.AlreadyOnline").replace("%player%", name).replace("%ip%", hostAddress));
  65. }
  66. }
  67. return;
  68. }
  69. }
  70. }
  71. if (ConfigHandler.getBoolean("config.yml", "TPSSettings.TPSChecking") && round <= ConfigHandler.getDouble("config.yml", "TPSSettings.MinTPS")) {
  72. asyncPlayerPreLoginEvent.disallow(AsyncPlayerPreLoginEvent.Result.KICK_BANNED, ConfigHandler.getRowList("config.yml", "KickMessages.TPSOverload"));
  73. GUIUtils.bots.add(name);
  74. for (final Player player5 : Bukkit.getOnlinePlayers()) {
  75. if (Utils.getMessage.contains(player5.getName())) {
  76. ActionBarAPI.sendActionBar(player5, ConfigHandler.getString("config.yml", "AdminAlert.TPSOverload").replace("%player%", name).replace("%ip%", hostAddress).replace("%tps", new StringBuilder(String.valueOf(round)).toString()));
  77. }
  78. }
  79. }
  80. if (ConfigHandler.getBoolean("config.yml", "MaxIPSettings.MaxIPCheck")) {
  81. final ArrayList<String> list = new ArrayList<String>();
  82. for (final Player player6 : Bukkit.getOnlinePlayers()) {
  83. if (player6.getAddress().getAddress().getHostAddress().equals(hostAddress)) {
  84. list.add(player6.getName());
  85. }
  86. }
  87. if (list.size() >= ConfigHandler.getInt("config.yml", "MaxIPSettings.MaxIPs")) {
  88. asyncPlayerPreLoginEvent.disallow(AsyncPlayerPreLoginEvent.Result.KICK_BANNED, ConfigHandler.getRowList("config.yml", "KickMessages.TooMuchIPs"));
  89. Utils.pinged.remove(hostAddress);
  90. for (final Player player7 : Bukkit.getOnlinePlayers()) {
  91. if (Utils.getMessage.contains(player7.getName())) {
  92. ActionBarAPI.sendActionBar(player7, ConfigHandler.getString("config.yml", "AdminAlert.MaxIPs").replace("%player%", name).replace("%ip%", hostAddress).replace("%value%", new StringBuilder(String.valueOf(ConfigHandler.getInt("config.yml", "MaxIPSettings.MaxIPs"))).toString()));
  93. }
  94. }
  95. GUIUtils.bots.add(name);
  96. }
  97. }
  98. if (ConfigHandler.getBoolean("config.yml", "MaxPlayerSettings.MaxPlayerCheck")) {
  99. AsyncPlayerPreLogin.maxpersec.add(name);
  100. if (AsyncPlayerPreLogin.maxpersec.size() > ConfigHandler.getInt("config.yml", "MaxPlayerSettings.PlayersPerSec")) {
  101. asyncPlayerPreLoginEvent.disallow(AsyncPlayerPreLoginEvent.Result.KICK_BANNED, ConfigHandler.getRowList("config.yml", "KickMessages.TooMuchPlayers"));
  102. GUIUtils.bots.add(name);
  103. Utils.pinged.remove(hostAddress);
  104. for (final Player player8 : Bukkit.getOnlinePlayers()) {
  105. if (Utils.getMessage.contains(player8.getName())) {
  106. ActionBarAPI.sendActionBar(player8, ConfigHandler.getString("config.yml", "AdminAlert.TooMuchPlayers").replace("%player%", name).replace("%ip%", hostAddress).replace("%value%", String.valueOf(AsyncPlayerPreLogin.maxpersec.size())));
  107. }
  108. }
  109. return;
  110. }
  111. }
  112. if (ConfigHandler.getBoolean("config.yml", "DoubleAccountSettings.DoubleAccountChecking")) {
  113. for (final Player player9 : Bukkit.getOnlinePlayers()) {
  114. if (player9.getAddress().getAddress().getHostAddress().equals(hostAddress)) {
  115. final String name2 = player9.getName();
  116. final String hostAddress2 = player9.getAddress().getAddress().getHostAddress();
  117. for (final Player player10 : Bukkit.getOnlinePlayers()) {
  118. if (Utils.getMessage.contains(player10.getName())) {
  119. ActionBarAPI.sendActionBar(player10, ConfigHandler.getString("config.yml", "AdminAlert.DoubleAccount").replace("%player%", name).replace("%ip%", hostAddress).replace("%other%", name2).replace("%otherip%", hostAddress2));
  120. }
  121. }
  122. GUIUtils.bots.add(name);
  123. Utils.pinged.remove(hostAddress);
  124. return;
  125. }
  126. }
  127. }
  128. if (ConfigHandler.getBoolean("config.yml", "ProxySettings.ProxyCheck")) {
  129. if (ProxyUtil.isProxy(hostAddress, "http://www.stopforumspam.com/api?ip=", "<appears>yes</appears>")) {
  130. asyncPlayerPreLoginEvent.disallow(AsyncPlayerPreLoginEvent.Result.KICK_BANNED, ConfigHandler.getRowList("config.yml", "KickMessages.Proxy"));
  131. Utils.pinged.remove(hostAddress);
  132. GUIUtils.bots.add(name);
  133. for (final Player player11 : Bukkit.getOnlinePlayers()) {
  134. if (Utils.getMessage.contains(player11.getName())) {
  135. ActionBarAPI.sendActionBar(player11, ConfigHandler.getString("config.yml", "AdminAlert.Proxy").replace("%player%", name).replace("%ip%", hostAddress));
  136. }
  137. }
  138. return;
  139. }
  140. if (ProxyUtil.isProxy(hostAddress, "http://www.shroomery.org/ythan/proxycheck.php?ip=", "Y")) {
  141. asyncPlayerPreLoginEvent.disallow(AsyncPlayerPreLoginEvent.Result.KICK_BANNED, ConfigHandler.getRowList("config.yml", "KickMessages.Proxy"));
  142. Utils.pinged.remove(hostAddress);
  143. GUIUtils.bots.add(name);
  144. for (final Player player12 : Bukkit.getOnlinePlayers()) {
  145. if (Utils.getMessage.contains(player12.getName())) {
  146. ActionBarAPI.sendActionBar(player12, ConfigHandler.getString("config.yml", "AdminAlert.Proxy").replace("%player%", name).replace("%ip%", hostAddress));
  147. }
  148. }
  149. return;
  150. }
  151. if (ConfigHandler.getBoolean("config.yml", "ProxySettings.PercentCheck") && ProxyUtil.isProxyPercentage(hostAddress)) {
  152. asyncPlayerPreLoginEvent.disallow(AsyncPlayerPreLoginEvent.Result.KICK_BANNED, ConfigHandler.getRowList("config.yml", "KickMessages.Proxy"));
  153. Utils.pinged.remove(hostAddress);
  154. GUIUtils.bots.add(name);
  155. for (final Player player13 : Bukkit.getOnlinePlayers()) {
  156. if (Utils.getMessage.contains(player13.getName())) {
  157. ActionBarAPI.sendActionBar(player13, ConfigHandler.getString("config.yml", "AdminAlert.Proxy").replace("%player%", name).replace("%ip%", hostAddress));
  158. }
  159. }
  160. return;
  161. }
  162. }
  163. this.addToList(name);
  164. GUIUtils.friendly.add(name);
  165. Utils.pinged.remove(hostAddress);
  166. }
  167.  
  168. public void addToList(final String s) {
  169. if (ConfigHandler.getBoolean("config.yml", "General.AutoWhitelist")) {
  170. final YamlConfiguration loadConfiguration = YamlConfiguration.loadConfiguration(new File(Main.getInstance().getDataFolder(), "autowhitelist.yml"));
  171. if (!loadConfiguration.isSet("Players." + s)) {
  172. loadConfiguration.set("Players." + s, (Object)System.currentTimeMillis());
  173. }
  174. else {
  175. try {
  176. if (loadConfiguration.getString("Players." + s) != null) {
  177. return;
  178. }
  179. loadConfiguration.set("Players." + s, (Object)System.currentTimeMillis());
  180. }
  181. catch (Exception ex2) {
  182. try {
  183. throw new BotCheckException("Failure by adding User to Whitelist");
  184. }
  185. catch (BotCheckException e) {
  186. e.printStackTrace();
  187. }
  188. }
  189. }
  190. try {
  191. loadConfiguration.save(new File(Main.getInstance().getDataFolder(), "autowhitelist.yml"));
  192. }
  193. catch (IOException ex) {
  194. ex.printStackTrace();
  195. }
  196. }
  197. }
  198. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement