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

/surface Plugin Help

Discussion in 'Development' started by Indexfire, Jan 28, 2017.

  1. Indexfire

    Indexfire Baby Zombie

    Messages:
    137
    GitHub:
    Indexfire
    I made a plugin that teleports you to the surface when you type /surface but i have no idea how to get the highest block of the world

    PHP:
    <?php

    namespace Indexfire\SurfaceCommand

    use pocketmine\command\Command;
    use 
    pocketmine\command\CommandSender;
    use 
    pocketmine\Player;
    use 
    pocketmine\plugin\PluginBase;

    class 
    SurfaceCommand extends PluginBase{

      public function 
    onEnable(){


    getLogger()->info("Indexfire's first Plugin");

      }

    public function 
    onCommand(CommandSender senderCommand $cmdString labelString[] args){

         }

    if (
    $cmd->getName() == "surface" && sender instanceof Player)
    im stuck halfway can anyone help?
     
    Last edited: Feb 2, 2017
  2. xBeastMode

    xBeastMode Shog Chips

    Messages:
    0
    Are you sure you know what you're doing? Pocketmine is made in PHP not Java, therefore plugins must be written in PHP. In your code it seems that you're mixing Java with PHP and that's never going to work. There is a server software made in Java, which I am unable to mention here.
     
  3. Indexfire

    Indexfire Baby Zombie

    Messages:
    137
    GitHub:
    Indexfire
    Its Nukkit and wait isnt that in PHP
     
  4. xBeastMode

    xBeastMode Shog Chips

    Messages:
    0
    No, it's Java, but be careful mentioning other server softwares.
     
    Muqsit likes this.
  5. Indexfire

    Indexfire Baby Zombie

    Messages:
    137
    GitHub:
    Indexfire
    But i dont get it how is it Java?
     
  6. Junkdude

    Junkdude Zombie

    Messages:
    346
    GitHub:
    JunkDaCoder
    *Sigh* if your on nukkit, go to the nukkit forums. Java is different than php in different ways.
     
    Muqsit likes this.
  7. Indexfire

    Indexfire Baby Zombie

    Messages:
    137
    GitHub:
    Indexfire
    How is any of this Java its PHP
     
  8. Junkdude

    Junkdude Zombie

    Messages:
    346
    GitHub:
    JunkDaCoder
    Code:
    
    if (cmd.getName().equalsIgnoreCase("surface") && sender instanceof Player)
    This is java code bud
     
  9. Sandertv

    Sandertv Zombie Pigman Poggit Reviewer

    Messages:
    786
    GitHub:
    Sandertv
    You can get the highest block of the world at a position using $this->level->getHighestBlockAt($x, $z).
     
    Indexfire and Muqsit like this.
  10. Indexfire

    Indexfire Baby Zombie

    Messages:
    137
    GitHub:
    Indexfire
    I fixed it is it correct now?
     
  11. robske_110 (Tim)

    robske_110 (Tim) Wither Skeleton Poggit Reviewer

    Messages:
    1,342
    GitHub:
    robske110
    Sadly, no. PHP strings are no objects in that way. You cannot call functions on strings. You'll get a funny error message. (called blah on string) You should learn php a bit more. you can simply do == "surface" and if you want to ignore the case strtolower($cmd->getName()) == "surface"
     
  12. Indexfire

    Indexfire Baby Zombie

    Messages:
    137
    GitHub:
    Indexfire
    I fixed it again how about now
     
  13. HimbeersaftLP

    HimbeersaftLP Fish

    Messages:
    2,402
    GitHub:
    HimbeersaftLP
    LEARN PHP BEFORE CODING PLUGINS

    Variables in php have a $ before them e.g. $cmd
     
    Muqsit likes this.
  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.