PHPackages                             muqsit/simple-packet-handler - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. muqsit/simple-packet-handler

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

muqsit/simple-packet-handler
============================

Handle specific data packets (virion for PMMP API 4.0.0)

0.1.6(4mo ago)417.8k—4.8%16[2 issues](https://github.com/Muqsit/SimplePacketHandler/issues)4GPL-3.0PHP

Since Jun 1Pushed 4mo ago2 watchersCompare

[ Source](https://github.com/Muqsit/SimplePacketHandler)[ Packagist](https://packagist.org/packages/muqsit/simple-packet-handler)[ RSS](/packages/muqsit-simple-packet-handler/feed)WikiDiscussions pm5 Synced yesterday

READMEChangelog (5)Dependencies (1)Versions (7)Used By (4)

SimplePacketHandler
===================

[](#simplepackethandler)

Put an end to the if-elseif instanceof hell.

API Documentation
-----------------

[](#api-documentation)

### Packet Monitor

[](#packet-monitor)

Monitor data packets - use this if you aren't modifying the outcome of the event.
Packet monitor registers DataPacket(Receive/Send)Event(s) at `MONITOR` priority.

Use case:

- Dumping extra data from packets
- Debugging whether a packet was sent / received

```
/** @var Plugin $plugin */
$packet_monitor = SimplePacketHandler::createMonitor($plugin);

$packet_monitor->monitorIncoming(function(LoginPacket $packet, NetworkSession $origin) : void{
	$this->getLogger()->debug("Received LoginPacket from #" . spl_object_id($origin));
});

$packet_monitor->monitorIncoming(function(ServerSettingsResponsePacket $packet, NetworkSession $origin) : void{
	$this->getLogger()->debug("Received server settings response from {$origin->getPlayer()->getName()}");
});

$packet_monitor->monitorOutgoing(function(SetActorDataPacket $packet, NetworkSession $target) : void{
	$this->getLogger()->debug("Sent SetActorDataPacket to #" . spl_object_id($target));
});
```

The `LoginPacket` example above is the equivalent of:

```
/**
 * @param DataPacketReceiveEvent $event
 * @priority MONITOR
 */
public function onDataPacketReceive(DataPacketReceiveEvent $event) : void{
	$packet = $event->getPacket();
	if($packet instanceof LoginPacket){
		$origin = $event->getOrigin();
		$this->getLogger()->debug("Received LoginPacket from #" . spl_object_id($origin));
	}
}
```

The `SetActorDataPacket` example above is the equivalent of:

```
/**
 * @param DataPacketSendEvent $event
 * @priority MONITOR
 */
public function onDataPacketSend(DataPacketSendEvent $event) : void{
	foreach($event->getPackets() as $packet){
		if($packet instanceof SetActorDataPacket){
			foreach($event->getTargets() as $target){
				$this->getLogger()->debug("Sent SetActorDataPacket to #" . spl_object_id($target));
			}
		}
	}
}
```

### Packet Interceptor

[](#packet-interceptor)

Handle data packets - DataPacket(Receive/Send)Event(s) are registered at &lt; `MONITOR` priority.

Use case:

- Blocking pocketmine from handling specific data packets
- Modifying data packets before pocketmine handles them

```
/** @var Plugin $plugin */
$packet_interceptor = SimplePacketHandler::createInterceptor($plugin);

$packet_interceptor->interceptIncoming(function(AdventureSettingsPacket $packet, NetworkSession $origin) : bool{
	if($packet->getFlag(AdventureSettingsPacket::FLYING)){
		return false; // cancels the DataPacketReceiveEvent
	}
	return true; // do nothing
});

$packet_interceptor->interceptOutgoing(function(SetTimePacket $packet, NetworkSession $target) : bool{
	$custom_player = CustomPlayerManager::get($target->getPlayer());
	if($custom_player->getPTime() !== $packet->time){
		$target->sendDataPacket(SetTimePacket::create($custom_player->getPTime()));
		return false;
	}
	return true;
});
```

The `AdventureSettingsPacket` example above is the equivalent of:

```
/**
 * @param DataPacketReceiveEvent $event
 * @priority NORMAL
 */
public function onDataPacketReceive(DataPacketReceiveEvent $event) : void{
	$packet = $event->getPacket();
	if($packet instanceof AdventureSettingsPacket){
		$origin = $event->getOrigin();
		if($packet->getFlag(AdventureSettingsPacket::FLYING)){
			$event->cancel();
		}
	}
}
```

The `SetTimePacket` example above is the equivalent of:

```
/**
 * @param DataPacketSendEvent $event
 * @priority NORMAL
 */
public function onDataPacketSend(DataPacketSendEvent $event) : void{
	foreach($event->getPackets() as $packet){
		if($packet instanceof SetTimePacket){
			$targets = $event->getTargets();
			$new_targets = $targets;
			foreach($new_targets as $index => $target){
				$custom_player = CustomPlayerManager::get($target->getPlayer());
				if($custom_player->getPTime() !== $packet->time){
					$target->sendDataPacket(SetTimePacket::create($custom_player->getPTime()));
					unset($new_targets[$index]);
				}
			}

			if(count($new_targets) !== count($targets)){
				// Cancel the event, try sending the remaining targets the
				// batch of packets again.
				$event->cancel();
				if(count($new_targets) > 0){
					$new_target_players = [];
					foreach($new_targets as $new_target){
						$new_target_players[] = $new_target->getPlayer();
					}
					$this->getServer()->broadcastPackets($new_target_players, $event->getPackets());
				}
				break;
			}
		}
	}
}
```

###  Health Score

45

—

FairBetter than 91% of packages

Maintenance74

Regular maintenance activity

Popularity37

Limited adoption so far

Community24

Small or concentrated contributor base

Maturity39

Early-stage or recently created project

 Bus Factor1

Top contributor holds 84% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~248 days

Total

5

Last Release

136d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/247134f60bf8c5c7c8a2f06b0ecea431a052614283aac5093b57bde51039e34a?d=identicon)[muqsit](/maintainers/muqsit)

---

Top Contributors

[![Muqsit](https://avatars.githubusercontent.com/u/15074389?v=4)](https://github.com/Muqsit "Muqsit (42 commits)")[![JuqnDev](https://avatars.githubusercontent.com/u/76711419?v=4)](https://github.com/JuqnDev "JuqnDev (3 commits)")[![JavierLeon9966](https://avatars.githubusercontent.com/u/58715544?v=4)](https://github.com/JavierLeon9966 "JavierLeon9966 (2 commits)")[![AkmalFairuz](https://avatars.githubusercontent.com/u/35138228?v=4)](https://github.com/AkmalFairuz "AkmalFairuz (1 commits)")[![poggit-bot](https://avatars.githubusercontent.com/u/22427965?v=4)](https://github.com/poggit-bot "poggit-bot (1 commits)")[![SOF3](https://avatars.githubusercontent.com/u/19623715?v=4)](https://github.com/SOF3 "SOF3 (1 commits)")

### Embed Badge

![Health badge](/badges/muqsit-simple-packet-handler/health.svg)

```
[![Health](https://phpackages.com/badges/muqsit-simple-packet-handler/health.svg)](https://phpackages.com/packages/muqsit-simple-packet-handler)
```

###  Alternatives

[muqsit/invmenu

A PocketMine-MP virion to create and manage virtual inventories!

2225.4k1](/packages/muqsit-invmenu)[dktapps/pmforms

Form API library for PocketMine-MP plugins

532.6k1](/packages/dktapps-pmforms)[muqsit/asynciterator

A virion that simplifies writing tasks that traverse iterators

183.1k](/packages/muqsit-asynciterator)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
