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

Solved Position not found

Discussion in 'Development' started by SJames, May 2, 2019.

  1. SJames

    SJames Spider Jockey

    Messages:
    35
    GitHub:
    sjamese
    Hello!
    I need some help with my plugin. I am getting the error
    "Class 'SJames\UpCommand\Position' not found" (EXCEPTION) in "plugins/UpCommand/src/SJames/UpCommand/Main" at line 26
    PHP:
    Main file

    <?php
    namespace SJames\UpCommand;

    use 
    pocketmine\Blocks;
    use 
    pocketmine\Player;
    use 
    pocketmine\plugin\PluginBase;
    use 
    pocketmine\Server;
    use 
    pocketmine\command\Command;
    use 
    pocketmine\command\CommandSender;
    use 
    pocketmine\utils\TextFormat as c;use pocketmine\Vector3;

    class 
    Main extends PluginBase {
        public function 
    onEnable(){
        }
        public function 
    onCommand(CommandSender $playerCommand $cmdString $label, array $args) :bool {
            switch(
    $cmd->getName()){
                case 
    "up" ;
                    if(!(
    $player instanceof Player)){
                        
    $sender->sendMessage("Please run this command in-game.");
                    }else{
                      
    $x $player->getX();
                      
    $z $player->getZ();
                      
    $level $player->getLevel();
                      
    $y $args[0];
                      if(
    is_numeric($y)) {
                       
    $player->teleport(new Position($x$y$z)); //line 26
                       
    $level->setBlock(new Position($x$y-1$z), new Glass(), false);
                       } else {
                        
    $sender->sendMessage("Usage: /up {y-coordinates}");
                        return 
    true;
    }
    }
    }
    }
    }
     
  2. SavionLegendZzz

    SavionLegendZzz Slime

    Messages:
    75
    GitHub:
    savionlegends
    add this:
    Code:
    use pocketmine\level\Position;
     
    SJames likes this.
  3. SJames

    SJames Spider Jockey

    Messages:
    35
    GitHub:
    sjamese
    Oh, Thanks!
     
  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.