Welcome!

Join our community of MMO enthusiasts and game developers! By registering, you'll gain access to discussions on the latest developments in MMO server files and collaborate with like-minded individuals. Join us today and unlock the potential of MMO server development!

Join Today!

!unban <Alternative> <Unbans Macs and IP Address Also>

Junior Spellweaver
Joined
Feb 23, 2008
Messages
111
Reaction score
1
Hi, I was about 50% finished making this !unban command when I notice someone released one. However, I notice that the current one doesn't unban macs and ip addresses, and mine does, so I decided I'd finish mine and release it.


Here's the code for CommandProcessor.java:

Code:
else if(splitted[0].equals("!unban"))
            {
                String playerName = splitted[1];
                
                Connection con = DatabaseConnection.getConnection();
                PreparedStatement ps;
                
                int accountid = 0;
                
                try
                {
                    //get points according to town
                    ps = con.prepareStatement("SELECT accountid FROM characters WHERE name = ?");
                    ps.setString(1, playerName);
                    ResultSet rs = ps.executeQuery();
                    if (!rs.next())
                    {
                        ps.close();
                    }
                    accountid = rs.getInt("accountid");
                    ps.close();
                }
                catch (SQLException e) {System.out.println("SQL Exception: " + e);}
                
                String banString = "";
                String macsOrig = "";
                
                try
                {
                    ps = con.prepareStatement("SELECT banreason, macs FROM accounts WHERE id = " + accountid);
                    ResultSet rs = ps.executeQuery();
                    if (!rs.next())
                    {
                        ps.close();
                    }
                    banString = rs.getString("banreason");
                    macsOrig = rs.getString("macs");
                    ps.close();
                }
                catch (SQLException e) {System.out.println("SQL Exception: " + e);}
                
                if(macsOrig != null)
                {
                    int occurs = 0;
                 
                    for(int i = 0; i < macsOrig.length(); i++)
                    {
                        
                          char next = macsOrig.charAt(i);
                          
                          if(next == ',')
                          {
                               occurs++;
                          }
                    }
                    
                    String macs[] = new String[occurs + 1];
                    
                    System.out.println("Creating macs array...");
                    for(int i = 0; i <= occurs; i++)
                    {
                        int offset = 0;
                        
                        if(i > 0)
                            offset = 2;
                        
                        macs[i] = macsOrig.substring((i * 17) + offset, (i * 17) + 17);
                        System.out.println(macs[i]);
                    }
                    
                    for(int i = 0; i < macs.length; i++)
                    {
                        try
                        {
                            ps = con.prepareStatement("DELETE FROM macbans WHERE mac = ?");
                            ps.setString(1, macs[i]);
                            ps.executeUpdate();
                            ps.close();
                        }
                        catch (SQLException e) {System.out.println("SQL Exception: " + e);}
                    }
                    mc.dropMessage("Macs Unbanned");
                }    
                
                if(banString.indexOf("IP: /") != -1)
                {
                    String ip = banString.substring(banString.indexOf("IP: /") + 5, banString.length() - 1);
                    try
                    {
                        ps = con.prepareStatement("DELETE FROM ipbans WHERE ip = ?");
                        ps.setString(1, ip);
                        ps.executeUpdate();
                        ps.close();
                        mc.dropMessage("IP Address Unbanned");
                    }
                    catch (SQLException e) {System.out.println("SQL Exception: " + e);}
                }
                
                
                try
                {
                    ps = con.prepareStatement("UPDATE accounts SET banned = -1, banreason = null WHERE id = " + accountid);
                    ps.executeUpdate();
                    ps.close();
                    mc.dropMessage("Account Unbanned");
                }
                catch (SQLException e) {System.out.println("SQL Exception: " + e);}
                
                
            }



And you'll need to execute this query in your database.
REMEMBER: Always make backups of your database before making any changes

Code:
ALTER TABLE `accounts` MODIFY COLUMN `banreason` VARCHAR(500) CHARACTER SET latin1 COLLATE latin1_swedish_ci;
 
Master Summoner
Loyal Member
Joined
Apr 20, 2008
Messages
578
Reaction score
76
Re: [RELEASE] !unban <Alternative> <Unbans Macs and IP Address Also>

Mine sets banned to -1, unbanning the ip and mac *sigh

But its a good alternative anyway.
 
Newbie Spellweaver
Joined
Jul 11, 2008
Messages
31
Reaction score
0
Re: [RELEASE] !unban <Alternative> <Unbans Macs and IP Address Also>

Great Release, I'll test right now.
 
Junior Spellweaver
Joined
Feb 23, 2008
Messages
111
Reaction score
1
Re: [RELEASE] !unban <Alternative> <Unbans Macs and IP Address Also>

Mine sets banned to -1, unbanning the ip and mac *sigh

But its a good alternative anyway.

I know, I'm not trying to compete or anything, but like I said, I had already started and didn't want what I'd done to go to waste, so I finished it.
 
Skilled Illusionist
Joined
Apr 12, 2008
Messages
397
Reaction score
0
Re: [RELEASE] !unban <Alternative> <Unbans Macs and IP Address Also>

lol, i already use'd zero's >.<

Oh well, they essentially do the same thing right?
 
Master Summoner
Loyal Member
Joined
Apr 20, 2008
Messages
578
Reaction score
76
Re: [RELEASE] !unban <Alternative> <Unbans Macs and IP Address Also>

Sathon said:
However, I notice that the current one doesn't unban macs and ip addresses, and mine does, so I decided I'd finish mine and release it.

