解决Windows启动时无法加载默认配置问题
This commit is contained in:
parent
63a6e44f44
commit
2aadf9d7ed
|
@ -8,7 +8,7 @@ import cn.serendipityr.EndMinecraftPlusV2.Tools.ProxyUtil;
|
|||
import cn.serendipityr.EndMinecraftPlusV2.Tools.SetTitle;
|
||||
|
||||
public class EndMinecraftPlusV2 {
|
||||
public static String ver = "1.1.0_Dev";
|
||||
public static String ver = "1.1.1_Dev";
|
||||
|
||||
public static void main(String[] args) {
|
||||
System.out.println("========================-Forked by SerendipityR-========================");
|
||||
|
|
|
@ -5,7 +5,11 @@ import cn.serendipityr.EndMinecraftPlusV2.EndMinecraftPlusV2;
|
|||
|
||||
import javax.naming.directory.Attribute;
|
||||
import javax.naming.directory.InitialDirContext;
|
||||
import java.io.BufferedInputStream;
|
||||
import java.io.File;
|
||||
import java.io.InputStreamReader;
|
||||
import java.io.OutputStreamWriter;
|
||||
import java.nio.file.Files;
|
||||
import java.util.Hashtable;
|
||||
import java.util.List;
|
||||
import java.util.Scanner;
|
||||
|
@ -99,6 +103,108 @@ public class ConfigUtil {
|
|||
} catch (Exception e) {
|
||||
LogUtil.emptyLog();
|
||||
LogUtil.doLog(1, "载入配置文件失败! 详细信息: " + e, null);
|
||||
LogUtil.doLog(-1, "配置可能存在编码问题,是否尝试转换编码以解决问题? [y/n]:", "CFGUtil");
|
||||
Scanner scanner = new Scanner(System.in);
|
||||
if (scanner.nextLine().contains("y")) {
|
||||
String currentCharset = getFileCharset(configFile);
|
||||
|
||||
File tempConfigFile = new File("config_temp.yml");
|
||||
|
||||
switch (currentCharset) {
|
||||
case "GBK":
|
||||
convertFileCharset(configFile, tempConfigFile, currentCharset, "UTF-8");
|
||||
break;
|
||||
case "UTF-8":
|
||||
default:
|
||||
convertFileCharset(configFile, tempConfigFile, currentCharset, "GBK");
|
||||
break;
|
||||
}
|
||||
|
||||
if (configFile.delete()) {
|
||||
tempConfigFile.renameTo(configFile);
|
||||
}
|
||||
|
||||
LogUtil.doLog(0, "任务完成。转换前编码: " + currentCharset + " | 转换后编码: " + getFileCharset(configFile) , "CFGUtil");
|
||||
}
|
||||
|
||||
loadConfig();
|
||||
}
|
||||
}
|
||||
|
||||
public static String getFileCharset(File file) {
|
||||
String charset = "GBK";
|
||||
|
||||
byte[] first3Bytes = new byte[3];
|
||||
|
||||
try {
|
||||
boolean checked = false;
|
||||
BufferedInputStream bis = new BufferedInputStream(Files.newInputStream(file.toPath()));
|
||||
bis.mark(100);
|
||||
|
||||
int read = bis.read(first3Bytes, 0, 3);
|
||||
|
||||
if (read == -1) {
|
||||
bis.close();
|
||||
return charset; // 文件编码为 ANSI
|
||||
} else if (first3Bytes[0] == (byte) 0xFF && first3Bytes[1] == (byte) 0xFE) {
|
||||
charset = "UTF-16LE"; // 文件编码为 Unicode
|
||||
checked = true;
|
||||
} else if (first3Bytes[0] == (byte) 0xFE && first3Bytes[1] == (byte) 0xFF) {
|
||||
charset = "UTF-16BE"; // 文件编码为 Unicode big endian
|
||||
checked = true;
|
||||
} else if (first3Bytes[0] == (byte) 0xEF && first3Bytes[1] == (byte) 0xBB
|
||||
&& first3Bytes[2] == (byte) 0xBF) {
|
||||
charset = "UTF-8"; // 文件编码为 UTF-8
|
||||
checked = true;
|
||||
}
|
||||
|
||||
bis.reset();
|
||||
|
||||
if (!checked) {
|
||||
while ((read = bis.read()) != -1) {
|
||||
if (read >= 0xF0)
|
||||
break;
|
||||
if (0x80 <= read && read <= 0xBF)
|
||||
break;
|
||||
if (0xC0 <= read && read <= 0xDF) {
|
||||
read = bis.read();
|
||||
if (!(0x80 <= read && read <= 0xBF)) {
|
||||
break;
|
||||
}
|
||||
} else if (0xE0 <= read) {
|
||||
read = bis.read();
|
||||
if (0x80 <= read && read <= 0xBF) {
|
||||
read = bis.read();
|
||||
if (0x80 <= read && read <= 0xBF) {
|
||||
charset = "UTF-8";
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
bis.close();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
return charset;
|
||||
}
|
||||
|
||||
public static void convertFileCharset(File inputFile, File outputFile,String currentCharset ,String targetCharset) {
|
||||
try {
|
||||
InputStreamReader isr = new InputStreamReader(Files.newInputStream(inputFile.toPath()) ,currentCharset);
|
||||
java.io.OutputStreamWriter osw = new OutputStreamWriter(Files.newOutputStream(outputFile.toPath()) ,targetCharset);
|
||||
|
||||
int len;
|
||||
while((len = isr.read())!=-1){
|
||||
osw.write(len);
|
||||
}
|
||||
|
||||
osw.close();
|
||||
isr.close();
|
||||
} catch (Exception e) {
|
||||
LogUtil.doLog(1, "转换文件编码时发生错误! 详细信息: " + e, null);
|
||||
EndMinecraftPlusV2.Exit();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -18,8 +18,10 @@ public class DataUtil {
|
|||
botRegPasswords = data.getStringList("Data");
|
||||
|
||||
for (String PwdData:botRegPasswords) {
|
||||
String[] aPwdData = PwdData.split("@");
|
||||
botRegPasswordsMap.put(aPwdData[0], aPwdData[1]);
|
||||
try {
|
||||
String[] aPwdData = PwdData.split("@");
|
||||
botRegPasswordsMap.put(aPwdData[0], aPwdData[1]);
|
||||
} catch (Exception ignored) {}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package cn.serendipityr.EndMinecraftPlusV2.VersionControl.NewVersion.ForgeProtocol;
|
||||
|
||||
import cn.serendipityr.EndMinecraftPlusV2.Tools.LogUtil;
|
||||
import com.google.gson.Gson;
|
||||
|
||||
import java.io.ByteArrayOutputStream;
|
||||
|
@ -55,11 +56,13 @@ public class MCForgeMOTD {
|
|||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
|
||||
LogUtil.doLog(1, "获取服务器上的Forge Mods时发生错误。详细信息: " + e.getMessage(), null);
|
||||
|
||||
try {
|
||||
if (socket.isConnected())
|
||||
socket.close();
|
||||
} catch (IOException e1) {}
|
||||
} catch (IOException ignored) {}
|
||||
}
|
||||
return modList;
|
||||
}
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package cn.serendipityr.EndMinecraftPlusV2.VersionControl.OldVersion.ForgeProtocol;
|
||||
|
||||
import cn.serendipityr.EndMinecraftPlusV2.Tools.LogUtil;
|
||||
import com.google.gson.Gson;
|
||||
|
||||
import java.io.ByteArrayOutputStream;
|
||||
|
@ -55,11 +56,13 @@ public class MCForgeMOTD {
|
|||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
|
||||
LogUtil.doLog(1, "获取服务器上的Forge Mods时发生错误。详细信息: " + e.getMessage(), null);
|
||||
|
||||
try {
|
||||
if (socket.isConnected())
|
||||
socket.close();
|
||||
} catch (IOException e1) {}
|
||||
} catch (IOException ignored) {}
|
||||
}
|
||||
return modList;
|
||||
}
|
||||
|
|
|
@ -106,7 +106,7 @@ public class ProtocolLibs {
|
|||
LogUtil.emptyLog();
|
||||
LogUtil.doLog(1, "加载Minecraft协议库时发生错误! 详细信息:" + e, null);
|
||||
LogUtil.doLog(0, "=========================错误排除=========================", "ProtocolLib");
|
||||
LogUtil.doLog(0, " 1.检查/libs文件夹内依赖库是否完整", "ProtocolLib");
|
||||
LogUtil.doLog(0, " 1.检查[/libs]文件夹内依赖库是否完整", "ProtocolLib");
|
||||
LogUtil.doLog(0, " 2.检查对应依赖库是否存在", "ProtocolLib");
|
||||
LogUtil.doLog(0, " (如[1.8]需要[MC-1.8.jar])", "ProtocolLib");
|
||||
LogUtil.doLog(0, " 3.请输入正确的协议库序号(如10)", "ProtocolLib");
|
||||
|
|
134
src/config.yml
134
src/config.yml
|
@ -1,68 +1,68 @@
|
|||
##############################
|
||||
# EndMinecraftPlusV2 #
|
||||
# Forked by SerendipityR #
|
||||
##############################
|
||||
|
||||
AttackSettings:
|
||||
Address: "example.com"
|
||||
Port: 25565
|
||||
# 攻击方式:
|
||||
# 1 - BotAttack - 集群假人(代理)
|
||||
# 2 - MotdAttackP - MOTD压测(代理)
|
||||
# 3 - MotdAttack - MOTD压测(无代理)
|
||||
# 4 - DoubleAttack - 影分身攻击(代理,仅原版单服可用)
|
||||
Method: 1
|
||||
Time: 3600
|
||||
ConnectDelay: 250
|
||||
# 实际连接数由代理质量和机器性能有关
|
||||
# 进行无代理Motd压测时不建议大于32
|
||||
MaxConnections: 2000
|
||||
# 旧版漏洞利用,大概率无效
|
||||
TabAttack: true
|
||||
AntiAttackMode: true
|
||||
DoubleExploitPlayer: "ImOldSix_666"
|
||||
ShowFails: false
|
||||
|
||||
BotSettings:
|
||||
# 可用占位符:
|
||||
# $rnd - 随机字符
|
||||
# $pwd - 随机生成密码
|
||||
BotName: "ImOldSix_$rnd"
|
||||
BotCount: 1000
|
||||
RejoinCount: 5
|
||||
RejoinDelay: 2000
|
||||
RejoinDetect:
|
||||
- "AntiAttack"
|
||||
ClickVerifiesDetect:
|
||||
- "点击验证"
|
||||
Register&Login: true
|
||||
RegisterCommands:
|
||||
- "/register $pwd $pwd"
|
||||
- "/login $pwd"
|
||||
ChatSpam: true
|
||||
CustomChat:
|
||||
- "喵喵喵萌喵~ $rnd"
|
||||
- "喵喵喵萌~ $rnd"
|
||||
- "喵喵喵~ $rnd"
|
||||
- "喵喵~ $rnd"
|
||||
- "喵~ $rnd"
|
||||
ChatDelay: 3000
|
||||
|
||||
Proxy:
|
||||
# 代理获取方式:
|
||||
# 1 - API - 从API获取
|
||||
# 2 - File - 从本地读取
|
||||
# 3 - File + API - 两种方式同时获取
|
||||
GetType: 1
|
||||
# 代理类型:
|
||||
# 1 - HTTP/HTTPS
|
||||
# 2 - SOCKS4/SOCKS5
|
||||
ProxyType: 1
|
||||
UpdateTime: 300
|
||||
File: "proxies.txt"
|
||||
APIs:
|
||||
- "http://www.66ip.cn/mo.php?tqsl=9999"
|
||||
- "https://www.89ip.cn/tqdl.html?api=1&num=9999"
|
||||
# 保存能连接到目标服务器的代理地址 (如果支持)
|
||||
# 位置: working-proxies.txt
|
||||
##############################
|
||||
# EndMinecraftPlusV2 #
|
||||
# Forked by SerendipityR #
|
||||
##############################
|
||||
|
||||
AttackSettings:
|
||||
Address: "example.com"
|
||||
Port: 25565
|
||||
# 攻击方式:
|
||||
# 1 - BotAttack - 集群假人(代理)
|
||||
# 2 - MotdAttackP - MOTD压测(代理)
|
||||
# 3 - MotdAttack - MOTD压测(无代理)
|
||||
# 4 - DoubleAttack - 影分身攻击(代理,仅原版单服可用)
|
||||
Method: 1
|
||||
Time: 3600
|
||||
ConnectDelay: 250
|
||||
# 实际连接数由代理质量和机器性能有关
|
||||
# 进行无代理Motd压测时不建议大于32
|
||||
MaxConnections: 2000
|
||||
# 旧版漏洞利用,大概率无效
|
||||
TabAttack: true
|
||||
AntiAttackMode: true
|
||||
DoubleExploitPlayer: "ImOldSix_666"
|
||||
ShowFails: false
|
||||
|
||||
BotSettings:
|
||||
# 可用占位符:
|
||||
# $rnd - 随机字符
|
||||
# $pwd - 随机生成密码
|
||||
BotName: "ImOldSix_$rnd"
|
||||
BotCount: 1000
|
||||
RejoinCount: 5
|
||||
RejoinDelay: 2000
|
||||
RejoinDetect:
|
||||
- "AntiAttack"
|
||||
ClickVerifiesDetect:
|
||||
- "点击验证"
|
||||
Register&Login: true
|
||||
RegisterCommands:
|
||||
- "/register $pwd $pwd"
|
||||
- "/login $pwd"
|
||||
ChatSpam: true
|
||||
CustomChat:
|
||||
- "喵喵喵萌喵~ $rnd"
|
||||
- "喵喵喵萌~ $rnd"
|
||||
- "喵喵喵~ $rnd"
|
||||
- "喵喵~ $rnd"
|
||||
- "喵~ $rnd"
|
||||
ChatDelay: 3000
|
||||
|
||||
Proxy:
|
||||
# 代理获取方式:
|
||||
# 1 - API - 从API获取
|
||||
# 2 - File - 从本地读取
|
||||
# 3 - File + API - 两种方式同时获取
|
||||
GetType: 1
|
||||
# 代理类型:
|
||||
# 1 - HTTP/HTTPS
|
||||
# 2 - SOCKS4/SOCKS5
|
||||
ProxyType: 1
|
||||
UpdateTime: 300
|
||||
File: "proxies.txt"
|
||||
APIs:
|
||||
- "http://www.66ip.cn/mo.php?tqsl=9999"
|
||||
- "https://www.89ip.cn/tqdl.html?api=1&num=9999"
|
||||
# 保存能连接到目标服务器的代理地址 (如果支持)
|
||||
# 位置: working-proxies.txt
|
||||
SaveWorkingProxy: true
|
Loading…
Reference in New Issue