Добавляем проверку в LoginController.java:
Скрытый текст PreparedStatement preparedstatement1 = con.prepareStatement((new StringBuilder()).append("SELECT * FROM accounts WHERE login='")+ user +("';").toString()); ResultSet resultset1 = preparedstatement1.executeQuery();
resultset1.next();
if(!address.getHostAddress().equalsIgnoreCase(resultset1.getString("lastIP")) && resultset1.getBoolean("ipblock"))
{
ok = false;
_log.warning((new StringBuilder()).append("IP Block mode: Failed attempt: account ") + user + (" IP: ") + address.getHostAddress());
Скрытый текстpackage l2jlionna.gameserver.handler.voicedcommandhandlers;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.logging.Logger;
import net.sf.l2j.L2DatabaseFactory;
import net.sf.l2j.gameserver.handler.IVoicedCommandHandler;
import net.sf.l2j.gameserver.model.actor.instance.L2PcInstance;
import net.sf.l2j.gameserver.util.FloodProtectors;
public class ipblock implements IVoicedCommandHandler
{
private static Logger _log = Logger.getLogger(ipblock.class.getName());
private static final String[] VOICED_COMMANDS =
{
"ipblock"
};
public boolean useVoicedCommand(String s, L2PcInstance l2pcinstance, String s1)
{
if (s.startsWith("ipblock"))
{
Object obj = null;
Object obj1 = null;
try
{
Connection connection = L2DatabaseFactory.getInstance().getConnection();
PreparedStatement preparedstatement = connection.prepareStatement("SELECT * FROM accounts WHERE login=?");
preparedstatement.setString(1, l2pcinstance.getAccountName());
ResultSet resultset = preparedstatement.executeQuery();
resultset.next();
if (resultset.getBoolean("IPBlock"))
{
PreparedStatement preparedstatement1 = connection.prepareStatement("UPDATE accounts SET ipblock = 0 WHERE login=?");
preparedstatement1.setString(1, l2pcinstance.getAccountName());
preparedstatement1.execute();
l2pcinstance.sendMessage("IP Block mode: account blocking _off");
_log.info("changing IP Block mode for account " + l2pcinstance.getAccountName() + ": Blocking off");
}
else
{
PreparedStatement preparedstatement2 = connection.prepareStatement("UPDATE accounts SET ipblock = 1 WHERE login=?");
preparedstatement2.setString(1, l2pcinstance.getAccountName());
preparedstatement2.execute();
l2pcinstance.sendMessage("IP Block mode: account blocking _on IP: " + resultset.getString("lastIP"));
_log.info("changing IP Block mode for account " + l2pcinstance.getAccountName() + ": Blocking on");
}
}
catch (SQLException sqlexception)
{
_log.warning("Could not store IPBlock mode: " + sqlexception);
}
}
return true;
}
public String[] getVoicedCommandList()
{
return VOICED_COMMANDS;
}
}
SQL ЗАпрос
Скрытый текстCREATE TABLE IF NOT EXISTS `accounts` ( `login` VARCHAR(45) NOT NULL default '',
`password` VARCHAR(45) ,
`lastactive` DECIMAL(20),
`access_level` INT,
`lastIP` VARCHAR(20),
`ipblock` int(1) UNSIGNED default 0,
`lastServer` int(4) default 1,
PRIMARY KEY (`login`)
);
Всё есть в интернете главное знать где найти