dresnite/easyui 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

dresnite/easyui

Composer 安装命令:

composer require dresnite/easyui

包简介

EasyUI is an intuitive and easy-to-use form library for PocketMine-MP. Designed to let you focus on your project and not on how the library works.

README 文档

README

EasyUI is an intuitive and easy-to-use form library for PocketMine-MP. Designed to let you focus on your project and not on how the library works.

Download

You can download the virion in Poggit.

Code examples

General rules

All the closures passed to EasyUI classes must declare a variable of the class Player as first and only argument, except for the CustomForm submit listener, which also requires FormResponse as second parameter.

SimpleForm

Creating a form with a button without an icon:

$form = new SimpleForm("This is the title");
$form->addButton(new Button("Say hi", null, function(Player $player) {
    $player->sendMessage("Hello!");
}));
$player->sendForm($form);

Creating a form with a button with an icon:

$form = new SimpleForm("This is the title");
$form->addButton(new Button("Press me!", new ButtonIcon("https://introduce-the-image-url.here"), function(Player $player) {
    $player->sendMessage("Hey! Thanks for pressing me :)");
}));
$player->sendForm($form);

Creating a form with a header text (optional):

new SimpleForm("This is the title", "This is the header text");

Controlling what happens when a form closes (optional):

$form->setCloseListener(function(Player $player) {
    echo "The form was closed!";
})

ModalForm

Creating a modal form and handling what happens when the player presses "accept" or "deny":

$form = new ModalForm("The title goes here!", "Do you want this plugin to save you a lot of time?");
$form->setAcceptListener(function(Player $player) {
    $player->sendMessage("Great! Keep building good software");
});

$form->setDenyListener(function(Player $player) {
    $player->sendMessage("Whatever :/");
});

You can also change the text of the buttons:

$form->setAcceptText("Yes");
$form->setDenyText("Yesn't");

CustomForm

Creating a custom form with an input and a dropdown

$form = new CustomForm("This is the title!");
$form->addElement("my_text", new Input("This is the input header text!"));

$dropdown = new Dropdown("This is the dropdown header text");
$dropdown->addOption(new Option("broadcast", "Broadcast message"));
$dropdown->addOption(new Option("send_to_myself", "Send message to myself"));

$form->addElement("what_to_do", $dropdown);

$form->setSubmitListener(function(Player $player, FormResponse $response) {
    $submittedText = $response->getInputSubmittedText("my_text");
    $submittedOption = $response->getDropdownSubmittedOptionId("what_to_do");
    if($submittedOption === "send_to_myself") {
        $player->sendMessage($submittedText);
    } elseif($submittedOption === "broadcast") {
        foreach($player->getServer()->getOnlinePlayers() as $onlinePlayer) {
            $onlinePlayer->sendMessage("[BROADCAST] $submittedText");
        }
    }
});

Object oriented approach

In some cases, the forms are huge and mess up the code. In those cases, you can use a more object oriented approach to keep the code as clean as possible.

SimpleForm

class ExampleForm extends SimpleForm {

    public function __construct() {
        parent::__construct("Form title");
    }

    protected function onCreation(): void {
        $button = new Button("A very very big button");
        $button->setIcon(new ButtonIcon("https://a-cool-url.i.think"));
        $button->setSubmitListener(function(Player $player) {
            $player->sendMessage("Making this form was so easy!");
        });
        $this->addButton($button);
    }

}

ModalForm

class ExampleForm extends ModalForm {
    
    public function __construct() {
        parent::__construct("The title", "The content text");
    }

    protected function onAccept(Player $player): void {
        $player->sendMessage("You pressed 'Accept' <3");
    }

    protected function onDeny(Player $player): void {
        $player->sendMessage("You pressed 'Deny' >:(");
    }

}

NOTE: onCreation() is also available on ModalForms.

CustomForm

class ExampleForm extends CustomForm {

    public function __construct() {
        parent::__construct("The title goes here");
    }

    public function onCreation(): void {
        // You can add the elements here
    }

    public function onSubmit(Player $player, FormResponse $response): void {
        // You can modify the response here
    }


}

Then you can send the forms as you normally would with:

$player->sendForm(new ExampleForm());

统计信息

  • 总下载量: 516
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 29
  • 点击次数: 3
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 29
  • Watchers: 0
  • Forks: 18
  • 开发语言: PHP

其他信息

  • 授权协议: LGPL-3.0
  • 更新时间: 2026-02-17

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固