Skip to content

Commit

Permalink
API化完成
Browse files Browse the repository at this point in the history
  • Loading branch information
EpsilonZunsat committed Jan 8, 2024
1 parent 46ce7ed commit f89f59c
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 3 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,5 @@ CMakeSettings.json
build/
/.xmake
/CMakeLists.txt
/bin
/bin
.cache/clangd/index
22 changes: 22 additions & 0 deletions include/GMLIB/Server/FakeListAPI.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#pragma once
#include "GMLIB/DllExport.h"
#include "mc/network/packet/PlayerListEntry.h"
namespace GMLIB::FakeListAPI{
GMLIB_API bool addFakeList(PlayerListEntry entry);

GMLIB_API bool addFakeList(std::string name, std::string xuid, long long auid, mce::UUID UUID);

GMLIB_API bool removeFakeList(std::string nameOrXuid);

GMLIB_API void removeAllFakeLists();

GMLIB_API bool checkFakeListExists(std::string name,std::string xuid);

GMLIB_API std::vector<std::string> externAllFakeListName();

//GMLIB_API

//GMLIB_API

//GMLIB_API
}
11 changes: 9 additions & 2 deletions src/Server/FakeListAPI/FakeList.cc
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ inline void sendAddFakeListPacket(PlayerListEntry entry) {
pkt.emplace(std::move(entry));
pktSender->send(pkt);
}
inline void sendRemoveFakeListPacket(std::vector<PlayerListEntry> entries) {
inline void sendRemoveFakeListPacket(std::vector<PlayerListEntry> entries) {
auto pkt = PlayerListPacket();
pkt.mAction = PlayerListPacketType::Remove;
for(auto &entry:entries){
Expand Down Expand Up @@ -59,12 +59,19 @@ void removeAllFakeLists() {
sendRemoveFakeListPacket(entries);
fakeListMap.clear();
}
bool CheckFakeListExists(std::string name,std::string xuid){
bool checkFakeListExists(std::string name,std::string xuid){
for (auto fakeListPair : fakeListMap) {
if (fakeListPair.first == name && fakeListPair.second.mXuid == xuid) {
return true;
}
}
return false;
}
std::vector<std::string> externAllFakeListName() {
std::vector<std::string> allFakeLists;
for (auto fakeListPair : fakeListMap) {
allFakeLists.push_back(fakeListPair.first);
}
return allFakeLists;
}
}
17 changes: 17 additions & 0 deletions src/Server/FakeListAPI/FakeListAPI.cc
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,21 @@ namespace GMLIB::FakeListAPI{
std::unordered_map<std::string, PlayerListEntry> fakeListMap;
extern void sendAddFakeListPacket(PlayerListEntry entry);
extern void sendRemoveFakeListPacket(std::vector<PlayerListEntry> entries);


LL_AUTO_TYPED_INSTANCE_HOOK(
sendAllFakeListPlayerJoin,
HookPriority::Normal,
ServerPlayer,
"?setLocalPlayerAsInitialized@ServerPlayer@@QEAAXXZ",
bool
) {
auto pkt = PlayerListPacket();
pkt.mAction = PlayerListPacketType::Add;
for(auto fakeListPair:fakeListMap){
pkt.emplace(std::move(fakeListPair.second));
}
pktSender->sendToClient(this->getNetworkIdentifier(),pkt,this->getClientSubId());
return origin();
}
}

0 comments on commit f89f59c

Please sign in to comment.