I'm not competing either, more like asking why you included that.
 
Junior Spellweaver
Joined
Feb 23, 2008
Messages
111
Reaction score
1
Re: [RELEASE] !unban <Alternative> <Unbans Macs and IP Address Also>

I'm not competing either, more like asking why you included that.

This actually removes the ip and mac bans, which insures that they are completely unbanned if, say, they have another account or something, or they have family members that play on the same computer/ip address.
 
Newbie Spellweaver
Joined
Jul 11, 2008
Messages
31
Reaction score
0
Re: [RELEASE] !unban <Alternative> <Unbans Macs and IP Address Also>

Kk, I tested on one of my Gm's and it works just fine..=D
Ty Sathon!
 
Junior Spellweaver
Joined
Feb 23, 2008
Messages
111
Reaction score
1
Re: [RELEASE] !unban <Alternative> <Unbans Macs and IP Address Also>

lol, i already use'd zero's >.<

Oh well, they essentially do the same thing right?

Essentially; this one is just more elaborate.
 
Newbie Spellweaver
Joined
Jun 10, 2008
Messages
71
Reaction score
1
Re: [RELEASE] !unban <Alternative> <Unbans Macs and IP Address Also>

i add it to the java file and when i type it in game it dont work
 
Initiate Mage
Joined
Jul 30, 2008
Messages
4
Reaction score
0
Re: [RELEASE] !unban <Alternative> <Unbans Macs and IP Address Also>

How to add it to the .java file??

Just copy Paste it at the end? :S

I don't understand it..

I pasted it in the .java file, but it doesn't work for me..
 
Junior Spellweaver
Joined
Jul 26, 2008
Messages
128
Reaction score
0
Re: [RELEASE] !unban <Alternative> <Unbans Macs and IP Address Also>

xDutch be sure to paste the .java in jre_6_0 blablabla too ...
 
Junior Spellweaver
Joined
Feb 23, 2008
Messages
111
Reaction score
1
Re: [RELEASE] !unban <Alternative> <Unbans Macs and IP Address Also>

i add it to the java file and when i type it in game it dont work

Did you make sure you compiled and replace your source code first?

How to add it to the .java file??

Just copy Paste it at the end? :S

I don't understand it..

I pasted it in the .java file, but it doesn't work for me..

Go ahead and paste it all UNDER ALL of this code:
Code:
else if (splitted[0].equals("!ban")) {
				if (splitted.length < 3) {
					new ServernoticeMapleClientMessageCallback(2, c).dropMessage("Syntaxhelper : Syntax: !ban charname reason");
					return true;
                                       
				}
				String originalReason = StringUtil.joinStringFrom(splitted, 2);
				String reason = c.getPlayer().getName() + " banned " + splitted[1] + ": " +
				originalReason;
				MapleCharacter target = cserv.getPlayerStorage().getCharacterByName(splitted[1]);
				if (target != null) {
					String readableTargetName = MapleCharacterUtil.makeMapleReadable(target.getName());
					String ip = target.getClient().getSession().getRemoteAddress().toString().split(":")[0];
					reason += " (IP: " + ip + ")";
                                        String gmsname = player.getName();
					target.ban(reason);
                                        c.getPlayer().getMap().broadcastMessage(MaplePacketCreator.serverNotice(6, "" +  splitted[1] + "  got pwned REAL bad by " + gmsname + " for " + originalReason));
                                      
				} else {
					if (MapleCharacter.ban(splitted[1], reason, false)) {
						mc.dropMessage("Offline Banned " + splitted[1]);
					} else {
						mc.dropMessage("Failed to ban " + splitted[1]);
					}
                                }
			}
 
Junior Spellweaver
Joined
Apr 3, 2008
Messages
156
Reaction score
1
Re: [RELEASE] !unban <Alternative> <Unbans Macs and IP Address Also>

ps = con.prepareStatement("UPDATE accounts SET banned = -1, banreason = null WHERE id = " + accountid);


Shouldnt it be banned = 0 ?
 
Junior Spellweaver
Joined
Feb 23, 2008
Messages
111
Reaction score
1
Re: [RELEASE] !unban <Alternative> <Unbans Macs and IP Address Also>

ps = con.prepareStatement("UPDATE accounts SET banned = -1, banreason = null WHERE id = " + accountid);


Shouldnt it be banned = 0 ?

That would work too, I guess the best way to describe it is that -1 is like a "stronger" unban, it really ensures that they get unbanned.
 
Legendary Battlemage
Joined
May 23, 2008
Messages
628
Reaction score
4
Re: [RELEASE] !unban <Alternative> <Unbans Macs and IP Address Also>

-1 unbans the ip and mac addresses you know
 
Legendary Battlemage
Joined
May 23, 2008
Messages
628
Reaction score
4
Re: [RELEASE] !unban <Alternative> <Unbans Macs and IP Address Also>

Zero's didnt work for me...(Keeps saying failed to unban)
So i'll try yours out :D
 
Elite Diviner
Joined
May 25, 2008
Messages
454
Reaction score
0
Re: [RELEASE] !unban <Alternative> <Unbans Macs and IP Address Also>

So does this work?
 
Junior Spellweaver
Joined
Feb 23, 2008
Messages
111
Reaction score
1
Re: [RELEASE] !unban <Alternative> <Unbans Macs and IP Address Also>

So does this work?

Yes, this will unban the banned IP address and the user's Macs as well as their account as opposed to just their account.

The usage is !unban <character name>
 
Back
Top