Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 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.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 defBanMsg = "Banned for Multi-accounting.";
- public static final String noRecent = "You have not searched a player yet.";
- public static String recent = "";
- public static String recentPlayer = "";
- public static File bannedIPs = new File("banned-ips.txt");
- public static File playersDir = new File("plugins/Essentials/userdata");
- 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 onPlayerJoin(PlayerLoginEvent e) {
- if (Configuration.notifyLogin || Configuration.secureMode) { // Only perform this if either one of these options is enabled, else return immediately
- Player player = e.getPlayer();
- boolean shouldCheck = false;
- // 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);
- getLogger().info(iNetAddress);
- 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;
- }
- }
- if (Configuration.secureMode) {
- shouldCheck = secureKick(secureCheck(ip.toString(), player.getName()), player.getName(), e);
- }
- if (Configuration.notifyLogin && shouldCheck) {
- loginCheck(ip.toString(), e.getPlayer());
- return;
- }
- }
- }
- return;
- }
- public static String getIP(PlayerLoginEvent e) {
- InetAddress a = e.getAddress();
- String ip = a.getHostAddress();
- return ip;
- }
- @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;
- // 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(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")) {
- Configuration.addExemption(1, args[2]);
- } else if (args[1].equalsIgnoreCase("ip")) {
- Configuration.addExemption(0, args[2]);
- }
- } else {
- sender.sendMessage(numArgsErr);
- }
- } else {
- sender.sendMessage(noPermErr);
- }
- return true;
- // Exempt-List Command
- } else if (args[0].equalsIgnoreCase("exempt-list")) {
- //TODO REQUIRES EXPLICIT PERMISSION SETUP
- if (args.length == 2) {
- //Command Instructions Here
- //TODO
- } else {
- sender.sendMessage(numArgsErr);
- }
- return true;
- // Toggle Command
- } else if (args[0].equalsIgnoreCase("toggle")) {
- if (sender.hasPermission("ipcheck.toggle") || sender.isOp()) {
- if (args.length == 2) {
- //Command Instructions Here
- //TODO
- } else {
- sender.sendMessage(numArgsErr);
- }
- } else {
- sender.sendMessage(noPermErr);
- }
- return true;
- // All else
- } else if (args.length == 1) {
- //Command Instructions here
- if (args[0].charAt(0) >= '0'&& args[0].charAt(0) <= '9') {
- report(checkPlayers(compareIP(args[0], getBannedList()), getPlayerFiles()), sender, args[0], false);
- recent = "";
- return true;
- } else {
- sender.sendMessage(illArgsErr);
- }
- }
- 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(noFind);
- return;
- }
- StringBuilder sb = new StringBuilder();
- for(String s:players) {
- s = s.replace(".yml", "");
- sb.append(s + ", ");
- }
- sender.sendMessage("");
- 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);
- }
- sender.sendMessage("");
- }
- if (foundIP) {
- sender.sendMessage(ChatColor.LIGHT_PURPLE + "IP Banned: " + ChatColor.RED + foundIP);
- } else {
- sender.sendMessage(ChatColor.LIGHT_PURPLE + "IP Banned: " + ChatColor.GREEN + foundIP);
- }
- sender.sendMessage(ChatColor.DARK_GRAY + "---------------------------------------------");
- }
- // Report for player login check
- public void loginReport(String ip, Player player) {
- //if (playersFound <= 1) {
- // return;
- //}
- Player[] online = getServer().getOnlinePlayers();
- Player curPlayer = player;
- if ((curPlayer.hasPlayedBefore() && (playersFound - 1) > Configuration.notifyThreshold) || (!curPlayer.hasPlayedBefore() && playersFound > Configuration.notifyThreshold)) { // If number of accounts is greater than threshold
- 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: " + player.getDisplayName());
- online[i].sendMessage(ChatColor.DARK_GRAY + "------------------------");
- online[i].sendMessage(ChatColor.GREEN + "IP Address: " + ChatColor.LIGHT_PURPLE + ip);
- if (curPlayer.hasPlayedBefore()) {
- playersFound -= 1;
- }
- 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.GOLD + plugName + ChatColor.RED + "Warning! " + ChatColor.LIGHT_PURPLE + player.getDisplayName() + ChatColor.RED + " may have multiple accounts!");
- }
- }
- }
- }
- }
- 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(defBanMsg);
- }
- 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) {
- if (accounts > Configuration.secureThreshold && !Configuration.isExempt(player)) { // 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;
- }
- }
- // Configuration class
- package net.risenphoenix.jnk.ipcheck;
- import java.io.BufferedReader;
- import java.io.DataInputStream;
- import java.io.File;
- import java.io.FileInputStream;
- import java.io.FileWriter;
- import java.io.IOException;
- import java.io.InputStreamReader;
- import java.sql.Date;
- import java.text.SimpleDateFormat;
- import java.util.ArrayList;
- import java.util.logging.Logger;
- import org.bukkit.Bukkit;
- public class Configuration {
- private static Logger logger = Bukkit.getLogger();
- // File paths
- static File dir = new File("plugins/IP-config");
- static File path = new File("plugins/IP-config/Config.ipc");
- private static String confWriteErr = "Failed to generate Configuration File!";
- private static String confReadErr = "Failed to read Configuration File!";
- public static boolean secureMode = false;
- public static boolean notifyLogin = true;
- public static boolean detailNotify = false;
- public static int notifyThreshold = 1;
- public static int secureThreshold = 1;
- public static String secureKickMsg = "Multiple Accounts Not Permitted.";
- public static String banMessage = "Banned for Multi-Accounting.";
- private static String defaultConfig =
- "# IPcheck Configuration / Exemption List\r\n" +
- "# Last Modified: " + getTime() + "\r\n" +
- "===============================\r\n" +
- "Configuration Options\r\n" +
- "===============================\r\n" +
- "notify-on-login: true\r\n" +
- "descriptive-notice: false\r\n" +
- "min-account-notify-threshold: 1\r\n" +
- "secure-mode: false\r\n" +
- "secure-kick-threshold: 1\r\n" +
- "secure-kick-message: 'Multiple Accounts Not Permitted.'\r\n" +
- "ban-message: 'Banned for Multi-Accounting.'\r\n" +
- "===============================\r\n" +
- "Exemptions: IP\r\n" +
- "===============================\r\n" +
- "===============================\r\n" +
- "Exemptions: Player_Name\r\n" +
- "===============================\r\n" +
- "===============================\r\n";
- public static void onLoad() {
- defaultConfiguration(); // Generate Default Configuration if one does not exist.
- parseConfigSettings(loadConfig()); // Load and parse configuration.
- }
- public static String getTime() {
- @SuppressWarnings("unused")
- Date date = new Date(System.currentTimeMillis());
- SimpleDateFormat sdf = new SimpleDateFormat("yyyy/MM/dd HH:mm");
- return sdf.toString();
- }
- // Generate Default Configuration is one is needed.
- public static void defaultConfiguration() {
- FileWriter f = null;
- try {
- // If VoteLinks folder does not exist, create it.
- if (!dir.exists()) dir.mkdir();
- // If configuration file does not exist, create it.
- if (!path.exists()) {
- f = new FileWriter(path, true);
- f.write(defaultConfig);
- f.close();
- }
- } catch (IOException e) {
- // Console Output (in the event of an exception)
- e.printStackTrace();
- logger.info(confWriteErr);
- }
- }
- // Fetch Configuration File for Editing Purposes
- public static ArrayList<String> getConfiguration() {
- ArrayList<String> config = new ArrayList<String>();
- 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) {
- config.add(strLine);
- }
- br.close();
- } catch (Exception e) {
- logger.info(confReadErr);
- }
- return config;
- }
- // Generate a Blank Configuration Document
- public static void regenerateConfiguration() {
- if (path.exists()) {
- path.delete();
- }
- defaultConfiguration();
- }
- public static void addExemption(int exemptionType, String exemption) {
- if (exemptionType == 0) { // IP Exemption
- return;
- } else if (exemptionType == 1) { // Player Exemption
- writeConfiguration(addPlayerExemption(getConfiguration(), exemption));
- loadConfig();
- }
- logger.warning("Failed to add exemption.");
- }
- // Add a Player Exemption to the configuration
- public static ArrayList<String> addPlayerExemption(ArrayList<String> config, String player) {
- ArrayList<String> newConfig = new ArrayList<String>();
- String EOC = config.get(config.size() - 1);
- config.set(config.size() - 1, player);
- config.add(EOC);
- for (String s:config) newConfig.add(s);
- return newConfig;
- }
- // Write Modified Configuration to File
- public static void writeConfiguration(ArrayList<String> newConfig) {
- FileWriter f = null;
- try {
- if (path.exists()) {
- path.delete();
- }
- f = new FileWriter(path, true);
- for(String s:newConfig) {
- f.write(s + "\r\n");
- }
- f.close();
- } catch (Exception e) {
- e.printStackTrace();
- logger.severe(confWriteErr);
- }
- }
- // Load Configuration from File, returns the configuration as an ArrayList<String for parsing
- public static ArrayList<String> loadConfig() {
- ArrayList<String> config = new ArrayList<String>();
- 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) {
- config.add(strLine);
- }
- br.close();
- } catch (Exception e) {
- logger.severe(confReadErr);
- }
- return config;
- }
- public static void parseConfigSettings(ArrayList<String> config) {
- String modulus;
- for (String line:config) {
- if (line.contains("notify-on-login: ")) {
- modulus = line.replace("notify-on-login: ", "");
- if (modulus.equalsIgnoreCase("true")) {
- notifyLogin = true;
- } else {
- notifyLogin = false;
- }
- } else if (line.contains("descriptive-notice: ")) {
- modulus = line.replace("descriptive-notice: ", "");
- if (modulus.equalsIgnoreCase("true")) {
- detailNotify = true;
- } else {
- detailNotify = false;
- }
- } else if (line.contains("min-account-notify-threshold: ")) {
- modulus = line.replace("min-account-notify-threshold: ", "");
- try {
- notifyThreshold = Integer.parseInt(modulus);
- if (notifyThreshold < 1) {
- logger.warning("Value of Configuration option 'min-account-notify-threshold' was lower than the minumum limit! 'min-account-notify-threshold' has been set to the default value (1).");
- notifyThreshold = 1;
- }
- } catch (NumberFormatException e) {
- logger.warning("Failed to parse Configuration option 'min-account-notify-threshold': was not valid integer.");
- }
- } else if (line.contains("secure-mode: ")) {
- modulus = line.replace("secure-mode: ", "");
- if (modulus.equalsIgnoreCase("true")) {
- secureMode = true;
- } else {
- secureMode = false;
- }
- } else if (line.contains("secure-kick-threshold: ")) {
- modulus = line.replace("secure-kick-threshold: ", "");
- try {
- secureThreshold = Integer.parseInt(modulus);
- if (secureThreshold < 1) {
- logger.warning("Value of Configuration option 'secure-kick-threshold' was lower than the minumum limit! 'secure-kick-threshold' has been set to the default value (1).");
- secureThreshold = 1;
- }
- } catch (NumberFormatException e) {
- logger.warning("Failed to parse Configuration option 'secure-kick-threshold': was not valid integer.");
- }
- } else if (line.contains("secure-kick-message: ")) {
- modulus = line.replace("secure-kick-message: ", "");
- secureKickMsg = modulus;
- } else if (line.contains("ban-message: ")) {
- modulus = line.replace("ban-message: ", "");
- banMessage = modulus;
- }
- }
- }
- // Returns list of exempt players from Configuration File
- public static ArrayList<String> getPlayerExemptList() {
- ArrayList<String> exemptList = new ArrayList<String>();
- ArrayList<String> config = loadConfig();
- int line = 0;
- for (String s:config) {
- if (s.equals("Exemptions: Player_Name")) {
- line+=2;
- break;
- }
- line++;
- }
- while (!config.get(line).contains("=")) {
- exemptList.add(config.get(line));
- line++;
- }
- return exemptList;
- }
- public static boolean isExempt(String player) {
- ArrayList<String> list = getPlayerExemptList();
- for (String s:list) {
- if (s.equalsIgnoreCase(player)) {
- return true;
- }
- }
- return false;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement