Feature/plugin api experimental (#12)

* added a null check to fix crash, expose internal latency value (its buggy)

* fix latency calculations

* sending packets from c#

* world save event, move shutdown def, move called location of shutdown, expose FourKit.FireEvent

* add docs

---------

Co-authored-by: sylvessa <225480449+sylvessa@users.noreply.github.com>
This commit is contained in:
DrPerkyLegit 2026-04-05 22:21:22 -04:00 committed by GitHub
parent 682989c8f1
commit 21b5accc69
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
18 changed files with 1420 additions and 20 deletions

View file

@ -350,7 +350,7 @@ void PlayerConnection::handleMovePlayer(shared_ptr<MovePlayerPacket> packet)
// Anti-cheat: reject movement packets that exceed server-authoritative bounds.
double velocitySq = player->xd * player->xd + player->yd * player->yd + player->zd * player->zd;
double maxAllowedSq = kMoveBaseAllowanceSq + (velocitySq * kMoveVelocityAllowanceScale);
if (player->isAllowedToFly() || player->gameMode->isCreative())
if (player->isAllowedToFly() || (player->gameMode != nullptr && player->gameMode->isCreative()))
{
// Creative / flight-allowed players can move farther legitimately per tick.
maxAllowedSq *= 1.5;
@ -1717,8 +1717,13 @@ void PlayerConnection::handleKeepAlive(shared_ptr<KeepAlivePacket> packet)
{
if (packet->id == lastKeepAliveId)
{
int time = static_cast<int>(System::nanoTime() / 1000000 - lastKeepAliveTime);
player->latency = (player->latency * 3 + time) / 4;
int64_t now = (System::nanoTime() / 1000000);
if (lastKeepAliveTime == 0) lastKeepAliveTime = now;
int64_t delta = static_cast<int64_t>(now - lastKeepAliveTime);
player->latency = (player->latency * 3 + delta) / 4;
lastKeepAliveTime = now;
}
}