Skip to content

Instantly share code, notes, and snippets.

@KeepJ96
Created April 7, 2013 04:35
Show Gist options
  • Save KeepJ96/5329049 to your computer and use it in GitHub Desktop.
Save KeepJ96/5329049 to your computer and use it in GitHub Desktop.
Main Class for IP-Check (Bukkit Plugin).
package net.risenphoenix.jnk.ipcheck;
import java.io.BufferedReader;
import java.io.DataInputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FilenameFilter;
import java.io.InputStreamReader;
import java.net.InetAddress;
import java.util.ArrayList;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.OfflinePlayer;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.event.player.PlayerLoginEvent;
import org.bukkit.event.player.PlayerLoginEvent.Result;
import org.bukkit.plugin.java.JavaPlugin;
public class IPcheck extends JavaPlugin implements Listener{
// IP-Check v1.1.0 by Jnk1296. Designed for checking for and banning multi-accounting players.
public static final String plugName = "[IP-Check] ";
public static final String banListReadErr = "Error occurred while attempting to read banned-ips.txt!";
public static final String playerFileReadErr = "Error occurred while attempting to read player file!";
public static final String noPermErr = "You don't have permission to do that!";
public static final String numArgsErr = "Incorrect Number of Arguments.";
public static final String illArgsErr = "Illegal Argument(s) were passed into the command.";
public static final String noFind = "The player specified could not be found.";
public static final String noRecent = "You have not searched a player yet.";
public static final String playExmpSuc = "Player added to exemption list!";
public static final String ipExmpSuc = "IP-Address added to exemption list!";
public static final String exemptionFail = "Sorry. :( Something went wrong. The exemption could not be added.";
public static final String toggleSecure = "Secure-Mode set to: ";
public static final String toggleNotify = "Notify-On-Login set to: ";
public static final String toggleDetail = "Descriptive-Notify set to: ";
public static final String toggleErr = "An error occurred while attempting to set state of toggle.";
public static final String exemptionDel = "Exemption successfully removed!";
public static final String exemptionDelErr = "Exemption specified does not exist.";
public static String recent = "";
public static String recentPlayer = "";
public static String latestIP = "";
public static File bannedIPs = new File("banned-ips.txt");
public static File playersDir = new File("plugins/Essentials/userdata");
private static boolean shouldCheck = true;
private static boolean foundIP = false;
private static boolean isBanned = false;
private static int playersFound = 0;
@Override
public void onEnable() {
getServer().getPluginManager().registerEvents(this, this); // Register the Player Login Listener
Configuration.onLoad(); // Load the Configuration File
}
@Override
public void onDisable() {
// Do Nothing
}
@EventHandler (priority = EventPriority.MONITOR)
public void onPlayerLogin(PlayerLoginEvent e) {
Player player = e.getPlayer();
shouldCheck = true;
// Do not perform check on operators or players with the "ipcheck.getnotify permission.
if (!player.isOp() && !player.hasPermission("ipcheck.getnotify")) {
// Construct the IP Address String
String iNetAddress = getIP(e);
StringBuilder ip = new StringBuilder();
for (int i = 0; i < iNetAddress.length(); i++) {
if ((iNetAddress.charAt(i) >= '0' && iNetAddress.charAt(i) <= '9') || iNetAddress.charAt(i) == '.') {
ip.append(iNetAddress.charAt(i));
} else if (iNetAddress.charAt(i) == ':') {
break;
}
}
latestIP = ip.toString();
if (Configuration.secureMode) {
shouldCheck = secureKick(secureCheck(latestIP, player.getName()), player.getName(), e, ip.toString());
}
}
return;
}
public static String getIP(PlayerLoginEvent e) {
InetAddress a = e.getAddress();
String ip = a.getHostAddress();
return ip;
}
@EventHandler (priority = EventPriority.MONITOR)
public void onPlayerJoin(PlayerJoinEvent e) {
Player player = e.getPlayer();
// Do not perform check on operators or players with the "ipcheck.getnotify permission.
if (!player.isOp() && !player.hasPermission("ipcheck.getnotify")) {
if (Configuration.notifyLogin && shouldCheck) {
loginCheck(latestIP, e.getPlayer());
}
}
return;
}
@Override
public boolean onCommand(CommandSender sender, Command cmd, String commandLabel, String[] args) {
if (cmd.getName().equalsIgnoreCase("check")) {
try {
if (args[0] != null) {
// Ban Command
if (args[0].equalsIgnoreCase("ban")) {
if (sender.hasPermission("ipcheck.ban") || sender.isOp()) {
if (args.length == 2) {
//Command Instructions Here
if (args[1].charAt(0) >= '0'&& args[1].charAt(0) <= '9') { // Check that argument is a potential IP address
// Command Operation
report(banPlayers(checkPlayers(compareIP(args[1], getBannedList()), getPlayerFiles()), sender, args[1], true), sender, args[1], false);
recent = "";
} else {
sender.sendMessage(illArgsErr);
}
} else {
sender.sendMessage(numArgsErr);
}
} else {
sender.sendMessage(noPermErr);
}
return true;
// Unban Command
} else if (args[0].equalsIgnoreCase("unban")) {
if (sender.hasPermission("ipcheck.unban") || sender.isOp()) {
if (args.length == 2) {
//Command Instructions Here
if (args[1].charAt(0) >= '0'&& args[1].charAt(0) <= '9') { // Check that argument is a potential IP address
// Command Operation
report(banPlayers(checkPlayers(compareIP(args[1], getBannedList()), getPlayerFiles()), sender, args[1], false), sender, args[1], false);
recent = "";
} else {
sender.sendMessage(illArgsErr);
}
} else {
sender.sendMessage(numArgsErr);
}
} else {
sender.sendMessage(noPermErr);
}
return true;
/* ***THIS COMMAND IS NO LONGER USED / HAS BEEN COMBINED WITH THE DEFAULT CHECK COMMAND***
// Player Command
} else if (args[0].equalsIgnoreCase("player")) {
if (sender.hasPermission("ipcheck.player") || sender.isOp()) {
if (args.length == 2) {
//Command Instructions Here
report(checkPlayers(compareIP(getPlayerInfo(args[1], getPlayerFiles()), getBannedList()), getPlayerFiles()), sender, recent, true);
} else {
sender.sendMessage(numArgsErr);
}
} else {
sender.sendMessage(noPermErr);
}
return true; */
// Banrecent Command
} else if (args[0].equalsIgnoreCase("banrecent")) {
if ((sender.hasPermission("ipcheck.recent") && sender.hasPermission("ipcheck.ban")) || sender.isOp()) {
if (args.length == 1) {
//Command Instructions Here
if (!recent.equals("")) {
report(banPlayers(checkPlayers(compareIP(recent, getBannedList()), getPlayerFiles()), sender, recent, true), sender, recent, false);
} else {
sender.sendMessage(ChatColor.GOLD + plugName + ChatColor.YELLOW + noRecent);
}
} else {
sender.sendMessage(numArgsErr);
}
} else {
sender.sendMessage(noPermErr);
}
return true;
// Unbanrecent Command
} else if (args[0].equalsIgnoreCase("unbanrecent")) {
if ((sender.hasPermission("ipcheck.recent") && sender.hasPermission("ipcheck.unban")) || sender.isOp()) {
if (args.length == 1) {
//Command Instructions Here
if (!recent.equals("")) {
report(banPlayers(checkPlayers(compareIP(recent, getBannedList()), getPlayerFiles()), sender, recent, false), sender, recent, false);
} else {
sender.sendMessage(noRecent);
}
} else {
sender.sendMessage(numArgsErr);
}
} else {
sender.sendMessage(noPermErr);
}
return true;
// Exempt Command
} else if (args[0].equalsIgnoreCase("exempt")) {
if (sender.hasPermission("ipcheck.exempt") || sender.isOp()) {
if (args.length == 3) {
//Command Instructions Here
if (args[1].equalsIgnoreCase("player")) {
if (Configuration.addExemption(1, args[2])) {
sender.sendMessage(ChatColor.GOLD + plugName + ChatColor.YELLOW + playExmpSuc);
} else {
sender.sendMessage(ChatColor.GOLD + plugName + ChatColor.YELLOW + exemptionFail);
}
} else if (args[1].equalsIgnoreCase("ip")) {
if (Configuration.addExemption(0, args[2])) {
sender.sendMessage(ChatColor.GOLD + plugName + ChatColor.YELLOW + ipExmpSuc);
} else {
sender.sendMessage(ChatColor.GOLD + plugName + ChatColor.YELLOW + exemptionFail);
}
} else if (args[1].equalsIgnoreCase("remove")) {
if (sender.hasPermission("ipcheck.exempt.remove") || sender.isOp()) {
boolean result = Configuration.deleteExemption(args[2]);
if (result) {
sender.sendMessage(ChatColor.GOLD + plugName + ChatColor.YELLOW + exemptionDel);
} else {
sender.sendMessage(ChatColor.GOLD + plugName + ChatColor.YELLOW + exemptionDelErr);
}
} else {
sender.sendMessage(noPermErr);
}
} else {
sender.sendMessage(illArgsErr);
}
} else {
sender.sendMessage(numArgsErr);
}
} else {
sender.sendMessage(noPermErr);
}
return true;
// Exempt-List Command
} else if (args[0].equalsIgnoreCase("exempt-list")) {
if (sender.hasPermission("ipcheck.list")) {
if (args.length == 2) {
//Command Instructions Here
if (args[1].equalsIgnoreCase("player")) {
ArrayList<String> list = Configuration.getPlayerExemptList();
sender.sendMessage("");
for (String s:list) {
sender.sendMessage(s);
}
sender.sendMessage(ChatColor.YELLOW + "Total players in exemption list: " + ChatColor.LIGHT_PURPLE + list.size());
sender.sendMessage("");
} else if (args[1].equalsIgnoreCase("ip")) {
ArrayList<String> list = Configuration.getIpExemptList();
sender.sendMessage("");
for (String s:list) {
sender.sendMessage(s);
}
sender.sendMessage(ChatColor.YELLOW + "Total players in exemption list: " + ChatColor.LIGHT_PURPLE + list.size());
sender.sendMessage("");
} else if (args[1].equalsIgnoreCase("list")) {
ArrayList<String> list = Configuration.getPlayerExemptList();
ArrayList<String> list2 = Configuration.getIpExemptList();
sender.sendMessage("");
for (String s:list) sender.sendMessage(s);
sender.sendMessage(ChatColor.GOLD + "------------------------------");
for (String s:list2) sender.sendMessage(s);
sender.sendMessage(ChatColor.YELLOW + "Total exemptions on file: " + ChatColor.LIGHT_PURPLE + (list.size() + list2.size()));
sender.sendMessage("");
}
} else {
sender.sendMessage(numArgsErr);
}
} else {
sender.sendMessage(noPermErr);
}
return true;
// Toggle Commands
} else if (args[0].equalsIgnoreCase("toggle")) {
if (sender.hasPermission("ipcheck.toggle") || sender.isOp()) {
if (args.length == 2) {
if (args[1].equalsIgnoreCase("immediate-mode") || args[1].equalsIgnoreCase("immediate") || args[1].equalsIgnoreCase("im")) {
int response = Configuration.toggle(0);
if (response == 0) {
sender.sendMessage(ChatColor.GOLD + plugName + ChatColor.YELLOW + toggleNotify + ChatColor.RED + "False");
} else if (response == 1) {
sender.sendMessage(ChatColor.GOLD + plugName + ChatColor.YELLOW + toggleNotify + ChatColor.GREEN + "True");
} else {
sender.sendMessage(ChatColor.GOLD + plugName + ChatColor.RED + toggleErr);
}
} else if (args[1].equalsIgnoreCase("notification-mode") || args[1].equalsIgnoreCase("notification") || args[1].equalsIgnoreCase("notify")) {
int response = Configuration.toggle(1);
if (response == 0) {
sender.sendMessage(ChatColor.GOLD + plugName + ChatColor.YELLOW + toggleDetail + ChatColor.RED + "False");
} else if (response == 1) {
sender.sendMessage(ChatColor.GOLD + plugName + ChatColor.YELLOW + toggleDetail + ChatColor.GREEN + "True");
} else {
sender.sendMessage(ChatColor.GOLD + plugName + ChatColor.RED + toggleErr);
}
} else if (args[1].equalsIgnoreCase("secure-mode") || args[1].equalsIgnoreCase("secure")) {
int response = Configuration.toggle(2);
if (response == 0) {
sender.sendMessage(ChatColor.GOLD + plugName + ChatColor.YELLOW + toggleSecure + ChatColor.RED + "False");
} else if (response == 1) {
sender.sendMessage(ChatColor.GOLD + plugName + ChatColor.YELLOW + toggleSecure + ChatColor.GREEN + "True");
} else {
sender.sendMessage(ChatColor.GOLD + plugName + ChatColor.RED + toggleErr);
}
} else {
sender.sendMessage(illArgsErr);
}
} else {
sender.sendMessage(numArgsErr);
}
} else {
sender.sendMessage(noPermErr);
}
return true;
// Reload the Configuration
} else if (args[0].equalsIgnoreCase("reload")) {
if (sender.hasPermission("ipcheck.reload") || sender.isOp()) {
if (args.length == 1) {
Configuration.onLoad();
} else {
sender.sendMessage(numArgsErr);
}
} else {
sender.sendMessage(noPermErr);
}
return true;
// About Command
} else if (args[0].equalsIgnoreCase("about")) {
sender.sendMessage(ChatColor.GOLD + plugName + ChatColor.YELLOW + "IP-Check v1.1.0 by Jnk1296.");
return true;
// All else
} else if (args.length == 1) {
String ip_filter = "\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}";
//Command Instructions here
if (args[0].toLowerCase().matches(ip_filter.toLowerCase())) {
report(checkPlayers(compareIP(args[0], getBannedList()), getPlayerFiles()), sender, args[0], false);
recent = "";
return true;
} else {
report(checkPlayers(compareIP(getPlayerInfo(args[0], getPlayerFiles()), getBannedList()), getPlayerFiles()), sender, recent, true);
return true;
}
}
return false;
}
} catch (ArrayIndexOutOfBoundsException e) {
sender.sendMessage(numArgsErr);
}
}
return false;
}
// Returns a File[] array of all player files found
public File[] getPlayerFiles() {
// Create a file array which holds all files found in the directory which have the extension *.yml
File[] playerFiles = playersDir.listFiles(new FilenameFilter() {
@Override
public boolean accept(File path, String name) {
if (name.toLowerCase().endsWith(".yml") && !name.toLowerCase().startsWith("nation_") && !name.toLowerCase().startsWith("town_")) {
return true;
} else {
return false;
}
}
});
return playerFiles;
}
// Returns an ArrayList<String> of all banned IP addresses
public ArrayList<String> getBannedList() {
ArrayList<String> ips = new ArrayList<String>();
try {
FileInputStream fstream = new FileInputStream(bannedIPs);
DataInputStream in = new DataInputStream(fstream);
BufferedReader br = new BufferedReader(new InputStreamReader(in));
String strLine;
// Skip the first three lines of the file
for (int lineSkip = 0; lineSkip < 3; lineSkip++) br.readLine();
while ((strLine = br.readLine()) != null) {
char start = strLine.charAt(0);
String ip = "";
int charCount = 0;
if (start >= '0' && start <= '9') {
while (strLine.charAt(charCount) != '|') {
ip = ip + strLine.charAt(charCount);
charCount++;
}
ips.add(ip);
}
}
br.close();
} catch (Exception e) {
// Console Output in the event we fail to read the configuration file.
getLogger().severe(banListReadErr);
}
return ips;
}
// Compares the IP given in the command to the IP list returned from getBannedList(), returns IP given
public String compareIP(String ip, ArrayList<String> bannedIPs) {
foundIP = false;
if (ip.equals("no-find")) return ip;
for (String s:bannedIPs) {
if (s.equals(ip)) {
foundIP = true;
break;
}
}
return ip;
}
// Checks the IP given against the IPs of all player files. and returns an ArrayList<String> of all player files that were found to match
public ArrayList<String> checkPlayers(String ip, File[] playerFiles) {
ArrayList<String> playersMatch = new ArrayList<String>();
playersFound = 0;
for (int i = 0; i < playerFiles.length; i++) {
File path = new File(playersDir + "/" + playerFiles[i].getName());
try {
FileInputStream fstream = new FileInputStream(path);
DataInputStream in = new DataInputStream(fstream);
BufferedReader br = new BufferedReader(new InputStreamReader(in));
String strLine;
while ((strLine = br.readLine()) != null) {
if (strLine.startsWith("ipAddress: ")) {
String currentIP = strLine;
currentIP = currentIP.replace("ipAddress: ", "");
if (ip.equals(currentIP)) {
playersFound++;
playersMatch.add(playerFiles[i].getName());
}
break;
}
}
br.close();
} catch (Exception e) {
// Console Output in the event we fail to read the configuration file.
getLogger().severe(playerFileReadErr);
}
}
return playersMatch;
}
// Returns the report summary
public void report(ArrayList<String> players, CommandSender sender, String ip, boolean forPlayer) {
if (ip.equals("no-find")) {
sender.sendMessage(ChatColor.GOLD + plugName + ChatColor.YELLOW + noFind);
return;
}
StringBuilder sb = new StringBuilder();
for(String s:players) {
s = s.replace(".yml", "");
sb.append(s + ", ");
}
sender.sendMessage(ChatColor.DARK_GRAY + "---------------------------------------------");
sender.sendMessage(ChatColor.GOLD + "Total Accounts found for: " + ip + " ... " + playersFound);
sender.sendMessage(ChatColor.DARK_GRAY + "---------------------------------------------");
sender.sendMessage(ChatColor.LIGHT_PURPLE + "The following players connect with the above IP address: " + ChatColor.YELLOW + sb);
sender.sendMessage("");
if (forPlayer) {
sender.sendMessage(ChatColor.LIGHT_PURPLE + "Player Searched for: " + ChatColor.YELLOW + recentPlayer);
if (isBanned) {
sender.sendMessage(ChatColor.LIGHT_PURPLE + "Player Banned: " + ChatColor.RED + isBanned);
} else {
sender.sendMessage(ChatColor.LIGHT_PURPLE + "Player Banned: " + ChatColor.GREEN + isBanned);
}
if (Configuration.isExemptPlayer(recentPlayer)) {
sender.sendMessage(ChatColor.LIGHT_PURPLE + "Player Exempt: " + ChatColor.GREEN + "true");
} else {
sender.sendMessage(ChatColor.LIGHT_PURPLE + "Player Exempt: " + ChatColor.RED + "false");
}
}
if (foundIP) {
sender.sendMessage(ChatColor.LIGHT_PURPLE + "IP Banned: " + ChatColor.RED + foundIP);
} else {
sender.sendMessage(ChatColor.LIGHT_PURPLE + "IP Banned: " + ChatColor.GREEN + foundIP);
}
if (Configuration.isExemptIp(ip)) {
sender.sendMessage(ChatColor.LIGHT_PURPLE + "IP Exempt: " + ChatColor.GREEN + "true");
} else {
sender.sendMessage(ChatColor.LIGHT_PURPLE + "IP Exempt: " + ChatColor.RED + "false");
}
sender.sendMessage(ChatColor.DARK_GRAY + "---------------------------------------------");
}
// Report for player login check
public void loginReport(String ip, Player player) {
Player[] online = getServer().getOnlinePlayers();
Player curPlayer = player;
getLogger().info(curPlayer.getDisplayName());
if ((curPlayer.hasPlayedBefore() && (playersFound - 1) > Configuration.notifyThreshold) || (!curPlayer.hasPlayedBefore() && playersFound > Configuration.notifyThreshold)) {
if (!Configuration.isExemptPlayer(player.getName()) && !Configuration.isExemptIp(ip)) { // If number of accounts is greater than threshold and player is not exempt
getLogger().info("" + playersFound); // For Debugging Purposes
// If player has logged in before, correct counting discrepancy
if (curPlayer.hasPlayedBefore()) {
playersFound -= 1;
}
for(int i = 0; i < online.length; i++) {
if (Configuration.detailNotify) { // If Detailed Notifications are enabled, display the detailed notification.
if (online[i].hasPermission("ipcheck.getnotify") || online[i].isOp()) { // If player is an operator or has the ipcheck.getnotify permission
online[i].sendMessage("");
online[i].sendMessage(ChatColor.RED + "Background Report for: " + ChatColor.LIGHT_PURPLE + player.getDisplayName());
online[i].sendMessage(ChatColor.DARK_GRAY + "------------------------");
online[i].sendMessage(ChatColor.GREEN + "IP Address: " + ChatColor.LIGHT_PURPLE + ip);
online[i].sendMessage(ChatColor.LIGHT_PURPLE + player.getDisplayName() + ChatColor.YELLOW + " was found to have " + ChatColor.LIGHT_PURPLE + playersFound + ChatColor.YELLOW + // subtract one from playersfound to make up for Recursion
" possible alternative accounts. Perform command " + ChatColor.LIGHT_PURPLE + "'/check player " + player.getDisplayName() + "'" +
ChatColor.YELLOW + " for more information.");
online[i].sendMessage(ChatColor.DARK_GRAY + "------------------------");
online[i].sendMessage("");
}
} else if (!Configuration.detailNotify) { // If Detailed Notifications are disabled, display the simple notification.
if (online[i].hasPermission("ipcheck.getnotify") || online[i].isOp()) { // If player is an operator or has the ipcheck.getnotify permission
online[i].sendMessage(ChatColor.DARK_GRAY + "---------------------------------------");
online[i].sendMessage(ChatColor.GOLD + plugName + ChatColor.RED + "Warning! " + ChatColor.LIGHT_PURPLE + player.getDisplayName() + ChatColor.RED + " may have multiple accounts!");
online[i].sendMessage(ChatColor.DARK_GRAY + "---------------------------------------");
}
}
}
}
}
}
public ArrayList<String> banPlayers(ArrayList<String> players, CommandSender sender, String ip, boolean banning) {
// Ban or Unban IP Address
if (banning) {
Bukkit.banIP(ip);
sender.sendMessage("");
sender.sendMessage("Banned IP Address: " + ip);
sender.sendMessage("");
foundIP = true;
} else if (!banning) {
Bukkit.unbanIP(ip);
sender.sendMessage("");
sender.sendMessage("Unbanned IP Address: " + ip);
sender.sendMessage("");
foundIP = false;
}
// Ban or Unban Players with corresponding IP Address
for(String s:players) {
s = s.replace(".yml", "");
Bukkit.getOfflinePlayer(s).setBanned(banning);
if (banning) {
Player player = Bukkit.getPlayer(s);
if (player != null) {
player.kickPlayer(Configuration.banMessage);
}
sender.sendMessage("Banned " + s);
} else if (!banning) {
sender.sendMessage("Pardoned " + s);
}
}
return players;
}
// Returns the IP address of a player specified, also sets the banned status of the player (calls getBannedStatus())
public String getPlayerInfo(String player, File[] playerFiles) {
String ip = "";
File path = null;
String lookFor = playersDir + "/" + player + ".yml"; // Set the expected player.yml path
// Set Path if player was found
for (int i = 0; i < playerFiles.length; i++) {
if ((playersDir + "/" + playerFiles[i].getName()).equalsIgnoreCase(lookFor)) {
path = new File(playersDir + "/" + playerFiles[i].getName());
break;
}
}
// If player was not found, return the "no-find" string for ip
if (path == null) {
ip = "no-find";
recent = ip;
return ip;
}
// If the player was valid, then set recentPlayer
recentPlayer = player;
// Set the banned status of the player
getBannedStatus(player);
// If player was found, then load their configuration file and obtain the IP address from it
try {
FileInputStream fstream = new FileInputStream(path);
DataInputStream in = new DataInputStream(fstream);
BufferedReader br = new BufferedReader(new InputStreamReader(in));
String strLine;
while ((strLine = br.readLine()) != null) {
if (strLine.startsWith("ipAddress: ")) {
strLine = strLine.replace("ipAddress: ", "");
ip = strLine;
recent = ip;
break;
}
}
br.close();
} catch (Exception e) {
// Console Output in the event we fail to read the configuration file.
getLogger().severe(playerFileReadErr);
}
// Return the IP address
return ip;
}
// Get the banned status of a player
public static void getBannedStatus(String userName) {
isBanned = false;
OfflinePlayer player = Bukkit.getOfflinePlayer(userName);
if (player.isBanned()) isBanned = true;
}
// Method called when a player logs in (has played before)
public void loginCheck(String ip, Player player) {
checkPlayers(compareIP(ip, getBannedList()), getPlayerFiles());
loginReport(ip, player);
}
public int secureCheck(String ip, String playerName) {
checkPlayers(compareIP(ip, getBannedList()), getPlayerFiles());
return playersFound;
}
public boolean secureKick(int accounts, String player, PlayerLoginEvent e, String ip) {
if (accounts > Configuration.secureThreshold && !Configuration.isExemptPlayer(player) && !Configuration.isExemptIp(ip)) { // If the player was reported to have more than the secure-threshold # of accounts, then kick (if not exempt).
//Player kickPlayer = Bukkit.getPlayer(player);
if (player != null) {
e.setKickMessage(Configuration.secureKickMsg);
e.setResult(Result.KICK_OTHER);
return false;
}
}
return true;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment