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:
DrPerkyLegit 2026-03-29 13:56:24 -04:00 committed by GitHub
parent 33e0ecac56
commit da2aaf1247
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
12 changed files with 241 additions and 4 deletions

View file

@ -1437,10 +1437,12 @@ void PlayerConnection::handleClientCommand(shared_ptr<ClientCommandPacket> packe
void PlayerConnection::handleRespawn(shared_ptr<RespawnPacket> packet)
{
//todo: fire respawn event
}
void PlayerConnection::handleContainerClose(shared_ptr<ContainerClosePacket> packet)
{
//todo: fire container close event
player->doCloseContainer();
}
@ -1819,6 +1821,7 @@ bool PlayerConnection::isServerPacketListener()
void PlayerConnection::handlePlayerAbilities(shared_ptr<PlayerAbilitiesPacket> playerAbilitiesPacket)
{
//todo: fire abilities change event
player->abilities.flying = playerAbilitiesPacket->isFlying() && player->abilities.mayfly;
}
@ -1937,6 +1940,7 @@ void PlayerConnection::handleCustomPayload(shared_ptr<CustomPayloadPacket> custo
Slot *slot = beaconMenu->getSlot(0);
if (slot->hasItem())
{
//todo: beacon powered event?
slot->remove(1);
shared_ptr<BeaconTileEntity> beacon = beaconMenu->getBeacon();
beacon->setPrimaryPower(primary);
@ -1950,6 +1954,7 @@ void PlayerConnection::handleCustomPayload(shared_ptr<CustomPayloadPacket> custo
AnvilMenu *menu = dynamic_cast<AnvilMenu *>( player->containerMenu);
if (menu)
{
//todo: anvel item rename event?
if (customPayloadPacket->data.data == nullptr || customPayloadPacket->data.length < 1)
{
menu->setItemName(L"");
@ -1977,6 +1982,7 @@ bool PlayerConnection::isDisconnected()
void PlayerConnection::handleDebugOptions(shared_ptr<DebugOptionsPacket> packet)
{
//todo: debug options event?
#ifdef _DEBUG
// Player player = dynamic_pointer_cast<Player>( player->shared_from_this() );
player->SetDebugOptions(packet->m_uiVal);
@ -2063,6 +2069,8 @@ void PlayerConnection::handleCraftItem(shared_ptr<CraftItemPacket> packet)
}
}
//todo: fire item crafted event?
// 4J Stu - Fix for #13119 - We should add the item after we remove the ingredients
if(player->inventory->add(pTempItemInst)==false )
{
@ -2137,6 +2145,7 @@ void PlayerConnection::handleTradeItem(shared_ptr<TradeItemPacket> packet)
int buyBMatches = player->inventory->countMatches(buyBItem);
if( (buyAItem != nullptr && buyAMatches >= buyAItem->count) && (buyBItem == nullptr || buyBMatches >= buyBItem->count) )
{
//todo: fire trade event?
menu->getMerchant()->notifyTrade(activeRecipe);
// Remove the items we are purchasing with