修复数据量不足时无法正确生成新数据

This commit is contained in:
SerendipityR 2022-08-20 18:33:13 +08:00 committed by GitHub
parent 10b2dd8ad3
commit 401623fc74
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 30 additions and 24 deletions

View File

@ -9,13 +9,27 @@ import java.util.HashMap;
import java.util.List;
public class DataUtil {
public static List<String> botRegPasswords = new ArrayList<>();
public static List<String> botRegPasswords;
public static HashMap<String,String> botRegPasswordsMap = new HashMap<>();
public static File dataFile = new File("data.yml");
public static void loadData() {
YamlConfiguration data = YamlConfiguration.loadConfiguration(dataFile);
botRegPasswords = data.getStringList("Data");
File dataFile = new File("data.yml");
if (dataFile.exists()) {
YamlConfiguration data = YamlConfiguration.loadConfiguration(dataFile);
botRegPasswords = data.getStringList("Data");
} else {
botRegPasswords = new ArrayList<>();
}
if (botRegPasswords.size() < ConfigUtil.BotCount) {
int count = ConfigUtil.BotCount - botRegPasswords.size();
for (int i = 0; i < count; i++) {
String newBotName = ConfigUtil.BotName.replace("$rnd", OtherUtils.getRandomString(3,5));
String newBotPwd = OtherUtils.getRandomString(8,10);
botRegPasswords.add(newBotName + "@" + newBotPwd);
}
}
for (String PwdData:botRegPasswords) {
try {
@ -23,17 +37,15 @@ public class DataUtil {
botRegPasswordsMap.put(aPwdData[0], aPwdData[1]);
} catch (Exception ignored) {}
}
updateData(botRegPasswords);
}
public static void updateData(String name, String pwd) {
public static void updateData(List<String> dataList) {
File dataFile = new File("data.yml");
YamlConfiguration data = YamlConfiguration.loadConfiguration(dataFile);
List<String> datas = data.getStringList("Data");
String aPwdData = name + "@" + pwd;
datas.add(aPwdData);
data.set("Data", datas);
botRegPasswords.add(aPwdData);
botRegPasswordsMap.put(name, pwd);
data.set("Data", dataList);
try {
data.save(dataFile);

View File

@ -18,17 +18,11 @@ public class AttackManager {
public static Boolean isDoubleAttack = false;
public static void doAttack() {
LogUtil.emptyLog();
DataUtil.loadData();
switch (ConfigUtil.AttackMethod) {
case 1:
// BotAttack
DataUtil.loadData();
if (DataUtil.botRegPasswords.size() < ConfigUtil.BotCount) {
for (int i = 0; i < (ConfigUtil.BotCount - DataUtil.botRegPasswords.size()); i++) {
DataUtil.updateData(ConfigUtil.BotName.replace("$rnd", OtherUtils.getRandomString(3,5)), OtherUtils.getRandomString(8,10));
}
}
Map<String, String> modList = new HashMap<>();
if (ProtocolLibs.highVersion) {

View File

@ -123,8 +123,6 @@ public class BotAttack extends IAttack {
if (this.attack_tab) {
tabThread = new Thread(() -> {
while (true) {
SetTitle.INSTANCE.SetConsoleTitleA("EndMinecraftPlusV2 - BotAttack | 当前连接数: " + clients.size() + "个 | 失败次数: " + failed + "次 | 成功加入: " + joined + "次 | 当前存活: " + alivePlayers.size() + "个 | 点击验证: " + clickVerifies + "次 | 重进尝试: " + rejoin);
for (Client c : clients) {
if (c.getSession().isConnected() && c.getSession().hasFlag("join")) {
MultiVersionPacket.sendTabPacket(c.getSession(), "/");
@ -175,6 +173,8 @@ public class BotAttack extends IAttack {
for (String p: ProxyUtil.proxies) {
try {
SetTitle.INSTANCE.SetConsoleTitleA("EndMinecraftPlusV2 - BotAttack | 当前连接数: " + clients.size() + "个 | 失败次数: " + failed + "次 | 成功加入: " + joined + "次 | 当前存活: " + alivePlayers.size() + "个 | 点击验证: " + clickVerifies + "次 | 重进尝试: " + rejoin);
String[] _p = p.split(":");
Proxy proxy = new Proxy(proxyType, new InetSocketAddress(_p[0], Integer.parseInt(_p[1])));
String[] User = AttackManager.getRandomUser().split("@");

View File

@ -141,8 +141,6 @@ public class NewBotAttack extends IAttack {
if (this.attack_tab) {
tabThread = new Thread(() -> {
while (true) {
SetTitle.INSTANCE.SetConsoleTitleA("EndMinecraftPlusV2 - BotAttack | 当前连接数: " + clients.size() + "个 | 失败次数: " + failed + "次 | 成功加入: " + joined + "次 | 当前存活: " + alivePlayers.size() + "个 | 点击验证: " + clickVerifies + "次 | 重进尝试: " + rejoin);
for (Session c : clients) {
if (c.isConnected() && c.hasFlag("join")) {
if (ProtocolLibs.adaptAfter758) {
@ -197,6 +195,8 @@ public class NewBotAttack extends IAttack {
for (String p: ProxyUtil.proxies) {
try {
SetTitle.INSTANCE.SetConsoleTitleA("EndMinecraftPlusV2 - BotAttack | 当前连接数: " + clients.size() + "个 | 失败次数: " + failed + "次 | 成功加入: " + joined + "次 | 当前存活: " + alivePlayers.size() + "个 | 点击验证: " + clickVerifies + "次 | 重进尝试: " + rejoin);
String[] _p = p.split(":");
Proxy proxy = new Proxy(proxyType, new InetSocketAddress(_p[0], Integer.parseInt(_p[1])));
String[] User = AttackManager.getRandomUser().split("@");

View File

@ -119,8 +119,6 @@ public class BotAttack extends IAttack {
if (this.attack_tab) {
tabThread = new Thread(() -> {
while (true) {
SetTitle.INSTANCE.SetConsoleTitleA("EndMinecraftPlusV2 - BotAttack | 当前连接数: " + clients.size() + "个 | 失败次数: " + failed + "次 | 成功加入: " + joined + "次 | 当前存活: " + alivePlayers.size() + "个 | 点击验证: " + clickVerifies + "次 | 重进尝试: " + rejoin);
for (Client c : clients) {
if (c.getSession().isConnected() && c.getSession().hasFlag("join")) {
MultiVersionPacket.sendTabPacket(c.getSession(), "/");
@ -171,6 +169,8 @@ public class BotAttack extends IAttack {
for (String p: ProxyUtil.proxies) {
try {
SetTitle.INSTANCE.SetConsoleTitleA("EndMinecraftPlusV2 - BotAttack | 当前连接数: " + clients.size() + "个 | 失败次数: " + failed + "次 | 成功加入: " + joined + "次 | 当前存活: " + alivePlayers.size() + "个 | 点击验证: " + clickVerifies + "次 | 重进尝试: " + rejoin);
String[] _p = p.split(":");
Proxy proxy = new Proxy(proxyType, new InetSocketAddress(_p[0], Integer.parseInt(_p[1])));
String[] User = AttackManager.getRandomUser().split("@");