Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public function onInteract(PlayerInteractEvent $event): void {
- if(($event->getAction() === PlayerInteractEvent::RIGHT_CLICK_AIR or $event->getAction() === PlayerInteractEvent::RIGHT_CLICK_BLOCK) and in_array($event->getPlayer()->getLevel()->getFolderName(), $this->getConfig()->get("worlds")) and $event->getItem()->getId() === Item::COMPASS){
- $form = $this->getFormAPI()->createSimpleForm(function(Player $player, $sel){
- if($sel === null) return;
- $button = $this->getConfig()->get("buttons");
- $player->teleport($this->getServer()->getLevelByName($button[$sel]["level"])->getSpawnLocation());
- });
- $form->setTitle($this->getConfig()->get("title"));
- $form->setContent($this->getConfig()->get("content"));
- foreach($this->getConfig()->get("buttons") as $button){
- $button["hasimage"] ? $form->addButton($button["text"], $button["imagetype"] === "url" ? 1 : 0, $button["path"]) : $form->addButton($button["text"]);
- }
- $form->sendToPlayer($event->getPlayer());
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement