234 Commits

Author SHA1 Message Date
Dylan K. Taylor
c5ebc12f1a Merge remote-tracking branch 'origin/stable' 2019-07-19 13:45:53 +01:00
TheNewHEROBRINEX
73d3f9f7f7 Fix loadbefore sometimes not working (#3040)
loadbefore operates by injecting self into the target plugin's soft-dependencies. The problem is that these soft-dependency lists are overwritten if the target plugin's soft-dependencies are resolved after the loadbefore of the origin plugin.
2019-07-17 16:52:29 +01:00
Dylan K. Taylor
5e5f43242e Extract a HandlerListManager unit from HandlerList 2019-06-30 14:49:09 +01:00
Dylan K. Taylor
68bff6cf69 moved RegisteredListener to event namespace 2019-06-30 14:31:53 +01:00
Dylan K. Taylor
a6395c9ac7 allow use of any iterable for enum initialization
this allows possible use of generators
2019-06-25 19:37:31 +01:00
Dylan K. Taylor
181cfef731 Remove a whole bunch of useless crap from PluginLogger
this is pretty much just an implementation of a NTS attachable logger now. It should probably be converted into a trait.
2019-06-23 19:39:40 +01:00
Dylan K. Taylor
b0071ed703 Revert "remove PluginBase->getFile()"
This reverts commit 67321bb3f6724f22101aed772537cc10a4bad3ae.
2019-06-07 10:44:52 +01:00
Dylan K. Taylor
b5805c2d0a Extract a ResourceLoader unit from PluginBase
this will allow addressing the resource accessing crash issue for script plugins, once fully implemented.
2019-06-06 19:32:23 +01:00
Dylan K. Taylor
67321bb3f6 remove PluginBase->getFile()
this is in preparation for opening the doors to more exotic kinds of plugin loaders, such as eval()d or web plugins.
2019-06-06 18:35:47 +01:00
Dylan K. Taylor
f8a7766880 PluginBase: remove useless function
it's possible to check the loader instance instead of doing this, and we're gunning to get rid of the path from the plugin base.
2019-06-06 18:22:20 +01:00
Dylan K. Taylor
df8db3b8e3 Merge branch 'stable' 2019-05-31 17:13:13 +01:00
Dylan T
025b72e2f2
Randomize the order of plugins retrieved from disk, fixes #2945 (#2948)
On most filesystems, plugins are loaded in lexical order because that's how the filesystem gives the files to us. This is a problem because it can hide bugs with dependency resolution on specific platforms with this behaviour, while inexplicably breaking on other platforms where the load order is different or undefined.

This change prevents plugins depending on any file yield order by randomizing the order in which plugin files are checked for loadability.
2019-05-31 17:11:20 +01:00
SOFe
3902a3c28c Require opting into receiving cancelled events instead of opting out (#2906)
Warning for plugin developers: This is a silent BC break. It won't raise any errors.

This alters the default behaviour of event handlers to **not** receive cancelled events by default.
It is now required to opt into receiving cancelled events by using the @handleCancelled directive (or the handleCancelled parameter where it's appropriate).

The ambiguous @ignoreCancelled directive is now ignored.

Ramifications:
- The majority of handlers with `if($event->isCancelled()) return;` no longer need such checks.
- Handlers with `@ignoreCancelled true` or `@ignoreCancelled` annotations can have them removed.
- Handlers which want to receive cancelled events need to use `@handleCancelled`.
2019-05-27 15:47:58 +01:00
Dylan K. Taylor
c4b4575c74 Refuse to load plugins with ambiguous minAPI versions
closes #2381
2019-04-12 19:51:43 +01:00
Dylan K. Taylor
bf2851f324 Move API checking to its own class so it can be unit-tested 2019-04-12 19:45:41 +01:00
Dylan K. Taylor
0017c0087a oopsie woopsie 2019-03-31 16:17:01 +01:00
Dylan K. Taylor
3de08bf452 Convert PluginLoadOrder into enum 2019-03-27 18:28:40 +00:00
Dylan T
9c76fb7d96
Implemented plugin loading whitelist/blacklist by config file (#2783) 2019-03-24 16:18:13 +00:00
Dylan K. Taylor
6c8fa8ae28 More nullable and void typehints 2019-03-02 10:29:11 +00:00
Dylan K. Taylor
0daf695825 Merge branch '3.6' 2019-02-23 10:51:28 +00:00
Dylan K. Taylor
2540dacdd7 PluginManager: fixed suffix split handling 2019-02-23 10:51:06 +00:00
Dylan K. Taylor
c26544475e More PHP 7.1 nullables 2019-02-22 12:55:34 +00:00
Dylan K. Taylor
efc2d72d5f Move permission parsing to dedicated PermissionParser class 2019-02-20 16:20:48 +00:00
Dylan K. Taylor
d378371cc8 Transition to spl_object_id() 2019-01-26 15:06:38 +00:00
Dylan K. Taylor
c5998a92a8 PluginManager: clean up some Throwable abuse 2019-01-17 23:34:59 +00:00
Dylan K. Taylor
adc1069ed2 Merge branch '3.5' 2019-01-04 23:28:44 +00:00
Dylan K. Taylor
4b9a142a5d Import global functions and constants for enhanced performance
This is better for performance because these then don't need to be reevaluated every time they are called.

When encountering an unqualified function or constant reference, PHP will first try to locate a symbol in the current namespace by that name, and then fall back to the global namespace.
This short-circuits the check, which has substantial performance effects in some cases - in particular, ord(), chr() and strlen() show ~1500x faster calls when they are fully qualified.

However, this doesn't mean that PM is getting a massive amount faster. In real world terms, this translates to about 10-15% performance improvement.
But before anyone gets excited, you should know that the CodeOptimizer in the PreProcessor repo has been applying fully-qualified symbol optimizations to Jenkins builds for years, which is one of the reasons why Jenkins builds have better performance than home-built or source installations.
We're choosing to do this for the sake of future SafePHP integration and also to be able to get rid of the buggy CodeOptimizer, so that phar and source are more consistent.
2019-01-04 20:43:15 +00:00
Dylan T
5d7feaaf21
Remove EventExecutor, event handlers now use closures (#2525)
This cleans up some cargo-cult code poorly copied from Bukkit, which has negative performance effects and also makes internal event handling more complex than necessary.

## API changes
- Removed `EventExecutor` and `MethodEventExecutor`.
- A listener is no longer required for an event handler to be registered. Closure objects can now be used directly provided that they meet the conditions for registration.
- `PluginManager->registerEvent()` signature has changed: the `Listener` and `EventExecutor` parameters have been removed and a `\Closure $handler` has been added in its place.
- `RegisteredListener` now requires a `Closure` parameter instead of `Listener, EventExecutor`.

## Behavioural changes
These changes reduce the execution complexity involved with calling an event handler. Since event calls can happen in hot paths, this may have visible positive effects on performance.

Initial testing reveals a performance improvement of ~15% per event handler call compared to the old method.
2018-11-13 21:04:47 +00:00
Dylan K. Taylor
3031128520 Merge branch 'release/3.4' 2018-11-11 19:52:05 +00:00
Dylan K. Taylor
46d9475568 Use Utils::getNiceClosureName() in PluginManager 2018-11-11 19:50:07 +00:00
Dylan K. Taylor
95bf3ab7a8 Merge branch 'release/3.4' 2018-11-11 11:15:54 +00:00
Dylan K. Taylor
5284ad0346 Merge branch 'release/3.3' into release/3.4 2018-11-11 11:15:46 +00:00
Dylan K. Taylor
b19b3134ad PluginManager: reduce unnecessary indentation 2018-11-11 11:15:27 +00:00
Dylan K. Taylor
2965109484 Merge branch 'release/3.4' 2018-11-10 22:37:17 +00:00
Dylan K. Taylor
7cf36f460b Merge branch 'release/3.3' into release/3.4 2018-11-10 22:37:08 +00:00
Dylan K. Taylor
9156cbc269 PluginManager: Make registerEvents() check order more logical
Prioritize validating that the function is actually a handler, before trying to parse its doc comment.
2018-11-10 22:36:46 +00:00
Dylan K. Taylor
3a6af3327f Encapsulate plugin.yml commands handling inside PluginBase, removed CommandExecutor requirement from Plugin interface
This removes the need for custom Plugin implementations to implement onCommand().

In the future it's planned to remove plugin.yml commands completely and have them registered similarly to how events are handled.
2018-11-09 19:50:52 +00:00
Dylan K. Taylor
6437078c8b TaskScheduler: remove deprecated constructor parameter 2018-11-04 23:30:04 +00:00
Dylan K. Taylor
90482e79bc Merge branch 'release/3.4' 2018-10-21 18:23:54 +01:00
Dylan K. Taylor
6dd2597934 Merge branch 'release/3.3' into release/3.4 2018-10-21 18:17:07 +01:00
Dylan K. Taylor
45c9caa38c Fixup some formatting issues 2018-10-21 18:15:25 +01:00
Dylan K. Taylor
605e7e08ed Remove some deprecated methods 2018-10-20 15:29:43 +01:00
Dylan K. Taylor
a653289c40 Rename Plugin->setEnabled() with a more clear name
This is intended to break API in order to jerk the rug out from underneath plugin developers who have been misusing this without noticing the side effects.
2018-10-08 13:06:51 +01:00
Dylan K. Taylor
db9b235aa5 Merge branch 'release/3.3' 2018-10-07 17:48:32 +01:00
Dylan K. Taylor
a3552875cb Merge branch 'release/3.2' into release/3.3 2018-10-07 17:48:26 +01:00
Dylan K. Taylor
d259b2c9ee Merge branch 'release/3.1' into release/3.2 2018-10-07 17:48:19 +01:00
Dylan K. Taylor
10fa74b417 Make clear that Plugin->setEnabled() is @internal
Use of this by plugins will produce a lot of undefined behaviour, such as event handlers not being unregistered, scheduled tasks not being removed, and registered permissions causing memory leaks.
2018-10-07 17:48:11 +01:00
Dylan K. Taylor
495a0b1dc2 Merge branch 'release/3.3' 2018-10-05 18:11:33 +01:00
Dylan K. Taylor
1dd6591ac1 Migrate a bunch of PluginManager->callEvent() usages to Event->call
This has the triple bonus effect of a) making a lot of code easier to read, b) reducing Server::getInstance() usages, and c) removing a whole bunch of Server dependencies.

The network and block namespaces are untouched by this commit due to potential for merge conflicts. These should be dealt with separately on master.
2018-10-05 17:30:06 +01:00
Dylan K. Taylor
6efef3bbc7 Move event calling functionality to Event->call() method
This is dependent on the changes made in b1e0f82cbf2f585ed729245a6883d713effd1793. This now makes it possible to call events without fetching a Server reference, allowing to eliminate a vast array of Server dependencies.
2018-10-05 16:55:37 +01:00