96 Commits

Author SHA1 Message Date
Dylan K. Taylor
15eaf67a0c
Merge branch 'minor-next' into major-next 2024-11-25 14:36:25 +00:00
Dylan K. Taylor
5325ecee37
Deal with a whole lot of PHPStan suppressed key casting errors
closes #6534
2024-11-25 14:30:58 +00:00
Dylan K. Taylor
e781c64540
Merge branch 'minor-next' into major-next 2024-03-14 12:47:18 +00:00
Dylan K. Taylor
4fab518384
PluginManager: do not accept generator functions as event handlers
closes #4912

I didn't merge the original PR because this needs to be checked for explicitly registered handlers as well as auto-detected ones from listeners.
2024-02-19 16:53:53 +00:00
Dylan K. Taylor
54694df48c
Merge branch 'minor-next' into major-next 2023-11-01 16:39:55 +00:00
Dylan K. Taylor
e6e2c54ec9
Fixed various reentrant-unsafe 2D array element unsets (similar to previous commit)
this pattern was used in various places
2023-11-01 16:28:59 +00:00
Dylan K. Taylor
e0ad39b70a
Remove ResourceProvider cruft
this had no obvious reason for existing, and with #5958 looming, this will become altogether useless anyway.
2023-08-07 16:14:01 +01:00
Javier León
b944205f60
Remove useless checks for plugins disabling other plugins (#5931) 2023-07-24 11:31:19 +01:00
Javier León
1ffa945fbf
Disallow plugins disabling other plugins (#5872) 2023-07-13 13:44:28 +01:00
Dylan K. Taylor
5c7f4570b4
Merge branch 'minor-next' into major-next 2023-05-06 17:20:37 +01:00
Dylan K. Taylor
d04da9b1d8
Reuse timings handlers for event handlers of the same events
due to direct repeated usage of registerEvent() with closures, we've seen some libraries like muqsit/SimplePacketHandler generate very large timings reports, because a new timings handler gets created every time a plugin registers or unregisters a new packet handler callback.

This change fixes the problem by ensuring that any handlers derived from the same function, handling the same event class, will share the same timer.
2023-05-06 15:42:52 +01:00
Dylan K. Taylor
7e1467f3f7
Merge branch 'minor-next' into major-next 2023-04-05 20:14:59 +01:00
Dylan K. Taylor
a6a360d179
Revert "Be more concise in event handler timing names"
This reverts commit 9db7e5f0ca984f17d6a8218d1c74b9be1c605863.
2023-03-31 21:51:00 +01:00
Dylan K. Taylor
10f3145af2
Merge branch 'minor-next' into major-next 2023-03-29 23:22:02 +01:00
Dylan K. Taylor
bed218d1dd
Fixed the first letter of event timing names getting trimmed off when src-namespace-prefix is not used 2023-03-29 23:11:30 +01:00
Dylan K. Taylor
04197d6b80
Merge remote-tracking branch 'origin/minor-next' into major-next 2023-03-27 19:08:34 +01:00
Dylan K. Taylor
1959d6dc9b
Fix CS 2023-03-27 12:59:26 +01:00
Dylan K. Taylor
9db7e5f0ca
Be more concise in event handler timing names 2023-03-27 01:19:17 +01:00
Dylan K. Taylor
cebdb95265
Optimise plugin timings report entries
this format is already supported by the timings host, so no changes are required to support this.
2023-03-27 01:15:42 +01:00
Dylan K. Taylor
c2918709a3
Merge branch 'next-minor' into next-major 2023-01-06 01:59:04 +00:00
Alexey
172ce659b8
Use str_starts_with, str_ends_with and str_contains instead of strpos (#5485) 2022-12-31 13:02:23 +00:00
Dylan K. Taylor
01bad344a0
Merge branch 'next-minor' into next-major 2022-11-04 20:47:26 +00:00
Dylan K. Taylor
cdbdcb5d67
Merge branch 'stable' into next-minor 2022-11-04 20:44:28 +00:00
Dylan K. Taylor
2fdc46c165
PHPStan 1.9 features 2022-11-04 20:23:34 +00:00
Dylan K. Taylor
7bcc663b60
Migrate core code to using symfony/filesystem
webmozart/path-util is retained for plugin compatibility, but is dropped in 5.0
2022-10-14 21:51:29 +01:00
Dylan K. Taylor
f88ae93897
BC break: Replaced webmozart/path-util with symfony/filesystem, closes #5332 2022-10-13 16:43:36 +01:00
Dylan K. Taylor
f80ffd8de0
Merge branch 'next-minor' into next-major 2022-09-15 13:59:21 +01:00
Dylan T
65ec318c30
PluginManager: Ensure dependents are disabled before dependencies in disablePlugins() (#5227)
this could later be expanded to disablePlugin() to make this disable order mandatory, to provide certainty for plugin devs.

Alternative solutions to this include disabling plugins in the opposite order that they were enabled in, but this doesn't allow for random plugin disables. This way seemed to make sense.
2022-08-31 18:43:30 +01:00
Dylan K. Taylor
aa9f8781ff
Merge branch 'next-minor' into next-major 2022-06-07 19:56:26 +01:00
Dylan K. Taylor
083a35f970
Modernize property type declarations 2022-06-04 18:16:32 +01:00
Dylan K. Taylor
237c2866e0
Merge branch 'stable' of github.com:pmmp/PocketMine-MP into stable 2022-06-04 17:35:18 +01:00
Dylan K. Taylor
38d6284671
Use PHP-CS-Fixer to enforce file header presence 2022-06-04 17:34:49 +01:00
Dylan K. Taylor
4b662d65b3
PluginManager: check graylist before doing any loadability checks
fixes #5087
2022-06-02 16:29:22 +01:00
Covered123
2b84cb7be4
DisablePluginException now can be used to disable plugins (#4780)
closes #2671
2022-05-20 17:01:34 +01:00
Dylan K. Taylor
c60311617d
Modernize private property declarations in src/plugin 2022-05-17 21:37:45 +01:00
Dylan T
52e74296de
Stop the server if any plugin failed to load or enable (#4951)
closes #3080 

If plugins fail to load for some reason, it's highly likely that some critical functionality of the server is compromised. For example:
- if an NPC plugin fails to load, all custom entities added by that plugin will be deleted from worlds
- if a world protection plugin fails, players will be able to grief your otherwise immutable lobby map
- if a worldgen plugin fails, worlds using custom generators won't load
- if a permission plugin fails, players might have access to commands and features they aren't supposed to have
- the list goes on...

This change makes the server commit graceful suicide if any plugin fails to load for error-related reasons, including (but not limited to):
- Incompatible API version
- Missing dependencies
- Invalid plugin.yml
- Invalid main class

Plugins prevented from loading by `plugin_list.yml` are not considered errors and **are not** included in this change. If a plugin is disallowed from loading due to the `plugin_list`, the server will continue to run as if the plugin was not present.
2022-05-11 20:43:38 +01:00
Dylan K. Taylor
212c94ce98
PluginManager: Log an error message when a plugin disables itself during enabling 2022-05-11 13:07:45 +01:00
Dylan K. Taylor
e388cb1643
Merge branch 'stable' into next-minor 2022-04-10 21:23:04 +01:00
Dylan K. Taylor
2efce35331
PluginManager: fixed updating disabled scheduler when plugins cause other plugins to be disabled from within scheduled tasks 2022-04-10 21:00:16 +01:00
Dylan K. Taylor
ac3a6033b9
PluginManager: account for possible abstract main classes
idk why anyone does this, but it shouldn't cause a core crash ...
2022-04-01 23:42:37 +01:00
Dylan K. Taylor
9963fcf849
PluginManager: return the created RegisteredListener from registerEvent()
this allows the handler to be later unregistered when used with a plain closure instead of a magic `Listener`.
2022-03-22 16:20:37 +00:00
Dylan K. Taylor
c9c50e16ec
PluginManager: fixed mishandling of self-disabling plugins in enablePlugins()
this caused a leak of the plugin context, PluginEnableEvent to be called with a disabled plugin, and the plugin's scheduler to get ticked.
2022-03-03 18:48:52 +00:00
Dylan K. Taylor
03f47d0a78
Replace disallowed operators in src/plugin/ 2022-01-20 19:19:20 +00:00
Dylan K. Taylor
889d048ca3
Make use of Utils::assumeNotFalse() in a bunch of places
I've stuck to only doing this in the places where I'm sure we should never get false back. Other places I'm less sure of (and I found more bugs along the way).
2021-12-08 19:39:04 +00:00
Dylan K. Taylor
269231c228
Ban foreach(arrayWithStringKeys as k => v)
this is not as good as phpstan/phpstan-src#769 (e.g. array_key_first()/array_key_last() aren't covered by this, nor is array_rand()) but it does eliminate the most infuriating cases where this usually crops up.
2021-11-15 22:52:05 +00:00
Dylan K. Taylor
6b316dc29a
PluginManager: Make declaration of duplicate permissions a load error 2021-11-06 17:05:37 +00:00
Dylan K. Taylor
4cb6c7dc1e
PluginManager: fixed plugins being able to alter groups of other plugins' permissions
this could happen if a plugin declared a permission already declared by another plugin, and then declared a different default for it (e.g. true instead of op).
2021-11-06 16:32:19 +00:00
Dylan K. Taylor
bb05af103d
PluginManager: fixed crash when using a plugin-loader plugin (read: devtools)
closes #4518
2021-10-28 15:55:05 +01:00
Dylan K. Taylor
e2275cc8ec
PluginManager: Prevent infinite recursion in loadPlugins()
if a plugin calls loadPlugins(server->getPluginPath()) during its onLoad(), and it itself is in that plugin path, an infinite recursion will occur.
2021-10-20 23:10:18 +01:00
Dylan K. Taylor
620874d902
PluginManager: Extract checkPluginLoadability() to a PluginLoadabilityChecker unit
this can be more easily unit-tested.
2021-10-20 22:31:56 +01:00