Giter VIP home page Giter VIP logo

easyforms's Introduction

EasyForms

⚠️ Deprecated! If you're looking for good PM4 forms API consider new forms library with PHP 8.0+ support and phpstan integration

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

Code samples

ModalForm

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

modal

MenuForm

$sender->sendForm(new MenuForm(
	"Select server", "Choose server", [new Button("SkyWars #1", new Image("https://gamepedia.cursecdn.com/minecraft_gamepedia/1/19/Melon.png"))],
	function(Player $player, Button $selected) : void{
		$player->sendMessage("You selected: " . $selected->getText());
		$player->sendMessage("Index of button: " . $selected->getValue());
	}
));

menu

CustomForm

$sender->sendForm(new CustomForm("Enter data",
	[
		new Dropdown("Select product", ["beer", "cheese", "cola"]),
		new Input("Enter your name", "Bob"),
		new Label("I am label!"), //Note: get<Element>() 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())
	],
	function(Player $player, CustomFormResponse $response) : void{
		$dropdown = $response->getDropdown();
		$player->sendMessage("You selected: {$dropdown->getSelectedOption()}");

		$input = $response->getInput();
		$player->sendMessage("Your name is {$input->getValue()}");

		$slider = $response->getSlider();
		$player->sendMessage("Count: {$slider->getValue()}");

		$stepSlider = $response->getStepSlider();
		$player->sendMessage("You selected: {$stepSlider->getSelectedOption()}");

		$toggle = $response->getToggle();
		$player->setGamemode($toggle->getValue() ? GameMode::CREATIVE() : GameMode::SURVIVAL());
	}
));

CustomForm with getValues() method

$sender->sendForm(new CustomForm("Enter data",
	[
		new Dropdown("Select product", ["beer", "cheese", "cola"]),
		new Input("Enter your name", "Bob"),
		new Label("I am label!"), //Also ignored by getValues()
		new Slider("Select count", 0.0, 100.0, 1.0, 50.0),
		new StepSlider("Select product", ["beer", "cheese", "cola"]),
		new Toggle("Creative", $sender->isCreative())
	],
	function(Player $player, CustomFormResponse $response) : void{
		list($product1, $username, $count, $product2, $enableCreative) = $response->getValues();
		$player->sendMessage("You selected: $product1");
		$player->sendMessage("Your name is $username");
		$player->sendMessage("Count: $count");
		$player->sendMessage("You selected: $product2");
		$player->setGamemode($enableCreative ? GameMode::CREATIVE() : GameMode::SURVIVAL());
	}
));

custom1 custom2

ServerSettingsForm

public function onServerSettingsRequest(ServerSettingsRequestEvent $e) : void{
	$player = $e->getPlayer();
	$e->setForm(new ServerSettingsForm("Server settings",
			[
				new Label("Some text"),
				new Toggle("Enable something", $player->isFlying())
			],
			new Image("http://icons.iconarchive.com/icons/double-j-design/diagram-free/128/settings-icon.png"),
			function(Player $player, CustomFormResponse $response) : void{
				$player->sendMessage($response->getToggle()->getValue() ? "enabled" : "disabled");
			}
		)
	);
}

settings

easyforms's People

Contributors

artulloss avatar frago9876543210 avatar poggit-bot avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

easyforms's Issues

Optimize plugin if you want to be better!

Optimise this plugin if you want be better.

And don't use 10000 functions for a useless code. If you want do good things, re-make this plugin and make them better

Kiss frago <3

Crash when click Settings

Hey there,
this is the error after I clicked the Settings button dare to crash "Internal Server Error".

