Thread: The REAL way to protect from illegal usernames - NO lag, 100% effective!

Page 1 of 4 123 ... LastLast
Results 1 to 10 of 33
  1. #1 The REAL way to protect from illegal usernames - NO lag, 100% effective! 
    Pancakes
    Guest
    Purpose: To filter any usernames containing symbols of any sort.
    Difficulty:1/10.
    Effectiveness: 100%.
    Source used: PVPScape

    Welcome all, to my tutorial on how to implement username filtering. First of all, why would we want to do this? Well there are a couple of reasons. First off, is to prevent people playing with names such as:
    Code:
    ~HEY~
    ^S^U^P
    Your G@Y
    You could also modify this tutorial a little bit to filter out any bad words, but that isn't what this is about. Now on to the code!

    Step one.
    First of all, open up your client.java. If you know of any existing ways that this is implemented, you should remove it to prevent lagging (doing the code twice over) and/or possible problems arising from accessing the same file. If you don't know, you should probably assume that you don't have any.

    Step two.
    Go to the very top of your client.java file, and search for this:
    Code:
    public class client extends Player implements Runnable {
    If you can't find that, I can't help you sorry, your on your own .
    Directly underneath that line of code, insert this line of code:
    Code:
    public String IllegalUsernameChars[] = {"~", "!", "@", "#", "$", "%", "^", "&", "*", "(", ")", ";", "'", ",", ".", "/", "?", ":", "[", "{", "]", "}", "|", "admin", "mod"};
    Step three.
    Go to the top of your client.java again, and search for this code:
    Code:
    playerLastConnect = connectedFrom;
    Right underneath that line of code, add this code:
    Code:
    	for (int j = 0; j < IllegalUsernameChars.length; j++) {
    		if (playerName.toLowerCase().contains(IllegalUsernameChars[j])) {
    			if (checkbannedusers() != 5) { //You may need to modify this line!
    				server.banHandler.appendToBanned(playerName);//You may need to modify this line!
    				server.playerHandler.kickNick = playerName;
    			}
    		}
    	}
    In the above code I have commented on two lines of code that you may need to modify, depending on what source you are using. The first is the method that checks to see if your username is on the banned username list, and the second line is to add the current username to the banned username list.

    Well done! You now have a username protection mechanism that disallows usernames with symbols in them! Congratulations.

    Afternote:
    If you want to add more symbols to the IllegalUserNameChars list, or if you wanted to add protection from 'bad' or 'rude' words in the username, you can do that by simply adding to the list. No other changes are nescessary!

    Cheers everyone who read this,
    ~Pancakes.

    I appreciate rëp
     

  2. #2  
    Fire
    Guest
    Going to try this, thanks
     

  3. #3  
    ZeroFreeze
    Guest
    no, this isn't the "real" way. This won't protect you from "SYIPkpker".
     

  4. #4  
    Pancakes
    Guest
    Quote Originally Posted by ZeroFreeze View Post
    no, this isn't the "real" way. This won't protect you from "SYIPkpker".
    You could definately add that in if you wanted to, it is as easy as adding to the list of illegal usernames. As I stated in the tutorial
     

  5. #5  
    Registered Member kiaz's Avatar
    Join Date
    Jun 2007
    Age
    37
    Posts
    29
    Thanks given
    0
    Thanks received
    0
    Rep Power
    1
    Great Tut

    also abit of known info
    SYipkers use the same UID so just block the uid and put a timer on for login attemps
     

  6. #6  
    Hippy
    Guest
    nice work, ill try it when i get home and see if it works.
     

  7. #7  
    Banned

    Join Date
    Oct 2006
    Age
    31
    Posts
    777
    Thanks given
    24
    Thanks received
    95
    Rep Power
    0
    nice kiaz.. now tell me.. whats SYIS user id?
     

  8. #8  
    ZeroFreeze
    Guest
    Quote Originally Posted by Pancakes View Post
    You could definately add that in if you wanted to, it is as easy as adding to the list of illegal usernames. As I stated in the tutorial
    Did you know that current unicode contains more than 100,000 characters?

    Therefore in my opinion it isn't efficient at all. Instead of having a list of illegal characters, it's smarter to use one with legal ones and simply block any client connecting with any characters other than the legal ones.
     

  9. #9  
    Jonny J
    Guest
    I Get This Error, Can You Tell Me How To Fix Please.
    Code:
    client.java:15532: cannot find symbol
    symbol  : variable banHandler
    location: class server
                                    server.banHandler.appendToBanned(playerName);//Y
    ou may need to modify this line!
                                          ^
    Note: stream.java uses or overrides a deprecated API.
    Note: Recompile with -Xlint:deprecation for details.
    1 error
     

  10. #10  
    Pancakes
    Guest
    @Zero: This tutorial was aimed at beginner scripters.
    @Jonny J: I said that you may need to change that line, because the handler 'banhandler' is unique to PVPScape, maybe some others have it too. Look up what method your server uses to ban people, and change what is nescessary.
     

Page 1 of 4 123 ... LastLast

Thread Information
Users Browsing this Thread

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


User Tag List

Posting Permissions
  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •