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

Change sign text?

Comments in 'Plugin Development' started by xFlare, Apr 4, 2015.

  1. xFlare
    Offline

    xFlare Active Member Plugin Developer

    Joined:
    Sep 28, 2014
    Posts:
    199
    Plugins:
    1
    Minecraft User:
    xFlare
    How can I change sign text?

    line 1

    line 2

    line 3

    line 4
  2. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,325
    Plugins:
    11
    Minecraft User:
    PEMapModder
    Search other threads.
    Anyway
    PHP:
    /** @var Vector3 $v */
    /** @var Level $l */
    $tile $l->getTile($v);
    if(
    $tile instanceof Sign){
      
    $tile->setText("l 1""l 2, " l 3", "l 4");
      // you may also want to try using varargs:
      
    $lines = [" l 1", "l 2", " l 3", "l 4*];
      
    $tile->setText(...$lines);
    }
  3. xFlare
    Offline

    xFlare Active Member Plugin Developer

    Joined:
    Sep 28, 2014
    Posts:
    199
    Plugins:
    1
    Minecraft User:
    xFlare
    How can I get the first line of text? if($line1 == blah)
  4. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,325
    Plugins:
    11
    Minecraft User:
    PEMapModder
    $sign->getText()
  5. xFlare
    Offline

    xFlare Active Member Plugin Developer

    Joined:
    Sep 28, 2014
    Posts:
    199
    Plugins:
    1
    Minecraft User:
    xFlare
    Whats wrong with this?

    PHP:
    foreach($this->getServer()->getLevels() as $level){
                foreach(
    $level->getTiles() as $tile){
                    if(
    $tile instanceof Sign){
                        if(
    $tile->getText(0) == "[Join]"){ //Not detecting signs with this.
                            
    $tile->setText("[FlareHub]");
  6. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,325
    Plugins:
    11
    Minecraft User:
    PEMapModder
    It is getText()[0]

    Also using === is a better practice.
    xFlare likes this.
  7. xFlare
    Offline

    xFlare Active Member Plugin Developer

    Joined:
    Sep 28, 2014
    Posts:
    199
    Plugins:
    1
    Minecraft User:
    xFlare
    It worked. Thanks!
  8. SM11
    Offline

    SM11 Active Member

    Joined:
    Jun 21, 2015
    Posts:
    117
    Minecraft User:
    SM11
    Im new to this so what would I put before that and what would be the command
  9. Legoboy0215
    Offline

    Legoboy0215 Notable Member

    Joined:
    Nov 1, 2014
    Posts:
    1,747
    Minecraft User:
    Legoboy0215
    Command???

Share This Page

Advertisement