Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/jurasciix/advancedevents

A PocketMine-MP plugin that allows you to comfortably register events using a new piece of PHP 8 power — attributes.
https://github.com/jurasciix/advancedevents

events php php-attibutes php8 plugin pmmp pmmp-plugin pmmp-plugins pmmp-virion pocketmine-mp poggit

Last synced: about 21 hours ago
JSON representation

A PocketMine-MP plugin that allows you to comfortably register events using a new piece of PHP 8 power — attributes.

Awesome Lists containing this project

README

        

# AdvancedEvents

This is a [PocketMine-MP](https://github.com/pmmp/PocketMine-MP) plugin that allows you to comfortably working with the events using a new piece of PHP 8 power — [attributes](https://www.php.net/manual/language.attributes.overview.php).

*Inspired by [qPexLegendary's CoolEventListener](https://github.com/qPexLegendary/CoolEventListener).*

## Examples

Below is a simple example of a plugin with an event listener using the [AdvancedEvents](https://github.com/JuraSciix/AdvancedEvents).

```php
getPlayer()->sendMessage("Welcome!");
}

// You can combine the handling of several events at once
#[EventHandler]
private function onBlockPlaceOrBreak(BlockPlaceEvent|BlockBreakEvent $event): void {
// Cancel the event and send a message to the player who initiated the event.
$event->cancel();
$event->getPlayer()->sendPopup("Pls don't do that.");
}
}
```