refactor to api 3.0.0
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
name: FormConstructor
|
||||
version: 1.0.0
|
||||
api: 5.0.0
|
||||
api: 3.0.0
|
||||
author: MEFRREEX
|
||||
description: Library for easy creating and handling of forms
|
||||
main: com\formconstructor\FormConstructor
|
||||
@@ -4,11 +4,10 @@ namespace com\formconstructor\event;
|
||||
|
||||
use com\formconstructor\form\Form;
|
||||
use pocketmine\event\Cancellable;
|
||||
use pocketmine\event\CancellableTrait;
|
||||
|
||||
use pocketmine\event\Event;
|
||||
|
||||
abstract class FormEvent extends Event implements Cancellable {
|
||||
use CancellableTrait;
|
||||
|
||||
private Form $form;
|
||||
|
||||
|
||||
@@ -3,7 +3,8 @@
|
||||
namespace com\formconstructor\event;
|
||||
|
||||
use com\formconstructor\form\Form;
|
||||
use pocketmine\player\Player;
|
||||
use pocketmine\Player;
|
||||
|
||||
|
||||
class PlayerFormCloseEvent extends FormEvent {
|
||||
|
||||
|
||||
@@ -3,7 +3,8 @@
|
||||
namespace com\formconstructor\event;
|
||||
|
||||
use com\formconstructor\form\Form;
|
||||
use pocketmine\player\Player;
|
||||
use pocketmine\Player;
|
||||
|
||||
|
||||
class PlayerFormSendEvent extends FormEvent {
|
||||
|
||||
|
||||
@@ -8,7 +8,7 @@ use com\formconstructor\form\element\custom\Label;
|
||||
use com\formconstructor\form\element\custom\validator\IValidator;
|
||||
use com\formconstructor\form\response\CustomFormResponse;
|
||||
use com\formconstructor\form\response\FormResponse;
|
||||
use pocketmine\player\Player;
|
||||
use pocketmine\Player;
|
||||
|
||||
class CustomForm extends CloseableForm {
|
||||
|
||||
|
||||
@@ -2,24 +2,25 @@
|
||||
|
||||
namespace com\formconstructor\form;
|
||||
|
||||
use pocketmine\player\Player;
|
||||
use pocketmine\Server;
|
||||
use pocketmine\form\Form as PMForm;
|
||||
use com\formconstructor\event\PlayerFormSendEvent;
|
||||
use com\formconstructor\task\FormHandlingTask;
|
||||
use com\formconstructor\form\response\FormResponse;
|
||||
use pocketmine\thread\NonThreadSafeValue;
|
||||
use com\formconstructor\task\FormHandlingTask;
|
||||
use pocketmine\form\Form as PMForm;
|
||||
use pocketmine\Player;
|
||||
|
||||
abstract class Form implements PMForm {
|
||||
abstract class Form implements PMForm
|
||||
{
|
||||
|
||||
private FormType $type;
|
||||
private bool $async;
|
||||
|
||||
public function __construct(FormType $type) {
|
||||
public function __construct(FormType $type)
|
||||
{
|
||||
$this->type = $type;
|
||||
}
|
||||
|
||||
public function send(Player $player, bool $async = false): void {
|
||||
public function send(Player $player, bool $async = false): void
|
||||
{
|
||||
$event = new PlayerFormSendEvent($player, $this, $async);
|
||||
$event->call();
|
||||
|
||||
@@ -29,15 +30,18 @@ abstract class Form implements PMForm {
|
||||
}
|
||||
}
|
||||
|
||||
public function sendAsync(Player $player) {
|
||||
public function sendAsync(Player $player)
|
||||
{
|
||||
$this->send($player, true);
|
||||
}
|
||||
|
||||
public function getType(): FormType {
|
||||
public function getType(): FormType
|
||||
{
|
||||
return $this->type;
|
||||
}
|
||||
|
||||
public function isAsync(): bool {
|
||||
public function isAsync(): bool
|
||||
{
|
||||
return $this->async;
|
||||
}
|
||||
|
||||
@@ -45,7 +49,8 @@ abstract class Form implements PMForm {
|
||||
|
||||
public abstract function getResponse(): ?FormResponse;
|
||||
|
||||
public final function handleResponse(Player $player, $data): void {
|
||||
public final function handleResponse(Player $player, $data): void
|
||||
{
|
||||
$this->setResponse($data);
|
||||
|
||||
$handler = new FormHandlingTask($this->getResponse(), $this, $player);
|
||||
|
||||
@@ -13,7 +13,8 @@ use com\formconstructor\form\element\custom\StepSlider;
|
||||
use com\formconstructor\form\element\custom\Toggle;
|
||||
use com\formconstructor\form\element\custom\validator\IValidator;
|
||||
use com\formconstructor\form\element\ElementType;
|
||||
use pocketmine\player\Player;
|
||||
use pocketmine\Player;
|
||||
|
||||
|
||||
class CustomFormResponse extends FormResponse {
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
namespace com\formconstructor\form\response;
|
||||
|
||||
use Closure;
|
||||
use pocketmine\player\Player;
|
||||
use pocketmine\Player;
|
||||
|
||||
abstract class FormResponse {
|
||||
|
||||
|
||||
@@ -3,7 +3,8 @@
|
||||
namespace com\formconstructor\form\response;
|
||||
|
||||
use Closure;
|
||||
use pocketmine\player\Player;
|
||||
use pocketmine\Player;
|
||||
|
||||
|
||||
class ModalFormResponse extends FormResponse {
|
||||
|
||||
|
||||
@@ -2,8 +2,9 @@
|
||||
|
||||
namespace com\formconstructor\form\response;
|
||||
|
||||
use pocketmine\player\Player;
|
||||
|
||||
use com\formconstructor\form\element\simple\Button;
|
||||
use pocketmine\Player;
|
||||
|
||||
class SimpleFormResponse extends FormResponse {
|
||||
|
||||
|
||||
@@ -9,7 +9,7 @@ use com\formconstructor\form\response\CustomFormResponse;
|
||||
use com\formconstructor\form\response\FormResponse;
|
||||
use com\formconstructor\form\response\ModalFormResponse;
|
||||
use com\formconstructor\form\response\SimpleFormResponse;
|
||||
use pocketmine\player\Player;
|
||||
use pocketmine\Player;
|
||||
|
||||
// TODO async handing
|
||||
class FormHandlingTask {
|
||||
|
||||
Reference in New Issue
Block a user