Here's the error
[12:10:49] [Server thread/CRITICAL]: Error: "Call to undefined method pocketmine\event\server\DataPacketReceiveEvent::getOrigin()" (EXCEPTION) in "plugins/EasyForms_v1.5.0/src/Frago9876543210/EasyForms/EasyForms" at line 47 [12:10:49] [Server thread/DEBUG]: #0 src/pocketmine/plugin/MethodEventExecutor(42): Frago9876543210\EasyForms\EasyForms->onDataPacketReceive(object pocketmine\event\server\DataPacketReceiveEvent) [12:10:49] [Server thread/DEBUG]: #1 src/pocketmine/plugin/RegisteredListener(80): pocketmine\plugin\MethodEventExecutor->execute(object Frago9876543210\EasyForms\EasyForms, object pocketmine\event\server\DataPacketReceiveEvent) [12:10:49] [Server thread/DEBUG]: #2 src/pocketmine/event/Event(88): pocketmine\plugin\RegisteredListener->callEvent(object pocketmine\event\server\DataPacketReceiveEvent) [12:10:49] [Server thread/DEBUG]: #3 src/pocketmine/network/mcpe/PlayerNetworkSessionAdapter(109): pocketmine\event\Event->call() [12:10:49] [Server thread/DEBUG]: #4 src/pocketmine/network/mcpe/protocol/BatchPacket(127): pocketmine\network\mcpe\PlayerNetworkSessionAdapter->handleDataPacket(object pocketmine\network\mcpe\protocol\ServerSettingsRequestPacket) [12:10:49] [Server thread/DEBUG]: #5 src/pocketmine/network/mcpe/PlayerNetworkSessionAdapter(110): pocketmine\network\mcpe\protocol\BatchPacket->handle(object pocketmine\network\mcpe\PlayerNetworkSessionAdapter) [12:10:49] [Server thread/DEBUG]: #6 src/pocketmine/Player(3096): pocketmine\network\mcpe\PlayerNetworkSessionAdapter->handleDataPacket(object pocketmine\network\mcpe\protocol\BatchPacket) [12:10:49] [Server thread/DEBUG]: #7 src/pocketmine/network/mcpe/RakLibInterface(169): pocketmine\Player->handleDataPacket(object pocketmine\network\mcpe\protocol\BatchPacket) [12:10:49] [Server thread/DEBUG]: #8 vendor/pocketmine/raklib/src/server/ServerHandler(99): pocketmine\network\mcpe\RakLibInterface->handleEncapsulated(string[19] 192.168.0.103 42633, object raklib\protocol\EncapsulatedPacket, integer 0) [12:10:49] [Server thread/DEBUG]: #9 src/pocketmine/network/mcpe/RakLibInterface(109): raklib\server\ServerHandler->handlePacket() [12:10:49] [Server thread/DEBUG]: #10 src/pocketmine/network/mcpe/RakLibInterface(99): pocketmine\network\mcpe\RakLibInterface->process() [12:10:49] [Server thread/DEBUG]: #11 vendor/pocketmine/snooze/src/SleeperHandler(123): pocketmine\network\mcpe\RakLibInterface->pocketmine\network\mcpe\{closure}() [12:10:49] [Server thread/DEBUG]: #12 vendor/pocketmine/snooze/src/SleeperHandler(85): pocketmine\snooze\SleeperHandler->processNotifications() [12:10:49] [Server thread/DEBUG]: #13 src/pocketmine/Server(2146): pocketmine\snooze\SleeperHandler->sleepUntil(double 1585656649.7095) [12:10:49] [Server thread/DEBUG]: #14 src/pocketmine/Server(1990): pocketmine\Server->tickProcessor() [12:10:49] [Server thread/DEBUG]: #15 src/pocketmine/Server(1584): pocketmine\Server->start() [12:10:49] [Server thread/DEBUG]: #16 src/pocketmine/PocketMine(273): pocketmine\Server->__construct(object BaseClassLoader, object pocketmine\utils\MainLogger, string[34] /storage/emulated/0/PocketMine-MP/, string[42] /storage/emulated/0/PocketMine-MP/plugins/) [12:10:49] [Server thread/DEBUG]: #17 src/pocketmine/PocketMine(296): pocketmine\server() [12:10:49] [Server thread/DEBUG]: #18 (11): require(string[89] phar:///storage/emulated/0/PocketMine-MP/PocketMine-MP.phar/src/pocketmine/Pocke)

Null

Error: "Call to a member function get() on null" (EXCEPTION) in "PluginForms/src/Forms/API/EasyForms" at line 47

I moved this plugin into my plugin as library, but this error occured
what is the matter?

check if player has permission?

i made a MenuForm and i want to send green "Fly" if the player has permission and red if not.
but i cant add if statements

How to use?

Hello, I have some questions:

  1. in which file path do I have to save a new function?
  2. how can I trigger a function via command e.g. /warp and it opens a menu where I can select a warp
    Please give me a full example.

new class?

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"); } });
new class as my class name or what?

HELP ME

HOW DO I USE THAT IN MY PLUGINS?

How to make multiple buttons in MenuForm?

Hi there,
I finally figured out how does it work.
I am confusing how to make multiple buttons in Menu Form.
It means "A" button will sendMessage("Hello") ; "B" button will sendMessage("Hi")

I know how to make "two" buttons.
but the two button are showing same message.

Does it possible to implement it?

Thanks a lot.

Need Improvements

How to send the response to a specified api for example i am creating a form for voting of candidates for minecraft government? and the users will vote for the election.

Special Symbols missing

