130 Commits

Author SHA1 Message Date
Dylan K. Taylor
4d79aced07
Merge branch 'next-minor' into next-major 2022-12-15 19:50:27 +00:00
Rush2929
31465525e3
Fixed PHP-CS-Fixer not import global constants. (#5449) 2022-12-12 17:12:33 +00:00
Dylan K. Taylor
99996b62d6
Align PhpDoc @param tags according to PHP-CS-Fixer 2022-12-06 13:21:20 +00:00
Dylan K. Taylor
3b6ff3c42b
Apply union types in some places (BC breaks) 2022-11-23 14:03:35 +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
bfd1b2c635
PHPStan 1.9.1 2022-11-04 18:28:07 +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
d4b7f66e15
Promote some constructors 2022-05-17 22:34:58 +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
8efa299c65
phpstan 1.4.8 2022-03-09 18:30:54 +00:00
Dylan K. Taylor
581bbfe255
DiskResourceProvider: add @var for type that PHPStan can't infer 2022-03-09 17:18:40 +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
75fc7a2d1f
Merge branch 'stable' into next-minor 2022-01-07 20:16:35 +00:00
Dylan K. Taylor
6d249026cc
Merge branch 'legacy/pm3' into stable 2022-01-07 20:15:15 +00:00
Dylan K. Taylor
a94b88424e
Merge branch 'stable' into next-minor 2021-12-10 19:15:57 +00:00
Dylan K. Taylor
fa48100da5
PluginDescription: ensure base type of decoded document is actually an array
fixes #4628
2021-12-10 18:08:50 +00:00
Dylan K. Taylor
922ce2e312
Merge branch 'stable' into next-minor 2021-12-08 20:10:23 +00:00
Dylan K. Taylor
0793e7e094
PluginLoadabilityChecker: fixed logic of extension compatibility check
if the extension doesn't specify any version, we can't do any constraint other than *.
2021-12-08 20:08:53 +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
0fe6038c41
Merge branch 'stable' 2021-11-24 23:41:40 +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
e4754ab029
PluginBase: Improved error messages for commands containing illegal characters 2021-11-12 00:16:53 +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
f2912fcdd8
Updated pocketmine/log and pocketmine/log-pthreads (BC breaks included)
AttachableLogger deals with Closures now instead of LoggerAttachment objects
ThreadedLoggerAttachment no longer implements LoggerAttachment
2021-11-01 22:22:22 +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
Dylan K. Taylor
44508a138f
Moved plugin extension requirement checks to PluginManager::checkPluginLoadability()
these don't really belong in PluginDescription.
2021-10-20 22:13:30 +01:00
Dylan K. Taylor
6d78a0b435
CS 2021-10-20 21:52:42 +01:00
Dylan K. Taylor
76b4b23d98
PluginManager: remove loadPlugin()
loadPlugins() is now the preferred option, since it does all the proper checks.
In addition, the server now acknowledges that loading a single plugin may cause multiple plugins to be loaded, so returning only a single Plugin is not representative of what's actually happening.
2021-10-20 21:52:19 +01:00
Dylan K. Taylor
03fcd844eb
PluginManager::loadPlugins() now accepts files as well as directories
loadPlugins() is now a superior option to loadPlugin(), since it enforces dependency checks and also supports automatic loading of plugins when new loaders are installed.
2021-10-20 21:36:14 +01:00