mirror of
https://github.com/quizhizhe/LiteLoaderBDS-1.16.40.git
synced 2025-06-03 04:23:39 +00:00
Add Level::getCurrentLevelPath and Level::getCurrentLevelName
This commit is contained in:
parent
59f02218d8
commit
f5888eb4da
@ -93,8 +93,8 @@ public:
|
||||
|
||||
LIAPI static void sendPacketForAllPlayers(Packet& pkt);
|
||||
|
||||
//LIAPI static std::string getCurrentLevelName();
|
||||
//LIAPI static std::string getCurrentLevelPath();
|
||||
LIAPI static std::string getCurrentLevelName();
|
||||
LIAPI static std::string getCurrentLevelPath();
|
||||
LIAPI static int64_t createBossEvent();
|
||||
|
||||
public:
|
||||
|
@ -365,26 +365,26 @@ void Level::sendPacketForAllPlayer(Packet& pkt) {
|
||||
sendPacketForAllPlayers(pkt);
|
||||
}
|
||||
|
||||
// std::string Level::getCurrentLevelName() {
|
||||
// if (Global<PropertiesSettings>)
|
||||
// return Global<PropertiesSettings>->getLevelName();
|
||||
// std::ifstream fin("server.properties");
|
||||
// string buf;
|
||||
// while (getline(fin, buf)) {
|
||||
// if (buf.find("level-name=") != string::npos) {
|
||||
// if (buf.back() == '\n')
|
||||
// buf.pop_back();
|
||||
// if (buf.back() == '\r')
|
||||
// buf.pop_back();
|
||||
// return buf.substr(11);
|
||||
// }
|
||||
// }
|
||||
// return "";
|
||||
// }
|
||||
std::string Level::getCurrentLevelName() {
|
||||
if (Global<PropertiesSettings>)
|
||||
return Global<PropertiesSettings>->getLevelName();
|
||||
std::ifstream fin("server.properties");
|
||||
string buf;
|
||||
while (getline(fin, buf)) {
|
||||
if (buf.find("level-name=") != string::npos) {
|
||||
if (buf.back() == '\n')
|
||||
buf.pop_back();
|
||||
if (buf.back() == '\r')
|
||||
buf.pop_back();
|
||||
return buf.substr(11);
|
||||
}
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
// std::string Level::getCurrentLevelPath() {
|
||||
// return "./worlds/" + getCurrentLevelName();
|
||||
// }
|
||||
std::string Level::getCurrentLevelPath() {
|
||||
return "./worlds/" + getCurrentLevelName();
|
||||
}
|
||||
|
||||
int64_t BossID = 7492341231332ull;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user