$a = 1111;
$b = 2222;
$c = 3333;
$d = 4444;
EasyForms::sendForm($player, new class("Test", "Test for me.\n\n" . 
        "Your Name : " . $a . "-" . $b . "-" . $c . "-" . $d . "\n\n" . 
        "If right Click [Y], or [N].\nSry for my bad eng.", "y", "n") extends ModalForm{
              public function onSubmit(Player $player, $response) : void{
                     if(!$response){
                        $player->sendMessage("§8[ §7§lAlert §r§8] §rThx.");
                        return;
                     }
                     $player->sendMessage("§8[ §7§lAlert §r§8] §rThx2"); 
              }
});

I expected the following.

Test for me.

Your Name : 1111-2222-3333-4444

If right Click [Y], or [N].
Sry for my bad eng.

But this is what we actually received.

Test for me.

Your Name

If right Click Y, or N.
Sry for my bad eng.

Where did the following characters disappear?

[ ] : -

sorry for my bad eng 👍

Playars name in drop down

How do i add each player to drop down

        foreach(Ban::getInstance()->getServer()->getOnlinePlayers() as $online){
            $name .=   $online->getName();
        }
            EasyForms::sendForm($player, new class("Ban", [
                new Dropdown("Players", ["{$name}"],0),```

What class to call?

Heyo!

Just help others and myself understand on how to implement this could you add the classes that need to be called, does anything need to be registered, and does it work as a virion?

Thanks!

Custom settings API

how would I check to see if a player has perm to toggle on and off "fly" in custom settings

error

[Server thread/CRITICAL]: ErrorException: "Declaration of class@anonymous::onSubmit(CastiaCore\events\Player $player, $response): void should be compatible with Frago9876543210\EasyForms\forms\CustomForm::onSubmit(pocketmine\Player $player, $response): void" (EXCEPTION) in "CastiaCore/src/CastiaCore/events/EventListener" at line 133

error

code:
public function sendInfo(ExonPlayer $player): void{
EasyForm::sendForm($player, new class(C::YELLOW . "---==>" . C::AQUA . $player->getName() . "'s Infomation" . C::YELLOW . "<==---", "", [
new Label(C::LIGHT_PURPLE . "Rank: " . C::GREEN . $player->getRank($player)),
new Label(C::LIGHT_PURPLE . "Title: " . C::GREEN . $player->getTitle($player)),
new Label(C::LIGHT_PURPLE . "Coins: " . C::GREEN . $player->getCoin($player))
]) extends CustomForm{
});
}

error:
Unhandled exception executing command 'info' in info: Argument 2 passed to form\forms\CustomForm::__construct() must be of the type array, string given, called in C:\Users\xxnic\OneDrive\Desktop\Server\plugins\ExonPECore-master\src\ExonCore\commands\InfoCommand.php on line 40
[16:27:53] [Server thread/CRITICAL]: TypeError: "Argument 2 passed to form\forms\CustomForm::__construct() must be of the type array, string given, called in C:\Users\xxnic\OneDrive\Desktop\Server\plugins\ExonPECore-master\src\ExonCore\commands\InfoCommand.php on line 40" (EXCEPTION) in "EasyForms-master/src/form/forms/CustomForm" at line 27

error

code:
public function sendInfo(ExonPlayer $player): void{
EasyForm::sendForm($player, new class(C::YELLOW . "---==>" . C::AQUA . $player->getName() . "'s Infomation" . C::YELLOW . "<==---", "", [
new Label(C::LIGHT_PURPLE . "Rank: " . C::GREEN . $player->getRank($player)),
new Label(C::LIGHT_PURPLE . "Title: " . C::GREEN . $player->getTitle($player)),
new Label(C::LIGHT_PURPLE . "Coins: " . C::GREEN . $player->getCoin($player))
]) extends CustomForm{
});
}

error:
Unhandled exception executing command 'info' in info: Argument 2 passed to form\forms\CustomForm::__construct() must be of the type array, string given, called in C:\Users\xxnic\OneDrive\Desktop\Server\plugins\ExonPECore-master\src\ExonCore\commands\InfoCommand.php on line 40
[16:27:53] [Server thread/CRITICAL]: TypeError: "Argument 2 passed to form\forms\CustomForm::__construct() must be of the type array, string given, called in C:\Users\xxnic\OneDrive\Desktop\Server\plugins\ExonPECore-master\src\ExonCore\commands\InfoCommand.php on line 40" (EXCEPTION) in "EasyForms-master/src/form/forms/CustomForm" at line 27

Изображения с сервера

Есть ли возможность подгружать иконки с сервера, а не по ссылке... Не знаю, с чем связано, но по ссылке что-то долго грузятся иконки

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.