Skip to content

Commit

Permalink
fix: remove unused configuration item (#1075)
Browse files Browse the repository at this point in the history
fix something about configuration file
remove version check for LL.NET
  • Loading branch information
Yushu2606 authored Feb 12, 2023
1 parent 143649b commit 452c4e1
Show file tree
Hide file tree
Showing 10 changed files with 51 additions and 46 deletions.
5 changes: 2 additions & 3 deletions LiteLoader/include/liteloader/Config.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,12 @@ struct LLConfig {
bool alwaysLaunchScriptEngine = false;

bool enableAddonsHelper = true;
std::string addonsInstallPath = "plugins/AddonsHelper";
std::string addonsInstallPath = ".\\plugins\\AddonsHelper\\";

bool enableCrashLogger = true;
std::string crashLoggerPath = "plugins\\LiteLoader\\CrashLogger_Daemon.exe";
std::string crashLoggerPath = ".\\plugins\\LiteLoader\\CrashLogger_Daemon.exe";
std::string antiGiveCommand = "kick {player}";
bool enableSimpleServerLogger = true;
bool enableFixDisconnectBug = true;
bool enableFixListenPort = false;
bool enableAntiGive = true;
bool enableUnlockCmd = true;
Expand Down
18 changes: 9 additions & 9 deletions LiteLoader/src/liteloader/BuiltinBugFix.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,22 +42,22 @@ TClasslessInstanceHook(__int64, "?LogIPSupport@RakPeerHelper@@AEAAXW4PeerPurpose
if (globalConfig.enableFixListenPort) {
if (isFirstLog) {
isFirstLog = false;
original(this);
__int64 rt = original(this);
endTime = clock();
Logger("Server").info("Done (" + fmt::format("{:.1f}", static_cast<double>(endTime - startTime) / 1000) +
R"(s)! For help, type "help" or "?")");
return 1;
return rt;
}
return 0;
} else {
original(this);
__int64 rt = original(this);
if (!isFirstLog) {
endTime = clock();
Logger("Server").info("Done (" + fmt::format("{:.1f}", static_cast<double>(endTime - startTime) / 1000) +
R"(s)! For help, type "help" or "?")");
}
isFirstLog = false;
return 1;
return rt;
}
}

Expand Down Expand Up @@ -213,7 +213,7 @@ TInstanceHook(NetworkPeer::DataStatus,
"allocator@D@2@@std@@AEAVNetworkHandler@@AEBV?$shared_ptr@V?$time_point@Usteady_clock@chrono@std@@V?$duration@_"
"JU?$ratio@$00$0DLJKMKAA@@std@@@23@@chrono@std@@@5@@Z",
NetworkConnection, string* data, __int64 a3, __int64** a4) {
auto status = original(this, data, a3, a4);
auto status = original(this, data, a3, a4);
if (status == NetworkPeer::DataStatus::HasData) {
auto stream = ReadOnlyBinaryStream(*data, false);
auto packetId = stream.getUnsignedVarInt();
Expand Down Expand Up @@ -272,27 +272,27 @@ TClasslessInstanceHook(void,
"?fireEventPlayerMessage@MinecraftEventing@@AEAAXAEBV?$basic_string@DU?$char_traits@D@std@@V?$"
"allocator@D@2@@std@@000@Z",
std::string const& a1, std::string const& a2, std::string const& a3, std::string const& a4) {
if (ll::isServerStopping())
if (ll::globalConfig.enableFixBDSCrash && ll::isServerStopping())
return;
original(this, a1, a2, a3, a4);
}

TClasslessInstanceHook(void, "?fireEventPlayerTransform@MinecraftEventing@@SAXAEAVPlayer@@@Z", class Player& a1) {
if (ll::isServerStopping())
if (ll::globalConfig.enableFixBDSCrash && ll::isServerStopping())
return;
original(this, a1);
}

TClasslessInstanceHook(void, "?fireEventPlayerTravelled@MinecraftEventing@@UEAAXPEAVPlayer@@M@Z", class Player& a1,
float a2) {
if (ll::isServerStopping())
if (ll::globalConfig.enableFixBDSCrash && ll::isServerStopping())
return;
original(this, a1, a2);
}

TClasslessInstanceHook(void, "?fireEventPlayerTeleported@MinecraftEventing@@SAXPEAVPlayer@@MW4TeleportationCause@1@H@Z",
class Player* a1, float a2, int a3, int a4) {
if (ll::isServerStopping())
if (ll::globalConfig.enableFixBDSCrash && ll::isServerStopping())
return;
original(this, a1, a2, a3, a4);
}
Expand Down
4 changes: 1 addition & 3 deletions LiteLoader/src/liteloader/BuiltinUnlockCmd.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -86,9 +86,7 @@ TClasslessInstanceHook(bool, "?isExpansionAllowed@CommandSelectorBase@@AEBA_NAEB
TClasslessInstanceHook(void, "?addEnumValueConstraints@CommandRegistry@@QEAAXAEBV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@AEBV?$vector@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@V?$allocator@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@2@@3@W4SemanticConstraint@@@Z",
std::string const& enumName, std::vector<std::string> const& enumValues, SemanticConstraint constraint) {
using namespace magic_enum::bitwise_operators;
if (!ll::globalConfig.enableUnlockCmd)
return original(this, enumName, enumValues, constraint);
if (magic_enum::enum_integer(constraint & SemanticConstraint::RequiresCheatsEnabled)) {
if (ll::globalConfig.enableUnlockCmd && magic_enum::enum_integer(constraint & SemanticConstraint::RequiresCheatsEnabled)) {
constraint = (SemanticConstraint)(constraint & (~SemanticConstraint::RequiresCheatsEnabled));
constraint = (SemanticConstraint)(constraint | SemanticConstraint::RequiresElevatedPermissions);
}
Expand Down
17 changes: 8 additions & 9 deletions LiteLoader/src/liteloader/Config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,6 @@ void inline to_json(nlohmann::json& j, const LLConfig& conf) {
{"SimpleServerLogger", {
{"enabled", conf.enableSimpleServerLogger}
}},
{"FixDisconnectBug", {
{"enabled", conf.enableFixDisconnectBug}
}},
{"UnlockCmd", {
{"enabled", conf.enableUnlockCmd}
}},
Expand Down Expand Up @@ -91,12 +88,18 @@ void inline to_json(nlohmann::json& j, const LLConfig& conf) {
{"ParticleAPI", {
{"enabled", conf.enableParticleAPI}
}},
{"PermissionAPI", {
{"PermissionAPI", {
{"enabled", conf.enablePermissionAPI}
}},
{"FixAbility", {
{"enabled", conf.enableFixAbility}
}},
{"FixBroadcastBug", {
{"enabled", conf.enableFixBroadcastBug}
}},
{"DisableAutoCompactionLog", {
{"enabled", conf.disableAutoCompactionLog}
}},
}}
};
// clang-format on
Expand Down Expand Up @@ -132,10 +135,6 @@ void inline from_json(const nlohmann::json& j, LLConfig& conf) {
const nlohmann::json& setting = modules.at("SimpleServerLogger");
conf.enableSimpleServerLogger = setting.value("enabled", true);
}
if (modules.find("FixDisconnectBug") != modules.end()) {
const nlohmann::json& setting = modules.at("FixDisconnectBug");
conf.enableFixDisconnectBug = setting.value("enabled", true);
}
if (modules.find("FixListenPort") != modules.end()) {
const nlohmann::json& setting = modules.at("FixListenPort");
conf.enableFixListenPort = setting.value("enabled", false);
Expand Down Expand Up @@ -234,7 +233,7 @@ inline bool SaveConfig(nlohmann::json& config) {

/* deprecated
void ChooseLanguage() {
void ChooseLanguage() {
std::unordered_map<std::string, std::string> languageList = {{"en", "English"}, {"zh_CN", "简体中文"}, {"zh_TW", "繁体中文"}, {"ja", "日本語"}, {"ru", "Русский"}, {"id", "Indonesian"}, {"th", "ไทย"}, {"it", "Italiano"}, {"vi", "tiếng việt"}};
ll::logger.info("Please select your language first");
std::unordered_map<unsigned short, std::string> languages;
Expand Down
8 changes: 3 additions & 5 deletions LiteLoader/src/liteloader/Loader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,9 @@ inline void loadScriptEngine() {
std::string llVersion = GetFileVersionString(GetCurrentModule(), true);
for (const string& backend : LLSE_VALID_BACKENDS) {
std::string path = "plugins/LiteLoader/LiteLoader." + backend + ".dll";
if (!filesystem::exists(path)) {
continue;
}
std::string version = GetFileVersionString(path, true);
if (version != llVersion) {
ll::logger.warn(tr("ll.loader.loadScriptEngine.error.versionNotMatch", version, backend, llVersion));
Expand All @@ -158,12 +161,7 @@ inline void loadScriptEngine() {
}

inline void loadDotNETEngine() {
std::string llVersion = GetFileVersionString(GetCurrentModule(), true);
std::string path = "plugins/LiteLoader/LiteLoader.NET.dll";
std::string version = GetFileVersionString(path, true);
if (version != llVersion) {
ll::logger.warn(tr("ll.loader.loadDotNetEngine.error.versionNotMatch", version, llVersion));
}
auto lib = LoadLibrary(str2wstr(path).c_str());
if (lib) {
ll::logger.info(tr("ll.loader.loadDotNetEngine.success"));
Expand Down
8 changes: 4 additions & 4 deletions LiteLoader/src/liteloader/ModifyInfomation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ string& replace_all_distinct(string& str, const string& old_value, const string&
}
return str;
}
THook(void, "?BedrockLogOut@@YAXIPEBDZZ",
THook(void, "?BedrockLogOut@@YAXIPEBDZZ",
int a1, char * a2,...)
{
char Buffer[4096];
Expand All @@ -39,7 +39,7 @@ THook(void, "?BedrockLogOut@@YAXIPEBDZZ",
return original(a1,a2,va);
string input = Buffer;


input.erase(std::remove(input.begin(), input.end(), '\n'), input.end());
switch (a1) {
case 1u:
Expand All @@ -57,8 +57,8 @@ THook(void, "?BedrockLogOut@@YAXIPEBDZZ",
default:
serverLogger.info << input << Logger::endl;
return;
}
}

return original(a1,a2,va);
}

Expand Down
10 changes: 5 additions & 5 deletions LiteLoader/src/liteloader/ModifyPack.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,15 @@ namespace ModifyPack {
THook(ResourcePack*, "??0ResourcePack@@QEAA@AEAVPack@@@Z",
ResourcePack* self, Pack* a2) {
auto Pack = original(self, a2);
auto manifest = &Pack->getManifest();
if (manifest && manifest->getPackOrigin() == PackOrigin::PackOrigin_Dev) {
ModifyPack::PackListCache.push_back(a2->getManifest().getIdentity());
}
auto manifest = &Pack->getManifest();
if (manifest && manifest->getPackOrigin() == PackOrigin::PackOrigin_Dev) {
ModifyPack::PackListCache.push_back(a2->getManifest().getIdentity());
}
return Pack;
}

THook(std::unique_ptr<ResourcePackStack>, "?deserialize@ResourcePackStack@@SA?AV?$unique_ptr@VResourcePackStack@@U?$default_delete@VResourcePackStack@@@std@@@std@@AEAV?$basic_istream@DU?$char_traits@D@std@@@3@AEBVIResourcePackRepository@@@Z",
__int64 a2, ResourcePackRepository* a3) {
__int64 a2, ResourcePackRepository* a3) {
auto Stack = original( a2, a3);
for (auto& id : ModifyPack::PackListCache) {
auto Pack = a3->getResourcePackForPackId(id);
Expand Down
6 changes: 2 additions & 4 deletions LiteLoader/src/llapi/EventAPI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2025,9 +2025,7 @@ TInstanceHook(
}
IF_LISTENED_END(MobTrySpawnEvent);
auto en = original(this, a2, a3, a4, a5, a6, a7, a8);
if (en == nullptr) {
return en;
} else {
if (en) {
IF_LISTENED(MobSpawnedEvent) {
MobSpawnedEvent ev{};
ev.mMob = en;
Expand All @@ -2036,8 +2034,8 @@ TInstanceHook(
ev.call();
}
IF_LISTENED_END(MobSpawnedEvent)
return en;
}
return en;
}

TClasslessInstanceHook(std::optional<class BlockPos>,
Expand Down
2 changes: 1 addition & 1 deletion PermissionAPI
Submodule PermissionAPI updated 1 files
+44 −31 README.md
19 changes: 16 additions & 3 deletions RELEASE_NOTES.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,23 @@
# Release 2.10.0-beta.2
# Release 2.10.0

![BDS 1.19.61.01](https://img.shields.io/badge/BDS-1.19.61.01-blue?style=for-the-badge)&emsp;![Protocol 567](https://img.shields.io/badge/Protocol-567-orange?style=for-the-badge)

## Added

* Release package containing all modules seperately (by @Futrime)
* Throwing original exception when fail to load plugin (by @yqs112358)

## Changed

- Pack modules into one zip file (by @Futrime)
* Adapt to 1.19.61 (by @dreamguxiang)
* Update README to latest documentation (by @Futrime)

## Fixed

* Small bugs in vectors (by @OEOTYAN)
* Simplayer problem (by @ShrBox)
* Strict mode error of some LLSE quickjs plugins (by @yqs112358)
* QuickJS ESM bugs (by @yqs112358)


**Full Changelog**: https://github.com/LiteLDev/LiteLoaderBDS/compare/2.10.0-beta.1...2.10.0-beta.2
**Full Changelog**: https://github.com/LiteLDev/LiteLoaderBDS/compare/2.9.3...2.10.0

0 comments on commit 452c4e1

Please sign in to comment.