presentkim / remove-plugin-data-folder
Removes the empty data folder that axolotl-pm/PocketMine-MP creates for plugins that never use it
Package info
github.com/presentkim-pm/remove-plugin-data-folder
pkg:composer/presentkim/remove-plugin-data-folder
Requires
- php: ^8.4
- pocketmine/pocketmine-mp: ^5.0
Requires (Dev)
- axolotl-pm/pocketmine-mp: ^5.51
- phpunit/phpunit: ^12.0
Suggests
None
Provides
None
Conflicts
None
Replaces
None
This package is auto-updated.
Last update: 2026-11-27 04:48:52 UTC
README
remove-plugin-data-folder
Stop leaving empty folders in plugin_data/ for plugins that never use them.
Packagist ยท Changelog ยท Report a bug ยท Request a feature
final class Main extends PluginBase{ use NoDataFolderPluginTrait; // plugin_data/Main/ is gone }
๐ Why remove-plugin-data-folder?
The server creates plugin_data/<PluginName>/ for every plugin it loads, whether the plugin ever writes a file or not.
A server with many small plugins ends up with a directory full of empty folders.
- Safe : only an empty folder is removed. A single file or subfolder, even a hidden one, keeps it
- Quiet : failures (permissions, another process writing the folder) return
falseinstead of throwing through the server's error handler - Tiny : one class and one trait, no dependencies besides the server
- Tested : on PHP 8.4 / 8.5 against the real
PluginBase
๐ฆ Installation
composer require presentkim/remove-plugin-data-folder
| Requirement | Version |
|---|---|
| Server | axolotl-pm/PocketMine-MP (fork of PocketMine-MP 5) |
| PHP | 8.4 or newer |
The Poggit virion for the original PocketMine-MP 5.44 and older is kept on the
legacy/pmmp-5.44branch (no longer maintained).
๐ Quick start
A plugin with no onLoad() / onEnable() / onDisable() of its own
Use the trait. It removes the empty folder when the plugin is loaded, enabled and disabled.
use kim\present\removeplugindatafolder\NoDataFolderPluginTrait; use pocketmine\plugin\PluginBase; final class Main extends PluginBase{ use NoDataFolderPluginTrait; }
A plugin that already implements them
The trait would clash with your methods, so call the eraser yourself:
use kim\present\removeplugindatafolder\PluginDataFolderEraser; final class Main extends PluginBase implements Listener{ protected function onEnable() : void{ PluginDataFolderEraser::erase($this); $this->getServer()->getPluginManager()->registerEvents($this, $this); } }
๐ API reference
| Method | Description |
|---|---|
PluginDataFolderEraser::erase(Plugin $plugin) : bool |
Remove the plugin's data folder if it is empty |
PluginDataFolderEraser::eraseDirectory(string $dir) : bool |
Remove any directory if it is empty |
NoDataFolderPluginTrait |
Implements onLoad(), onEnable() and onDisable() with erase() |
Both methods return true only when the folder was removed. A missing folder, a folder with anything in it,
a path that is not a directory, or a failed removal return false.
๐งช Development
composer install --ignore-platform-req='ext-*' composer test
๐ License
Distributed under the MIT License. See LICENSE for more information.