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
you can do it with /give. 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
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
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($b, 0); } }}
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 }
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
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