Skip to content

Plugin for pmmp that allow you create GUI in a few clicks.

License

Notifications You must be signed in to change notification settings

SkyLightMCPE/EasyForms

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

28 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

EasyForms

Plugin for pmmp that allow you create GUI in a few clicks.

Code samples

ModalForm

EasyForms::sendForm($sender, new class("A small question", "Our server is cool?") extends ModalForm{
	public function onSubmit(Player $player, $response) : void{
		$player->sendMessage($response ? "Thank you" : "We will try to become better");
	}
});

modal

MenuForm

EasyForms::sendForm($sender, new class("Select server", "Choose server", [
	new Button("SkyWars #1", "https://d1u5p3l4wpay3k.cloudfront.net/minecraft_gamepedia/1/19/Melon.png")
]) extends MenuForm{
	public function onSubmit(Player $player, $response) : void{
		parent::onSubmit($player, $response);
		$player->sendMessage("You selected: " . $this->buttons[$response]->getText());
	}
});

menu

CustomForm

EasyForms::sendForm($sender, new class("Enter data", [
	new Dropdown("Select product", ["beer", "cheese", "cola"]),
	new Input("Enter your name", "Bob"),
	new Label("I am label!"), //popElement() does not work with label
	new Slider("Select count", 0.0, 100.0, 1.0, 50.0),
	new StepSlider("Select product", ["beer", "cheese", "cola"]),
	new Toggle("Creative", $sender->isCreative())
]) extends CustomForm{
	public function onSubmit(Player $player, $response) : void{
		parent::onSubmit($player, $response);
		/** @var Dropdown $dropdown */
		$dropdown = $this->popElement();
		$player->sendMessage("You selected: {$dropdown->getSelectedOption()}");

		/** @var Input $input */
		$input = $this->popElement();
		$player->sendMessage("Your name is {$input->getValue()}");

		/** @var Slider $slider */
		$slider = $this->popElement();
		$player->sendMessage("Count: {$slider->getValue()}");

		/** @var StepSlider $stepSlider */
		$stepSlider = $this->popElement();
		$player->sendMessage("You selected: {$stepSlider->getSelectedOption()}");

		/** @var Toggle $toggle */
		$toggle = $this->popElement();
		$player->setGamemode($toggle->getValue() ? 1 : 0);
	}
});

custom1 custom2

ServerSettingsForm

public function onServerSettingsRequest(ServerSettingsRequestEvent $e) : void{
	$player = $e->getPlayer();
	EasyForms::sendForm($player, new class("Server settings", [
		new Label("Some text"),
		new Toggle("Fly", $player->isFlying())
	], "http://icons.iconarchive.com/icons/double-j-design/diagram-free/128/settings-icon.png") extends ServerSettingsForm{
		public function onSubmit(Player $player, $response) : void{
			parent::onSubmit($player, $response);
			/** @var Toggle $toggle */
			$toggle = $this->popElement();
			$player->setAllowFlight((bool) $toggle->getValue());
		}
	});
}

settings

About

Plugin for pmmp that allow you create GUI in a few clicks.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • PHP 100.0%