2023-03-01 11:35:10 -08:00
|
|
|
<?php
|
2025-03-29 10:50:03 +00:00
|
|
|
|
2023-03-01 11:35:10 -08:00
|
|
|
/**
|
|
|
|
|
* Represents a class-based event.
|
|
|
|
|
*
|
|
|
|
|
* @package NamelessMC\Events
|
|
|
|
|
* @author Aberdeener
|
2025-05-02 19:19:52 +02:00
|
|
|
* @version 2.3.0
|
2023-03-01 11:35:10 -08:00
|
|
|
* @license MIT
|
|
|
|
|
*/
|
2024-03-09 03:19:55 -08:00
|
|
|
abstract class AbstractEvent
|
|
|
|
|
{
|
2023-03-01 11:35:10 -08:00
|
|
|
/**
|
|
|
|
|
* Convert the class name to the event name.
|
2024-03-09 03:19:55 -08:00
|
|
|
* Example: UserDeletedEvent -> userDeleted.
|
2023-03-01 11:35:10 -08:00
|
|
|
*
|
|
|
|
|
* @return string The name of the subclass, without the "Event" suffix
|
|
|
|
|
*/
|
2024-03-09 03:19:55 -08:00
|
|
|
public static function name(): string
|
|
|
|
|
{
|
2023-03-01 11:35:10 -08:00
|
|
|
return lcfirst(str_replace('Event', '', static::class));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Get the description of the event.
|
|
|
|
|
*
|
|
|
|
|
* @return string The description of the event
|
|
|
|
|
*/
|
2025-05-02 19:19:52 +02:00
|
|
|
public static function description(): string
|
2024-03-09 03:19:55 -08:00
|
|
|
{
|
2025-05-02 19:19:52 +02:00
|
|
|
return static::name();
|
2023-03-01 11:35:10 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Determine whether to hide this hook from users in the StaffCP, some events should be private.
|
|
|
|
|
*
|
|
|
|
|
* @return bool Whether to hide this hook from users in the StaffCP
|
|
|
|
|
*/
|
2024-03-09 03:19:55 -08:00
|
|
|
public static function internal(): bool
|
|
|
|
|
{
|
2023-03-01 11:35:10 -08:00
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Get the parameters of the event.
|
|
|
|
|
* Parameters are assumed to be public properties of the event class.
|
|
|
|
|
*
|
|
|
|
|
* @return array The parameters of the event
|
|
|
|
|
*/
|
2024-03-09 03:19:55 -08:00
|
|
|
final public function params(): array
|
|
|
|
|
{
|
2023-03-01 11:35:10 -08:00
|
|
|
return get_object_vars($this);
|
|
|
|
|
}
|
|
|
|
|
}
|