What it checks
File location validation
The analyzer verifies the main class file exists at the expected path based on the namespace defined inplugin.yml:
- Converts the fully-qualified class name to a file path
- Expects files under the
src/directory - Follows PSR-4 autoloading conventions
src/MyPlugin/Main.php
Class definition validation
Once the file is found, the analyzer parses and validates:- A class definition exists in the file
- The fully-qualified class name (FQCN) matches the plugin.yml declaration
- The class is not abstract
- The class properly extends or implements PocketMine-MP plugin interfaces
Plugin interface validation
Your main class must follow one of these patterns:Extend PluginBase
The recommended approach for most plugins.
Implement Plugin interface
For advanced use cases requiring custom plugin base classes.
Lifecycle method validation
The analyzer checks that plugin lifecycle methods follow proper visibility rules:onLoad()- Should be public or protectedonEnable()- Should be public or protectedonDisable()- Should be public or protected
Issues detected
Error severity issues
Main class file not found
Main class file not found
The file at the expected path doesn’t exist.Fix: Create the main class file at the expected location or update the
main field in plugin.yml.Failed to parse main class
Failed to parse main class
The PHP file contains syntax errors.Fix: Correct the PHP syntax errors in your main class file.
No class definition found
No class definition found
The file doesn’t contain a class definition.Fix: Ensure your main class file contains a class definition.
FQCN mismatch
FQCN mismatch
The class name or namespace doesn’t match plugin.yml.Fix: Change the class name/namespace to match the
main field in plugin.yml.Abstract class
Abstract class
The main class is declared as abstract.Fix: Remove the
abstract modifier from the main class.Not a plugin
Not a plugin
The class doesn’t extend PluginBase or implement Plugin interface.Fix: Extend
pocketmine\plugin\PluginBase or implement pocketmine\plugin\Plugin.Warning severity issues
- Lifecycle methods (
onLoad,onEnable,onDisable) should be public or protected
Code examples
Correct implementation
Common issues
Path resolution
The analyzer resolves the main class path using PSR-4 conventions:- Takes the FQCN from plugin.yml (e.g.,
MyPlugin\SubNamespace\Main) - Converts backslashes to forward slashes:
MyPlugin/SubNamespace/Main - Adds
.phpextension:MyPlugin/SubNamespace/Main.php - Prepends
src/directory:src/MyPlugin/SubNamespace/Main.php
The analyzer expects your source files to be in the
src/ directory following PSR-4 autoloading standards.Best practices
Use proper namespace structure
Organize your code with meaningful namespaces that match your directory structure.
Keep lifecycle methods protected
Use protected visibility for
onLoad(), onEnable(), and onDisable() methods.Always extend PluginBase
Unless you have specific requirements, extend PluginBase instead of implementing Plugin interface directly.
The analyzer validates your main class at
src/Analyzer/MainClassAnalyzer.php:16-44