[FEATURE] compareMode в HWIDHandler

This commit is contained in:
Gravit 2019-03-08 18:15:01 +07:00
parent 920a15a6b2
commit 7f61f21a0b
No known key found for this signature in database
GPG key ID: 061981E1E85D3216

View file

@ -36,6 +36,11 @@ public class MysqlHWIDHandler extends HWIDHandler {
private String banMessage; private String banMessage;
private boolean compareMode = false;
//Using queryHWID "queryHwids": "SELECT * FROM `users_hwids` WHERE `totalMemory` = ? or `serialNumber` = ? or `HWDiskSerial` = ? or `processorID` = ?"
private int compare = 50; //При наборе схожести в 50 очков
private boolean oneCompareMode = false;
/* /*
//Добавить поля hwid в базу с пользователями //Добавить поля hwid в базу с пользователями
@ -136,12 +141,22 @@ public void onCheckInfo(OshiHWID hwid, String username, Connection c) throws HWI
a.setString(i + 1, CommonHelper.replace(paramsHwids[i], replaceParams)); a.setString(i + 1, CommonHelper.replace(paramsHwids[i], replaceParams));
} }
ResultSet set = a.executeQuery(); ResultSet set = a.executeQuery();
if (set.next()) { boolean isOne = false;
while(set.next()) {
if(!oneCompareMode) isOne = true;
OshiHWID db_hwid = new OshiHWID();
db_hwid.serialNumber = set.getString(hwidFieldSerialNumber);
db_hwid.processorID = set.getString(hwidFieldProcessorID);
db_hwid.HWDiskSerial = set.getString(hwidFieldHWDiskSerial);
db_hwid.totalMemory = Long.valueOf(set.getString(hwidFieldTotalMemory));
if(hwid.compare(db_hwid) < compare) continue;
if(oneCompareMode) isOne = true;
boolean isBanned = set.getBoolean(hwidFieldBanned); boolean isBanned = set.getBoolean(hwidFieldBanned);
if (isBanned) { if (isBanned) {
throw new HWIDException(banMessage); throw new HWIDException(banMessage);
} }
} else { }
if(isOne) {
onUpdateInfo(hwid, username, c); onUpdateInfo(hwid, username, c);
} }
} catch (SQLException e) { } catch (SQLException e) {