Advertisement
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Check the text on a sign?

Comments in 'Plugin Development' started by Hotshot_9930, Oct 5, 2015.

  1. Hotshot_9930
    Offline

    Hotshot_9930 Notable Member Plugin Developer

    Joined:
    May 26, 2014
    Posts:
    665
    Plugins:
    2
    Minecraft User:
    HotshotHD
    Let's say i wanted to send a player a message when they interact with a sign that has the world "Hello" on a specific line. How would i go about doing that?
  2. Gamecrafter
    Offline

    Gamecrafter

    Joined:
    Nov 20, 2014
    Posts:
    978
    Plugins:
    9
    Here's how:
    PHP:
    public function onTouch(PlayerInteractEvent $event){
        
    $tile $event->getPlayer()->getLevel()->getTile($event->getBlock());
        if(
    $tile instanceof \pocketmine\tile\Sign){
            if(
    $tile->getText()[0] === "Hello"){
                
    //code here
            
    }
        }
    }
    AppPhil and CraftYourBukkit like this.

Share This Page

Advertisement