Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class PlayerJoinListener {
- public void execute (PlayerJoinEvent e) {
- Player player = e.getPlayer();
- LoginCheck lc = new LoginCheck();
- // Construct the IP Address String
- InetSocketAddress a = player.getAddress();
- InetAddress iNetAddress = a.getAddress();
- String address = iNetAddress.getHostAddress();
- StringBuilder ip = new StringBuilder();
- for (int i = 0; i < address.length(); i++) {
- if ((address.charAt(i) >= '0' && address.charAt(i) <= '9') || address.charAt(i) == '.') {
- ip.append(address.charAt(i));
- } else if (address.charAt(i) == ':') {
- break;
- }
- }
- IPcheck.ipToCheck = ip.toString();
- IPcheck.backend.log(player.getName(), ip.toString());
- IPcheck.shouldCheck = true;
- if (Configuration.secureMode) {
- IPcheck.shouldCheck = lc.secureCheck(ip.toString(), e);
- }
- LoginReport lp = new LoginReport();
- // Do not perform check on operators or players with the "ipcheck.getnotify permission.
- if (!player.isOp() && !player.hasPermission("ipcheck.getnotify")) {
- if (Configuration.notifyLogin && IPcheck.shouldCheck) {
- int accounts = (IPcheck.backend.getAlts(IPcheck.ipToCheck)).size();
- Player playerCheck = e.getPlayer();
- lp.execute(IPcheck.ipToCheck, playerCheck, accounts);
- }
- }
- return;
- }
- }
- public class LoginCheck {
- public boolean secureCheck(String ip, PlayerJoinEvent e) {
- ArrayList<String> players = IPcheck.backend.getAlts(ip);
- int accounts = players.size();
- Player player = e.getPlayer();
- return secureKick(accounts, player.getName(), e, ip);
- }
- public boolean secureKick(int accounts, String player, PlayerJoinEvent e, String ip) {
- // If the player was reported to have more than the secure-threshold # of accounts, then kick (if not exempt).
- if (accounts > Configuration.secureThreshold && !Configuration.isExemptPlayer(player) && !Configuration.isExemptIp(ip)) {
- if (player != null) {
- Player kickPlayer = e.getPlayer();
- kickPlayer.kickPlayer(Configuration.secureKickMsg);
- return false;
- }
- }
- return true;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement