rubenjisan / jisanutils
A Pocketmine-MP 5 library for common Pocketmine plugins utils
Requires
- php: ^8.1
Requires (Dev)
- axolotl-pm/pocketmine-mp: ^5.51.0
- dktapps/pmforms: ^2.3.0
- sof3/pharynx: ^0.3.6
Suggests
None
Provides
None
Conflicts
None
Replaces
None
README
A virion with ready-made forms and common helpers for PocketMine plugins: confirmation, success and error dialogs, a paginated-style item list with optional search and back buttons, a search input form, and small utilities for command placeholders and icon paths. Every text is localized through JisanLanguages with a built-in fallback, so the forms work out of the box and can be translated without touching code.
Built for the plugins of the SlimeGames network, with a focus on consistency: every plugin that uses it shows the same dialogs, the same buttons and the same behavior.
Table of contents
- Features
- Engineering highlights
- How it works
- Installation
- Quick start
- Forms reference
- JisanUtils helpers
- Localization keys
- Icons
- API overview
- Project structure
- Troubleshooting
- Author
- License
Features
| # | Feature | Description |
|---|---|---|
| 1 | Modal dialogs | MessageForm, ConfirmationForm, SuccessForm and ErrorForm with consistent titles and buttons |
| 2 | List form | A menu built from an array of strings, with optional search and back buttons and an automatic empty state |
| 3 | Search input form | A custom form with a label and a text input that returns the trimmed query |
| 4 | Localized texts | All titles, buttons and messages are resolved per player through JisanLanguages, with a default fallback |
| 5 | Command placeholders | {player}, {x}, {y}, {z} and {world} replaced in a command string |
| 6 | Icon helpers | Build and check texture paths for form icons |
| 7 | Callback-based API | Plain callables with a documented signature, no subclassing required |
Engineering highlights
- One base class for all dialogs.
ConfirmationForm,SuccessFormandErrorFormextendMessageForm, which wraps the modal form response into two simple callbacks:onSubmitfor the positive choice andonCancelfor the negative one. - Closing the form counts as cancel. The same
onCancelcallback runs when the player presses the negative button or closes the form, so you handle both with a single function. - Localized with a safe fallback. Every text is requested from JisanLanguages using a key and a default value. If a translation is missing, the default text is shown instead of an empty or broken form.
- Index mapping handled for you.
ListFormbuilds the options in the order search → items → back and translates the clicked index back to the item, so youronSelectreceives the string itself and not a button number. - Empty lists are handled. When there are no items,
ListFormreplaces the content with a localized message so the player never sees a blank menu. - Safe command strings.
getRunnableCommand()wraps player names that contain spaces in quotes so the resulting command can be dispatched correctly. - Embeddable as a virion. Compiled into each plugin with a renamed namespace, so different plugins can ship different versions without conflicts.
How it works
flowchart TD
A["ModalForm (pmforms)"] --> B["MessageForm"]
B --> C["ConfirmationForm"]
B --> D["SuccessForm"]
B --> E["ErrorForm"]
F["MenuForm (pmforms)"] --> G["ListForm"]
H["CustomForm (pmforms)"] --> I["SearchInputForm"]
J["JisanLanguages (Lang)"] -.->|"titles, buttons, messages"| B
J -.-> G
J -.-> I
Loading
Installation
Requirements
- PHP 8.1 or later
- PocketMine-MP 5 or AxolotlPM 5 (API
5.0.0) - Composer, and Pharynx to build your plugin
- pmforms (
dktapps/pmforms), used as the form engine - JisanLanguages, used for localized texts
Both dependencies are installed automatically by Composer when you require this library.
With Composer (Packagist)
composer require rubenjisan/jisanutils
Keep PocketMine/AxolotlPM and Pharynx as development dependencies of your plugin so they are not bundled into your .phar:
{
"require": {
"rubenjisan/jisanutils": "^0.1"
},
"require-dev": {
"axolotl-pm/pocketmine-mp": "^5.51.0",
"sof3/pharynx": "^0.3.6"
}
}
Directly from GitHub
If you prefer not to use Packagist, add the repository to your plugin's composer.json:
{
"repositories": [
{ "type": "vcs", "url": "https://github.com/RubenJisan/JisanUtils" }
]
}
Then run composer require rubenjisan/jisanutils.
Building your plugin
This library is a virion: it only works inside a .phar built with Pharynx, not from a plugin folder.
php -dphar.readonly=0 vendor/bin/pharynx -i=. -c -p=YourPlugin.phar
Quick start
Confirmation dialog
use pocketmine\player\Player; use rubenjisan\JisanUtils\forms\modal\ConfirmationForm; $player->sendForm(new ConfirmationForm( $player, "Do you really want to delete this warp?", function(Player $player): void { $player->sendMessage("Warp deleted."); }, function(Player $player): void { $player->sendMessage("Cancelled."); } ));
List with search and back
use pocketmine\player\Player; use rubenjisan\JisanUtils\forms\ListForm; use rubenjisan\JisanUtils\forms\SearchInputForm; $warps = ["Spawn", "Arena", "Shop"]; $player->sendForm(new ListForm( $player, $warps, "§lWarps", "Select a warp", onSelect: function(Player $player, string $warp): void { $player->sendMessage("You selected: " . $warp); }, onSearch: function(Player $player) use ($warps): void { $player->sendForm(new SearchInputForm( $player, "§lSearch warps", "Type part of the warp name", function(Player $player, string $query) use ($warps): void { $results = array_filter($warps, fn(string $w) => stripos($w, $query) !== false); $player->sendForm(new ListForm($player, $results, "§lResults")); } )); }, onBack: function(Player $player): void { $player->sendMessage("Back to the main menu."); } ));
Success and error dialogs
use rubenjisan\JisanUtils\forms\modal\ErrorForm; use rubenjisan\JisanUtils\forms\modal\SuccessForm; $player->sendForm(new SuccessForm($player, "Your clan was created.", fn(Player $p) => null)); $player->sendForm(new ErrorForm( $player, "A clan with that name already exists.", fn(Player $p) => $this->openCreateClanForm($p) // "Retry" button ));
Forms reference
All forms are sent with $player->sendForm(...). Callbacks receive the player who interacted with the form.
MessageForm
Base modal dialog with two buttons. Extend it or use it directly for custom dialogs.
| Parameter | Type | Description |
|---|---|---|
$player |
Player |
The player the form is built for (used for localization) |
$title |
string |
Form title |
$text |
string |
Form body |
$onSubmit |
callable |
fn(Player $player): void, runs on the positive button |
$yesButtonText |
?string |
Positive button text. Defaults to the localized "Accept" |
$noButtonText |
?string |
Negative button text. Defaults to the localized "Cancel" |
$onCancel |
?callable |
fn(Player $player): void, runs on the negative button or when the form is closed |
ConfirmationForm
MessageForm with the localized title Confirmation. Use it before destructive or important actions.
new ConfirmationForm(Player $player, string $text, callable $onSubmit, ?callable $onCancel = null)
SuccessForm
MessageForm with the localized title Success. Use it to confirm that an action completed.
new SuccessForm(Player $player, string $text, callable $onSubmit, ?callable $onCancel = null)
ErrorForm
MessageForm with the localized title Error and a Retry button as the positive choice. onSubmit is where you re-open the previous form.
new ErrorForm(Player $player, string $text, callable $onSubmit, ?callable $onCancel = null)
ListForm
A menu form generated from an array of strings.
| Parameter | Type | Description |
|---|---|---|
$player |
Player |
The player the form is built for |
$items |
string[] |
The entries to display, one button each |
$title |
string |
Form title |
$content |
?string |
Text shown above the buttons |
$onSelect |
?callable |
fn(Player $player, string $item): void, receives the clicked item |
$onSearch |
?callable |
fn(Player $player): void. If set, a Search button is added at the top |
$onBack |
?callable |
fn(Player $player): void. If set, a Back button is added at the bottom |
$onClose |
?callable |
fn(Player $player): void, runs when the player closes the form |
Button order: [Search] → items → [Back]. If $items is empty, the content is replaced with a localized "nothing to show" message.
SearchInputForm
A custom form with a label and a text input.
| Parameter | Type | Description |
|---|---|---|
$player |
Player |
The player the form is built for |
$title |
string |
Form title |
$label |
string |
Text shown above the input |
$onSubmit |
callable |
fn(Player $player, string $query): void, receives the trimmed text |
$placeholder |
?string |
Input placeholder. Defaults to the localized text |
$onClose |
?callable |
fn(Player $player): void, runs when the player closes the form |
JisanUtils helpers
JisanUtils::getRunnableCommand(Player $player, string $command): string
Replaces placeholders in a command string with the player's information and trims leading whitespace.
| Placeholder | Replaced with |
|---|---|
{player} |
The player's name, wrapped in quotes if it contains spaces |
{x}, {y}, {z} |
The player's coordinates |
{world} |
The display name of the player's world |
$command = JisanUtils::getRunnableCommand($player, "tp {player} {x} {y} {z}");
JisanUtils::getIconPath(string $iconTextureName): string
Returns the texture path used by the forms: textures/icons/<name>.png.
JisanUtils::iconExists(string $iconTextureName): bool
Checks whether the file for that icon exists at the path returned by getIconPath().
Localization keys
Texts are resolved through JisanLanguages using these keys. If a key has no translation, the default text is used.
| Key | Used in | Default text |
|---|---|---|
forms.modal.confirmation.title |
ConfirmationForm |
§lConfirmacion |
forms.modal.success.title |
SuccessForm |
§lExito |
forms.modal.error.title |
ErrorForm |
§lError |
forms.modal.error.retry |
ErrorForm |
§l§aReintentar |
forms.modal.confirmation.yes |
MessageForm |
§l§aAceptar |
forms.modal.cancel |
MessageForm |
§l§cCancelar |
forms.menu.search |
ListForm |
§lBuscar |
forms.menu.back |
ListForm |
§l§cRegresar |
forms.menu.empty |
ListForm |
No hay elementos para mostrar. |
forms.search.placeholder |
SearchInputForm |
Ingrese su busqueda aqui |
Icons
ListForm uses two icons for its optional buttons. They are loaded by path from the resource pack the client has:
| Button | Texture path |
|---|---|
| Search | textures/icons/search.png |
| Back | textures/icons/back.png |
Add those two files to your server's resource pack to display the icons.
API overview
| Class | Namespace | Purpose |
|---|---|---|
JisanUtils |
rubenjisan\JisanUtils |
Static helpers: command placeholders and icon paths |
MessageForm |
forms\modal |
Base modal dialog with submit and cancel callbacks |
ConfirmationForm |
forms\modal |
Localized confirmation dialog |
SuccessForm |
forms\modal |
Localized success dialog |
ErrorForm |
forms\modal |
Localized error dialog with a retry button |
ListForm |
forms |
Menu form from an array, with optional search and back buttons |
SearchInputForm |
forms |
Text input form that returns a trimmed query |
All namespaces are under rubenjisan\JisanUtils\.
Project structure
JisanUtils/
├── composer.json
├── README.md
├── LICENSE.txt
└── src/rubenjisan/JisanUtils/
├── JisanUtils.php
└── forms/
├── ListForm.php
├── SearchInputForm.php
└── modal/
├── MessageForm.php
├── ConfirmationForm.php
├── SuccessForm.php
└── ErrorForm.php
Troubleshooting
| Symptom | Cause and fix |
|---|---|
Class "...\Lang" not found |
JisanLanguages isn't installed or wasn't embedded. Run composer install and build with Pharynx |
Class "dktapps\pmforms\..." not found |
pmforms isn't installed or wasn't embedded. Run composer install and build with Pharynx |
| Texts appear in Spanish | Those are the default fallbacks. Add the localization keys to your language files |
Icons don't show in ListForm |
The resource pack must include textures/icons/search.png and textures/icons/back.png |
| Nothing happens when the player closes a modal | Pass an $onCancel callback; without it, closing the form does nothing |
ListForm shows no Search or Back button |
The button is only added when $onSearch or $onBack is provided |
onSelect is not called |
The callback is only used when $onSelect is set and the clicked item exists in $items |
Author
Rubén Jiménez — Software Solutions Developer GitHub · LinkedIn
License
Licensed under the PolyForm Noncommercial License 1.0.0. You may use, copy and modify this library for noncommercial purposes only. Commercial use, including selling it, requires a separate license from the author.
Required Notice: Copyright (c) 2026 RubenJisan (https://github.com/RubenJisan)