mirror of
https://github.com/smartcmd/MinecraftConsoles.git
synced 2026-05-12 20:23:51 +00:00
Add PlayerPreLoginEvent (#8)
* PlayerPreLoginEvent, comments for more events * basic plugin events * plugin failed to load event * add docs --------- Co-authored-by: sylvessa <225480449+sylvessa@users.noreply.github.com>
This commit is contained in:
parent
33e0ecac56
commit
da2aaf1247
12 changed files with 241 additions and 4 deletions
|
|
@ -17,6 +17,7 @@ namespace FourKitBridge
|
|||
{
|
||||
|
||||
typedef void(__stdcall *fn_initialize)();
|
||||
typedef int(__stdcall *fn_fire_player_prelogin)(const char* nameUtf8, int nameByteLen, const char* ipUtf8, int ipByteLen, int port);
|
||||
typedef void(__stdcall *fn_fire_player_join)(int entityId, const char *nameUtf8, int nameByteLen, const char *uuidUtf8, int uuidByteLen);
|
||||
typedef void(__stdcall *fn_fire_player_quit)(int entityId);
|
||||
typedef int(__stdcall *fn_fire_player_kick)(int entityId, int disconnectReason,
|
||||
|
|
@ -100,6 +101,7 @@ struct OpenContainerInfo
|
|||
static std::unordered_map<int, OpenContainerInfo> s_openContainerInfo;
|
||||
|
||||
static fn_initialize s_managedInit = nullptr;
|
||||
static fn_fire_player_prelogin s_managedFirePreLogin = nullptr;
|
||||
static fn_fire_player_join s_managedFireJoin = nullptr;
|
||||
static fn_update_entity_id s_managedUpdateEntityId = nullptr;
|
||||
static fn_fire_player_quit s_managedFireQuit = nullptr;
|
||||
|
|
@ -165,6 +167,7 @@ void Initialize()
|
|||
|
||||
struct { const wchar_t *name; void **target; } entries[] = {
|
||||
{L"Initialize", (void **)&s_managedInit},
|
||||
{L"FirePlayerPreLogin", (void **)&s_managedFirePreLogin},
|
||||
{L"FirePlayerJoin", (void **)&s_managedFireJoin},
|
||||
{L"FirePlayerQuit", (void **)&s_managedFireQuit},
|
||||
{L"FirePlayerKick", (void **)&s_managedFireKick},
|
||||
|
|
@ -305,6 +308,23 @@ void Shutdown()
|
|||
LogInfo("fourkit", "FourKit shut down.");
|
||||
}
|
||||
|
||||
bool FirePlayerPreLogin(const std::wstring& name, const std::string& ip, int port) {
|
||||
if (!s_initialized || !s_managedFirePreLogin)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
std::string nameUtf8 = ServerRuntime::StringUtils::WideToUtf8(name);
|
||||
int canceled = s_managedFirePreLogin(
|
||||
nameUtf8.empty() ? "" : nameUtf8.data(), (int)nameUtf8.size(),
|
||||
ip.empty() ? "" : ip.data(), (int)ip.size(),
|
||||
port);
|
||||
|
||||
LogDebugf("fourkit", "Fired PlayerPreLogin: %s", nameUtf8.data());
|
||||
|
||||
return canceled != 0;
|
||||
}
|
||||
|
||||
void FirePlayerJoin(int entityId, const std::wstring &name, const std::wstring &uuid)
|
||||
{
|
||||
if (!s_initialized || !s_managedFireJoin)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue