forked from KobeBryant114514/DeathMessages
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
08293e0
commit e85056f
Showing
4 changed files
with
104 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
#include <LoggerAPI.h> | ||
|
||
nlohmann::json Plugin_Config = {}; | ||
extern bool ConsoleLog; | ||
extern bool FileLog; | ||
extern bool JLLog; | ||
extern bool fixDragonBreath; | ||
|
||
std::string defaultConfig = R"({ | ||
//是否启用控制台死亡信息 | ||
//由于从 BDS 1.20.0 开始,BDS的I18n只加载原版资源包,这会导致控制台部分死亡信息不能正常翻译 | ||
//欲修复此问题,请安装 I18nFixer 插件 | ||
"EnableConsoleLog": false, | ||
//是否将死亡日志写入文件保存 | ||
//保存路径为 ./logs/DeathLog.log | ||
//如果未启用控制台死亡信息,此选项无效 | ||
"EnableDeathLogFile": false, | ||
//是否修复龙息伤害定义 | ||
//在Java版15w31c前,末影龙的龙息攻击使用dragon_breath伤害类型,但之后则改为了indirect_magic伤害类型。 | ||
//启用此项后死于龙息会有特殊的死亡信息 | ||
"EnableDragonBreathFix": false, | ||
//是否启用玩家进退服信息 | ||
"EnableJoin&LeftMessage": false | ||
})"; | ||
|
||
void tryCreateConfigFile() { | ||
if(!std::filesystem::exists("./plugins/DeathMessages")){ | ||
std::filesystem::create_directories("./plugins/DeathMessages"); | ||
} | ||
if(!std::filesystem::exists("./plugins/DeathMessages/config.jsonc")){ | ||
WriteAllFile("./plugins/DeathMessages/config.jsonc", defaultConfig); | ||
} | ||
} | ||
|
||
void initConfig() { | ||
std::ifstream jsonfile("./plugins/DeathMessages/config.jsonc"); | ||
if (jsonfile) { | ||
std::stringstream buffer; | ||
buffer << jsonfile.rdbuf(); | ||
std::string jsoncString = buffer.str(); | ||
Plugin_Config = nlohmann::json::parse(jsoncString, nullptr, true, true); | ||
jsonfile.close(); | ||
} | ||
if (Plugin_Config.contains("EnableConsoleLog") && Plugin_Config["EnableConsoleLog"].is_boolean()) { | ||
ConsoleLog = Plugin_Config["EnableConsoleLog"].get<bool>(); | ||
} | ||
if (Plugin_Config.contains("EnableDeathLogFile") && Plugin_Config["EnableDeathLogFile"].is_boolean()) { | ||
FileLog = Plugin_Config["EnableDeathLogFile"].get<bool>(); | ||
} | ||
if (Plugin_Config.contains("EnableDragonBreathFix") && Plugin_Config["EnableDragonBreathFix"].is_boolean()) { | ||
fixDragonBreath = Plugin_Config["EnableDragonBreathFix"].get<bool>(); | ||
} | ||
if (Plugin_Config.contains("EnableJoin&LeftMessage") && Plugin_Config["EnableJoin&LeftMessage"].is_boolean()) { | ||
JLLog = Plugin_Config["EnableJoin&LeftMessage"].get<bool>(); | ||
} | ||
} | ||
|
||
void loadConfig() { | ||
tryCreateConfigFile(); | ||
initConfig(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters