Thread: Ipban

Results 1 to 4 of 4
  1. #1 Ipban 
    Registered Member
    Join Date
    Dec 2012
    Posts
    227
    Thanks given
    8
    Thanks received
    3
    Rep Power
    12
    Can someoen give me a proper ipban? the one with connection.java Atm my ipban just kicks the player.

    Btw i tried the time banned but it does not work for some reason. Thank you. I can't seem to find it using the search bar or google.
    Reply With Quote  
     

  2. #2  
    -Founder Off Returnofpk-


    Join Date
    Oct 2012
    Age
    28
    Posts
    655
    Thanks given
    97
    Thanks received
    211
    Rep Power
    303
    Code:
    	/**
    	* Adding Ban IP
    	**/
    	public static void addIpToBanList(String IP) {
    		bannedIps.add(IP);
    	}
    	
    	
    	
    	/**
    	* Removing Ban IP
    	**/
    	public static void removeIpFromBanList(String IP) {
    		bannedIps.remove(IP);
    	}
    	
    	/**
    	* Contains Ban IP
    	**/
    	public static boolean isIpBanned(String IP) {
    		if(bannedIps.contains(IP)) {
    			return true;
    		}
    		return false;
    	}
    	
    	public static void banIps() {
    		try {
    			BufferedReader in = new BufferedReader(new FileReader("./Data/bans/IpsBanned.txt"));
    			String data = null;
    			try {
    				while ((data = in.readLine()) != null) {
    					addIpToBanList(data);
    				}
    			} finally {
    				in.close();
    			}
    		} catch (IOException e) {
    			e.printStackTrace();
    		}
    	}
    Attached image
    Reply With Quote  
     

  3. Thankful users:


  4. #3  
    Registered Member
    Join Date
    Dec 2012
    Posts
    227
    Thanks given
    8
    Thanks received
    3
    Rep Power
    12
    Quote Originally Posted by sheepmonger View Post
    Code:
    	/**
    	* Adding Ban IP
    	**/
    	public static void addIpToBanList(String IP) {
    		bannedIps.add(IP);
    	}
    	
    	
    	
    	/**
    	* Removing Ban IP
    	**/
    	public static void removeIpFromBanList(String IP) {
    		bannedIps.remove(IP);
    	}
    	
    	/**
    	* Contains Ban IP
    	**/
    	public static boolean isIpBanned(String IP) {
    		if(bannedIps.contains(IP)) {
    			return true;
    		}
    		return false;
    	}
    	
    	public static void banIps() {
    		try {
    			BufferedReader in = new BufferedReader(new FileReader("./Data/bans/IpsBanned.txt"));
    			String data = null;
    			try {
    				while ((data = in.readLine()) != null) {
    					addIpToBanList(data);
    				}
    			} finally {
    				in.close();
    			}
    		} catch (IOException e) {
    			e.printStackTrace();
    		}
    	}

    i already had all that added.... can you give me your commands? Cause all my commands do is kick them.
    Reply With Quote  
     

  5. #4  
    -Founder Off Returnofpk-


    Join Date
    Oct 2012
    Age
    28
    Posts
    655
    Thanks given
    97
    Thanks received
    211
    Rep Power
    303
    Quote Originally Posted by Lost Legacy View Post
    i already had all that added.... can you give me your commands? Cause all my commands do is kick them.
    Code:
    if (playerCommand.startsWith("ipban")) {
                try {
                    String playerToBan = playerCommand.substring(6);
                    for (int i = 0; i < Config.MAX_PLAYERS; i++) {
                        if (Server.playerHandler.players[i] != null) {
                            if (Server.playerHandler.players[i].playerName.equalsIgnoreCase(playerToBan)) {
                                Connection.addIpToBanList(Server.playerHandler.players[i].connectedFrom);
                                Connection.addIpToFile(Server.playerHandler.players[i].connectedFrom);
                                c.sendMessage("You have IP banned the user: " + Server.playerHandler.players[i].playerName + " with the host: " + Server.playerHandler.players[i].connectedFrom);
                                Client c2 = (Client) Server.playerHandler.players[i];
                                Server.playerHandler.players[i].disconnected = true;
                                c2.sendMessage(" " + c2.playerName + " Got IpBanned By " + c.playerName + ".");
                            }
                        }
                    }
                } catch (Exception e) {
                    c.sendMessage("Player Must Be Offline.");
                }
            }
    Attached image
    Reply With Quote  
     

  6. Thankful user:



Thread Information
Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)


User Tag List

Similar Threads

  1. Ipban/Banuser/Unban All 100% Working =]
    By cycl0n3pk3r in forum Snippets
    Replies: 30
    Last Post: 03-09-2009, 11:07 PM
  2. 100% working ipban!
    By Lil Str Kid in forum Tutorials
    Replies: 27
    Last Post: 07-13-2008, 07:38 PM
  3. Java Scripts For Ipban & Unban
    By Ludacris in forum RS2 Server
    Replies: 5
    Last Post: 06-14-2008, 05:44 PM
  4. auto ipban hackers on your server
    By Icy Whip in forum Tutorials
    Replies: 67
    Last Post: 02-06-2008, 11:45 PM
  5. working ipban!
    By Lil Str Kid in forum Tutorials
    Replies: 1
    Last Post: 01-24-2008, 09:04 PM
Posting Permissions
  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •