PHPackages                             laith98dev/simple-event-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. laith98dev/simple-event-handler

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

laith98dev/simple-event-handler
===============================

21PHP

Since Jun 4Pushed 1y agoCompare

[ Source](https://github.com/ArabSkillsNetwork/SimpleEventHandler)[ Packagist](https://packagist.org/packages/laith98dev/simple-event-handler)[ RSS](/packages/laith98dev-simple-event-handler/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependenciesVersions (1)Used By (0)

SimpleEventHandler
==================

[](#simpleeventhandler)

Simple library to handle events for PocketMIne-MP

Usage
=====

[](#usage)

- Create Handler:

```
$handler = SimpleEventHandler::createHandler(plugin: $this, eventClass: PlayerChatEvent::class, callback: function (PlayerChatEvent $event){
    $player = $event->getPlayer();
    // TODO
}, priority: EventPriority::NORMAL, handleCancelled: false);
```

- Once:
    - This will make the event work once.

```
$handler->once();
```

- Filter
    - You can filter the event by specific things like player name, block type, specific message, and specific item.

```
use Laith98Dev\SimpleEventHandler\event\Filter;

// Filter::fromPlayer("Laith98Dev") // this will be for `PlayerEvent`
// Filter::fromMessage("Hello World") // this will be for `PlayerChatEvent`
// Filter::fromBlock(VanillaBlocks::DIRT()) // this will be for `BlockEvent`
// Filter::fromItem(VanillaItems::IRON_SWORD())

$handler->setFilter(Filter::fromPlayer("Laith98Dev"));
```

- Bindings
    - You can use the bindWith` function to bind many events together.

```
$handler->bindWith($eventClass);
```

- Kill
    - This function will kill the handler.

```
$handler->kill();
```

Example
=======

[](#example)

- Instead of doing this:

```
class Main extends PluginBase implements Listener
{
    public function onEnable(): void
    {
        $this->getServer()->getPluginManager()->registerEvents($this, $this);
    }

    public function onChat(PlayerChatEvent $event){
        if($event->getPlayer()->getName() == "Laith98Dev"){
            $this->doIt($event);
        }
    }

    public function onBlockBreak(BlockBreakEvent $event){
        if($event->getPlayer()->getName() == "Laith98Dev"){
            $this->doIt($event);
        }
    }

    public function doIt(PlayerChatEvent|BlockBreakEvent $event){
        $player = $event->getPlayer();

        echo "Hey, i'm working - " . $event::class . " - " . $player->getName() . "\n";
    }
}
```

- It can be done with:

```
class Main extends PluginBase
{
    public function onEnable(): void
    {
        SimpleEventHandler::createHandler($this, PlayerChatEvent::class, function (PlayerChatEvent|BlockBreakEvent $event){
            $player = $event->getPlayer();
            echo "Hey, i'm working - " . $event::class . " - " . $player->getName() . "\n";
        })
        ->setFilter(Filter::fromPlayer("Laith98Dev")->setBlock(VanillaBlocks::DIRT()))
        ->bindWith(BlockBreakEvent::class);
    }
}
```

###  Health Score

14

—

LowBetter than 2% of packages

Maintenance26

Infrequent updates — may be unmaintained

Popularity4

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity18

Early-stage or recently created project

 Bus Factor1

Top contributor holds 75% 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.

### Community

Maintainers

![](https://www.gravatar.com/avatar/94d6c897004242fe5bf0ff02b82606556e98bc2de04e2a2f79eb839765af1111?d=identicon)[Laith98Dev](/maintainers/Laith98Dev)

---

Top Contributors

[![Laith98Dev](https://avatars.githubusercontent.com/u/49840784?v=4)](https://github.com/Laith98Dev "Laith98Dev (12 commits)")[![poggit-bot](https://avatars.githubusercontent.com/u/22427965?v=4)](https://github.com/poggit-bot "poggit-bot (4 commits)")

### Embed Badge

![Health badge](/badges/laith98dev-simple-event-handler/health.svg)

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

PHPackages © 2026

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