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

How to get a sign's position

Comments in 'Plugin Development' started by RekkuzaRage, May 21, 2015.

  1. RekkuzaRage
    Offline

    RekkuzaRage Active Member

    Joined:
    Apr 15, 2014
    Posts:
    251
    Minecraft User:
    RekkuzaRage
    How do I get a sign's position and save it to a config file?
  2. xiaoq
    Offline

    xiaoq Active Member

    Joined:
    Dec 23, 2014
    Posts:
    232
    Minecraft User:
    xiaoq
    Do you mean player place a sign?
  3. RekkuzaRage
    Offline

    RekkuzaRage Active Member

    Joined:
    Apr 15, 2014
    Posts:
    251
    Minecraft User:
    RekkuzaRage
    No, I am trying to create a shop sign plugin for my server to use with my custom economy plugin, but I am not sure how to get a sign's position/coords.
  4. CraftYourBukkit
    Offline

    CraftYourBukkit Notable Member Plugin Developer

    Joined:
    Jan 20, 2015
    Posts:
    1,022
    Plugins:
    2
    Minecraft User:
    CraftYourBukkit
    When do you want to save it?(Event)
  5. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,294
    Plugins:
    11
    Minecraft User:
    PEMapModder
    PHP:
    /** @var \pocketmine\tile\Sign $sign */
    $x $sign->getX();
    $y $sign->getY();
    $z $sign->getZ();
    $config->set($pathToYourEntry, [$x$y$z]);
    RekkuzaRage likes this.
  6. RekkuzaRage
    Offline

    RekkuzaRage Active Member

    Joined:
    Apr 15, 2014
    Posts:
    251
    Minecraft User:
    RekkuzaRage
    I thought you couldn't define $config.
  7. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,294
    Plugins:
    11
    Minecraft User:
    PEMapModder
    You can. All variables can be defined. In this case, $config refers to the expression that resolves as your Config object, and it can be a variable called $config or whatever you like.
    For example:
    PHP:
    $config $this->getConfig();
    $config->set("a""b");
    Does the same thing as:
    PHP:
    $this->getConfig()->set("a""b");
    xiaoq and RekkuzaRage like this.
  8. CrazedMiner
    Offline

    CrazedMiner Notable Member Plugin Developer

    Joined:
    Jan 31, 2015
    Posts:
    348
    Plugins:
    2
    Minecraft User:
    CrazedMinerYT
    Would u want to save it when a player places a sign (SignPlaceEvent) or when a player interacts with a sign (PlayerInteractEvent)?
  9. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,294
    Plugins:
    11
    Minecraft User:
    PEMapModder
    Actualy, you don't even need to get the sign's tile object to get its coords. A Block (pocketmine\block\Sign) can already represent the position.

Share This Page

Advertisement