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

Solved SignChangeEvent

Comments in 'Plugin Development' started by TheBison_, Dec 19, 2015.

  1. TheBison_
    Offline

    TheBison_ New Member

    Joined:
    Mar 31, 2014
    Posts:
    46
    Minecraft User:
    TheBisonXD_
    Hello guys,
    Why does this not work?

    public function onSignCreate(SignChangeEvent $event)
    {
    if ($event->getLine(0) == "QSG")
    {
    $event->setLine(0, TextFormat::GRAY . "[" . TextFormat::AQUA . "QSG" . TextFormat::GRAY . "]");
    $event->setLine(1, TextFormat::GREEN . "Loading...");
    $event->getPlayer()->sendMessage(TextFormat::AQUA . "Finish!");
    }
    }
  2. Tim // robske Büba
    Offline

    Tim // robske Büba Notable Member

    Joined:
    Feb 26, 2014
    Posts:
    606
    Minecraft User:
    robske_110
    Use
    PHP:
    public function onSignCreate(SignChangeEvent $event)
    {
      
    $sign $event->getLines();
      if(
    $sign[0]=='QSG')
    {
    //Your code
    }
    }
    TheBison_ likes this.
  3. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,294
    Plugins:
    11
    Minecraft User:
    PEMapModder
    Explain how it "not work"?
    $event->getLines[0] is same as $event->getLine(0).
    TheBison_ likes this.
  4. Bluplayz
    Offline

    Bluplayz Active Member

    Joined:
    Aug 20, 2015
    Posts:
    74
    Minecraft User:
    Bluplayz
    xD i think that you need to define Sign , or else try
    PHP:
    $event->getLines();
    TheBison_ likes this.
  5. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,294
    Plugins:
    11
    Minecraft User:
    PEMapModder
    $event->getLines() returns the $lines property in the SignChangeEvent class. And why does he need to define Sign? It isn't even used anywhere.
    cake23 and TheBison_ like this.
  6. TheBison_
    Offline

    TheBison_ New Member

    Joined:
    Mar 31, 2014
    Posts:
    46
    Minecraft User:
    TheBisonXD_
    The Sign doesnt change.
    Watch this Video:
  7. Tim // robske Büba
    Offline

    Tim // robske Büba Notable Member

    Joined:
    Feb 26, 2014
    Posts:
    606
    Minecraft User:
    robske_110
    PHP:
    public function tileupdate(SignChangeEvent $event){
    if(
    $event->getBlock()->getID() == 323 || $event->getBlock()->getID() == 63 || $event->getBlock()->getID() == 68){Server::getInstance()->broadcastMessage("DebugASignHasBeenPlaced"); //DEBUG$sign = $event->getPlayer()->getLevel()->getTile($event->getBlock());
    if(!($sign instanceof Sign)){
    return 
    true;
    }
    $sign $event->getLines();
    if(
    $sign[0]=='[QSG]')
    {
    $event->setLine(0TextFormat::GRAY "[" TextFormat::AQUA "QSG" TextFormat::GRAY "]");
    $event->setLine(1TextFormat::GREEN "Loading...");
    $event->getPlayer()->sendMessage(TextFormat::AQUA "Finished!");
    }
    TheBison_ likes this.
  8. Bluplayz
    Offline

    Bluplayz Active Member

    Joined:
    Aug 20, 2015
    Posts:
    74
    Minecraft User:
    Bluplayz
    I See that you dont implements the Listener ^^ tutorial can you watch morning
    TheBison_ likes this.
  9. TheBison_
    Offline

    TheBison_ New Member

    Joined:
    Mar 31, 2014
    Posts:
    46
    Minecraft User:
    TheBisonXD_
    Thanks i have forgot "$this->getServer()->getPluginManager()->registerEvents($this, $this);" in onEnable.... :D
    cake23 likes this.
  10. Tim // robske Büba
    Offline

    Tim // robske Büba Notable Member

    Joined:
    Feb 26, 2014
    Posts:
    606
    Minecraft User:
    robske_110
    Oh, I just programmed an example for that:

    Attached Files:

    TheBison_ likes this.
  11. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,294
    Plugins:
    11
    Minecraft User:
    PEMapModder
    Cough, for the {PHP_INT_MAX}'th time, how can a block ID be 323?
  12. Legoboy0215
    Offline

    Legoboy0215 Notable Member

    Joined:
    Nov 1, 2014
    Posts:
    1,724
    Minecraft User:
    Legoboy0215
    In addition, I believe 'Sign'ChangeEvent only returns signs.
  13. Tim // robske Büba
    Offline

    Tim // robske Büba Notable Member

    Joined:
    Feb 26, 2014
    Posts:
    606
    Minecraft User:
    robske_110
    It works and whats wrong with id 323?
  14. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,294
    Plugins:
    11
    Minecraft User:
    PEMapModder
    Because you don't need to check. It must be a sign.
  15. JackboyPlay
    Offline

    JackboyPlay Active Member

    Joined:
    Apr 25, 2015
    Posts:
    507
    Minecraft User:
    JackboyPlay
    @TheBison_ he want Clicks for his YouTuber Video :O
  16. AndrewBit
    Offline

    AndrewBit Notable Member

    Joined:
    Jun 18, 2015
    Posts:
    435
    Minecraft User:
    AndrewBit4
    323 is a item, not a block
  17. AndrewBit
    Offline

    AndrewBit Notable Member

    Joined:
    Jun 18, 2015
    Posts:
    435
    Minecraft User:
    AndrewBit4
    1. You don't need to check if it's a sign, remember, you're using SignChangeEvent.
    2. Is a bad practice use getLines(), and also is easyer use $event->getLine(0) on your if...
  18. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,294
    Plugins:
    11
    Minecraft User:
    PEMapModder
    It's not a bad practice, but less convenient.

Share This Page

Advertisement