1. The forums will be archived and moved to a read only mode in about 2 weeks (mid march).

Get the text on placing a sign

Discussion in 'Development' started by Palente, Jan 13, 2018.

  1. Palente

    Palente Slime

    Messages:
    75
    GitHub:
    palente
    Hey, i want to know how to get the Text on the sign when he is placed.
    I have tried By getting the id and checking tiles but don't work and i tried by using
    Signchangeevent but that dont work correctly.
    What i want:
    When a player place a sign to get the text and to check if he is op, if he isn't op break the sign.
    I just want to know the event not the plugin i don't see how to do it
     
  2. HBIDamian

    HBIDamian HBIDamian Staff Member

    Messages:
    365
    GitHub:
    HBIDamian
    you can do it with /give. :D

    Code:
    /give Your_Name sign 1 {display:{Name:"§6§lPLACE ME!"},BlockEntityTag:{Text1:"CUSTOM TEXT",Text2:"lol",Text3:"can I have",Text4:"a like, please?"}}
    
    More information at:
    Code:
    https://gist.github.com/shoghicp/7a48c811a55b2a984b82#default-sign-text 
     
  3. Palente

    Palente Slime

    Messages:
    75
    GitHub:
    palente
    okay thanks..
    but i want a event
    an event like BlockPlaceEvent but i want to get the tile of the sign and get the text
     
  4. Kyd

    Kyd Zombie Pigman

    Messages:
    678
    GitHub:
    boi1216
    PHP:
    public function onBreak(\pocketmine\event\block\BlockBreakEvent $e){
           
    $b $e->getBlock();
           
    $p $e->getPlayer();
           
    $tile $b->getLevel()->getTile($b);
           if(
    $tile instanceof \pocketmine\tile\Chest){
                  
    $text $tile->getText();
                   if(!
    $p->isOp()){
                       
    $b->getLevel()->setBlockIdAt($b0);
                   }
           }
    }
     
  5. Palente

    Palente Slime

    Messages:
    75
    GitHub:
    palente
    okay so i didnt mean exactly what i want no problem
    i retry to explain what i want.
    I want to get The text of a sign when a player place that sign
    i tried
    PHP:
    public function Changesign(SignChangeEvent $event){
        
    $player$event->getPlayer();
        if(
    $event->getLine(0)=="[KITADMIN]"){
            
    $text$event->getLines();
        if(!
    $player->isOp()){
            return 
    $event->setCancelled(true);
    //here i want to cancel the event or just set the block like kyd said
        
    }
     
  6. Kyd

    Kyd Zombie Pigman

    Messages:
    678
    GitHub:
    boi1216
    With code that I proved you can get it.. $text variable is string with the text and now you can only compare it with string
     
  7. Palente

    Palente Slime

    Messages:
    75
    GitHub:
    palente
    That work on the EventOnPlace?
    Because i want to get the text when the sign is placed
     
  8. Kyd

    Kyd Zombie Pigman

    Messages:
    678
    GitHub:
    boi1216
    If you are setting the text in same time when sign is placed, then it will work.. But if you are editing the sign after you place then use SignChangeEvent
     
  9. kenygamer

    kenygamer Banned Banned

    Messages:
    106
    GitHub:
    kenygamer
    SignChangeEvent does not return anything.
    Change to

    PHP:
    $event->setCancelled(true);
    return;
     
  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.