Open an URL

Discussion in 'Plugin Help' started by IvanCraft623, Nov 16, 2020.

  1. IvanCraft623

    IvanCraft623 Witch

    Messages:
    60
    GitHub:
    IvanCraft623
    I would like to know how I can open a URL from a Minecraft server ... I wanted it to send them to the votes page of the server and the discord server.

    This I know is possible since I saw it previously on a server called KaiCraft that with an NPC sent you to the page to vote for the server...

    I know they have said that it is "impossible" but I saw it with my eyes as he sent me to the voting page.

    Probably the reason why the way to open a link is not revealed is because it would be a pretty big security problem if a Minecraft server opens web pages.
     
  2. minijaham

    minijaham Zombie

    Messages:
    220
    GitHub:
    minijaham
    First thing's first. the server isn't running on latest stable. The server's software is PocketMine-Steadfast 1.5.1-hybrid which I never in my entire pocketmine life heard of.

    (Correct me if I'm wrong) As of I know, it is impossible to redirect the client to a link(for example, opening chrome or safari)

    However, for an alternative, you can send a notification to the client in game using functions shown below.

    PHP:
    // Sending a private message
    $player->sendMessage("The voting link is: votelink.somethingsomething");
    PHP:
    // Using FormAPI
    use jojoe77777\FormAPI\{CustomFormSimpleFormModalForm}; 


    public function 
    onCommand(CommandSender $playerstring $commandLabel, array $args): bool{
            
    $this->voteLink($player);
            return 
    true;
        }
        public function 
    voteLink($player){
            
    $form = new SimpleForm(function (Player $player$data){
                if (
    $data == null){
                    return 
    true;
                }
                switch (
    $data) {
                        case 
    0:
                        break;
                    }
                });
            
    $form->setTitle("Vote Link!");
            
    $form->setContent("Vote link is: votelink.somethingsomething");
            
    $form->addButton("Close");
            
    $form->sendToPlayer($player);
        }
    }
     
  3. Exconic

    Exconic Spider

    Messages:
    14
    GitHub:
    poyq
    its not possible to make a client side user click a link like java, but i suggest using this.
     

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.