Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class AsyncPlayerPreLogin implements Listener
- {
- public static List<String> maxpersec;
- static {
- AsyncPlayerPreLogin.maxpersec = new ArrayList<String>();
- }
- @EventHandler(priority = EventPriority.HIGHEST)
- public void onJoin(final AsyncPlayerPreLoginEvent asyncPlayerPreLoginEvent) {
- if (!Main.getInstance().warmup) {
- return;
- }
- final String hostAddress = asyncPlayerPreLoginEvent.getAddress().getHostAddress();
- final String name = asyncPlayerPreLoginEvent.getName();
- final double round = JoinListener.round(TPSSample.getTPS(), 1);
- if (WhiteList.isWhitelisted(name)) {
- return;
- }
- if (WhiteList.isWhitelisted(hostAddress)) {
- return;
- }
- if (ConfigHandler.getBoolean("config.yml", "BlackListSettings.BlacklistGeneral")) {
- if (Blacklist.isBlacklisted(hostAddress)) {
- asyncPlayerPreLoginEvent.disallow(AsyncPlayerPreLoginEvent.Result.KICK_BANNED, ConfigHandler.getRowList("config.yml", "KickMessages.BlackListed"));
- GUIUtils.bots.add(name);
- for (final Player player : Bukkit.getOnlinePlayers()) {
- if (Utils.getMessage.contains(player.getName())) {
- ActionBarAPI.sendActionBar(player, ConfigHandler.getString("config.yml", "AdminAlert.Blacklisted").replace("%player%", name).replace("%ip%", hostAddress));
- }
- }
- return;
- }
- if (Blacklist.isPlayerBlacklisted(name)) {
- asyncPlayerPreLoginEvent.disallow(AsyncPlayerPreLoginEvent.Result.KICK_BANNED, ConfigHandler.getRowList("config.yml", "KickMessages.BlackListed"));
- GUIUtils.bots.add(name);
- for (final Player player2 : Bukkit.getOnlinePlayers()) {
- if (Utils.getMessage.contains(player2.getName())) {
- ActionBarAPI.sendActionBar(player2, ConfigHandler.getString("config.yml", "AdminAlert.Blacklisted").replace("%player%", name).replace("%ip%", hostAddress));
- }
- }
- return;
- }
- }
- if (ConfigHandler.getBoolean("config.yml", "PingSettings.PingCheck") && !Utils.pinged.contains(hostAddress)) {
- asyncPlayerPreLoginEvent.disallow(AsyncPlayerPreLoginEvent.Result.KICK_BANNED, ConfigHandler.getRowList("config.yml", "KickMessages.NotPinged"));
- GUIUtils.bots.add(name);
- for (final Player player3 : Bukkit.getOnlinePlayers()) {
- if (Utils.getMessage.contains(player3.getName())) {
- ActionBarAPI.sendActionBar(player3, ConfigHandler.getString("config.yml", "AdminAlert.NotPinged").replace("%player%", name).replace("%ip%", hostAddress));
- }
- }
- return;
- }
- if (ConfigHandler.getBoolean("config.yml", "AlreadyOnlineSettings.AlreadyOnlineCheck")) {
- final Iterator<Player> iterator4 = (Iterator<Player>) Bukkit.getOnlinePlayers().iterator();
- while (iterator4.hasNext()) {
- if (iterator4.next().getName().equals(name)) {
- asyncPlayerPreLoginEvent.disallow(AsyncPlayerPreLoginEvent.Result.KICK_BANNED, ConfigHandler.getRowList("config.yml", "KickMessages.AlreadyOnline"));
- GUIUtils.bots.add(name);
- Utils.pinged.remove(hostAddress);
- for (final Player player4 : Bukkit.getOnlinePlayers()) {
- if (Utils.getMessage.contains(player4.getName())) {
- ActionBarAPI.sendActionBar(player4, ConfigHandler.getString("config.yml", "AdminAlert.AlreadyOnline").replace("%player%", name).replace("%ip%", hostAddress));
- }
- }
- return;
- }
- }
- }
- if (ConfigHandler.getBoolean("config.yml", "TPSSettings.TPSChecking") && round <= ConfigHandler.getDouble("config.yml", "TPSSettings.MinTPS")) {
- asyncPlayerPreLoginEvent.disallow(AsyncPlayerPreLoginEvent.Result.KICK_BANNED, ConfigHandler.getRowList("config.yml", "KickMessages.TPSOverload"));
- GUIUtils.bots.add(name);
- for (final Player player5 : Bukkit.getOnlinePlayers()) {
- if (Utils.getMessage.contains(player5.getName())) {
- ActionBarAPI.sendActionBar(player5, ConfigHandler.getString("config.yml", "AdminAlert.TPSOverload").replace("%player%", name).replace("%ip%", hostAddress).replace("%tps", new StringBuilder(String.valueOf(round)).toString()));
- }
- }
- }
- if (ConfigHandler.getBoolean("config.yml", "MaxIPSettings.MaxIPCheck")) {
- final ArrayList<String> list = new ArrayList<String>();
- for (final Player player6 : Bukkit.getOnlinePlayers()) {
- if (player6.getAddress().getAddress().getHostAddress().equals(hostAddress)) {
- list.add(player6.getName());
- }
- }
- if (list.size() >= ConfigHandler.getInt("config.yml", "MaxIPSettings.MaxIPs")) {
- asyncPlayerPreLoginEvent.disallow(AsyncPlayerPreLoginEvent.Result.KICK_BANNED, ConfigHandler.getRowList("config.yml", "KickMessages.TooMuchIPs"));
- Utils.pinged.remove(hostAddress);
- for (final Player player7 : Bukkit.getOnlinePlayers()) {
- if (Utils.getMessage.contains(player7.getName())) {
- 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()));
- }
- }
- GUIUtils.bots.add(name);
- }
- }
- if (ConfigHandler.getBoolean("config.yml", "MaxPlayerSettings.MaxPlayerCheck")) {
- AsyncPlayerPreLogin.maxpersec.add(name);
- if (AsyncPlayerPreLogin.maxpersec.size() > ConfigHandler.getInt("config.yml", "MaxPlayerSettings.PlayersPerSec")) {
- asyncPlayerPreLoginEvent.disallow(AsyncPlayerPreLoginEvent.Result.KICK_BANNED, ConfigHandler.getRowList("config.yml", "KickMessages.TooMuchPlayers"));
- GUIUtils.bots.add(name);
- Utils.pinged.remove(hostAddress);
- for (final Player player8 : Bukkit.getOnlinePlayers()) {
- if (Utils.getMessage.contains(player8.getName())) {
- ActionBarAPI.sendActionBar(player8, ConfigHandler.getString("config.yml", "AdminAlert.TooMuchPlayers").replace("%player%", name).replace("%ip%", hostAddress).replace("%value%", String.valueOf(AsyncPlayerPreLogin.maxpersec.size())));
- }
- }
- return;
- }
- }
- if (ConfigHandler.getBoolean("config.yml", "DoubleAccountSettings.DoubleAccountChecking")) {
- for (final Player player9 : Bukkit.getOnlinePlayers()) {
- if (player9.getAddress().getAddress().getHostAddress().equals(hostAddress)) {
- final String name2 = player9.getName();
- final String hostAddress2 = player9.getAddress().getAddress().getHostAddress();
- for (final Player player10 : Bukkit.getOnlinePlayers()) {
- if (Utils.getMessage.contains(player10.getName())) {
- ActionBarAPI.sendActionBar(player10, ConfigHandler.getString("config.yml", "AdminAlert.DoubleAccount").replace("%player%", name).replace("%ip%", hostAddress).replace("%other%", name2).replace("%otherip%", hostAddress2));
- }
- }
- GUIUtils.bots.add(name);
- Utils.pinged.remove(hostAddress);
- return;
- }
- }
- }
- if (ConfigHandler.getBoolean("config.yml", "ProxySettings.ProxyCheck")) {
- if (ProxyUtil.isProxy(hostAddress, "http://www.stopforumspam.com/api?ip=", "<appears>yes</appears>")) {
- asyncPlayerPreLoginEvent.disallow(AsyncPlayerPreLoginEvent.Result.KICK_BANNED, ConfigHandler.getRowList("config.yml", "KickMessages.Proxy"));
- Utils.pinged.remove(hostAddress);
- GUIUtils.bots.add(name);
- for (final Player player11 : Bukkit.getOnlinePlayers()) {
- if (Utils.getMessage.contains(player11.getName())) {
- ActionBarAPI.sendActionBar(player11, ConfigHandler.getString("config.yml", "AdminAlert.Proxy").replace("%player%", name).replace("%ip%", hostAddress));
- }
- }
- return;
- }
- if (ProxyUtil.isProxy(hostAddress, "http://www.shroomery.org/ythan/proxycheck.php?ip=", "Y")) {
- asyncPlayerPreLoginEvent.disallow(AsyncPlayerPreLoginEvent.Result.KICK_BANNED, ConfigHandler.getRowList("config.yml", "KickMessages.Proxy"));
- Utils.pinged.remove(hostAddress);
- GUIUtils.bots.add(name);
- for (final Player player12 : Bukkit.getOnlinePlayers()) {
- if (Utils.getMessage.contains(player12.getName())) {
- ActionBarAPI.sendActionBar(player12, ConfigHandler.getString("config.yml", "AdminAlert.Proxy").replace("%player%", name).replace("%ip%", hostAddress));
- }
- }
- return;
- }
- if (ConfigHandler.getBoolean("config.yml", "ProxySettings.PercentCheck") && ProxyUtil.isProxyPercentage(hostAddress)) {
- asyncPlayerPreLoginEvent.disallow(AsyncPlayerPreLoginEvent.Result.KICK_BANNED, ConfigHandler.getRowList("config.yml", "KickMessages.Proxy"));
- Utils.pinged.remove(hostAddress);
- GUIUtils.bots.add(name);
- for (final Player player13 : Bukkit.getOnlinePlayers()) {
- if (Utils.getMessage.contains(player13.getName())) {
- ActionBarAPI.sendActionBar(player13, ConfigHandler.getString("config.yml", "AdminAlert.Proxy").replace("%player%", name).replace("%ip%", hostAddress));
- }
- }
- return;
- }
- }
- this.addToList(name);
- GUIUtils.friendly.add(name);
- Utils.pinged.remove(hostAddress);
- }
- public void addToList(final String s) {
- if (ConfigHandler.getBoolean("config.yml", "General.AutoWhitelist")) {
- final YamlConfiguration loadConfiguration = YamlConfiguration.loadConfiguration(new File(Main.getInstance().getDataFolder(), "autowhitelist.yml"));
- if (!loadConfiguration.isSet("Players." + s)) {
- loadConfiguration.set("Players." + s, (Object)System.currentTimeMillis());
- }
- else {
- try {
- if (loadConfiguration.getString("Players." + s) != null) {
- return;
- }
- loadConfiguration.set("Players." + s, (Object)System.currentTimeMillis());
- }
- catch (Exception ex2) {
- try {
- throw new BotCheckException("Failure by adding User to Whitelist");
- }
- catch (BotCheckException e) {
- e.printStackTrace();
- }
- }
- }
- try {
- loadConfiguration.save(new File(Main.getInstance().getDataFolder(), "autowhitelist.yml"));
- }
- catch (IOException ex) {
- ex.printStackTrace();
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement