Commit Graph

18 Commits

Author SHA1 Message Date
ce27c03774 PlayerChatEvent: fixed crash when non-CommandSender permissibles subscribe to broadcast permission
doing such a thing doesn't make any sense, but the system allows it, so it has to be accounted for.
2019-12-01 21:44:13 +00:00
c4a8781b5c Fixed doc type inconsistencies surrounding chat broadcast handling (several problems that are all related) 2019-12-01 21:40:11 +00:00
9a2845640b Permissions management cleanup (#2332)
* Added a new PermissionManager, remove ridiculous cyclic dependencies of Permissions on Server

Aside from all the other ridiculous design problems with the permission system, the biggest problems are its API. This is, once again, a result of poor API design copied from Bukkit.

This pull request removes all permission-related functionality from `PluginManager` and moves it to the `pocketmine\permission\PermissionManager` class.

As can be observed from the removed code in the diff, the permissions system was previously entirely dependent on the Server, because it needed to get the PluginManager for registering permissions. This is utterly ridiculous. This refactor isolates _most_ permission-related functionality within the `permission` namespace.

As mentioned above, this stupid API is a direct result of copying from Bukkit. If you look at the API documentation for Bukkit for `PluginManager` you will see that the methods I'm deprecating here are also in there.

## Changes
- Added a new `PermissionManager` class. This can be accessed via its singleton `getInstance()` static method.
- Deprecated the following `PluginManager` methods - these will be removed no later than 4.0.0:
  - `getPermission()`
  - `addPermission()`
  - `removePermission()`
  - `getDefaultPermissions()`
  - `recalculatePermissionDefaults()`
  - `subscribeToPermission()`
  - `unsubscribeFromPermission()`
  - `getPermissionSubscriptions()`
  - `subscribeToDefaultPerms()`
  - `unsubscribeFromDefaultPerms()`
  - `getDefaultPermSubscriptions()`
  - `getPermissions()`
2018-07-26 10:21:41 +01:00
eb0276d459 Apply nullable and void typehints to events namespace 2018-06-11 13:49:16 +01:00
49fbbea7bf Implemented event handler inheritance, allow registering handlers for any valid event (#1792)
* Event handlers always handle subclass events. public static $handlerList no longer required.
* Removed $handlerList declarations
* HandlerList cleanup: Removed HandlerList->handlers and related bake methods
* Removed obsolete Event->getHandlers()
* EventPriority: Added fromString()
* PluginManager: throw exceptions on registering handlers with invalid priorities

This allows specifying a handler of `EntityDamageEvent` which will handle any instanceof it (as per current behaviour), AND also now allows specifying a handler specifically for `EntityDamageByEntityEvent`, which only handles `EntityDamageEvent`.

This was not previously possible due to limitations in the way handlers were registered.

Abstract events may not be handled unless they declare the `@allowHandle` PhpDoc tag.
2018-03-20 17:05:09 +00:00
4f8e4f0522 Add EOF newlines where missing (bulk) (#1836)
This should solve issues with people making GitHub PRs and having the web editor messing things up. GitHub Web Editor sucks :(
2017-12-20 11:56:36 +00:00
6cd4d2c5a2 Added typehints and PhpDoc for events API
excluded blocks and entities events API to avoid merge conflicts
2017-07-05 16:42:06 +01:00
846be84324 Fixed all file headers 2017-06-16 16:18:16 +01:00
51b0673b4b Bite the bullet and enable strict types on everything 2017-06-07 12:53:16 +01:00
3ffdb8e552 Removed @deprecated classes, methods and properties, added some type hints 2015-09-12 17:10:11 +02:00
9e14435dbb Moved network ids to constants, improved some entity methods, more performance 2015-05-30 23:59:24 +02:00
8d468a1efb Format fix 2015-04-11 21:59:55 +02:00
c29ae333a2 Translate format text 2015-04-11 02:15:46 +02:00
7d406066a7 Added outdated event static properties 2015-01-11 19:37:21 +01:00
350cee3d41 Added Event allocation pool, updated SPL with Class::onClassLoaded() 2014-10-28 10:47:40 +01:00
6cbd39de9b Added Inventory interfaces and types, updated long array() to [] 2014-05-22 18:59:16 +02:00
b4cc3bbd43 Added /op, /deop, /kick, OfflinePlayer, moved player list to Server instead of static Player 2014-04-01 19:46:48 +02:00
dd17652aca Fixed wrong paths 2014-04-01 05:06:12 +02:00