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

Class not found

Discussion in 'Facepalm' started by gsdgamer, May 7, 2017.

Thread Status:
Not open for further replies.
  1. gsdgamer

    gsdgamer Spider Jockey

    Messages:
    28
    Hi all, I don't know what i'm doing wrong but when I try starting up my plugin I get ClassNotFoundException: "Class SkyBlocks\Command not found"
    My Main.php is:
    Code:
    <?php
    
    namespace SkyBlocks;
    
    use pocketmine\plugin\PluginBase;
    use pocketmine\event\Listener;
    use pocketmine\utils\TextFormat;
    use SkyBlocks\Commands;
    use pocketmine\command\Command;
    
    
    class Main extends PluginBase implements Listener{
        
        public function onEnable(){
            $this->getServer()->getCommandMap()->register("Commands", new Command());
            if(!file_exists($this->getDataFolder() . "config.yml")){
                @mkdir($this->getDataFolder());
                file_put_contents($this->getDataFolder()."config.yml", $this->getResources("config.yml"));
            }
            $this->getServer()->getPluginManager()->registerEvents($this, $this);
            $this->getLogger()->info(TextFormat::GREEN . "Sky Blocks has been enabled.");
    Then my Command.php code is:
    Code:
    <?php
    
    namespace SkyBlocks;
    
    use pocketmine\level\Level;
    use pocketmine\math\Vector3;
    use pocketmine\command\CommandSender;
    use pocketmine\command\Command;
    use pocketmine\utils\TextFormat;
    use pocketmine\Player;
    
    class Commands {
        
        private $level;
        private $level2;
        private $minpos;
        private $maxpos;
        
        public function onCommand(CommandSender $sender, Command $cmd, $label, array $args){
            strtolower($cmd->getName() == "sb");
            if(!($sender instanceof Player)){
                $sender->sendMessage(TextFormat::RED . "Please use the command in game.");
            }
                if(!(isset($args[0]))){
                    $sender->sendMessage(TextFormat::RED . "Error: Type /sb help for info.");
            }elseif(isset($args[0]) && $sender->hasPermission("sb.setup")){
                switch($args){
                    case "pos1":
                            $sender->getPosition();
                            $this->minpos = new Vector3($sender->getX(),$sender->getY(),$sender->getZ());
                            $this->level = $sender->getLevel()->getName();
                            break;
    I just don't seem to be able to get it to find the class.
     
  2. Sandertv

    Sandertv Zombie Pigman Poggit Reviewer

    Messages:
    786
    GitHub:
    Sandertv
    Remove the s from the 'use Skyblocks\Commands' in the first file you showed, and remove the pocketmine\command\Command use statement.
     
  3. gsdgamer

    gsdgamer Spider Jockey

    Messages:
    28
    Ok done that but still getting the same thing. I bet it is something so simple but my brain is going no you're not gonna find it lol
     
  4. SOFe

    SOFe Administrator Staff Member PMMP Team Poggit Admin

    Messages:
    1,968
    GitHub:
    sof3
Thread Status:
Not open for further replies.
  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.